WHO FHIR Implementation Guide (IG): Integrated Management of Childhood Illness (IMCI) in emergencies
0.1.0 - release

WHO FHIR Implementation Guide (IG): Integrated Management of Childhood Illness (IMCI) in emergencies, published by World Health Organization (WHO). This guide is not an authorized publication; it is the continuous build for version 0.1.0 built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of https://github.com/WorldHealthOrganization/smart-emcare/tree/feature/update-canonical and changes regularly. See the Directory of published versions

## : CccBase - XML Representation

Active as of 2026-04-07

Raw xml | Download

    <Library xmlns="http://hl7.org/fhir">
      <id value="Cccbase"/>
      <text>
        <status value="extensions"/>
        <div xmlns="http://www.w3.org/1999/xhtml">
    <div>
        <table class="grid dict">

            <tr>
                <th scope="row"><b>Title: </b></th>
                <td style="padding-left: 4px;">CccBase</td>
            </tr>

            <tr>
                <th scope="row"><b>Id: </b></th>
                <td style="padding-left: 4px;">Cccbase</td>
            </tr>

            <tr>
                <th scope="row"><b>Version: </b></th>
                <td style="padding-left: 4px;">0.1.0</td>
            </tr>

            <tr>
                <th scope="row"><b>Url: </b></th>
                <td style="padding-left: 4px;"><a href="Library-Cccbase.html">CccBase</a></td>
            </tr>

            <tr>
                <th scope="row"><b>Type: </b></th>
                <td style="padding-left: 4px;">

                            <p style="margin-bottom: 5px;">
                                <b>system: </b> <span><a href="http://hl7.org/fhir/R4/valueset-library-type.html">http://hl7.org/fhir/ValueSet/library-type</a></span>
                            </p>

                            <p style="margin-bottom: 5px;">
                                <b>code: </b> <span>logic-library</span>
                            </p>

                </td>
            </tr>

            <tr>
                <th scope="row"><b>Date: </b></th>
                <td style="padding-left: 4px;">2026-04-07 13:42:05+0000</td>
            </tr>

            <tr>
                <th scope="row"><b>Publisher: </b></th>
                <td style="padding-left: 4px;">World Health Organization (WHO)</td>
            </tr>

            <tr>
                <th scope="row"><b>Jurisdiction: </b></th>
                <td style="padding-left: 4px;">001</td>
            </tr>

            <tr>
                <th scope="row"><b>Related Artifacts: </b></th>
                <td style="padding-left: 4px;">

                    <p><b>Dependencies</b></p>
                    <ul>

                        <li><code>http://fhir.org/guides/who/anc-cds/Library/FHIRHelpers</code></li>

                    </ul>

                </td>
            </tr>

            <tr>
              <th scope="row"><b>Parameters: </b></th>
              <td style="padding-left: 4px;">
                <table class="grid-dict">
                  <tr><th><b>Name</b></th><th><b>Type</b></th><th><b>Min</b></th><th><b>Max</b></th><th><b>In/Out</b></th></tr>

                    <tr><th>encounterid</th><th>string</th><th/><th/><th>In</th></tr>

                </table>
              </td>
            </tr>

            <tr>
              <th scope="row"><b>Data Requirements:</b></th>
              <td style="padding-left: 4px;">
                <table class="grid-dict">
                  <tr><th><b>Type</b></th><th><b>Profile</b></th><th><b>MS</b></th><th><b>Code Filter</b></th></tr>

                    <tr>
                      <th>Patient</th>
                      <th>http://hl7.org/fhir/StructureDefinition/Patient</th>
                      <th/>
                      <th>

                      </th>
                    </tr>

                    <tr>
                      <th>Encounter</th>
                      <th>http://hl7.org/fhir/StructureDefinition/Encounter</th>
                      <th/>
                      <th>

                      </th>
                    </tr>

                </table>
              </td>
            </tr>

            <tr>
              <td colspan="2">
                <table>
                  <tr><th><a id="cql-content"><b>Content: </b></a> text/cql</th></tr>
                  <tr><td><pre><code class="language-cql">/*nter&quot;
    @author: Patrick Delcroix
    @description: This library is part of the project EmCare Project, its allows standardisation for the observation processing
    */

    library emcarebase version '1.0.1.rc12.build.156'

    using FHIR version '4.0.1'

    include FHIRHelpers version '4.0.1'

    parameter &quot;encounterid&quot; String
    //parameter &quot;Encounter&quot; Encounter$
    codesystem &quot;RoleCodeSystem&quot; : 'https://fhir.dk.swisstph-mis.ch/matchbox/fhir/CodeSystem/emcare-custom-codes'
    code &quot;Mother&quot;: 'MTH' from &quot;RoleCodeSystem&quot;

    context Patient

    //define encounterid:
    //  &quot;Encounter&quot;.id

    define &quot;Yes&quot;:
      true

    define &quot;No&quot;:
      false

    define function IsInEncounter(ref FHIR.Reference):
        case
        when encounterid = ref.id then true
        when encounterid = Last(Split(ref.reference, '/')) then true
       // when ref.identifier is not null and id = ref.identifier.id then true
        else false
    end

    define getEncounters:
        [Encounter] E
          where E.id = &quot;encounterid&quot;
            return E

    define getEncounter:
        singleton from getEncounters

    define function EmCareExtensions(element Patient, id String):
      element.extension E
          where E.url = ('https://fhir.dk.swisstph-mis.ch/matchbox/fhir//StructureDefinition/' + id)
          return E

    define function EmCareExtension(element Patient, id String):
      singleton from EmCareExtensions(element, id)

    define getPrimaryCareGiverReference:
      EmCareExtension(Patient, 'primarycaregiver').value

    define getPrimaryCareGiver:
      [RelatedPerson] RP where RP.id = Last(Split(getPrimaryCareGiverReference.reference, '/'))
        return RP

    define isMotherPrimaryCareGiver:
      getPrimaryCareGiver is not null and Exists(getPrimaryCareGiver.relationship r where r ~ &quot;Mother&quot;)

    define &quot;Biological Mother Vital Status&quot;:
      EmCareExtension(Patient, 'motherVitalStatus').value

    define &quot;Biological Father Vital Status&quot;:
      EmCareExtension(Patient, 'fatherVitalStatus').value
    // person accompanying the child is a participant with a null type
    define getRelatedPersonReferenceAccompanyingTheChild:
      Coalesce(First(getEncounter.participant P where not exists(P.type) ).individual, getPrimaryCareGiverReference)

    define getRelatedPersonsAccompanyingTheChild:
      [RelatedPerson] RP where RP.id = Last(Split(getRelatedPersonReferenceAccompanyingTheChild.reference, '/'))
        return RP

    define getRelatedPersonAccompanyingTheChild:
      singleton from getRelatedPersonsAccompanyingTheChild

    define &quot;Person accompanying child today's Relationship to Client&quot;:
      getRelatedPersonAccompanyingTheChild.relationship

    define function getValue(O Observation):
      case
          when  O is null then null
          when O.value is CodeableConcept then Coalesce(First(O.value.coding C where C.system  = 'https://fhir.dk.swisstph-mis.ch/matchbox/fhir/CodeSystem/emcare-custom-codes'), First(O.value.coding))
          else O.value
      end

    define function assesObservation(O Observation):
      case
          when  O is null then null
          when  O.status in  {'cancelled'} then false
          when O.value is null then  true
          else O.value
      end
    /*
    define function GetObservationDuringEncounter(idlist List&lt;System.Code&gt;):
      if GetObservationDuringEncounterDone(idlist ) is null then
          GetObservationDuringEncounterDone(idlist )
      else
        GetObservationDuringEncounterNotFound(idlist )
    */

    define function GetObservationDuringEncounter(id System.Code):
      Coalesce(GetObservationDuringEncounterDone(id ), GetObservationDuringEncounterNotFound(id ))
    /*
    define function GetObservationDuringEncounterDone(idlist List&lt;System.Code&gt;):
          Last([Observation: idlist ] O
            where   IsInEncounter(O.encounter)
            and O.status in { 'final', 'amended', 'corrected'})
    */
    define function GetObservationDuringEncounterDone(id System.Code):
          First([Observation: id ] O
            where   IsInEncounter(O.encounter)
            and O.status in { 'final', 'amended', 'corrected'}
            sort by issued.value desc)

    define function HasObservationCodeDuringEncounterDone(id System.Code, valueCode System.Code):

        Exists([Observation: id ] O
            where   IsInEncounter(O.encounter)
            and O.status in { 'final', 'amended', 'corrected'}
            and O.value is FHIR.CodeableConcept
            and O.value ~ valueCode)

    //Exists([Observation] O where O.status in { 'final', 'amended', 'corrected'} and O.value is FHIR.CodeableConcept   and Exists( O.value.coding C where C is FHIR.Coding and C.code = FHIR.code {value: 'EmCare.B20S2.DE04'}) )&quot;

    /*
    define function GetObservationDuringEncounterNotFound(idlist List&lt;System.Code&gt;):
          Last([Observation: idlist] O
           where  IsInEncounter(O.encounter)
              and O.status in {'cancelled'})
              */
    define function GetObservationDuringEncounterNotFound(id System.Code):
          First([Observation: id] O
           where  IsInEncounter(O.encounter)
              and O.status in {'cancelled'}
              sort by issued.value desc)
    /*

    define function GetNumberObservationDuringEncounter(idlist List&lt;System.Code&gt;):
      Count(
        [Observation: idlist] O
            where  IsInEncounter( O.encounter)
            and O.status in { 'final', 'amended', 'corrected'})
    */
    define function GetNumberObservationDuringEncounter(id System.Code):
      Count(
        [Observation: id] O
            where  IsInEncounter( O.encounter)
            and O.status in { 'final', 'amended', 'corrected'})

    // ************************   GetObsValue ************************/
    /*
    define function GetObsValue(idlist List&lt;System.Code&gt;):
        getValue(GetObservationDuringEncounter(idlist))

    define function GetObsValue(id System.Code):
        getValue(GetObservationDuringEncounter({id}))
    */

    define function GetObsValue(id System.Code):
        getValue(GetObservationDuringEncounter(id))

    define function GetObsValue(id System.String, codesystem System.String):
        getValue(GetObservationDuringEncounter(coding(id, codesystem)))

    define function GetObsValue(id System.String):
        getValue(GetObservationDuringEncounter(coding(id, 'https://fhir.dk.swisstph-mis.ch/matchbox/fhir/CodeSystem/emcare-custom-codes')))

    define function HasObsValueCode(id System.String, value System.Code):
       HasObservationCodeDuringEncounterDone(coding(id, 'https://fhir.dk.swisstph-mis.ch/matchbox/fhir/CodeSystem/emcare-custom-codes') , value )

    define function HasObsValueCode(id System.String, value System.String):
       HasObservationCodeDuringEncounterDone(coding(id, 'https://fhir.dk.swisstph-mis.ch/matchbox/fhir/CodeSystem/emcare-custom-codes') , coding(value, 'https://fhir.dk.swisstph-mis.ch/matchbox/fhir/CodeSystem/emcare-custom-codes') )

    define function HasObsValueCode(id System.Code, value System.String):
       HasObservationCodeDuringEncounterDone(id , coding(value, 'https://fhir.dk.swisstph-mis.ch/matchbox/fhir/CodeSystem/emcare-custom-codes') )

    // ************************   HasObs ************************/
    /*
    define function HasObs(idlist List&lt;System.Code&gt;):
        assesObservation(GetObservationDuringEncounter(idlist))

    define function HasObs(id System.Code):
        assesObservation(GetObservationDuringEncounter({id}))
    */
    define function HasObs(id System.Code):
        assesObservation(GetObservationDuringEncounter(id))

    define function HasObs(id System.String, codesystem System.String):
        assesObservation(GetObservationDuringEncounter(coding(id, codesystem)))

    define function HasObs(id System.String):
        assesObservation(GetObservationDuringEncounter(coding(id)))

    define function HasObs(id FHIR.code, codesystem System.String):
        assesObservation(GetObservationDuringEncounter(coding(id, codesystem)))
    /*
    define function GetHistoricObservation(idlist List&lt;System.Code&gt;, nbdays Integer):
      if GetHistoricObservationNotfound(idlist , codesystem , nbdays ) is null then
          GetHistoricObservationNotfound(idlist , codesystem , nbdays )
      else
        GetHistoricObservationNotfound(idlist , codesystem , nbdays )
    */

    define function GetHistoricObservation(id System.Code, nbdays Integer):
      Coalesce(GetHistoricObservationDone(id ,  nbdays ),  GetHistoricObservationNotfound(id  , nbdays ))
    /*
    define function GetHistoricObservationDone(idlist List&lt;System.Code&gt;, nbdays Integer):
          Last([Observation: idlist ] O
            where  O.status in { 'final', 'amended', 'corrected'}
            and (difference in days between O.issued and Today()) &lt; nbdays)
    */
    define function GetHistoricObservationDone(id System.Code, nbdays Integer):
          First([Observation: id ] O
            where  O.status in { 'final', 'amended', 'corrected'}
            and (difference in days between O.issued.value and Today()) &lt; nbdays
            sort by issued.value desc )

    /*
    define function GetHistoricObservationNotfound(idlist List&lt;System.Code&gt;, nbdays Integer):
          Last([Observation: idlist] O
            where  O.status in {'cancelled'}
    */
    define function GetHistoricObservationNotfound(id System.Code, nbdays Integer):
          First([Observation: id] O
            where  O.status in {'cancelled'}
              and (difference in days between O.issued.value and Today()) &lt; nbdays
            sort by issued.value desc)
    // ************************   HasObsHistory ************************/

    /*
    define function HasObsHistory(idlist List&lt;System.Code&gt;,  nbdays Integer):
      assesObservation(GetHistoricObservation(idlist, nbdays))

     define function HasObsHistory(id System.Code, cnbdays Integer):
      assesObservation(GetHistoricObservation({id}, nbdays))
    */
    define function HasObsHistory(id System.Code, nbdays Integer):
      assesObservation(GetHistoricObservation(id, nbdays))

    define function HasObsHistory(id System.String, codesystem System.String, nbdays Integer):
      assesObservation(GetHistoricObservation(coding(id, codesystem), nbdays))

    define function HasObsHistory(id System.String, nbdays Integer):
      assesObservation(GetHistoricObservation(coding(id), nbdays))

    define function c(s System.String):
      FHIR.code { value: s }

    define function coding(s System.String, url System.String):
      System.Code {
                    code:  s ,
                    system:  url
                }

    define function coding(s FHIR.code, url System.String):
      System.Code {
                    code:  s.value ,
                    system:  url
                }

    define function coding(s System.String):
      System.Code {
                    code:  s ,
                    system:  'https://fhir.dk.swisstph-mis.ch/matchbox/fhir/CodeSystem/emcare-custom-codes'
                }

    define function ToUrl(s System.String):
      url {value:s}

    // ************************   GetCond ************************/
    /*
    define function GetCoO.encounterndition(idlist List&lt;System.Code&gt;):
          Last([Condition: idlist] O
            where  IsInEncounter( O.encounter)
            and exists(O.verificationStatus.coding C where C.code in {'unconfirmed', 'provisional', 'differential', 'confirmed'}
            and C.system = 'http://terminology.hl7.org/CodeSystem/condition-ver-status'))
    */
    define function GetCondition(id System.Code):
          First([Condition: id] O
            where  IsInEncounter(O.encounter)
            and exists(O.verificationStatus.coding C where C.code in {'unconfirmed', 'provisional', 'differential', 'confirmed'}
            and C.system = 'http://terminology.hl7.org/CodeSystem/condition-ver-status')
            sort by recordedDate desc)

    define function assesCondition(O Condition):
      if O is null then
        false
      else
        true
    /*
    define function GetCond(idlist List&lt;System.Code&gt;):
      GetCondition(idlist)

    define function GetCond(id System.Code):
      GetCondition({id})
    */
    define function GetCond(id System.Code):
      (GetCondition(id))

    define function GetCond(id System.String, codesystem System.String):
      (GetCondition(coding(id, codesystem)))

    define function GetCond(id System.String):
      (GetCondition(coding(id)))

    // ************************   HasCond ************************/
    /*
    define function HasCond(idlist List&lt;System.Code&gt;):
      assesCondition(GetCondition(idlist))

    3518GetCondition(id))
    */
    define function HasCond(id System.String, codesystem System.String):
      assesCondition(GetCondition(coding(id, codesystem)))

    define function HasCond(id System.String):
      assesCondition(GetCondition(coding(id)))

    define function HasCond(id System.Code):
      assesCondition(GetCondition(id))

    // ************************   PatientHasHistoryOfCondition ************************/
    /*
    define function GetHistoricCondition(idlist List&lt;System.Code&gt;,  nbdays Integer):
          Last([Condition: idlist] O
            where  (difference in days between O.recordedDate and Today()) &lt; nbdays
            and exists(O.verificationStatus.coding C where C.code in {'unconfirmed', 'provisional', 'differential', 'confirmed'}
            and C.system = 'http://terminology.hl7.org/CodeSystem/condition-ver-status'))
    */

    define function GetHistoricCondition(id System.Code,  nbdays Integer):
          First([Condition: id] O
            where  (difference in days between O.recordedDate and Today()) &lt; nbdays
            and exists(O.verificationStatus.coding C where C.code in {'unconfirmed', 'provisional', 'differential', 'confirmed'}
            and C.system = 'http://terminology.hl7.org/CodeSystem/condition-ver-status')
            sort by recordedDate desc)

    /*
    define function HasCondHistory(idlist List&lt;System.Code&gt;,  nbdays Integer):
      assesCondition(GetHistoricCondition(idlist,  nbdays))

    define function HasCondHistory(id System.Code,  nbdays Integer):
      assesCondition(GetHistoricCondition({id}, nbdays))
    */
    define function HasCondHistory(id System.Code, nbdays Integer):
      assesCondition(GetHistoricCondition(id,  nbdays))

    define function HasCondHistory(id System.String, codesystem System.String, nbdays Integer):
      assesCondition(GetHistoricCondition(coding(id,codesystem),nbdays))

    define function HasCondHistory(id System.String, nbdays Integer):
      assesCondition(GetHistoricCondition(coding(id),  nbdays))

    //define function PatientHasConditionDuringEncounter(id String, codesystem url, duration Integer)):

    //define function PatientHasConditionFromValueSetDuringEncounter(id String, codesystem url, duration Integer)):

    //define function PatientHasHsistoryCondition(id String,codesystem url , duration Integer):
    //define function PatientHasHsistoryConditionFromValueSet(id String,codesystem url , duration Integer):

    // PatientHasSymptom(&quot;symptom name&quot;): symptom in the encounter

    // PatientLastMeasureOf(&quot;measure name&quot;): measure in the encounter

    // PatientLastHistoricMeasureOf(&quot;measure name&quot;, duration): measure in the patient history during duration

    // PatientHasDiagnostic(&quot;Diagnostic name&quot; ): Diagnostic in the encounter

    // PatientHasHistoryOfDiagnostic(&quot;Diagnostic name&quot;, duration ): Diagnostic in the patient history during duration

    // PatientHasProposedorConfirmedDianostic(&quot;Diagnostic name&quot; ): Diagnostic in the encounter

    // PatientHasHistoryOfProposedorConfirmedDianostic(&quot;Diagnostic name&quot;, duration ): Diagnostic in the patient history during duration

    // PatientZScoreWfA(wieght, age)

    // PatientWeightFromWfA(age, Muac)
    </code></pre></td></tr>
                </table>
              </td>
            </tr>

        </table>
    </div>
    </div>
      </text>
      <url value="https://smart.who.int/ccc/Library/Cccbase"/>
      <version value="0.1.0"/>
      <name value="Cccbase"/>
      <title value="CccBase"/>
      <status value="active"/>
      <type>
        <coding>
          <system value="http://hl7.org/fhir/ValueSet/library-type"/>
          <code value="logic-library"/>
        </coding>
      </type>
      <date value="2026-04-07T13:42:05+00:00"/>
      <publisher value="World Health Organization (WHO)"/>
      <contact>
        <name value="World Health Organization (WHO)"/>
        <telecom>
          <system value="url"/>
          <value value="https://www.who.int"/>
        </telecom>
      </contact>
      <contact>
        <telecom>
          <system value="url"/>
          <value value="https://www.who.int"/>
        </telecom>
      </contact>
      <jurisdiction>
        <coding>
          <system value="http://unstats.un.org/unsd/methods/m49/m49.htm"/>
          <code value="001"/>
        </coding>
      </jurisdiction>
      <relatedArtifact>
        <type value="depends-on"/>
        <resource value="http://fhir.org/guides/who/anc-cds/Library/FHIRHelpers"/>
      </relatedArtifact>
      <parameter>
        <name value="encounterid"/>
        <use value="in"/>
        <type value="string"/>
      </parameter>
      <dataRequirement>
        <type value="Patient"/>
        <profile value="http://hl7.org/fhir/StructureDefinition/Patient"/>
      </dataRequirement>
      <dataRequirement>
        <type value="Encounter"/>
        <profile value="http://hl7.org/fhir/StructureDefinition/Encounter"/>
      </dataRequirement>
      <content id="ig-loader-Cccbase.cql">
        <contentType value="text/cql"/>
        <data
              value=" "/>
      </content>
    </Library>