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

FHIR IG analytics

Packagesilfhirprofileig
Resource TypeStructureMap
IdStructureMap-ExtractInpatientPaediatricAdmissionAssessment.json
FHIR VersionR5
Sourcehttps://build.fhir.org/ig/savannahghi/sil_fhir_profile_ig/StructureMap-ExtractInpatientPaediatricAdmissionAssessment.html
URLhttps://fhir.slade360.co.ke/fhir/StructureMap/ExtractInpatientPaediatricAdmissionAssessment
Version0.1.0
Statusactive
Date2026-09-11T12:18:36+00:00
NameExtractInpatientPaediatricAdmissionAssessment
TitleInpatient Paediatric Admission Assessment Extraction
DescriptionWeight, immunisation status and feeding become Observations; the guardian at the bedside becomes a RelatedPerson. Immunisation status is an Observation rather than an Immunization because the form records what the guardian says, not a dose given with a vaccine, a date and a batch -- an Immunization built from `Partially immunised` would be a fiction. The guardian is a new RelatedPerson rather than a patch to Patient.contact: repeated assessments would append a duplicate contact each time with nothing to deduplicate on, and moh-510-extractor already mints guardian RelatedPersons this way.

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 ExtractInpatientPaediatricAdmissionAssessment

/// url = 'https://fhir.slade360.co.ke/fhir/StructureMap/ExtractInpatientPaediatricAdmissionAssessment'
/// name = 'ExtractInpatientPaediatricAdmissionAssessment'
/// title = 'Inpatient Paediatric Admission Assessment Extraction'
/// status = 'active'
/// description = 'Weight, immunisation status and feeding become Observations; the guardian at the bedside becomes a RelatedPerson. Immunisation status is an Observation rather than an Immunization because the form records what the guardian says, not a dose given with a vaccine, a date and a batch -- an Immunization built from `Partially immunised` would be a fiction. The guardian is a new RelatedPerson rather than a patch to Patient.contact: repeated assessments would append a duplicate contact each time with nothing to deduplicate on, and moh-510-extractor already mints guardian RelatedPersons this way.'

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/RelatedPerson" alias RelatedPerson as target

