FHIR FactGuard is a zero-trust safety layer for the Prompt Opinion platform. It monitors and validates clinical decisions made by AI models by cross-referencing them with actual patient data (FHIR) and official medical standards (RxNorm) in real-time.
When LLMs are used in clinics, they sometimes make mistakes—like "hallucinating" treatments or missing critical details in a patient's history (allergies, past reactions, etc.). In a medical setting, a wrong prescription isn't just a bug; it's a serious risk. FactGuard was created to catch these errors before they reach a patient.
FactGuard sits as a "guardrail" on the message bus where AI agents talk to each other. When an agent suggests a clinical action (like prescribing a drug), FactGuard jumps in:
- Intercepts the message immediately.
- Normalizes the medication name using the RxNorm API so there's no ambiguity.
- Validates the suggestion against the patient's FHIR record to check for allergies or conflicts.
- Scores the risk using our Clinical Grounding Index (CGI). If things look shaky, it sends a BLOCK signal to stop the action and generates an Audit ID for full traceability.
The system is built with three main parts:
server.py: Our MCP server that handles the heavy lifting—like thevalidate_clinical_intentandget_clinical_provenancetools. We kept it light by using direct REST calls (httpx) to avoid bulky dependencies.safety_agent.py: The brains of the operation. It usespo_adk.A2aListenerto keep an eye on all clinical conversations.clinical_agent_sim.py: A quick simulator we use to show what happens when the system catches a risky prescription.
# 1. Grab the dependencies
pip install -r requirements.txt
# 2. Fire up the MCP server
python server.py
# 3. Start the safety agent
python safety_agent.py
# 4. Run the simulation to see it in action
python clinical_agent_sim.py