The problem
- Each new patient arrives with intake questionnaires, symptom scores, lab reports and the doctor’s own notes, spread across PDFs, spreadsheets and scans.
- Building one treatment plan meant reading all of it, pulling protocols from reference books, writing the diet plan and supplement schedule, and checking the numbers. That took 1 to 2 hours per patient.
- A general chatbot gave different answers to the same patient on different days, sounded nothing like the doctor, kept no audit trail, and required patient details to be removed by hand before every use.
- Every hour spent assembling a plan was an hour away from patients and from the creative clinical work the doctor does best.
What we built: the treatment plan pipeline
A competent clinical AI application is mostly engineering around the model. These are the twelve parts we built, from the first PDF to the approved plan.
Step 1
Three-tier document extraction
PDFs are read from the text layer first, then with local OCR for scanned pages, then with a vision model only when needed. Patient details are masked and confirmed before any page leaves the machine.
Step 2
Structural chunking
Reference books and protocols are split by their own headings and layout, into chunks of 239 to 1,043 tokens that keep 60 to 98 percent of the source text. An earlier pattern-based method kept 13 percent and was replaced.
Step 3
Structured clinical extraction
Recipes, supplements, protocols and templates become structured rows with ingredients, timing, servings and clinical tags. Every row links back to the chunk it came from.
Step 4
Diagnosis-tagged knowledge
Every chunk is tagged with the clinical domains it applies to at upload. Eight treatment categories form a controlled vocabulary, so a patient’s plan draws on knowledge for that patient’s presentation.
Step 5
Graph-linked retrieval
Knowledge chunks, recipes, supplements, treatment categories and past approved plans are linked to each other. Retrieval follows those links with full-text search and local embeddings, so similar past patients inform the next plan.
Step 6
One clinical picture per patient
A single builder reads intake responses, provider notes from every visit, and structured lab results into one patient picture. Every part of the app reads the same truth.
Step 7
Context engineering
The prompt is assembled in named slots, each with its own token budget, inside a 13,130 token input limit. Truncation is logged, never silent, and the assembled context can be dumped for review.
Step 8
Grounded numbers from external sources
Nutrition macros come from USDA FoodData Central: each ingredient is parsed, matched, converted to grams and summed with a confidence score. The model never invents a number.
Step 9
The doctor’s voice
The doctor answered 25 questions about how he thinks and writes. A voice library and his own rules shape every plan, with sentences that do not sound like him flagged for review.
Step 10
Source traceability
Every supplement, protocol and recipe in a plan shows the patient data that triggered it and the knowledge it came from. Provenance and confidence are stored for every extracted fact.
Step 11
Approval before anything is used
The plan generator drafts the test review, diet plan and supplement protocol. The doctor edits and approves. Approved plans become knowledge for the next similar patient.
Step 12
Private by design
A local model runs on the practice’s own computer. Patient documents never enter the shared knowledge library, and nothing leaves the building without the expert’s approval.
Results
- From 1 to 2 hours to minutes. Each treatment plan arrives as a complete draft built from the patient’s own records. The doctor reviews and approves.
- Two more patients a month. The time returned went back onto the calendar. The practice reports an average of two more patients a month.
- Same patient, same answer. Plans are built from one clinical picture and one curated library, so they stay consistent from day to day.
- Every number can be defended. Macros trace to USDA data and every recommendation traces to its source in the library.
- More time for the creative clinical work. Assembly moved to the system. Judgment, creativity and the patient relationship stayed with the doctor.
The ROI
Time per plan
1 to 2 hours
Down to minutes of review and approval
Every 10 plans
10 to 20 hours
Returned to patient care
New patients
+24 a year
Two more patients a month, on average
More patients seen is more revenue, from hours that used to go into assembling documents. The practice decides what each new patient is worth. The system gives back the time to see them.
Second healthcare build: research intelligence for a specialist physician
A specialist physician at an academic medical center tracks drug safety and hospital reimbursement news for two newsletters and his consulting work. Reading every publisher, database and filing by hand every day was not possible. We built a private research desk that does the reading, keeps the citations, and leaves every editorial decision with him. Pulling articles, checking every citation for accuracy and putting each issue together used to take 3 hours. The system now does that work and he reviews.
3 hours
saved on each newsletter: pulling articles, checking citations and accuracy, assembling the issue
19
publisher feeds scanned daily
3
official databases: PubMed, ClinicalTrials.gov, openFDA
2
newsletters from one engine, every item cited
Daily source scan
19 publisher feeds plus official APIs for PubMed, ClinicalTrials.gov and openFDA, and securities filings for material drug safety disclosures. Each source fails on its own without stopping the scan.
Keyword signal matching
Twelve monitoring terms chosen by the physician find the articles that matter. Every match is stored with its own article link, never just the publisher.
Signal cards for curation
Matches arrive as cards with a short summary and the full citation. The physician picks what goes in, and nothing reaches a reader unreviewed.
Two newsletters, one engine
A drug safety newsletter and a hospital revenue and reimbursement newsletter, each with its own sources, prompts and settings.
A knowledge wiki that compounds
Every approved signal is written into a wiki page tagged by drug, source and topic, with local embeddings for search. Knowledge grows with every approval instead of starting from zero each query.
The physician’s voice
Summaries are shaped by his answers to 25 questions about how he thinks and writes, stored in the app where he can edit them.
Consulting invoices from the calendar
A forwarded meeting invite is detected, matched to the client, and turned into an invoice after he confirms prep hours.
Self-service settings
Keywords, sources, model choice and account connections are controls in the app, so changes never wait on a developer.
Governance and data privacy, built in
Both builds run on the practice’s own computers. Governance is part of the architecture, written into the code and checked before every release.
A hard boundary for cloud calls
Public sources may be sent to a cloud model for prose. The physician’s voice, wiki, approved work and patient records never are. The boundary is enforced in code where the request is assembled.
Masking before anything leaves
Patient names and dates are stripped before any cloud call. The masked text is shown for confirmation first, and every cloud call is logged.
Separate databases by purpose
The expert’s knowledge and voice, the day-to-day records, and the audit trail live in separate databases, backed up and migrated independently.
An audit trail of every event
Extractions, generations, approvals and cloud calls are recorded with time and source, so any output can be traced after the fact.
Patient documents stay scoped
Patient records are stored per patient and never enter the shared knowledge library.
Provenance and confidence
Every extracted fact keeps its source document, page and chunk. Low-confidence items route to the clinician for review.
Numbers from authoritative sources
Nutrition, drug and lab figures come from external reference data. A model never invents a quantity.
A human approves every output
Plans, summaries and newsletters are drafts until the clinician approves them.
The same pipeline works across healthcare
Any practice where an expert reads documents and writes a plan can run the same pipeline: extract, chunk, tag, retrieve, ground the numbers, draft in the expert’s voice, and approve.
Functional and integrative medicine
Intake, labs and notes into one picture, with protocols drafted from the practitioner’s own library.
Private AI for healthcare practicesPhysical therapy and rehab
Evaluations and progress notes into exercise plans written in the clinician’s voice.
Private AI for healthcare practicesDietitians and nutrition practices
Meal plans with macros grounded in USDA data, built from a curated recipe library.
Expertise captureSpecialist physicians
Research, newsletters and patient education drafted from cited literature in the physician’s voice.
Private AI for healthcare practicesCoaching and wellness
Assessments and session notes into plans and follow-ups in the coach’s voice.
Coaching case studyAny expert-led practice
Wherever an expert turns documents into a written plan, the same pipeline applies.
Agents for small and medium businessesFrequently asked questions
Does the AI decide the treatment?
No. It drafts the plan from the patient’s records and the practice’s own library. The doctor reviews, edits and approves every plan.
Where does patient data live?
On the practice’s own computer. A local model does the work. Patient details are masked before any cloud call, and nothing leaves the building without the expert’s approval.
What is context engineering?
Deciding exactly what the model sees for each plan: the patient picture, the right knowledge chunks, the doctor’s voice rules and past plans, each within a fixed token budget.
What is graph-linked retrieval?
Knowledge, recipes, supplements, treatment categories and approved plans are connected to each other, so retrieval follows the links that matter for this patient.
Where do the nutrition numbers come from?
USDA FoodData Central. The model never generates a macro, a dose or a lab value on its own.
What did the second healthcare build do?
It scans publisher feeds, PubMed, ClinicalTrials.gov and openFDA every day, matches the physician’s keywords, and turns approved signals into two cited newsletters. It saves 3 hours on each newsletter.
Which data can go to a cloud model?
Only public sources, and only for prose. The clinician’s knowledge, voice and patient records stay on the practice’s computer.
How much time does it save?
Building a plan by hand took 1 to 2 hours. A draft now takes minutes, and every 10 plans return 10 to 20 hours.