group ExtractInpatientPaediatricAdmissionAssessment(source qr : QR, target bundle : Bundle) {
  qr -> bundle.type = 'transaction' "setBundleType";
  qr.item as itW where ((linkId = 'weight') and answer.value.exists()) then {
    itW.answer first as aW then {
      aW ->  bundle.entry as entryW,  entryW.resource = create('Observation') as obsW then {
        qr ->  obsW,  entryW then BuildObsBase(qr, obsW, entryW) "weightBase";
        qr -> obsW then SetVitalSignsCategory(qr, obsW) "weightCategory";
        qr -> obsW.code as code then {
          qr -> code.coding as coding then {
            qr -> coding.system = 'http://loinc.org' "codeSystem";
            qr -> coding.code = '29463-7' "codeCode";
            qr -> coding.display = 'Body weight' "codeDisplay";
          } "codeCoding";
        } "weightCode";
        // Already a Quantity: the item is type `quantity` with a unitOption
        // pinning kg.
        aW.value as v -> obsW.value = v "weightValue";
      } "weightObservation";
    } "weightAnswer";
  } "weightRule";
  qr.item as itI where ((linkId = 'immunisation') and answer.value.exists()) then {
    itI.answer first as aI then {
      aI ->  bundle.entry as entryI,  entryI.resource = create('Observation') as obsI then {
        qr ->  obsI,  entryI then BuildObsBase(qr, obsI, entryI) "immunisationBase";
        qr -> obsI then SetSocialHistoryCategory(qr, obsI) "immunisationCategory";
        qr -> obsI.code as code then {
          qr -> code.coding as coding then {
            qr -> coding.system = 'http://loinc.org' "codeSystem";
            qr -> coding.code = '11370-4' "codeCode";
            qr -> coding.display = 'Immunization status - Reported' "codeDisplay";
          } "codeCoding";
        } "immunisationCode";
        aI -> obsI then SetCodedValue(aI, obsI) "immunisationValue";
      } "immunisationObservation";
    } "immunisationAnswer";
  } "immunisationRule";
  qr.item as itF where ((linkId = 'feeding') and answer.value.exists()) then {
    itF.answer first as aF then {
      aF ->  bundle.entry as entryF,  entryF.resource = create('Observation') as obsF then {
        qr ->  obsF,  entryF then BuildObsBase(qr, obsF, entryF) "feedingBase";
        qr -> obsF then SetSocialHistoryCategory(qr, obsF) "feedingCategory";
        // No LOINC concept for a free-text account of how a child is fed, so a
        // local code. See SGHIInpatientClinicalConceptCodeSystem.
        qr -> obsF.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 = 'feeding' "codeCode";
            qr -> coding.display = 'Feeding' "codeDisplay";
          } "codeCoding";
          qr -> code.text = 'Feeding' "codeText";
        } "feedingCode";
        aF.value as v -> obsF.value = v "feedingValue";
      } "feedingObservation";
    } "feedingAnswer";
  } "feedingRule";
  // ── Guardian ───────────────────────────────────────────────────────────────
  // RelatedPerson has no element that points back at the response it came from,
  // so this resource is the one thing the map emits with no link home. A
  // Provenance would carry it, but that is a wider change than this form.
  qr.item as itG where ((linkId = 'guardianName') and answer.value.exists()) then {
    itG.answer first as aG then {
      aG ->  bundle.entry as entryG,  entryG.resource = create('RelatedPerson') as rp then {
        qr -> rp.id = uuid() then SetRelatedPersonFullUrl(rp, entryG) "idAndFullUrl";
        qr -> entryG.request as request then {
          qr -> request.method = 'POST' "requestMethod";
          qr -> request.url = 'RelatedPerson' "requestUrl";
        } "entryRequest";
        qr -> rp.active = true "active";
        qr.subject as s -> rp.patient = s "patient";
        aG.value as v -> rp.name as name then {
          v -> name.text = v "nameText";
        } "guardianName";
        // The relationship is written as the guardian described it on the day.
        // v3-RoleCode has concepts for mother and father, but the form accepts
        // anything from "Aunt" to "Neighbour", so matching free text against a
        // code system here would guess.
        qr.item as itR where ((linkId = 'guardianRel') and answer.value.exists()) then {
          itR.answer first as aR then {
            aR.value as rv -> rp.relationship as rel then {
              rv -> rel.text = rv "relationshipText";
            } "guardianRelationship";
          } "guardianRelAnswer";
        } "guardianRelRule";
      } "relatedPerson";
    } "guardianNameAnswer";
  } "guardianRule";
}

// ─────────────────────────────────────────────────────────────────────────────
// 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.
// ─────────────────────────────────────────────────────────────────────────────
// Source parameters are left untyped on purpose. Writing `: Element` makes the
// publisher's StructureMap 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.
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";
}

// A coded answer becomes the Observation's value, coding and display intact, so
// the record says both what was picked and how it read on screen.
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 SetVitalSignsCategory(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 = 'vital-signs' "categoryCode";
      qr -> coding.display = 'Vital Signs' "categoryDisplay";
    } "categoryCoding";
  } "category";
}

group SetSocialHistoryCategory(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 = 'social-history' "categoryCode";
      qr -> coding.display = 'Social History' "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 SetRelatedPersonFullUrl(source rp : RelatedPerson, target entry) {
  rp.id as id -> entry.fullUrl = append('https://fhir.slade360.co.ke/fhir/RelatedPerson/', id) "assignFullUrl";
}


Source1

