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

: Conditions Translated to ICD-10

Page standards status: Informative

Raw xml | Download


<Library xmlns="http://hl7.org/fhir">
  <id value="ConditionsToIcd10Query"/>
  <meta>
    <profile
             value="http://hl7.org/fhir/uv/sql-on-fhir/StructureDefinition/SQLQuery"/>
  </meta>
  <language value="en"/>
  <text>
    <status value="extensions"/>
    <div xmlns="http://www.w3.org/1999/xhtml">
  <table class="narrative-table">
    <tbody>
<tr>


<th colspan="2" scope="row" class="row-header"><a name="metadata"> </a>Metadata</th>


</tr>

<tr>


<th scope="row" class="row-header">Title</th>



<td class="content-container">Conditions Translated to ICD-10</td>


</tr>





<tr>


<th scope="row" class="row-header">Version</th>



<td class="content-container">3.0.0-ballot</td>


</tr>







  
<tr>


<th scope="row" class="row-header">Identifier</th>



<td class="content-container">urn:oid:2.16.840.1.113883.4.642.40.77.28.8</td>


</tr>



















<tr>


<th scope="row" class="row-header">Jurisdiction</th>



<td class="content-container">
    World


</td>


</tr>











<tr>


<th scope="row" class="row-header">Steward (Publisher)</th>



<td class="content-container">HL7 International / FHIR Infrastructure</td>


</tr>



<tr>


<th scope="row" class="row-header">Steward Contact</th>



<td class="content-container">HL7 International / FHIR Infrastructure</td>


</tr>







<tr>


<th scope="row" class="row-header">Description</th>



<td class="content-container"><div><p>Returns each condition with the ICD-10 code its SNOMED CT code maps to under
the <code>http://example.org/ConceptMap/sct-to-icd10|2026</code> concept map. The map is
declared as a dependency and the runner exposes it under the <code>sct_to_icd10</code>
label as a relation with the columns <code>source_system</code>, <code>source_version</code>,
<code>source_code</code>, <code>source_display</code>, <code>target_system</code>, <code>target_version</code>,
<code>target_code</code>, <code>target_display</code> and <code>relationship</code> (see
<a href="terminology-in-sql.html#concept-map-relation">Terminology in SQL</a>). The
<code>LEFT JOIN</code> keeps conditions the map does not translate, with a null
<code>target_code</code>; the <code>relationship</code> predicate excludes rows asserting that a
target is not related to the source, and admits null so that a <code>noMap</code> row is
kept.</p>
<pre><code class="language-sql">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 &lt;&gt; 'not-related-to')
</code></pre>
</div></td>


</tr>









<tr>


<th scope="row" class="row-header">Type</th>



<td class="content-container">
    <a href="CodeSystem-LibraryTypesCodes.html">http://hl7.org/fhir/uv/sql-on-fhir/CodeSystem/LibraryTypesCodes</a>#sql-query


</td>


</tr>













<tr>


<th colspan="2" scope="row" class="row-header"><a name="parameters"> </a>Parameters</th>


</tr>


<tr>


<th scope="row" class="row-header">Parameter</th>



<td class="content-container">None</td>


</tr>








  <tr>


<th colspan="2" scope="row" class="row-header">Library Content</th>


</tr>
  
    
    <tr>
      <th scope="row" class="row-header">application/sqlContent</th>
      <td>
        <pre style="border: none;" class="content-container highlight language-cql"><code>Encoded data </code></pre>
      </td>
    </tr>
    
  


<tr>


<th colspan="2" scope="row" class="row-header"><a name="related-artifacts"> </a>Citations and References</th>


</tr>


<tr>
  
  
  
  
  

<th scope="row" class="row-header">Dependency</th>


  
  
  <td class="content-container">
    
    <em>Description</em>: Condition view with patient_id, system, version and code columns
    
    <br/>
    
    
    
    
    
    
    <em>Resource</em>: <code>https://example.org/ViewDefinition/conditions</code>
    <br/>
    <em>Canonical URL</em>: <tt>https://example.org/ViewDefinition/conditions</tt>
    
    
    
  </td>
</tr>

<tr>
  
  
  
  
  

