<?xml version="1.0" encoding="UTF-8"?>

<Bundle xmlns="http://hl7.org/fhir">
  <id value="recruit-sample-study-transaction"/>
  <language value="en"/>
  <type value="transaction"/>
  <entry>
    <resource>
      <ResearchStudy>
        <id value="98d96608-475f-4386-b7b5-6ddc1eb57e71"/>
        <meta>
          <profile value="https://openrecruit.dev/fhir/StructureDefinition/recruit-research-study"/>
        </meta>
        <language value="en"/>
        <text>
          <status value="extensions"/><div xmlns="http://www.w3.org/1999/xhtml"><a name="ResearchStudy_98d96608-475f-4386-b7b5-6ddc1eb57e71"> </a><p class="res-header-id"><b>Generated Narrative: ResearchStudy 98d96608-475f-4386-b7b5-6ddc1eb57e71</b></p><a name="98d96608-475f-4386-b7b5-6ddc1eb57e71"> </a><a name="hc98d96608-475f-4386-b7b5-6ddc1eb57e71"> </a><div style="display: inline-block; background-color: #d9e0e7; padding: 6px; margin: 4px; border: 1px solid #8da1b4; border-radius: 5px; line-height: 60%"><p style="margin-bottom: 0px"/><p style="margin-bottom: 0px">Profile: <a href="StructureDefinition-recruit-research-study.html">RecruitResearchStudy</a></p></div><p><b>MII EX Studie Akronym</b>: DEMO-BRONCHITIS</p><p><b>identifier</b>: <a href="NamingSystem-sql-criteria-research-study-id.html" title="The identifier system for a RecruitResearchStudy whose SQL-encoded criteria are authored as FSH, such as the demo study.">SqlCriteriaResearchStudyIdentifier</a>/bronchitis</p><p><b>title</b>: Bronchitis Demo Study</p><p><b>status</b>: Active</p><p><b>enrollment</b>: <a href="Bundle-recruit-sample-study-transaction.html#Group_be24c1a6-b052-4360-871b-0a1b7b6bdfb4">be24c1a6-b052-4360-871b-0a1b7b6bdfb4</a></p></div>
        </text>
        <extension url="https://www.medizininformatik-initiative.de/fhir/modul-studie/StructureDefinition/mii-ex-studie-akronym">
          <valueString value="DEMO-BRONCHITIS"/>
        </extension>
        <identifier>
          <system value="https://openrecruit.dev/fhir/identifiers/sql-criteria-research-study-id"/>
          <value value="bronchitis"/>
        </identifier>
        <title value="Bronchitis Demo Study"/>
        <status value="active"/>
        <enrollment>
          <reference value="Group/be24c1a6-b052-4360-871b-0a1b7b6bdfb4"/>
        </enrollment>
      </ResearchStudy>
    </resource>
    <request>
      <method value="PUT"/>
      <url value="ResearchStudy/98d96608-475f-4386-b7b5-6ddc1eb57e71"/>
    </request>
  </entry>
  <entry>
    <resource>
      <Group>
        <id value="be24c1a6-b052-4360-871b-0a1b7b6bdfb4"/>
        <meta>
          <profile value="https://openrecruit.dev/fhir/StructureDefinition/eligibility-group"/>
        </meta>
        <language value="en"/>
        <text>
          <status value="extensions"/><div xmlns="http://www.w3.org/1999/xhtml"><a name="Group_be24c1a6-b052-4360-871b-0a1b7b6bdfb4"> </a>
  <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">Identifier</th>



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


</tr>


















































<tr>


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



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


</tr>


<tr>


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



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


</tr>


<tr>


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



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


</tr>


<tr>


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



<td class="content-container">SQL-encoded eligibility criteria
</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>
        <identifier>
          <system value="https://openrecruit.dev/fhir/identifiers/eligibility-group-id"/>
          <value value="bronchitis"/>
        </identifier>
        <active value="true"/>
        <type value="person"/>
        <actual value="false"/>
        <code>
          <coding>
            <system value="https://openrecruit.dev/fhir/CodeSystem/eligibility-criteria-types"/>
            <code value="sql-query"/>
          </coding>
          <text value="SQL-encoded eligibility criteria"/>
        </code>
        <characteristic>
          <code>
            <text value="Bronchitis diagnosis"/>
          </code>
          <valueReference>
            <reference value="Library/bb4e037a-0a43-4fee-befc-b9ed598c3e64"/>
          </valueReference>
          <exclude value="false"/>
        </characteristic>
        <characteristic>
          <code>
            <text value="Age &gt; 18 years"/>
          </code>
          <valueReference>
            <reference value="Library/12b09320-2426-43e9-930d-64f151d39e68"/>
          </valueReference>
          <exclude value="false"/>
        </characteristic>
        <characteristic>
          <code>
            <text value="No sepsis diagnosis within 3 months of the bronchitis diagnosis"/>
          </code>
          <valueReference>
            <reference value="Library/9be54194-a4d9-4835-bf9e-21314e4f046c"/>
          </valueReference>
          <exclude value="true"/>
        </characteristic>
        <characteristic>
          <code>
            <text value="LDL cholesterol below 190 mg/dL"/>
          </code>
          <valueReference>
            <reference value="Library/5f3c2a8e-7d41-4b9a-9e2f-6c1d8b0a4e73"/>
          </valueReference>
          <exclude value="false"/>
        </characteristic>
      </Group>
    </resource>
    <request>
      <method value="PUT"/>
      <url value="Group/be24c1a6-b052-4360-871b-0a1b7b6bdfb4"/>
    </request>
  </entry>
  <entry>
    <resource>
      <Library>
        <id value="bb4e037a-0a43-4fee-befc-b9ed598c3e64"/>
        <meta>
          <profile value="https://openrecruit.dev/fhir/StructureDefinition/sql-query-library"/>
        </meta>
        <language value="en"/>
        <text>
          <status value="extensions"/><div xmlns="http://www.w3.org/1999/xhtml"><a name="Library_bb4e037a-0a43-4fee-befc-b9ed598c3e64"> </a>
  <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">Bronchitis diagnosis</td>


