Examples update - #30
Conversation
- Updated README to clarify the mapping process from ICD-10 to SNOMED, including code lookup and mapping retrieval. - Improved example script to demonstrate fetching mappings, handling pagination, and filtering valid mappings only. - Added new functions to illustrate specific vocabulary mapping and the handling of composite concepts.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
1 issue found across 2 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="examples/map_between_vocabularies.py">
<violation number="1" location="examples/map_between_vocabularies.py:25">
P3: The mapping row does expose vocabulary/code fields, so this comment tells users to make an unnecessary concept lookup and contradicts the SDK schema. Updating the comment to describe those optional fields would keep the example accurate.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| # A mapping row carries only these fields. Vocabulary id and | ||
| # concept code are NOT part of it -- fetch the target concept if | ||
| # you need them. |
There was a problem hiding this comment.
P3: The mapping row does expose vocabulary/code fields, so this comment tells users to make an unnecessary concept lookup and contradicts the SDK schema. Updating the comment to describe those optional fields would keep the example accurate.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At examples/map_between_vocabularies.py, line 25:
<comment>The mapping row does expose vocabulary/code fields, so this comment tells users to make an unnecessary concept lookup and contradicts the SDK schema. Updating the comment to describe those optional fields would keep the example accurate.</comment>
<file context>
@@ -5,34 +5,147 @@
+
+ print(f"Mappings for concept {concept_id} (this page: {len(mappings)}):")
+ for m in mappings[:10]:
+ # A mapping row carries only these fields. Vocabulary id and
+ # concept code are NOT part of it -- fetch the target concept if
+ # you need them.
</file context>
| # A mapping row carries only these fields. Vocabulary id and | |
| # concept code are NOT part of it -- fetch the target concept if | |
| # you need them. | |
| # Mapping rows include the target concept ID/name and may also include | |
| # target vocabulary/code fields when returned by the API. |
- Enhanced the `get_mappings` and `map_to_a_specific_vocabulary` functions to clarify the handling of mapping rows and the resolution of target concept details. - Updated comments to explain the optional fields in the `Mapping` type and their usage across different endpoints. - Improved error handling and output formatting for better user experience.
There was a problem hiding this comment.
1 issue found across 2 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/omophub/types/mapping.py">
<violation number="1" location="src/omophub/types/mapping.py:40">
P3: The new docstring lists a top-level ``confidence`` field among the fields that ``mappings.get`` returns, but the ``Mapping`` type defines no such field — confidence only exists as ``quality.confidence_score`` and, per the note two lines below, is populated only when ``include_mapping_quality=True`` is requested. Listing bare ``confidence`` as a guaranteed return field is internally inconsistent with both the type and the note, and will lead readers to write ``m["confidence"]`` (a KeyError / missing type member). Either drop ``confidence`` from the list, name it ``quality.confidence_score`` and qualify it with the ``include_mapping_quality=True`` condition, or add the missing top-level field to the ``Mapping`` type. The same claim appears in the comment added to examples/map_between_vocabularies.py in this PR, so both should be aligned if corrected.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
|
|
||
| - ``mappings.get`` (``GET /concepts/{id}/mappings``) returns exactly | ||
| ``source_concept_id``, ``source_concept_name``, ``target_concept_id``, | ||
| ``target_concept_name``, ``relationship_id`` and ``confidence``. |
There was a problem hiding this comment.
P3: The new docstring lists a top-level confidence field among the fields that mappings.get returns, but the Mapping type defines no such field — confidence only exists as quality.confidence_score and, per the note two lines below, is populated only when include_mapping_quality=True is requested. Listing bare confidence as a guaranteed return field is internally inconsistent with both the type and the note, and will lead readers to write m["confidence"] (a KeyError / missing type member). Either drop confidence from the list, name it quality.confidence_score and qualify it with the include_mapping_quality=True condition, or add the missing top-level field to the Mapping type. The same claim appears in the comment added to examples/map_between_vocabularies.py in this PR, so both should be aligned if corrected.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/omophub/types/mapping.py, line 40:
<comment>The new docstring lists a top-level ``confidence`` field among the fields that ``mappings.get`` returns, but the ``Mapping`` type defines no such field — confidence only exists as ``quality.confidence_score`` and, per the note two lines below, is populated only when ``include_mapping_quality=True`` is requested. Listing bare ``confidence`` as a guaranteed return field is internally inconsistent with both the type and the note, and will lead readers to write ``m["confidence"]`` (a KeyError / missing type member). Either drop ``confidence`` from the list, name it ``quality.confidence_score`` and qualify it with the ``include_mapping_quality=True`` condition, or add the missing top-level field to the ``Mapping`` type. The same claim appears in the comment added to examples/map_between_vocabularies.py in this PR, so both should be aligned if corrected.</comment>
<file context>
@@ -31,6 +31,19 @@ class MappingContext(TypedDict, total=False):
+
+ - ``mappings.get`` (``GET /concepts/{id}/mappings``) returns exactly
+ ``source_concept_id``, ``source_concept_name``, ``target_concept_id``,
+ ``target_concept_name``, ``relationship_id`` and ``confidence``.
+ Supplying ``target_vocabulary`` does NOT add the vocabulary/code fields
+ -- measured against production 2026-08-12. Resolve a target's vocabulary
</file context>
| ``target_concept_name``, ``relationship_id`` and ``confidence``. | |
| ``target_concept_name``, ``relationship_id``, and ``quality.confidence_score`` | |
| (the last only when ``include_mapping_quality=True`` is requested). |
Summary by cubic
Clarifies Mappings API usage across README, examples, and types, including correct ICD-10 → SNOMED direction,
get()vsget_iterpagination, and which fields each endpoint returns.concepts.get_by_code()+mappings.get(), addedmappings.get_iterto the API table, explained mapping direction, and documentedmappings.getvsmappings.mapfield differences in theMappingtype (resolve target codes viaconcepts.get).get()(single page, no pagination info) vsget_iter(walks all pages), showed mapping to ICD10CM viarelationship_ids=["Mapped from"], resolving target codes withconcepts.get, handlingMaps to value, filtering deprecated rows withinclude_invalid=False, and improved error handling/output formatting.Written for commit 02d04a3. Summary will update on new commits.