{
  "resourceType" : "Library",
  "id" : "ANCCohort",
  "meta" : {
    "profile" : ["http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-computablelibrary"]
  },
  "text" : {
    "status" : "generated",
    "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\t  where E.url = ('http://fhir.org/guides/who/core/StructureDefinition/' + id)\r\n\t\treturn 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>"
  },
  "extension" : [{
    "url" : "http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-softwaresystem",
    "valueReference" : {
      "reference" : "Device/cqf-tooling"
    }
  }],
  "url" : "http://hl7.org/fhir/uv/crmi/Library/ANCCohort",
  "identifier" : [{
    "system" : "urn:ietf:rfc:3986",
    "value" : "urn:oid:2.16.840.1.113883.4.642.40.38.28.1"
  }],
  "version" : "1.0.0",
  "name" : "ANCCohort",
  "title" : "ANC Cohort",
  "status" : "active",
  "experimental" : false,
  "type" : {
    "coding" : [{
      "system" : "http://terminology.hl7.org/CodeSystem/library-type",
      "code" : "logic-library"
    }]
  },
  "date" : "2024-05-31T16:42:56+00:00",
  "publisher" : "HL7 International / Clinical Decision Support",
  "contact" : [{
    "telecom" : [{
      "system" : "url",
      "value" : "http://www.hl7.org/Special/committees/dss"
    }]
  }],
  "description" : "Cohort definition for antenatal care",
  "jurisdiction" : [{
    "coding" : [{
      "system" : "http://unstats.un.org/unsd/methods/m49/m49.htm",
      "code" : "001",
      "display" : "World"
    }]
  }],
  "relatedArtifact" : [{
    "type" : "depends-on",
    "display" : "FHIR model information",
    "resource" : "http://fhir.org/guides/cqf/common/Library/FHIR-ModelInfo|4.0.1"
  },
  {
    "type" : "depends-on",
    "display" : "Library FHIRHelpers",
    "resource" : "http://fhir.org/guides/cqf/common/Library/FHIRHelpers|4.0.1"
  },
  {
    "type" : "depends-on",
    "display" : "Library FC",
    "resource" : "http://hl7.org/fhir/uv/crmi/Library/FHIRCommon"
  },
  {
    "type" : "depends-on",
    "display" : "Code system ANCM Concept Codes",
    "resource" : "http://hl7.org/fhir/uv/crmi/CodeSystem/publishable-example"
  }],
  "parameter" : [{
    "name" : "Is pregnancy confirmed",
    "use" : "out",
    "min" : 0,
    "max" : "1",
    "type" : "boolean"
  },
  {
    "extension" : [{
      "url" : "http://hl7.org/fhir/StructureDefinition/cqf-defaultValue",
      "valueBoolean" : false
    }],
    "name" : "Is Antenatal Care Applicable",
    "use" : "out",
    "min" : 0,
    "max" : "1",
    "type" : "boolean"
  }],
  "dataRequirement" : [{
    "type" : "Observation",
    "profile" : ["http://hl7.org/fhir/StructureDefinition/Observation"],
    "mustSupport" : ["code"],
    "codeFilter" : [{
      "path" : "code",
      "code" : [{
        "system" : "http://hl7.org/fhir/uv/crmi/CodeSystem/publishable-example",
        "code" : "ANC.B4.DE1",
        "display" : "Pregnancy confirmed"
      }]
    }]
  }],
  "content" : [{
    "contentType" : "text/cql",
    "data" : "bGlicmFyeSBBTkNDb2hvcnQNCg0KdXNpbmcgRkhJUiB2ZXJzaW9uICc0LjAuMScNCg0KaW5jbHVkZSBGSElSSGVscGVycyB2ZXJzaW9uICc0LjAuMScNCmluY2x1ZGUgRkhJUkNvbW1vbiBjYWxsZWQgRkMNCg0KY29kZXN5c3RlbSAiQU5DTSBDb25jZXB0IENvZGVzIjogJ2h0dHA6Ly9maGlyLm9yZy9ndWlkZXMvd2hvL3NtYXJ0LWFuYy1taW5pL0NvZGVTeXN0ZW0vY29uY2VwdC1jb2RlcycNCg0KY29kZSAiUHJlZ25hbmN5IGNvbmZpcm1lZCI6ICdBTkMuQjQuREUxJyBmcm9tICJBTkNNIENvbmNlcHQgQ29kZXMiIGRpc3BsYXkgJ1ByZWduYW5jeSBjb25maXJtZWQnDQoNCmRlZmluZSAiSXMgQW50ZW5hdGFsIENhcmUgQXBwbGljYWJsZSI6DQogICJJcyBwcmVnbmFuY3kgY29uZmlybWVkIiBpcyB0cnVlDQoNCg0KLyogQ29waWVkIGZyb20gQU5DTUNvbnRhY3REYXRhRWxlbWVudHMgKi8NCi8qDQogIEBkYXRhRWxlbWVudDogQU5DLkI0LkRFMSBQcmVnbmFuY3kgY29uZmlybWVkDQogIEBhY3Rpdml0eTogQU5DLkI0IENvbmZpcm0gcHJlZ25hbmN5DQogIEBkZXNjcmlwdGlvbjogUHJlZ25hbmN5IGhhcyBiZWVuIGNvbmZpcm1lZA0KKi8NCmRlZmluZSAiSXMgcHJlZ25hbmN5IGNvbmZpcm1lZCI6DQogIE1vc3RSZWNlbnQoDQogICAgRmlu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NlIERvbWFpblJlc291cmNlLCBpZCBTdHJpbmcpOg0KICBkb21haW5SZXNvdXJjZS5tb2RpZmllckV4dGVuc2lvbiBFDQoJICB3aGVyZSBFLnVybCA9ICgnaHR0cDovL2ZoaXIub3JnL2d1aWRlcy93aG8vY29yZS9TdHJ1Y3R1cmVEZWZpbml0aW9uLycgKyBpZCkNCgkJcmV0dXJuIEUNCg0KLyoNCkBkZXNjcmlwdGlvbjogUmV0dXJucyB0aGUgc2luZ2xlIFdITyBjb3JlIG1vZGlmaWVyIGV4dGVuc2lvbiAoaWYgcHJlc2VudCkgb24gdGhlIGdpdmVuIHJlc291cmNlIHdpdGggdGhlIHNwZWNpZmllZCBpZC4NCkBjb21tZW50OiBUaGlzIGZ1bmN0aW9uIHVzZXMgc2luZ2xldG9uIGZyb20gdG8gZW5zdXJlIHRoYXQgYSBydW4tdGltZSBleGNlcHRpb24gaXMgdGhyb3duIGlmIHRoZXJlDQppcyBtb3JlIHRoYW4gb25lIGV4dGVuc2lvbiBvbiB0aGUgZ2l2ZW4gcmVzb3VyY2Ugd2l0aCB0aGUgc3BlY2lmaWVkIHVybC4NCiovDQpkZWZpbmUgZnVuY3Rpb24gTW9kaWZpZXJFeHRlbnNpb24oZG9tYWluUmVzb3VyY2UgRG9tYWluUmVzb3VyY2UsIGlkIFN0cmluZyk6DQogIHNpbmdsZXRvbiBmcm9tIE1vZGlmaWVyRXh0ZW5zaW9ucyhkb21haW5SZXNvdXJjZSwgaWQpDQoNCg=="
  },
  {
    "contentType" : "application/elm+xml",
    "data" : "[encoded data, 33136 characters]"
  },
  {
    "contentType" : "application/elm+json",
    "data" : "[encoded data, 57992 characters]"
  }]
}