</tr>













  
<tr>


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



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


</tr>





































<tr>


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



<td class="content-container"><div><p>Active bronchitis diagnosis (SNOMED CT code 10509002).</p>
</div></td>


</tr>









<tr>


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



<td class="content-container">
    <a href="https://simplifier.net/resolve?scope=de.medizininformatikinitiative.kerndatensatz.studie@2026.0.2&amp;canonical=https://sql-on-fhir.org/ig/CodeSystem/LibraryTypesCodes">https://sql-on-fhir.org/ig/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/sql;dialect=trinoContent</th>
      <td>
        <pre style="border: none;" class="content-container highlight language-cql"><code>Encoded data </code></pre>
      </td>
    </tr>
    
  
    
    <tr>
      <th scope="row" class="row-header">application/sql;dialect=duckdbContent</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">Generated using version 0.5.6 of the sample-content-ig Liquid templates</th>
</tr>

    </tbody>
  </table>
</div>
        </text>
        <identifier>
          <system value="https://openrecruit.dev/fhir/identifiers/sql-criteria-library-id"/>
          <value value="bronchitis"/>
        </identifier>
        <name value="bronchitis"/>
        <title value="Bronchitis diagnosis"/>
        <status value="active"/>
        <type>
          <coding>
            <system value="https://sql-on-fhir.org/ig/CodeSystem/LibraryTypesCodes"/>
            <code value="sql-query"/>
          </coding>
        </type>
        <description value="Active bronchitis diagnosis (SNOMED CT code 10509002)."/>
        <content>
          <extension url="https://sql-on-fhir.org/ig/StructureDefinition/sql-text">
            <valueString value="SELECT&#xA;    patient.id AS patient_id,&#xA;    EXISTS (&#xA;        SELECT 1&#xA;        FROM&#xA;            fhir.default.condition,&#xA;            UNNEST(condition.code.coding) AS condition_coding&#xA;        WHERE&#xA;            condition.subject.reference = CONCAT('Patient/', patient.id)&#xA;            AND condition_coding.system = 'http://snomed.info/sct'&#xA;            AND condition_coding.code IN ('10509002')&#xA;    ) AS is_met&#xA;FROM fhir.default.patient AS patient"/>
          </extension>
          <contentType value="application/sql;dialect=trino"/>
          <data value="U0VMRUNUCiAgICBwYXRpZW50LmlkIEFTIHBhdGllbnRfaWQsCiAgICBFWElTVFMgKAogICAgICAgIFNFTEVDVCAxCiAgICAgICAgRlJPTQogICAgICAgICAgICBmaGlyLmRlZmF1bHQuY29uZGl0aW9uLAogICAgICAgICAgICBVTk5FU1QoY29uZGl0aW9uLmNvZGUuY29kaW5nKSBBUyBjb25kaXRpb25fY29kaW5nCiAgICAgICAgV0hFUkUKICAgICAgICAgICAgY29uZGl0aW9uLnN1YmplY3QucmVmZXJlbmNlID0gQ09OQ0FUKCdQYXRpZW50LycsIHBhdGllbnQuaWQpCiAgICAgICAgICAgIEFORCBjb25kaXRpb25fY29kaW5nLnN5c3RlbSA9ICdodHRwOi8vc25vbWVkLmluZm8vc2N0JwogICAgICAgICAgICBBTkQgY29uZGl0aW9uX2NvZGluZy5jb2RlIElOICgnMTA1MDkwMDInKQogICAgKSBBUyBpc19tZXQKRlJPTSBmaGlyLmRlZmF1bHQucGF0aWVudCBBUyBwYXRpZW50"/>
        </content>
        <content>
          <extension url="https://sql-on-fhir.org/ig/StructureDefinition/sql-text">
            <valueString value="SELECT&#xA;    patient.id AS patient_id,&#xA;    EXISTS (&#xA;        SELECT 1&#xA;        FROM&#xA;            fhir.default.condition,&#xA;            UNNEST(condition.code.coding) AS u(condition_coding)&#xA;        WHERE&#xA;            condition.subject.reference = CONCAT('Patient/', patient.id)&#xA;            AND condition_coding.system = 'http://snomed.info/sct'&#xA;            AND condition_coding.code IN ('10509002')&#xA;    ) AS is_met&#xA;FROM fhir.default.patient AS patient"/>
          </extension>
          <contentType value="application/sql;dialect=duckdb"/>
          <data value="U0VMRUNUCiAgICBwYXRpZW50LmlkIEFTIHBhdGllbnRfaWQsCiAgICBFWElTVFMgKAogICAgICAgIFNFTEVDVCAxCiAgICAgICAgRlJPTQogICAgICAgICAgICBmaGlyLmRlZmF1bHQuY29uZGl0aW9uLAogICAgICAgICAgICBVTk5FU1QoY29uZGl0aW9uLmNvZGUuY29kaW5nKSBBUyB1KGNvbmRpdGlvbl9jb2RpbmcpCiAgICAgICAgV0hFUkUKICAgICAgICAgICAgY29uZGl0aW9uLnN1YmplY3QucmVmZXJlbmNlID0gQ09OQ0FUKCdQYXRpZW50LycsIHBhdGllbnQuaWQpCiAgICAgICAgICAgIEFORCBjb25kaXRpb25fY29kaW5nLnN5c3RlbSA9ICdodHRwOi8vc25vbWVkLmluZm8vc2N0JwogICAgICAgICAgICBBTkQgY29uZGl0aW9uX2NvZGluZy5jb2RlIElOICgnMTA1MDkwMDInKQogICAgKSBBUyBpc19tZXQKRlJPTSBmaGlyLmRlZmF1bHQucGF0aWVudCBBUyBwYXRpZW50"/>
        </content>
      </Library>
    </resource>
    <request>
      <method value="PUT"/>
      <url value="Library/bb4e037a-0a43-4fee-befc-b9ed598c3e64"/>
    </request>
  </entry>
  <entry>
    <resource>
      <Library>
        <id value="12b09320-2426-43e9-930d-64f151d39e68"/>
        <meta>
          <profile value="https://openrecruit.dev/fhir/StructureDefinition/sql-query-library"/>
        </meta>
        <language value="en"/>
        <text>
          <status value="extensions"/><div xmlns="http://www.w3.org/1999/xhtml"><a name="Library_12b09320-2426-43e9-930d-64f151d39e68"> </a>
  <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">Age over 18</td>


