ExtractVitalSigns
type: StructureMap
node role: treeRoot
id:
  v: ExtractVitalSigns
text:
  status:
    v: generated
  div:
    v: Generated Narrative: StructureMap ExtractVitalSigns #xD; /// url = 'https://fhir.slade360.co.ke/fhir/StructureMap/ExtractVitalSigns'#xD; /// name = 'ExtractVitalSigns'#xD; /// status = 'draft'#xD; #xD; uses "http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse" alias QR as source#xD; uses "http://hl7.org/fhir/StructureDefinition/Bundle" alias Bundle as target#xD; uses "http://hl7.org/fhir/StructureDefinition/Observation" alias Observation as target#xD; #xD; group ExtractVitalSigns(source qr : QR, target bundle : Bundle) {#xD; qr -> bundle.type = 'transaction' "setBundleType";#xD; qr.item as itH where (linkId = '8302-2') then {#xD; itH.answer first as aH then {#xD; aH -> bundle.entry as eH, eH.resource = create('Observation') as oH then {#xD; qr -> oH, eH then BuildBaseObs(qr, oH, eH) "heightBase";#xD; qr -> oH.code = cc('http://loinc.org', '8302-2', 'Body Height') "codeH";#xD; aH.value as hv -> oH.valueQuantity as vH then {#xD; hv -> vH.value = hv "setVal";#xD; qr -> vH.system = 'http://unitsofmeasure.org' "setSys";#xD; qr -> vH.code = 'cm' "setCode";#xD; qr -> vH.unit = 'centimeter' "setUnit";#xD; } "valH";#xD; } "heightObs";#xD; } "heightAns";#xD; } "heightRule"; // Height#xD; qr.item as itW where (linkId = '29463-7') then {#xD; itW.answer first as aW then {#xD; aW -> bundle.entry as eW, eW.resource = create('Observation') as oW then {#xD; qr -> oW, eW then BuildBaseObs(qr, oW, eW) "weightBase";#xD; qr -> oW.code = cc('http://loinc.org', '29463-7', 'Body Weight') "codeW";#xD; aW.value as hv -> oW.valueQuantity as vW then {#xD; hv -> vW.value = hv "setVal";#xD; qr -> vW.system = 'http://unitsofmeasure.org' "setSys";#xD; qr -> vW.code = 'kg' "setCode";#xD; qr -> vW.unit = 'kilogram' "setUnit";#xD; } "valW";#xD; } "weightObs";#xD; } "weightAns";#xD; } "weightRule"; // Weight#xD; qr.item as itBmi where (linkId = '39156-5') then {#xD; itBmi.answer first as aBmi then {#xD; aBmi -> bundle.entry as eBmi, eBmi.resource = create('Observation') as oBmi then {#xD; qr…
url:
  v: https://fhir.slade360.co.ke/fhir/StructureMap/ExtractVitalSigns
  l: ExtractVitalSigns
version:
  v: 0.1.0
name:
  v: ExtractVitalSigns
status:
  v: draft
date:
  v: 2025-12-12T13:43:17+00:00
publisher:
  v: Kathurima Kimathi
contact:
  name:
    v: Kathurima Kimathi
  telecom:
    system:
      v: url
    value:
      v: https://www.linkedin.com/in/kathurima-kimathi/
  telecom:
    system:
      v: email
contact:
  name:
    v: Oscar John
  telecom:
    system:
      v: email
    use:
      v: work
contact:
  name:
    v: Kennedy Omondi
  telecom:
    system:
      v: email
    use:
      v: work
structure:
  url:
    v: http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse
    l: QuestionnaireResponse
  mode:
    v: source
  alias:
    v: QR
structure:
  url:
    v: http://hl7.org/fhir/StructureDefinition/Bundle
    l: Bundle
  mode:
    v: target
  alias:
    v: Bundle
structure:
  url:
    v: http://hl7.org/fhir/StructureDefinition/Observation
    l: Observation
  mode:
    v: target
  alias:
    v: Observation
