From be5711f795cec2221fb8056892ebaff68512a4f5 Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Sun, 2 Jun 2024 18:39:09 +0530 Subject: [PATCH] Exclude ICD11 entries from redis that does not have a `meta_chapter_short` (#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 --- care/facility/static_data/icd11.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/care/facility/static_data/icd11.py b/care/facility/static_data/icd11.py index dd379671e5..d379d62450 100644 --- a/care/facility/static_data/icd11.py +++ b/care/facility/static_data/icd11.py @@ -36,8 +36,10 @@ 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: @@ -45,7 +47,7 @@ def load_icd11_diagnosis(): 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()