Skip to main content
← Monday's Prompts

Automate Patient Intake 🚀

Turn Monday's 3 prompts into production-ready code

April 15, 2025
17 min read
⚕️ Healthcare🐍 Python + TypeScript⚡ 0 → 5000 patients/day

The Problem

On Monday you tested the 3 prompts in ChatGPT. Awesome! You saw how extraction → validation → questions works. But here's the thing: you can't ask your staff to copy-paste 500 times per day. One nurse spending 2 hours running prompts manually? That's $60/day in labor costs. Multiply that across a busy clinic and you're looking at $18,000/year just on intake admin. Plus the copy-paste errors that lead to incomplete charts.

2+ hours
Per day running prompts manually
40% error
From copy-paste mistakes
Can't scale
Beyond 10-20 patients/day

See It Work

Watch the 3 prompts chain together automatically. This is what you'll build.

Watch It Work

See the AI automation in action

Live Demo • No Setup Required

The Code

Three levels: start simple, add reliability, then scale to production. Pick where you are.

Basic = Quick startProduction = Full featuresAdvanced = Custom + Scale

Simple API Calls

Good for: 0-100 patients/day | Setup time: 15 minutes

Simple API Calls
Good for: 0-100 patients/day | Setup time: 15 minutes
# Simple API Calls (0-100 patients/day)
import openai
import json
import os
from typing import Dict, List, Optional
from datetime import datetime

# Set your API key
openai.api_key = os.getenv('OPENAI_API_KEY')

def automate_patient_intake(patient_text: str) -> Dict:
    """Chain the 3 prompts: extract → validate → question"""
    
    # Step 1: Extract patient data
    extraction_prompt = f"""Extract patient symptoms and demographics from this intake text and format as JSON.
Showing 15 of 103 lines

When to Level Up

1

Simple API Calls

  • Direct OpenAI/Claude API calls
  • Basic retry logic
  • Simple JSON validation
  • Manual review of all outputs
Level Up
2

Add Reliability

  • Exponential backoff retries
  • Structured logging (Winston/Python logging)
  • Rate limiting
  • Async processing with queues
  • 10% human review sampling
Level Up
3

Framework with Orchestration

  • Multi-step workflows with LangGraph
  • AWS Comprehend Medical for PHI detection
  • Conditional routing based on completeness
  • EHR/FHIR integration
  • HIPAA-compliant logging
  • Automated quality checks
Level Up
4

Multi-Agent System

  • Multiple specialized agents (extraction, validation, triage)
  • Load balancing across API providers
  • Real-time EHR sync
  • Advanced PHI redaction
  • Compliance monitoring dashboard
  • 24/7 automated processing

Healthcare-Specific Gotchas

Real issues you'll hit. Here's how to handle them.

PHI Redaction Before LLM

Use AWS Comprehend Medical to detect and redact PHI before sending to LLM

Solution
import boto3

comprehend = boto3.client('comprehendmedical')

def redact_phi(text: str) -> str:
    response = comprehend.detect_phi(Text=text)
    entities = response['Entities']
    
Showing 8 of 18 lines

HIPAA Logging Requirements

Log every API call with patient ID, user ID, timestamp, action

Solution
import logging
import json

logger = logging.getLogger(__name__)

def log_hipaa_access(patient_id: str, user_id: str, action: str, data: dict):
    logger.info('HIPAA_ACCESS', extra={
        'patient_id': patient_id,
Showing 8 of 14 lines

Medical Abbreviation Handling

Pre-process text to expand common abbreviations before extraction

Solution
MEDICAL_ABBREVS = {
    'SOB': 'shortness of breath',
    'CP': 'chest pain',
    'HA': 'headache',
    'N/V': 'nausea and vomiting',
    'HTN': 'hypertension',
    'DM': 'diabetes mellitus',
    'GERD': 'gastroesophageal reflux disease'
Showing 8 of 15 lines

EHR Integration (Epic/Cerner FHIR)

Use FHIR API to create/update Patient and Observation resources

Solution
from fhir.resources.patient import Patient
from fhir.resources.observation import Observation
import requests

def sync_to_ehr(extracted_data: dict, ehr_base_url: str, auth_token: str):
    # Create FHIR Patient resource
    patient = Patient(
        name=[{"family": extracted_data['patient_name'].split()[-1],
Showing 8 of 34 lines

Patient Consent Management

Store consent records in database, check before processing

Solution
from sqlalchemy import Column, String, Boolean, DateTime
from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()

class PatientConsent(Base):
    __tablename__ = 'patient_consents'
    
Showing 8 of 23 lines

Adjust Your Numbers

500
105,000
5 min
1 min60 min
$50/hr
$15/hr$200/hr

❌ Manual Process

Time per patient:5 min
Cost per patient:$4.17
Daily volume:500 patients
Daily:$2,083
Monthly:$45,833
Yearly:$550,000

✅ AI-Automated

Time per patient:~2 sec
API cost:$0.02
Review (10%):$0.42
Daily:$218
Monthly:$4,803
Yearly:$57,640

You Save

0/day
90% cost reduction
Monthly Savings
$41,030
Yearly Savings
$492,360
💡 ROI payback: Typically 1-2 months for basic implementation
⚕️

Want This Running in Your Clinic?

We build custom healthcare AI systems. HIPAA-compliant, EHR-integrated, production-ready. From prompts to deployed code in 2 weeks.

©

2026 Randeep Bhatia. All Rights Reserved.

No part of this content may be reproduced, distributed, or transmitted in any form without prior written permission.