group:
  name:
    v: ExtractVitalSigns
  input:
    name:
      v: qr
    type:
      v: QR
    mode:
      v: source
  input:
    name:
      v: bundle
    type:
      v: Bundle
    mode:
      v: target
  rule:
    name:
      v: setBundleType
    source:
      context:
        v: qr
    target:
      context:
        v: bundle
      element:
        v: type
      transform:
        v: copy
      parameter:
        value: String
  rule:
    name:
      v: heightRule
    source:
      context:
        v: qr
      element:
        v: item
      variable:
        v: itH
      condition:
        v: (linkId = '8302-2')
    rule:
      name:
        v: heightAns
    documentation:
      v: Height
  rule:
    name:
      v: weightRule
    source:
      context:
        v: qr
      element:
        v: item
      variable:
        v: itW
      condition:
        v: (linkId = '29463-7')
    rule:
      name:
        v: weightAns
    documentation:
      v: Weight
  rule:
    name:
      v: bmiRule
    source:
      context:
        v: qr
      element:
        v: item
      variable:
        v: itBmi
      condition:
        v: (linkId = '39156-5')
    rule:
      name:
        v: bmiAns
    documentation:
      v: BMI
  rule:
    name:
      v: pulseRule
    source:
      context:
        v: qr
      element:
        v: item
      variable:
        v: itP
      condition:
        v: (linkId = '8889-8')
    rule:
      name:
        v: pulseAns
    documentation:
      v: Pulse
  rule:
    name:
      v: bpRule
    source:
      context:
        v: qr
      element:
        v: item
      variable:
        v: itBP
      condition:
        v: (linkId = '55284-4')
    rule:
      name:
        v: bpAns
    documentation:
      v: Blood Pressure
  rule:
    name:
      v: tempRule
    source:
      context:
        v: qr
      element:
        v: item
      variable:
        v: itT
      condition:
        v: (linkId = '8310-5')

String
v: transaction

v: itH

v: answer

v: first

v: aH

v: heightObs

context:
  v: aH

context:
  v: bundle
element:
  v: entry
variable:
  v: eH

context:
  v: eH
element:
  v: resource
variable:
  v: oH
transform:
  v: create
parameter:
  value: String
    v: Observation

name:
  v: heightBase
source:
  context:
    v: qr
target:
  transform:
    v: copy
  parameter:
    value: Id
      v: oH
target:
  transform:
    v: copy
  parameter:
    value: Id
      v: eH
dependent:
  name:
    v: BuildBaseObs
  parameter:
    value: Id
      v: qr
  parameter:
    value: Id
      v: oH
  parameter:
    value: Id
      v: eH

name:
  v: codeH
source:
  context:
    v: qr
target:
  context:
    v: oH
  element:
    v: code
  transform:
    v: cc
  parameter:
    value: String
      v: http://loinc.org
  parameter:
    value: String
      v: 8302-2
  parameter:
    value: String
      v: Body Height

name:
  v: valH
source:
  context:
    v: aH
  element:
    v: value
  variable:
    v: hv
target:
  context:
    v: oH
  element:
    v: valueQuantity
  variable:
    v: vH
rule:
  name:
    v: setVal
  source:
    context:
      v: hv
  target:
    context:
      v: vH
    element:
      v: value
    transform:
      v: copy
    parameter:
      value: Id
        v: hv
rule:
  name:
    v: setSys
  source:
    context:
      v: qr
  target:
    context:
      v: vH
    element:
      v: system
    transform:
      v: copy
    parameter:
      value: String
        v: http://unitsofmeasure.org
rule:
  name:
    v: setCode
  source:
    context:
      v: qr
  target:
    context:
      v: vH
    element:
      v: code
    transform:
      v: copy
    parameter:
      value: String
        v: cm
rule:
  name:
    v: setUnit
  source:
    context:
      v: qr
  target:
    context:
      v: vH
    element:
      v: unit
    transform:
      v: copy
    parameter:
      value: String
        v: centimeter

v: itW

v: answer

v: first

v: aW

v: weightObs

context:
  v: aW

context:
  v: bundle
element:
  v: entry
variable:
  v: eW

context:
  v: eW
element:
  v: resource
variable:
  v: oW
transform:
  v: create
parameter:
  value: String
    v: Observation

name:
  v: weightBase
source:
  context:
    v: qr
target:
  transform:
    v: copy
  parameter:
    value: Id
      v: oW
target:
  transform:
    v: copy
  parameter:
    value: Id
      v: eW
dependent:
  name:
    v: BuildBaseObs
  parameter:
    value: Id
      v: qr
  parameter:
    value: Id
      v: oW
  parameter:
    value: Id
      v: eW

name:
  v: codeW
source:
  context:
    v: qr
target:
  context:
    v: oW
  element:
    v: code
  transform:
    v: cc
  parameter:
    value: String
      v: http://loinc.org
  parameter:
    value: String
      v: 29463-7
  parameter:
    value: String
      v: Body Weight

name:
  v: valW
source:
  context:
    v: aW
  element:
    v: value
  variable:
    v: hv
target:
  context:
    v: oW
  element:
    v: valueQuantity
  variable:
    v: vW
