Skip to content

Commit

Permalink
update handling ids
Browse files Browse the repository at this point in the history
  • Loading branch information
korikuzma committed Sep 13, 2023
1 parent 9f9e7b0 commit 35ae54a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion disease/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ def _add_disease(
:return: completed normalized response object ready to return to user
"""
disease_obj = core_models.Disease(
id=record["concept_id"], label=record["label"]
id=f"normalize.disease.{record['concept_id']}", label=record["label"]
)

source_ids = record.get("xrefs", []) + record.get("associated_with", [])
Expand Down Expand Up @@ -360,6 +360,7 @@ def _add_disease(

response["match_type"] = match_type
response["disease"] = disease_obj
response["normalized_id"] = record["concept_id"]
response = self._add_merged_meta(response)
return NormalizationService(**response)

Expand Down
4 changes: 3 additions & 1 deletion disease/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ class NormalizationService(BaseModel):
query: StrictStr
warnings: Optional[Dict] = None
match_type: MatchType
normalized_id: Optional[str] = None
disease: Optional[core_models.Disease] = None
source_meta_: Optional[Dict[SourceName, SourceMeta]] = None
service_meta_: ServiceMeta
Expand All @@ -305,8 +306,9 @@ class NormalizationService(BaseModel):
"query": "childhood leukemia",
"warnings": None,
"match_type": 80,
"normalized_id": "ncit:C4989",
"disease": {
"id": "ncit:C4989",
"id": "normalize.disease.ncit:C4989",
"type": "Disease",
"label": "Childhood Leukemia",
"aliases": [
Expand Down
7 changes: 4 additions & 3 deletions tests/unit/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def neuroblastoma():
return core_models.Disease(
**{
"type": "Disease",
"id": "ncit:C3270",
"id": "normalize.disease.ncit:C3270",
"label": "Neuroblastoma",
"mappings": [
{
Expand Down Expand Up @@ -94,7 +94,7 @@ def skin_myo():
return core_models.Disease(
**{
"type": "Disease",
"id": "ncit:C167370",
"id": "normalize.disease.ncit:C167370",
"label": "Skin Myoepithelioma",
"aliases": ["Cutaneous Myoepithelioma"],
}
Expand All @@ -109,7 +109,7 @@ def mafd2():
return core_models.Disease(
**{
"type": "Disease",
"id": "mondo:0010648",
"id": "normalize.disease.mondo:0010648",
"label": "major affective disorder 2",
"aliases": [
"MAFD2",
Expand Down Expand Up @@ -138,6 +138,7 @@ def mafd2():

def compare_disease(actual, fixture):
"""Verify correctness of returned Disease core object against test fixture."""
assert actual.normalized_id == fixture.id.split("normalize.disease.")[-1]
actual = actual.disease
actual_keys = actual.model_dump(exclude_none=True).keys()
fixture_keys = fixture.model_dump(exclude_none=True).keys()
Expand Down

0 comments on commit 35ae54a

Please sign in to comment.