Inferensys

Prompt

Clinical Medication Reconciliation Extraction Prompt

A practical prompt playbook for extracting structured, normalized medication records from admission and discharge documentation using a Clinical Medication Reconciliation Extraction Prompt in production AI workflows.
Operations team reviewing AI workflow automation on laptop, workflow builder visible, casual office setup.
PROMPT PLAYBOOK

When to Use This Prompt

Defines the clinical context, ideal user, and operational boundaries for the medication reconciliation extraction prompt.

This prompt is designed for clinical pharmacists, care transition teams, and clinical data engineers who need to extract a structured Best Possible Medication History (BPMH) from unstructured clinical notes. It targets admission notes, discharge summaries, transfer documents, and medication administration records. The prompt produces normalized JSON records with medication name, dose, route, frequency, and a reconciliation status flag. It is built to handle PRN medications, tapered regimens, and intentional discontinuations.

This is not a general-purpose clinical extraction prompt. It assumes the input text contains medication information and that the output will be reviewed by a qualified clinician before any clinical decision. The prompt does not perform drug-drug interaction checks, allergy cross-referencing, or therapeutic duplication analysis. It will not catch clinical errors in the source documentation, nor will it flag medications that are contraindicated for the patient. The prompt's job is to faithfully structure what is stated in the text, not to interpret what should have been prescribed.

Use this prompt when you have a defined medication reconciliation workflow and need to convert free-text medication lists into a machine-readable format for downstream systems. Do not use this prompt on text that does not contain medication information, such as radiology reports or progress notes focused solely on physical exam findings. The prompt expects that each input document has already been identified as medication-relevant. If you need to first classify whether a document contains a medication list, pair this with a classification routing prompt before extraction.

The output schema is designed for direct ingestion into medication reconciliation modules, EHR data pipelines, or clinical data warehouses. Each extracted record includes a reconciliation_status field that flags whether the medication is continuing, discontinued, modified, or newly identified. This status is critical for care transition workflows where the goal is to identify discrepancies between what the patient was taking before admission and what is ordered at discharge. Always validate the extracted records against the source text and ensure a clinical pharmacist reviews the output before it is committed to any system of record.

PRACTICAL GUARDRAILS

Use Case Fit

Where this prompt works and where it does not. Understand the operational boundaries before embedding this extraction contract into a clinical workflow.

01

Good Fit: Structured Admission Notes

Use when: extracting medications from typed or dictated admission history and physicals with clear section headers. Guardrail: The prompt expects explicit medication lists; it performs best when the source document separates home medications from inpatient orders.

02

Bad Fit: Unstructured Narrative Summaries

Avoid when: the source is a free-text narrative without discrete medication sections, such as a social work note or a general progress note. Guardrail: Route these documents to a general entity extraction prompt first, then pass candidate spans to this specialized reconciliation prompt.

03

Required Inputs

Risk: Missing or incomplete source documents lead to silent omissions, not explicit nulls. Guardrail: The application layer must validate that both an admission and a discharge document are provided before invoking the prompt. Do not rely on the model to flag a missing document.

04

Operational Risk: Tapered Regimens

Risk: Complex instructions like steroid tapers or insulin sliding scales are often flattened into a single, incorrect row. Guardrail: Add a post-extraction validation rule that flags any medication with a frequency containing 'taper', 'titrate', or 'sliding scale' for mandatory human review.

05

Operational Risk: Intentional Discontinuations

Risk: The model may incorrectly classify a medication that was intentionally stopped as an active medication, or vice-versa. Guardrail: The output schema must include a reconciliation_status enum field. Implement a business rule that requires an explicit discontinuation_reason for any status of discontinued.

06

Operational Risk: PRN Medications

Risk: PRN medications without a documented indication or last administration time can be misrepresented as scheduled medications. Guardrail: The prompt must output a separate prn_details object. The application should quarantine any PRN record missing an indication field for pharmacist review.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A production-ready prompt template for extracting structured medication records from clinical notes and reconciling them against a pre-admission medication list.

