From 3ca8d9f11d5937b676e6a05a57204feb09929284 Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Wed, 6 Sep 2023 21:04:18 +0530 Subject: [PATCH] fixes coronasafe/care_fe#6231 --- .../commands/load_meta_icd11_diagnosis.py | 43 +++++++++++++++++-- ...taicd11diagnosis_chapter_short_and_more.py | 22 ++++++++++ care/facility/models/meta_icd11_diagnosis.py | 2 + 3 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 care/facility/migrations/0384_metaicd11diagnosis_chapter_short_and_more.py diff --git a/care/facility/management/commands/load_meta_icd11_diagnosis.py b/care/facility/management/commands/load_meta_icd11_diagnosis.py index 2895608657..1ffae591b0 100644 --- a/care/facility/management/commands/load_meta_icd11_diagnosis.py +++ b/care/facility/management/commands/load_meta_icd11_diagnosis.py @@ -33,6 +33,37 @@ class Command(BaseCommand): "category": "root_category", } + ICD11_GROUP_LABEL_PRETTY = { + "01 Certain infectious or parasitic diseases": "Infection and parasites ", + "02 Neoplasms": "Neoplasms", + "03 Diseases of the blood or blood-forming organs": "Hematology", + "04 Diseases of the immune system": "Immune System", + "05 Endocrine, nutritional or metabolic diseases": "Endocrine, nutritional or metabolism", + "06 Mental, behavioural or neurodevelopmental disorders": "Mental, behavioural or neurological", + "07 Sleep-wake disorders": "Sleep", + "08 Diseases of the nervous system": "Nervous System", + "09 Diseases of the visual system": "Ophthalmology", + "10 Diseases of the ear or mastoid process": "ENT", + "11 Diseases of the circulatory system": "Circulatory System", + "12 Diseases of the respiratory system": "Respiratory System", + "13 Diseases of the digestive system": "Digestive System", + "14 Diseases of the skin": "Skin", + "15 Diseases of the musculoskeletal system or connective tissue": "Musculoskeletal System", + "16 Diseases of the genitourinary system": "Genitourinary System", + "17 Conditions related to sexual health": "Sexual Health", + "18 Pregnancy, childbirth or the puerperium": "OBGYN", + "19 Certain conditions originating in the perinatal period": "Neonatology", + "20 Developmental anomalies": "Developmental Anomalies", + "21 Symptoms, signs or clinical findings, not elsewhere classified": "Others", + "22 Injury, poisoning or certain other consequences of external causes": "Injury, Poisoning ", + "23 External causes of morbidity or mortality": "External Causes of Injury", + "24 Factors influencing health status or contact with health services": None, + "25 Codes for special purposes": "Codes for special purposes", + "26 Supplementary Chapter Traditional Medicine Conditions - Module I": None, + "V Supplementary section for functioning assessment": "Functioning assessment ", + "X Extension Codes": "NOT RELEVANT", + } + def find_roots(self, item): id = item["ID"] @@ -72,10 +103,16 @@ def handle(self, *args, **options): self.data = fetch_data() def roots(item): - return { - self.CLASS_KIND_DB_KEYS.get(k, k): v - for k, v in self.find_roots(item).items() + roots = self.find_roots(item) + mapped = self.ICD11_GROUP_LABEL_PRETTY.get( + roots["chapter"], roots["chapter"] + ) + result = { + self.CLASS_KIND_DB_KEYS.get(k, k): v for k, v in roots.items() } + result["chapter_short"] = mapped + result["deleted"] = mapped is None + return result MetaICD11Diagnosis.objects.all().delete() MetaICD11Diagnosis.objects.bulk_create( diff --git a/care/facility/migrations/0384_metaicd11diagnosis_chapter_short_and_more.py b/care/facility/migrations/0384_metaicd11diagnosis_chapter_short_and_more.py new file mode 100644 index 0000000000..8537d04b3c --- /dev/null +++ b/care/facility/migrations/0384_metaicd11diagnosis_chapter_short_and_more.py @@ -0,0 +1,22 @@ +# Generated by Django 4.2.2 on 2023-09-06 15:13 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("facility", "0383_patientconsultation_icd11_principal_diagnosis"), + ] + + operations = [ + migrations.AddField( + model_name="metaicd11diagnosis", + name="chapter_short", + field=models.CharField(max_length=255, null=True), + ), + migrations.AddField( + model_name="metaicd11diagnosis", + name="deleted", + field=models.BooleanField(default=False), + ), + ] diff --git a/care/facility/models/meta_icd11_diagnosis.py b/care/facility/models/meta_icd11_diagnosis.py index a3ea15f5b5..4a2bb45da7 100644 --- a/care/facility/models/meta_icd11_diagnosis.py +++ b/care/facility/models/meta_icd11_diagnosis.py @@ -16,8 +16,10 @@ class MetaICD11Diagnosis(models.Model): label = models.CharField(max_length=255) breadth_value = models.DecimalField(max_digits=24, decimal_places=22) chapter = models.CharField(max_length=255) + chapter_short = models.CharField(max_length=255, null=True) root_block = models.CharField(max_length=255, null=True) root_category = models.CharField(max_length=255, null=True) + deleted = models.BooleanField(default=False) class Meta: db_table = "meta_icd11_diagnosis"