</tr>













  
<tr>


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



<td class="content-container">age-over-18</td>


</tr>





































<tr>


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



<td class="content-container"><div><p>Patient is over 18 years old.</p>
</div></td>


</tr>









<tr>


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



<td class="content-container">
    <a href="https://simplifier.net/resolve?scope=de.medizininformatikinitiative.kerndatensatz.studie@2026.0.2&amp;canonical=https://sql-on-fhir.org/ig/CodeSystem/LibraryTypesCodes">https://sql-on-fhir.org/ig/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/sql;dialect=trinoContent</th>
      <td>
        <pre style="border: none;" class="content-container highlight language-cql"><code>Encoded data </code></pre>
      </td>
    </tr>
    
  
    
    <tr>
      <th scope="row" class="row-header">application/sql;dialect=duckdbContent</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">Generated using version 0.5.6 of the sample-content-ig Liquid templates</th>
</tr>

    </tbody>
  </table>
</div>
        </text>
        <identifier>
          <system value="https://openrecruit.dev/fhir/identifiers/sql-criteria-library-id"/>
          <value value="age-over-18"/>
        </identifier>
        <name value="age-over-18"/>
        <title value="Age over 18"/>
        <status value="active"/>
        <type>
          <coding>
            <system value="https://sql-on-fhir.org/ig/CodeSystem/LibraryTypesCodes"/>
            <code value="sql-query"/>
          </coding>
        </type>
        <description value="Patient is over 18 years old."/>
        <content>
          <extension url="https://sql-on-fhir.org/ig/StructureDefinition/sql-text">
            <valueString value="SELECT&#xA;    patient.id AS patient_id,&#xA;    date_diff('year', date(patient.birthdate), current_date) &gt; 18 AS is_met&#xA;FROM fhir.default.patient AS patient"/>
          </extension>
          <contentType value="application/sql;dialect=trino"/>
          <data value="U0VMRUNUCiAgICBwYXRpZW50LmlkIEFTIHBhdGllbnRfaWQsCiAgICBkYXRlX2RpZmYoJ3llYXInLCBkYXRlKHBhdGllbnQuYmlydGhkYXRlKSwgY3VycmVudF9kYXRlKSA+IDE4IEFTIGlzX21ldApGUk9NIGZoaXIuZGVmYXVsdC5wYXRpZW50IEFTIHBhdGllbnQ="/>
        </content>
        <content>
          <extension url="https://sql-on-fhir.org/ig/StructureDefinition/sql-text">
            <valueString value="SELECT&#xA;    patient.id AS patient_id,&#xA;    date_sub('year', CAST(patient.birthdate AS DATE), current_date) &gt; 18 AS is_met&#xA;FROM fhir.default.patient AS patient"/>
          </extension>
          <contentType value="application/sql;dialect=duckdb"/>
          <data value="U0VMRUNUCiAgICBwYXRpZW50LmlkIEFTIHBhdGllbnRfaWQsCiAgICBkYXRlX3N1YigneWVhcicsIENBU1QocGF0aWVudC5iaXJ0aGRhdGUgQVMgREFURSksIGN1cnJlbnRfZGF0ZSkgPiAxOCBBUyBpc19tZXQKRlJPTSBmaGlyLmRlZmF1bHQucGF0aWVudCBBUyBwYXRpZW50"/>
        </content>
      </Library>
    </resource>
    <request>
      <method value="PUT"/>
      <url value="Library/12b09320-2426-43e9-930d-64f151d39e68"/>
    </request>
  </entry>
  <entry>
    <resource>
      <Library>
        <id value="9be54194-a4d9-4835-bf9e-21314e4f046c"/>
        <meta>
          <profile value="https://openrecruit.dev/fhir/StructureDefinition/sql-query-library"/>
        </meta>
        <language value="en"/>
        <text>
          <status value="extensions"/><div xmlns="http://www.w3.org/1999/xhtml"><a name="Library_9be54194-a4d9-4835-bf9e-21314e4f046c"> </a>
  <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">Sepsis within 3 months of bronchitis</td>


