@@ -65,6 +65,75 @@ def test_get_case_review(client, session, mocker):
6565 assert data == expected
6666
6767
68+ def test_get_case_review_with_physical_exam_filtering (client , session , mocker ):
69+ """Test that PHYSICAL EXAMINATION items are filtered based on path_config"""
70+ input_case (session )
71+
72+ # Config with PHYSICAL EXAMINATION items in path_config
73+ config = DisplayConfig (
74+ 75+ case_id = 1 ,
76+ id = "2" ,
77+ path_config = [
78+ {"path" : "BACKGROUND.Patient Demographics.Age" },
79+ {"path" : "BACKGROUND.Patient Demographics.Gender" },
80+ {"path" : "PHYSICAL EXAMINATION.Vital signs.Pulse rate" }, # Only keep Pulse rate
81+ ]
82+ )
83+ session .add (config )
84+
85+ session .add (
86+ SystemConfig (
87+ id = "page_config" ,
88+ json_config = {
89+ "BACKGROUND" : {
90+ "Family History" : [4167217 ],
91+ "Social History" : {
92+ "Smoke" : [4041306 ],
93+ "Alcohol" : [4238768 ],
94+ "Drug use" : [4038710 ],
95+ "Sexual behavior" : [4283657 , 4314454 ],
96+ },
97+ },
98+ "PATIENT COMPLAINT" : {
99+ "Chief Complaint" : [38000282 ],
100+ "Current Symptoms" : [4034855 ],
101+ },
102+ "PHYSICAL EXAMINATION" : {
103+ "Vital Signs" : [4263222 ],
104+ "Abdominal" : [4152368 ],
105+ },
106+ },
107+ )
108+ )
109+ session .flush ()
110+
111+ mocker .patch (
112+ "src.user.utils.auth_utils.validate_jwt_and_refresh" , return_value = None
113+ )
114+ mocker .patch (
115+ "src.cases.service.case_service.get_user_email_from_jwt" ,
116+ 117+ )
118+
119+ response = client .get (f"/api/case-reviews/{ config .id } " )
120+
121+ assert response .status_code == 200
122+ data = response .get_json ()["data" ]
123+
124+ # Physical examination should only have "Pulse rate" since that's in path_config
125+ phys_exam = next ((d for d in data ["details" ] if d ["key" ] == "PHYSICAL EXAMINATION" ), None )
126+ assert phys_exam is not None
127+
128+ # Should have Vital signs section
129+ vital_signs = next ((v for v in phys_exam ["values" ] if v ["key" ] == "Vital signs" ), None )
130+ assert vital_signs is not None
131+
132+ # Vital signs should only have "Pulse rate"
133+ assert len (vital_signs ["values" ]) == 1
134+ assert vital_signs ["values" ][0 ]["key" ] == "Pulse rate"
135+
136+
68137def expected_json ():
69138 with open ("tests/cases/controller/expected_response.json" ) as f :
70139 return json .load (f )
0 commit comments