Replace Fragile Automations with Production-Grade Python Workflows
Python scripts running on AWS Lambda manage patient intake, scheduling, and billing communication. This provides HIPAA-compliant logging and handles complex conditional logic impossible with GUI-based tools.
The scope of a custom build depends on the EMR system in use and the number of communication touchpoints. Connecting to a modern EMR with a well-documented API is straightforward. A system that needs to parse PDF referrals or connect to legacy billing software requires a more involved discovery process.
We built a communication system for a 3-location physical therapy practice with 15 therapists. They were manually emailing intake forms and appointment reminders for 400 new patients per month. The new system went live in 4 weeks, reducing front-desk admin time by 10 hours per week.
What Problem Does This Solve?
Many clinics start by connecting their web form builder to an email service using a connector tool. The problem is that these tools charge per 'task'. A single new patient inquiry can trigger 5-10 tasks: log to a spreadsheet, send an email, create a calendar event, and notify staff. At 20 new patients per day, this becomes 100-200 tasks, quickly exceeding free tiers and pushing monthly bills into the hundreds for one workflow.
A physical therapy clinic in Austin with 8 therapists tried to automate appointment reminders. They set up a workflow to check their EMR's Google Calendar export every 15 minutes for upcoming appointments. This polling interval meant reminders were often sent late, at 23 hours and 45 minutes before an appointment, causing patient confusion. The tool could not check the EMR's database directly to see if a patient had already confirmed, leading to redundant messages.
These GUI-based tools also create HIPAA compliance challenges. Patient data passes through third-party servers with opaque logging, making it difficult to produce a clear audit trail for Protected Health Information (PHI). Furthermore, complex clinical logic, like sending a different follow-up survey based on the CPT code of the patient's last visit, is impossible. The workflows can branch but cannot reference historical data from a separate system in the same step.
How Does It Work?
We start by connecting directly to the clinic's EMR, often a system like Jane App or WebPT, via their API. We build a client using Python's httpx library to pull patient records and appointment schedules. All credentials and PHI are managed securely using AWS Secrets Manager. We map the entire patient journey, from form submission to post-treatment survey, which involves processing an average of 1,200 patient records for a mid-sized clinic.
The core logic is built as a set of Python functions within a FastAPI application. An appointment reminder function queries a Supabase view of upcoming appointments and sends personalized SMS messages via the Twilio API. This direct query runs in under 500ms, eliminating 15-minute polling cycles. We use Pydantic for data validation to ensure patient data from the EMR matches expected formats, reducing data entry errors by over 90%. All communication is logged to a HIPAA-compliant table in Supabase, creating a full audit trail.
These FastAPI endpoints are deployed as serverless functions on AWS Lambda. This architecture is cost-effective; a clinic handling 5,000 patient interactions per month typically sees an AWS bill under $30. The intake form processor is a Lambda function triggered by an API Gateway webhook. It parses the form, creates a preliminary patient record in the EMR, and notifies the front desk via a secure Slack message, all in under 2 seconds. The entire build and deployment takes a 3-week cycle.
We implement structured logging using structlog for every transaction. Logs are sent to AWS CloudWatch. We set up specific alarms, for example, if the Twilio API fails to send an SMS more than 3 times in 5 minutes, an alert is sent to a designated staff member. This proactive monitoring catches issues before patients are impacted.
What Are the Key Benefits?
HIPAA Compliance with an Audit Trail
Every patient interaction is logged directly to your Supabase database. You get a complete, auditable record of what PHI was accessed and when.
Under $30/mo Hosting, Not $300/mo
Serverless deployment on AWS Lambda means you pay only for what you use. A typical clinic's monthly cost is less than a single premium SaaS subscription.
You Own The Code and Infrastructure
The entire system is deployed in your AWS account and the code is in your GitHub repository. You are not locked into a proprietary platform.
Real-Time Triggers, Not 15-Minute Delays
Workflows run instantly via webhooks from your EMR. Patient intake processing completes in under 2 seconds, not after a polling delay.
Connects Directly to Your EMR API
We build direct integrations with your EMR (e.g., Jane App, WebPT) and other tools like Twilio. No more relying on brittle spreadsheet exports or email parsing.
What Does the Process Look Like?
System Mapping (Week 1)
You provide read-only API access to your EMR and other tools. We deliver a detailed workflow diagram mapping every patient communication touchpoint to be automated.
Core Logic Build (Week 2)
We write the Python functions for each workflow step. You receive access to a private GitHub repository to review the code as it's developed.
Deployment & Testing (Week 3)
We deploy the system on AWS Lambda in your account and connect it to your live systems. We process 10-20 test patients to verify every step.
Monitoring & Handoff (Week 4)
We monitor the live system for one week to resolve any issues. You receive a runbook with deployment instructions, monitoring dashboards, and an operational guide.
Frequently Asked Questions
- How much does a custom patient communication system cost?
- Pricing is based on the number of distinct workflows and the complexity of the EMR integration. A system with intake, reminders, and follow-ups for a common EMR like Jane App is a standard engagement. Integrating with a legacy, on-premise system with no API requires more custom work. We provide a fixed-price quote after our discovery call.
- What happens if our EMR updates its API and something breaks?
- The system alerts us if API calls to the EMR fail consistently. During the initial 4-week engagement, we fix this at no cost. After handoff, we offer an ongoing maintenance plan that covers API changes, dependency updates, and on-call support. Most API changes are minor and can be fixed within a few hours.
- How is this different from hiring a marketing agency to set up ActiveCampaign?
- Marketing automation tools are not built for clinical workflows or PHI. They lack HIPAA compliance and direct EMR integration. ActiveCampaign cannot trigger a workflow based on a specific CPT code from a patient's visit. We build a production system that lives inside your secure infrastructure, not a marketing tool.
- Can we make changes to the workflows ourselves later?
- Yes. The system is built with standard Python, FastAPI, and AWS Lambda. Any competent Python developer can understand and modify the code. The runbook we provide includes instructions for common changes, like altering the text of an SMS reminder or adding a new question to a follow-up survey. You have full ownership.
- What data do you need from us to start?
- We need read-only API keys for your EMR, your email/SMS provider, and any form builders. We also need documentation of your current manual processes. We never store patient health information on our own systems; all processing happens within your secure AWS environment during the build.
- Our clinic uses a custom-built EMR. Can you integrate with it?
- If your EMR has a REST or SOAP API, we can almost certainly integrate. If it has no API, we can sometimes work with database exports or other data access methods, but this increases complexity. The first step in our discovery process is always a technical review of your EMR's integration capabilities to confirm feasibility.
Related Solutions
Ready to Automate Your Small Business Operations?
Book a call to discuss how we can implement ai automation for your small business business.
Book a Call