This prompt template is designed to be dropped into an AI application that processes admission or discharge documentation. It forces the model to operate as a strict extraction engine, not a conversational assistant. The template uses square-bracket placeholders for all variable inputs—clinical note text, an optional pre-admission medication list, and a JSON output schema—so you can wire it directly into your data pipeline. The core instruction prohibits the model from inventing medications not present in the source text, which is the most common and dangerous failure mode in clinical extraction.

text
Extract a structured medication list from the clinical note below. Return only valid JSON matching the output schema. Do not invent medications not present in the text. For each medication, determine the reconciliation status by comparing the documented medication against the provided pre-admission medication list if available. Flag any discrepancies.

[INPUT]

[PRE_ADMISSION_MEDICATIONS]

[OUTPUT_SCHEMA]

[CONSTRAINTS]
- Do not add, remove, or modify medications.
- If a field is not explicitly stated in the text, set its value to null.
- For reconciliation status, use only the values: "continued", "discontinued", "dose_changed", "new", "held", or "unable_to_determine".
- If a pre-admission list is not provided, set reconciliation status to "unable_to_determine" for all medications.
- For PRN medications, include the indication in the frequency field if documented.
- For tapered regimens, capture the full taper schedule as a structured array in the dosage_instructions field.
- Flag any intentional discontinuations explicitly mentioned in the note.

To adapt this template, replace each bracketed placeholder with your application's runtime data. [INPUT] should contain the raw clinical note text. [PRE_ADMISSION_MEDICATIONS] should contain a structured list of the patient's medications before admission, or an empty string if unavailable. [OUTPUT_SCHEMA] should be your exact JSON schema definition, including field names, types, and enum values. The [CONSTRAINTS] section is critical for high-risk clinical workflows: it enforces null handling for missing data, restricts reconciliation statuses to a controlled vocabulary, and explicitly requires handling for PRN medications and tapered regimens—two common sources of extraction errors. Before deploying, validate that your schema includes fields for medication name, dose, route, frequency, PRN status, taper schedule, reconciliation status, discrepancy flags, and source text spans for auditability. Always pair this prompt with a JSON schema validator in your application layer and route any output that fails validation to a human review queue.

IMPLEMENTATION TABLE

Prompt Variables

Required inputs for the Clinical Medication Reconciliation Extraction Prompt. Each placeholder must be populated before the prompt is assembled and sent to the model. Validation notes describe how to check that the input is well-formed before execution.

PlaceholderPurposeExampleValidation Notes

[CLINICAL_DOCUMENT_TEXT]

Raw admission or discharge documentation containing medication lists, orders, and reconciliation notes

Admission Note: Patient arrived on 3/14 with home med list. Currently taking metformin 500mg PO BID, lisinopril 10mg PO daily, and atorvastatin 40mg PO at bedtime. Discontinued warfarin on admission per cardiology.

Check that text is non-empty and contains at least one medication reference. Reject if document is purely demographic or billing data with no clinical narrative.

[DOCUMENT_TYPE]

Specifies whether the source is an admission note, discharge summary, transfer note, or medication reconciliation form

discharge_summary

Must be one of: admission_note, discharge_summary, transfer_note, med_rec_form, progress_note, ed_note. Reject unrecognized values before prompt assembly.

[PATIENT_CONTEXT]

Known patient demographics and clinical context that may affect medication interpretation, such as age, weight, renal function, and allergies

Age: 72, Weight: 84kg, CrCl: 45mL/min, Allergies: sulfa, penicillin

Check that age and weight are numeric and non-negative. CrCl should be a positive number. Allergies field may be empty string if unknown but must not be null. Do not pass PHI beyond what is necessary for dose interpretation.

[OUTPUT_SCHEMA]

JSON schema definition that the extracted medication records must conform to

{"type":"object","properties":{"medications":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"dose":{"type":"string"},"route":{"type":"string"},"frequency":{"type":"string"},"status":{"enum":["active","discontinued","held","completed","unknown"]},"reconciliation_note":{"type":"string"}}}}}}

Validate that the schema is parseable JSON with a medications array. Each medication object must include name, dose, route, frequency, and status fields at minimum. Reject schemas missing the status enum.