<th scope="row" class="row-header">Dependency</th>


  
  
  <td class="content-container">
    
    <em>Description</em>: SNOMED CT to ICD-10 concept map, exposed as a relation
    
    <br/>
    
    
    
    
    
    
    <em>Resource</em>: <code>http://example.org/ConceptMap/sct-to-icd10|2026</code>
    <br/>
    <em>Canonical URL</em>: <tt>http://example.org/ConceptMap/sct-to-icd10|2026</tt>
    
    
    
  </td>
</tr>




<tr>
  <th colspan="2" scope="row" class="row-header">Generated using version 0.5.6 of the sample-content-ig Liquid templates</th>
</tr>

    </tbody>
  </table>
</div>
  </text>
  <url
       value="http://hl7.org/fhir/uv/sql-on-fhir/Library/ConditionsToIcd10Query"/>
  <identifier>
    <system value="urn:ietf:rfc:3986"/>
    <value value="urn:oid:2.16.840.1.113883.4.642.40.77.28.8"/>
  </identifier>
  <version value="3.0.0-ballot"/>
  <name value="ConditionsToIcd10Query"/>
  <title value="Conditions Translated to ICD-10"/>
  <status value="active"/>
  <type>
    <coding>
      <system
              value="http://hl7.org/fhir/uv/sql-on-fhir/CodeSystem/LibraryTypesCodes"/>
      <code value="sql-query"/>
    </coding>
  </type>
  <date value="2026-10-13T03:59:03+00:00"/>
  <publisher value="HL7 International / FHIR Infrastructure"/>
  <contact>
    <name value="HL7 International / FHIR Infrastructure"/>
    <telecom>
      <system value="url"/>
      <value value="http://www.hl7.org/Special/committees/fiwg"/>
    </telecom>
  </contact>
  <description
               value="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](terminology-in-sql.html#concept-map-relation)). 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.

```sql
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 &lt;&gt; 'not-related-to')
```"/>
  <jurisdiction>
    <coding>
      <system value="http://unstats.un.org/unsd/methods/m49/m49.htm"/>
      <code value="001"/>
      <display value="World"/>
    </coding>
  </jurisdiction>
  <relatedArtifact>
    <type value="depends-on"/>
    <label value="conditions"/>
    <display
             value="Condition view with patient_id, system, version and code columns"/>
    <resource value="https://example.org/ViewDefinition/conditions"/>
  </relatedArtifact>
  <relatedArtifact>
    <type value="depends-on"/>
    <label value="sct_to_icd10"/>
    <display value="SNOMED CT to ICD-10 concept map, exposed as a relation"/>
    <resource value="http://example.org/ConceptMap/sct-to-icd10|2026"/>
  </relatedArtifact>
  <content>
    <extension
               url="http://hl7.org/fhir/uv/sql-on-fhir/StructureDefinition/sql-text">
      <valueString
                   value="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 &lt;&gt; 'not-related-to')"/>
    </extension>
    <contentType value="application/sql"/>
    <data
          value="U0VMRUNUIGNvbmRpdGlvbnMucGF0aWVudF9pZCwKICAgICAgIGNvbmRpdGlvbnMuY29kZSwKICAgICAgIHNjdF90b19pY2QxMC50YXJnZXRfY29kZSwKICAgICAgIHNjdF90b19pY2QxMC5yZWxhdGlvbnNoaXAKRlJPTSBjb25kaXRpb25zCkxFRlQgSk9JTiBzY3RfdG9faWNkMTAKICBPTiBzY3RfdG9faWNkMTAuc291cmNlX3N5c3RlbSA9IGNvbmRpdGlvbnMuc3lzdGVtCiBBTkQgc2N0X3RvX2ljZDEwLnNvdXJjZV9jb2RlID0gY29uZGl0aW9ucy5jb2RlCiBBTkQgKHNjdF90b19pY2QxMC5yZWxhdGlvbnNoaXAgSVMgTlVMTAogICAgICBPUiBzY3RfdG9faWNkMTAucmVsYXRpb25zaGlwIDw+ICdub3QtcmVsYXRlZC10bycp"/>
  </content>
</Library>