SQL on FHIR
3.0.0-ballot - STU 3 Ballot International flag

SQL on FHIR, published by HL7 International / FHIR Infrastructure. This guide is not an authorized publication; it is the continuous build for version 3.0.0-ballot built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of https://github.com/HL7/sql-on-fhir/ and changes regularly. See the Directory of published versions

Library: Conditions Translated to ICD-10

Official URL: http://hl7.org/fhir/uv/sql-on-fhir/Library/ConditionsToIcd10Query Version: 3.0.0-ballot
Standards status: Informative Computable Name: ConditionsToIcd10Query
Other Identifiers: OID:2.16.840.1.113883.4.642.40.77.28.8

Returns each condition with the ICD-10 code its SNOMED CT code maps to under the http://example.org/ConceptMap/sct-to-icd10|2026 concept map. The map is declared as a dependency and the runner exposes it under the sct_to_icd10 label as a relation with the columns source_system, source_version, source_code, source_display, target_system, target_version, target_code, target_display and relationship (see Terminology in SQL). The LEFT JOIN keeps conditions the map does not translate, with a null target_code; the relationship predicate excludes rows asserting that a target is not related to the source, and admits null so that a noMap row is kept.

SELECT conditions.patient_id,
       conditions.code,
       sct_to_icd10.target_code,
       sct_to_icd10.relationship
FROM conditions
LEFT JOIN sct_to_icd10
  ON sct_to_icd10.source_system = conditions.system
 AND sct_to_icd10.source_code = conditions.code
 AND (sct_to_icd10.relationship IS NULL
      OR sct_to_icd10.relationship <> 'not-related-to')
Metadata
Title Conditions Translated to ICD-10
Version 3.0.0-ballot
Identifier urn:oid:2.16.840.1.113883.4.642.40.77.28.8
Jurisdiction World
Steward (Publisher) HL7 International / FHIR Infrastructure
Steward Contact HL7 International / FHIR Infrastructure
Description

Returns each condition with the ICD-10 code its SNOMED CT code maps to under the http://example.org/ConceptMap/sct-to-icd10|2026 concept map. The map is declared as a dependency and the runner exposes it under the sct_to_icd10 label as a relation with the columns source_system, source_version, source_code, source_display, target_system, target_version, target_code, target_display and relationship (see Terminology in SQL). The LEFT JOIN keeps conditions the map does not translate, with a null target_code; the relationship predicate excludes rows asserting that a target is not related to the source, and admits null so that a noMap row is kept.

SELECT conditions.patient_id,
       conditions.code,
       sct_to_icd10.target_code,
       sct_to_icd10.relationship
FROM conditions
LEFT JOIN sct_to_icd10
  ON sct_to_icd10.source_system = conditions.system
 AND sct_to_icd10.source_code = conditions.code
 AND (sct_to_icd10.relationship IS NULL
      OR sct_to_icd10.relationship <> 'not-related-to')
Type http://hl7.org/fhir/uv/sql-on-fhir/CodeSystem/LibraryTypesCodes#sql-query
Parameters
Parameter None
Library Content
application/sqlContent
Encoded data 
Citations and References
Dependency Description: Condition view with patient_id, system, version and code columns
Resource: https://example.org/ViewDefinition/conditions
Canonical URL: https://example.org/ViewDefinition/conditions
Dependency Description: SNOMED CT to ICD-10 concept map, exposed as a relation
Resource: http://example.org/ConceptMap/sct-to-icd10|2026
Canonical URL: http://example.org/ConceptMap/sct-to-icd10|2026
Generated using version 0.5.6 of the sample-content-ig Liquid templates