Skip to content

Commit

Permalink
Exclude ICD11 entries from redis that does not have a `meta_chapter_s…
Browse files Browse the repository at this point in the history
…hort` (#2207)

* ICD11: Fallback to meta_chapter if meta_chapter_short is null

* Exclude icd11 diagnosis that does not have meta_chapter_short from redis

---------

Co-authored-by: Vignesh Hari <[email protected]>
  • Loading branch information
rithviknishad and vigneshhari authored Jun 2, 2024
1 parent ee311a1 commit be5711f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions care/facility/static_data/icd11.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,18 @@ def get_representation(self) -> ICD11Object:
def load_icd11_diagnosis():
print("Loading ICD11 Diagnosis into the redis cache...", end="", flush=True)

icd_objs = ICD11Diagnosis.objects.order_by("id").values_list(
"id", "label", "meta_chapter_short"
icd_objs = (
ICD11Diagnosis.objects.filter(meta_chapter_short__isnull=False)
.order_by("id")
.values_list("id", "label", "meta_chapter_short")
)
paginator = Paginator(icd_objs, 5000)
for page_number in paginator.page_range:
for diagnosis in paginator.page(page_number).object_list:
ICD11(
id=diagnosis[0],
label=diagnosis[1],
chapter=diagnosis[2] or "",
chapter=diagnosis[2],
has_code=1 if re.match(DISEASE_CODE_PATTERN, diagnosis[1]) else 0,
vec=diagnosis[1].replace(".", "\\.", 1),
).save()
Expand Down

0 comments on commit be5711f

Please sign in to comment.