ExtractMedicationRequest
type: StructureMap
node role: treeRoot
id:
  v: ExtractMedicationRequest
text:
  status:
    v: generated
  div:
    v: Generated Narrative: StructureMap ExtractMedicationRequest #xD; /// url = 'https://fhir.slade360.co.ke/fhir/StructureMap/ExtractMedicationRequest'#xD; /// name = 'ExtractMedicationRequest'#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/MedicationRequest" alias MedicationRequest as target#xD; uses "http://hl7.org/fhir/StructureDefinition/Medication" alias Medication as target#xD; #xD; group ExtractMedicationRequest(source qr : QR, target bundle : Bundle) {#xD; qr -> bundle.type = 'transaction' "setBundleType";#xD; qr.item as prescriptionGroup where (linkId = 'prescription-form') then {#xD; prescriptionGroup -> bundle.entry as entry, entry.resource = create('MedicationRequest') as medReq then {#xD; qr -> medReq, entry then BuildMedicationRequest(qr, prescriptionGroup, medReq, entry) "buildMedReq";#xD; } "createMedReq";#xD; } "findPrescriptionGroup";#xD; }#xD; #xD; group BuildMedicationRequest(source qr : QR, source prescriptionGroup, target medReq : MedicationRequest, target entry) {#xD; qr -> medReq.status = 'draft' "setStatus"; // status will always be draft until medication has been signed off#xD; qr -> medReq.intent = 'order' "setIntent";#xD; qr.subject as s -> medReq.subject = s "setSubject"; // Subject from QuestionnaireResponse#xD; qr.encounter as enc -> medReq.encounter = enc "setEncounter"; // Encounter from QuestionnaireResponse#xD; qr.authored as authored -> medReq.authoredOn = authored "setAuthoredOn"; // AuthoredOn from QuestionnaireResponse.authored#xD; qr.source as src -> medReq.requester = src "setRequester"; // Requester from QuestionnaireResponse.source (the Organization)#xD; qr.identifier first as qrIdent -> medReq.identifier = qrIdent "copyIdentifier"; // Copy identifier from QuestionnaireResponse to MedicationRequest#xD; qr.extension first as ex…
url:
  v: https://fhir.slade360.co.ke/fhir/StructureMap/ExtractMedicationRequest
  l: ExtractMedicationRequest
version:
  v: 0.1.0
name:
  v: ExtractMedicationRequest
status:
  v: draft
date:
  v: 2026-02-11T13:07:07+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/MedicationRequest
    l: MedicationRequest
  mode:
    v: target
  alias:
    v: MedicationRequest
structure:
  url:
    v: http://hl7.org/fhir/StructureDefinition/Medication
    l: Medication
  mode:
    v: target
  alias:
    v: Medication
group:
  name:
    v: ExtractMedicationRequest
  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: findPrescriptionGroup
    source:
      context:
        v: qr
      element:
        v: item
      variable:
        v: prescriptionGroup
      condition:
        v: (linkId = 'prescription-form')
    rule:
      name:
        v: createMedReq
group:
  name:
    v: BuildMedicationRequest
  input:
    name:
      v: qr
    type:
      v: QR
    mode:
      v: source
  input:
    name:
      v: prescriptionGroup
    mode:
      v: source
  input:
    name:
      v: medReq
    type:
      v: MedicationRequest
    mode:
      v: target
  input:
    name:
      v: entry
    mode:
      v: target
  rule:
    name:
      v: setStatus
    source:
      context:
        v: qr
    target:
      context:
        v: medReq
      element:
        v: status
      transform:
        v: copy
      parameter:
        value: String
    documentation:
      v: status will always be draft until medication has been signed off
  rule:
    name:
      v: setIntent
    source:
      context:
        v: qr
    target:
      context:
        v: medReq
      element:
        v: intent
      transform:
        v: copy
      parameter:
        value: String
  rule:
    name:
      v: setSubject
    source:
      context:
        v: qr
      element:
        v: subject
      variable:
        v: s
    target:
      context:
        v: medReq
      element:
        v: subject
      transform:
        v: copy

String
v: transaction

v: prescriptionGroup

v: bundle

v: entry

v: entry

v: entry

v: resource

v: medReq

v: create

value: String
  v: MedicationRequest

v: buildMedReq

context:
  v: qr

transform:
  v: copy
