WHO Clinical Care in Crisis Implementation Guide for Children
0.1.0 - ci-build

WHO Clinical Care in Crisis Implementation Guide for Children - Local Development build (v0.1.0). See the Directory of published versions

: CHE.Z.Score - JSON Representation

Active as of 2023-10-04

Raw json | Download


{
  "resourceType" : "Library",
  "id" : "chezscore",
  "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><code>http://fhir.org/guides/who/anc-cds/Library/FHIRHelpers</code></td></tr><tr><td>depends-on</td><td><code>https://fhir.dk.swisstph-mis.ch/matchbox/fhir/Library/chebase</code></td></tr><tr><td>depends-on</td><td><code>https://fhir.dk.swisstph-mis.ch/matchbox/fhir/Library/weightforage</code></td></tr><tr><td>depends-on</td><td><a href=\"Library-anthrobase.html\">anthrobase</a></td></tr><tr><td>depends-on</td><td><code>https://fhir.dk.swisstph-mis.ch/matchbox/fhir/Library/weightforlength</code></td></tr><tr><td>depends-on</td><td><code>https://fhir.dk.swisstph-mis.ch/matchbox/fhir/Library/weightforheight</code></td></tr></table><h2>Parameters</h2><table class=\"grid\"><tr><td>encounter</td><td>in</td><td/><td/><td>Encounter</td></tr><tr><td>pastweight</td><td>out</td><td/><td/><td>decimal</td></tr><tr><td>patientsex</td><td>out</td><td/><td/><td>string</td></tr><tr><td>ageatpastweight</td><td>out</td><td/><td/><td>integer</td></tr><tr><td>pastweightzscore</td><td>out</td><td/><td/><td>decimal</td></tr><tr><td>pastweightactualised</td><td>out</td><td/><td/><td>decimal</td></tr><tr><td>WAZ</td><td>out</td><td/><td/><td>decimal</td></tr></table><h2>Data Requirements</h2><table class=\"grid\"><tr><td colspan=\"2\"><b>Type</b>: <a href=\"http://hl7.org/fhir/R4/patient.html\">Patient</a> (<a href=\"http://hl7.org/fhir/R4/patient.html\">Patient</a>)</td></tr></table><table class=\"grid\"><tr><td colspan=\"2\"><b>Type</b>: <a href=\"http://hl7.org/fhir/R4/encounter.html\">Encounter</a> (<a href=\"http://hl7.org/fhir/R4/encounter.html\">Encounter</a>)</td></tr></table><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: [not stated] CHE.B6.DE06: CHE.B6.DE06</td></tr></table><h2>Contents</h2><p><code>text/cql</code></p><pre><code class=\"language-sql\">/*\n@author: Patrick Delcroix\n@description: This library is part of the project CHE\n*/\nlibrary chezscore version '1.0.313+build.456'\nusing FHIR version '4.0.1'\ninclude FHIRHelpers version '4.0.1' called FHIRHelpers \ninclude chebase version '1.0.313+build.456' called Base\ninclude WeightForAge version '1.0.4' called wfa\ninclude WeightForLength version '1.0.4' called wfl\ninclude WeightForHeight version '1.0.4' called wfh\n\n\n\n//codesystem &quot;CHE&quot; : 'https://fhir.dk.swisstph-mis.ch/matchbox/fhir/CodeSystem/che-custom-codes'\n\n\n\n//code &quot;Weight&quot;: 'CHE.B6.DE06' from &quot;CHE&quot; display 'Weight'\n//code &quot;Estimated Weight&quot;: 'CHE.B6.DE08' from &quot;CHE&quot; display 'Estimated Weight'\n//code &quot;MUAC&quot;: 'CHE.B6.DE17' from &quot;CHE&quot; display 'MUAC'\n//code &quot;Length&quot;: 'CHE.B6.DE12' from &quot;CHE&quot; display 'Length'\n//code &quot;Height&quot;: 'CHE.B6.DE09' from &quot;CHE&quot; display 'Height'\n\nparameter &quot;encounterid&quot; String\n\ncontext Patient\n\ndefine &quot;Weight&quot;:\n  Base.coding('CHE.B6.DE06')\ndefine &quot;Estimated Weight&quot;:\n  Base.coding('CHE.B6.DE08')\ndefine &quot;MUAC&quot;:\n  Base.coding('CHE.B6.DE17')\ndefine &quot;Length&quot;:\n  Base.coding('CHE.B6.DE12')\ndefine &quot;Height&quot;:\n  Base.coding('CHE.B6.DE09')\ndefine &quot;Visually assess&quot;:\n  Base.coding('CHE.B6.DE18')\ndefine &quot;Underweight&quot;:\n  Base.coding('CHE.B6.DE20') \ndefine &quot;Severely Underweight&quot;:\n  Base.coding('CHE.B6.DE21') \n\n/* pastweight : Previous Weight*/\ndefine &quot;pastweightobs&quot;:\n    if AgeInMonths()&lt; 4  then\n      Base.GetHistoricObservation(&quot;Weight&quot;, 60)\n    else if AgeInMonths()&lt; 6  then\n      Base.GetHistoricObservation(&quot;Weight&quot;, 91)\n    else if AgeInMonths()&lt; 12  then\n      Base.GetHistoricObservation(&quot;Weight&quot;, 121)\n    else \n      Base.GetHistoricObservation(&quot;Weight&quot;, 180)\n\ndefine &quot;pastweight&quot;:\n    if &quot;pastweightobs&quot; is not null then\n      &quot;pastweightobs&quot;.value\n    else null\n\n/* patientsex : Patient sex*/\ndefine &quot;patientsex&quot;:\n    if Patient.gender = 'female' then 'female' else 'male'\n\n/* ageatpastweight : Age at Previous Weight*/\ndefine &quot;ageatpastweight&quot;:\n    if &quot;pastweight&quot; is not null  then\n        (difference in days between Patient.birthDate and ToDate(pastweightobs.issued)) * ( 1.0 as System.Decimal )\n    else\n     null\n\n/* pastweightzscore : Z-Score at Previous Weight*/\ndefine &quot;pastweightzscore&quot;:\n    if &quot;pastweight&quot; is not null  then\n      wfa.generateZScoreWeightForAge(&quot;patientsex&quot;, &quot;ageatpastweight&quot; , (&quot;pastweight&quot;.value * ( 1.0 as System.Decimal)))\n    else\n      null\n\n/* pastweightactualised : Weight from  at Previous Weight*/\ndefine &quot;pastweightactualised&quot;:\n    if &quot;pastweightzscore&quot; is not null then\n      System.Quantity { value: Round(wfa.generateWeightFromAge(&quot;patientsex&quot;,AgeInDays() * ( 1.0 as System.Decimal ),  &quot;pastweightzscore&quot; ),2), unit: 'kg'} \n    else \n       null\n\n\n\ndefine existingweight:\n  Base.GetObsValue(&quot;Weight&quot;)\n\ndefine existingestimnatedweight:\n  if existingweight is null then  \n    Base.GetObsValue(&quot;Estimated Weight&quot;)\n  else \n    null\n\ndefine existingheight:\n  Base.GetObsValue(&quot;Height&quot;)\n\ndefine existinglength:\n  Base.GetObsValue(&quot;Length&quot;)\n\ndefine existingmuac:\n  Base.GetObsValue(&quot;MUAC&quot;)\n\ndefine existingvisual:\n  Base.GetObsValue(&quot;Visually assess&quot;)\n//\ndefine zscorefrommuac:\n  if existingmuac is null then null\n  else if existingmuac &lt; 115 'mnm' then -3.0\n  else if existingmuac &lt; 125 'mnm' then -2.0\n  else 0.0\n\ndefine estimatedweight:\n  case  \n  when existingweight is not null then null\n  when existingestimnatedweight is not null then existingestimnatedweight\n  when pastweightactualised is not null then pastweightactualised\n  when AgeInMonths()&gt;24 and existingheight then weightfromheight\n  when AgeInMonths()&lt;=24 and existinglength then weightfromlength\n  else weightfromage\n  end\n\ndefine zscorefromvisual:\n    if existingvisual is not null then\n      case  \n        when existingvisual ~ &quot;Severely Underweight&quot; then -3.0\n        when existingvisual ~ &quot;Underweight&quot; then -2.0\n        else 0.0\n      end\n    else  null\n\n\ndefine weightfromlength:\n    System.Quantity { value: Round(wfl.generateWeightFromLength(&quot;patientsex&quot;,(convert existinglength to 'cm').value * ( 1.0 as System.Decimal ), zscorefrommuac),2), unit: 'kg'}\n\ndefine weightfromheight:\n    System.Quantity { value:Round(wfh.generateWeightFromHeight(&quot;patientsex&quot;,(convert existingheight to 'cm').value * ( 1.0 as System.Decimal ), zscorefrommuac),2), unit: 'kg'}\n\ndefine weightfromage:\n    System.Quantity { value:Round(wfa.generateWeightFromAge(&quot;patientsex&quot;,AgeInDays() * ( 1.0 as System.Decimal ), zscorefrommuac),2), unit: 'kg'}\n/*\n(convert Base.HasObs(&quot;Weight&quot;) to 'Kg') does not work, so let's assume the weight is in Kg\n*/\ndefine &quot;WAZ&quot;:\n    if existingweight is not null then\n         wfa.generateZScoreWeightForAge(&quot;patientsex&quot;, AgeInDays() , (existingweight.value * ( 1.0 as System.Decimal )))\n    else if existingmuac is not null then\n        zscorefrommuac\n    else if existingvisual then\n        zscorefromvisual\n    else null\n\ndefine &quot;WLZ&quot;:\n    if existingweight is not null then\n         wfl.generateZScoreWeightForLength(&quot;patientsex&quot;, (existinglength.value * ( 1.0 as System.Decimal )) ,  (existingweight.value * ( 1.0 as System.Decimal )))\n    else if existingmuac is not null then\n        zscorefrommuac\n    else if existingvisual then\n        zscorefromvisual\n    else null\n\ndefine &quot;WHZ&quot;:\n    if existingweight is not null then\n         wfh.generateZScoreWeightForHeight(&quot;patientsex&quot;, (existingheight.value * ( 1.0 as System.Decimal )) ,  (existingweight.value * ( 1.0 as System.Decimal )))\n    else if existingmuac is not null then\n        zscorefrommuac\n    else if existingvisual then\n        zscorefromvisual\n    else null\n</code></pre></div>"
  },
  "url" : "https://fhir.dk.swisstph-mis.ch/matchbox/fhir//Library/chezscore",
  "identifier" : [
    {
      "use" : "official",
      "value" : "CHEZScore"
    }
  ],
  "version" : "0.1.0",
  "name" : "chezscore",
  "title" : "CHE.Z.Score",
  "status" : "active",
  "type" : {
    "coding" : [
      {
        "system" : "http://hl7.org/fhir/ValueSet/library-type",
        "code" : "logic-library"
      }
    ]
  },
  "date" : "2023-10-04T12:32:21+00:00",
  "publisher" : "WHO",
  "contact" : [
    {
      "name" : "WHO",
      "telecom" : [
        {
          "system" : "url",
          "value" : "http://who.int"
        }
      ]
    }
  ],
  "relatedArtifact" : [
    {
      "type" : "depends-on",
      "resource" : "http://fhir.org/guides/who/anc-cds/Library/FHIRHelpers"
    },
    {
      "type" : "depends-on",
      "resource" : "https://fhir.dk.swisstph-mis.ch/matchbox/fhir/Library/chebase"
    },
    {
      "type" : "depends-on",
      "resource" : "https://fhir.dk.swisstph-mis.ch/matchbox/fhir/Library/weightforage"
    },
    {
      "type" : "depends-on",
      "resource" : "https://fhir.dk.swisstph-mis.ch/matchbox/fhir/Library/anthrobase"
    },
    {
      "type" : "depends-on",
      "resource" : "https://fhir.dk.swisstph-mis.ch/matchbox/fhir/Library/weightforlength"
    },
    {
      "type" : "depends-on",
      "resource" : "https://fhir.dk.swisstph-mis.ch/matchbox/fhir/Library/weightforheight"
    }
  ],
  "parameter" : [
    {
      "name" : "encounter",
      "use" : "in",
      "type" : "Encounter"
    },
    {
      "name" : "pastweight",
      "use" : "out",
      "type" : "decimal"
    },
    {
      "name" : "patientsex",
      "use" : "out",
      "type" : "string"
    },
    {
      "name" : "ageatpastweight",
      "use" : "out",
      "type" : "integer"
    },
    {
      "name" : "pastweightzscore",
      "use" : "out",
      "type" : "decimal"
    },
    {
      "name" : "pastweightactualised",
      "use" : "out",
      "type" : "decimal"
    },
    {
      "name" : "WAZ",
      "use" : "out",
      "type" : "decimal"
    }
  ],
  "dataRequirement" : [
    {
      "type" : "Patient",
      "profile" : [
        "http://hl7.org/fhir/StructureDefinition/Patient"
      ]
    },
    {
      "type" : "Encounter",
      "profile" : [
        "http://hl7.org/fhir/StructureDefinition/Encounter"
      ]
    },
    {
      "type" : "Observation",
      "profile" : [
        "http://hl7.org/fhir/StructureDefinition/Observation"
      ],
      "mustSupport" : [
        "code",
        "encounter.reference",
        "encounter",
        "value",
        "status"
      ],
      "codeFilter" : [
        {
          "path" : "code",
          "code" : [
            {
              "code" : "CHE.B6.DE06"
            }
          ]
        }
      ]
    }
  ],
  "content" : [
    {
      "id" : "ig-loader-chezscore.cql",
      "contentType" : "text/cql",
      "data" : "LyoKQGF1dGhvcjogUGF0cmljayBEZWxjcm9peApAZGVzY3JpcHRpb246IFRoaXMgbGlicmFyeSBpcyBwYXJ0IG9mIHRoZSBwcm9qZWN0IENIRQoqLwpsaWJyYXJ5IGNoZXpzY29yZSB2ZXJzaW9uICcxLjAuMzEzK2J1aWxkLjQ1NicKdXNpbmcgRkhJUiB2ZXJzaW9uICc0LjAuMScKaW5jbHVkZSBGSElSSGVscGVycyB2ZXJzaW9uICc0LjAuMScgY2FsbGVkIEZISVJIZWxwZXJzIAppbmNsdWRlIGNoZWJhc2UgdmVyc2lvbiAnMS4wLjMxMytidWlsZC40NTYnIGNhbGxlZCBCYXNlC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