FHIR IG analytics| Package | silfhirprofileig |
| Resource Type | StructureMap |
| Id | StructureMap-ExtractInpatientAdultGeneralAdmissionAssessment.json |
| FHIR Version | R5 |
| Source | https://build.fhir.org/ig/savannahghi/sil_fhir_profile_ig/StructureMap-ExtractInpatientAdultGeneralAdmissionAssessment.html |
| URL | https://fhir.slade360.co.ke/fhir/StructureMap/ExtractInpatientAdultGeneralAdmissionAssessment |
| Version | 0.1.0 |
| Status | active |
| Date | 2026-09-11T12:18:36+00:00 |
| Name | ExtractInpatientAdultGeneralAdmissionAssessment |
| Title | Inpatient Adult General Admission Assessment Extraction |
| Description | Turns a response to the adult general admission assessment into a chief-complaint Observation, one Observation per vital, and a Composition that files the assessment and carries the allergies and medication the assessor reviewed. Nothing is copied: the allergies and medication are already AllergyIntolerance and MedicationRequest resources -- the form loads them off the server -- so they become section entries. The Composition exists for exactly that reason; without a container those two rows of the assessment extract to nothing at all. |
No resources found
No resources found
Note: links and images are rebased to the (stated) source
Generated Narrative: StructureMap ExtractInpatientAdultGeneralAdmissionAssessment
/// url = 'https://fhir.slade360.co.ke/fhir/StructureMap/ExtractInpatientAdultGeneralAdmissionAssessment' /// name = 'ExtractInpatientAdultGeneralAdmissionAssessment' /// title = 'Inpatient Adult General Admission Assessment Extraction' /// status = 'active' /// description = 'Turns a response to the adult general admission assessment into a chief-complaint Observation, one Observation per vital, and a Composition that files the assessment and carries the allergies and medication the assessor reviewed. Nothing is copied: the allergies and medication are already AllergyIntolerance and MedicationRequest resources -- the form loads them off the server -- so they become section entries. The Composition exists for exactly that reason; without a container those two rows of the assessment extract to nothing at all.' 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/Composition" alias Composition as target group ExtractInpatientAdultGeneralAdmissionAssessment(source qr : QR, target bundle : Bundle) { qr -> bundle.type = 'transaction' "setBundleType"; // ── Presenting complaint ─────────────────────────────────────────────────── // Category `social-history` and code 10154-3 match what extract-vital-signs // already produces for a chief complaint, so a consumer querying // category=social-history&code=10154-3 gets both without knowing which form // the complaint came from. qr.item as itC where ((linkId = 'complaint') and answer.value.exists()) then { itC.answer first as aC then { aC -> bundle.entry as entryC, entryC.resource = create('Observation') as obsC then { qr -> obsC, entryC then BuildObsBase(qr, obsC, entryC) "complaintBase"; qr -> obsC then SetSocialHistoryCategory(qr, obsC) "complaintCategory"; qr -> obsC.code as code then { qr -> code.coding as coding then { qr -> coding.system = 'http://loinc.org' "codeSystem"; qr -> coding.code = '10154-3' "codeCode"; qr -> coding.display = 'Chief complaint Narrative - Reported' "codeDisplay"; } "codeCoding"; } "complaintCode"; aC.value as v -> obsC.value = v "complaintValue"; } "complaintObservation"; } "complaintAnswer"; } "complaintRule"; // ── Vitals on admission ──────────────────────────────────────────────────── // Six items, six Observations, exactly as the form extracted before it had a // map. Each answer is already a Quantity -- the item is type `quantity` with // a questionnaire-unitOption pinning the unit -- so it is copied through // whole. Rebuilding it here would mean restating a unit the client actually // sent, which turns a wrong unit into a wrong reading. qr.item as gV where (linkId = 'vitals') then { gV.item as itS where ((linkId = 'vitals.bpSys') 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) "bpSysBase"; qr -> obsS then SetVitalSignsCategory(qr, obsS) "bpSysCategory"; qr -> obsS.code as code then { qr -> code.coding as coding then { qr -> coding.system = 'http://loinc.org' "codeSystem"; qr -> coding.code = '8480-6' "codeCode"; qr -> coding.display = 'Systolic blood pressure' "codeDisplay"; } "codeCoding"; } "bpSysCode"; aS.value as v -> obsS.value = v "bpSysValue"; } "bpSysObservation"; } "bpSysAnswer"; } "bpSysRule"; gV.item as itD where ((linkId = 'vitals.bpDia') and answer.value.exists()) then { itD.answer first as aD then { aD -> bundle.entry as entryD, entryD.resource = create('Observation') as obsD then { qr -> obsD, entryD then BuildObsBase(qr, obsD, entryD) "bpDiaBase"; qr -> obsD then SetVitalSignsCategory(qr, obsD) "bpDiaCategory"; qr -> obsD.code as code then { qr -> code.coding as coding then { qr -> coding.system = 'http://loinc.org' "codeSystem"; qr -> coding.code = '8462-4' "codeCode"; qr -> coding.display = 'Diastolic blood pressure' "codeDisplay"; } "codeCoding"; } "bpDiaCode"; aD.value as v -> obsD.value = v "bpDiaValue"; } "bpDiaObservation"; } "bpDiaAnswer"; } "bpDiaRule"; gV.item as itP where ((linkId = 'vitals.pulse') and answer.value.exists()) then { itP.answer first as aP then { aP -> bundle.entry as entryP, entryP.resource = create('Observation') as obsP then { qr -> obsP, entryP then BuildObsBase(qr, obsP, entryP) "pulseBase"; qr -> obsP then SetVitalSignsCategory(qr, obsP) "pulseCategory"; qr -> obsP.code as code then { qr -> code.coding as coding then { qr -> coding.system = 'http://loinc.org' "codeSystem"; qr -> coding.code = '8867-4' "codeCode"; qr -> coding.display = 'Heart rate' "codeDisplay"; } "codeCoding"; } "pulseCode"; aP.value as v -> obsP.value = v "pulseValue"; } "pulseObservation"; } "pulseAnswer"; } "pulseRule"; gV.item as itT where ((linkId = 'vitals.temp') and answer.value.exists()) then { itT.answer first as aT then { aT -> bundle.entry as entryT, entryT.resource = create('Observation') as obsT then { qr -> obsT, entryT then BuildObsBase(qr, obsT, entryT) "tempBase"; qr -> obsT then SetVitalSignsCategory(qr, obsT) "tempCategory"; qr -> obsT.code as code then { qr -> code.coding as coding then { qr -> coding.system = 'http://loinc.org' "codeSystem"; qr -> coding.code = '8310-5' "codeCode"; qr -> coding.display = 'Body temperature' "codeDisplay"; } "codeCoding"; } "tempCode"; aT.value as v -> obsT.value = v "tempValue"; } "tempObservation"; } "tempAnswer"; } "tempRule"; gV.item as itR where ((linkId = 'vitals.resp') and answer.value.exists()) then { itR.answer first as aR then { aR -> bundle.entry as entryR, entryR.resource = create('Observation') as obsR then { qr -> obsR, entryR then BuildObsBase(qr, obsR, entryR) "respBase"; qr -> obsR then SetVitalSignsCategory(qr, obsR) "respCategory"; qr -> obsR.code as code then { qr -> code.coding as coding then { qr -> coding.system = 'http://loinc.org' "codeSystem"; qr -> coding.code = '9279-1' "codeCode"; qr -> coding.display = 'Respiratory rate' "codeDisplay"; } "codeCoding"; } "respCode"; aR.value as v -> obsR.value = v "respValue"; } "respObservation"; } "respAnswer"; } "respRule"; gV.item as itO where ((linkId = 'vitals.spo2') 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) "spo2Base"; qr -> obsO then SetVitalSignsCategory(qr, obsO) "spo2Category"; qr -> obsO.code as code then { qr -> code.coding as coding then { qr -> coding.system = 'http://loinc.org' "codeSystem"; qr -> coding.code = '59408-5' "codeCode"; qr -> coding.display = 'Oxygen saturation in Arterial blood by Pulse oximetry' "codeDisplay"; } "codeCoding"; } "spo2Code"; aO.value as v -> obsO.value = v "spo2Value"; } "spo2Observation"; } "spo2Answer"; } "spo2Rule"; } "vitalsGroupRule"; // ── The assessment as a filed document ───────────────────────────────────── qr -> bundle.entry as entry, entry.resource = create('Composition') as comp then { qr -> comp, entry then BuildNoteBase(qr, comp, entry) "noteBase"; qr -> comp.name = 'InpatientAdultGeneralAdmissionAssessment' "noteName"; qr -> comp.title = 'Adult general admission assessment' "noteTitle"; qr -> comp.type as ty then { qr -> ty.coding as sghi then { qr -> sghi.system = 'https://fhir.slade360.co.ke/fhir/CodeSystem/inpatient-document-type-codesystem' "sghiSystem"; qr -> sghi.code = 'adult-general-admission-assessment' "sghiCode"; qr -> sghi.display = 'Adult general admission assessment' "sghiDisplay"; } "sghiCoding"; qr -> ty.text = 'Adult general admission assessment' "typeText"; } "noteType"; qr.item as it where ((linkId = 'complaint') and answer.value.exists()) -> comp.section as sec then { it -> sec.title = 'Presenting complaint' "complaintTitle"; it -> sec then AddSectionText(it, sec) "complaintSectionText"; } "complaintSectionRule"; qr.item as itA where ((linkId = 'allergies') and answer.value.exists()) -> comp.section as secA then { itA -> secA.title = 'Known allergies' "allergiesTitle"; itA.answer as aA then { aA.value as av -> secA.entry = av "allergiesEntry"; } "allergiesAnswers"; } "allergiesRule"; qr.item as itM where ((linkId = 'meds') and answer.value.exists()) -> comp.section as secM then { itM -> secM.title = 'Current medication' "medsTitle"; itM.answer as aM then { aM.value as mv -> secM.entry = mv "medsEntry"; } "medsAnswers"; } "medsRule"; } "composition"; } // ───────────────────────────────────────────────────────────────────────────── // 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; // `effective`, not `effectiveDateTime`: the R5 transform engine writes choice // elements by their base name and rejects the typed form. This form asks for // no time of its own, so the moment the response was authored is the best // available. 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.id` already resolves to the type-qualified relative reference under this // engine, so it is used unprefixed. qr -> obs.derivedFrom = create('Reference') as ref then { qr.id as qid -> ref.reference = qid "derivedFromRef"; } "linkQuestionnaireResponse"; } 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 BuildNoteBase(source qr : QR, target comp : Composition, target entry) { qr -> comp.id = uuid() then SetCompositionFullUrl(comp, entry) "idAndFullUrl"; qr -> entry.request as request then { qr -> request.method = 'POST' "requestMethod"; qr -> request.url = 'Composition' "requestUrl"; } "entryRequest"; qr -> comp.status = 'final' "status"; qr.subject as s -> comp.subject = s; qr.encounter as e -> comp.encounter = e; // Composition.date is 1..1. `authored` is only 0..1 on the response, so when a // client sends none the extraction time stands in. It is a poor substitute for // when the note was written, but a document with no date at all is worse, and // extraction happens moments after submission in practice. qr.authored as t -> comp.date = t "date"; qr where (authored.exists().not()) then { qr -> comp.date = evaluate(qr, now()) "dateFromExtractionTime"; } "dateFallback"; // Composition.author is 1..1 minimum. R5 QuestionnaireResponse carries both // `author` (who recorded the answers) and `source` (who supplied them); the // author is the one who wrote the note, so it wins, and `source` only stands // in when the client did not send an author. If the response carries neither, // the note comes out unauthored -- there is nothing on a QuestionnaireResponse // to invent one from, and guessing at who wrote a clinical note is not a thing // a map should do. qr.author as a -> comp.author = a "authorFromAuthor"; qr where (author.exists().not()) then { qr.source as src -> comp.author = src "authorFromSource"; } "authorFallback"; qr -> comp.relatesTo as rel then { qr -> rel.type = 'derived-from' "relatesToType"; qr -> rel.resourceReference = create('Reference') as ref then { qr.id as qid -> ref.reference = qid "relatesToRef"; } "relatesToTarget"; } "linkQuestionnaireResponse"; } group AddSectionText(source it, target sec) { it.answer first as a then { a.value as v -> sec.text as narrative then { v -> narrative.status = 'generated' "narrativeStatus"; v -> narrative.div = create('xhtml') as xhtml then { v -> xhtml.value = evaluate(a, '<div xmlns="http://www.w3.org/1999/xhtml"><p>' + value.toString().escape('html') + '</p></div>') "narrativeDiv"; } "narrativeXhtml"; } "sectionText"; } "sectionAnswer"; } group SetCompositionFullUrl(source comp : Composition, target entry) { comp.id as id -> entry.fullUrl = append('https://fhir.slade360.co.ke/fhir/Composition/', id) "assignFullUrl"; }
{
"resourceType": "StructureMap",
"id": "ExtractInpatientAdultGeneralAdmissionAssessment",
"text": {
"status": "generated",
"div": "<!-- snip (see above) -->"
},
"url": "https://fhir.slade360.co.ke/fhir/StructureMap/ExtractInpatientAdultGeneralAdmissionAssessment",
"version": "0.1.0",
"name": "ExtractInpatientAdultGeneralAdmissionAssessment",
"title": "Inpatient Adult General 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": "Turns a response to the adult general admission assessment into a chief-complaint Observation, one Observation per vital, and a Composition that files the assessment and carries the allergies and medication the assessor reviewed. Nothing is copied: the allergies and medication are already AllergyIntolerance and MedicationRequest resources -- the form loads them off the server -- so they become section entries. The Composition exists for exactly that reason; without a container those two rows of the assessment extract to nothing at all.",
"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/Composition",
"mode": "target",
"alias": "Composition"
}
],
"group": [
{
"name": "ExtractInpatientAdultGeneralAdmissionAssessment",
"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": "complaintRule",
"source": [
{
"context": "qr",
"element": "item",
"variable": "itC",
"condition": "(linkId = 'complaint') and answer.value.exists()"
}
],
"rule": [
{
"name": "complaintAnswer",
"source": [
{
"context": "itC",
"element": "answer",
"listMode": "first",
"variable": "aC"
}
],
"rule": [
{
"name": "complaintObservation",
"source": [
{
"context": "aC"
}
],
"target": [
{
"context": "bundle",
"element": "entry",
"variable": "entryC"
},
{
"context": "entryC",
"element": "resource",
"variable": "obsC",
"transform": "create",
"parameter": [
{
"valueString": "Observation"
}
]
}
],
"rule": [
{
"name": "complaintBase",
"source": [
{
"context": "qr"
}
],
"target": [
{
"context": "obsC"
},
{
"context": "entryC"
}
],
"dependent": [
{
"name": "BuildObsBase",
"parameter": [
{
"valueId": "qr"
},
{
"valueId": "obsC"
},
{
"valueId": "entryC"
}
]
}
]
},
{
"name": "complaintCategory",
"source": [
{
"context": "qr"
}
],
"target": [
{
"context": "obsC"
}
],
"dependent": [
{
"name": "SetSocialHistoryCategory",
"parameter": [
{
"valueId": "qr"
},
{
"valueId": "obsC"
}
]
}
]
},
{
"name": "complaintCode",
"source": [
{
"context": "qr"
}
],
"target": [
{
"context": "obsC",
"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": "10154-3"
}
]
}
]
},
{
"name": "codeDisplay",
"source": [
{
"context": "qr"
}
],
"target": [
{
"context": "coding",
"element": "display",
"transform": "copy",
"parameter": [
{
"valueString": "Chief complaint Narrative - Reported"
}
]
}
]
}
]
}
]
},
{
"name": "complaintValue",
"source": [
{
"context": "aC",
"element": "value",
"variable": "v"
}
],
"target": [
{
"context": "obsC",
"element": "value",
"transform": "copy",
"parameter": [
{
"valueId": "v"
}
]
}
]
}
]
}
]
}
],
"documentation": "── Presenting complaint ───────────────────────────────────────────────────\r\nCategory `social-history` and code 10154-3 match what extract-vital-signs\r\nalready produces for a chief complaint, so a consumer querying\r\ncategory=social-history&code=10154-3 gets both without knowing which form\r\nthe complaint came from."
},
{
"name": "vitalsGroupRule",
"source": [
{
"context": "qr",
"element": "item",
"variable": "gV",
"condition": "linkId = 'vitals'"
}
],
"rule": [
{
"name": "bpSysRule",
"source": [
{
"context": "gV",
"element": "item",
"variable": "itS",
"condition": "(linkId = 'vitals.bpSys') and answer.value.exists()"
}
],
"rule": [
{
"name": "bpSysAnswer",
"source": [
{
"context": "itS",
"element": "answer",
"listMode": "first",
"variable": "aS"
}
],
"rule": [
{
"name": "bpSysObservation",
"source": [
{
"context": "aS"
}
],
"target": [
{
"context": "bundle",
"element": "entry",
"variable": "entryS"
},
{
"context": "entryS",
"element": "resource",
"variable": "obsS",
"transform": "create",
"parameter": [
{
"valueString": "Observation"
}
]
}
],
"rule": [
{
"name": "bpSysBase",
"source": [
{
"context": "qr"
}
],
"target": [
{
"context": "obsS"
},
{
"context": "entryS"
}
],
"dependent": [
{
"name": "BuildObsBase",
"parameter": [
{
"valueId": "qr"
},
{
"valueId": "obsS"
},
{
"valueId": "entryS"
}
]
}
]
},
{
"name": "bpSysCategory",
"source": [
{
"context": "qr"
}
],
"target": [
{
"context": "obsS"
}
],
"dependent": [
{
"name": "SetVitalSignsCategory",
"parameter": [
{
"valueId": "qr"
},
{
"valueId": "obsS"
}
]
}
]
},
{
"name": "bpSysCode",
"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": "http://loinc.org"
}
]
}
]
},
{
"name": "codeCode",
"source": [
{
"context": "qr"
}
],
"target": [
{
"context": "coding",
"element": "code",
"transform": "copy",
"parameter": [
{
"valueString": "8480-6"
}
]
}
]
},
{
"name": "codeDisplay",
"source": [
{
"context": "qr"
}
],
"target": [
{
"context": "coding",
"element": "display",
"transform": "copy",
"parameter": [
{
"valueString": "Systolic blood pressure"
}
]
}
]
}
]
}
]
},
{
"name": "bpSysValue",
"source": [
{
"context": "aS",
"element": "value",
"variable": "v"
}
],
"target": [
{
"context": "obsS",
"element": "value",
"transform": "copy",
"parameter": [
{
"valueId": "v"
}
]
}
]
}
]
}
]
}
]
},
{
"name": "bpDiaRule",
"source": [
{
"context": "gV",
"element": "item",
"variable": "itD",
"condition": "(linkId = 'vitals.bpDia') and answer.value.exists()"
}
],
"rule": [
{
"name": "bpDiaAnswer",
"source": [
{
"context": "itD",
"element": "answer",
"listMode": "first",
"variable": "aD"
}
],
"rule": [
{
"name": "bpDiaObservation",
"source": [
{
"context": "aD"
}
],
"target": [
{
"context": "bundle",
"element": "entry",
"variable": "entryD"
},
{
"context": "entryD",
"element": "resource",
"variable": "obsD",
"transform": "create",
"parameter": [
{
"valueString": "Observation"
}
]
}
],
"rule": [
{
"name": "bpDiaBase",
"source": [
{
"context": "qr"
}
],
"target": [
{
"context": "obsD"
},
{
"context": "entryD"
}
],
"dependent": [
{
"name": "BuildObsBase",
"parameter": [
{
"valueId": "qr"
},
{
"valueId": "obsD"
},
{
"valueId": "entryD"
}
]
}
]
},
{
"name": "bpDiaCategory",
"source": [
{
"context": "qr"
}
],
"target": [
{
"context": "obsD"
}
],
"dependent": [
{
"name": "SetVitalSignsCategory",
"parameter": [
{
"valueId": "qr"
},
{
"valueId": "obsD"
}
]
}
]
},
{
"name": "bpDiaCode",
"source": [
{
"context": "qr"
}
],
"target": [
{
"context": "obsD",
"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": "8462-4"
}
]
}
]
},
{
"name": "codeDisplay",
"source": [
{
"context": "qr"
}
],
"target": [
{
"context": "coding",
"element": "display",
"transform": "copy",
"parameter": [
{
"valueString": "Diastolic blood pressure"
}
]
}
]
}
]
}
]
},
{
"name": "bpDiaValue",
"source": [
{
"context": "aD",
"element": "value",
"variable": "v"
}
],
"target": [
{
"context": "obsD",
"element": "value",
"transform": "copy",
"parameter": [
{
"valueId": "v"
}
]
}
]
}
]
}
]
}
]
},
{
"name": "pulseRule",
"source": [
{
"context": "gV",
"element": "item",
"variable": "itP",
"condition": "(linkId = 'vitals.pulse') and answer.value.exists()"
}
],
"rule": [
{
"name": "pulseAnswer",
"source": [
{
"context": "itP",
"element": "answer",
"listMode": "first",
"variable": "aP"
}
],
"rule": [
{
"name": "pulseObservation",
"source": [
{
"context": "aP"
}
],
"target": [
{
"context": "bundle",
"element": "entry",
"variable": "entryP"
},
{
"context": "entryP",
"element": "resource",
"variable": "obsP",
"transform": "create",
"parameter": [
{
"valueString": "Observation"
}
]
}
],
"rule": [
{
"name": "pulseBase",
"source": [
{
"context": "qr"
}
],
"target": [
{
"context": "obsP"
},
{
"context": "entryP"
}
],
"dependent": [
{
"name": "BuildObsBase",
"parameter": [
{
"valueId": "qr"
},
{
"valueId": "obsP"
},
{
"valueId": "entryP"
}
]
}
]
},
{
"name": "pulseCategory",
"source": [
{
"context": "qr"
}
],
"target": [
{
"context": "obsP"
}
],
"dependent": [
{
"name": "SetVitalSignsCategory",
"parameter": [
{
"valueId": "qr"
},
{
"valueId": "obsP"
}
]
}
]
},
{
"name": "pulseCode",
"source": [
{
"context": "qr"
}
],
"target": [
{
"context": "obsP",
"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": "8867-4"
}
]
}
]
},
{
"name": "codeDisplay",
"source": [
{
"context": "qr"
}
],
"target": [
{
"context": "coding",
"element": "display",
"transform": "copy",
"parameter": [
{
"valueString": "Heart rate"
}
]
}
]
}
]
}
]
},
{
"name": "pulseValue",
"source": [
{
"context": "aP",
"element": "value",
"variable": "v"
}
],
"target": [
{
"context": "obsP",
"element": "value",
"transform": "copy",
"parameter": [
{
"valueId": "v"
}
]
}
]
}
]
}
]
}
]
},
{
"name": "tempRule",
"source": [
{
"context": "gV",
"element": "item",
"variable": "itT",
"condition": "(linkId = 'vitals.temp') and answer.value.exists()"
}
],
"rule": [
{
"name": "tempAnswer",
"source": [
{
"context": "itT",
"element": "answer",
"listMode": "first",
"variable": "aT"
}
],
"rule": [
{
"name": "tempObservation",
"source": [
{
"context": "aT"
}
],
"target": [
{
"context": "bundle",
"element": "entry",
"variable": "entryT"
},
{
"context": "entryT",
"element": "resource",
"variable": "obsT",
"transform": "create",
"parameter": [
{
"valueString": "Observation"
}
]
}
],
"rule": [
{
"name": "tempBase",
"source": [
{
"context": "qr"
}
],
"target": [
{
"context": "obsT"
},
{
"context": "entryT"
}
],
"dependent": [
{
"name": "BuildObsBase",
"parameter": [
{
"valueId": "qr"
},
{
"valueId": "obsT"
},
{
"valueId": "entryT"
}
]
}
]
},
{
"name": "tempCategory",
"source": [
{
"context": "qr"
}
],
"target": [
{
"context": "obsT"
}
],
"dependent": [
{
"name": "SetVitalSignsCategory",
"parameter": [
{
"valueId": "qr"
},
{
"valueId": "obsT"
}
]
}
]
},
{
"name": "tempCode",
"source": [
{
"context": "qr"
}
],
"target": [
{
"context": "obsT",
"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": "8310-5"
}
]
}
]
},
{
"name": "codeDisplay",
"source": [
{
"context": "qr"
}
],
"target": [
{
"context": "coding",
"element": "display",
"transform": "copy",
"parameter": [
{
"valueString": "Body temperature"
}
]
}
]
}
]
}
]
},
{
"name": "tempValue",
"source": [
{
"context": "aT",
"element": "value",
"variable": "v"
}
],
"target": [
{
"context": "obsT",
"element": "value",
"transform": "copy",
"parameter": [
{
"valueId": "v"
}
]
}
]
}
]
}
]
}
]
},
{
"name": "respRule",
"source": [
{
"context": "gV",
"element": "item",
"variable": "itR",
"condition": "(linkId = 'vitals.resp') and answer.value.exists()"
}
],
"rule": [
{
"name": "respAnswer",
"source": [
{
"context": "itR",
"element": "answer",
"listMode": "first",
"variable": "aR"
}
],
"rule": [
{
"name": "respObservation",
"source": [
{
"context": "aR"
}
],
"target": [
{
"context": "bundle",
"element": "entry",
"variable": "entryR"
},
{
"context": "entryR",
"element": "resource",
"variable": "obsR",
"transform": "create",
"parameter": [
{
"valueString": "Observation"
}
]
}
],
"rule": [
{
"name": "respBase",
"source": [
{
"context": "qr"
}
],
"target": [
{
"context": "obsR"
},
{
"context": "entryR"
}
],
"dependent": [
{
"name": "BuildObsBase",
"parameter": [
{
"valueId": "qr"
},
{
"valueId": "obsR"
},
{
"valueId": "entryR"
}
]
}
]
},
{
"name": "respCategory",
"source": [
{
"context": "qr"
}
],
"target": [
{
"context": "obsR"
}
],
"dependent": [
{
"name": "SetVitalSignsCategory",
"parameter": [
{
"valueId": "qr"
},
{
"valueId": "obsR"
}
]
}
]
},
{
"name": "respCode",
"source": [
{
"context": "qr"
}
],
"target": [
{
"context": "obsR",
"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": "9279-1"
}
]
}
]
},
{
"name": "codeDisplay",
"source": [
{
"context": "qr"
}
],
"target": [
{
"context": "coding",
"element": "display",
"transform": "copy",
"parameter": [
{
"valueString": "Respiratory rate"
}
]
}
]
}
]
}
]
},
{
"name": "respValue",
"source": [
{
"context": "aR",
"element": "value",
"variable": "v"
}
],
"target": [
{
"context": "obsR",
"element": "value",
"transform": "copy",
"parameter": [
{
"valueId": "v"
}
]
}
]
}
]
}
]
}
]
},
{
"name": "spo2Rule",
"source": [
{
"context": "gV",
"element": "item",
"variable": "itO",
"condition": "(linkId = 'vitals.spo2') and answer.value.exists()"
}
],
"rule": [
{
"name": "spo2Answer",
"source": [
{
"context": "itO",
"element": "answer",
"listMode": "first",
"variable": "aO"
}
],
"rule": [
{
"name": "spo2Observation",
"source": [
{
"context": "aO"
}
],
"target": [
{
"context": "bundle",
"element": "entry",
"variable": "entryO"
},
{
"context": "entryO",
"element": "resource",
"variable": "obsO",
"transform": "create",
"parameter": [
{
"valueString": "Observation"
}
]
}
],
"rule": [
{
"name": "spo2Base",
"source": [
{
"context": "qr"
}
],
"target": [
{
"context": "obsO"
},
{
"context": "entryO"
}
],
"dependent": [
{
"name": "BuildObsBase",
"parameter": [
{
"valueId": "qr"
},
{
"valueId": "obsO"
},
{
"valueId": "entryO"
}
]
}
]
},
{
"name": "spo2Category",
"source": [
{
"context": "qr"
}
],
"target": [
{
"context": "obsO"
}
],
"dependent": [
{
"name": "SetVitalSignsCategory",
"parameter": [
{
"valueId": "qr"
},
{
"valueId": "obsO"
}
]
}
]
},
{
"name": "spo2Code",
"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": "59408-5"
}
]
}
]
},
{
"name": "codeDisplay",
"source": [
{
"context": "qr"
}
],
"target": [
{
"context": "coding",
"element": "display",
"transform": "copy",
"parameter": [
{
"valueString": "Oxygen saturation in Arterial blood by Pulse oximetry"
}
]
}
]
}
]
}
]
},
{
"name": "spo2Value",
"source": [
{
"context": "aO",
"element": "value",
"variable": "v"
}
],
"target": [
{
"context": "obsO",
"element": "value",
"transform": "copy",
"parameter": [
{
"valueId": "v"
}
]
}
]
}
]
}
]
}
]
}
],
"documentation": "── Vitals on admission ────────────────────────────────────────────────────\r\nSix items, six Observations, exactly as the form extracted before it had a\r\nmap. Each answer is already a Quantity -- the item is type `quantity` with\r\na questionnaire-unitOption pinning the unit -- so it is copied through\r\nwhole. Rebuilding it here would mean restating a unit the client actually\r\nsent, which turns a wrong unit into a wrong reading."
},
{
"name": "composition",
"source": [
{
"context": "qr"
}
],
"target": [
{
"context": "bundle",
"element": "entry",
"variable": "entry"
},
{
"context": "entry",
"element": "resource",
"variable": "comp",
"transform": "create",
"parameter": [
{
"valueString": "Composition"
}
]
}
],
"rule": [
{
"name": "noteBase",
"source": [
{
"context": "qr"
}
],
"target": [
{
"context": "comp"
},
{
"context": "entry"
}
],
"dependent": [
{
"name": "BuildNoteBase",
"parameter": [
{
"valueId": "qr"
},
{
"valueId": "comp"
},
{
"valueId": "entry"
}
]
}
]
},
{
"name": "noteName",
"source": [
{
"context": "qr"
}
],
"target": [
{
"context": "comp",
"element": "name",
"transform": "copy",
"parameter": [
{
"valueString": "InpatientAdultGeneralAdmissionAssessment"
}
]
}
]
},
{
"name": "noteTitle",
"source": [
{
"context": "qr"
}
],
"target": [
{
"context": "comp",
"element": "title",
"transform": "copy",
"parameter": [
{
"valueString": "Adult general admission assessment"
}
]
}
]
},
{
"name": "noteType",
"source": [
{
"context": "qr"
}
],
"target": [
{
"context": "comp",
"element": "type",
"variable": "ty"
}
],
"rule": [
{
"name": "sghiCoding",
"source": [
{
"context": "qr"
}
],
"target": [
{
"context": "ty",
"element": "coding",
"variable": "sghi"
}
],
"rule": [
{
"name": "sghiSystem",
"source": [
{
"context": "qr"
}
],
"target": [
{
"context": "sghi",
"element": "system",
"transform": "copy",
"parameter": [
{
"valueString": "https://fhir.slade360.co.ke/fhir/CodeSystem/inpatient-document-type-codesystem"
}
]
}
]
},
{
"name": "sghiCode",
"source": [
{
"context": "qr"
}
],
"target": [
{
"context": "sghi",
"element": "code",
"transform": "copy",
"parameter": [
{
"valueString": "adult-general-admission-assessment"
}
]
}
]
},
{
"name": "sghiDisplay",
"source": [
{
"context": "qr"
}
],
"target": [
{
"context": "sghi",
"element": "display",
"transform": "copy",
"parameter": [
{
"valueString": "Adult general admission assessment"
}
]
}
]
}
]
},
{
"name": "typeText",
"source": [
{
"context": "qr"
}
],
"target": [
{
"context": "ty",
"element": "text",
"transform": "copy",
"parameter": [
{
"valueString": "Adult general admission assessment"
}
]
}
]
}
]
},
{
"name": "complaintSectionRule",
"source": [
{
"context": "qr",
"element": "item",
"variable": "it",
"condition": "(linkId = 'complaint') and answer.value.exists()"
}
],
"target": [
{
"context": "comp",
"element": "section",
"variable": "sec"
}
],
"rule": [
{
"name": "complaintTitle",
"source": [
{
"context": "it"
}
],
"target": [
{
"context": "sec",
"element": "title",
"transform": "copy",
"parameter": [
{
"valueString": "Presenting complaint"
}
]
}
]
},
{
"name": "complaintSectionText",
"source": [
{
"context": "it"
}
],
"target": [
{
"context": "sec"
}
],
"dependent": [
{
"name": "AddSectionText",
"parameter": [
{
"valueId": "it"
},
{
"valueId": "sec"
}
]
}
]
}
]
},
{
"name": "allergiesRule",
"source": [
{
"context": "qr",
"element": "item",
"variable": "itA",
"condition": "(linkId = 'allergies') and answer.value.exists()"
}
],
"target": [
{
"context": "comp",
"element": "section",
"variable": "secA"
}
],
"rule": [
{
"name": "allergiesTitle",
"source": [
{
"context": "itA"
}
],
"target": [
{
"context": "secA",
"element": "title",
"transform": "copy",
"parameter": [
{
"valueString": "Known allergies"
}
]
}
]
},
{
"name": "allergiesAnswers",
"source": [
{
"context": "itA",
"element": "answer",
"variable": "aA"
}
],
"rule": [
{
"name": "allergiesEntry",
"source": [
{
"context": "aA",
"element": "value",
"variable": "av"
}
],
"target": [
{
"context": "secA",
"element": "entry",
"transform": "copy",
"parameter": [
{
"valueId": "av"
}
]
}
]
}
]
}
]
},
{
"name": "medsRule",
"source": [
{
"context": "qr",
"element": "item",
"variable": "itM",
"condition": "(linkId = 'meds') and answer.value.exists()"
}
],
"target": [
{
"context": "comp",
"element": "section",
"variable": "secM"
}
],
"rule": [
{
"name": "medsTitle",
"source": [
{
"context": "itM"
}
],
"target": [
{
"context": "secM",
"element": "title",
"transform": "copy",
"parameter": [
{
"valueString": "Current medication"
}
]
}
]
},
{
"name": "medsAnswers",
"source": [
{
"context": "itM",
"element": "answer",
"variable": "aM"
}
],
"rule": [
{
"name": "medsEntry",
"source": [
{
"context": "aM",
"element": "value",
"variable": "mv"
}
],
"target": [
{
"context": "secM",
"element": "entry",
"transform": "copy",
"parameter": [
{
"valueId": "mv"
}
]
}
]
}
]
}
]
}
],
"documentation": "── The assessment as a filed document ─────────────────────────────────────"
}
]
},
{
"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"
}
]
}
],
"documentation": "`effective`, not `effectiveDateTime`: the R5 transform engine writes choice\r\nelements by their base name and rejects the typed form. This form asks for\r\nno time of its own, so the moment the response was authored is the best\r\navailable."
},
{
"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"
}
]
}
]
}
],
"documentation": "`qr.id` already resolves to the type-qualified relative reference under this\r\nengine, so it is used unprefixed."
}
]
},
{
"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": "BuildNoteBase",
"input": [
{
"name": "qr",
"type": "QR",
"mode": "source"
},
{
"name": "comp",
"type": "Composition",
"mode": "target"
},
{
"name": "entry",
"mode": "target"
}
],
"rule": [
{
"name": "idAndFullUrl",
"source": [
{
"context": "qr"
}
],
"target": [
{
"context": "comp",
"element": "id",
"transform": "uuid"
}
],
"dependent": [
{
"name": "SetCompositionFullUrl",
"parameter": [
{
"valueId": "comp"
},
{
"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": "Composition"
}
]
}
]
}
]
},
{
"name": "status",
"source": [
{
"context": "qr"
}
],
"target": [
{
"context": "comp",
"element": "status",
"transform": "copy",
"parameter": [
{
"valueString": "final"
}
]
}
]
},
{
"name": "subject",
"source": [
{
"context": "qr",
"element": "subject",
"variable": "s"
}
],
"target": [
{
"context": "comp",
"element": "subject",
"transform": "copy",
"parameter": [
{
"valueId": "s"
}
]
}
]
},
{
"name": "encounter",
"source": [
{
"context": "qr",
"element": "encounter",
"variable": "e"
}
],
"target": [
{
"context": "comp",
"element": "encounter",
"transform": "copy",
"parameter": [
{
"valueId": "e"
}
]
}
]
},
{
"name": "date",
"source": [
{
"context": "qr",
"element": "authored",
"variable": "t"
}
],
"target": [
{
"context": "comp",
"element": "date",
"transform": "copy",
"parameter": [
{
"valueId": "t"
}
]
}
],
"documentation": "Composition.date is 1..1. `authored` is only 0..1 on the response, so when a\r\nclient sends none the extraction time stands in. It is a poor substitute for\r\nwhen the note was written, but a document with no date at all is worse, and\r\nextraction happens moments after submission in practice."
},
{
"name": "dateFallback",
"source": [
{
"context": "qr",
"condition": "authored.exists().not()"
}
],
"rule": [
{
"name": "dateFromExtractionTime",
"source": [
{
"context": "qr"
}
],
"target": [
{
"context": "comp",
"element": "date",
"transform": "evaluate",
"parameter": [
{
"valueId": "qr"
},
{
"valueString": "now()"
}
]
}
]
}
]
},
{
"name": "authorFromAuthor",
"source": [
{
"context": "qr",
"element": "author",
"variable": "a"
}
],
"target": [
{
"context": "comp",
"element": "author",
"transform": "copy",
"parameter": [
{
"valueId": "a"
}
]
}
],
"documentation": "Composition.author is 1..1 minimum. R5 QuestionnaireResponse carries both\r\n`author` (who recorded the answers) and `source` (who supplied them); the\r\nauthor is the one who wrote the note, so it wins, and `source` only stands\r\nin when the client did not send an author. If the response carries neither,\r\nthe note comes out unauthored -- there is nothing on a QuestionnaireResponse\r\nto invent one from, and guessing at who wrote a clinical note is not a thing\r\na map should do."
},
{
"name": "authorFallback",
"source": [
{
"context": "qr",
"condition": "author.exists().not()"
}
],
"rule": [
{
"name": "authorFromSource",
"source": [
{
"context": "qr",
"element": "source",
"variable": "src"
}
],
"target": [
{
"context": "comp",
"element": "author",
"transform": "copy",
"parameter": [
{
"valueId": "src"
}
]
}
]
}
]
},
{
"name": "linkQuestionnaireResponse",
"source": [
{
"context": "qr"
}
],
"target": [
{
"context": "comp",
"element": "relatesTo",
"variable": "rel"
}
],
"rule": [
{
"name": "relatesToType",
"source": [
{
"context": "qr"
}
],
"target": [
{
"context": "rel",
"element": "type",
"transform": "copy",
"parameter": [
{
"valueString": "derived-from"
}
]
}
]
},
{
"name": "relatesToTarget",
"source": [
{
"context": "qr"
}
],
"target": [
{
"context": "rel",
"element": "resourceReference",
"variable": "ref",
"transform": "create",
"parameter": [
{
"valueString": "Reference"
}
]
}
],
"rule": [
{
"name": "relatesToRef",
"source": [
{
"context": "qr",
"element": "id",
"variable": "qid"
}
],
"target": [
{
"context": "ref",
"element": "reference",
"transform": "copy",
"parameter": [
{
"valueId": "qid"
}
]
}
]
}
]
}
]
}
]
},
{
"name": "AddSectionText",
"input": [
{
"name": "it",
"mode": "source"
},
{
"name": "sec",
"mode": "target"
}
],
"rule": [
{
"name": "sectionAnswer",
"source": [
{
"context": "it",
"element": "answer",
"listMode": "first",
"variable": "a"
}
],
"rule": [
{
"name": "sectionText",
"source": [
{
"context": "a",
"element": "value",
"variable": "v"
}
],
"target": [
{
"context": "sec",
"element": "text",
"variable": "narrative"
}
],
"rule": [
{
"name": "narrativeStatus",
"source": [
{
"context": "v"
}
],
"target": [
{
"context": "narrative",
"element": "status",
"transform": "copy",
"parameter": [
{
"valueString": "generated"
}
]
}
]
},
{
"name": "narrativeXhtml",
"source": [
{
"context": "v"
}
],
"target": [
{
"context": "narrative",
"element": "div",
"variable": "xhtml",
"transform": "create",
"parameter": [
{
"valueString": "xhtml"
}
]
}
],
"rule": [
{
"name": "narrativeDiv",
"source": [
{
"context": "v"
}
],
"target": [
{
"context": "xhtml",
"element": "value",
"transform": "evaluate",
"parameter": [
{
"valueId": "a"
},
{
"valueString": "'<div xmlns=\"http://www.w3.org/1999/xhtml\"><p>' + value.toString().escape('html') + '</p></div>'"
}
]
}
]
}
]
}
]
}
]
}
]
},
{
"name": "SetCompositionFullUrl",
"input": [
{
"name": "comp",
"type": "Composition",
"mode": "source"
},
{
"name": "entry",
"mode": "target"
}
],
"rule": [
{
"name": "assignFullUrl",
"source": [
{
"context": "comp",
"element": "id",
"variable": "id"
}
],
"target": [
{
"context": "entry",
"element": "fullUrl",
"transform": "append",
"parameter": [
{
"valueString": "https://fhir.slade360.co.ke/fhir/Composition/"
},
{
"valueId": "id"
}
]
}
]
}
]
}
]
}