AI Clinical Documentation

Building Trial Recruitment Automation from EHR Data

Minhaj Ali
Minhaj Ali
Clinical AI, AST
Aug 9, 202610 min read
Two people stand near a glass-walled hospital workspace with notes and a closed laptop on the table, seen from behind in soft window light.
TL;DR The fastest way to automate clinical trial recruitment is not to start with a large language model and hope it “understands” the chart. I build the system the other way around: normalize EHR data, phenotype patients with explicit rules, run AI only where it adds value, and keep the outreach layer separate from research access. That separation is what keeps the workflow usable, auditable, and IRB-safe.

I have been in enough live care workflows to know the first bad assumption: people think trial matching is a model problem. It is not. It is a data quality problem, a consent problem, a workflow problem, and only then an AI problem.

When teams ask AST to help build recruitment automation, I start with the failure modes we have already seen in production-style healthcare software. A diagnosis buried in a free-text note. Lab values coming through in different units. Medication history split across Epic, scanned PDFs, and an outside feed. A coordinator who trusts the match list half the time and manually rebuilds it the other half. That is the real system. If you do not design for that mess, your AI matching layer becomes decorative.

TL;DR Build the pipeline as four separated layers: ingest EHR data, phenotype eligibility with FHIR-aware logic, score candidates with AI, and route only IRB-approved contact actions to outreach. The best systems do not expose raw charts to recruiters, and they do not let the model make final eligibility decisions. They reduce the coordinator’s drag without turning research ops into a compliance headache.

I learned this the hard way in a workflow prototype that looked great in demo and fell apart the moment we loaded real encounter history. The system was confidently matching patients based on one recent note while missing a contraindication that lived in an imported problem list record. That mistake changed how I design these systems: if the gold standard is “the model read the chart,” you are already in trouble. The gold standard is “the system built a reviewable candidate package from structured data first.”

Key Insight: The right architecture does not try to make EHR data look perfect. It assumes the EHR is uneven, uses FHIR R4 and HL7v2 where they help, and builds a deterministic phenotype layer before any AI scoring. AI then ranks and explains candidates; it does not invent eligibility from scratch.

Start with the data you can defend

Before you talk about embeddings or retrieval, decide what sources are allowed into the recruitment engine. I keep the source layer small on purpose:

  • Structured demographics from the EHR.
  • Problems, diagnoses, allergies, medications, procedures, encounters, and labs.
  • FHIR R4 resources where the vendor supports reliable extraction.
  • HL7v2 feeds for event-driven updates when they are already part of the hospital’s interface stack.
  • Carefully scoped note text only where the protocol actually needs it.

The reason is simple: every additional source multiplies your ambiguity. If you let the model ingest every possible note, fax, and attachment on day one, you will spend your time auditing exceptions instead of recruiting patients.

At AST, we usually wire this as a clinical data layer that normalizes source feeds into a common patient record before matching starts. That may sound pedestrian, but it is the part that stops the whole thing from wobbling. We have had projects where one vendor sent medication starts as timestamps and another sent date-only values. That looks minor until eligibility depends on whether treatment started before a protocol cutoff. Then it matters a lot.


How I structure the matching engine

I split matching into three distinct passes.

  1. Phenotype the cohort deterministically Convert protocol criteria into machine-readable inclusion and exclusion logic. Age, diagnosis, recent lab thresholds, encounter recency, medication exposure, and procedure history belong here. This is the gate that removes obvious non-matches.
  2. Use AI for fuzzy interpretation Allow the model to read messy elements such as note text, pathology snippets, or ambiguous clinical phrasing. The model can suggest similarity, presence, or risk of mismatch, but it never overrides hard exclusions.
  3. Produce an auditable candidate packet Every match needs a trace: which criteria were satisfied, which were uncertain, what source value was used, and which reviewer approved outreach. If the system cannot explain itself, it is not ready for a real site.

