FHIR © HL7.org  |  FHIRsmith 4.0.1  |  Server Home  |  XIG Home  |  XIG Stats  | 

FHIR IG analytics

Packagesilfhirprofileig
Resource TypeStructureMap
IdStructureMap-ExtractInpatientCriticalCareAssessment.json
FHIR VersionR5
Sourcehttps://build.fhir.org/ig/savannahghi/sil_fhir_profile_ig/StructureMap-ExtractInpatientCriticalCareAssessment.html
URLhttps://fhir.slade360.co.ke/fhir/StructureMap/ExtractInpatientCriticalCareAssessment
Version0.1.0
Statusactive
Date2026-09-11T12:18:36+00:00
NameExtractInpatientCriticalCareAssessment
TitleInpatient Critical Care Assessment Extraction
DescriptionOne Observation for the Glasgow Coma Scale, carrying the total as its value and the eye, verbal and motor sub-scores as components; one for the method of oxygen delivery; one for the organ support narrative; and a MedicationAdministration for the vasopressor the patient is on. The GCS total prefers the calculated total the form submits and falls back to summing the answer weights itself, so the score still extracts from a client that does not evaluate SDC expressions.

Resources that use this resource

No resources found


Resources that this resource uses

No resources found


Narrative

Note: links and images are rebased to the (stated) source

Generated Narrative: StructureMap ExtractInpatientCriticalCareAssessment

/// url = 'https://fhir.slade360.co.ke/fhir/StructureMap/ExtractInpatientCriticalCareAssessment'
/// name = 'ExtractInpatientCriticalCareAssessment'
/// title = 'Inpatient Critical Care Assessment Extraction'
/// status = 'active'
/// description = 'One Observation for the Glasgow Coma Scale, carrying the total as its value and the eye, verbal and motor sub-scores as components; one for the method of oxygen delivery; one for the organ support narrative; and a MedicationAdministration for the vasopressor the patient is on. The GCS total prefers the calculated total the form submits and falls back to summing the answer weights itself, so the score still extracts from a client that does not evaluate SDC expressions.'

uses "http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse" alias QR as source
uses "http://hl7.org/fhir/StructureDefinition/Bundle" alias Bundle as target
uses "http://hl7.org/fhir/StructureDefinition/Observation" alias Observation as target
uses "http://hl7.org/fhir/StructureDefinition/MedicationAdministration" alias MedicationAdministration as target

group ExtractInpatientCriticalCareAssessment(source qr : QR, target bundle : Bundle) {
  qr -> bundle.type = 'transaction' "setBundleType";
  // ── Glasgow Coma Scale ─────────────────────────────────────────────────────
  // One Observation, not three. The total is the reading a clinician acts on
  // and the three sub-scores are how it was arrived at, which is exactly what
  // Observation.component is for. (The older GlasgowCommaScaleExtract map emits
  // three separate Observations from a different questionnaire; it is untouched.)
  qr.item as gG where ((linkId = 'gcs') and item.answer.value.ofType(Coding).exists()) then {
    gG ->  bundle.entry as entryG,  entryG.resource = create('Observation') as obsG then {
      qr ->  obsG,  entryG then BuildObsBase(qr, obsG, entryG) "gcsBase";
      qr -> obsG then SetSurveyCategory(qr, obsG) "gcsCategory";
      qr -> obsG.code as code then {
        qr -> code.coding as coding then {
          qr -> coding.system = 'http://loinc.org' "codeSystem";
          qr -> coding.code = '9269-2' "codeCode";
          qr -> coding.display = 'Glasgow coma score total' "codeDisplay";
        } "codeCoding";
      } "gcsCode";
      // The submitted total wins; otherwise sum the answers. Every scored answer
      // in SGHIClinicalScoreCodeSystem ends in its own weight -- gcs-motor-6 is
      // worth 6 -- so the fallback reads the weight off the code. The two paths
      // are the same arithmetic as the questionnaire's calculatedExpression, so
      // they cannot disagree.
      // Guarded on all three sub-scores being present. A GCS of 7 summed from
      // eye and motor alone reads as a comatose patient; the components still
      // extract, but the total does not, because a partial GCS is not a GCS.
      gG where (item.answer.value.ofType(Coding).count() = 3) then {
        gG -> obsG.value = evaluate(gG, iif(item.where(linkId = 'gcs.total').answer.value.exists(), item.where(linkId = 'gcs.total').answer.value, item.answer.value.ofType(Coding).code.select($this.split('-').last().toInteger()).aggregate($this + $total, 0))) "gcsTotalValue";
      } "gcsTotalRule";
      gG.item as itE where ((linkId = 'gcs.eye') and answer.value.exists()) -> obsG.component as comp then {
        itE -> comp.code as code then {
          itE -> code.coding as coding then {
            itE -> coding.system = 'http://loinc.org' "codeSystem";
            itE -> coding.code = '9267-6' "codeCode";
            itE -> coding.display = 'Glasgow coma score eye opening' "codeDisplay";
          } "codeCoding";
        } "eyeCode";
        itE -> comp then SetComponentCodedValue(itE, comp) "eyeValue";
      } "gcsEyeRule";
      gG.item as itV where ((linkId = 'gcs.verbal') and answer.value.exists()) -> obsG.component as comp then {
        itV -> comp.code as code then {
          itV -> code.coding as coding then {
            itV -> coding.system = 'http://loinc.org' "codeSystem";
            itV -> coding.code = '9270-0' "codeCode";
            itV -> coding.display = 'Glasgow coma score verbal' "codeDisplay";
          } "codeCoding";
        } "verbalCode";
        itV -> comp then SetComponentCodedValue(itV, comp) "verbalValue";
      } "gcsVerbalRule";
      gG.item as itM where ((linkId = 'gcs.motor') and answer.value.exists()) -> obsG.component as comp then {
        itM -> comp.code as code then {
          itM -> code.coding as coding then {
            itM -> coding.system = 'http://loinc.org' "codeSystem";
            itM -> coding.code = '9268-4' "codeCode";
            itM -> coding.display = 'Glasgow coma score motor' "codeDisplay";
          } "codeCoding";
        } "motorCode";
        itM -> comp then SetComponentCodedValue(itM, comp) "motorValue";
      } "gcsMotorRule";
    } "gcsObservation";
  } "gcsRule";
  // ── Oxygen support ─────────────────────────────────────────────────────────
  // Category `therapy`: this records a treatment being delivered, not a
  // measurement taken.
  qr.item as itO where ((linkId = 'oxygen') and answer.value.exists()) then {
    itO.answer first as aO then {
      aO ->  bundle.entry as entryO,  entryO.resource = create('Observation') as obsO then {
        qr ->  obsO,  entryO then BuildObsBase(qr, obsO, entryO) "oxygenBase";
        qr -> obsO then SetTherapyCategory(qr, obsO) "oxygenCategory";
        qr -> obsO.code as code then {
          qr -> code.coding as coding then {
            qr -> coding.system = 'http://loinc.org' "codeSystem";
            qr -> coding.code = '107117-4' "codeCode";
            qr -> coding.display = 'Method of oxygen delivery' "codeDisplay";
          } "codeCoding";
        } "oxygenCode";
        aO -> obsO then SetCodedValue(aO, obsO) "oxygenValue";
      } "oxygenObservation";
    } "oxygenAnswer";
  } "oxygenRule";
  // ── Organ support ──────────────────────────────────────────────────────────
  // LOINC has codes for individual supports but none for the summary the form
  // asks for, so a local code. See SGHIInpatientClinicalConceptCodeSystem.
  qr.item as itS where ((linkId = 'organSupport') and answer.value.exists()) then {
    itS.answer first as aS then {
      aS ->  bundle.entry as entryS,  entryS.resource = create('Observation') as obsS then {
        qr ->  obsS,  entryS then BuildObsBase(qr, obsS, entryS) "organSupportBase";
        qr -> obsS then SetTherapyCategory(qr, obsS) "organSupportCategory";
        qr -> obsS.code as code then {
          qr -> code.coding as coding then {
            qr -> coding.system = 'https://fhir.slade360.co.ke/fhir/CodeSystem/inpatient-clinical-concept-codesystem' "codeSystem";
            qr -> coding.code = 'organ-support' "codeCode";
            qr -> coding.display = 'Organ support needed' "codeDisplay";
          } "codeCoding";
          qr -> code.text = 'Organ support needed' "codeText";
        } "organSupportCode";
        aS.value as v -> obsS.value = v "organSupportValue";
      } "organSupportObservation";
    } "organSupportAnswer";
  } "organSupportRule";
  // ── Vasopressor ────────────────────────────────────────────────────────────
  // The form captures a dose description ("Noradrenaline 0.1 mcg/kg/min"), not
  // a medication reference, so the wording lands in medication.concept.text
  // rather than being matched against a drug dictionary. Status is
  // `in-progress`: the assessment records an infusion running at the moment it
  // was written, and `completed` would assert it had finished, which is not
  // what the nurse wrote.
  qr.item as itV where ((linkId = 'vasopressor') and answer.value.exists()) then {
    itV.answer first as aV then {
      aV ->  bundle.entry as entryV,  entryV.resource = create('MedicationAdministration') as ma then {
        qr -> ma.id = uuid() then SetMedicationAdministrationFullUrl(ma, entryV) "idAndFullUrl";
        qr -> entryV.request as request then {
          qr -> request.method = 'POST' "requestMethod";
          qr -> request.url = 'MedicationAdministration' "requestUrl";
        } "entryRequest";
        qr -> ma.status = 'in-progress' "status";
        qr -> ma.category as cat then {
          qr -> cat.coding as coding then {
            qr -> coding.system = 'http://terminology.hl7.org/CodeSystem/medication-admin-location' "categorySystem";
            qr -> coding.code = 'inpatient' "categoryCode";
            qr -> coding.display = 'Inpatient' "categoryDisplay";
          } "categoryCoding";
        } "category";
        aV.value as v -> ma.medication as medRef then {
          v -> medRef.concept as concept then {
            v -> concept.text = v "medicationText";
          } "medicationConcept";
        } "medication";
        qr.subject as s -> ma.subject = s;
        qr.encounter as e -> ma.encounter = e;
        // R5 spells this element `occurence[x]`. That is the specification's own
        // typo, not one here.
        qr.authored as t -> ma.occurence = t "occurrence";
        qr.authored as t -> ma.recorded = t "recorded";
        qr -> ma.supportingInformation = create('Reference') as ref then {
          qr.id as qid -> ref.reference = qid "supportingInformationRef";
        } "linkQuestionnaireResponse";
      } "medicationAdministration";
    } "vasopressorAnswer";
  } "vasopressorRule";
}

