From 2740882a24acedeb5d4d27685b6081fc0951b698 Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Wed, 29 May 2024 23:21:01 +0530 Subject: [PATCH 1/2] ICD11: Fallback to meta_chapter if meta_chapter_short is null --- care/facility/static_data/icd11.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/care/facility/static_data/icd11.py b/care/facility/static_data/icd11.py index dd379671e5..eae332f9e6 100644 --- a/care/facility/static_data/icd11.py +++ b/care/facility/static_data/icd11.py @@ -37,7 +37,7 @@ 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" + "id", "label", "meta_chapter_short", "meta_chapter" ) paginator = Paginator(icd_objs, 5000) for page_number in paginator.page_range: @@ -45,7 +45,7 @@ def load_icd11_diagnosis(): ICD11( id=diagnosis[0], label=diagnosis[1], - chapter=diagnosis[2] or "", + chapter=diagnosis[2] or diagnosis[3], has_code=1 if re.match(DISEASE_CODE_PATTERN, diagnosis[1]) else 0, vec=diagnosis[1].replace(".", "\\.", 1), ).save() From 2199c13276a48029e84afd7a92777af015f7d413 Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Thu, 30 May 2024 10:06:56 +0530 Subject: [PATCH 2/2] Exclude icd11 diagnosis that does not have meta_chapter_short from redis --- 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 eae332f9e6..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", "meta_chapter" + 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 diagnosis[3], + chapter=diagnosis[2], has_code=1 if re.match(DISEASE_CODE_PATTERN, diagnosis[1]) else 0, vec=diagnosis[1].replace(".", "\\.", 1), ).save()