This is where a lot of teams get seduced by “AI matching.” They want a single score. I do not. A single score hides the reason a patient is eligible, and that is exactly what coordinators need when they call a principal investigator or answer site questions.

Warning: Do not let a model send first-touch outreach directly from a raw chart search. If you skip reviewer gating, you will eventually contact the wrong patient, misstate eligibility, or surface protected information to the wrong workflow path. That is not a tuning problem. It is a system design failure.

The practical pattern is to keep the phenotype layer boring and strict. Then build the AI layer to do what humans are bad at: reading loosely structured content, ranking borderline candidates, and summarizing why this patient belongs on the review queue. If you want a service boundary analogy, this is exactly the sort of workflow we build in our clinical AI systems: model output is useful only when the downstream process knows how to distrust it safely.

IRB-safe data flows are the backbone, not paperwork

This part matters more than people want it to. Trial recruitment sits at the intersection of treatment data and research operations, which means your access model needs to be narrow, logged, and purposeful.

I design the flow like this:

  • Clinical data is ingested into a secured matching workspace.
  • The system computes eligibility inside that restricted environment.
  • Recruiters and coordinators see only the minimum necessary candidate summary.
  • Any patient outreach request is routed through an approved template and contact workflow.
  • Audit trails preserve who viewed what, when, and why.

If the study requires an honest broker, de-identification, or consent checkpoint before outreach, that step belongs in the workflow engine, not in a policy PDF nobody reads. I have seen teams build a technically impressive matcher and then bolt on manual spreadsheet exports for “safety.” That is usually how data leaks and confusion sneak back in.

AST has had to design around this exact tension in live clinical environments: keep the operations team productive without giving them broader access than they need. In practice, that means partitioning the system into a matching service, a review surface, and an outreach service. The matching service can see more than the outreach team. The outreach team can act only after review approval. That separation feels slower at first. It is the reason the system survives contact with compliance.

Pro Tip: Write eligibility logic as a versioned artifact tied to the protocol schedule, not as scattered application code. When the protocol changes, you want to diff criteria and rerun matches without guessing which engineer touched which branch of logic six weeks ago.

FHIR phenotyping is useful, but only if you respect the gaps

FHIR R4 is a strong foundation for this work because it gives you clean resource boundaries: Patient, Observation, Condition, MedicationRequest, Procedure, Encounter, and DocumentReference. The trap is assuming every EHR exposes those resources consistently enough for production trial matching. They do not.

When we build around FHIR, we treat it as the canonical access pattern where possible, then backfill edge cases with other interfaces or vendor-native extracts. The matching core should not care whether a lab moved through FHIR Observation or a transformed feed from an interface engine. It should care that the value was normalized, provenance was preserved, and the unit conversion is unambiguous.

That distinction matters because phenotyping fails in quiet ways. A lab cutoff off by one unit. A diagnosis coded in a local terminology variant. A medication exposure that looks current until you notice it is just a med list artifact. The machine does not know which of those is clinically binding unless you teach it.

How AST Handles This: We map protocol criteria to an intermediate phenotype schema first, then bind each criterion to one or more source concepts and validation rules. That gives us a stable matching layer even when one hospital is on Epic, another on Oracle Health, and a third has enough HL7v2 history to make every assumption fragile.

A practical build sequence I would use this week

  1. Choose one protocol Do not build for “all trials.” Pick a study with clear inclusion and exclusion logic and enough volume to test review burden.
  2. Write the eligibility map Convert the protocol into structured criteria. Mark each criterion as hard, soft, or notes-only.
  3. Inventory your data sources Decide exactly which EHR objects, feeds, and documents are allowed into the matcher.
  4. Normalize and timestamp everything Align units, code systems, and temporal rules before scoring.
  5. Separate review from outreach The matching output should feed a coordinator queue, not a send button.
  6. Log explanation artifacts Keep the source facts, rule hits, and AI rationale together for audit and QA.
  7. Run shadow mode Compare system matches with manual coordinator picks before you automate any patient contact.

