Skip to content

Commit fb404ad

Browse files
author
alex-omophub
committed
Update CHANGELOG for v0.2.0: add parameters to concepts.get_by_code() for synonyms and relationships, and update User-Agent header format.
1 parent b7d0202 commit fb404ad

5 files changed

Lines changed: 64 additions & 9 deletions

File tree

CHANGELOG.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.2.0] - 2025-12-09
9+
10+
### Added
11+
12+
- `include_synonyms` and `include_relationships` parameters to `concepts.get_by_code()` method for retrieving concept synonyms and relationships in a single request.
13+
14+
### Changed
15+
16+
- User-Agent header updated to `OMOPHub-SDK-Python/{version}`.
17+
818
## [0.1.0] - 2025-12-01
919

1020
### Added
@@ -27,5 +37,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2737
- Full type hints and PEP 561 compliance
2838
- HTTP/2 support via httpx
2939

30-
[Unreleased]: https://github.com/omopHub/omophub-python/compare/v0.1.0...HEAD
40+
[Unreleased]: https://github.com/omopHub/omophub-python/compare/v0.2.0...HEAD
41+
[0.2.0]: https://github.com/omopHub/omophub-python/compare/v0.1.0...v0.2.0
3142
[0.1.0]: https://github.com/omopHub/omophub-python/releases/tag/v0.1.0

src/omophub/_http.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def _get_default_headers(self) -> dict[str, str]:
103103
return {
104104
"Accept": "application/json",
105105
"Content-Type": "application/json",
106-
"User-Agent": f"omophub-python/{get_version()}",
106+
"User-Agent": f"OMOPHub-SDK-Python/{get_version()}",
107107
}
108108

109109
def request(
@@ -186,7 +186,7 @@ def _get_default_headers(self) -> dict[str, str]:
186186
return {
187187
"Accept": "application/json",
188188
"Content-Type": "application/json",
189-
"User-Agent": f"omophub-python/{get_version()}",
189+
"User-Agent": f"OMOPHub-SDK-Python/{get_version()}",
190190
}
191191

192192
async def request(

src/omophub/resources/concepts.py

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,31 @@ def get_by_code(
9494
self,
9595
vocabulary_id: str,
9696
concept_code: str,
97+
*,
98+
include_relationships: bool = False,
99+
include_synonyms: bool = False,
97100
) -> Concept:
98101
"""Get a concept by vocabulary and code.
99102
100103
Args:
101104
vocabulary_id: The vocabulary ID (e.g., "SNOMED", "ICD10CM")
102105
concept_code: The concept code within the vocabulary
106+
include_relationships: Include related concepts
107+
include_synonyms: Include concept synonyms
103108
104109
Returns:
105-
The concept data with mappings
110+
The concept data with optional relationships and synonyms
106111
"""
107-
return self._request.get(f"/concepts/by-code/{vocabulary_id}/{concept_code}")
112+
params: dict[str, Any] = {}
113+
if include_relationships:
114+
params["include_relationships"] = "true"
115+
if include_synonyms:
116+
params["include_synonyms"] = "true"
117+
118+
return self._request.get(
119+
f"/concepts/by-code/{vocabulary_id}/{concept_code}",
120+
params=params or None,
121+
)
108122

109123
def batch(
110124
self,
@@ -274,10 +288,30 @@ async def get_by_code(
274288
self,
275289
vocabulary_id: str,
276290
concept_code: str,
291+
*,
292+
include_relationships: bool = False,
293+
include_synonyms: bool = False,
277294
) -> Concept:
278-
"""Get a concept by vocabulary and code."""
295+
"""Get a concept by vocabulary and code.
296+
297+
Args:
298+
vocabulary_id: The vocabulary ID (e.g., "SNOMED", "ICD10CM")
299+
concept_code: The concept code within the vocabulary
300+
include_relationships: Include related concepts
301+
include_synonyms: Include concept synonyms
302+
303+
Returns:
304+
The concept data with optional relationships and synonyms
305+
"""
306+
params: dict[str, Any] = {}
307+
if include_relationships:
308+
params["include_relationships"] = "true"
309+
if include_synonyms:
310+
params["include_synonyms"] = "true"
311+
279312
return await self._request.get(
280-
f"/concepts/by-code/{vocabulary_id}/{concept_code}"
313+
f"/concepts/by-code/{vocabulary_id}/{concept_code}",
314+
params=params or None,
281315
)
282316

283317
async def batch(

tests/conftest.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from __future__ import annotations
44

55
import os
6+
import time
67
from typing import Any
78

89
import pytest
@@ -135,6 +136,15 @@ def mock_error_response() -> dict[str, Any]:
135136
}
136137

137138

139+
@pytest.fixture(autouse=True)
140+
def rate_limit_delay(request: pytest.FixtureRequest) -> None:
141+
"""Add delay between integration tests to avoid rate limiting."""
142+
yield
143+
# Only delay for integration tests
144+
if "integration" in request.keywords:
145+
time.sleep(1)
146+
147+
138148
# Well-known test concept IDs for integration tests
139149
DIABETES_CONCEPT_ID = 201826 # Type 2 diabetes mellitus (SNOMED)
140150
ASPIRIN_CONCEPT_ID = 1112807 # Aspirin (RxNorm)

tests/unit/test_http.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ def test_default_headers(self) -> None:
201201
assert "Content-Type" in headers
202202
assert headers["Content-Type"] == "application/json"
203203
assert "User-Agent" in headers
204-
assert "omophub-python" in headers["User-Agent"]
204+
assert "OMOPHub-SDK-Python" in headers["User-Agent"]
205205

206206
client.close()
207207

@@ -350,7 +350,7 @@ async def test_default_headers(self) -> None:
350350
assert "Accept" in headers
351351
assert headers["Accept"] == "application/json"
352352
assert "User-Agent" in headers
353-
assert "omophub-python" in headers["User-Agent"]
353+
assert "OMOPHub-SDK-Python" in headers["User-Agent"]
354354

355355
await client.close()
356356

0 commit comments

Comments
 (0)