rule:
  name:
    v: setVal
  source:
    context:
      v: hv
  target:
    context:
      v: vW
    element:
      v: value
    transform:
      v: copy
    parameter:
      value: Id
        v: hv
rule:
  name:
    v: setSys
  source:
    context:
      v: qr
  target:
    context:
      v: vW
    element:
      v: system
    transform:
      v: copy
    parameter:
      value: String
        v: http://unitsofmeasure.org
rule:
  name:
    v: setCode
  source:
    context:
      v: qr
  target:
    context:
      v: vW
    element:
      v: code
    transform:
      v: copy
    parameter:
      value: String
        v: kg
rule:
  name:
    v: setUnit
  source:
    context:
      v: qr
  target:
    context:
      v: vW
    element:
      v: unit
    transform:
      v: copy
    parameter:
      value: String
        v: kilogram

v: itBmi

v: answer

v: first

v: aBmi

v: bmiObs

context:
  v: aBmi

context:
  v: bundle
element:
  v: entry
variable:
  v: eBmi

context:
  v: eBmi
element:
  v: resource
variable:
  v: oBmi
transform:
  v: create
parameter:
  value: String
    v: Observation

name:
  v: bmiBase
source:
  context:
    v: qr
target:
  transform:
    v: copy
  parameter:
    value: Id
      v: oBmi
target:
  transform:
    v: copy
  parameter:
    value: Id
      v: eBmi
dependent:
  name:
    v: BuildBaseObs
  parameter:
    value: Id
      v: qr
  parameter:
    value: Id
      v: oBmi
  parameter:
    value: Id
      v: eBmi

name:
  v: codeBmi
source:
  context:
    v: qr
target:
  context:
    v: oBmi
  element:
    v: code
  transform:
    v: cc
  parameter:
    value: String
      v: http://loinc.org
  parameter:
    value: String
      v: 39156-5
  parameter:
    value: String
      v: Body mass index (BMI) [Ratio]

name:
  v: valBmi
source:
  context:
    v: aBmi
  element:
    v: value
  variable:
    v: hv
target:
  context:
    v: oBmi
  element:
    v: valueQuantity
  variable:
    v: vBmi
rule:
  name:
    v: setVal
  source:
    context:
      v: hv
  target:
    context:
      v: vBmi
    element:
      v: value
    transform:
      v: copy
    parameter:
      value: Id
        v: hv
rule:
  name:
    v: setSys
  source:
    context:
      v: qr
  target:
    context:
      v: vBmi
    element:
      v: system
    transform:
      v: copy
    parameter:
      value: String
        v: http://unitsofmeasure.org
rule:
  name:
    v: setCode
  source:
    context:
      v: qr
  target:
    context:
      v: vBmi
    element:
      v: code
    transform:
      v: copy
    parameter:
      value: String
        v: kg/m2
rule:
  name:
    v: setUnit
  source:
    context:
      v: qr
  target:
    context:
      v: vBmi
    element:
      v: unit
    transform:
      v: copy
    parameter:
      value: String
        v: kilogram per square meter

name:
  v: findBmiStatus
source:
  context:
    v: itBmi
  element:
    v: item
  variable:
    v: bmiStatusItem
  condition:
    v: (linkId = '39156-5_status')
rule:
  name:
    v: setInterpBmi
  source:
    context:
      v: bmiStatusItem
    element:
      v: answer
    list mode:
      v: first
    variable:
      v: bmiStatusAns
  target:
    context:
      v: oBmi
    element:
      v: interpretation
    variable:
      v: iBmi
  rule:
    name:
      v: interpBmi
    source:
      context:
        v: bmiStatusAns
      element:
        v: value
      variable:
        v: statusText
    target:
      context:
        v: iBmi
      element:
        v: text
      transform:
        v: copy
      parameter:
        value: Id
documentation:
  v: Interpretation 39156-5_status

Id
v: statusText

v: itP

v: answer

v: first

v: aP

v: pulseObs

context:
  v: aP

context:
  v: bundle
element:
  v: entry
variable:
  v: eP

context:
  v: eP
element:
  v: resource
variable:
  v: oP
transform:
  v: create
parameter:
  value: String
    v: Observation

name:
  v: pulseBase
source:
  context:
    v: qr
target:
  transform:
    v: copy
  parameter:
    value: Id
      v: oP
target:
  transform:
    v: copy
  parameter:
    value: Id
      v: eP
dependent:
  name:
    v: BuildBaseObs
  parameter:
    value: Id
      v: qr
  parameter:
    value: Id
      v: oP
  parameter:
    value: Id
      v: eP

