File size: 2,195 Bytes
5dcfc5c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
46
47
48
49
50
51
52
53
54
55
56
import importlib
from typing import Any


def test_protocol_guidance_returns_json_and_evidence_panel(monkeypatch: Any) -> None:
    app = importlib.import_module("app")
    retrieved_cards = [
        {
            "card_id": "PED-DEHYD-RED-FLAGS-v1",
            "title": "Pediatric dehydration red flags",
            "score": 8.5,
            "source": "json_fallback",
            "snippet": "Reported lethargy matched red flag wording.",
            "card": {
                "card_id": "PED-DEHYD-RED-FLAGS-v1",
                "title": "Pediatric dehydration red flags",
                "escalation_criteria": [
                    "Any listed red flag requires urgent or emergency escalation according to local protocol."
                ],
                "safety_boundary": (
                    "Prototype protocol navigation card for trained-responder review only."
                ),
            },
        },
        {
            "card_id": "SAFETY-BOUNDARIES-v1",
            "title": "Safety boundaries",
            "score": 3.0,
            "source": "json_fallback",
            "card": {
                "card_id": "SAFETY-BOUNDARIES-v1",
                "title": "Safety boundaries",
                "safety_boundary": "Prototype evidence only; not a medical device.",
            },
        },
    ]
    monkeypatch.setattr(app, "search_protocol_cards", lambda query: retrieved_cards)

    json_cards, evidence_panel = app._retrieve_with_evidence_ui(
        {
            "setting": "shelter clinic",
            "chief_concern": "vomiting and dehydration concern",
            "symptoms": "lethargic, very dry mouth",
        }
    )

    assert json_cards == retrieved_cards
    assert "Prototype evidence/source material" in evidence_panel
    assert "PED-DEHYD-RED-FLAGS-v1" in evidence_panel
    assert "Pediatric dehydration red flags" in evidence_panel
    assert "urgent or emergency escalation according to local protocol" in evidence_panel
    assert "score=8.50" in evidence_panel
    assert "Reported lethargy matched red flag wording." in evidence_panel
    assert "SAFETY-BOUNDARIES-v1" in evidence_panel
    assert "not a medical device" in evidence_panel