parameter:
  value: Id
    v: medReq

transform:
  v: copy
parameter:
  value: Id
    v: entry

name:
  v: BuildMedicationRequest
parameter:
  value: Id
    v: qr
parameter:
  value: Id
    v: prescriptionGroup
parameter:
  value: Id
    v: medReq
parameter:
  value: Id
    v: entry

String
v: draft

String
v: order

value: Id
  v: s

v: Subject from QuestionnaireResponse

name:
  v: setEncounter
source:
  context:
    v: qr
  element:
    v: encounter
  variable:
    v: enc
target:
  context:
    v: medReq
  element:
    v: encounter
  transform:
    v: copy
  parameter:
    value: Id
      v: enc
documentation:
  v: Encounter from QuestionnaireResponse

name:
  v: setAuthoredOn
source:
  context:
    v: qr
  element:
    v: authored
  variable:
    v: authored
target:
  context:
    v: medReq
  element:
    v: authoredOn
  transform:
    v: copy
  parameter:
    value: Id
      v: authored
documentation:
  v: AuthoredOn from QuestionnaireResponse.authored

name:
  v: setRequester
source:
  context:
    v: qr
  element:
    v: source
  variable:
    v: src
target:
  context:
    v: medReq
  element:
    v: requester
  transform:
    v: copy
  parameter:
    value: Id
      v: src
documentation:
  v: Requester from QuestionnaireResponse.source (the Organization)

name:
  v: copyIdentifier
source:
  context:
    v: qr
  element:
    v: identifier
  list mode:
    v: first
  variable:
    v: qrIdent
target:
  context:
    v: medReq
  element:
    v: identifier
  transform:
    v: copy
  parameter:
    value: Id
      v: qrIdent
documentation:
  v: Copy identifier from QuestionnaireResponse to MedicationRequest

name:
  v: findMedicationExt
source:
  context:
    v: qr
  element:
    v: extension
  list mode:
    v: first
  variable:
    v: ext
rule:
  name:
    v: accessMedication
  source:
    context:
      v: ext
    element:
      v: valueCodeableConcept
    variable:
      v: medCC
  target:
    context:
      v: medReq
    element:
      v: medication
    variable:
      v: med
  rule:
    name:
      v: setMedConcept
    source:
      context:
        v: medCC
    target:
      context:
        v: med
      element:
        v: concept
      transform:
        v: copy
      parameter:
        value: Id
documentation:
  v: Medication as CodeableReference from QR extension (using concept)

Id
v: medCC

name:
  v: findPriority
source:
  context:
    v: prescriptionGroup
  element:
    v: item
  variable:
    v: priorityItem
  condition:
    v: (linkId = 'priority')
rule:
  name:
    v: extractPriority
  source:
    context:
      v: priorityItem
    element:
      v: answer
    list mode:
      v: first
    variable:
      v: priorityAns
  rule:
    name:
      v: extractPriorityCode
    source:
      context:
        v: priorityAns
      element:
        v: valueCoding
      variable:
        v: priorityCoding
    rule:
      name:
        v: setPriorityCode
documentation:
  v: Priority

v: priorityCoding

v: code

v: pCode

v: medReq

v: priority

v: copy

value: Id
  v: pCode

name:
  v: createDosage
source:
  context:
    v: qr
target:
  context:
    v: medReq
  element:
    v: dosageInstruction
  variable:
    v: dosage
  transform:
    v: create
  parameter:
    value: String
      v: Dosage
rule:
  name:
    v: buildDosage
  source:
    context:
      v: prescriptionGroup
  target:
    transform:
      v: copy
    parameter:
      value: Id
        v: dosage
  dependent:
    name:
      v: BuildDosage
    parameter:
      value: Id
        v: prescriptionGroup
    parameter:
      value: Id
        v: dosage
documentation:
  v: Dosage Instruction

name:
  v: findSubst
source:
  context:
    v: prescriptionGroup
  element:
    v: item
  variable:
    v: substItem
  condition:
    v: (linkId = 'substitutable')
rule:
  name:
    v: extractSubst
  source:
    context:
      v: substItem
    element:
      v: answer
    list mode:
      v: first
    variable:
      v: substAns
  rule:
    name:
      v: createSubst
    source:
      context:
        v: substAns
      element:
        v: valueBoolean
      variable:
        v: substBool
    target:
      context:
        v: medReq
      element:
        v: substitution
      variable:
        v: subst
    rule:
      name:
        v: setSubstValue