{
  "resourceType": "StructureMap",
  "id": "ExtractInpatientPaediatricAdmissionAssessment",
  "text": {
    "status": "generated",
    "div": "<!-- snip (see above) -->"
  },
  "url": "https://fhir.slade360.co.ke/fhir/StructureMap/ExtractInpatientPaediatricAdmissionAssessment",
  "version": "0.1.0",
  "name": "ExtractInpatientPaediatricAdmissionAssessment",
  "title": "Inpatient Paediatric Admission 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": "Weight, immunisation status and feeding become Observations; the guardian at the bedside becomes a RelatedPerson. Immunisation status is an Observation rather than an Immunization because the form records what the guardian says, not a dose given with a vaccine, a date and a batch -- an Immunization built from `Partially immunised` would be a fiction. The guardian is a new RelatedPerson rather than a patch to Patient.contact: repeated assessments would append a duplicate contact each time with nothing to deduplicate on, and moh-510-extractor already mints guardian RelatedPersons this way.",
  "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/RelatedPerson",
      "mode": "target",
      "alias": "RelatedPerson"
    }
  ],
  "group": [
    {
      "name": "ExtractInpatientPaediatricAdmissionAssessment",
      "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": "weightRule",
          "source": [
            {
              "context": "qr",
              "element": "item",
              "variable": "itW",
              "condition": "(linkId = 'weight') and answer.value.exists()"
            }
          ],
          "rule": [
            {
              "name": "weightAnswer",
              "source": [
                {
                  "context": "itW",
                  "element": "answer",
                  "listMode": "first",
                  "variable": "aW"
                }
              ],
              "rule": [
                {
                  "name": "weightObservation",
                  "source": [
                    {
                      "context": "aW"
                    }
                  ],
                  "target": [
                    {
                      "context": "bundle",
                      "element": "entry",
                      "variable": "entryW"
                    },
                    {
                      "context": "entryW",
                      "element": "resource",
                      "variable": "obsW",
                      "transform": "create",
                      "parameter": [
                        {
                          "valueString": "Observation"
                        }
                      ]
                    }
                  ],
                  "rule": [
                    {
                      "name": "weightBase",
                      "source": [
                        {
                          "context": "qr"
                        }
                      ],
                      "target": [
                        {
                          "context": "obsW"
                        },
                        {
                          "context": "entryW"
                        }
                      ],
                      "dependent": [
                        {
                          "name": "BuildObsBase",
                          "parameter": [
                            {
                              "valueId": "qr"
                            },
                            {
                              "valueId": "obsW"
                            },
                            {
                              "valueId": "entryW"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name": "weightCategory",
                      "source": [
                        {
                          "context": "qr"
                        }
                      ],
                      "target": [
                        {
                          "context": "obsW"
                        }
                      ],
                      "dependent": [
                        {
                          "name": "SetVitalSignsCategory",
                          "parameter": [
                            {
                              "valueId": "qr"
                            },
                            {
                              "valueId": "obsW"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name": "weightCode",
                      "source": [
                        {
                          "context": "qr"
                        }
                      ],
                      "target": [
                        {
                          "context": "obsW",
                          "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": "29463-7"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name": "codeDisplay",
                              "source": [
                                {
                                  "context": "qr"
                                }
                              ],
                              "target": [
                                {
                                  "context": "coding",
                                  "element": "display",
                                  "transform": "copy",
                                  "parameter": [
                                    {
                                      "valueString": "Body weight"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name": "weightValue",
                      "source": [
                        {
                          "context": "aW",
                          "element": "value",
                          "variable": "v"
                        }
                      ],
                      "target": [
                        {
                          "context": "obsW",
                          "element": "value",
                          "transform": "copy",
                          "parameter": [
                            {
                              "valueId": "v"
                            }
                          ]
                        }
                      ],
                      "documentation": "Already a Quantity: the item is type `quantity` with a unitOption\r\npinning kg."
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name": "immunisationRule",
          "source": [
            {
              "context": "qr",
              "element": "item",
              "variable": "itI",
              "condition": "(linkId = 'immunisation') and answer.value.exists()"
            }
          ],
          "rule": [
            {
              "name": "immunisationAnswer",
              "source": [
                {
                  "context": "itI",
                  "element": "answer",
                  "listMode": "first",
                  "variable": "aI"
                }
              ],
              "rule": [
                {
                  "name": "immunisationObservation",
                  "source": [
                    {
                      "context": "aI"
                    }
                  ],
                  "target": [
                    {
                      "context": "bundle",
                      "element": "entry",
                      "variable": "entryI"
                    },
                    {
                      "context": "entryI",
                      "element": "resource",
                      "variable": "obsI",
                      "transform": "create",
                      "parameter": [
                        {
                          "valueString": "Observation"
                        }
                      ]
                    }
                  ],
                  "rule": [
                    {
                      "name": "immunisationBase",
                      "source": [
                        {
                          "context": "qr"
                        }
                      ],
                      "target": [
                        {
                          "context": "obsI"
                        },
                        {
                          "context": "entryI"
                        }
                      ],
                      "dependent": [
                        {
                          "name": "BuildObsBase",
                          "parameter": [
                            {
                              "valueId": "qr"
                            },
                            {
                              "valueId": "obsI"
                            },
                            {
                              "valueId": "entryI"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name": "immunisationCategory",
                      "source": [
                        {
                          "context": "qr"
                        }
                      ],
                      "target": [
                        {
                          "context": "obsI"
                        }
                      ],
                      "dependent": [
                        {
                          "name": "SetSocialHistoryCategory",
                          "parameter": [
                            {
                              "valueId": "qr"
                            },
                            {
                              "valueId": "obsI"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name": "immunisationCode",
                      "source": [
                        {
                          "context": "qr"
                        }
                      ],
                      "target": [
                        {
                          "context": "obsI",
                          "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": "11370-4"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name": "codeDisplay",
                              "source": [
                                {
                                  "context": "qr"
                                }
                              ],
                              "target": [
                                {
                                  "context": "coding",
                                  "element": "display",
                                  "transform": "copy",
                                  "parameter": [
                                    {
                                      "valueString": "Immunization status - Reported"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name": "immunisationValue",
                      "source": [
                        {
                          "context": "aI"
                        }
                      ],
                      "target": [
                        {
                          "context": "obsI"
                        }
                      ],
                      "dependent": [
                        {
                          "name": "SetCodedValue",
                          "parameter": [
                            {
                              "valueId": "aI"
                            },
                            {
                              "valueId": "obsI"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name": "feedingRule",
          "source": [
            {
              "context": "qr",
              "element": "item",
              "variable": "itF",
              "condition": "(linkId = 'feeding') and answer.value.exists()"
            }
          ],
          "rule": [
            {
              "name": "feedingAnswer",
              "source": [
                {
                  "context": "itF",
                  "element": "answer",
                  "listMode": "first",
                  "variable": "aF"
                }
              ],
              "rule": [
                {
                  "name": "feedingObservation",
                  "source": [
                    {
                      "context": "aF"
                    }
                  ],
                  "target": [
                    {
                      "context": "bundle",
                      "element": "entry",
                      "variable": "entryF"
                    },
                    {
                      "context": "entryF",
                      "element": "resource",
                      "variable": "obsF",
                      "transform": "create",
                      "parameter": [
                        {
                          "valueString": "Observation"
                        }
                      ]
                    }
                  ],
                  "rule": [
                    {
                      "name": "feedingBase",
                      "source": [
                        {
                          "context": "qr"
                        }
                      ],
                      "target": [
                        {
                          "context": "obsF"
                        },
                        {
                          "context": "entryF"
                        }
                      ],
                      "dependent": [
                        {
                          "name": "BuildObsBase",
                          "parameter": [
                            {
                              "valueId": "qr"
                            },
                            {
                              "valueId": "obsF"
                            },
                            {
                              "valueId": "entryF"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name": "feedingCategory",
                      "source": [
                        {
                          "context": "qr"
                        }
                      ],
                      "target": [
                        {
                          "context": "obsF"
                        }
                      ],
                      "dependent": [
                        {
                          "name": "SetSocialHistoryCategory",
                          "parameter": [
                            {
                              "valueId": "qr"
                            },
                            {
                              "valueId": "obsF"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name": "feedingCode",
                      "source": [
                        {
                          "context": "qr"
                        }
                      ],
                      "target": [
                        {
                          "context": "obsF",
                          "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": "feeding"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name": "codeDisplay",
                              "source": [
                                {
                                  "context": "qr"
                                }
                              ],
                              "target": [
                                {
                                  "context": "coding",
                                  "element": "display",
                                  "transform": "copy",
                                  "parameter": [
                                    {
                                      "valueString": "Feeding"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "codeText",
                          "source": [
                            {
                              "context": "qr"
                            }
                          ],
                          "target": [
                            {
                              "context": "code",
                              "element": "text",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Feeding"
                                }
                              ]
                            }
                          ]
                        }
                      ],
                      "documentation": "No LOINC concept for a free-text account of how a child is fed, so a\r\nlocal code. See SGHIInpatientClinicalConceptCodeSystem."
                    },
                    {
                      "name": "feedingValue",
                      "source": [
                        {
                          "context": "aF",
                          "element": "value",
                          "variable": "v"
                        }
                      ],
                      "target": [
                        {
                          "context": "obsF",
                          "element": "value",
                          "transform": "copy",
                          "parameter": [
                            {
                              "valueId": "v"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name": "guardianRule",
          "source": [
            {
              "context": "qr",
              "element": "item",
              "variable": "itG",
              "condition": "(linkId = 'guardianName') and answer.value.exists()"
            }
          ],
          "rule": [
            {
              "name": "guardianNameAnswer",
              "source": [
                {
                  "context": "itG",
                  "element": "answer",
                  "listMode": "first",
                  "variable": "aG"
                }
              ],
              "rule": [
                {
                  "name": "relatedPerson",
                  "source": [
                    {
                      "context": "aG"
                    }
                  ],
                  "target": [
                    {
                      "context": "bundle",
                      "element": "entry",
                      "variable": "entryG"
                    },
                    {
                      "context": "entryG",
                      "element": "resource",
                      "variable": "rp",
                      "transform": "create",
                      "parameter": [
                        {
                          "valueString": "RelatedPerson"
                        }
                      ]
                    }
                  ],
                  "rule": [
                    {
                      "name": "idAndFullUrl",
                      "source": [
                        {
                          "context": "qr"
                        }
                      ],
                      "target": [
                        {
                          "context": "rp",
                          "element": "id",
                          "transform": "uuid"
                        }
                      ],
                      "dependent": [
                        {
                          "name": "SetRelatedPersonFullUrl",
                          "parameter": [
                            {
                              "valueId": "rp"
                            },
                            {
                              "valueId": "entryG"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name": "entryRequest",
                      "source": [
                        {
                          "context": "qr"
                        }
                      ],
                      "target": [
                        {
                          "context": "entryG",
                          "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": "RelatedPerson"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name": "active",
                      "source": [
                        {
                          "context": "qr"
                        }
                      ],
                      "target": [
                        {
                          "context": "rp",
                          "element": "active",
                          "transform": "copy",
                          "parameter": [
                            {
                              "valueBoolean": true
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name": "patient",
                      "source": [
                        {
                          "context": "qr",
                          "element": "subject",
                          "variable": "s"
                        }
                      ],
                      "target": [
                        {
                          "context": "rp",
                          "element": "patient",
                          "transform": "copy",
                          "parameter": [
                            {
                              "valueId": "s"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name": "guardianName",
                      "source": [
                        {
                          "context": "aG",
                          "element": "value",
                          "variable": "v"
                        }
                      ],
                      "target": [
                        {
                          "context": "rp",
                          "element": "name",
                          "variable": "name"
                        }
                      ],
                      "rule": [
                        {
                          "name": "nameText",
                          "source": [
                            {
                              "context": "v"
                            }
                          ],
                          "target": [
                            {
                              "context": "name",
                              "element": "text",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueId": "v"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name": "guardianRelRule",
                      "source": [
                        {
                          "context": "qr",
                          "element": "item",
                          "variable": "itR",
                          "condition": "(linkId = 'guardianRel') and answer.value.exists()"
                        }
                      ],
                      "rule": [
                        {
                          "name": "guardianRelAnswer",
                          "source": [
                            {
                              "context": "itR",
                              "element": "answer",
                              "listMode": "first",
                              "variable": "aR"
                            }
                          ],
                          "rule": [
                            {
                              "name": "guardianRelationship",
                              "source": [
                                {
                                  "context": "aR",
                                  "element": "value",
                                  "variable": "rv"
                                }
                              ],
                              "target": [
                                {
                                  "context": "rp",
                                  "element": "relationship",
                                  "variable": "rel"
                                }
                              ],
                              "rule": [
                                {
                                  "name": "relationshipText",
                                  "source": [
                                    {
                                      "context": "rv"
                                    }
                                  ],
                                  "target": [
                                    {
                                      "context": "rel",
                                      "element": "text",
                                      "transform": "copy",
                                      "parameter": [
                                        {
                                          "valueId": "rv"
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ],
                      "documentation": "The relationship is written as the guardian described it on the day.\r\nv3-RoleCode has concepts for mother and father, but the form accepts\r\nanything from \"Aunt\" to \"Neighbour\", so matching free text against a\r\ncode system here would guess."
                    }
                  ]
                }
              ]
            }
          ],
          "documentation": "── Guardian ───────────────────────────────────────────────────────────────\r\nRelatedPerson has no element that points back at the response it came from,\r\nso this resource is the one thing the map emits with no link home. A\r\nProvenance would carry it, but that is a wider change than this form."
        }
      ]
    },
    {
      "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\nSource parameters are left untyped on purpose. Writing `: Element` makes the\r\npublisher's StructureMap validator compare QuestionnaireResponse.item against\r\nthe literal 'Element' and report them as incompatible with each other, which is\r\nnoise, not a finding. Untyped, it says only that it cannot check the paths.",
      "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",
      "documentation": "A coded answer becomes the Observation's value, coding and display intact, so\r\nthe record says both what was picked and how it read on screen.",
      "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": "SetVitalSignsCategory",
      "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": "vital-signs"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "categoryDisplay",
                  "source": [
                    {
                      "context": "qr"
                    }
                  ],
                  "target": [
                    {
                      "context": "coding",
                      "element": "display",
                      "transform": "copy",
                      "parameter": [
                        {
                          "valueString": "Vital Signs"
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name": "SetSocialHistoryCategory",
      "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": "social-history"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "categoryDisplay",
                  "source": [
                    {
                      "context": "qr"
                    }
                  ],
                  "target": [
                    {
                      "context": "coding",
                      "element": "display",
                      "transform": "copy",
                      "parameter": [
                        {
                          "valueString": "Social History"
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "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": "SetRelatedPersonFullUrl",
      "input": [
        {
          "name": "rp",
          "type": "RelatedPerson",
          "mode": "source"
        },
        {
          "name": "entry",
          "mode": "target"
        }
      ],
      "rule": [
        {
          "name": "assignFullUrl",
          "source": [
            {
              "context": "rp",
              "element": "id",
              "variable": "id"
            }
          ],
          "target": [
            {
              "context": "entry",
              "element": "fullUrl",
              "transform": "append",
              "parameter": [
                {
                  "valueString": "https://fhir.slade360.co.ke/fhir/RelatedPerson/"
                },
                {
                  "valueId": "id"
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}