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
| Page standards status: Informative |
<Library xmlns="http://hl7.org/fhir">
<id value="CardiovascularDiseasePatientsQuery"/>
<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">Cardiovascular Disease Patients</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.7</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 whose code is a member of the
<code>http://example.org/ValueSet/cardiovascular-disease|2026</code> value set. The value
set is declared as a dependency and the runner exposes it under the <code>cvd_codes</code>
label as a relation with the columns <code>system</code>, <code>version</code>, <code>code</code>, <code>display</code> and
<code>inactive</code> (see <a href="terminology-in-sql.html">Terminology in SQL</a>). Because the
<code>conditions</code> view carries no code system version, membership is tested on
<code>system</code> and <code>code</code> with a semi-join, which cannot multiply rows.</p>
<pre><code class="language-sql">SELECT conditions.patient_id, conditions.code
FROM conditions
WHERE EXISTS (
SELECT 1
FROM cvd_codes
WHERE cvd_codes.system = conditions.system
AND cvd_codes.code = conditions.code
)
</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>: Cardiovascular disease value set, exposed as a relation
<br/>
<em>Resource</em>: <code>http://example.org/ValueSet/cardiovascular-disease|2026</code>
<br/>
<em>Canonical URL</em>: <tt>http://example.org/ValueSet/cardiovascular-disease|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/CardiovascularDiseasePatientsQuery"/>
<identifier>
<system value="urn:ietf:rfc:3986"/>
<value value="urn:oid:2.16.840.1.113883.4.642.40.77.28.7"/>
</identifier>
<version value="3.0.0-ballot"/>
<name value="CardiovascularDiseasePatientsQuery"/>
<title value="Cardiovascular Disease Patients"/>
<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 whose code is a member of the
`http://example.org/ValueSet/cardiovascular-disease|2026` value set. The value
set is declared as a dependency and the runner exposes it under the `cvd_codes`
label as a relation with the columns `system`, `version`, `code`, `display` and
`inactive` (see [Terminology in SQL](terminology-in-sql.html)). Because the
`conditions` view carries no code system version, membership is tested on
`system` and `code` with a semi-join, which cannot multiply rows.
```sql
SELECT conditions.patient_id, conditions.code
FROM conditions
WHERE EXISTS (
SELECT 1
FROM cvd_codes
WHERE cvd_codes.system = conditions.system
AND cvd_codes.code = conditions.code
)
```"/>
<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="cvd_codes"/>
<display value="Cardiovascular disease value set, exposed as a relation"/>
<resource
value="http://example.org/ValueSet/cardiovascular-disease|2026"/>
</relatedArtifact>
<content>
<extension
url="http://hl7.org/fhir/uv/sql-on-fhir/StructureDefinition/sql-text">
<valueString
value="SELECT conditions.patient_id, conditions.code
FROM conditions
WHERE EXISTS (
SELECT 1
FROM cvd_codes
WHERE cvd_codes.system = conditions.system
AND cvd_codes.code = conditions.code
)"/>
</extension>
<contentType value="application/sql"/>
<data
value="U0VMRUNUIGNvbmRpdGlvbnMucGF0aWVudF9pZCwgY29uZGl0aW9ucy5jb2RlCkZST00gY29uZGl0aW9ucwpXSEVSRSBFWElTVFMgKAogIFNFTEVDVCAxCiAgRlJPTSBjdmRfY29kZXMKICBXSEVSRSBjdmRfY29kZXMuc3lzdGVtID0gY29uZGl0aW9ucy5zeXN0ZW0KICAgIEFORCBjdmRfY29kZXMuY29kZSA9IGNvbmRpdGlvbnMuY29kZQop"/>
</content>
</Library>