documentation:
  v: Substitution

v: substBool

v: subst

v: allowedBoolean

v: copy

value: Id
  v: substBool

name:
  v: createDispReq
source:
  context:
    v: qr
target:
  context:
    v: medReq
  element:
    v: dispenseRequest
  variable:
    v: dispReq
rule:
  name:
    v: buildDispReq
  source:
    context:
      v: prescriptionGroup
  target:
    transform:
      v: copy
    parameter:
      value: Id
        v: dispReq
  dependent:
    name:
      v: BuildDispenseRequest
    parameter:
      value: Id
        v: qr
    parameter:
      value: Id
        v: prescriptionGroup
    parameter:
      value: Id
        v: dispReq
documentation:
  v: Dispense Request

name:
  v: setMedReqIdAndFullUrl
source:
  context:
    v: qr
target:
  context:
    v: medReq
  element:
    v: id
  transform:
    v: uuid
dependent:
  name:
    v: SetMedicationRequestFullUrl
  parameter:
    value: Id
      v: medReq
  parameter:
    value: Id
      v: entry
documentation:
  v: Set ID and FullUrl

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
        v: POST
rule:
  name:
    v: reqUrl
  source:
    context:
      v: qr
  target:
    context:
      v: request
    element:
      v: url
    transform:
      v: copy
    parameter:
      value: String
        v: MedicationRequest
documentation:
  v: Entry request for transaction bundle

name:
  v: BuildDosage
input:
  name:
    v: prescriptionGroup
  mode:
    v: source
input:
  name:
    v: dosage
  type:
    v: Dosage
  mode:
    v: target
rule:
  name:
    v: accessTiming
  source:
    context:
      v: prescriptionGroup
  target:
    context:
      v: dosage
    element:
      v: timing
    variable:
      v: timing
  rule:
    name:
      v: accessRepeat
    source:
      context:
        v: prescriptionGroup
    target:
      context:
        v: timing
      element:
        v: repeat
      variable:
        v: repeat
    rule:
      name:
        v: findFreq
      documentation:
        v: Frequency (OD, BD, TID, QID)
    rule:
      name:
        v: setPeriod
      documentation:
        v: Period (1 day)
    rule:
      name:
        v: setPeriodUnit
    rule:
      name:
        v: findDuration
      documentation:
        v: Duration
    rule:
      name:
        v: findDurUom
      documentation:
        v: Duration UOM - directly use the code from unitsofmeasure.org (h, d, wk, mo, a)
    rule:
      name:
        v: findWhen
      documentation:
        v: When to take - directly use the code (AC, PC, ACM, ACD, ACV, PCM, PCD, PCV, etc.)
    rule:
      name:
        v: findStartDate
      documentation:
        v: Bounds Period from start-date and end-date
rule:
  name:
    v: findRoute
  source:
    context:
      v: prescriptionGroup
    element:
      v: item
    variable:
      v: routeItem
    condition:
      v: (linkId = 'route')
  rule:
    name:
      v: extractRoute
    source:
      context:
        v: routeItem
      element:
        v: answer
      list mode:
        v: first
      variable:
        v: routeAns
    rule:
      name:
        v: setRouteCC
  documentation:
    v: Route
rule:
  name:
    v: findDose
  source:
    context:
      v: prescriptionGroup
    element:
      v: item
    variable:
      v: doseItem
    condition:
      v: (linkId = 'dose')
  rule:
    name:
      v: extractDoseAns
    source:
      context:
        v: doseItem
      element:
        v: answer
      list mode:
        v: first
      variable:
        v: doseAns
    rule:
      name:
        v: createDoseAndRate
  documentation:
    v: Dose and Rate
rule:
  name:
    v: findDosageInstr
  source:
    context:
      v: prescriptionGroup
    element:
      v: item
    variable:
      v: instrItem
    condition:
      v: (linkId = 'dosage-instructions')
  rule:
    name:
      v: extractInstr
    source:
      context:
        v: instrItem
      element:
        v: answer
      list mode:
        v: first
      variable:
        v: instrAns
    rule:
      name:
        v: setPatientInstruction
  documentation:
    v: Dosage Instructions (patient instruction)