name:
  v: codeP
source:
  context:
    v: qr
target:
  context:
    v: oP
  element:
    v: code
  transform:
    v: cc
  parameter:
    value: String
      v: http://loinc.org
  parameter:
    value: String
      v: 8889-8
  parameter:
    value: String
      v: Heart rate by Pulse oximetry

name:
  v: valP
source:
  context:
    v: aP
  element:
    v: value
  variable:
    v: hv
target:
  context:
    v: oP
  element:
    v: valueQuantity
  variable:
    v: vP
rule:
  name:
    v: setVal
  source:
    context:
      v: hv
  target:
    context:
      v: vP
    element:
      v: value
    transform:
      v: copy
    parameter:
      value: Id
        v: hv
rule:
  name:
    v: setSys
  source:
    context:
      v: qr
  target:
    context:
      v: vP
    element:
      v: system
    transform:
      v: copy
    parameter:
      value: String
        v: http://unitsofmeasure.org
rule:
  name:
    v: setCode
  source:
    context:
      v: qr
  target:
    context:
      v: vP
    element:
      v: code
    transform:
      v: copy
    parameter:
      value: String
        v: /min
rule:
  name:
    v: setUnit
  source:
    context:
      v: qr
  target:
    context:
      v: vP
    element:
      v: unit
    transform:
      v: copy
    parameter:
      value: String
        v: per minute

v: itBP

v: answer

v: first

v: aPanel

v: bpObs

context:
  v: aPanel

context:
  v: bundle
element:
  v: entry
variable:
  v: eBP

context:
  v: eBP
element:
  v: resource
variable:
  v: oBP
transform:
  v: create
parameter:
  value: String
    v: Observation

name:
  v: bpBase
source:
  context:
    v: qr
target:
  transform:
    v: copy
  parameter:
    value: Id
      v: oBP
target:
  transform:
    v: copy
  parameter:
    value: Id
      v: eBP
dependent:
  name:
    v: BuildBaseObs
  parameter:
    value: Id
      v: qr
  parameter:
    value: Id
      v: oBP
  parameter:
    value: Id
      v: eBP

name:
  v: codeBP
source:
  context:
    v: qr
target:
  context:
    v: oBP
  element:
    v: code
  transform:
    v: cc
  parameter:
    value: String
      v: http://loinc.org
  parameter:
    value: String
      v: 55284-4
  parameter:
    value: String
      v: Blood pressure systolic and diastolic

name:
  v: bpSysRule
source:
  context:
    v: itBP
  element:
    v: item
  variable:
    v: itSys
  condition:
    v: (linkId = '8480-6')
rule:
  name:
    v: bpSysComponent
  source:
    context:
      v: itSys
    element:
      v: answer
    list mode:
      v: first
    variable:
      v: aSys
  target:
    context:
      v: oBP
    element:
      v: component
    variable:
      v: cSys
  rule:
    name:
      v: bpSysCode
    source:
      context:
        v: aSys
    target:
      context:
        v: cSys
      element:
        v: code
      transform:
        v: cc
      parameter:
        value: String
      parameter:
        value: String
      parameter:
        value: String
  rule:
    name:
      v: bpSysVal
    source:
      context:
        v: aSys
      element:
        v: value
      variable:
        v: hv
    target:
      context:
        v: cSys
      element:
        v: valueQuantity
      variable:
        v: vSys
    rule:
      name:
        v: setVal
    rule:
      name:
        v: setSys
    rule:
      name:
        v: setCode
    rule:
      name:
        v: setUnit
documentation:
  v: Systolic 8480-6

String
v: 8480-6

String
v: Systolic blood pressure

v: hv

v: vSys

v: value

v: copy

value: Id
  v: hv

v: qr

v: vSys

v: system

v: copy

v: qr

v: vSys

v: code

v: copy

value: String
  v: mm[Hg]

v: qr

v: vSys

v: unit

v: copy

value: String
  v: millimeter of mercury

name:
  v: bpDiaRule
source:
  context:
    v: itBP
  element:
    v: item
  variable:
    v: itDia
  condition:
    v: (linkId = '8462-4')
