File size: 1,538 Bytes
aefac4f
 
696f787
aefac4f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9659593
aefac4f
 
 
 
9659593
 
 
 
aefac4f
 
9659593
aefac4f
 
 
 
 
 
 
 
 
9659593
aefac4f
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import sys
from pathlib import Path

sys.path.insert(0, str(Path(__file__).parent.parent / "api"))

from app.services.ragbot import RagBotService


def test_format_response_uses_synthesizer_payload():
    service = RagBotService()
    workflow_result = {
        "final_response": {
            "biomarker_flags": [
                {
                    "name": "Glucose",
                    "value": 120,
                    "unit": "mg/dL",
                    "status": "HIGH",
                    "reference_range": "70-100 mg/dL",
                    "warning": None,
                }
            ],
            "safety_alerts": [],
            "key_drivers": [],
            "disease_explanation": {"pathophysiology": "", "citations": [], "retrieved_chunks": None},
            "recommendations": {"immediate_actions": [], "lifestyle_changes": [], "monitoring": []},
            "confidence_assessment": {"prediction_reliability": "LOW", "evidence_strength": "WEAK", "limitations": []},
            "patient_summary": {"narrative": ""},
        },
        "biomarker_flags": [],
        "safety_alerts": [],
    }

    response = service._format_response(
        request_id="req_test",
        workflow_result=workflow_result,
        input_biomarkers={"Glucose": 120},
        extracted_biomarkers=None,
        patient_context={},
        model_prediction={"disease": "Diabetes", "confidence": 0.6, "probabilities": {}},
        processing_time_ms=10.0,
    )

    assert response.analysis.biomarker_flags[0].name == "Glucose"