rule:
  name:
    v: findAddInstr
  source:
    context:
      v: prescriptionGroup
    element:
      v: item
    variable:
      v: addInstrItem
    condition:
      v: (linkId = 'additional-instructions')
  rule:
    name:
      v: extractAddInstr
    source:
      context:
        v: addInstrItem
      element:
        v: answer
      list mode:
        v: first
      variable:
        v: addInstrAns
    rule:
      name:
        v: setDosageText
  documentation:
    v: Additional Instructions (text)

v: prescriptionGroup

v: item

v: freqItem

v: (linkId = 'frequency')

v: extractFreq

context:
  v: freqItem
element:
  v: answer
list mode:
  v: first
variable:
  v: freqAns

name:
  v: setFreqOD
source:
  context:
    v: freqAns
  element:
    v: valueCoding
  variable:
    v: freqCoding
  condition:
    v: (code = 'OD')
target:
  context:
    v: repeat
  element:
    v: frequency
  transform:
    v: copy
  parameter:
    value: String
      v: 1

name:
  v: setFreqBD
source:
  context:
    v: freqAns
  element:
    v: valueCoding
  variable:
    v: freqCoding
  condition:
    v: (code = 'BD')
target:
  context:
    v: repeat
  element:
    v: frequency
  transform:
    v: copy
  parameter:
    value: String
      v: 2

name:
  v: setFreqTID
source:
  context:
    v: freqAns
  element:
    v: valueCoding
  variable:
    v: freqCoding
  condition:
    v: (code = 'TID')
target:
  context:
    v: repeat
  element:
    v: frequency
  transform:
    v: copy
  parameter:
    value: String
      v: 3

name:
  v: setFreqQID
source:
  context:
    v: freqAns
  element:
    v: valueCoding
  variable:
    v: freqCoding
  condition:
    v: (code = 'QID')
target:
  context:
    v: repeat
  element:
    v: frequency
  transform:
    v: copy
  parameter:
    value: String
      v: 4

v: prescriptionGroup

v: repeat

v: period

v: copy

value: String
  v: 1

v: prescriptionGroup

v: repeat

v: periodUnit

v: copy

value: String
  v: d

v: prescriptionGroup

v: item

v: durItem

v: (linkId = 'duration')

v: extractDuration

context:
  v: durItem
element:
  v: answer
list mode:
  v: first
variable:
  v: durAns

name:
  v: setDuration
source:
  context:
    v: durAns
  element:
    v: valueInteger
  variable:
    v: durValue
target:
  context:
    v: repeat
  element:
    v: duration
  transform:
    v: copy
  parameter:
    value: Id
      v: durValue

v: prescriptionGroup

v: item

v: durUomItem

v: (linkId = 'duration-uom')

v: extractDurUom

context:
  v: durUomItem
element:
  v: answer
list mode:
  v: first
variable:
  v: durUomAns

name:
  v: extractDurUomCode
source:
  context:
    v: durUomAns
  element:
    v: valueCoding
  variable:
    v: durUomCoding
rule:
  name:
    v: setDurationUnit
  source:
    context:
      v: durUomCoding
    element:
      v: code
    variable:
      v: durUomCode
  target:
    context:
      v: repeat
    element:
      v: durationUnit
    transform:
      v: copy
    parameter:
      value: Id
        v: durUomCode

v: prescriptionGroup

v: item

v: whenItem

v: (linkId = 'when-to-take')

v: extractWhen

context:
  v: whenItem
element:
  v: answer
list mode:
  v: first
variable:
  v: whenAns

name:
  v: extractWhenCode
source:
  context:
    v: whenAns
  element:
    v: valueCoding
  variable:
    v: whenCoding
rule:
  name:
    v: setWhenCode
  source:
    context:
      v: whenCoding
    element:
      v: code
    variable:
      v: whenCode
  target:
    context:
      v: repeat
    element:
      v: when
    transform:
      v: copy
    parameter:
      value: Id
        v: whenCode

v: prescriptionGroup

v: item

v: startItem

v: (linkId = 'start-date')

v: extractStartDate

context:
  v: startItem
element:
  v: answer
list mode:
  v: first
variable:
  v: startAns

name:
  v: createBoundsPeriod
source:
  context:
    v: startAns
  element:
    v: valueDate
  variable:
    v: startDate
