Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions tests/cases/controller/case_controller_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,75 @@ def test_get_case_review(client, session, mocker):
assert data == expected


def test_get_case_review_with_physical_exam_filtering(client, session, mocker):
"""Test that PHYSICAL EXAMINATION items are filtered based on path_config"""
input_case(session)

# Config with PHYSICAL EXAMINATION items in path_config
config = DisplayConfig(
user_email="[email protected]",
case_id=1,
id="2",
path_config=[
{"path": "BACKGROUND.Patient Demographics.Age"},
{"path": "BACKGROUND.Patient Demographics.Gender"},
{"path": "PHYSICAL EXAMINATION.Vital signs.Pulse rate"}, # Only keep Pulse rate
]
)
session.add(config)

session.add(
SystemConfig(
id="page_config",
json_config={
"BACKGROUND": {
"Family History": [4167217],
"Social History": {
"Smoke": [4041306],
"Alcohol": [4238768],
"Drug use": [4038710],
"Sexual behavior": [4283657, 4314454],
},
},
"PATIENT COMPLAINT": {
"Chief Complaint": [38000282],
"Current Symptoms": [4034855],
},
"PHYSICAL EXAMINATION": {
"Vital Signs": [4263222],
"Abdominal": [4152368],
},
},
)
)
session.flush()

mocker.patch(
"src.user.utils.auth_utils.validate_jwt_and_refresh", return_value=None
)
mocker.patch(
"src.cases.service.case_service.get_user_email_from_jwt",
return_value="[email protected]",
)

response = client.get(f"/api/case-reviews/{config.id}")

assert response.status_code == 200
data = response.get_json()["data"]

# Physical examination should only have "Pulse rate" since that's in path_config
phys_exam = next((d for d in data["details"] if d["key"] == "PHYSICAL EXAMINATION"), None)
assert phys_exam is not None

# Should have Vital signs section
vital_signs = next((v for v in phys_exam["values"] if v["key"] == "Vital signs"), None)
assert vital_signs is not None

# Vital signs should only have "Pulse rate"
assert len(vital_signs["values"]) == 1
assert vital_signs["values"][0]["key"] == "Pulse rate"


def expected_json():
with open("tests/cases/controller/expected_response.json") as f:
return json.load(f)
Expand Down
Loading