Skip to content

Examples update - #30

Merged
alex-omophub merged 2 commits into
mainfrom
develop
Aug 11, 2026
Merged

Examples update#30
alex-omophub merged 2 commits into
mainfrom
develop

Conversation

@alex-omophub

@alex-omophub alex-omophub commented Aug 11, 2026

Copy link
Copy Markdown
Member

Summary by cubic

Clarifies Mappings API usage across README, examples, and types, including correct ICD-10 → SNOMED direction, get() vs get_iter pagination, and which fields each endpoint returns.

  • New Features
    • README and types: switched ICD-10 example to concepts.get_by_code() + mappings.get(), added mappings.get_iter to the API table, explained mapping direction, and documented mappings.get vs mappings.map field differences in the Mapping type (resolve target codes via concepts.get).
    • Examples: clarified get() (single page, no pagination info) vs get_iter (walks all pages), showed mapping to ICD10CM via relationship_ids=["Mapped from"], resolving target codes with concepts.get, handling Maps to value, filtering deprecated rows with include_invalid=False, and improved error handling/output formatting.

Written for commit 02d04a3. Summary will update on new commits.

Review in cubic

- 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

codecov Bot commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread examples/map_between_vocabularies.py Outdated
Comment thread examples/map_between_vocabularies.py Outdated
Comment thread examples/map_between_vocabularies.py Outdated
Comment thread examples/map_between_vocabularies.py Outdated
Comment on lines +25 to +27
# 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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Suggested change
# 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.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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``.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Suggested change
``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).

@alex-omophub
alex-omophub merged commit ae1fde0 into main Aug 11, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant