@prefix fhir: <http://hl7.org/fhir/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

# - resource -------------------------------------------------------------------

<http://hl7.org/fhir/uv/crmi/Library/ANCCohort> a fhir:Library ;
  fhir:nodeRole fhir:treeRoot ;
  fhir:id [ fhir:v "ANCCohort"] ; # 
  fhir:meta [
     fhir:profile ( [
       fhir:v "http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-computablelibrary"^^xsd:anyURI ;
       fhir:link <http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-computablelibrary>
     ] )
  ] ; # 
  fhir:text [
     fhir:status [ fhir:v "generated" ] ;
     fhir:div "<div xmlns=\"http://www.w3.org/1999/xhtml\"><h2>Related Artifacts</h2><table class=\"grid\"><tr><td>depends-on</td><td>FHIR model information</td><td><code>http://fhir.org/guides/cqf/common/Library/FHIR-ModelInfo|4.0.1</code></td></tr><tr><td>depends-on</td><td>Library FHIRHelpers</td><td><code>http://fhir.org/guides/cqf/common/Library/FHIRHelpers|4.0.1</code></td></tr><tr><td>depends-on</td><td>Library FC</td><td><a href=\"Library-FHIRCommon.html\">FHIR Common (Example)</a></td></tr><tr><td>depends-on</td><td>Code system ANCM Concept Codes</td><td><a href=\"CodeSystem-publishable-example.html\">ANCM Concept Codes (Publishable Example)</a></td></tr></table><h2>Parameters</h2><table class=\"grid\"><tr><td>Is pregnancy confirmed</td><td>out</td><td>0</td><td>1</td><td>boolean</td></tr><tr><td>Is Antenatal Care Applicable</td><td>out</td><td>0</td><td>1</td><td>boolean</td></tr></table><h2>Data Requirements</h2><table class=\"grid\"><tr><td colspan=\"2\"><b>Type</b>: <a href=\"http://hl7.org/fhir/R4/observation.html\">Observation</a> (<a href=\"http://hl7.org/fhir/R4/observation.html\">Observation</a>)</td></tr><tr style=\"background-color: #efefef\"><td>Filter</td><td>Value</td></tr><tr><td>code</td><td>One of these codes: <a href=\"CodeSystem-publishable-example.html#publishable-example-ANC.46B4.46DE1\">ANCM Concept Codes (Publishable Example)</a> ANC.B4.DE1: Pregnancy confirmed</td></tr></table><h2>Contents</h2><p><code>text/cql</code></p><pre><code class=\"language-sql\">library ANCCohort\r\n\r\nusing FHIR version '4.0.1'\r\n\r\ninclude FHIRHelpers version '4.0.1'\r\ninclude FHIRCommon called FC\r\n\r\ncodesystem &quot;ANCM Concept Codes&quot;: 'http://fhir.org/guides/who/smart-anc-mini/CodeSystem/concept-codes'\r\n\r\ncode &quot;Pregnancy confirmed&quot;: 'ANC.B4.DE1' from &quot;ANCM Concept Codes&quot; display 'Pregnancy confirmed'\r\n\r\ndefine &quot;Is Antenatal Care Applicable&quot;:\r\n  &quot;Is pregnancy confirmed&quot; is true\r\n\r\n\r\n/* Copied from ANCMContactDataElements */\r\n/*\r\n  @dataElement: ANC.B4.DE1 Pregnancy confirmed\r\n  @activity: ANC.B4 Confirm pregnancy\r\n  @description: Pregnancy has been confirmed\r\n*/\r\ndefine &quot;Is pregnancy confirmed&quot;:\r\n  MostRecent(\r\n    Final([Observation: &quot;Pregnancy confirmed&quot;])\r\n  ).value as boolean\r\n\r\n/* Copied from WHOCommon */\r\ndefine function Final(observations List&lt;Observation&gt;):\r\n  observations O\r\n    where O.status in { 'final', 'amended', 'corrected' }\r\n      and Coalesce(ModifierExtension(O, 'who-notDone').value, false) is false\r\n      and O.value is not null\r\n\r\ndefine function MostRecent(observations List&lt;Observation&gt;):\r\n  Last(\r\n    observations O\r\n      sort by issued\r\n  )\r\n\r\n/*\r\n@description: Returns any WHO core modifier extensions defined on the given resource with the specified id.\r\n@comment: NOTE: Extensions are not the preferred approach, but are used as a way to access\r\ncontent that is defined by extensions but not yet surfaced in the\r\nCQL model info.\r\n*/\r\ndefine function ModifierExtensions(domainResource DomainResource, id String):\r\n  domainResource.modifierExtension E\r\n	  where E.url = ('http://fhir.org/guides/who/core/StructureDefinition/' + id)\r\n		return E\r\n\r\n/*\r\n@description: Returns the single WHO core modifier extension (if present) on the given resource with the specified id.\r\n@comment: This function uses singleton from to ensure that a run-time exception is thrown if there\r\nis more than one extension on the given resource with the specified url.\r\n*/\r\ndefine function ModifierExtension(domainResource DomainResource, id String):\r\n  singleton from ModifierExtensions(domainResource, id)\r\n\r\n</code></pre><p><code>Content not shown - (</code><code>application/elm+xml</code>, size = 24Kb )</p><p><code>Content not shown - (</code><code>application/elm+json</code>, size = 42Kb )</p></div>"
  ] ; # 
  fhir:extension ( [
     fhir:url [ fhir:v "http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-softwaresystem"^^xsd:anyURI ] ;
     fhir:value [
       a fhir:Reference ;
       fhir:link <http://hl7.org/fhir/uv/crmi/Device/cqf-tooling> ;
       fhir:reference [ fhir:v "Device/cqf-tooling" ]
     ]
  ] ) ; # 
  fhir:url [ fhir:v "http://hl7.org/fhir/uv/crmi/Library/ANCCohort"^^xsd:anyURI] ; # 
  fhir:identifier ( [
     fhir:system [ fhir:v "urn:ietf:rfc:3986"^^xsd:anyURI ] ;
     fhir:value [ fhir:v "urn:oid:2.16.840.1.113883.4.642.40.38.28.1" ]
  ] ) ; # 
  fhir:version [ fhir:v "1.0.0"] ; # 
  fhir:name [ fhir:v "ANCCohort"] ; # 
  fhir:title [ fhir:v "ANC Cohort"] ; # 
  fhir:status [ fhir:v "active"] ; # 
  fhir:experimental [ fhir:v "false"^^xsd:boolean] ; # 
  fhir:type [
     fhir:coding ( [
       fhir:system [ fhir:v "http://terminology.hl7.org/CodeSystem/library-type"^^xsd:anyURI ] ;
       fhir:code [ fhir:v "logic-library" ]
     ] )
  ] ; # 
  fhir:date [ fhir:v "2024-05-31T16:42:56+00:00"^^xsd:dateTime] ; # 
  fhir:publisher [ fhir:v "HL7 International / Clinical Decision Support"] ; # 
  fhir:contact ( [
     fhir:telecom ( [
       fhir:system [ fhir:v "url" ] ;
       fhir:value [ fhir:v "http://www.hl7.org/Special/committees/dss" ]
     ] )
  ] ) ; # 
  fhir:description [ fhir:v "Cohort definition for antenatal care"] ; # 
  fhir:jurisdiction ( [
     fhir:coding ( [
       fhir:system [ fhir:v "http://unstats.un.org/unsd/methods/m49/m49.htm"^^xsd:anyURI ] ;
       fhir:code [ fhir:v "001" ] ;
       fhir:display [ fhir:v "World" ]
     ] )
  ] ) ; # 
  fhir:relatedArtifact ( [
     fhir:type [ fhir:v "depends-on" ] ;
     fhir:display [ fhir:v "FHIR model information" ] ;
     fhir:resource [
       fhir:v "http://fhir.org/guides/cqf/common/Library/FHIR-ModelInfo|4.0.1"^^xsd:anyURI ;
       fhir:link <http://fhir.org/guides/cqf/common/Library/FHIR-ModelInfo|4.0.1>
     ]
  ] [
     fhir:type [ fhir:v "depends-on" ] ;
     fhir:display [ fhir:v "Library FHIRHelpers" ] ;
     fhir:resource [
       fhir:v "http://fhir.org/guides/cqf/common/Library/FHIRHelpers|4.0.1"^^xsd:anyURI ;
       fhir:link <http://fhir.org/guides/cqf/common/Library/FHIRHelpers|4.0.1>
     ]
  ] [
     fhir:type [ fhir:v "depends-on" ] ;
     fhir:display [ fhir:v "Library FC" ] ;
     fhir:resource [
       fhir:v "http://hl7.org/fhir/uv/crmi/Library/FHIRCommon"^^xsd:anyURI ;
       fhir:link <http://hl7.org/fhir/uv/crmi/Library/FHIRCommon>
     ]
  ] [
     fhir:type [ fhir:v "depends-on" ] ;
     fhir:display [ fhir:v "Code system ANCM Concept Codes" ] ;
     fhir:resource [
       fhir:v "http://hl7.org/fhir/uv/crmi/CodeSystem/publishable-example"^^xsd:anyURI ;
       fhir:link <http://hl7.org/fhir/uv/crmi/CodeSystem/publishable-example>
     ]
  ] ) ; # 
  fhir:parameter ( [
     fhir:name [ fhir:v "Is pregnancy confirmed" ] ;
     fhir:use [ fhir:v "out" ] ;
     fhir:min [ fhir:v "0"^^xsd:integer ] ;
     fhir:max [ fhir:v "1" ] ;
     fhir:type [ fhir:v "boolean" ]
  ] [
     fhir:extension ( [
       fhir:url [ fhir:v "http://hl7.org/fhir/StructureDefinition/cqf-defaultValue"^^xsd:anyURI ] ;
       fhir:value [ fhir:v "false"^^xsd:boolean ]
     ] ) ;
     fhir:name [ fhir:v "Is Antenatal Care Applicable" ] ;
     fhir:use [ fhir:v "out" ] ;
     fhir:min [ fhir:v "0"^^xsd:integer ] ;
     fhir:max [ fhir:v "1" ] ;
     fhir:type [ fhir:v "boolean" ]
  ] ) ; # 
  fhir:dataRequirement ( [
     fhir:type [ fhir:v "Observation" ] ;
     fhir:profile ( [
       fhir:v "http://hl7.org/fhir/StructureDefinition/Observation"^^xsd:anyURI ;
       fhir:link <http://hl7.org/fhir/StructureDefinition/Observation>
     ] ) ;
     fhir:mustSupport ( [ fhir:v "code" ] ) ;
     fhir:codeFilter ( [
       fhir:path [ fhir:v "code" ] ;
       fhir:code ( [
         fhir:system [ fhir:v "http://hl7.org/fhir/uv/crmi/CodeSystem/publishable-example"^^xsd:anyURI ] ;
         fhir:code [ fhir:v "ANC.B4.DE1" ] ;
         fhir:display [ fhir:v "Pregnancy confirmed" ]
       ] )
     ] )
  ] ) ; # 
  fhir:content ( [
     fhir:contentType [ fhir:v "text/cql" ] ;
     fhir:data [ fhir:v "bGlicmFyeSBBTkNDb2hvcnQNCg0KdXNpbmcgRkhJUiB2ZXJzaW9uICc0LjAuMScNCg0KaW5jbHVkZSBGSElSSGVscGVycyB2ZXJzaW9uICc0LjAuMScNCmluY2x1ZGUgRkhJUkNvbW1vbiBjYWxsZWQgRkMNCg0KY29kZXN5c3RlbSAiQU5DTSBDb25jZXB0IENvZGVzIjogJ2h0dHA6Ly9maGlyLm9yZy9ndWlkZXMvd2hvL3NtYXJ0LWFuYy1taW5pL0NvZGVTeXN0ZW0vY29uY2VwdC1jb2RlcycNCg0KY29kZSAiUHJlZ25hbmN5IGNvbmZpcm1lZCI6ICdBTkMuQjQuREUxJyBmcm9tICJBTkNNIENvbmNlcHQgQ29kZXMiIGRpc3BsYXkgJ1ByZWduYW5jeSBjb25maXJtZWQnDQoNCm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lbnNpb24oZG9tYWluUmVzb3VyY2UgRG9tYWluUmVzb3VyY2UsIGlkIFN0cmluZyk6DQogIHNpbmdsZXRvbiBmcm9tIE1vZGlmaWVyRXh0ZW5zaW9ucyhkb21haW5SZXNvdXJjZSwgaWQpDQoNCg=="^^xsd:base64Binary ]
  ] [
     fhir:contentType [ fhir:v "application/elm+xml" ] ;
     fhir:data [ fhir:v "[encoded data, 33136 characters]"^^xsd:base64Binary ]
  ] [
     fhir:contentType [ fhir:v "application/elm+json" ] ;
     fhir:data [ fhir:v "[encoded data, 57992 characters]"^^xsd:base64Binary ]
  ] ) . # 

<http://hl7.org/fhir/uv/crmi/Device/cqf-tooling> a fhir:uv .

# -------------------------------------------------------------------------------------