target:
  context:
    v: repeat
  element:
    v: boundsPeriod
  variable:
    v: boundsPeriod
rule:
  name:
    v: setBoundsStart
  source:
    context:
      v: startDate
  target:
    context:
      v: boundsPeriod
    element:
      v: start
    transform:
      v: copy
    parameter:
      value: Id
        v: startDate
rule:
  name:
    v: findEndDate
  source:
    context:
      v: prescriptionGroup
    element:
      v: item
    variable:
      v: endItem
    condition:
      v: (linkId = 'end-date')
  rule:
    name:
      v: extractEndDate
    source:
      context:
        v: endItem
      element:
        v: answer
      list mode:
        v: first
      variable:
        v: endAns
    rule:
      name:
        v: setBoundsEnd

v: endAns

v: valueDate

v: endDate

v: boundsPeriod

v: end

v: copy

value: Id
  v: endDate

v: routeAns

v: valueCoding

v: routeCoding

v: dosage

v: route

v: routeCC

v: create

value: String
  v: CodeableConcept

v: setRouteCoding

context:
  v: routeCoding

context:
  v: routeCC
element:
  v: coding
transform:
  v: copy
parameter:
  value: Id
    v: routeCoding

v: setRouteText

context:
  v: routeCoding
element:
  v: display
variable:
  v: disp

context:
  v: routeCC
element:
  v: text
transform:
  v: copy
parameter:
  value: Id
    v: disp

v: doseAns

v: valueInteger

v: doseValue

v: dosage

v: doseAndRate

v: doseRate

v: doseRate

v: doseQuantity

v: doseQty

v: setDoseValue

context:
  v: doseValue

context:
  v: doseQty
element:
  v: value
transform:
  v: copy
parameter:
  value: Id
    v: doseValue

v: findDoseUnit

context:
  v: prescriptionGroup
element:
  v: item
variable:
  v: doseUnitItem
condition:
  v: (linkId = 'dosage-unit')

name:
  v: extractDoseUnitAns
source:
  context:
    v: doseUnitItem
  element:
    v: answer
  list mode:
    v: first
  variable:
    v: doseUnitAns
rule:
  name:
    v: extractUnitCoding
  source:
    context:
      v: doseUnitAns
    element:
      v: valueCoding
    variable:
      v: unitCoding
  rule:
    name:
      v: setDoseUnit
    source:
      context:
        v: unitCoding
      element:
        v: display
      variable:
        v: unitDisp
    target:
      context:
        v: doseQty
      element:
        v: unit
      transform:
        v: copy
      parameter:
        value: Id
  rule:
    name:
      v: setDoseCode
    source:
      context:
        v: unitCoding
      element:
        v: code
      variable:
        v: unitCode
    target:
      context:
        v: doseQty
      element:
        v: code
      transform:
        v: copy
      parameter:
        value: Id
  rule:
    name:
      v: setDoseSystem
    source:
      context:
        v: unitCoding
      element:
        v: system
      variable:
        v: unitSys
    target:
      context:
        v: doseQty
      element:
        v: system
      transform:
        v: copy
      parameter:
        value: Id

Id
v: unitDisp

Id
v: unitCode

Id
v: unitSys

v: instrAns

v: valueString

v: instrText

v: dosage

v: patientInstruction

v: copy

value: Id
  v: instrText

v: addInstrAns

v: valueString

v: addInstrText

v: dosage

v: text

v: copy

value: Id
  v: addInstrText

name:
  v: BuildDispenseRequest
input:
  name:
    v: qr
  type:
    v: QR
  mode:
    v: source
input:
  name:
    v: prescriptionGroup
  mode:
    v: source
input:
  name:
    v: dispReq
  mode:
    v: target
rule:
  name:
    v: findRefills
  source:
    context:
      v: prescriptionGroup
    element:
      v: item
    variable:
      v: refillsItem
    condition:
      v: (linkId = 'refills')
  rule:
    name:
      v: extractRefills
    source:
      context:
        v: refillsItem
      element:
        v: answer
      list mode:
        v: first
      variable:
        v: refillsAns
    rule:
      name:
        v: setRefills
  documentation:
    v: Refills
