Skip to content

Commit

Permalink
Load all icd11 records to redis; search filter by has_code (#1852)
Browse files Browse the repository at this point in the history
  • Loading branch information
rithviknishad authored Jan 25, 2024
1 parent 58cdfd5 commit 00eea21
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion care/facility/api/viewsets/icd.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def list(self, request):
except (ValueError, TypeError):
limit = 20

query = []
query = [ICD11.has_code == 1]
if q := request.query_params.get("query"):
query.append(ICD11.label % query_builder(q))

Expand Down
13 changes: 7 additions & 6 deletions care/facility/static_data/icd11.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class ICD11(BaseRedisModel):
id: int = Field(primary_key=True)
label: str = Field(index=True, full_text_search=True)
chapter: str
has_code: int = Field(index=True)

def get_representation(self) -> ICD11Object:
return {
Expand All @@ -39,12 +40,12 @@ def load_icd11_diagnosis():
paginator = Paginator(icd_objs, 5000)
for page_number in paginator.page_range:
for diagnosis in paginator.page(page_number).object_list:
if re.match(DISEASE_CODE_PATTERN, diagnosis[1]):
ICD11(
id=diagnosis[0],
label=diagnosis[1],
chapter=diagnosis[2] or "",
).save()
ICD11(

Check warning on line 43 in care/facility/static_data/icd11.py

View check run for this annotation

Codecov / codecov/patch

care/facility/static_data/icd11.py#L43

Added line #L43 was not covered by tests
id=diagnosis[0],
label=diagnosis[1],
chapter=diagnosis[2] or "",
has_code=1 if re.match(DISEASE_CODE_PATTERN, diagnosis[1]) else 0,
).save()
Migrator().run()
print("Done")

Expand Down

0 comments on commit 00eea21

Please sign in to comment.