</tr>













  
<tr>


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



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


</tr>





































<tr>


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



<td class="content-container"><div><p>Sepsis diagnosis (SNOMED CT code 91302008) with an onset within 3 months before or after a bronchitis diagnosis (SNOMED CT code 10509002), falling back to the recorded date where no onset is documented.</p>
</div></td>


</tr>









<tr>


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



<td class="content-container">
    <a href="https://simplifier.net/resolve?scope=de.medizininformatikinitiative.kerndatensatz.studie@2026.0.2&amp;canonical=https://sql-on-fhir.org/ig/CodeSystem/LibraryTypesCodes">https://sql-on-fhir.org/ig/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/sql;dialect=trinoContent</th>
      <td>
        <pre style="border: none;" class="content-container highlight language-cql"><code>Encoded data </code></pre>
      </td>
    </tr>
    
  
    
    <tr>
      <th scope="row" class="row-header">application/sql;dialect=duckdbContent</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">Generated using version 0.5.6 of the sample-content-ig Liquid templates</th>
</tr>

    </tbody>
  </table>
</div>
        </text>
        <identifier>
          <system value="https://openrecruit.dev/fhir/identifiers/sql-criteria-library-id"/>
          <value value="sepsis"/>
        </identifier>
        <name value="sepsis"/>
        <title value="Sepsis within 3 months of bronchitis"/>
        <status value="active"/>
        <type>
          <coding>
            <system value="https://sql-on-fhir.org/ig/CodeSystem/LibraryTypesCodes"/>
            <code value="sql-query"/>
          </coding>
        </type>
        <description value="Sepsis diagnosis (SNOMED CT code 91302008) with an onset within 3 months before or after a bronchitis diagnosis (SNOMED CT code 10509002), falling back to the recorded date where no onset is documented."/>
        <content>
          <extension url="https://sql-on-fhir.org/ig/StructureDefinition/sql-text">
            <valueString value="SELECT&#xA;    patient.id AS patient_id,&#xA;    EXISTS (&#xA;        SELECT 1&#xA;        FROM&#xA;            fhir.default.condition AS sepsis,&#xA;            UNNEST(sepsis.code.coding) AS sepsis_coding,&#xA;            fhir.default.condition AS bronchitis,&#xA;            UNNEST(bronchitis.code.coding) AS bronchitis_coding&#xA;        WHERE&#xA;            sepsis.subject.reference = CONCAT('Patient/', patient.id)&#xA;            AND sepsis_coding.system = 'http://snomed.info/sct'&#xA;            AND sepsis_coding.code IN ('91302008')&#xA;            AND bronchitis.subject.reference = sepsis.subject.reference&#xA;            AND bronchitis_coding.system = 'http://snomed.info/sct'&#xA;            AND bronchitis_coding.code IN ('10509002')&#xA;            AND from_iso8601_timestamp(COALESCE(sepsis.onsetdatetime, sepsis.recordeddate))&#xA;                BETWEEN from_iso8601_timestamp(COALESCE(bronchitis.onsetdatetime, bronchitis.recordeddate)) - INTERVAL '3' MONTH&#xA;                    AND from_iso8601_timestamp(COALESCE(bronchitis.onsetdatetime, bronchitis.recordeddate)) + INTERVAL '3' MONTH&#xA;    ) AS is_met&#xA;FROM fhir.default.patient AS patient"/>
          </extension>
          <contentType value="application/sql;dialect=trino"/>
          <data value="U0VMRUNUCiAgICBwYXRpZW50LmlkIEFTIHBhdGllbnRfaWQsCiAgICBFWElTVFMgKAogICAgICAgIFNFTEVDVCAxCiAgICAgICAgRlJPTQogICAgICAgICAgICBmaGlyLmRlZmF1bHQuY29uZGl0aW9uIEFTIHNlcHNpcywKICAgICAgICAgICAgVU5ORVNUKHNlcHNpcy5jb2RlLmNvZGluZykgQVMgc2Vwc2lzX2NvZGluZywKICAgICAgICAgICAgZmhpci5kZWZhdWx0LmNvbmRpdGlvbiBBUyBicm9uY2hpdGlzLAogICAgICAgICAgICBVTk5FU1QoYnJvbmNoaXRpcy5jb2RlLmNvZGluZykgQVMgYnJvbmNoaXRpc19jb2RpbmcKICAgICAgICBXSEVSRQogICAgICAgICAgICBzZXBzaXMuc3ViamVjdC5yZWZlcmVuY2UgPSBDT05DQVQoJ1BhdGllbnQvJywgcGF0aWVudC5pZCkKICAgICAgICAgICAgQU5EIHNlcHNpc19jb2Rpbmcuc3lzdGVtID0gJ2h0dHA6Ly9zbm9tZWQuaW5mby9zY3QnCiAgICAgICAgICAgIEFORCBzZXBzaXNfY29kaW5nLmNvZGUgSU4gKCc5MTMwMjAwOCcpCiAgICAgICAgICAgIEFORCBicm9uY2hpdGlzLnN1YmplY3QucmVmZXJlbmNlID0gc2Vwc2lzLnN1YmplY3QucmVmZXJlbmNlCiAgICAgICAgICAgIEFORCBicm9uY2hpdGlzX2NvZGluZy5zeXN0ZW0gPSAnaHR0cDovL3Nub21lZC5pbmZvL3NjdCcKICAgICAgICAgICAgQU5EIGJyb25jaGl0aXNfY29kaW5nLmNvZGUgSU4gKCcxMDUwOTAwMicpCiAgICAgICAgICAgIEFORCBmcm9tX2lzbzg2MDFfdGltZXN0YW1wKENPQUxFU0NFKHNlcHNpcy5vbnNldGRhdGV0aW1lLCBzZXBzaXMucmVjb3JkZWRkYXRlKSkKICAgICAgICAgICAgICAgIEJFVFdFRU4gZnJvbV9pc284NjAxX3RpbWVzdGFtcChDT0FMRVNDRShicm9uY2hpdGlzLm9uc2V0ZGF0ZXRpbWUsIGJyb25jaGl0aXMucmVjb3JkZWRkYXRlKSkgLSBJTlRFUlZBTCAnMycgTU9OVEgKICAgICAgICAgICAgICAgICAgICBBTkQgZnJvbV9pc284NjAxX3RpbWVzdGFtcChDT0FMRVNDRShicm9uY2hpdGlzLm9uc2V0ZGF0ZXRpbWUsIGJyb25jaGl0aXMucmVjb3JkZWRkYXRlKSkgKyBJTlRFUlZBTCAnMycgTU9OVEgKICAgICkgQVMgaXNfbWV0CkZST00gZmhpci5kZWZhdWx0LnBhdGllbnQgQVMgcGF0aWVudA=="/>
        </content>
        <content>
          <extension url="https://sql-on-fhir.org/ig/StructureDefinition/sql-text">
            <valueString value="SELECT&#xA;    patient.id AS patient_id,&#xA;    EXISTS (&#xA;        SELECT 1&#xA;        FROM&#xA;            (&#xA;                SELECT&#xA;                    sepsis.subject.reference AS subject_reference,&#xA;                    CAST(COALESCE(sepsis.onsetdatetime, sepsis.recordeddate) AS TIMESTAMPTZ) AS onset&#xA;                FROM&#xA;                    fhir.default.condition AS sepsis,&#xA;                    UNNEST(sepsis.code.coding) AS u(sepsis_coding)&#xA;                WHERE&#xA;                    sepsis_coding.system = 'http://snomed.info/sct'&#xA;                    AND sepsis_coding.code IN ('91302008')&#xA;            ) AS sepsis&#xA;            JOIN (&#xA;                SELECT&#xA;                    bronchitis.subject.reference AS subject_reference,&#xA;                    CAST(COALESCE(bronchitis.onsetdatetime, bronchitis.recordeddate) AS TIMESTAMPTZ) AS onset&#xA;                FROM&#xA;                    fhir.default.condition AS bronchitis,&#xA;                    UNNEST(bronchitis.code.coding) AS v(bronchitis_coding)&#xA;                WHERE&#xA;                    bronchitis_coding.system = 'http://snomed.info/sct'&#xA;                    AND bronchitis_coding.code IN ('10509002')&#xA;            ) AS bronchitis ON bronchitis.subject_reference = sepsis.subject_reference&#xA;        WHERE&#xA;            sepsis.subject_reference = CONCAT('Patient/', patient.id)&#xA;            AND sepsis.onset&#xA;                BETWEEN bronchitis.onset - INTERVAL 3 MONTH&#xA;                    AND bronchitis.onset + INTERVAL 3 MONTH&#xA;    ) AS is_met&#xA;FROM fhir.default.patient AS patient"/>
          </extension>
          <contentType value="application/sql;dialect=duckdb"/>
          <data value="U0VMRUNUCiAgICBwYXRpZW50LmlkIEFTIHBhdGllbnRfaWQsCiAgICBFWElTVFMgKAogICAgICAgIFNFTEVDVCAxCiAgICAgICAgRlJPTQogICAgICAgICAgICAoCiAgICAgICAgICAgICAgICBTRUxFQ1QKICAgICAgICAgICAgICAgICAgICBzZXBzaXMuc3ViamVjdC5yZWZlcmVuY2UgQVMgc3ViamVjdF9yZWZlcmVuY2UsCiAgICAgICAgICAgICAgICAgICAgQ0FTVChDT0FMRVNDRShzZXBzaXMub25zZXRkYXRldGltZSwgc2Vwc2lzLnJlY29yZGVkZGF0ZSkgQVMgVElNRVNUQU1QVFopIEFTIG9uc2V0CiAgICAgICAgICAgICAgICBGUk9NCiAgICAgICAgICAgICAgICAgICAgZmhpci5kZWZhdWx0LmNvbmRpdGlvbiBBUyBzZXBzaXMsCiAgICAgICAgICAgICAgICAgICAgVU5ORVNUKHNlcHNpcy5jb2RlLmNvZGluZykgQVMgdShzZXBzaXNfY29kaW5nKQogICAgICAgICAgICAgICAgV0hFUkUKICAgICAgICAgICAgICAgICAgICBzZXBzaXNfY29kaW5nLnN5c3RlbSA9ICdodHRwOi8vc25vbWVkLmluZm8vc2N0JwogICAgICAgICAgICAgICAgICAgIEFORCBzZXBzaXNfY29kaW5nLmNvZGUgSU4gKCc5MTMwMjAwOCcpCiAgICAgICAgICAgICkgQVMgc2Vwc2lzCiAgICAgICAgICAgIEpPSU4gKAogICAgICAgICAgICAgICAgU0VMRUNUCiAgICAgICAgICAgICAgICAgICAgYnJvbmNoaXRpcy5zdWJqZWN0LnJlZmVyZW5jZSBBUyBzdWJqZWN0X3JlZmVyZW5jZSwKICAgICAgICAgICAgICAgICAgICBDQVNUKENPQUxFU0NFKGJyb25jaGl0aXMub25zZXRkYXRldGltZSwgYnJvbmNoaXRpcy5yZWNvcmRlZGRhdGUpIEFTIFRJTUVTVEFNUFRaKSBBUyBvbnNldAogICAgICAgICAgICAgICAgRlJPTQogICAgICAgICAgICAgICAgICAgIGZoaXIuZGVmYXVsdC5jb25kaXRpb24gQVMgYnJvbmNoaXRpcywKICAgICAgICAgICAgICAgICAgICBVTk5FU1QoYnJvbmNoaXRpcy5jb2RlLmNvZGluZykgQVMgdihicm9uY2hpdGlzX2NvZGluZykKICAgICAgICAgICAgICAgIFdIRVJFCiAgICAgICAgICAgICAgICAgICAgYnJvbmNoaXRpc19jb2Rpbmcuc3lzdGVtID0gJ2h0dHA6Ly9zbm9tZWQuaW5mby9zY3QnCiAgICAgICAgICAgICAgICAgICAgQU5EIGJyb25jaGl0aXNfY29kaW5nLmNvZGUgSU4gKCcxMDUwOTAwMicpCiAgICAgICAgICAgICkgQVMgYnJvbmNoaXRpcyBPTiBicm9uY2hpdGlzLnN1YmplY3RfcmVmZXJlbmNlID0gc2Vwc2lzLnN1YmplY3RfcmVmZXJlbmNlCiAgICAgICAgV0hFUkUKICAgICAgICAgICAgc2Vwc2lzLnN1YmplY3RfcmVmZXJlbmNlID0gQ09OQ0FUKCdQYXRpZW50LycsIHBhdGllbnQuaWQpCiAgICAgICAgICAgIEFORCBzZXBzaXMub25zZXQKICAgICAgICAgICAgICAgIEJFVFdFRU4gYnJvbmNoaXRpcy5vbnNldCAtIElOVEVSVkFMIDMgTU9OVEgKICAgICAgICAgICAgICAgICAgICBBTkQgYnJvbmNoaXRpcy5vbnNldCArIElOVEVSVkFMIDMgTU9OVEgKICAgICkgQVMgaXNfbWV0CkZST00gZmhpci5kZWZhdWx0LnBhdGllbnQgQVMgcGF0aWVudA=="/>
        </content>
      </Library>
    </resource>
    <request>
      <method value="PUT"/>
      <url value="Library/9be54194-a4d9-4835-bf9e-21314e4f046c"/>
    </request>
  </entry>
  <entry>
    <resource>
      <Library>
        <id value="5f3c2a8e-7d41-4b9a-9e2f-6c1d8b0a4e73"/>
        <meta>
          <profile value="https://openrecruit.dev/fhir/StructureDefinition/sql-query-library"/>
        </meta>
        <language value="en"/>
        <text>
          <status value="extensions"/><div xmlns="http://www.w3.org/1999/xhtml"><a name="Library_5f3c2a8e-7d41-4b9a-9e2f-6c1d8b0a4e73"> </a>
  <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">LDL cholesterol below 190 mg/dL</td>