// ─────────────────────────────────────────────────────────────────────────────
// Shared scaffolding. Repeated in each map rather than imported: the transform
// engine resolves `imports` against whatever StructureMaps happen to be on the
// server, and a form that stops extracting because a shared map was not
// uploaded is a worse failure than a duplicated group.
// ─────────────────────────────────────────────────────────────────────────────
// Two notes on what the publisher's StructureMap validator says about this file.
// Source parameters below are left untyped on purpose. Writing `: Element` makes
// the validator compare QuestionnaireResponse.item against the literal 'Element'
// and report them as incompatible with each other, which is noise, not a finding.
// Untyped, it says only that it cannot check the paths.
// `evaluate(context, expression)` is flagged as "takes 1 parameter but 2 were
// found". Leave it. The FML parser in the same jar refuses the one-argument form
// outright -- it wants a parameter, a comma, then the FHIRPath -- so the publisher
// is objecting to what its own compiler emits. Two arguments is the only form that
// compiles, and it is what the R5 transform engine executes.
group BuildObsBase(source qr : QR, target obs : Observation, target entry) {
  qr -> obs.id = uuid() then SetObservationFullUrl(obs, entry) "idAndFullUrl";
  qr -> entry.request as request then {
    qr -> request.method = 'POST' "requestMethod";
    qr -> request.url = 'Observation' "requestUrl";
  } "entryRequest";
  qr -> obs.status = 'final' "status";
  qr.subject as s -> obs.subject = s;
  qr.encounter as e -> obs.encounter = e;
  qr.authored as t -> obs.effective = t "effective";
  qr.source as src -> obs.performer = src "performerFromSource";
  qr where (source.exists().not()) then {
    qr.author as a -> obs.performer = a "performerFromAuthor";
  } "performerFallback";
  qr -> obs.derivedFrom = create('Reference') as ref then {
    qr.id as qid -> ref.reference = qid "derivedFromRef";
  } "linkQuestionnaireResponse";
}

group SetCodedValue(source a, target obs : Observation) {
  a.value as cv -> obs.value = create('CodeableConcept') as cc then {
    cv -> cc.coding = cv "valueCoding";
    cv.display as d -> cc.text = d "valueText";
  } "codedValue";
}

group SetComponentCodedValue(source it, target comp) {
  it.answer first as a then {
    a.value as cv -> comp.value = create('CodeableConcept') as cc then {
      cv -> cc.coding = cv "valueCoding";
      cv.display as d -> cc.text = d "valueText";
    } "codedValue";
  } "componentAnswer";
}

group SetSurveyCategory(source qr : QR, target obs : Observation) {
  qr -> obs.category as cat then {
    qr -> cat.coding as coding then {
      qr -> coding.system = 'http://terminology.hl7.org/CodeSystem/observation-category' "categorySystem";
      qr -> coding.code = 'survey' "categoryCode";
      qr -> coding.display = 'Survey' "categoryDisplay";
    } "categoryCoding";
  } "category";
}

