π©Ί CoDeX(CovidβDengue eXpert) - Dual Expert System for COVID-19 vs Dengue Differential Diagnosis
A hybrid expert system implementing two complementary classical AI approaches: rule-based reasoning (deterministic) and Bayesian probabilistic inference for differential diagnosis between COVID-19 and Dengue, tailored to the Argentine epidemiological context in dengue-endemic regions (2025).
π€ AI-Assisted Development: This project was designed and developed with the assistance of Generative Artificial Intelligence. It serves as a dual case study: it implements classical AI techniques (rule-based systems + probabilistic reasoning) while demonstrating how modern AI tools can accelerate complex software development in the medical-academic domain.
- Deterministic Agent: Rule-based system with forward chaining and weighted scoring
- Probabilistic Agent: Bayesian network with 13 nodes and 16 causal dependencies
- Intelligent Consensus: Complementary results with full reasoning traceability
- Medical Form: Direct capture of 16 clinical-epidemiological parameters
- Conversational Chat: Step-by-step guided triage with adaptive logic
- Advanced Visualization: Interactive decision tree with React Flow + inference traces
- 2025 protocols from the Argentine Ministry of Health + PAHO
- 6 differential diagnosis rules with calibrated weights
- 3 alarm signs with automatic urgent referral
- Fuzzy fever logic (low-grade/high/hyperpyrexia)
- Endemic areas: Corrientes, Misiones, Formosa, Chaco
- Seasonality: Higher dengue incidence in summer (Aedes aegypti)
- Risk factors: travel to Brazil, contact with confirmed cases
Architecture: Pure Python implementation of forward chaining inference engine (no expert system libraries).
Knowledge Base (backend/data/reglas_infectologia.json):
-
6 differential diagnosis rules with calibrated weights:
retro_orbital_pain: +5 Dengue, -1 COVID β Classic arbovirus symptomcough: +2 COVID, -2 Dengue β Upper respiratory symptomanosmia: +7 COVID, -2 Dengue β Highly specific for COVID-19myalgia: +4 Dengue, +1 COVID β "Breakbone fever"dengue_contact: +10 Dengue β Strongest predictor in active outbreaks
-
2 contextual rules:
- Corrientes + Summer: +5 Dengue (endemic zone + high Aedes aegypti season)
- Corrientes + Other seasons: +2 Dengue (endemic zone, lower vector activity)
-
3 alarm signs with urgent referral:
- Intense abdominal pain β plasma extravasation (severe dengue)
- Mucosal bleeding β evaluate platelets/hematocrit
- Dyspnea β COVID pneumonia, Oβ saturation check
Inference Algorithm:
- Perception: Maps patient data to internal evidence
- Weighted Scoring: Accumulates points per activated rule
- Fuzzy Fever Logic:
- 37.0-37.9Β°C: low-grade fever (+0 dengue)
- 38.0-39.5Β°C: high fever (+2 dengue)
- β₯39.6Β°C: hyperpyrexia (+3 dengue)
- Severity Assessment: Detects alarm signs with maximum priority
- Differential Classification:
if score_dengue > score_covid + 3: return "SUSPICIOUS OF DENGUE (High Probability)" elif score_covid > score_dengue + 3: return "COMPATIBLE WITH COVID-19" else: return "REQUIRES DIFFERENTIAL DIAGNOSIS"
- Traceability: Generates human-readable trace of every fired rule
Example Trace:
START: Fever detected (40.2Β°C) β Initial scores
Applying R_RETROOCULAR β Dengue +5, COVID -1
Context: Corrientes + Summer β Dengue +5
Fuzzy Logic: 40.2Β°C β HYPERPYREXIA (Dengue +3)
FINAL SCORES: Dengue 23 vs COVID 3
DIAGNOSIS: SUSPICIOUS OF DENGUE (High Probability)
Architecture: DAG (Directed Acyclic Graph) with 13 nodes, 16 edges implemented using pgmpy.
Network Structure:
Root Nodes (Context):
Season β Dengue
Location β Dengue
Travel β Dengue
Contact β Dengue
Disease Nodes:
COVID (independent - global circulation)
Dengue (depends on 4 contextual factors)
Symptom Nodes (observed evidence):
Fever β {Dengue, COVID}
Cough β {Dengue, COVID}
SoreThroat β {Dengue, COVID}
RetroOrbitalPain β {Dengue, COVID}
Myalgia β {Dengue, COVID}
Anosmia β {Dengue, COVID}
Dyspnea β {Dengue, COVID}
Key Conditional Probability Tables (CPDs):
- Baseline Prevalence: P(COVID) = 5%, P(Dengue | default) = 1%
- Contextual Dengue: P(Dengue | Contact=Yes) = 85%, P(Dengue | Travel=Yes) = 55%
- Discriminant Symptoms:
- P(Anosmia | COVID=Yes, Dengue=No) = 85% (highly specific)
- P(RetroOrbital | Dengue=Yes, COVID=No) = 80% (classic dengue)
- P(Cough | COVID=Yes, Dengue=No) = 80% (upper respiratory)
Inference: Variable Elimination algorithm applies Bayes' Theorem recursively, propagating evidence to disease nodes and returning posterior probabilities P(COVID|Evidence) and P(Dengue|Evidence).
16-Question Dynamic Flow:
- Base Symptoms (4): Fever, Temperature (conditional), Retro-orbital pain, Cough
- Differentiators (5): Sore throat, Myalgia, Anosmia, Alarm signs (3 combined)
- Epidemiological Context (6): Location, Season, Brazil travel, Dengue contact, Medical history (asthma, hypertension)
Adaptive Logic: Temperature question only appears if fever=Yes (conditional rendering).
Session Management: RESTful API with UUID-based sessions (/chat/start, /chat/{session_id}/message).
Final Output: After 16 questions, both engines run and return deterministic classification + Bayesian probabilities + full inference trace + interactive decision tree.
- Python 3.10+, Node.js 20+, npm
Create and activate virtual environment:
# Create virtual environment
python -m venv venv
# Activate on Windows
venv\Scripts\activate
# Activate on Linux/Mac
source venv/bin/activateInstall dependencies and run:
pip install -r requirements.txt
python -m uvicorn backend.main:app --reloadβ
Backend running at http://localhost:8000 (API docs: /docs)
cd frontend
npm install
npm run devβ
Frontend running at http://localhost:3000
- Open
http://localhost:3000 - Choose mode:
- π Form: Direct 16-field input
- π¬ Chat: Step-by-step conversational triage
- View dual results: deterministic classification + Bayesian probabilities + inference trace + decision tree
Input: Temp 40.5Β°C, retro-orbital pain, myalgia, Corrientes+Summer, dengue contact
Output:
- Deterministic: "SUSPICIOUS OF DENGUE" (Score 23 vs -1)
- Probabilistic: Dengue 99.99%, COVID 0.01%
Input: Temp 38.2Β°C, cough, sore throat, anosmia, CABA+Winter
Output:
- Deterministic: "COMPATIBLE WITH COVID-19" (Score 9 vs 0)
- Probabilistic: COVID 99.81%, Dengue 0.19%
Input: Temp 39.8Β°C, retro-orbital pain, intense abdominal pain, mucosal bleeding
Output:
- Deterministic: "SEVERE DENGUE CASE (Alarm Signs)"
- Action: "
β οΈ MEDICAL EMERGENCY - IMMEDIATE REFERRAL"
tp3_prototipo1/
βββ backend/
β βββ main.py # FastAPI endpoints
β βββ agents/
β β βββ deterministic.py # Rule-based engine with scoring
β β βββ probabilistic.py # Bayesian network (pgmpy)
β β βββ conversational.py # Chat logic (16 questions)
β βββ data/
β βββ reglas_infectologia.json # Medical knowledge base
βββ frontend/
β βββ app/
β β βββ page.tsx # Main page (tabs: form/chat)
β βββ components/
β β βββ diagnostic-form.tsx # 16-field medical form
β β βββ chat-interface.tsx # Conversational interface
β β βββ diagnostic-results.tsx # Results visualization
β β βββ decision-tree.tsx # Interactive tree (React Flow)
β βββ lib/
β βββ i18n.ts # Internationalization (ES/EN)
βββ requirements.txt
βββ README.md
- Argentine Ministry of Health (2025 Protocols)
- PAHO - Dengue Guidelines
- Scientific papers: COVIDENGUE Score, arbovirus differential diagnosis
6 Differential Diagnosis Rules:
- Retro-orbital pain: +5 Dengue (classic arbovirus)
- Cough: +2 COVID (upper respiratory)
- Anosmia: +7 COVID (highly specific)
- Intense myalgia: +4 Dengue ("breakbone fever")
- Epidemiological link: +10 Dengue (strongest predictor)
2 Contextual Rules:
- Corrientes + Summer: +5 Dengue (endemic zone + Aedes aegypti season)
- Corrientes + Other seasons: +2 Dengue (endemic zone, lower vector)
3 Alarm Signs:
- Intense abdominal pain β URGENT (plasma extravasation)
- Mucosal bleeding β URGENT (platelets/hematocrit)
- Dyspnea β RESPIRATORY (COVID pneumonia, Oβ saturation)
- Knowledge Representation: IF-THEN rules with numeric weights
- Inference Engine: Forward chaining
- Search Strategy: Breadth-first in rule space
- Conflict Resolution: Priority by accumulated weights
- Explainability: Full trace of fired rules
- Bayes' Theorem: P(Disease|Symptoms) = P(Symptoms|Disease) Γ P(Disease) / P(Symptoms)
- Conditional Independence: Symptoms independent given disease
- Exact Inference: Variable Elimination algorithm
- Advantage: Rigorous uncertainty handling + Bayesian updating
| Aspect | Deterministic | Probabilistic |
|---|---|---|
| Output | Categorical classification | Probability distribution |
| Explainability | High (full trace) | Medium (probabilities) |
| Maintenance | Easy (JSON editable) | Complex (CPD calibration) |
| Uncertainty | Not formally handled | Mathematical rigor |
| Speed | O(n) rules | O(exponential in tree-width) |
| Clinical Use | Quick triage | Epidemiological research |
This project is part of a university assignment for the Artificial Intelligence course (Computer Science Degree, UNNE - Argentina).
License: MIT (free educational use)
Citation:
Dual Expert System for COVID-19 vs Dengue Differential Diagnosis
National University of the Northeast, Faculty of Exact Sciences
2025 - Developed with Generative AI Assistance
- Argentine Ministry of Health (public protocols)
- PAHO/WHO (epidemiological guidelines)
- pgmpy community (Bayesian network library)
- shadcn/ui (React components)
- Claude AI (Anthropic) for development assistance