Inspiration

In Nigeria, a large share of women who attend antenatal care (ANC) visits still do not deliver in a health facility — a gap in the data known as the "ANC Paradox," backed by NDHS (Nigeria Demographic and Health Survey) data. Facility delivery is one of the strongest predictors of safe maternal outcomes, so a woman attending ANC but planning a home delivery is a real, addressable risk signal that's easy to miss without automated support. As a statistician working in Nigerian healthcare data for 15+ years, I've seen this pattern in real hospital records — this project is my attempt to catch it automatically, before it becomes an emergency.

What it does

MaternaGuard is a four-agent pipeline that:

  1. Scouts ANC patient records from a live FHIR R4 server for the ANC-Paradox pattern (adequate ANC attendance, no confirmed facility delivery plan)
  2. Scores flagged patients against maternal health risk factors
  3. Explains the risk in plain, non-clinical language a community health worker can read directly to a patient's family
  4. Acts by writing the assessment back to the FHIR server as a real, auditable clinical observation

Every step of every run is logged with a real UTC timestamp to a job-history file, so the full execution trail is inspectable end-to-end — not just a demo screenshot.

How I built it

  • NVIDIA Nemotron 3 (Nano for high-volume triage/scoring, Ultra for the reasoning-heavy explanation step) served via Nebius Token Factory
  • CliniqBridge, my own FHIR R4 MCP server, connecting the pipeline to real patient data via the Model Context Protocol (JSON-RPC)
  • Python orchestration layer with per-agent retry/backoff and structured audit logging
  • Deployed and tested against a live FHIR server end-to-end, including real writes confirmed by read-back

Challenges I ran into

  • CliniqBridge's actual tool schema turned out to require a known patient_id per call rather than a bulk "list all patients" query, so I had to redesign the candidate-fetching logic around known patient IDs instead of a live search
  • Confirming real field names and data shapes required testing against the live server rather than assuming a schema — several early assumptions about field names (e.g. display vs observation) turned out wrong and had to be corrected against real responses
  • CliniqBridge returns tool results as Python dict-repr strings (single quotes) rather than valid JSON, which silently broke standard JSON parsing until I switched to ast.literal_eval — a subtle bug that looked like "no data" rather than a parsing failure, caught only by directly inspecting a real tool response
  • CliniqBridge's create_observation only reliably accepts numeric values, not free text, discovered by testing a text-valued write against a real LOINC code and comparing the failure to a direct FHIR server call that succeeded with the same payload
  • Render's free-tier cold starts caused early timeouts against the live CliniqBridge server; fixed by extending the request timeout

Accomplishments I'm proud of

  • A genuinely working read AND write loop against a real FHIR server, not just a mock — confirmed via write-then-read-back verification
  • Clean separation of reasoning load across model tiers: fast/cheap steps on Nano, the one step that needs deep reasoning (turning a risk score into a culturally appropriate explanation) on Ultra
  • A real, timestamped end-to-end run on NVIDIA Nemotron 3 via Nebius Token Factory: Scout (Nemotron 3 Nano) correctly flagged a patient with 6 ANC visits, 35 weeks gestation, and a recorded home-delivery intent; Risk Agent (Nano) scored her 0.88 using real lab values already in her record (HbA1c 12.5%, indicating uncontrolled hyperglycemia); Explain Agent (Nemotron 3 Ultra) produced a clear, actionable, non-clinical message a community health worker could read directly to the family; Action Agent wrote the finding back to the FHIR server as Observation/137805220 - a real, independently verifiable record

What's next for MaternaGuard

  • Live UCTH (University of Calabar Teaching Hospital) patient data integration, pending ethics approval
  • SentinelCall integration for automated voice follow-up on flagged patients (building on my earlier SentinelCall hackathon project)
  • Expanding beyond the ANC Paradox to other NDHS-derived maternal risk signals

Built With

  • fastapi
  • fhir-r4
  • healthcare-ai
  • json-rpc
  • mcp
  • model-context-protocol
  • multi-agent-systems
  • nebius-token-factory
  • nvidia-nemotron-3
  • python
Share this project:

Updates

Submission history