group SetTherapyCategory(source qr : QR, target obs : Observation) {
  qr -> obs.category as cat then {
    qr -> cat.coding as coding then {
      qr -> coding.system = 'http://terminology.hl7.org/CodeSystem/observation-category' "categorySystem";
      qr -> coding.code = 'therapy' "categoryCode";
      qr -> coding.display = 'Therapy' "categoryDisplay";
    } "categoryCoding";
  } "category";
}

group SetObservationFullUrl(source obs : Observation, target entry) {
  obs.id as id -> entry.fullUrl = append('https://fhir.slade360.co.ke/fhir/Observation/', id) "assignFullUrl";
}

group SetMedicationAdministrationFullUrl(source ma : MedicationAdministration, target entry) {
  ma.id as id -> entry.fullUrl = append('https://fhir.slade360.co.ke/fhir/MedicationAdministration/', id) "assignFullUrl";
}


Source1

{
  "resourceType": "StructureMap",
  "id": "ExtractInpatientCriticalCareAssessment",
  "text": {
    "status": "generated",
    "div": "<!-- snip (see above) -->"
  },
  "url": "https://fhir.slade360.co.ke/fhir/StructureMap/ExtractInpatientCriticalCareAssessment",
  "version": "0.1.0",
  "name": "ExtractInpatientCriticalCareAssessment",
  "title": "Inpatient Critical Care Assessment Extraction",
  "status": "active",
  "date": "2026-09-11T12:18:36+00:00",
  "publisher": "Kathurima Kimathi",
  "contact": [
    {
      "name": "Kathurima Kimathi",
      "telecom": [
        {
          "system": "url",
          "value": "https://www.linkedin.com/in/kathurima-kimathi/"
        },
        {
          "system": "email",
          "value": "kathurimakimathi415@gmail.com"
        }
      ]
    },
    {
      "name": "Oscar John",
      "telecom": [
        {
          "system": "email",
          "value": "oscarjohnotieno@gmail.com",
          "use": "work"
        }
      ]
    },
    {
      "name": "Kennedy Omondi",
      "telecom": [
        {
          "system": "email",
          "value": "kennankole@gmail.com",
          "use": "work"
        }
      ]
    }
  ],
  "description": "One Observation for the Glasgow Coma Scale, carrying the total as its value and the eye, verbal and motor sub-scores as components; one for the method of oxygen delivery; one for the organ support narrative; and a MedicationAdministration for the vasopressor the patient is on. The GCS total prefers the calculated total the form submits and falls back to summing the answer weights itself, so the score still extracts from a client that does not evaluate SDC expressions.",
  "structure": [
    {
      "url": "http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse",
      "mode": "source",
      "alias": "QR"
    },
    {
      "url": "http://hl7.org/fhir/StructureDefinition/Bundle",
      "mode": "target",
      "alias": "Bundle"
    },
    {
      "url": "http://hl7.org/fhir/StructureDefinition/Observation",
      "mode": "target",
      "alias": "Observation"
    },
    {
      "url": "http://hl7.org/fhir/StructureDefinition/MedicationAdministration",
      "mode": "target",
      "alias": "MedicationAdministration"
    }
  ],
  "group": [
    {
      "name": "ExtractInpatientCriticalCareAssessment",
      "input": [
        {
          "name": "qr",
          "type": "QR",
          "mode": "source"
        },
        {
          "name": "bundle",
          "type": "Bundle",
          "mode": "target"
        }
      ],
      "rule": [
        {
          "name": "setBundleType",
          "source": [
            {
              "context": "qr"
            }
          ],
          "target": [
            {
              "context": "bundle",
              "element": "type",
              "transform": "copy",
              "parameter": [
                {
                  "valueString": "transaction"
                }
              ]
            }
          ]
        },
        {
          "name": "gcsRule",
          "source": [
            {
              "context": "qr",
              "element": "item",
              "variable": "gG",
              "condition": "(linkId = 'gcs') and item.answer.value.ofType(Coding).exists()"
            }
          ],
          "rule": [
            {
              "name": "gcsObservation",
              "source": [
                {
                  "context": "gG"
                }
              ],
              "target": [
                {
                  "context": "bundle",
                  "element": "entry",
                  "variable": "entryG"
                },
                {
                  "context": "entryG",
                  "element": "resource",
                  "variable": "obsG",
                  "transform": "create",
                  "parameter": [
                    {
                      "valueString": "Observation"
                    }
                  ]
                }
              ],
              "rule": [
                {
                  "name": "gcsBase",
                  "source": [
                    {
                      "context": "qr"
                    }
                  ],
                  "target": [
                    {
                      "context": "obsG"
                    },
                    {
                      "context": "entryG"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "BuildObsBase",
                      "parameter": [
                        {
                          "valueId": "qr"
                        },
                        {
                          "valueId": "obsG"
                        },
                        {
                          "valueId": "entryG"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "gcsCategory",
                  "source": [
                    {
                      "context": "qr"
                    }
                  ],
                  "target": [
                    {
                      "context": "obsG"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetSurveyCategory",
                      "parameter": [
                        {
                          "valueId": "qr"
                        },
                        {
                          "valueId": "obsG"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "gcsCode",
                  "source": [
                    {
                      "context": "qr"
                    }
                  ],
                  "target": [
                    {
                      "context": "obsG",
                      "element": "code",
                      "variable": "code"
                    }
                  ],
                  "rule": [
                    {
                      "name": "codeCoding",
                      "source": [
                        {
                          "context": "qr"
                        }
                      ],
                      "target": [
                        {
                          "context": "code",
                          "element": "coding",
                          "variable": "coding"
                        }
                      ],
                      "rule": [
                        {
                          "name": "codeSystem",
                          "source": [
                            {
                              "context": "qr"
                            }
                          ],
                          "target": [
                            {
                              "context": "coding",
                              "element": "system",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "http://loinc.org"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "codeCode",
                          "source": [
                            {
                              "context": "qr"
                            }
                          ],
                          "target": [
                            {
                              "context": "coding",
                              "element": "code",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "9269-2"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "codeDisplay",
                          "source": [
                            {
                              "context": "qr"
                            }
                          ],
                          "target": [
                            {
                              "context": "coding",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Glasgow coma score total"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "gcsTotalRule",
                  "source": [
                    {
                      "context": "gG",
                      "condition": "item.answer.value.ofType(Coding).count() = 3"
                    }
                  ],
                  "rule": [
                    {
                      "name": "gcsTotalValue",
                      "source": [
                        {
                          "context": "gG"
                        }
                      ],
                      "target": [
                        {
                          "context": "obsG",
                          "element": "value",
                          "transform": "evaluate",
                          "parameter": [
                            {
                              "valueId": "gG"
                            },
                            {
                              "valueString": "iif(item.where(linkId = 'gcs.total').answer.value.exists(), item.where(linkId = 'gcs.total').answer.value, item.answer.value.ofType(Coding).code.select($this.split('-').last().toInteger()).aggregate($this + $total, 0))"
                            }
                          ]
                        }
                      ]
                    }
                  ],
                  "documentation": "The submitted total wins; otherwise sum the answers. Every scored answer\r\nin SGHIClinicalScoreCodeSystem ends in its own weight -- gcs-motor-6 is\r\nworth 6 -- so the fallback reads the weight off the code. The two paths\r\nare the same arithmetic as the questionnaire's calculatedExpression, so\r\nthey cannot disagree.\r\nGuarded on all three sub-scores being present. A GCS of 7 summed from\r\neye and motor alone reads as a comatose patient; the components still\r\nextract, but the total does not, because a partial GCS is not a GCS."
                },
                {
                  "name": "gcsEyeRule",
                  "source": [
                    {
                      "context": "gG",
                      "element": "item",
                      "variable": "itE",
                      "condition": "(linkId = 'gcs.eye') and answer.value.exists()"
                    }
                  ],
                  "target": [
                    {
                      "context": "obsG",
                      "element": "component",
                      "variable": "comp"
                    }
                  ],
                  "rule": [
                    {
                      "name": "eyeCode",
                      "source": [
                        {
                          "context": "itE"
                        }
                      ],
                      "target": [
                        {
                          "context": "comp",
                          "element": "code",
                          "variable": "code"
                        }
                      ],
                      "rule": [
                        {
                          "name": "codeCoding",
                          "source": [
                            {
                              "context": "itE"
                            }
                          ],
                          "target": [
                            {
                              "context": "code",
                              "element": "coding",
                              "variable": "coding"
                            }
                          ],
                          "rule": [
                            {
                              "name": "codeSystem",
                              "source": [
                                {
                                  "context": "itE"
                                }
                              ],
                              "target": [
                                {
                                  "context": "coding",
                                  "element": "system",
                                  "transform": "copy",
                                  "parameter": [
                                    {
                                      "valueString": "http://loinc.org"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name": "codeCode",
                              "source": [
                                {
                                  "context": "itE"
                                }
                              ],
                              "target": [
                                {
                                  "context": "coding",
                                  "element": "code",
                                  "transform": "copy",
                                  "parameter": [
                                    {
                                      "valueString": "9267-6"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name": "codeDisplay",
                              "source": [
                                {
                                  "context": "itE"
                                }
                              ],
                              "target": [
                                {
                                  "context": "coding",
                                  "element": "display",
                                  "transform": "copy",
                                  "parameter": [
                                    {
                                      "valueString": "Glasgow coma score eye opening"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name": "eyeValue",
                      "source": [
                        {
                          "context": "itE"
                        }
                      ],
                      "target": [
                        {
                          "context": "comp"
                        }
                      ],
                      "dependent": [
                        {
                          "name": "SetComponentCodedValue",
                          "parameter": [
                            {
                              "valueId": "itE"
                            },
                            {
                              "valueId": "comp"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "gcsVerbalRule",
                  "source": [
                    {
                      "context": "gG",
                      "element": "item",
                      "variable": "itV",
                      "condition": "(linkId = 'gcs.verbal') and answer.value.exists()"
                    }
                  ],
                  "target": [
                    {
                      "context": "obsG",
                      "element": "component",
                      "variable": "comp"
                    }
                  ],
                  "rule": [
                    {
                      "name": "verbalCode",
                      "source": [
                        {
                          "context": "itV"
                        }
                      ],
                      "target": [
                        {
                          "context": "comp",
                          "element": "code",
                          "variable": "code"
                        }
                      ],
                      "rule": [
                        {
                          "name": "codeCoding",
                          "source": [
                            {
                              "context": "itV"
                            }
                          ],
                          "target": [
                            {
                              "context": "code",
                              "element": "coding",
                              "variable": "coding"
                            }
                          ],
                          "rule": [
                            {
                              "name": "codeSystem",
                              "source": [
                                {
                                  "context": "itV"
                                }
                              ],
                              "target": [
                                {
                                  "context": "coding",
                                  "element": "system",
                                  "transform": "copy",
                                  "parameter": [
                                    {
                                      "valueString": "http://loinc.org"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name": "codeCode",
                              "source": [
                                {
                                  "context": "itV"
                                }
                              ],
                              "target": [
                                {
                                  "context": "coding",
                                  "element": "code",
                                  "transform": "copy",
                                  "parameter": [
                                    {
                                      "valueString": "9270-0"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name": "codeDisplay",
                              "source": [
                                {
                                  "context": "itV"
                                }
                              ],
                              "target": [
                                {
                                  "context": "coding",
                                  "element": "display",
                                  "transform": "copy",
                                  "parameter": [
                                    {
                                      "valueString": "Glasgow coma score verbal"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name": "verbalValue",
                      "source": [
                        {
                          "context": "itV"
                        }
                      ],
                      "target": [
                        {
                          "context": "comp"
                        }
                      ],
                      "dependent": [
                        {
                          "name": "SetComponentCodedValue",
                          "parameter": [
                            {
                              "valueId": "itV"
                            },
                            {
                              "valueId": "comp"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "gcsMotorRule",
                  "source": [
                    {
                      "context": "gG",
                      "element": "item",
                      "variable": "itM",
                      "condition": "(linkId = 'gcs.motor') and answer.value.exists()"
                    }
                  ],
                  "target": [
                    {
                      "context": "obsG",
                      "element": "component",
                      "variable": "comp"
                    }
                  ],
                  "rule": [
                    {
                      "name": "motorCode",
                      "source": [
                        {
                          "context": "itM"
                        }
                      ],
                      "target": [
                        {
                          "context": "comp",
                          "element": "code",
                          "variable": "code"
                        }
                      ],
                      "rule": [
                        {
                          "name": "codeCoding",
                          "source": [
                            {
                              "context": "itM"
                            }
                          ],
                          "target": [
                            {
                              "context": "code",
                              "element": "coding",
                              "variable": "coding"
                            }
                          ],
                          "rule": [
                            {
                              "name": "codeSystem",
                              "source": [
                                {
                                  "context": "itM"
                                }
                              ],
                              "target": [
                                {
                                  "context": "coding",
                                  "element": "system",
                                  "transform": "copy",
                                  "parameter": [
                                    {
                                      "valueString": "http://loinc.org"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name": "codeCode",
                              "source": [
                                {
                                  "context": "itM"
                                }
                              ],
                              "target": [
                                {
                                  "context": "coding",
                                  "element": "code",
                                  "transform": "copy",
                                  "parameter": [
                                    {
                                      "valueString": "9268-4"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name": "codeDisplay",
                              "source": [
                                {
                                  "context": "itM"
                                }
                              ],
                              "target": [
                                {
                                  "context": "coding",
                                  "element": "display",
                                  "transform": "copy",
                                  "parameter": [
                                    {
                                      "valueString": "Glasgow coma score motor"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name": "motorValue",
                      "source": [
                        {
                          "context": "itM"
                        }
                      ],
                      "target": [
                        {
                          "context": "comp"
                        }
                      ],
                      "dependent": [
                        {
                          "name": "SetComponentCodedValue",
                          "parameter": [
                            {
                              "valueId": "itM"
                            },
                            {
                              "valueId": "comp"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ],
          "documentation": "── Glasgow Coma Scale ─────────────────────────────────────────────────────\r\nOne Observation, not three. The total is the reading a clinician acts on\r\nand the three sub-scores are how it was arrived at, which is exactly what\r\nObservation.component is for. (The older GlasgowCommaScaleExtract map emits\r\nthree separate Observations from a different questionnaire; it is untouched.)"
        },
        {
          "name": "oxygenRule",
          "source": [
            {
              "context": "qr",
              "element": "item",
              "variable": "itO",
              "condition": "(linkId = 'oxygen') and answer.value.exists()"
            }
          ],
          "rule": [
            {
              "name": "oxygenAnswer",
              "source": [
                {
                  "context": "itO",
                  "element": "answer",
                  "listMode": "first",
                  "variable": "aO"
                }
              ],
              "rule": [
                {
                  "name": "oxygenObservation",
                  "source": [
                    {
                      "context": "aO"
                    }
                  ],
                  "target": [
                    {
                      "context": "bundle",
                      "element": "entry",
                      "variable": "entryO"
                    },
                    {
                      "context": "entryO",
                      "element": "resource",
                      "variable": "obsO",
                      "transform": "create",
                      "parameter": [
                        {
                          "valueString": "Observation"
                        }
                      ]
                    }
                  ],
                  "rule": [
                    {
                      "name": "oxygenBase",
                      "source": [
                        {
                          "context": "qr"
                        }
                      ],
                      "target": [
                        {
                          "context": "obsO"
                        },
                        {
                          "context": "entryO"
                        }
                      ],
                      "dependent": [
                        {
                          "name": "BuildObsBase",
                          "parameter": [
                            {
                              "valueId": "qr"
                            },
                            {
                              "valueId": "obsO"
                            },
                            {
                              "valueId": "entryO"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name": "oxygenCategory",
                      "source": [
                        {
                          "context": "qr"
                        }
                      ],
                      "target": [
                        {
                          "context": "obsO"
                        }
                      ],
                      "dependent": [
                        {
                          "name": "SetTherapyCategory",
                          "parameter": [
                            {
                              "valueId": "qr"
                            },
                            {
                              "valueId": "obsO"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name": "oxygenCode",
                      "source": [
                        {
                          "context": "qr"
                        }
                      ],
                      "target": [
                        {
                          "context": "obsO",
                          "element": "code",
                          "variable": "code"
                        }
                      ],
                      "rule": [
                        {
                          "name": "codeCoding",
                          "source": [
                            {
                              "context": "qr"
                            }
                          ],
                          "target": [
                            {
                              "context": "code",
                              "element": "coding",
                              "variable": "coding"
                            }
                          ],
                          "rule": [
                            {
                              "name": "codeSystem",
                              "source": [
                                {
                                  "context": "qr"
                                }
                              ],
                              "target": [
                                {
                                  "context": "coding",
                                  "element": "system",
                                  "transform": "copy",
                                  "parameter": [
                                    {
                                      "valueString": "http://loinc.org"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name": "codeCode",
                              "source": [
                                {
                                  "context": "qr"
                                }
                              ],
                              "target": [
                                {
                                  "context": "coding",
                                  "element": "code",
                                  "transform": "copy",
                                  "parameter": [
                                    {
                                      "valueString": "107117-4"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name": "codeDisplay",
                              "source": [
                                {
                                  "context": "qr"
                                }
                              ],
                              "target": [
                                {
                                  "context": "coding",
                                  "element": "display",
                                  "transform": "copy",
                                  "parameter": [
                                    {
                                      "valueString": "Method of oxygen delivery"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name": "oxygenValue",
                      "source": [
                        {
                          "context": "aO"
                        }
                      ],
                      "target": [
                        {
                          "context": "obsO"
                        }
                      ],
                      "dependent": [
                        {
                          "name": "SetCodedValue",
                          "parameter": [
                            {
                              "valueId": "aO"
                            },
                            {
                              "valueId": "obsO"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ],
          "documentation": "── Oxygen support ─────────────────────────────────────────────────────────\r\nCategory `therapy`: this records a treatment being delivered, not a\r\nmeasurement taken."
        },
        {
          "name": "organSupportRule",
          "source": [
            {
              "context": "qr",
              "element": "item",
              "variable": "itS",
              "condition": "(linkId = 'organSupport') and answer.value.exists()"
            }
          ],
          "rule": [
            {
              "name": "organSupportAnswer",
              "source": [
                {
                  "context": "itS",
                  "element": "answer",
                  "listMode": "first",
                  "variable": "aS"
                }
              ],
              "rule": [
                {
                  "name": "organSupportObservation",
                  "source": [
                    {
                      "context": "aS"
                    }
                  ],
                  "target": [
                    {
                      "context": "bundle",
                      "element": "entry",
                      "variable": "entryS"
                    },
                    {
                      "context": "entryS",
                      "element": "resource",
                      "variable": "obsS",
                      "transform": "create",
                      "parameter": [
                        {
                          "valueString": "Observation"
                        }
                      ]
                    }
                  ],
                  "rule": [
                    {
                      "name": "organSupportBase",
                      "source": [
                        {
                          "context": "qr"
                        }
                      ],
                      "target": [
                        {
                          "context": "obsS"
                        },
                        {
                          "context": "entryS"
                        }
                      ],
                      "dependent": [
                        {
                          "name": "BuildObsBase",
                          "parameter": [
                            {
                              "valueId": "qr"
                            },
                            {
                              "valueId": "obsS"
                            },
                            {
                              "valueId": "entryS"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name": "organSupportCategory",
                      "source": [
                        {
                          "context": "qr"
                        }
                      ],
                      "target": [
                        {
                          "context": "obsS"
                        }
                      ],
                      "dependent": [
                        {
                          "name": "SetTherapyCategory",
                          "parameter": [
                            {
                              "valueId": "qr"
                            },
                            {
                              "valueId": "obsS"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name": "organSupportCode",
                      "source": [
                        {
                          "context": "qr"
                        }
                      ],
                      "target": [
                        {
                          "context": "obsS",
                          "element": "code",
                          "variable": "code"
                        }
                      ],
                      "rule": [
                        {
                          "name": "codeCoding",
                          "source": [
                            {
                              "context": "qr"
                            }
                          ],
                          "target": [
                            {
                              "context": "code",
                              "element": "coding",
                              "variable": "coding"
                            }
                          ],
                          "rule": [
                            {
                              "name": "codeSystem",
                              "source": [
                                {
                                  "context": "qr"
                                }
                              ],
                              "target": [
                                {
                                  "context": "coding",
                                  "element": "system",
                                  "transform": "copy",
                                  "parameter": [
                                    {
                                      "valueString": "https://fhir.slade360.co.ke/fhir/CodeSystem/inpatient-clinical-concept-codesystem"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name": "codeCode",
                              "source": [
                                {
                                  "context": "qr"
                                }
                              ],
                              "target": [
                                {
                                  "context": "coding",
                                  "element": "code",
                                  "transform": "copy",
                                  "parameter": [
                                    {
                                      "valueString": "organ-support"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name": "codeDisplay",
                              "source": [
                                {
                                  "context": "qr"
                                }
                              ],
                              "target": [
                                {
                                  "context": "coding",
                                  "element": "display",
                                  "transform": "copy",
                                  "parameter": [
                                    {
                                      "valueString": "Organ support needed"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "codeText",
                          "source": [
                            {
                              "context": "qr"
                            }
                          ],
                          "target": [
                            {
                              "context": "code",
                              "element": "text",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Organ support needed"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name": "organSupportValue",
                      "source": [
                        {
                          "context": "aS",
                          "element": "value",
                          "variable": "v"
                        }
                      ],
                      "target": [
                        {
                          "context": "obsS",
                          "element": "value",
                          "transform": "copy",
                          "parameter": [
                            {
                              "valueId": "v"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ],
          "documentation": "── Organ support ──────────────────────────────────────────────────────────\r\nLOINC has codes for individual supports but none for the summary the form\r\nasks for, so a local code. See SGHIInpatientClinicalConceptCodeSystem."
        },
        {
          "name": "vasopressorRule",
          "source": [
            {
              "context": "qr",
              "element": "item",
              "variable": "itV",
              "condition": "(linkId = 'vasopressor') and answer.value.exists()"
            }
          ],
          "rule": [
            {
              "name": "vasopressorAnswer",
              "source": [
                {
                  "context": "itV",
                  "element": "answer",
                  "listMode": "first",
                  "variable": "aV"
                }
              ],
              "rule": [
                {
                  "name": "medicationAdministration",
                  "source": [
                    {
                      "context": "aV"
                    }
                  ],
                  "target": [
                    {
                      "context": "bundle",
                      "element": "entry",
                      "variable": "entryV"
                    },
                    {
                      "context": "entryV",
                      "element": "resource",
                      "variable": "ma",
                      "transform": "create",
                      "parameter": [
                        {
                          "valueString": "MedicationAdministration"
                        }
                      ]
                    }
                  ],
                  "rule": [
                    {
                      "name": "idAndFullUrl",
                      "source": [
                        {
                          "context": "qr"
                        }
                      ],
                      "target": [
                        {
                          "context": "ma",
                          "element": "id",
                          "transform": "uuid"
                        }
                      ],
                      "dependent": [
                        {
                          "name": "SetMedicationAdministrationFullUrl",
                          "parameter": [
                            {
                              "valueId": "ma"
                            },
                            {
                              "valueId": "entryV"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name": "entryRequest",
                      "source": [
                        {
                          "context": "qr"
                        }
                      ],
                      "target": [
                        {
                          "context": "entryV",
                          "element": "request",
                          "variable": "request"
                        }
                      ],
                      "rule": [
                        {
                          "name": "requestMethod",
                          "source": [
                            {
                              "context": "qr"
                            }
                          ],
                          "target": [
                            {
                              "context": "request",
                              "element": "method",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "POST"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "requestUrl",
                          "source": [
                            {
                              "context": "qr"
                            }
                          ],
                          "target": [
                            {
                              "context": "request",
                              "element": "url",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "MedicationAdministration"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name": "status",
                      "source": [
                        {
                          "context": "qr"
                        }
                      ],
                      "target": [
                        {
                          "context": "ma",
                          "element": "status",
                          "transform": "copy",
                          "parameter": [
                            {
                              "valueString": "in-progress"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name": "category",
                      "source": [
                        {
                          "context": "qr"
                        }
                      ],
                      "target": [
                        {
                          "context": "ma",
                          "element": "category",
                          "variable": "cat"
                        }
                      ],
                      "rule": [
                        {
                          "name": "categoryCoding",
                          "source": [
                            {
                              "context": "qr"
                            }
                          ],
                          "target": [
                            {
                              "context": "cat",
                              "element": "coding",
                              "variable": "coding"
                            }
                          ],
                          "rule": [
                            {
                              "name": "categorySystem",
                              "source": [
                                {
                                  "context": "qr"
                                }
                              ],
                              "target": [
                                {
                                  "context": "coding",
                                  "element": "system",
                                  "transform": "copy",
                                  "parameter": [
                                    {
                                      "valueString": "http://terminology.hl7.org/CodeSystem/medication-admin-location"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name": "categoryCode",
                              "source": [
                                {
                                  "context": "qr"
                                }
                              ],
                              "target": [
                                {
                                  "context": "coding",
                                  "element": "code",
                                  "transform": "copy",
                                  "parameter": [
                                    {
                                      "valueString": "inpatient"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name": "categoryDisplay",
                              "source": [
                                {
                                  "context": "qr"
                                }
                              ],
                              "target": [
                                {
                                  "context": "coding",
                                  "element": "display",
                                  "transform": "copy",
                                  "parameter": [
                                    {
                                      "valueString": "Inpatient"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name": "medication",
                      "source": [
                        {
                          "context": "aV",
                          "element": "value",
                          "variable": "v"
                        }
                      ],
                      "target": [
                        {
                          "context": "ma",
                          "element": "medication",
                          "variable": "medRef"
                        }
                      ],
                      "rule": [
                        {
                          "name": "medicationConcept",
                          "source": [
                            {
                              "context": "v"
                            }
                          ],
                          "target": [
                            {
                              "context": "medRef",
                              "element": "concept",
                              "variable": "concept"
                            }
                          ],
                          "rule": [
                            {
                              "name": "medicationText",
                              "source": [
                                {
                                  "context": "v"
                                }
                              ],
                              "target": [
                                {
                                  "context": "concept",
                                  "element": "text",
                                  "transform": "copy",
                                  "parameter": [
                                    {
                                      "valueId": "v"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name": "subject",
                      "source": [
                        {
                          "context": "qr",
                          "element": "subject",
                          "variable": "s"
                        }
                      ],
                      "target": [
                        {
                          "context": "ma",
                          "element": "subject",
                          "transform": "copy",
                          "parameter": [
                            {
                              "valueId": "s"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name": "encounter",
                      "source": [
                        {
                          "context": "qr",
                          "element": "encounter",
                          "variable": "e"
                        }
                      ],
                      "target": [
                        {
                          "context": "ma",
                          "element": "encounter",
                          "transform": "copy",
                          "parameter": [
                            {
                              "valueId": "e"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name": "occurrence",
                      "source": [
                        {
                          "context": "qr",
                          "element": "authored",
                          "variable": "t"
                        }
                      ],
                      "target": [
                        {
                          "context": "ma",
                          "element": "occurence",
                          "transform": "copy",
                          "parameter": [
                            {
                              "valueId": "t"
                            }
                          ]
                        }
                      ],
                      "documentation": "R5 spells this element `occurence[x]`. That is the specification's own\r\ntypo, not one here."
                    },
                    {
                      "name": "recorded",
                      "source": [
                        {
                          "context": "qr",
                          "element": "authored",
                          "variable": "t"
                        }
                      ],
                      "target": [
                        {
                          "context": "ma",
                          "element": "recorded",
                          "transform": "copy",
                          "parameter": [
                            {
                              "valueId": "t"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name": "linkQuestionnaireResponse",
                      "source": [
                        {
                          "context": "qr"
                        }
                      ],
                      "target": [
                        {
                          "context": "ma",
                          "element": "supportingInformation",
                          "variable": "ref",
                          "transform": "create",
                          "parameter": [
                            {
                              "valueString": "Reference"
                            }
                          ]
                        }
                      ],
                      "rule": [
                        {
                          "name": "supportingInformationRef",
                          "source": [
                            {
                              "context": "qr",
                              "element": "id",
                              "variable": "qid"
                            }
                          ],
                          "target": [
                            {
                              "context": "ref",
                              "element": "reference",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueId": "qid"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ],
          "documentation": "── Vasopressor ────────────────────────────────────────────────────────────\r\nThe form captures a dose description (\"Noradrenaline 0.1 mcg/kg/min\"), not\r\na medication reference, so the wording lands in medication.concept.text\r\nrather than being matched against a drug dictionary. Status is\r\n`in-progress`: the assessment records an infusion running at the moment it\r\nwas written, and `completed` would assert it had finished, which is not\r\nwhat the nurse wrote."
        }
      ]
    },
    {
      "name": "BuildObsBase",
      "documentation": "─────────────────────────────────────────────────────────────────────────────\r\nShared scaffolding. Repeated in each map rather than imported: the transform\r\nengine resolves `imports` against whatever StructureMaps happen to be on the\r\nserver, and a form that stops extracting because a shared map was not\r\nuploaded is a worse failure than a duplicated group.\r\n─────────────────────────────────────────────────────────────────────────────\r\nTwo notes on what the publisher's StructureMap validator says about this file.\r\nSource parameters below are left untyped on purpose. Writing `: Element` makes\r\nthe validator compare QuestionnaireResponse.item against the literal 'Element'\r\nand report them as incompatible with each other, which is noise, not a finding.\r\nUntyped, it says only that it cannot check the paths.\r\n`evaluate(context, expression)` is flagged as \"takes 1 parameter but 2 were\r\nfound\". Leave it. The FML parser in the same jar refuses the one-argument form\r\noutright -- it wants a parameter, a comma, then the FHIRPath -- so the publisher\r\nis objecting to what its own compiler emits. Two arguments is the only form that\r\ncompiles, and it is what the R5 transform engine executes.",
      "input": [
        {
          "name": "qr",
          "type": "QR",
          "mode": "source"
        },
        {
          "name": "obs",
          "type": "Observation",
          "mode": "target"
        },
        {
          "name": "entry",
          "mode": "target"
        }
      ],
      "rule": [
        {
          "name": "idAndFullUrl",
          "source": [
            {
              "context": "qr"
            }
          ],
          "target": [
            {
              "context": "obs",
              "element": "id",
              "transform": "uuid"
            }
          ],
          "dependent": [
            {
              "name": "SetObservationFullUrl",
              "parameter": [
                {
                  "valueId": "obs"
                },
                {
                  "valueId": "entry"
                }
              ]
            }
          ]
        },
        {
          "name": "entryRequest",
          "source": [
            {
              "context": "qr"
            }
          ],
          "target": [
            {
              "context": "entry",
              "element": "request",
              "variable": "request"
            }
          ],
          "rule": [
            {
              "name": "requestMethod",
              "source": [
                {
                  "context": "qr"
                }
              ],
              "target": [
                {
                  "context": "request",
                  "element": "method",
                  "transform": "copy",
                  "parameter": [
                    {
                      "valueString": "POST"
                    }
                  ]
                }
              ]
            },
            {
              "name": "requestUrl",
              "source": [
                {
                  "context": "qr"
                }
              ],
              "target": [
                {
                  "context": "request",
                  "element": "url",
                  "transform": "copy",
                  "parameter": [
                    {
                      "valueString": "Observation"
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name": "status",
          "source": [
            {
              "context": "qr"
            }
          ],
          "target": [
            {
              "context": "obs",
              "element": "status",
              "transform": "copy",
              "parameter": [
                {
                  "valueString": "final"
                }
              ]
            }
          ]
        },
        {
          "name": "subject",
          "source": [
            {
              "context": "qr",
              "element": "subject",
              "variable": "s"
            }
          ],
          "target": [
            {
              "context": "obs",
              "element": "subject",
              "transform": "copy",
              "parameter": [
                {
                  "valueId": "s"
                }
              ]
            }
          ]
        },
        {
          "name": "encounter",
          "source": [
            {
              "context": "qr",
              "element": "encounter",
              "variable": "e"
            }
          ],
          "target": [
            {
              "context": "obs",
              "element": "encounter",
              "transform": "copy",
              "parameter": [
                {
                  "valueId": "e"
                }
              ]
            }
          ]
        },
        {
          "name": "effective",
          "source": [
            {
              "context": "qr",
              "element": "authored",
              "variable": "t"
            }
          ],
          "target": [
            {
              "context": "obs",
              "element": "effective",
              "transform": "copy",
              "parameter": [
                {
                  "valueId": "t"
                }
              ]
            }
          ]
        },
        {
          "name": "performerFromSource",
          "source": [
            {
              "context": "qr",
              "element": "source",
              "variable": "src"
            }
          ],
          "target": [
            {
              "context": "obs",
              "element": "performer",
              "transform": "copy",
              "parameter": [
                {
                  "valueId": "src"
                }
              ]
            }
          ]
        },
        {
          "name": "performerFallback",
          "source": [
            {
              "context": "qr",
              "condition": "source.exists().not()"
            }
          ],
          "rule": [
            {
              "name": "performerFromAuthor",
              "source": [
                {
                  "context": "qr",
                  "element": "author",
                  "variable": "a"
                }
              ],
              "target": [
                {
                  "context": "obs",
                  "element": "performer",
                  "transform": "copy",
                  "parameter": [
                    {
                      "valueId": "a"
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name": "linkQuestionnaireResponse",
          "source": [
            {
              "context": "qr"
            }
          ],
          "target": [
            {
              "context": "obs",
              "element": "derivedFrom",
              "variable": "ref",
              "transform": "create",
              "parameter": [
                {
                  "valueString": "Reference"
                }
              ]
            }
          ],
          "rule": [
            {
              "name": "derivedFromRef",
              "source": [
                {
                  "context": "qr",
                  "element": "id",
                  "variable": "qid"
                }
              ],
              "target": [
                {
                  "context": "ref",
                  "element": "reference",
                  "transform": "copy",
                  "parameter": [
                    {
                      "valueId": "qid"
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name": "SetCodedValue",
      "input": [
        {
          "name": "a",
          "mode": "source"
        },
        {
          "name": "obs",
          "type": "Observation",
          "mode": "target"
        }
      ],
      "rule": [
        {
          "name": "codedValue",
          "source": [
            {
              "context": "a",
              "element": "value",
              "variable": "cv"
            }
          ],
          "target": [
            {
              "context": "obs",
              "element": "value",
              "variable": "cc",
              "transform": "create",
              "parameter": [
                {
                  "valueString": "CodeableConcept"
                }
              ]
            }
          ],
          "rule": [
            {
              "name": "valueCoding",
              "source": [
                {
                  "context": "cv"
                }
              ],
              "target": [
                {
                  "context": "cc",
                  "element": "coding",
                  "transform": "copy",
                  "parameter": [
                    {
                      "valueId": "cv"
                    }
                  ]
                }
              ]
            },
            {
              "name": "valueText",
              "source": [
                {
                  "context": "cv",
                  "element": "display",
                  "variable": "d"
                }
              ],
              "target": [
                {
                  "context": "cc",
                  "element": "text",
                  "transform": "copy",
                  "parameter": [
                    {
                      "valueId": "d"
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name": "SetComponentCodedValue",
      "input": [
        {
          "name": "it",
          "mode": "source"
        },
        {
          "name": "comp",
          "mode": "target"
        }
      ],
      "rule": [
        {
          "name": "componentAnswer",
          "source": [
            {
              "context": "it",
              "element": "answer",
              "listMode": "first",
              "variable": "a"
            }
          ],
          "rule": [
            {
              "name": "codedValue",
              "source": [
                {
                  "context": "a",
                  "element": "value",
                  "variable": "cv"
                }
              ],
              "target": [
                {
                  "context": "comp",
                  "element": "value",
                  "variable": "cc",
                  "transform": "create",
                  "parameter": [
                    {
                      "valueString": "CodeableConcept"
                    }
                  ]
                }
              ],
              "rule": [
                {
                  "name": "valueCoding",
                  "source": [
                    {
                      "context": "cv"
                    }
                  ],
                  "target": [
                    {
                      "context": "cc",
                      "element": "coding",
                      "transform": "copy",
                      "parameter": [
                        {
                          "valueId": "cv"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "valueText",
                  "source": [
                    {
                      "context": "cv",
                      "element": "display",
                      "variable": "d"
                    }
                  ],
                  "target": [
                    {
                      "context": "cc",
                      "element": "text",
                      "transform": "copy",
                      "parameter": [
                        {
                          "valueId": "d"
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name": "SetSurveyCategory",
      "input": [
        {
          "name": "qr",
          "type": "QR",
          "mode": "source"
        },
        {
          "name": "obs",
          "type": "Observation",
          "mode": "target"
        }
      ],
      "rule": [
        {
          "name": "category",
          "source": [
            {
              "context": "qr"
            }
          ],
          "target": [
            {
              "context": "obs",
              "element": "category",
              "variable": "cat"
            }
          ],
          "rule": [
            {
              "name": "categoryCoding",
              "source": [
                {
                  "context": "qr"
                }
              ],
              "target": [
                {
                  "context": "cat",
                  "element": "coding",
                  "variable": "coding"
                }
              ],
              "rule": [
                {
                  "name": "categorySystem",
                  "source": [
                    {
                      "context": "qr"
                    }
                  ],
                  "target": [
                    {
                      "context": "coding",
                      "element": "system",
                      "transform": "copy",
                      "parameter": [
                        {
                          "valueString": "http://terminology.hl7.org/CodeSystem/observation-category"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "categoryCode",
                  "source": [
                    {
                      "context": "qr"
                    }
                  ],
                  "target": [
                    {
                      "context": "coding",
                      "element": "code",
                      "transform": "copy",
                      "parameter": [
                        {
                          "valueString": "survey"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "categoryDisplay",
                  "source": [
                    {
                      "context": "qr"
                    }
                  ],
                  "target": [
                    {
                      "context": "coding",
                      "element": "display",
                      "transform": "copy",
                      "parameter": [
                        {
                          "valueString": "Survey"
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name": "SetTherapyCategory",
      "input": [
        {
          "name": "qr",
          "type": "QR",
          "mode": "source"
        },
        {
          "name": "obs",
          "type": "Observation",
          "mode": "target"
        }
      ],
      "rule": [
        {
          "name": "category",
          "source": [
            {
              "context": "qr"
            }
          ],
          "target": [
            {
              "context": "obs",
              "element": "category",
              "variable": "cat"
            }
          ],
          "rule": [
            {
              "name": "categoryCoding",
              "source": [
                {
                  "context": "qr"
                }
              ],
              "target": [
                {
                  "context": "cat",
                  "element": "coding",
                  "variable": "coding"
                }
              ],
              "rule": [
                {
                  "name": "categorySystem",
                  "source": [
                    {
                      "context": "qr"
                    }
                  ],
                  "target": [
                    {
                      "context": "coding",
                      "element": "system",
                      "transform": "copy",
                      "parameter": [
                        {
                          "valueString": "http://terminology.hl7.org/CodeSystem/observation-category"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "categoryCode",
                  "source": [
                    {
                      "context": "qr"
                    }
                  ],
                  "target": [
                    {
                      "context": "coding",
                      "element": "code",
                      "transform": "copy",
                      "parameter": [
                        {
                          "valueString": "therapy"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "categoryDisplay",
                  "source": [
                    {
                      "context": "qr"
                    }
                  ],
                  "target": [
                    {
                      "context": "coding",
                      "element": "display",
                      "transform": "copy",
                      "parameter": [
                        {
                          "valueString": "Therapy"
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name": "SetObservationFullUrl",
      "input": [
        {
          "name": "obs",
          "type": "Observation",
          "mode": "source"
        },
        {
          "name": "entry",
          "mode": "target"
        }
      ],
      "rule": [
        {
          "name": "assignFullUrl",
          "source": [
            {
              "context": "obs",
              "element": "id",
              "variable": "id"
            }
          ],
          "target": [
            {
              "context": "entry",
              "element": "fullUrl",
              "transform": "append",
              "parameter": [
                {
                  "valueString": "https://fhir.slade360.co.ke/fhir/Observation/"
                },
                {
                  "valueId": "id"
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name": "SetMedicationAdministrationFullUrl",
      "input": [
        {
          "name": "ma",
          "type": "MedicationAdministration",
          "mode": "source"
        },
        {
          "name": "entry",
          "mode": "target"
        }
      ],
      "rule": [
        {
          "name": "assignFullUrl",
          "source": [
            {
              "context": "ma",
              "element": "id",
              "variable": "id"
            }
          ],
          "target": [
            {
              "context": "entry",
              "element": "fullUrl",
              "transform": "append",
              "parameter": [
                {
                  "valueString": "https://fhir.slade360.co.ke/fhir/MedicationAdministration/"
                },
                {
                  "valueId": "id"
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}