rule:
  name:
    v: bpDiaComponent
  source:
    context:
      v: itDia
    element:
      v: answer
    list mode:
      v: first
    variable:
      v: aDia
  target:
    context:
      v: oBP
    element:
      v: component
    variable:
      v: cDia
  rule:
    name:
      v: bpDiaCode
    source:
      context:
        v: aDia
    target:
      context:
        v: cDia
      element:
        v: code
      transform:
        v: cc
      parameter:
        value: String
      parameter:
        value: String
      parameter:
        value: String
  rule:
    name:
      v: bpDiaVal
    source:
      context:
        v: aDia
      element:
        v: value
      variable:
        v: hv
    target:
      context:
        v: cDia
      element:
        v: valueQuantity
      variable:
        v: vDia
    rule:
      name:
        v: setVal
    rule:
      name:
        v: setSys
    rule:
      name:
        v: setCode
    rule:
      name:
        v: setUnit
documentation:
  v: Diastolic 8462-4

String
v: 8462-4

String
v: Diastolic blood pressure

v: hv

v: vDia

v: value

v: copy

value: Id
  v: hv

v: qr

v: vDia

v: system

v: copy

v: qr

v: vDia

v: code

v: copy

value: String
  v: mm[Hg]

v: qr

v: vDia

v: unit

v: copy

value: String
  v: millimeter of mercury

name:
  v: tempAns
source:
  context:
    v: itT
  element:
    v: answer
  list mode:
    v: first
  variable:
    v: aT
rule:
  name:
    v: tempObs
  source:
    context:
      v: aT
  target:
    context:
      v: bundle
    element:
      v: entry
    variable:
      v: eT
  target:
    context:
      v: eT
    element:
      v: resource
    variable:
      v: oT
    transform:
      v: create
    parameter:
      value: String
        v: Observation
  rule:
    name:
      v: tempBase
    source:
      context:
        v: qr
    target:
      transform:
        v: copy
      parameter:
        value: Id
    target:
      transform:
        v: copy
      parameter:
        value: Id
    dependent:
      name:
        v: BuildBaseObs
      parameter:
        value: Id
      parameter:
        value: Id
      parameter:
        value: Id
  rule:
    name:
      v: codeT
    source:
      context:
        v: qr
    target:
      context:
        v: oT
      element:
        v: code
      transform:
        v: cc
      parameter:
        value: String
      parameter:
        value: String
      parameter:
        value: String
  rule:
    name:
      v: valT
    source:
      context:
        v: aT
      element:
        v: value
      variable:
        v: hv
    target:
      context:
        v: oT
      element:
        v: valueQuantity
      variable:
        v: vT
    rule:
      name:
        v: setVal
    rule:
      name:
        v: setSys
    rule:
      name:
        v: setCode
    rule:
      name:
        v: setUnit
  rule:
    name:
      v: findTStatus
    source:
      context:
        v: itT
      element:
        v: item
      variable:
        v: tStatusItem
      condition:
        v: (linkId = '8310-5_status')
    rule:
      name:
        v: setInterpT
    documentation:
      v: Interpretation 8310-5_status

Id
v: oT

Id
v: eT

Id
v: qr

Id
v: oT

Id
v: eT

String
v: 8310-5

String
v: Body Temperature

v: hv

v: vT

v: value

v: copy

value: Id
  v: hv

v: qr

v: vT

v: system

v: copy

v: qr

v: vT

v: code

v: copy

value: String
  v: Cel

v: qr

v: vT

v: unit

v: copy

value: String
  v: degree Celsius

v: tStatusItem

v: answer

v: first

v: tStatusAns

v: oT

v: interpretation

v: iT

v: interpT

context:
  v: tStatusAns
element:
  v: value
variable:
  v: statusText

context:
  v: iT
element:
  v: text
transform:
  v: copy
parameter:
  value: Id
    v: statusText

v: Temperature

name:
  v: spo2Rule
source:
  context:
    v: qr
  element:
    v: item
  variable:
    v: itO2
  condition:
    v: (linkId = '20564-1')
rule:
  name:
    v: spo2Ans
  source:
    context:
      v: itO2
    element:
      v: answer
    list mode:
      v: first
    variable:
      v: aO2
  rule:
    name:
      v: spo2Obs
    source:
      context:
        v: aO2
    target:
      context:
        v: bundle
      element:
        v: entry
      variable:
        v: eO2
    target:
      context:
        v: eO2
      element:
        v: resource
      variable:
        v: oO2
      transform:
        v: create
      parameter:
        value: String
    rule:
      name:
        v: spo2Base
    rule:
      name:
        v: codeO2
    rule:
      name:
        v: valO2
    rule:
      name:
        v: findO2Status
      documentation:
        v: Interpretation of SpO2 20564-1_status
documentation:
  v: SpO2

String
v: Observation

v: qr

v: copy

value: Id
  v: oO2

v: copy

value: Id
  v: eO2

v: BuildBaseObs

value: Id
  v: qr

value: Id
  v: oO2

value: Id
  v: eO2

