A rule-based clinical decision support system that classifies antenatal care (ANC) visit risk into GREEN / AMBER / RED - built with FastAPI, React, and a deterministic guideline-cited risk engine, for frontline health workers (ASHA/ANM) in India.
Instead of relying on an AI model to guess whether a pregnancy is high-risk (which is unreliable and unauditable in a clinical setting), NeoSure applies deterministic clinical thresholds to ANC visit data and classifies risk into three tiers:
| Risk Level | Meaning | Example Trigger |
|---|---|---|
| 🟢 GREEN | No high-risk indicators | Normal BP, Hb ≥ 11 g/dL, no danger signs |
| 🟡 AMBER | Some risk indicators present | Moderate anemia, borderline BP, bad obstetric history |
| 🔴 RED | High-risk, urgent attention required | Severe anemia, severe hypertension, any danger sign, pre-eclampsia |
Every rule that fires carries a citation back to the specific clinical guideline that justifies it (MoHFW Anemia Mukt Bharat, PMSMA High-Risk Conditions in Pregnancy, FOGSI Routine Antenatal Care Guideline) - so the classification is explainable, not a black box.
Beyond a single visit, the engine also looks across a patient's visit history to catch patterns a single reading can't show - a value that's persistently abnormal across visits, one that's swinging unpredictably, or a one-off reading that's since resolved.
| Feature | Description |
|---|---|
| Deterministic risk engine | Hard-coded clinical thresholds for hemoglobin, blood pressure, danger signs, obstetric history, infection screening, fetal/placental concerns, and chronic conditions - no probabilistic AI in the classification path |
| Guideline citations | Every flag maps to a real source document and quoted rationale |
| Confidence scoring | Reflects both rule certainty and data completeness |
| Trend analysis | Detects persistent vs. fluctuating vs. resolved abnormalities across visits |
| Multi-user auth | Each ASHA/ANM worker has their own account; patient data is scoped per user |
| Pregnancy lifecycle tracking | Obstetric history locks after the first visit of a pregnancy; completed pregnancies are archived (view-only); a new pregnancy under the same RCH ID starts a fresh cycle |
| Auto-scheduled ANC visits | Implements India's minimum 4-visit ANC schedule and surfaces due/overdue/upcoming patients automatically |
| Referral & logistics workflow | RED classifications auto-create a referral to the facility with the most free capacity for the specific bed type needed (ICU/HDU/NICU/General); ANM progresses it through a real status pipeline with timestamped logs |
| Pre-arrival clinical alert | Structured vitals + reason-for-referral payload generated the moment a referral goes "in transit" |
| PDF report export | Full patient summary or single-visit report, regenerated fresh on every download - includes every field captured, guideline citations, and clinician notes |
| Read-only threshold reference | A page showing the exact numeric thresholds the engine uses, so the logic is inspectable without reading code |
| Accessibility | Dark mode, adjustable text size, English/Kannada/Hindi language toggle |
| Layer | Technology |
|---|---|
| Backend | FastAPI (Python) |
| Risk Engine | Custom rule-based classifier (deterministic, not ML) |
| Database | SQLite via SQLAlchemy ORM |
| Auth | Token-based sessions, PBKDF2 password hashing |
| PDF Generation | fpdf2 |
| Frontend | React (Vite), React Router |
| Styling | Plain CSS (custom design system, no framework) |
git clone https://github.com/YOUR_USERNAME/neosure.git
cd neosurecd backend
python -m venv venv
# Windows
venv\Scripts\activate
# Mac/Linux
source venv/bin/activate
pip install -r requirements.txt
uvicorn app.main:app --reload --port 8000The API is live at http://localhost:8000 (interactive docs at /docs). The SQLite database is created automatically on first run.
In a second terminal:
cd frontend
npm install
npm run devOpen the URL Vite prints (usually http://127.0.0.1:5173). The dev server proxies /api/* requests to the backend on port 8000.
Register a new account from the login screen, then start adding patients via "New Registration." Each account's patient data is private to that account.
| Category | Fields |
|---|---|
| Patient Identity | Full name, RCH ID, age, phone number, LMP date |
| Vitals | Height, weight, blood pressure, fetal heart rate |
| Labs | Hemoglobin, Rh status, HIV/syphilis screening, urine protein/sugar |
| Medical History | Previous C-section, bad obstetric history, chronic hypertension, diabetes, thyroid, smoking/tobacco/alcohol use |
| Obstetric History | Gravida, inter-pregnancy interval, prior stillbirths/abortions, twin pregnancy |
| Fetal Observations | Malpresentation, placenta previa, reduced fetal movement, amniotic fluid, Doppler |
| Current Symptoms | Headache, visual disturbance, epigastric pain, decreased urine output, vaginal bleeding, convulsions |
The classification logic is intentionally not machine learning - a probabilistic model has no place deciding whether a pregnancy is flagged high-risk in a clinical safety context. Instead:
- Thresholds are hard-coded from real guideline documents (e.g., hemoglobin < 7 g/dL = severe anemia per Anemia Mukt Bharat; BP ≥ 160/110 mmHg = severe hypertension per PMSMA).
- Every flag returned by the engine includes
{code, label, severity, guideline, citation}- fully traceable to its source. - A confidence score (0–1) reflects how complete the input data was and how certain the triggering rule is (a danger sign is near-certain; a borderline single reading is less so).
- Trend analysis compares the current visit against the patient's recent history to distinguish a resolved one-off issue from a persistent or fluctuating problem.
This design keeps the system auditable: any classification can be traced back to an exact numeric threshold and its source document, rather than an AI-generated explanation after the fact.
- No real ambulance GPS tracking - referral status is confirmed manually by the health worker as it progresses.
- No real receiving-hospital dashboard - the "pre-arrival clinical alert" generates and stores the data payload that would be transmitted, but there's no second application on the hospital side to receive it.
- Guideline citations are a curated static lookup, not live retrieval-augmented generation over a full document corpus.
- Dark mode and font scaling use CSS
zoom, which isn't supported in Firefox. - Kannada/Hindi translation currently covers navigation, dashboard, and Settings - not yet the full assessment wizard.
- Real retrieval (FAISS/Chroma) over the full source guideline PDFs, replacing the static citation lookup
- Receiving-hospital-side dashboard to consume the clinical alert payload
- SMS/paging integration for the notification toggles already in Settings
- Full multi-language coverage across the assessment wizard
- Postgres migration for multi-district deployment
- Role-based access for supervisors overseeing multiple health workers
- Clinical thresholds referenced from MoHFW's Anemia Mukt Bharat guidelines, the PMSMA High-Risk Conditions in Pregnancy document, and FOGSI's Routine Antenatal Care Guideline.
- UI design system built from scratch (cream/terracotta palette, Playfair Display + Inter typography).