Skip to content

Commit e8cb1d6

Browse files
author
alex-omophub
committed
Release preparation
1 parent f37ba3a commit e8cb1d6

7 files changed

Lines changed: 74 additions & 153 deletions

File tree

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ for c in results["concepts"]:
5151
print(f"{c['concept_id']}: {c['concept_name']}")
5252

5353
# Map ICD-10 code to SNOMED
54-
mappings = client.mappings.get_by_code("ICD10CM", "E11.9", target_vocabularies=["SNOMED"])
54+
mappings = client.mappings.get_by_code("ICD10CM", "E11.9", target_vocabulary="SNOMED")
5555

5656
# Navigate concept hierarchy
5757
ancestors = client.hierarchy.ancestors(201826, max_levels=3)
@@ -82,8 +82,8 @@ Validate and map clinical codes during OMOP CDM transformations:
8282
def validate_and_map(source_vocab, source_code):
8383
concept = client.concepts.get_by_code(source_vocab, source_code)
8484
if concept["standard_concept"] != "S":
85-
mappings = client.mappings.get(concept["concept_id"],
86-
target_vocabularies=["SNOMED"])
85+
mappings = client.mappings.get(concept["concept_id"],
86+
target_vocabulary="SNOMED")
8787
return mappings["mappings"][0]["target_concept_id"]
8888
return concept["concept_id"]
8989
```
@@ -109,7 +109,7 @@ Explore hierarchies to build comprehensive concept sets:
109109

110110
```python
111111
# Get all descendants of "Type 2 diabetes mellitus" for phenotype
112-
descendants = client.hierarchy.descendants(201826, max_levels=5, standard_only=True)
112+
descendants = client.hierarchy.descendants(201826, max_levels=5)
113113
concept_set = [d["concept_id"] for d in descendants["concepts"]]
114114
print(f"Found {len(concept_set)} concepts for T2DM phenotype")
115115
```
@@ -120,7 +120,7 @@ Build terminology lookups into healthcare applications:
120120

121121
```python
122122
# Autocomplete for clinical coding interface
123-
suggestions = client.concepts.suggest("diab", vocabulary="SNOMED", limit=10)
123+
suggestions = client.concepts.suggest("diab", vocabulary_ids=["SNOMED"], page_size=10)
124124
# Returns: ["Diabetes mellitus", "Diabetic nephropathy", "Diabetic retinopathy", ...]
125125
```
126126

src/omophub/resources/concepts.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
if TYPE_CHECKING:
88
from .._request import AsyncRequest, Request
99
from ..types.concept import BatchConceptResult, Concept
10-
from ..types.search import Suggestion
1110

1211

1312
class GetConceptParams(TypedDict, total=False):

src/omophub/resources/vocabularies.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
from typing import TYPE_CHECKING, Any
66

77
if TYPE_CHECKING:
8-
import builtins
9-
108
from .._request import AsyncRequest, Request
119
from ..types.vocabulary import Vocabulary, VocabularyStats
1210

tests/unit/resources/test_concepts.py

Lines changed: 32 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,15 @@ def test_suggest_concepts_with_filters(
137137

138138
sync_client.concepts.suggest(
139139
"diabetes",
140-
vocabulary="SNOMED",
141-
domain="Condition",
142-
limit=20,
140+
vocabulary_ids=["SNOMED"],
141+
domain_ids=["Condition"],
142+
page_size=20,
143143
)
144144

145145
url_str = str(route.calls[0].request.url)
146-
assert "vocabulary=SNOMED" in url_str
147-
assert "domain=Condition" in url_str
148-
assert "limit=20" in url_str
146+
assert "vocabulary_ids=SNOMED" in url_str
147+
assert "domain_ids=Condition" in url_str
148+
assert "page_size=20" in url_str
149149

150150
@respx.mock
151151
def test_get_related_concepts(self, sync_client: OMOPHub, base_url: str) -> None:
@@ -179,23 +179,15 @@ def test_get_related_with_options(
179179

180180
sync_client.concepts.related(
181181
201826,
182-
relatedness_types=["hierarchical", "semantic"],
183-
vocabulary_ids=["SNOMED"],
184-
domain_ids=["Condition"],
185-
min_relatedness_score=0.5,
186-
max_results=100,
187-
include_scores=False,
188-
standard_concepts_only=True,
182+
relationship_types=["Is a", "Maps to"],
183+
min_score=0.5,
184+
page_size=100,
189185
)
190186

191187
url_str = str(route.calls[0].request.url)
192-
assert "relatedness_types=hierarchical%2Csemantic" in url_str
193-
assert "vocabulary_ids=SNOMED" in url_str
194-
assert "domain_ids=Condition" in url_str
195-
assert "min_relatedness_score=0.5" in url_str
196-
assert "max_results=100" in url_str
197-
assert "include_scores=false" in url_str
198-
assert "standard_concepts_only=true" in url_str
188+
assert "relationship_types=Is+a%2CMaps+to" in url_str
189+
assert "min_score=0.5" in url_str
190+
assert "page_size=100" in url_str
199191

200192
@respx.mock
201193
def test_get_concept_relationships(
@@ -230,20 +222,16 @@ def test_get_concept_relationships_with_options(
230222

231223
sync_client.concepts.relationships(
232224
201826,
233-
relationship_type="Is a",
234-
target_vocabulary="SNOMED",
225+
relationship_ids="Is a",
226+
vocabulary_ids="SNOMED",
235227
include_invalid=True,
236-
page=2,
237-
page_size=50,
238228
)
239229

240230
url_str = str(route.calls[0].request.url)
241231
# All params use snake_case to match API standards
242-
assert "relationship_type=Is+a" in url_str
243-
assert "target_vocabulary=SNOMED" in url_str
232+
assert "relationship_ids=Is+a" in url_str
233+
assert "vocabulary_ids=SNOMED" in url_str
244234
assert "include_invalid=true" in url_str
245-
assert "page=2" in url_str
246-
assert "page_size=50" in url_str
247235

248236

249237
class TestAsyncConceptsResource:
@@ -369,15 +357,15 @@ async def test_async_suggest_with_filters(
369357

370358
await async_client.concepts.suggest(
371359
"aspirin",
372-
vocabulary="SNOMED",
373-
domain="Drug",
374-
limit=5,
360+
vocabulary_ids=["SNOMED"],
361+
domain_ids=["Drug"],
362+
page_size=5,
375363
)
376364

377365
url_str = str(route.calls[0].request.url)
378-
assert "vocabulary=SNOMED" in url_str
379-
assert "domain=Drug" in url_str
380-
assert "limit=5" in url_str
366+
assert "vocabulary_ids=SNOMED" in url_str
367+
assert "domain_ids=Drug" in url_str
368+
assert "page_size=5" in url_str
381369

382370
@pytest.mark.asyncio
383371
@respx.mock
@@ -408,20 +396,15 @@ async def test_async_get_related_with_options(
408396

409397
await async_client.concepts.related(
410398
201826,
411-
relatedness_types=["semantic"],
412-
vocabulary_ids=["SNOMED"],
413-
domain_ids=["Condition"],
414-
min_relatedness_score=0.7,
415-
max_results=25,
416-
include_scores=True,
417-
standard_concepts_only=True,
399+
relationship_types=["Is a"],
400+
min_score=0.7,
401+
page_size=25,
418402
)
419403

420404
url_str = str(route.calls[0].request.url)
421-
assert "relatedness_types=semantic" in url_str
422-
assert "vocabulary_ids=SNOMED" in url_str
423-
assert "min_relatedness_score=0.7" in url_str
424-
assert "standard_concepts_only=true" in url_str
405+
assert "relationship_types=Is+a" in url_str
406+
assert "min_score=0.7" in url_str
407+
assert "page_size=25" in url_str
425408

426409
@pytest.mark.asyncio
427410
@respx.mock
@@ -452,14 +435,12 @@ async def test_async_get_relationships_with_options(
452435

453436
await async_client.concepts.relationships(
454437
201826,
455-
relationship_type="Maps to",
456-
target_vocabulary="ICD10CM",
438+
relationship_ids="Maps to",
439+
vocabulary_ids="ICD10CM",
457440
include_invalid=True,
458-
page=1,
459-
page_size=100,
460441
)
461442

462443
url_str = str(route.calls[0].request.url)
463-
assert "relationship_type=Maps+to" in url_str
464-
assert "target_vocabulary=ICD10CM" in url_str
444+
assert "relationship_ids=Maps+to" in url_str
445+
assert "vocabulary_ids=ICD10CM" in url_str
465446
assert "include_invalid=true" in url_str

tests/unit/resources/test_mappings.py

Lines changed: 10 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def test_get_mappings(self, sync_client: OMOPHub, base_url: str) -> None:
4444
def test_get_mappings_with_filters(
4545
self, sync_client: OMOPHub, base_url: str
4646
) -> None:
47-
"""Test getting mappings with all filter options."""
47+
"""Test getting mappings with filter options."""
4848
route = respx.get(f"{base_url}/concepts/201826/mappings").mock(
4949
return_value=Response(
5050
200, json={"success": True, "data": {"mappings": []}}
@@ -53,33 +53,13 @@ def test_get_mappings_with_filters(
5353

5454
sync_client.mappings.get(
5555
201826,
56-
target_vocabularies=["ICD10CM", "ICD9CM"],
57-
mapping_types=["MAPS TO", "IS A"],
58-
direction="outgoing",
59-
include_indirect=True,
60-
standard_only=True,
61-
include_mapping_quality=True,
62-
include_synonyms=True,
63-
include_context=True,
64-
active_only=False,
65-
sort_by="mapping_type",
66-
sort_order="asc",
67-
page=1,
68-
page_size=100,
56+
target_vocabulary="ICD10CM",
57+
include_invalid=True,
6958
)
7059

7160
url_str = str(route.calls[0].request.url)
72-
assert "target_vocabularies=ICD10CM%2CICD9CM" in url_str
73-
assert "mapping_types=MAPS+TO%2CIS+A" in url_str
74-
assert "direction=outgoing" in url_str
75-
assert "include_indirect=true" in url_str
76-
assert "standard_only=true" in url_str
77-
assert "include_mapping_quality=true" in url_str
78-
assert "include_synonyms=true" in url_str
79-
assert "include_context=true" in url_str
80-
assert "active_only=false" in url_str
81-
assert "sort_by=mapping_type" in url_str
82-
assert "sort_order=asc" in url_str
61+
assert "target_vocabulary=ICD10CM" in url_str
62+
assert "include_invalid=true" in url_str
8363

8464
@respx.mock
8565
def test_map_concepts(self, sync_client: OMOPHub, base_url: str) -> None:
@@ -158,7 +138,7 @@ async def test_async_get_mappings(
158138
async def test_async_get_mappings_with_filters(
159139
self, async_client: omophub.AsyncOMOPHub, base_url: str
160140
) -> None:
161-
"""Test async mappings with all filters."""
141+
"""Test async mappings with filters."""
162142
route = respx.get(f"{base_url}/concepts/201826/mappings").mock(
163143
return_value=Response(
164144
200, json={"success": True, "data": {"mappings": []}}
@@ -167,23 +147,13 @@ async def test_async_get_mappings_with_filters(
167147

168148
await async_client.mappings.get(
169149
201826,
170-
target_vocabularies=["ICD10CM"],
171-
mapping_types=["MAPS TO"],
172-
direction="both",
173-
include_indirect=True,
174-
standard_only=True,
175-
include_mapping_quality=True,
176-
include_synonyms=True,
177-
include_context=True,
178-
active_only=False,
179-
sort_by="target_vocabulary",
180-
sort_order="desc",
150+
target_vocabulary="ICD10CM",
151+
include_invalid=True,
181152
)
182153

183154
url_str = str(route.calls[0].request.url)
184-
assert "target_vocabularies=ICD10CM" in url_str
185-
assert "include_indirect=true" in url_str
186-
assert "active_only=false" in url_str
155+
assert "target_vocabulary=ICD10CM" in url_str
156+
assert "include_invalid=true" in url_str
187157

188158
@pytest.mark.asyncio
189159
@respx.mock

tests/unit/resources/test_relationships.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,16 @@ def test_get_relationships_with_filters(
5353

5454
sync_client.relationships.get(
5555
201826,
56-
relationship_type="Is a",
57-
target_vocabulary="SNOMED",
56+
relationship_ids=["Is a"],
57+
vocabulary_ids=["SNOMED"],
5858
include_invalid=True,
5959
page=2,
6060
page_size=100,
6161
)
6262

6363
url_str = str(route.calls[0].request.url)
64-
assert "relationship_type=Is+a" in url_str
65-
assert "target_vocabulary=SNOMED" in url_str
64+
assert "relationship_ids=Is+a" in url_str
65+
assert "vocabulary_ids=SNOMED" in url_str
6666
assert "include_invalid=true" in url_str
6767
assert "page=2" in url_str
6868
assert "page_size=100" in url_str
@@ -137,16 +137,16 @@ async def test_async_get_relationships_with_filters(
137137

138138
await async_client.relationships.get(
139139
201826,
140-
relationship_type="Maps to",
141-
target_vocabulary="ICD10CM",
140+
relationship_ids=["Maps to"],
141+
vocabulary_ids=["ICD10CM"],
142142
include_invalid=True,
143143
page=1,
144144
page_size=200,
145145
)
146146

147147
url_str = str(route.calls[0].request.url)
148-
assert "relationship_type=Maps+to" in url_str
149-
assert "target_vocabulary=ICD10CM" in url_str
148+
assert "relationship_ids=Maps+to" in url_str
149+
assert "vocabulary_ids=ICD10CM" in url_str
150150
assert "include_invalid=true" in url_str
151151
assert "page=1" in url_str
152152
assert "page_size=200" in url_str

0 commit comments

Comments
 (0)