v: qr

v: oO2

v: code

v: cc

value: String
  v: 20564-1

value: String
  v: Oxygen saturation in Blood

v: aO2

v: value

v: hv

v: oO2

v: valueQuantity

v: vO2

v: setVal

context:
  v: hv

context:
  v: vO2
element:
  v: value
transform:
  v: copy
parameter:
  value: Id
    v: hv

v: setSys

context:
  v: qr

context:
  v: vO2
element:
  v: system
transform:
  v: copy
parameter:
  value: String
    v: http://unitsofmeasure.org

v: setCode

context:
  v: qr

context:
  v: vO2
element:
  v: code
transform:
  v: copy
parameter:
  value: String
    v: %

v: setUnit

context:
  v: qr

context:
  v: vO2
element:
  v: unit
transform:
  v: copy
parameter:
  value: String
    v: %

v: itO2

v: item

v: o2StatusItem

v: (linkId = '20564-1_status')

v: setInterpO2

context:
  v: o2StatusItem
element:
  v: answer
list mode:
  v: first
variable:
  v: o2StatusAns

context:
  v: oO2
element:
  v: interpretation
variable:
  v: iO2

name:
  v: interpO2
source:
  context:
    v: o2StatusAns
  element:
    v: value
  variable:
    v: statusText
target:
  context:
    v: iO2
  element:
    v: text
  transform:
    v: copy
  parameter:
    value: Id
      v: statusText

name:
  v: rrRule
source:
  context:
    v: qr
  element:
    v: item
  variable:
    v: itRR
  condition:
    v: (linkId = '9279-1')
rule:
  name:
    v: rrAns
  source:
    context:
      v: itRR
    element:
      v: answer
    list mode:
      v: first
    variable:
      v: aRR
  rule:
    name:
      v: rrObs
    source:
      context:
        v: aRR
    target:
      context:
        v: bundle
      element:
        v: entry
      variable:
        v: eRR
    target:
      context:
        v: eRR
      element:
        v: resource
      variable:
        v: oRR
      transform:
        v: create
      parameter:
        value: String
    rule:
      name:
        v: rrBase
    rule:
      name:
        v: codeRR
    rule:
      name:
        v: valRR
documentation:
  v: Respiratory rate

String
v: Observation

v: qr

v: copy

value: Id
  v: oRR

v: copy

value: Id
  v: eRR

v: BuildBaseObs

value: Id
  v: qr

value: Id
  v: oRR

value: Id
  v: eRR

v: qr

v: oRR

v: code

v: cc

value: String
  v: 9279-1

value: String
  v: Respiratory rate

v: aRR

v: value

v: hv

v: oRR

v: valueQuantity

v: vRR

v: setVal

context:
  v: hv

context:
  v: vRR
element:
  v: value
transform:
  v: copy
parameter:
  value: Id
    v: hv

v: setSys

context:
  v: qr

context:
  v: vRR
element:
  v: system
transform:
  v: copy
parameter:
  value: String
    v: http://unitsofmeasure.org

v: setCode

context:
  v: qr

context:
  v: vRR
element:
  v: code
transform:
  v: copy
parameter:
  value: String
    v: /min

v: setUnit

context:
  v: qr

context:
  v: vRR
element:
  v: unit
transform:
  v: copy
parameter:
  value: String
    v: per minute

name:
  v: muacRule
source:
  context:
    v: qr
  element:
    v: item
  variable:
    v: itMuac
  condition:
    v: (linkId = '9847-5')
rule:
  name:
    v: muacAns
  source:
    context:
      v: itMuac
    element:
      v: answer
    list mode:
      v: first
    variable:
      v: aMuac
  rule:
    name:
      v: muacObs
    source:
      context:
        v: aMuac
    target:
      context:
        v: bundle
      element:
        v: entry
      variable:
        v: eMuac
    target:
      context:
        v: eMuac
      element:
        v: resource
      variable:
        v: oMuac
      transform:
        v: create
      parameter:
        value: String
    rule:
      name:
        v: muacBase
    rule:
      name:
        v: codeMuac
    rule:
      name:
        v: valMuac
documentation:
  v: MUAC

String
v: Observation

v: qr

v: copy

value: Id
  v: oMuac

v: copy

value: Id
  v: eMuac

v: BuildBaseObs

value: Id
  v: qr

value: Id
  v: oMuac

value: Id
  v: eMuac

v: qr

v: oMuac

v: code

v: cc

value: String
  v: 9847-5

value: String
  v: Circumference

v: aMuac

v: value

v: hv

v: oMuac

v: valueQuantity

