Skip to content

Commit

Permalink
Addressed requested changes from PR review
Browse files Browse the repository at this point in the history
  • Loading branch information
rmanaem committed Jan 7, 2025
1 parent 2e1d4b3 commit fc5b27c
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/api/routers/assessments.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
path="/vocab",
endpoint=route_factory.create_get_vocab_handler(
external_vocab=EXTERNAL_VOCAB,
vocab_name="SNOMED Assessment",
vocab_name="SNOMED CT Assessment Scale",
namespace_prefix="snomed",
),
methods=["GET"],
Expand Down
2 changes: 1 addition & 1 deletion app/api/routers/diagnoses.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
path="/vocab",
endpoint=route_factory.create_get_vocab_handler(
external_vocab=EXTERNAL_VOCAB,
vocab_name="SNOMED Disorder",
vocab_name="SNOMED CT Disorder",
namespace_prefix="snomed",
),
methods=["GET"],
Expand Down
7 changes: 5 additions & 2 deletions app/api/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@

CONTEXT = {
"nb": "http://neurobagel.org/vocab/",
"nbg": "http://neurobagel.org/graph/", # TODO: Check if we still need this namespace.
"ncit": "http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#",
"nidm": "http://purl.org/nidash/nidm#",
"snomed": "http://purl.bioontology.org/ontology/SNOMEDCT/",
Expand Down Expand Up @@ -460,7 +459,11 @@ def create_snomed_assessment_lookup(output_path: Path):
"""
vocab = load_json(BACKUP_VOCAB_DIR / "snomed_assessment.json")

term_labels = {term["identifier"][7:]: term["label"] for term in vocab}
term_labels = {
term["identifier"].removeprefix("snomed:"): term["label"]
for term in vocab
}

with open(output_path, "w") as f:
f.write(json.dumps(term_labels, indent=2))

Expand Down
9 changes: 6 additions & 3 deletions tests/test_app_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,19 @@ def test_app_with_set_allowed_origins(
)


@pytest.mark.parametrize(
"lookup_file",
["snomed_disorder", "snomed_assessment"],
)
@pytest.mark.filterwarnings("ignore:.*NB_API_ALLOWED_ORIGINS")
def test_stored_vocab_lookup_file_created_on_startup(
test_app,
set_test_credentials,
disable_auth,
lookup_file,
):
"""Test that on startup, a non-empty temporary lookup file is created for term ID-label mappings for the locally stored SNOMED CT vocabulary."""
with test_app:
term_labels_path = test_app.app.state.vocab_lookup_paths[
"snomed_disorder"
]
term_labels_path = test_app.app.state.vocab_lookup_paths[lookup_file]
assert term_labels_path.exists()
assert term_labels_path.stat().st_size > 0
6 changes: 3 additions & 3 deletions tests/test_attribute_factory_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_get_instances_endpoint_with_vocab_lookup(
{
"termURL": {
"type": "uri",
"value": "http://notpurl.bioontology.org/ontology/SNOMEDCT/123456789",
"value": "http://unknownvocab.org/123456789",
}
},
]
Expand Down Expand Up @@ -123,8 +123,8 @@ def mock_httpx_post(**kwargs):
@pytest.mark.parametrize(
"attribute, expected_vocab_name, expected_namespace_pfx",
[
("assessments", "SNOMED Assessment", "snomed"),
("diagnoses", "SNOMED Disorder", "snomed"),
("assessments", "SNOMED CT Assessment Scale", "snomed"),
("diagnoses", "SNOMED CT Disorder", "snomed"),
],
)
def test_get_vocab_endpoint(
Expand Down

0 comments on commit fc5b27c

Please sign in to comment.