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
25 changes: 13 additions & 12 deletions src/cases/service/case_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,9 @@ def get_nodes_of_measurement(self, case_id, title_config):
children_measurements, lambda m: m.measurement_concept_id
)
for concept_id, rows in measurements_by_concept.items():
# Special handling for BMI - change title from 'centile' to 'range'
if concept_id == 40490382:
concept_name = "BMI (body mass index) range"
else:
concept_name = self.get_concept_name(concept_id)

parent_node.add_node(
TreeNode(
concept_name,
self.get_concept_name(concept_id),
get_value_of_rows(rows, self.get_value_of_measurement),
)
)
Expand Down Expand Up @@ -403,11 +397,7 @@ def get_case_review(self, case_config_id): # pragma: no cover
# Filter child.values - handle both string lists and TreeNode lists
if child.values and isinstance(child.values[0], TreeNode):
# child.values is a list of TreeNode objects
# Special handling for BMI - accept both 'range' and 'centile' versions
keep_with_bmi = keep.copy()
if "BMI (body mass index) centile" in keep:
keep_with_bmi.add("BMI (body mass index) range")
child.values = [v for v in child.values if v.key in keep_with_bmi]
child.values = [v for v in child.values if v.key in keep]
else:
# child.values is a list of strings
child.values = [v for v in child.values if v in keep]
Expand All @@ -432,6 +422,17 @@ def get_case_review(self, case_config_id): # pragma: no cover
"weight": merged["top"],
}
)

# --- 4c) Rename BMI title from 'centile' to 'range' after filtering ---
for top in case_details:
if top.key != "PHYSICAL EXAMINATION":
continue
for child in top.values:
if child.key == "Body measure" and child.values:
if isinstance(child.values[0], TreeNode):
for node in child.values:
if node.key == "BMI (body mass index) centile":
node.key = "BMI (body mass index) range"

# sort and wrap into TreeNodes
important_infos.sort(key=itemgetter("weight"))
Expand Down
Loading