v: vMuac

v: setVal

context:
  v: hv

context:
  v: vMuac
element:
  v: value
transform:
  v: copy
parameter:
  value: Id
    v: hv

v: setSys

context:
  v: qr

context:
  v: vMuac
element:
  v: system
transform:
  v: copy
parameter:
  value: String
    v: http://unitsofmeasure.org

v: setCode

context:
  v: qr

context:
  v: vMuac
element:
  v: code
transform:
  v: copy
parameter:
  value: String
    v: mm

v: setUnit

context:
  v: qr

context:
  v: vMuac
element:
  v: unit
transform:
  v: copy
parameter:
  value: String
    v: millimeter

name:
  v: chiefComplaintRule
source:
  context:
    v: qr
  element:
    v: item
  variable:
    v: itCC
  condition:
    v: (linkId = '10154-3')
rule:
  name:
    v: chiefComplaintAns
  source:
    context:
      v: itCC
    element:
      v: answer
    list mode:
      v: first
    variable:
      v: aCC
  rule:
    name:
      v: chiefComplaintObs
    source:
      context:
        v: aCC
    target:
      context:
        v: bundle
      element:
        v: entry
      variable:
        v: eCC
    target:
      context:
        v: eCC
      element:
        v: resource
      variable:
        v: oCC
      transform:
        v: create
      parameter:
        value: String
    rule:
      name:
        v: chiefComplaintBase
    rule:
      name:
        v: chiefComplaintCategory
      documentation:
        v: Override category to social-history
    rule:
      name:
        v: chiefComplaintCode
    rule:
      name:
        v: chiefComplaintValue
documentation:
  v: Chief Complaint

String
v: Observation

v: qr

v: copy

value: Id
  v: oCC

v: copy

value: Id
  v: eCC

v: BuildBaseObs

value: Id
  v: qr

value: Id
  v: oCC

value: Id
  v: eCC

v: qr

v: oCC

v: category

v: cc

value: String
  v: social-history

value: String
  v: Social History

v: qr

v: oCC

v: code

v: cc

value: String
  v: 10154-3

value: String
  v: Chief complaint Narrative

v: aCC

v: value

v: textVal

v: oCC

v: valueString

v: copy

value: Id
  v: textVal

name:
  v: historyOfPIRule
source:
  context:
    v: qr
  element:
    v: item
  variable:
    v: hpiCC
  condition:
    v: (linkId = '8684-3')
rule:
  name:
    v: historyOfPIAns
  source:
    context:
      v: hpiCC
    element:
      v: answer
    list mode:
      v: first
    variable:
      v: aCC
  rule:
    name:
      v: historyOfPIObs
    source:
      context:
        v: aCC
    target:
      context:
        v: bundle
      element:
        v: entry
      variable:
        v: eCC
    target:
      context:
        v: eCC
      element:
        v: resource
      variable:
        v: oCC
      transform:
        v: create
      parameter:
        value: String
    rule:
      name:
        v: historyOfPIBase
    rule:
      name:
        v: historyOfPICategory
      documentation:
        v: Override category to social-history
    rule:
      name:
        v: historyOfPICode
    rule:
      name:
        v: historyOfPIValue
documentation:
  v: History of Presenting Illness

String
v: Observation

v: qr

v: copy

value: Id
  v: oCC

v: copy

value: Id
  v: eCC

v: BuildBaseObs

value: Id
  v: qr

value: Id
  v: oCC

value: Id
  v: eCC

v: qr

v: oCC

v: category

v: cc

value: String
  v: social-history

value: String
  v: Social History

v: qr

v: oCC

v: code

v: cc

value: String
  v: 8684-3

value: String
  v: History of Present illness

v: aCC

v: value

v: textVal

v: oCC

v: valueString

v: copy

value: Id
  v: textVal

name:
  v: historyOfPastIRule
source:
  context:
    v: qr
  element:
    v: item
  variable:
    v: hPastCC
  condition:
    v: (linkId = '11349-8')
rule:
  name:
    v: historyOfPastIAns
  source:
    context:
      v: hPastCC
    element:
      v: answer
    list mode:
      v: first
    variable:
      v: aCC
  rule:
    name:
      v: historyOfPastIObs
    source:
      context:
        v: aCC
    target:
      context:
        v: bundle
      element:
        v: entry
      variable:
        v: eCC
    target:
      context:
        v: eCC
      element:
        v: resource
      variable:
        v: oCC
      transform:
        v: create
      parameter:
        value: String
    rule:
      name:
        v: historyOfPastIBase
    rule:
      name:
        v: historyOfPastICategory
      documentation:
        v: Override category to social-history
    rule:
      name:
        v: historyOfPastICode
    rule:
      name:
        v: historyOfPastIValue