</tr>













  
<tr>


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



<td class="content-container">ldl-below-190</td>


</tr>





































<tr>


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



<td class="content-container"><div><p>Every LDL cholesterol result (LOINC 18262-6) is below 190 mg/dL. Unknown if the patient has no LDL result, and indeterminate if results lie on both sides of the threshold, to demonstrate criteria the data doesn't settle.</p>
</div></td>


</tr>









<tr>


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



<td class="content-container">
    <a href="https://simplifier.net/resolve?scope=de.medizininformatikinitiative.kerndatensatz.studie@2026.0.2&amp;canonical=https://sql-on-fhir.org/ig/CodeSystem/LibraryTypesCodes">https://sql-on-fhir.org/ig/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/sql;dialect=trinoContent</th>
      <td>
        <pre style="border: none;" class="content-container highlight language-cql"><code>Encoded data </code></pre>
      </td>
    </tr>
    
  
    
    <tr>
      <th scope="row" class="row-header">application/sql;dialect=duckdbContent</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">Generated using version 0.5.6 of the sample-content-ig Liquid templates</th>
</tr>

    </tbody>
  </table>
</div>
        </text>
        <identifier>
          <system value="https://openrecruit.dev/fhir/identifiers/sql-criteria-library-id"/>
          <value value="ldl-below-190"/>
        </identifier>
        <name value="ldl-below-190"/>
        <title value="LDL cholesterol below 190 mg/dL"/>
        <status value="active"/>
        <type>
          <coding>
            <system value="https://sql-on-fhir.org/ig/CodeSystem/LibraryTypesCodes"/>
            <code value="sql-query"/>
          </coding>
        </type>
        <description value="Every LDL cholesterol result (LOINC 18262-6) is below 190 mg/dL. Unknown if the patient has no LDL result, and indeterminate if results lie on both sides of the threshold, to demonstrate criteria the data doesn't settle."/>
        <content>
          <extension url="https://sql-on-fhir.org/ig/StructureDefinition/sql-text">
            <valueString value="SELECT&#xA;    patient.id AS patient_id,&#xA;    CASE&#xA;        WHEN max(ldl.value) &lt; 190 THEN TRUE&#xA;        WHEN min(ldl.value) &gt;= 190 THEN FALSE&#xA;    END AS is_met,&#xA;    count(ldl.value) &gt; 0 AND min(ldl.value) &lt; 190 AND max(ldl.value) &gt;= 190 AS is_indeterminate,&#xA;    CASE&#xA;        WHEN count(ldl.value) = 0 THEN 'No LDL cholesterol result'&#xA;        WHEN min(ldl.value) &lt; 190 AND max(ldl.value) &gt;= 190&#xA;            THEN 'LDL cholesterol results between ' || format('%.1f', CAST(min(ldl.value) AS DOUBLE)) || ' and '&#xA;                || format('%.1f', CAST(max(ldl.value) AS DOUBLE)) || ' mg/dL'&#xA;    END AS result_note&#xA;FROM fhir.default.patient AS patient&#xA;LEFT JOIN (&#xA;    SELECT observation.subject.reference AS subject_reference, observation.valuequantity.value AS value&#xA;    FROM fhir.default.observation, UNNEST(observation.code.coding) AS observation_coding&#xA;    WHERE observation_coding.system = 'http://loinc.org' AND observation_coding.code = '18262-6'&#xA;) AS ldl ON ldl.subject_reference = CONCAT('Patient/', patient.id)&#xA;GROUP BY patient.id"/>
          </extension>
          <contentType value="application/sql;dialect=trino"/>
          <data value="U0VMRUNUCiAgICBwYXRpZW50LmlkIEFTIHBhdGllbnRfaWQsCiAgICBDQVNFCiAgICAgICAgV0hFTiBtYXgobGRsLnZhbHVlKSA8IDE5MCBUSEVOIFRSVUUKICAgICAgICBXSEVOIG1pbihsZGwudmFsdWUpID49IDE5MCBUSEVOIEZBTFNFCiAgICBFTkQgQVMgaXNfbWV0LAogICAgY291bnQobGRsLnZhbHVlKSA+IDAgQU5EIG1pbihsZGwudmFsdWUpIDwgMTkwIEFORCBtYXgobGRsLnZhbHVlKSA+PSAxOTAgQVMgaXNfaW5kZXRlcm1pbmF0ZSwKICAgIENBU0UKICAgICAgICBXSEVOIGNvdW50KGxkbC52YWx1ZSkgPSAwIFRIRU4gJ05vIExETCBjaG9sZXN0ZXJvbCByZXN1bHQnCiAgICAgICAgV0hFTiBtaW4obGRsLnZhbHVlKSA8IDE5MCBBTkQgbWF4KGxkbC52YWx1ZSkgPj0gMTkwCiAgICAgICAgICAgIFRIRU4gJ0xETCBjaG9sZXN0ZXJvbCByZXN1bHRzIGJldHdlZW4gJyB8fCBmb3JtYXQoJyUuMWYnLCBDQVNUKG1pbihsZGwudmFsdWUpIEFTIERPVUJMRSkpIHx8ICcgYW5kICcKICAgICAgICAgICAgICAgIHx8IGZvcm1hdCgnJS4xZicsIENBU1QobWF4KGxkbC52YWx1ZSkgQVMgRE9VQkxFKSkgfHwgJyBtZy9kTCcKICAgIEVORCBBUyByZXN1bHRfbm90ZQpGUk9NIGZoaXIuZGVmYXVsdC5wYXRpZW50IEFTIHBhdGllbnQKTEVGVCBKT0lOICgKICAgIFNFTEVDVCBvYnNlcnZhdGlvbi5zdWJqZWN0LnJlZmVyZW5jZSBBUyBzdWJqZWN0X3JlZmVyZW5jZSwgb2JzZXJ2YXRpb24udmFsdWVxdWFudGl0eS52YWx1ZSBBUyB2YWx1ZQogICAgRlJPTSBmaGlyLmRlZmF1bHQub2JzZXJ2YXRpb24sIFVOTkVTVChvYnNlcnZhdGlvbi5jb2RlLmNvZGluZykgQVMgb2JzZXJ2YXRpb25fY29kaW5nCiAgICBXSEVSRSBvYnNlcnZhdGlvbl9jb2Rpbmcuc3lzdGVtID0gJ2h0dHA6Ly9sb2luYy5vcmcnIEFORCBvYnNlcnZhdGlvbl9jb2RpbmcuY29kZSA9ICcxODI2Mi02JwopIEFTIGxkbCBPTiBsZGwuc3ViamVjdF9yZWZlcmVuY2UgPSBDT05DQVQoJ1BhdGllbnQvJywgcGF0aWVudC5pZCkKR1JPVVAgQlkgcGF0aWVudC5pZA=="/>
        </content>
        <content>
          <extension url="https://sql-on-fhir.org/ig/StructureDefinition/sql-text">
            <valueString value="SELECT&#xA;    patient.id AS patient_id,&#xA;    CASE&#xA;        WHEN max(ldl.value) &lt; 190 THEN TRUE&#xA;        WHEN min(ldl.value) &gt;= 190 THEN FALSE&#xA;    END AS is_met,&#xA;    count(ldl.value) &gt; 0 AND min(ldl.value) &lt; 190 AND max(ldl.value) &gt;= 190 AS is_indeterminate,&#xA;    CASE&#xA;        WHEN count(ldl.value) = 0 THEN 'No LDL cholesterol result'&#xA;        WHEN min(ldl.value) &lt; 190 AND max(ldl.value) &gt;= 190&#xA;            THEN 'LDL cholesterol results between ' || printf('%.1f', CAST(min(ldl.value) AS DOUBLE)) || ' and '&#xA;                || printf('%.1f', CAST(max(ldl.value) AS DOUBLE)) || ' mg/dL'&#xA;    END AS result_note&#xA;FROM fhir.default.patient AS patient&#xA;LEFT JOIN (&#xA;    SELECT observation.subject.reference AS subject_reference, observation.valuequantity.value AS value&#xA;    FROM fhir.default.observation, UNNEST(observation.code.coding) AS u(observation_coding)&#xA;    WHERE observation_coding.system = 'http://loinc.org' AND observation_coding.code = '18262-6'&#xA;) AS ldl ON ldl.subject_reference = CONCAT('Patient/', patient.id)&#xA;GROUP BY patient.id"/>
          </extension>
          <contentType value="application/sql;dialect=duckdb"/>
          <data value="U0VMRUNUCiAgICBwYXRpZW50LmlkIEFTIHBhdGllbnRfaWQsCiAgICBDQVNFCiAgICAgICAgV0hFTiBtYXgobGRsLnZhbHVlKSA8IDE5MCBUSEVOIFRSVUUKICAgICAgICBXSEVOIG1pbihsZGwudmFsdWUpID49IDE5MCBUSEVOIEZBTFNFCiAgICBFTkQgQVMgaXNfbWV0LAogICAgY291bnQobGRsLnZhbHVlKSA+IDAgQU5EIG1pbihsZGwudmFsdWUpIDwgMTkwIEFORCBtYXgobGRsLnZhbHVlKSA+PSAxOTAgQVMgaXNfaW5kZXRlcm1pbmF0ZSwKICAgIENBU0UKICAgICAgICBXSEVOIGNvdW50KGxkbC52YWx1ZSkgPSAwIFRIRU4gJ05vIExETCBjaG9sZXN0ZXJvbCByZXN1bHQnCiAgICAgICAgV0hFTiBtaW4obGRsLnZhbHVlKSA8IDE5MCBBTkQgbWF4KGxkbC52YWx1ZSkgPj0gMTkwCiAgICAgICAgICAgIFRIRU4gJ0xETCBjaG9sZXN0ZXJvbCByZXN1bHRzIGJldHdlZW4gJyB8fCBwcmludGYoJyUuMWYnLCBDQVNUKG1pbihsZGwudmFsdWUpIEFTIERPVUJMRSkpIHx8ICcgYW5kICcKICAgICAgICAgICAgICAgIHx8IHByaW50ZignJS4xZicsIENBU1QobWF4KGxkbC52YWx1ZSkgQVMgRE9VQkxFKSkgfHwgJyBtZy9kTCcKICAgIEVORCBBUyByZXN1bHRfbm90ZQpGUk9NIGZoaXIuZGVmYXVsdC5wYXRpZW50IEFTIHBhdGllbnQKTEVGVCBKT0lOICgKICAgIFNFTEVDVCBvYnNlcnZhdGlvbi5zdWJqZWN0LnJlZmVyZW5jZSBBUyBzdWJqZWN0X3JlZmVyZW5jZSwgb2JzZXJ2YXRpb24udmFsdWVxdWFudGl0eS52YWx1ZSBBUyB2YWx1ZQogICAgRlJPTSBmaGlyLmRlZmF1bHQub2JzZXJ2YXRpb24sIFVOTkVTVChvYnNlcnZhdGlvbi5jb2RlLmNvZGluZykgQVMgdShvYnNlcnZhdGlvbl9jb2RpbmcpCiAgICBXSEVSRSBvYnNlcnZhdGlvbl9jb2Rpbmcuc3lzdGVtID0gJ2h0dHA6Ly9sb2luYy5vcmcnIEFORCBvYnNlcnZhdGlvbl9jb2RpbmcuY29kZSA9ICcxODI2Mi02JwopIEFTIGxkbCBPTiBsZGwuc3ViamVjdF9yZWZlcmVuY2UgPSBDT05DQVQoJ1BhdGllbnQvJywgcGF0aWVudC5pZCkKR1JPVVAgQlkgcGF0aWVudC5pZA=="/>
        </content>
      </Library>
    </resource>
    <request>
      <method value="PUT"/>
      <url value="Library/5f3c2a8e-7d41-4b9a-9e2f-6c1d8b0a4e73"/>
    </request>
  </entry>
</Bundle>