If you do not run shadow mode, you are betting your workflow on assumptions you have not tested. We have learned that the easiest way to break a recruitment product is to skip the quiet months where the system proves whether it can find patients the way coordinators actually work.

ApproachWhat it does wellWhere it breaksMy take
Rules onlyTransparent eligibility checksMisses messy chart language and borderline casesNecessary, but not enough
AI onlyFinds semantic patterns in notesWeak on hard exclusions and auditabilityToo risky for live recruitment
Rules plus AIDefensible gating with flexible rankingNeeds careful governance and data normalizationThis is the version I would ship

Patient outreach should feel operational, not creepy

Once a candidate is approved, outreach becomes a product design problem. The message has to be accurate, minimal, and approved by the study workflow. It should not reveal sensitive detail in a first pass. It should not overstate eligibility. It should not pretend the system has made a clinical promise.

I always tell teams the same thing: the automation does not replace the coordinator’s judgment, it removes the repetitive searching. That difference matters. Coordinators are not there to babysit a machine. They are there to interpret context, handle exceptions, and make the last-mile judgment that software should never fake.

We have seen better adoption when the system presents the candidate with the reason they were surfaced, the specific protocol criteria they seem to satisfy, and a simple next action. The moment a recruiter has to reverse-engineer the logic, trust falls apart. And once trust goes, the “automation” quietly turns into another tab people ignore.

How do I keep clinical trial matching HIPAA-safe when using EHR data?
Keep the matching workspace separated from outreach, minimize access by role, log every view and action, and move only approved candidate summaries into the recruiter workflow. Do not expose raw chart data to people who only need contact status and eligibility reasons.
Can FHIR R4 alone support trial phenotyping?
Sometimes, but not reliably across all vendors. FHIR R4 is a strong access layer for core resources like Condition and Observation, but most real deployments need fallback handling for vendor quirks, interface feeds, and document text.
Should the AI decide final eligibility for a trial?
No. The AI should rank, extract, and explain. Final eligibility should be based on explicit protocol logic and reviewer approval, especially when exclusion criteria or consent requirements are involved.
How do I handle patient outreach after a match is found?
Route outreach through an approved workflow with template control, review gating, and audit logging. The contact step should be separated from the matching step so you can prove what was inferred, what was approved, and what was sent.
What is the best first pilot for trial recruitment automation?
Pick one protocol with clear criteria, enough candidate volume, and a coordinator team willing to review shadow-mode results. Start small enough that your team can inspect every miss and every false positive without drowning.

The most counterintuitive thing I have seen is that the strongest matching systems feel less magical than people expect. They are narrower, more boring, and more explainable than the demo-driven version. That is not a weakness. That is what gets them used in a live clinic and not just admired in a meeting.

At AST, we build these systems as integrated engineering pods, not as a pile of features thrown over the wall. That matters because recruitment automation touches data pipelines, workflow design, and compliance at the same time. If you tackle only one of those layers, the product leaks in the other two.

Build trial recruitment automation that coordinators can trust

If you are trying to turn EHR data into a usable recruitment engine, start with defensible phenotyping, then layer AI where it helps the reviewer instead of replacing them. We build the data flow, the matching logic, and the outreach workflow as one system so it can survive real clinical operations.

Talk to our clinical AI team

Minhaj Ali
Minhaj Ali
Clinical AI, AST
Minhaj ships ambient documentation and coding-assist systems inside live care networks, where the model is the easy part and the workflow is the engineering.

Comments

Comments are warming up. Live, no-sign-in discussion will appear here shortly.

Have a question now? Email info@allstartech.net.

Get in touch
Work with AST

Embed a vetted engineering pod into your team and ship clinical software faster — without cutting a compliance corner.

Book a consultation
Careers at AST

We hire engineers who want to work inside real healthcare problems — EMR, FHIR, clinical AI and the compliance that holds it together.

See open roles