Overview
Clinical systems expose patient data via FHIR R4 APIs (Epic, Cerner, etc.). If medguard can pull a patient's current medication list from a FHIR server, it can check the LLM query against the full medication profile — not just drugs mentioned in the message.
What to build
medguard/integrations/fhir.py — FHIRMedicationLoader
get_medications(patient_id, fhir_base_url, token) → list[str] drug names
- Parses
MedicationRequest and MedicationStatement FHIR resources
- Uses
httpx (already a dependency)
MedGuard.achat(message, fhir_context=None) — optional FHIR context
- When
fhir_context provided, drug safety checks include FHIR medications + message drugs
FHIR endpoint example
GET {base}/MedicationRequest?patient={id}&status=active
Authorization: Bearer {token}
Files to create/modify
medguard/integrations/fhir.py — new file
medguard/core.py — accept optional fhir_context in achat
medguard/guardrails/drug_safety.py — merge FHIR drugs with extracted drugs
Acceptance criteria
Resources
Overview
Clinical systems expose patient data via FHIR R4 APIs (Epic, Cerner, etc.). If medguard can pull a patient's current medication list from a FHIR server, it can check the LLM query against the full medication profile — not just drugs mentioned in the message.
What to build
medguard/integrations/fhir.py—FHIRMedicationLoaderget_medications(patient_id, fhir_base_url, token)→list[str]drug namesMedicationRequestandMedicationStatementFHIR resourceshttpx(already a dependency)MedGuard.achat(message, fhir_context=None)— optional FHIR contextfhir_contextprovided, drug safety checks include FHIR medications + message drugsFHIR endpoint example
Files to create/modify
medguard/integrations/fhir.py— new filemedguard/core.py— accept optionalfhir_contextinachatmedguard/guardrails/drug_safety.py— merge FHIR drugs with extracted drugsAcceptance criteria
FHIRMedicationLoader.get_medications(...)parses FHIR MedicationRequest JSONResources