documentation:
  v: History of Past Illness

String
v: Observation

v: qr

v: copy

value: Id
  v: oCC

v: copy

value: Id
  v: eCC

v: BuildBaseObs

value: Id
  v: qr

value: Id
  v: oCC

value: Id
  v: eCC

v: qr

v: oCC

v: category

v: cc

value: String
  v: social-history

value: String
  v: Social History

v: qr

v: oCC

v: code

v: cc

value: String
  v: 11349-8

value: String
  v: History of Past illness

v: aCC

v: value

v: textVal

v: oCC

v: valueString

v: copy

value: Id
  v: textVal

name:
  v: BuildBaseObs
input:
  name:
    v: qr
  type:
    v: QR
  mode:
    v: source
input:
  name:
    v: obs
  type:
    v: Observation
  mode:
    v: target
input:
  name:
    v: entry
  mode:
    v: target
rule:
  name:
    v: status
  source:
    context:
      v: qr
  target:
    context:
      v: obs
    element:
      v: status
    transform:
      v: copy
    parameter:
      value: String
        v: final
rule:
  name:
    v: subject
  source:
    context:
      v: qr
    element:
      v: subject
    variable:
      v: s
  target:
    context:
      v: obs
    element:
      v: subject
    transform:
      v: copy
    parameter:
      value: Id
        v: s
rule:
  name:
    v: encounter
  source:
    context:
      v: qr
    element:
      v: encounter
    variable:
      v: e
  target:
    context:
      v: obs
    element:
      v: encounter
    transform:
      v: copy
    parameter:
      value: Id
        v: e
rule:
  name:
    v: effective
  source:
    context:
      v: qr
    element:
      v: authored
    variable:
      v: t
  target:
    context:
      v: obs
    element:
      v: effectiveDateTime
    transform:
      v: copy
    parameter:
      value: Id
        v: t
rule:
  name:
    v: category
  source:
    context:
      v: qr
  target:
    context:
      v: obs
    element:
      v: category
    transform:
      v: cc
    parameter:
      value: String
        v: http://terminology.hl7.org/CodeSystem/observation-category
    parameter:
      value: String
        v: vital-signs
    parameter:
      value: String
        v: Vital Signs
  documentation:
    v: Category (vital signs) - defaukt
rule:
  name:
    v: setObsIdAndFullUrl
  source:
    context:
      v: qr
  target:
    context:
      v: obs
    element:
      v: id
    transform:
      v: uuid
  dependent:
    name:
      v: SetObservationFullUrl
    parameter:
      value: Id
        v: obs
    parameter:
      value: Id
        v: entry
  documentation:
    v: Observation id and fullUrl
rule:
  name:
    v: entryRequest
  source:
    context:
      v: qr
  target:
    context:
      v: entry
    element:
      v: request
    variable:
      v: request
  rule:
    name:
      v: reqMethod
    source:
      context:
        v: qr
    target:
      context:
        v: request
      element:
        v: method
      transform:
        v: copy
      parameter:
        value: String
  rule:
    name:
      v: reqUrl
    source:
      context:
        v: qr
    target:
      context:
        v: request
      element:
        v: url
      transform:
        v: copy
      parameter:
        value: String
  documentation:
    v: Bundle.entry.request (transaction POST Observation)
rule:
  name:
    v: linkQR
  source:
    context:
      v: qr
  target:
    context:
      v: obs
    element:
      v: derivedFrom
    variable:
      v: newRef

String
v: POST

String
v: Observation

v: create

value: String
  v: Reference

name:
  v: setQRRef
source:
  context:
    v: qr
  element:
    v: id
  variable:
    v: qid
target:
  context:
    v: newRef
  element:
    v: reference
  transform:
    v: append
  parameter:
    value: String
      v: QuestionnaireResponse/
  parameter:
    value: Id
      v: qid

v: Link Observation -> QuestionnaireResponse

name:
  v: SetObservationFullUrl
input:
  name:
    v: obs
  type:
    v: Observation
  mode:
    v: source
input:
  name:
    v: entry
  mode:
    v: target
rule:
  name:
    v: assignFullUrl
  source:
    context:
      v: obs
    element:
      v: id
    variable:
      v: id
  target:
    context:
      v: entry
    element:
      v: fullUrl
    transform:
      v: append
    parameter:
      value: String
        v: https://fhir.slade360.co.ke/fhir/Observation/
    parameter:
      value: Id
        v: id