rule:
  name:
    v: findValidityStart
  source:
    context:
      v: prescriptionGroup
    element:
      v: item
    variable:
      v: startItem
    condition:
      v: (linkId = 'start-date')
  rule:
    name:
      v: extractValidityStart
    source:
      context:
        v: startItem
      element:
        v: answer
      list mode:
        v: first
      variable:
        v: startAns
    rule:
      name:
        v: createValidityPeriod
  documentation:
    v: Validity Period from start-date and end-date
rule:
  name:
    v: findSupplyDuration
  source:
    context:
      v: prescriptionGroup
    element:
      v: item
    variable:
      v: durItem
    condition:
      v: (linkId = 'duration')
  rule:
    name:
      v: extractSupplyDuration
    source:
      context:
        v: durItem
      element:
        v: answer
      list mode:
        v: first
      variable:
        v: durAns
    rule:
      name:
        v: createSupplyDuration
  documentation:
    v: Expected Supply Duration
rule:
  name:
    v: setDispenser
  source:
    context:
      v: qr
    element:
      v: source
    variable:
      v: src
  target:
    context:
      v: dispReq
    element:
      v: dispenser
    transform:
      v: copy
    parameter:
      value: Id
        v: src
  documentation:
    v: Dispenser - from QuestionnaireResponse.source (Organization)

v: refillsAns

v: valueInteger

v: refillsValue

v: dispReq

v: numberOfRepeatsAllowed

v: copy

value: Id
  v: refillsValue

v: startAns

v: valueDate

v: startDate

v: dispReq

v: validityPeriod

v: validPeriod

v: setValidityStart

context:
  v: startDate

context:
  v: validPeriod
element:
  v: start
transform:
  v: copy
parameter:
  value: Id
    v: startDate

v: findValidityEnd

context:
  v: prescriptionGroup
element:
  v: item
variable:
  v: endItem
condition:
  v: (linkId = 'end-date')

name:
  v: extractValidityEnd
source:
  context:
    v: endItem
  element:
    v: answer
  list mode:
    v: first
  variable:
    v: endAns
rule:
  name:
    v: setValidityEnd
  source:
    context:
      v: endAns
    element:
      v: valueDate
    variable:
      v: endDate
  target:
    context:
      v: validPeriod
    element:
      v: end
    transform:
      v: copy
    parameter:
      value: Id
        v: endDate

v: durAns

v: valueInteger

v: durValue

v: dispReq

v: expectedSupplyDuration

v: supplyDur

v: setSupplyDurValue

context:
  v: durValue

context:
  v: supplyDur
element:
  v: value
transform:
  v: copy
parameter:
  value: Id
    v: durValue

v: findSupplyDurUom

context:
  v: prescriptionGroup
element:
  v: item
variable:
  v: durUomItem
condition:
  v: (linkId = 'duration-uom')

name:
  v: extractSupplyDurUomAns
source:
  context:
    v: durUomItem
  element:
    v: answer
  list mode:
    v: first
  variable:
    v: durUomAns
rule:
  name:
    v: extractSupplyDurUom
  source:
    context:
      v: durUomAns
    element:
      v: valueCoding
    variable:
      v: durUomCoding
  rule:
    name:
      v: setSupplyDurCode
    source:
      context:
        v: durUomCoding
      element:
        v: code
      variable:
        v: uomCode
    target:
      context:
        v: supplyDur
      element:
        v: code
      transform:
        v: copy
      parameter:
        value: Id
  rule:
    name:
      v: setSupplyDurUnit
    source:
      context:
        v: durUomCoding
      element:
        v: display
      variable:
        v: uomDisplay
    target:
      context:
        v: supplyDur
      element:
        v: unit
      transform:
        v: copy
      parameter:
        value: Id
  rule:
    name:
      v: setSupplyDurSystem
    source:
      context:
        v: durUomCoding
      element:
        v: system
      variable:
        v: uomSystem
    target:
      context:
        v: supplyDur
      element:
        v: system
      transform:
        v: copy
      parameter:
        value: Id

Id
v: uomCode

Id
v: uomDisplay

Id
v: uomSystem

name:
  v: SetMedicationRequestFullUrl
input:
  name:
    v: medReq
  type:
    v: MedicationRequest
  mode:
    v: source
input:
  name:
    v: entry
  mode:
    v: target
rule:
  name:
    v: assignFullUrl
  source:
    context:
      v: medReq
    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/MedicationRequest/
    parameter:
      value: Id
        v: id