[RECONCILIATION_RULES]

Domain rules for determining reconciliation status, such as intentional discontinuation criteria, hold reasons, and taper recognition patterns

Intentional discontinuation requires explicit documentation of reason. PRN medications marked as active only if administered within last 24 hours. Tapered regimens must capture current step and target step.

Check that rules are non-empty and reference at least: discontinuation criteria, PRN handling, and taper handling. Rules should be written as imperative statements the model can follow. Reject rules that contradict the output schema status enum.

[NORMALIZATION_REFERENCE]

Reference data for normalizing medication names, routes, and frequencies to standard terminologies

{"routes":{"PO":["oral","by mouth","per os"],"IV":["intravenous","IV push","IV drip"]},"frequencies":{"BID":["twice daily","twice a day","2x daily"],"QD":["daily","once daily","once a day"]}}

Validate that the reference is parseable JSON with at least routes and frequencies mappings. Each canonical term must map to a non-empty array of variants. Missing mappings are allowed but will reduce normalization quality.

[CONFIDENCE_THRESHOLD]

Minimum confidence score below which extracted medication records should be flagged for human review rather than auto-ingested

0.85

Must be a float between 0.0 and 1.0. Values below 0.7 are not recommended for clinical workflows. Reject non-numeric values. If set to 0.0, all records pass through without confidence gating.

[SOURCE_CITATION_REQUIRED]

Boolean flag indicating whether every extracted medication field must include a character-span citation back to the source document

Must be true or false. When true, the output schema must include a citation field per medication record. When false, citations are optional. For clinical reconciliation, true is strongly recommended.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Clinical Medication Reconciliation Extraction Prompt into a production application with validation, retries, and human review gates.

This prompt is designed to be called from an application layer that manages the full lifecycle: receiving admission or discharge documentation, assembling the prompt with the correct [INPUT_TEXT] and [FORMULARY_CONTEXT], calling the LLM, validating the structured output, and routing low-confidence or unreconciled records for pharmacist review. The prompt itself is stateless—it expects a single clinical document per call and returns a complete medication list. The application is responsible for batching multi-page documents, deduplicating medications across multiple calls, and merging results into the patient's medication history.

Validation and retry logic is critical because missing a discontinued medication or misinterpreting a tapered regimen can cause patient harm. After receiving the JSON output, validate that every medication object contains the required fields (medication_name, status, source_span). Check that status values are strictly from the allowed enum: active, discontinued, held, completed, PRN. For discontinued medications, verify that a discontinuation_reason is present or explicitly null with a confidence note. If validation fails, retry the prompt once with the validation errors appended to [CONSTRAINTS]. If the retry also fails, route the record to a human review queue with the original text, the failed output, and the specific validation errors highlighted. Do not silently drop failed extractions.

Confidence scoring and human review gates should be implemented in the application layer. Parse the confidence field from each medication record. Define a threshold (e.g., confidence < 0.85) below which the medication is flagged for pharmacist review. Additionally, any medication with reconciliation_status: unreconciled or reconciliation_status: conflict must be routed to a human reviewer, regardless of confidence. The application should present the original source text, the extracted medication record, and the specific ambiguity or conflict in a review UI that allows the pharmacist to confirm, edit, or reject the extraction. Log all human corrections to improve future prompt iterations and fine-tuning datasets.

Model choice and context window considerations: This prompt works best with models that have strong instruction-following and structured output capabilities (e.g., GPT-4o, Claude 3.5 Sonnet, or fine-tuned clinical models). The input document plus the prompt template typically consumes 2,000–8,000 tokens. If admission notes exceed the context window, chunk the document by section (e.g., 'Home Medications', 'Hospital Medications', 'Discharge Instructions') and run the prompt on each section independently, then merge and deduplicate by medication_name + source_span. For RAG-enhanced workflows, retrieve the patient's prior medication list and the hospital formulary as [FORMULARY_CONTEXT] to help the model normalize drug names and detect discrepancies. Always log the prompt version, model version, input document hash, and output JSON for audit trails—clinical systems require full traceability for every automated extraction.

