-
Notifications
You must be signed in to change notification settings - Fork 326
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor ICD11 Table; Cleanup in-memory search (#1636)
* Refactor ICD11 Table * optimize memory usage * gracefully handle relation not existing * check table exists before loading from db * Apply suggestions from code review Co-authored-by: Aakash Singh <[email protected]> * move fetch_data to commands * fix id type in in-memory * patch * merge migrations --------- Co-authored-by: Aakash Singh <[email protected]>
- Loading branch information
1 parent
0a4a4c4
commit fd7fd29
Showing
7 changed files
with
177 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Generated by Django 4.2.2 on 2023-09-25 13:00 | ||
|
||
import django.db.models.deletion | ||
from django.core.management import call_command | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("facility", "0387_merge_20230911_2303"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="ICD11Diagnosis", | ||
fields=[ | ||
("id", models.BigIntegerField(primary_key=True, serialize=False)), | ||
("icd11_id", models.CharField(max_length=255, unique=True)), | ||
("label", models.CharField(max_length=255)), | ||
( | ||
"class_kind", | ||
models.CharField( | ||
choices=[ | ||
("chapter", "Chapter"), | ||
("block", "Block"), | ||
("category", "Category"), | ||
], | ||
max_length=255, | ||
), | ||
), | ||
("is_leaf", models.BooleanField()), | ||
("average_depth", models.IntegerField()), | ||
("is_adopted_child", models.BooleanField()), | ||
( | ||
"breadth_value", | ||
models.DecimalField(decimal_places=22, max_digits=24), | ||
), | ||
("meta_hidden", models.BooleanField(default=False)), | ||
("meta_chapter", models.CharField(max_length=255)), | ||
("meta_chapter_short", models.CharField(max_length=255, null=True)), | ||
("meta_root_block", models.CharField(max_length=255, null=True)), | ||
("meta_root_category", models.CharField(max_length=255, null=True)), | ||
( | ||
"parent", | ||
models.ForeignKey( | ||
null=True, | ||
on_delete=django.db.models.deletion.DO_NOTHING, | ||
to="facility.icd11diagnosis", | ||
), | ||
), | ||
], | ||
), | ||
migrations.RunPython( | ||
lambda apps, schema_editor: call_command("load_icd11_diagnoses_data"), | ||
reverse_code=migrations.RunPython.noop, | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Generated by Django 4.2.5 on 2023-10-05 17:17 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("facility", "0388_goal_goalentry_goalproperty_goalpropertyentry"), | ||
("facility", "0388_icd11diagnosis"), | ||
] | ||
|
||
operations = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from django.db import models | ||
|
||
|
||
class ICD11ClassKind(models.TextChoices): | ||
CHAPTER = "chapter" | ||
BLOCK = "block" | ||
CATEGORY = "category" | ||
|
||
|
||
class ICD11Diagnosis(models.Model): | ||
""" | ||
Use ICDDiseases for in-memory search. | ||
""" | ||
|
||
id = models.BigIntegerField(primary_key=True) | ||
icd11_id = models.CharField(max_length=255, unique=True) | ||
label = models.CharField(max_length=255) | ||
class_kind = models.CharField(max_length=255, choices=ICD11ClassKind.choices) | ||
is_leaf = models.BooleanField() | ||
parent = models.ForeignKey("self", on_delete=models.DO_NOTHING, null=True) | ||
average_depth = models.IntegerField() | ||
is_adopted_child = models.BooleanField() | ||
breadth_value = models.DecimalField(max_digits=24, decimal_places=22) | ||
|
||
# Meta fields | ||
meta_hidden = models.BooleanField(default=False) | ||
meta_chapter = models.CharField(max_length=255) | ||
meta_chapter_short = models.CharField(max_length=255, null=True) | ||
meta_root_block = models.CharField(max_length=255, null=True) | ||
meta_root_category = models.CharField(max_length=255, null=True) | ||
|
||
def __str__(self) -> str: | ||
return self.label |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters