Skip to content

Commit

Permalink
ICD11 patch: load all to in-memory; but search filter by `is_leaf=Tru…
Browse files Browse the repository at this point in the history
…e` (#1661)

* icd11: remove `is_leaf` filter for in-memory table

* search api; filter by is_leaf=True
  • Loading branch information
rithviknishad authored Oct 6, 2023
1 parent fd7fd29 commit ab695cd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion care/facility/api/viewsets/icd.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def list(self, request):
if request.GET.get("query", False):
query = request.GET.get("query")
queryset = queryset.where(
label=queryset.re_match(r".*" + query + r".*", IGNORECASE)
label=queryset.re_match(r".*" + query + r".*", IGNORECASE),
is_leaf=True,
) # can accept regex from FE if needed.
return Response(serailize_data(queryset[0:100]))
5 changes: 3 additions & 2 deletions care/facility/static_data/icd11.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ def fetch_from_db():
{
"id": str(diagnosis["id"]),
"label": diagnosis["label"],
"is_leaf": diagnosis["is_leaf"],
}
for diagnosis in ICD11Diagnosis.objects.filter(is_leaf=True).values(
"id", "label"
for diagnosis in ICD11Diagnosis.objects.filter().values(
"id", "label", "is_leaf"
)
]
return []
Expand Down

0 comments on commit ab695cd

Please sign in to comment.