IMPLEMENTATION TABLE

Expected Output Contract

Each extracted medication record must conform to this schema. Validate every field before ingestion. Reject or flag records that violate these rules.

Field or ElementType or FormatRequiredValidation Rule

medication_name

string

Must match a recognized generic or brand name from [FORMULARY_SOURCE]. Reject if empty or contains only punctuation.

dose

object { value: number, unit: string }

Unit must be from [DOSE_UNIT_ENUM]. Value must be > 0. Reject if value is null and medication is not explicitly discontinued.

route

string

Must be a value from [ROUTE_ENUM]. If route is not explicitly stated in the source text, set to 'unspecified' and set confidence to 'low'.

frequency

string

Must be a value from [FREQUENCY_ENUM]. For PRN medications, include the reason in [prn_reason]. For tapered regimens, use the [taper_schedule] array instead.

reconciliation_status

string

Must be one of: 'continued', 'discontinued', 'modified', 'held', 'new'. If status cannot be determined from explicit documentation, set to 'unable_to_determine' and flag for human review.

source_span

string

Must contain the exact text from the source document that supports this record. Reject if span is hallucinated or does not appear in [SOURCE_DOCUMENT].

discontinuation_reason

string or null

Required if reconciliation_status is 'discontinued'. Must be a value from [DISCONTINUATION_REASON_ENUM] or a direct quote from the source. Set to null for all other statuses.

confidence

string

Must be one of: 'high', 'medium', 'low'. Set to 'low' if any required field was inferred rather than directly extracted. Route 'low' confidence records to [HUMAN_REVIEW_QUEUE].

PRACTICAL GUARDRAILS

Common Failure Modes

What breaks first when extracting medication reconciliation records and how to guard against it in production.

01

Medication Name Hallucination

What to watch: The model invents plausible-sounding drug names or normalizes an ambiguous abbreviation to the wrong medication. This is especially dangerous with look-alike/sound-alike drugs (e.g., hydroxyzine vs hydralazine). Guardrail: Require exact string matching against a pre-approved formulary or RxNorm vocabulary. Flag any extracted medication name not found in the reference set for human review.

02

Dose and Frequency Misalignment

What to watch: The model extracts the correct dose but assigns it to the wrong frequency (e.g., '10mg daily' becomes '10mg BID') or misinterprets tapered regimens as static doses. PRN medications often lose their indication context. Guardrail: Validate dose-frequency pairs against clinical dosing rules. For tapered regimens, enforce a structured array output with explicit start/end dates and dose steps rather than a single free-text field.

03

Reconciliation Status Confusion

What to watch: The model fails to correctly classify medications as 'continued,' 'discontinued,' 'modified,' or 'new' when the clinical narrative is ambiguous. Intentional discontinuations with reasons are often misclassified as active medications. Guardrail: Require explicit evidence spans for every reconciliation status assignment. If the text does not clearly state the status, default to 'unclear' and route to a pharmacist for review rather than guessing.

04

Route and Form Drift

What to watch: The model normalizes administration routes incorrectly (e.g., 'sublingual' becomes 'oral') or drops the dosage form entirely (e.g., 'extended-release' omitted from 'metformin ER'). This can lead to clinically significant errors in downstream systems. Guardrail: Use a constrained enum for route and form fields. If the extracted value does not match an allowed term, return the raw text in a separate route_raw field and flag for mapping review.

05

Temporal Context Loss

What to watch: The model extracts a medication list but loses the temporal context—whether a medication was taken before admission, started during the stay, or prescribed at discharge. This flattens the reconciliation timeline into a single point-in-time list. Guardrail: Require a time_context field with allowed values ('pre-admission,' 'during-stay,' 'at-discharge') and enforce that every medication entry includes this field. If temporal context is ambiguous, flag for review.

06

Omitted PRN Indications

What to watch: PRN (as-needed) medications are extracted with dose and frequency but the clinical indication that justifies use is dropped (e.g., 'acetaminophen 650mg PO q6h PRN pain' becomes just 'acetaminophen 650mg PO q6h PRN'). This strips critical safety context. Guardrail: Add a dedicated prn_indication field to the output schema. If a medication is marked as PRN but no indication is found, flag the record as incomplete and do not suppress the PRN flag.

IMPLEMENTATION TABLE

Evaluation Rubric

Criteria for testing the quality of extracted medication reconciliation records before integrating them into downstream clinical systems or review queues.

CriterionPass StandardFailure SignalTest Method

Medication Name Normalization

All extracted medication names map to a single RxNorm ingredient or clinical drug form when available; brand names are resolved to generics.

Output contains raw, unmapped brand names or ambiguous abbreviations without a normalized form.

Run a spot check of 20 records against a reference terminology service; flag any unmapped or ambiguous entries.

Dose and Unit Extraction

Dose value and unit are extracted as separate, typed fields for every scheduled medication; null is explicitly returned for missing data.

Dose and unit are concatenated into a single string, or dose is missing for a medication that clearly has a stated dose in the source.

Validate JSON schema compliance; assert that dose is a number or null and unit is a string from a controlled vocabulary or null.

Route and Frequency Completeness

Route and frequency are populated for at least 90% of active, scheduled medications; PRN medications include the PRN reason if documented.

Route or frequency is missing for a medication where the source text explicitly states it; PRN flag is true but the reason field is empty.

Parse output with a schema validator; run a completeness check query that counts null route/frequency for active scheduled meds.

Reconciliation Status Accuracy

Each medication is classified into exactly one status: continued, discontinued, modified, or new; the status matches a clinician's review.

A medication is classified as continued when the source clearly states it was stopped; a single medication has multiple conflicting statuses.

Prepare a golden set of 10 admission/discharge note pairs with clinician-annotated statuses; assert exact match on status field.

Tapered Regimen Handling

Tapered medications include a structured schedule array with dose, duration, and sequence steps; free-text taper instructions are not used as a fallback.

Taper instructions appear only in a free-text notes field; the schedule array is empty or missing for a clearly documented taper.

Query output for medications with a taper flag set to true; assert that the schedule array is present and contains at least two steps.

Intentional Discontinuation Documentation

Discontinued medications include a discontinuation reason field populated from the source when explicitly stated; null is allowed when the reason is not documented.

A medication marked as discontinued has a hallucinated reason not present in the source text.

For a test set of 5 notes with known discontinuation reasons, assert that the reason field exactly matches a source span or is null when absent.

Source Citation Anchoring

Every extracted medication record includes a source document reference and a character span or section identifier for audit traceability.

A medication record is returned without any source pointer; citation points to a wrong section of the document.

Validate that every record in the output array has a non-null source field; manually verify 5 random citations against the original document.

Null vs. Missing Distinction

Fields not present in the source are null; fields explicitly stated as unknown or not applicable are marked with a controlled sentinel value.

A required field is an empty string instead of null; a field that the source says is unknown is incorrectly returned as null.

Run a schema validator that enforces null vs. sentinel value rules; spot-check 10 records for correct null/sentinel usage.

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Use the base prompt with a frontier model (GPT-4o, Claude 3.5 Sonnet) and a simplified output schema. Remove strict enum constraints for reconciliation status and medication route. Accept free-text fields for dose and frequency instead of requiring structured sub-objects. Start with 10-20 sample discharge summaries and iterate on the prompt until extraction accuracy is directionally correct.

Prompt modification

code
Extract medications from [CLINICAL_DOCUMENT]. For each medication, return:
- medication_name: string
- dose: string (free text, e.g., "10mg", "2 puffs")
- frequency: string (free text, e.g., "daily", "q6h PRN")
- route: string
- reconciliation_status: string (free text, e.g., "continued", "discontinued", "new")

Include PRN medications and tapered regimens. Note any ambiguous entries with a [NEEDS REVIEW] flag.

Watch for

  • Missing PRN medications that appear only in narrative text
  • Tapered regimens extracted as single flat entries instead of sequenced instructions
  • Intentional discontinuations misclassified as active medications
  • Free-text fields producing inconsistent downstream parsing
Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.