SGHI FHIR Profile Implementation Guide
0.1.0 - ci-build

SGHI FHIR Profile Implementation Guide, published by Kathurima Kimathi. This guide is not an authorized publication; it is the continuous build for version 0.1.0 built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of https://github.com/savannahghi/sil_fhir_profile_ig/ and changes regularly. See the Directory of published versions

## : ExtractMedicationRequest - TTL Representation

Draft as of 2026-04-27

Raw ttl | Download

    @prefix fhir: <http://hl7.org/fhir/> .
    @prefix owl: <http://www.w3.org/2002/07/owl#> .
    @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
    @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
    @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

    # - resource -------------------------------------------------------------------

     a fhir:StructureMap ;
      fhir:nodeRole fhir:treeRoot ;
      fhir:id [ fhir:v "ExtractMedicationRequest"] ; #
      fhir:text [
    fhir:status [ fhir:v "generated" ] ;
    fhir:div [ fhir:v "<div xmlns=\"http://www.w3.org/1999/xhtml\"><p class=\"res-header-id\"><b>Generated Narrative: StructureMap ExtractMedicationRequest</b></p><a name=\"ExtractMedicationRequest\"> </a><a name=\"hcExtractMedicationRequest\"> </a><pre class=\"fml\">#xD;\n<span style=\"color: #cc00cc\">/// <b>url</b> = </span><span style=\"color: blue\">'https://fhir.slade360.co.ke/fhir/StructureMap/ExtractMedicationRequest'</span>#xD;\n<span style=\"color: #cc00cc\">/// <b>name</b> = </span><span style=\"color: blue\">'ExtractMedicationRequest'</span>#xD;\n<span style=\"color: #cc00cc\">/// <b>status</b> = </span><span style=\"color: blue\">'draft'</span>#xD;\n#xD;\n<b>uses</b><span style=\"color: navy\"> \"</span><a href=\"http://hl7.org/fhir/R5/questionnaireresponse.html\" title=\"QuestionnaireResponse\">http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse</a><span style=\"color: navy\">\" </span><b>alias </b>QR <b>as </b><b>source</b>#xD;\n<b>uses</b><span style=\"color: navy\"> \"</span><a href=\"http://hl7.org/fhir/R5/bundle.html\" title=\"Bundle\">http://hl7.org/fhir/StructureDefinition/Bundle</a><span style=\"color: navy\">\" </span><b>alias </b>Bundle <b>as </b><b>target</b>#xD;\n<b>uses</b><span style=\"color: navy\"> \"</span><a href=\"http://hl7.org/fhir/R5/medicationrequest.html\" title=\"MedicationRequest\">http://hl7.org/fhir/StructureDefinition/MedicationRequest</a><span style=\"color: navy\">\" </span><b>alias </b>MedicationRequest <b>as </b><b>target</b>#xD;\n<b>uses</b><span style=\"color: navy\"> \"</span><a href=\"http://hl7.org/fhir/R5/medication.html\" title=\"Medication\">http://hl7.org/fhir/StructureDefinition/Medication</a><span style=\"color: navy\">\" </span><b>alias </b>Medication <b>as </b><b>target</b>#xD;\n#xD;\n<b>group </b>ExtractMedicationRequest<span style=\"color: navy\">(</span><b>source</b> <span style=\"color: maroon\">qr</span><span style=\"color: navy\"> : </span>QR, <b>target</b> <span style=\"color: maroon\">bundle</span><span style=\"color: navy\"> : </span>Bundle<span style=\"color: navy\">)</span><span style=\"color: navy\"> {#xD;\n</span>  qr<span style=\"color: navy\"><b> -&gt; </b></span>bundle.type = <span style=\"color: blue\">'transaction'</span> <i>\"setBundleType\"</i><span style=\"color: navy\">;</span>#xD;\n  qr.item<b> as </b><span style=\"color: maroon\">prescriptionGroup</span><b> where </b>(linkId = 'prescription-form')<b> then</b><span style=\"color: navy\"> {#xD;\n</span>    prescriptionGroup<span style=\"color: navy\"><b> -&gt; </b></span> bundle.entry<b> as </b><span style=\"color: maroon\">entry</span><span style=\"color: navy\">, </span> entry.resource = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'MedicationRequest'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">medReq</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>      qr<span style=\"color: navy\"><b> -&gt; </b></span> <span style=\"color: maroon\">medReq</span><span style=\"color: navy\">, </span> <span style=\"color: maroon\">entry</span><b> then </b>BuildMedicationRequest<span style=\"color: navy\">(</span><span style=\"color: maroon\">qr</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">prescriptionGroup</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">medReq</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">entry</span><span style=\"color: navy\">)</span> <i>\"buildMedReq\"</i><span style=\"color: navy\">;</span>#xD;\n    <span style=\"color: navy\">}</span> <i>\"createMedReq\"</i><span style=\"color: navy\">;</span>#xD;\n  <span style=\"color: navy\">}</span> <i>\"findPrescriptionGroup\"</i><span style=\"color: navy\">;</span>#xD;\n<span style=\"color: navy\">}#xD;\n#xD;\n</span><b>group </b>BuildMedicationRequest<span style=\"color: navy\">(</span><b>source</b> <span style=\"color: maroon\">qr</span><span style=\"color: navy\"> : </span>QR, <b>source</b> <span style=\"color: maroon\">prescriptionGroup</span>, <b>target</b> <span style=\"color: maroon\">medReq</span><span style=\"color: navy\"> : </span>MedicationRequest, <b>target</b> <span style=\"color: maroon\">entry</span><span style=\"color: navy\">)</span><span style=\"color: navy\"> {#xD;\n</span>  qr<span style=\"color: navy\"><b> -&gt; </b></span>medReq.status = <span style=\"color: blue\">'draft'</span> <i>\"setStatus\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">status will always be draft until medication has been signed off</span>#xD;\n  qr<span style=\"color: navy\"><b> -&gt; </b></span>medReq.intent = <span style=\"color: blue\">'order'</span> <i>\"setIntent\"</i><span style=\"color: navy\">;</span>#xD;\n  qr.subject<b> as </b><span style=\"color: maroon\">s</span><span style=\"color: navy\"><b> -&gt; </b></span>medReq.subject = <span style=\"color: maroon\">s</span> <i>\"setSubject\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Subject from QuestionnaireResponse</span>#xD;\n  qr.encounter<b> as </b><span style=\"color: maroon\">enc</span><span style=\"color: navy\"><b> -&gt; </b></span>medReq.encounter = <span style=\"color: maroon\">enc</span> <i>\"setEncounter\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Encounter from QuestionnaireResponse</span>#xD;\n  qr.authored<b> as </b><span style=\"color: maroon\">authored</span><span style=\"color: navy\"><b> -&gt; </b></span>medReq.authoredOn = <span style=\"color: maroon\">authored</span> <i>\"setAuthoredOn\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">AuthoredOn from QuestionnaireResponse.authored</span>#xD;\n  qr.source<b> as </b><span style=\"color: maroon\">src</span><span style=\"color: navy\"><b> -&gt; </b></span>medReq.requester = <span style=\"color: maroon\">src</span> <i>\"setRequester\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Requester from QuestionnaireResponse.source (the Organization)</span>#xD;\n  qr.identifier first<b> as </b><span style=\"color: maroon\">qrIdent</span><span style=\"color: navy\"><b> -&gt; </b></span>medReq.identifier = <span style=\"color: maroon\">qrIdent</span> <i>\"copyIdentifier\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Copy identifier from QuestionnaireResponse to MedicationRequest</span>#xD;\n  qr.extension first<b> as </b><span style=\"color: maroon\">ext</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>    ext.valueCodeableConcept<b> as </b><span style=\"color: maroon\">medCC</span><span style=\"color: navy\"><b> -&gt; </b></span>medReq.medication<b> as </b><span style=\"color: maroon\">med</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>      medCC<span style=\"color: navy\"><b> -&gt; </b></span>med.concept = <span style=\"color: maroon\">medCC</span> <i>\"setMedConcept\"</i><span style=\"color: navy\">;</span>#xD;\n    <span style=\"color: navy\">}</span> <i>\"accessMedication\"</i><span style=\"color: navy\">;</span>#xD;\n  <span style=\"color: navy\">}</span> <i>\"findMedicationExt\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Medication as CodeableReference from QR extension (using concept)</span>#xD;\n  prescriptionGroup.item<b> as </b><span style=\"color: maroon\">priorityItem</span><b> where </b>(linkId = 'priority')<b> then</b><span style=\"color: navy\"> {#xD;\n</span>    priorityItem.answer first<b> as </b><span style=\"color: maroon\">priorityAns</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>      priorityAns.valueCoding<b> as </b><span style=\"color: maroon\">priorityCoding</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>        priorityCoding.code<b> as </b><span style=\"color: maroon\">pCode</span><span style=\"color: navy\"><b> -&gt; </b></span>medReq.priority = <span style=\"color: maroon\">pCode</span> <i>\"setPriorityCode\"</i><span style=\"color: navy\">;</span>#xD;\n      <span style=\"color: navy\">}</span> <i>\"extractPriorityCode\"</i><span style=\"color: navy\">;</span>#xD;\n    <span style=\"color: navy\">}</span> <i>\"extractPriority\"</i><span style=\"color: navy\">;</span>#xD;\n  <span style=\"color: navy\">}</span> <i>\"findPriority\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Priority</span>#xD;\n  qr<span style=\"color: navy\"><b> -&gt; </b></span>medReq.dosageInstruction = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'Dosage'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">dosage</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>    prescriptionGroup<span style=\"color: navy\"><b> -&gt; </b></span><span style=\"color: maroon\">dosage</span><b> then </b>BuildDosage<span style=\"color: navy\">(</span><span style=\"color: maroon\">prescriptionGroup</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">dosage</span><span style=\"color: navy\">)</span> <i>\"buildDosage\"</i><span style=\"color: navy\">;</span>#xD;\n  <span style=\"color: navy\">}</span> <i>\"createDosage\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Dosage Instruction</span>#xD;\n  prescriptionGroup.item<b> as </b><span style=\"color: maroon\">substItem</span><b> where </b>(linkId = 'substitutable')<b> then</b><span style=\"color: navy\"> {#xD;\n</span>    substItem.answer first<b> as </b><span style=\"color: maroon\">substAns</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>      substAns.valueBoolean<b> as </b><span style=\"color: maroon\">substBool</span><span style=\"color: navy\"><b> -&gt; </b></span>medReq.substitution<b> as </b><span style=\"color: maroon\">subst</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>        substBool<span style=\"color: navy\"><b> -&gt; </b></span>subst.allowedBoolean = <span style=\"color: maroon\">substBool</span> <i>\"setSubstValue\"</i><span style=\"color: navy\">;</span>#xD;\n      <span style=\"color: navy\">}</span> <i>\"createSubst\"</i><span style=\"color: navy\">;</span>#xD;\n    <span style=\"color: navy\">}</span> <i>\"extractSubst\"</i><span style=\"color: navy\">;</span>#xD;\n  <span style=\"color: navy\">}</span> <i>\"findSubst\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Substitution</span>#xD;\n  qr<span style=\"color: navy\"><b> -&gt; </b></span>medReq.dispenseRequest<b> as </b><span style=\"color: maroon\">dispReq</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>    prescriptionGroup<span style=\"color: navy\"><b> -&gt; </b></span><span style=\"color: maroon\">dispReq</span><b> then </b>BuildDispenseRequest<span style=\"color: navy\">(</span><span style=\"color: maroon\">qr</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">prescriptionGroup</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">dispReq</span><span style=\"color: navy\">)</span> <i>\"buildDispReq\"</i><span style=\"color: navy\">;</span>#xD;\n  <span style=\"color: navy\">}</span> <i>\"createDispReq\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Dispense Request</span>#xD;\n  qr<span style=\"color: navy\"><b> -&gt; </b></span>medReq.id = <b>uuid</b><span style=\"color: navy\">(</span><span style=\"color: navy\">)</span><b> then </b>SetMedicationRequestFullUrl<span style=\"color: navy\">(</span><span style=\"color: maroon\">medReq</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">entry</span><span style=\"color: navy\">)</span> <i>\"setMedReqIdAndFullUrl\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Set ID and FullUrl</span>#xD;\n  qr<span style=\"color: navy\"><b> -&gt; </b></span>entry.request<b> as </b><span style=\"color: maroon\">request</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>    qr<span style=\"color: navy\"><b> -&gt; </b></span>request.method = <span style=\"color: blue\">'POST'</span> <i>\"reqMethod\"</i><span style=\"color: navy\">;</span>#xD;\n    qr<span style=\"color: navy\"><b> -&gt; </b></span>request.url = <span style=\"color: blue\">'MedicationRequest'</span> <i>\"reqUrl\"</i><span style=\"color: navy\">;</span>#xD;\n  <span style=\"color: navy\">}</span> <i>\"entryRequest\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Entry request for transaction bundle</span>#xD;\n<span style=\"color: navy\">}#xD;\n#xD;\n</span><b>group </b>BuildDosage<span style=\"color: navy\">(</span><b>source</b> <span style=\"color: maroon\">prescriptionGroup</span>, <b>target</b> <span style=\"color: maroon\">dosage</span><span style=\"color: navy\"> : </span>Dosage<span style=\"color: navy\">)</span><span style=\"color: navy\"> {#xD;\n</span>  prescriptionGroup<span style=\"color: navy\"><b> -&gt; </b></span>dosage.timing<b> as </b><span style=\"color: maroon\">timing</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>    prescriptionGroup<span style=\"color: navy\"><b> -&gt; </b></span>timing.repeat<b> as </b><span style=\"color: maroon\">repeat</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>      prescriptionGroup.item<b> as </b><span style=\"color: maroon\">freqItem</span><b> where </b>(linkId = 'frequency')<b> then</b><span style=\"color: navy\"> {#xD;\n</span>        freqItem.answer first<b> as </b><span style=\"color: maroon\">freqAns</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>          freqAns.valueCoding<b> as </b><span style=\"color: maroon\">freqCoding</span><b> where </b>(code = 'OD')<span style=\"color: navy\"><b> -&gt; </b></span>repeat.frequency = <span style=\"color: blue\">'1'</span> <i>\"setFreqOD\"</i><span style=\"color: navy\">;</span>#xD;\n          freqAns.valueCoding<b> as </b><span style=\"color: maroon\">freqCoding</span><b> where </b>(code = 'BD')<span style=\"color: navy\"><b> -&gt; </b></span>repeat.frequency = <span style=\"color: blue\">'2'</span> <i>\"setFreqBD\"</i><span style=\"color: navy\">;</span>#xD;\n          freqAns.valueCoding<b> as </b><span style=\"color: maroon\">freqCoding</span><b> where </b>(code = 'TID')<span style=\"color: navy\"><b> -&gt; </b></span>repeat.frequency = <span style=\"color: blue\">'3'</span> <i>\"setFreqTID\"</i><span style=\"color: navy\">;</span>#xD;\n          freqAns.valueCoding<b> as </b><span style=\"color: maroon\">freqCoding</span><b> where </b>(code = 'QID')<span style=\"color: navy\"><b> -&gt; </b></span>repeat.frequency = <span style=\"color: blue\">'4'</span> <i>\"setFreqQID\"</i><span style=\"color: navy\">;</span>#xD;\n        <span style=\"color: navy\">}</span> <i>\"extractFreq\"</i><span style=\"color: navy\">;</span>#xD;\n      <span style=\"color: navy\">}</span> <i>\"findFreq\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Frequency (OD, BD, TID, QID)</span>#xD;\n      prescriptionGroup<span style=\"color: navy\"><b> -&gt; </b></span>repeat.period = <span style=\"color: blue\">'1'</span> <i>\"setPeriod\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Period (1 day)</span>#xD;\n      prescriptionGroup<span style=\"color: navy\"><b> -&gt; </b></span>repeat.periodUnit = <span style=\"color: blue\">'d'</span> <i>\"setPeriodUnit\"</i><span style=\"color: navy\">;</span>#xD;\n      prescriptionGroup.item<b> as </b><span style=\"color: maroon\">durItem</span><b> where </b>(linkId = 'duration')<b> then</b><span style=\"color: navy\"> {#xD;\n</span>        durItem.answer first<b> as </b><span style=\"color: maroon\">durAns</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>          durAns.valueInteger<b> as </b><span style=\"color: maroon\">durValue</span><span style=\"color: navy\"><b> -&gt; </b></span>repeat.duration = <span style=\"color: maroon\">durValue</span> <i>\"setDuration\"</i><span style=\"color: navy\">;</span>#xD;\n        <span style=\"color: navy\">}</span> <i>\"extractDuration\"</i><span style=\"color: navy\">;</span>#xD;\n      <span style=\"color: navy\">}</span> <i>\"findDuration\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Duration</span>#xD;\n      prescriptionGroup.item<b> as </b><span style=\"color: maroon\">durUomItem</span><b> where </b>(linkId = 'duration-uom')<b> then</b><span style=\"color: navy\"> {#xD;\n</span>        durUomItem.answer first<b> as </b><span style=\"color: maroon\">durUomAns</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>          durUomAns.valueCoding<b> as </b><span style=\"color: maroon\">durUomCoding</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>            durUomCoding.code<b> as </b><span style=\"color: maroon\">durUomCode</span><span style=\"color: navy\"><b> -&gt; </b></span>repeat.durationUnit = <span style=\"color: maroon\">durUomCode</span> <i>\"setDurationUnit\"</i><span style=\"color: navy\">;</span>#xD;\n          <span style=\"color: navy\">}</span> <i>\"extractDurUomCode\"</i><span style=\"color: navy\">;</span>#xD;\n        <span style=\"color: navy\">}</span> <i>\"extractDurUom\"</i><span style=\"color: navy\">;</span>#xD;\n      <span style=\"color: navy\">}</span> <i>\"findDurUom\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Duration UOM - directly use the code from unitsofmeasure.org (h, d, wk, mo, a)</span>#xD;\n      prescriptionGroup.item<b> as </b><span style=\"color: maroon\">whenItem</span><b> where </b>(linkId = 'when-to-take')<b> then</b><span style=\"color: navy\"> {#xD;\n</span>        whenItem.answer first<b> as </b><span style=\"color: maroon\">whenAns</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>          whenAns.valueCoding<b> as </b><span style=\"color: maroon\">whenCoding</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>            whenCoding.code<b> as </b><span style=\"color: maroon\">whenCode</span><span style=\"color: navy\"><b> -&gt; </b></span>repeat.when = <span style=\"color: maroon\">whenCode</span> <i>\"setWhenCode\"</i><span style=\"color: navy\">;</span>#xD;\n          <span style=\"color: navy\">}</span> <i>\"extractWhenCode\"</i><span style=\"color: navy\">;</span>#xD;\n        <span style=\"color: navy\">}</span> <i>\"extractWhen\"</i><span style=\"color: navy\">;</span>#xD;\n      <span style=\"color: navy\">}</span> <i>\"findWhen\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">When to take - directly use the code (AC, PC, ACM, ACD, ACV, PCM, PCD, PCV, etc.)</span>#xD;\n      prescriptionGroup.item<b> as </b><span style=\"color: maroon\">startItem</span><b> where </b>(linkId = 'start-date')<b> then</b><span style=\"color: navy\"> {#xD;\n</span>        startItem.answer first<b> as </b><span style=\"color: maroon\">startAns</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>          startAns.valueDate<b> as </b><span style=\"color: maroon\">startDate</span><span style=\"color: navy\"><b> -&gt; </b></span>repeat.boundsPeriod<b> as </b><span style=\"color: maroon\">boundsPeriod</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>            startDate<span style=\"color: navy\"><b> -&gt; </b></span>boundsPeriod.start = <span style=\"color: maroon\">startDate</span> <i>\"setBoundsStart\"</i><span style=\"color: navy\">;</span>#xD;\n            prescriptionGroup.item<b> as </b><span style=\"color: maroon\">endItem</span><b> where </b>(linkId = 'end-date')<b> then</b><span style=\"color: navy\"> {#xD;\n</span>              endItem.answer first<b> as </b><span style=\"color: maroon\">endAns</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>                endAns.valueDate<b> as </b><span style=\"color: maroon\">endDate</span><span style=\"color: navy\"><b> -&gt; </b></span>boundsPeriod.end = <span style=\"color: maroon\">endDate</span> <i>\"setBoundsEnd\"</i><span style=\"color: navy\">;</span>#xD;\n              <span style=\"color: navy\">}</span> <i>\"extractEndDate\"</i><span style=\"color: navy\">;</span>#xD;\n            <span style=\"color: navy\">}</span> <i>\"findEndDate\"</i><span style=\"color: navy\">;</span>#xD;\n          <span style=\"color: navy\">}</span> <i>\"createBoundsPeriod\"</i><span style=\"color: navy\">;</span>#xD;\n        <span style=\"color: navy\">}</span> <i>\"extractStartDate\"</i><span style=\"color: navy\">;</span>#xD;\n      <span style=\"color: navy\">}</span> <i>\"findStartDate\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Bounds Period from start-date and end-date</span>#xD;\n    <span style=\"color: navy\">}</span> <i>\"accessRepeat\"</i><span style=\"color: navy\">;</span>#xD;\n  <span style=\"color: navy\">}</span> <i>\"accessTiming\"</i><span style=\"color: navy\">;</span>#xD;\n  prescriptionGroup.item<b> as </b><span style=\"color: maroon\">routeItem</span><b> where </b>(linkId = 'route')<b> then</b><span style=\"color: navy\"> {#xD;\n</span>    routeItem.answer first<b> as </b><span style=\"color: maroon\">routeAns</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>      routeAns.valueCoding<b> as </b><span style=\"color: maroon\">routeCoding</span><span style=\"color: navy\"><b> -&gt; </b></span>dosage.route = <b>create</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'CodeableConcept'</span><span style=\"color: navy\">)</span><b> as </b><span style=\"color: maroon\">routeCC</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>        routeCoding<span style=\"color: navy\"><b> -&gt; </b></span>routeCC.coding = <span style=\"color: maroon\">routeCoding</span> <i>\"setRouteCoding\"</i><span style=\"color: navy\">;</span>#xD;\n        routeCoding.display<b> as </b><span style=\"color: maroon\">disp</span><span style=\"color: navy\"><b> -&gt; </b></span>routeCC.text = <span style=\"color: maroon\">disp</span> <i>\"setRouteText\"</i><span style=\"color: navy\">;</span>#xD;\n      <span style=\"color: navy\">}</span> <i>\"setRouteCC\"</i><span style=\"color: navy\">;</span>#xD;\n    <span style=\"color: navy\">}</span> <i>\"extractRoute\"</i><span style=\"color: navy\">;</span>#xD;\n  <span style=\"color: navy\">}</span> <i>\"findRoute\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Route</span>#xD;\n  prescriptionGroup.item<b> as </b><span style=\"color: maroon\">doseItem</span><b> where </b>(linkId = 'dose')<b> then</b><span style=\"color: navy\"> {#xD;\n</span>    doseItem.answer first<b> as </b><span style=\"color: maroon\">doseAns</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>      doseAns.valueInteger<b> as </b><span style=\"color: maroon\">doseValue</span><span style=\"color: navy\"><b> -&gt; </b></span> dosage.doseAndRate<b> as </b><span style=\"color: maroon\">doseRate</span><span style=\"color: navy\">, </span> doseRate.doseQuantity<b> as </b><span style=\"color: maroon\">doseQty</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>        doseValue<span style=\"color: navy\"><b> -&gt; </b></span>doseQty.value = <span style=\"color: maroon\">doseValue</span> <i>\"setDoseValue\"</i><span style=\"color: navy\">;</span>#xD;\n        prescriptionGroup.item<b> as </b><span style=\"color: maroon\">doseUnitItem</span><b> where </b>(linkId = 'dosage-unit')<b> then</b><span style=\"color: navy\"> {#xD;\n</span>          doseUnitItem.answer first<b> as </b><span style=\"color: maroon\">doseUnitAns</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>            doseUnitAns.valueCoding<b> as </b><span style=\"color: maroon\">unitCoding</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>              unitCoding.display<b> as </b><span style=\"color: maroon\">unitDisp</span><span style=\"color: navy\"><b> -&gt; </b></span>doseQty.unit = <span style=\"color: maroon\">unitDisp</span> <i>\"setDoseUnit\"</i><span style=\"color: navy\">;</span>#xD;\n              unitCoding.code<b> as </b><span style=\"color: maroon\">unitCode</span><span style=\"color: navy\"><b> -&gt; </b></span>doseQty.code = <span style=\"color: maroon\">unitCode</span> <i>\"setDoseCode\"</i><span style=\"color: navy\">;</span>#xD;\n              unitCoding.system<b> as </b><span style=\"color: maroon\">unitSys</span><span style=\"color: navy\"><b> -&gt; </b></span>doseQty.system = <span style=\"color: maroon\">unitSys</span> <i>\"setDoseSystem\"</i><span style=\"color: navy\">;</span>#xD;\n            <span style=\"color: navy\">}</span> <i>\"extractUnitCoding\"</i><span style=\"color: navy\">;</span>#xD;\n          <span style=\"color: navy\">}</span> <i>\"extractDoseUnitAns\"</i><span style=\"color: navy\">;</span>#xD;\n        <span style=\"color: navy\">}</span> <i>\"findDoseUnit\"</i><span style=\"color: navy\">;</span>#xD;\n      <span style=\"color: navy\">}</span> <i>\"createDoseAndRate\"</i><span style=\"color: navy\">;</span>#xD;\n    <span style=\"color: navy\">}</span> <i>\"extractDoseAns\"</i><span style=\"color: navy\">;</span>#xD;\n  <span style=\"color: navy\">}</span> <i>\"findDose\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Dose and Rate</span>#xD;\n  prescriptionGroup.item<b> as </b><span style=\"color: maroon\">instrItem</span><b> where </b>(linkId = 'dosage-instructions')<b> then</b><span style=\"color: navy\"> {#xD;\n</span>    instrItem.answer first<b> as </b><span style=\"color: maroon\">instrAns</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>      instrAns.valueString<b> as </b><span style=\"color: maroon\">instrText</span><span style=\"color: navy\"><b> -&gt; </b></span>dosage.patientInstruction = <span style=\"color: maroon\">instrText</span> <i>\"setPatientInstruction\"</i><span style=\"color: navy\">;</span>#xD;\n    <span style=\"color: navy\">}</span> <i>\"extractInstr\"</i><span style=\"color: navy\">;</span>#xD;\n  <span style=\"color: navy\">}</span> <i>\"findDosageInstr\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Dosage Instructions (patient instruction)</span>#xD;\n  prescriptionGroup.item<b> as </b><span style=\"color: maroon\">addInstrItem</span><b> where </b>(linkId = 'additional-instructions')<b> then</b><span style=\"color: navy\"> {#xD;\n</span>    addInstrItem.answer first<b> as </b><span style=\"color: maroon\">addInstrAns</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>      addInstrAns.valueString<b> as </b><span style=\"color: maroon\">addInstrText</span><span style=\"color: navy\"><b> -&gt; </b></span>dosage.text = <span style=\"color: maroon\">addInstrText</span> <i>\"setDosageText\"</i><span style=\"color: navy\">;</span>#xD;\n    <span style=\"color: navy\">}</span> <i>\"extractAddInstr\"</i><span style=\"color: navy\">;</span>#xD;\n  <span style=\"color: navy\">}</span> <i>\"findAddInstr\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Additional Instructions (text)</span>#xD;\n<span style=\"color: navy\">}#xD;\n#xD;\n</span><b>group </b>BuildDispenseRequest<span style=\"color: navy\">(</span><b>source</b> <span style=\"color: maroon\">qr</span><span style=\"color: navy\"> : </span>QR, <b>source</b> <span style=\"color: maroon\">prescriptionGroup</span>, <b>target</b> <span style=\"color: maroon\">dispReq</span><span style=\"color: navy\">)</span><span style=\"color: navy\"> {#xD;\n</span>  prescriptionGroup.item<b> as </b><span style=\"color: maroon\">refillsItem</span><b> where </b>(linkId = 'refills')<b> then</b><span style=\"color: navy\"> {#xD;\n</span>    refillsItem.answer first<b> as </b><span style=\"color: maroon\">refillsAns</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>      refillsAns.valueInteger<b> as </b><span style=\"color: maroon\">refillsValue</span><span style=\"color: navy\"><b> -&gt; </b></span>dispReq.numberOfRepeatsAllowed = <span style=\"color: maroon\">refillsValue</span> <i>\"setRefills\"</i><span style=\"color: navy\">;</span>#xD;\n    <span style=\"color: navy\">}</span> <i>\"extractRefills\"</i><span style=\"color: navy\">;</span>#xD;\n  <span style=\"color: navy\">}</span> <i>\"findRefills\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Refills</span>#xD;\n  prescriptionGroup.item<b> as </b><span style=\"color: maroon\">startItem</span><b> where </b>(linkId = 'start-date')<b> then</b><span style=\"color: navy\"> {#xD;\n</span>    startItem.answer first<b> as </b><span style=\"color: maroon\">startAns</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>      startAns.valueDate<b> as </b><span style=\"color: maroon\">startDate</span><span style=\"color: navy\"><b> -&gt; </b></span>dispReq.validityPeriod<b> as </b><span style=\"color: maroon\">validPeriod</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>        startDate<span style=\"color: navy\"><b> -&gt; </b></span>validPeriod.start = <span style=\"color: maroon\">startDate</span> <i>\"setValidityStart\"</i><span style=\"color: navy\">;</span>#xD;\n        prescriptionGroup.item<b> as </b><span style=\"color: maroon\">endItem</span><b> where </b>(linkId = 'end-date')<b> then</b><span style=\"color: navy\"> {#xD;\n</span>          endItem.answer first<b> as </b><span style=\"color: maroon\">endAns</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>            endAns.valueDate<b> as </b><span style=\"color: maroon\">endDate</span><span style=\"color: navy\"><b> -&gt; </b></span>validPeriod.end = <span style=\"color: maroon\">endDate</span> <i>\"setValidityEnd\"</i><span style=\"color: navy\">;</span>#xD;\n          <span style=\"color: navy\">}</span> <i>\"extractValidityEnd\"</i><span style=\"color: navy\">;</span>#xD;\n        <span style=\"color: navy\">}</span> <i>\"findValidityEnd\"</i><span style=\"color: navy\">;</span>#xD;\n      <span style=\"color: navy\">}</span> <i>\"createValidityPeriod\"</i><span style=\"color: navy\">;</span>#xD;\n    <span style=\"color: navy\">}</span> <i>\"extractValidityStart\"</i><span style=\"color: navy\">;</span>#xD;\n  <span style=\"color: navy\">}</span> <i>\"findValidityStart\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Validity Period from start-date and end-date</span>#xD;\n  prescriptionGroup.item<b> as </b><span style=\"color: maroon\">durItem</span><b> where </b>(linkId = 'duration')<b> then</b><span style=\"color: navy\"> {#xD;\n</span>    durItem.answer first<b> as </b><span style=\"color: maroon\">durAns</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>      durAns.valueInteger<b> as </b><span style=\"color: maroon\">durValue</span><span style=\"color: navy\"><b> -&gt; </b></span>dispReq.expectedSupplyDuration<b> as </b><span style=\"color: maroon\">supplyDur</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>        durValue<span style=\"color: navy\"><b> -&gt; </b></span>supplyDur.value = <span style=\"color: maroon\">durValue</span> <i>\"setSupplyDurValue\"</i><span style=\"color: navy\">;</span>#xD;\n        prescriptionGroup.item<b> as </b><span style=\"color: maroon\">durUomItem</span><b> where </b>(linkId = 'duration-uom')<b> then</b><span style=\"color: navy\"> {#xD;\n</span>          durUomItem.answer first<b> as </b><span style=\"color: maroon\">durUomAns</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>            durUomAns.valueCoding<b> as </b><span style=\"color: maroon\">durUomCoding</span><b> then</b><span style=\"color: navy\"> {#xD;\n</span>              durUomCoding.code<b> as </b><span style=\"color: maroon\">uomCode</span><span style=\"color: navy\"><b> -&gt; </b></span>supplyDur.code = <span style=\"color: maroon\">uomCode</span> <i>\"setSupplyDurCode\"</i><span style=\"color: navy\">;</span>#xD;\n              durUomCoding.display<b> as </b><span style=\"color: maroon\">uomDisplay</span><span style=\"color: navy\"><b> -&gt; </b></span>supplyDur.unit = <span style=\"color: maroon\">uomDisplay</span> <i>\"setSupplyDurUnit\"</i><span style=\"color: navy\">;</span>#xD;\n              durUomCoding.system<b> as </b><span style=\"color: maroon\">uomSystem</span><span style=\"color: navy\"><b> -&gt; </b></span>supplyDur.system = <span style=\"color: maroon\">uomSystem</span> <i>\"setSupplyDurSystem\"</i><span style=\"color: navy\">;</span>#xD;\n            <span style=\"color: navy\">}</span> <i>\"extractSupplyDurUom\"</i><span style=\"color: navy\">;</span>#xD;\n          <span style=\"color: navy\">}</span> <i>\"extractSupplyDurUomAns\"</i><span style=\"color: navy\">;</span>#xD;\n        <span style=\"color: navy\">}</span> <i>\"findSupplyDurUom\"</i><span style=\"color: navy\">;</span>#xD;\n      <span style=\"color: navy\">}</span> <i>\"createSupplyDuration\"</i><span style=\"color: navy\">;</span>#xD;\n    <span style=\"color: navy\">}</span> <i>\"extractSupplyDuration\"</i><span style=\"color: navy\">;</span>#xD;\n  <span style=\"color: navy\">}</span> <i>\"findSupplyDuration\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Expected Supply Duration</span>#xD;\n  qr.source<b> as </b><span style=\"color: maroon\">src</span><span style=\"color: navy\"><b> -&gt; </b></span>dispReq.dispenser = <span style=\"color: maroon\">src</span> <i>\"setDispenser\"</i><span style=\"color: navy\">;</span> <span style=\"color: navy\">// </span><span style=\"color: green\">Dispenser - from QuestionnaireResponse.source (Organization)</span>#xD;\n<span style=\"color: navy\">}#xD;\n#xD;\n</span><b>group </b>SetMedicationRequestFullUrl<span style=\"color: navy\">(</span><b>source</b> <span style=\"color: maroon\">medReq</span><span style=\"color: navy\"> : </span>MedicationRequest, <b>target</b> <span style=\"color: maroon\">entry</span><span style=\"color: navy\">)</span><span style=\"color: navy\"> {#xD;\n</span>  medReq.id<b> as </b><span style=\"color: maroon\">id</span><span style=\"color: navy\"><b> -&gt; </b></span>entry.fullUrl = <b>append</b><span style=\"color: navy\">(</span><span style=\"color: blue\">'https://fhir.slade360.co.ke/fhir/MedicationRequest/'</span><span style=\"color: navy\">, </span><span style=\"color: maroon\">id</span><span style=\"color: navy\">)</span> <i>\"assignFullUrl\"</i><span style=\"color: navy\">;</span>#xD;\n<span style=\"color: navy\">}#xD;\n#xD;\n</span></pre></div>"^^rdf:XMLLiteral ]
      ] ; #
      fhir:url [
    fhir:v "https://fhir.slade360.co.ke/fhir/StructureMap/ExtractMedicationRequest"^^xsd:anyURI ;
    fhir:l <https://fhir.slade360.co.ke/fhir/StructureMap/ExtractMedicationRequest>
      ] ; #
      fhir:version [ fhir:v "0.1.0"] ; #
      fhir:name [ fhir:v "ExtractMedicationRequest"] ; #
      fhir:status [ fhir:v "draft"] ; #
      fhir:date [ fhir:v "2026-04-27T09:21:43+00:00"^^xsd:dateTime] ; #
      fhir:publisher [ fhir:v "Kathurima Kimathi"] ; #
      fhir:contact ( [
    fhir:name [ fhir:v "Kathurima Kimathi" ] ;
        ( fhir:telecom [
    fhir:system [ fhir:v "url" ] ;
    fhir:value [ fhir:v "https://www.linkedin.com/in/kathurima-kimathi/" ]     ] [
    fhir:system [ fhir:v "email" ] ;
    fhir:value [ fhir:v "kathurimakimathi415@gmail.com" ]     ] )
      ] [
    fhir:name [ fhir:v "Oscar John" ] ;
        ( fhir:telecom [
    fhir:system [ fhir:v "email" ] ;
    fhir:value [ fhir:v "oscarjohnotieno@gmail.com" ] ;
    fhir:use [ fhir:v "work" ]     ] )
      ] [
    fhir:name [ fhir:v "Kennedy Omondi" ] ;
        ( fhir:telecom [
    fhir:system [ fhir:v "email" ] ;
    fhir:value [ fhir:v "kennankole@gmail.com" ] ;
    fhir:use [ fhir:v "work" ]     ] )
      ] ) ; #
      fhir:structure ( [
    fhir:url [
    fhir:v "http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse"^^xsd:anyURI ;
    fhir:l <http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse>     ] ;
    fhir:mode [ fhir:v "source" ] ;
    fhir:alias [ fhir:v "QR" ]
      ] [
    fhir:url [
    fhir:v "http://hl7.org/fhir/StructureDefinition/Bundle"^^xsd:anyURI ;
    fhir:l <http://hl7.org/fhir/StructureDefinition/Bundle>     ] ;
    fhir:mode [ fhir:v "target" ] ;
    fhir:alias [ fhir:v "Bundle" ]
      ] [
    fhir:url [
    fhir:v "http://hl7.org/fhir/StructureDefinition/MedicationRequest"^^xsd:anyURI ;
    fhir:l <http://hl7.org/fhir/StructureDefinition/MedicationRequest>     ] ;
    fhir:mode [ fhir:v "target" ] ;
    fhir:alias [ fhir:v "MedicationRequest" ]
      ] [
    fhir:url [
    fhir:v "http://hl7.org/fhir/StructureDefinition/Medication"^^xsd:anyURI ;
    fhir:l <http://hl7.org/fhir/StructureDefinition/Medication>     ] ;
    fhir:mode [ fhir:v "target" ] ;
    fhir:alias [ fhir:v "Medication" ]
      ] ) ; #
      fhir:group ( [
    fhir:name [ fhir:v "ExtractMedicationRequest" ] ;
        ( fhir:input [
    fhir:name [ fhir:v "qr" ] ;
    fhir:type [ fhir:v "QR" ] ;
    fhir:mode [ fhir:v "source" ]     ] [
    fhir:name [ fhir:v "bundle" ] ;
    fhir:type [ fhir:v "Bundle" ] ;
    fhir:mode [ fhir:v "target" ]     ] ) ;
        ( fhir:rule [
    fhir:name [ fhir:v "setBundleType" ] ;
          ( fhir:source [
    fhir:context [ fhir:v "qr" ]       ] ) ;
          ( fhir:target [
    fhir:context [ fhir:v "bundle" ] ;
    fhir:element [ fhir:v "type" ] ;
    fhir:transform [ fhir:v "copy" ] ;
            ( fhir:parameter [
    fhir:value [
    a fhir:String ;
    fhir:v "transaction"           ]         ] )       ] )     ] [
    fhir:name [ fhir:v "findPrescriptionGroup" ] ;
          ( fhir:source [
    fhir:context [ fhir:v "qr" ] ;
    fhir:element [ fhir:v "item" ] ;
    fhir:variable [ fhir:v "prescriptionGroup" ] ;
    fhir:condition [ fhir:v "(linkId = 'prescription-form')" ]       ] ) ;
          ( fhir:rule [
    fhir:name [ fhir:v "createMedReq" ] ;
            ( fhir:source [
    fhir:context [ fhir:v "prescriptionGroup" ]         ] ) ;
            ( fhir:target [
    fhir:context [ fhir:v "bundle" ] ;
    fhir:element [ fhir:v "entry" ] ;
    fhir:variable [ fhir:v "entry" ]         ] [
    fhir:context [ fhir:v "entry" ] ;
    fhir:element [ fhir:v "resource" ] ;
    fhir:variable [ fhir:v "medReq" ] ;
    fhir:transform [ fhir:v "create" ] ;
              ( fhir:parameter [
    fhir:value [
    a fhir:String ;
    fhir:v "MedicationRequest"             ]           ] )         ] ) ;
            ( fhir:rule [
    fhir:name [ fhir:v "buildMedReq" ] ;
              ( fhir:source [
    fhir:context [ fhir:v "qr" ]           ] ) ;
              ( fhir:target [
    fhir:transform [ fhir:v "copy" ] ;
                ( fhir:parameter [
    fhir:value [
    a fhir:Id ;
    fhir:v "medReq"               ]             ] )           ] [
    fhir:transform [ fhir:v "copy" ] ;
                ( fhir:parameter [
    fhir:value [
    a fhir:Id ;
    fhir:v "entry"               ]             ] )           ] ) ;
              ( fhir:dependent [
    fhir:name [ fhir:v "BuildMedicationRequest" ] ;
                ( fhir:parameter [
    fhir:value [
    a fhir:Id ;
    fhir:v "qr"               ]             ] [
    fhir:value [
    a fhir:Id ;
    fhir:v "prescriptionGroup"               ]             ] [
    fhir:value [
    a fhir:Id ;
    fhir:v "medReq"               ]             ] [
    fhir:value [
    a fhir:Id ;
    fhir:v "entry"               ]             ] )           ] )         ] )       ] )     ] )
      ] [
    fhir:name [ fhir:v "BuildMedicationRequest" ] ;
        ( fhir:input [
    fhir:name [ fhir:v "qr" ] ;
    fhir:type [ fhir:v "QR" ] ;
    fhir:mode [ fhir:v "source" ]     ] [
    fhir:name [ fhir:v "prescriptionGroup" ] ;
    fhir:mode [ fhir:v "source" ]     ] [
    fhir:name [ fhir:v "medReq" ] ;
    fhir:type [ fhir:v "MedicationRequest" ] ;
    fhir:mode [ fhir:v "target" ]     ] [
    fhir:name [ fhir:v "entry" ] ;
    fhir:mode [ fhir:v "target" ]     ] ) ;
        ( fhir:rule [
    fhir:name [ fhir:v "setStatus" ] ;
          ( fhir:source [
    fhir:context [ fhir:v "qr" ]       ] ) ;
          ( fhir:target [
    fhir:context [ fhir:v "medReq" ] ;
    fhir:element [ fhir:v "status" ] ;
    fhir:transform [ fhir:v "copy" ] ;
            ( fhir:parameter [
    fhir:value [
    a fhir:String ;
    fhir:v "draft"           ]         ] )       ] ) ;
    fhir:documentation [ fhir:v "status will always be draft until medication has been signed off" ]     ] [
    fhir:name [ fhir:v "setIntent" ] ;
          ( fhir:source [
    fhir:context [ fhir:v "qr" ]       ] ) ;
          ( fhir:target [
    fhir:context [ fhir:v "medReq" ] ;
    fhir:element [ fhir:v "intent" ] ;
    fhir:transform [ fhir:v "copy" ] ;
            ( fhir:parameter [
    fhir:value [
    a fhir:String ;
    fhir:v "order"           ]         ] )       ] )     ] [
    fhir:name [ fhir:v "setSubject" ] ;
          ( fhir:source [
    fhir:context [ fhir:v "qr" ] ;
    fhir:element [ fhir:v "subject" ] ;
    fhir:variable [ fhir:v "s" ]       ] ) ;
          ( fhir:target [
    fhir:context [ fhir:v "medReq" ] ;
    fhir:element [ fhir:v "subject" ] ;
    fhir:transform [ fhir:v "copy" ] ;
            ( fhir:parameter [
    fhir:value [
    a fhir:Id ;
    fhir:v "s"           ]         ] )       ] ) ;
    fhir:documentation [ fhir:v "Subject from QuestionnaireResponse" ]     ] [
    fhir:name [ fhir:v "setEncounter" ] ;
          ( fhir:source [
    fhir:context [ fhir:v "qr" ] ;
    fhir:element [ fhir:v "encounter" ] ;
    fhir:variable [ fhir:v "enc" ]       ] ) ;
          ( fhir:target [
    fhir:context [ fhir:v "medReq" ] ;
    fhir:element [ fhir:v "encounter" ] ;
    fhir:transform [ fhir:v "copy" ] ;
            ( fhir:parameter [
    fhir:value [
    a fhir:Id ;
    fhir:v "enc"           ]         ] )       ] ) ;
    fhir:documentation [ fhir:v "Encounter from QuestionnaireResponse" ]     ] [
    fhir:name [ fhir:v "setAuthoredOn" ] ;
          ( fhir:source [
    fhir:context [ fhir:v "qr" ] ;
    fhir:element [ fhir:v "authored" ] ;
    fhir:variable [ fhir:v "authored" ]       ] ) ;
          ( fhir:target [
    fhir:context [ fhir:v "medReq" ] ;
    fhir:element [ fhir:v "authoredOn" ] ;
    fhir:transform [ fhir:v "copy" ] ;
            ( fhir:parameter [
    fhir:value [
    a fhir:Id ;
    fhir:v "authored"           ]         ] )       ] ) ;
    fhir:documentation [ fhir:v "AuthoredOn from QuestionnaireResponse.authored" ]     ] [
    fhir:name [ fhir:v "setRequester" ] ;
          ( fhir:source [
    fhir:context [ fhir:v "qr" ] ;
    fhir:element [ fhir:v "source" ] ;
    fhir:variable [ fhir:v "src" ]       ] ) ;
          ( fhir:target [
    fhir:context [ fhir:v "medReq" ] ;
    fhir:element [ fhir:v "requester" ] ;
    fhir:transform [ fhir:v "copy" ] ;
            ( fhir:parameter [
    fhir:value [
    a fhir:Id ;
    fhir:v "src"           ]         ] )       ] ) ;
    fhir:documentation [ fhir:v "Requester from QuestionnaireResponse.source (the Organization)" ]     ] [
    fhir:name [ fhir:v "copyIdentifier" ] ;
          ( fhir:source [
    fhir:context [ fhir:v "qr" ] ;
    fhir:element [ fhir:v "identifier" ] ;
    fhir:listMode [ fhir:v "first" ] ;
    fhir:variable [ fhir:v "qrIdent" ]       ] ) ;
          ( fhir:target [
    fhir:context [ fhir:v "medReq" ] ;
    fhir:element [ fhir:v "identifier" ] ;
    fhir:transform [ fhir:v "copy" ] ;
            ( fhir:parameter [
    fhir:value [
    a fhir:Id ;
    fhir:v "qrIdent"           ]         ] )       ] ) ;
    fhir:documentation [ fhir:v "Copy identifier from QuestionnaireResponse to MedicationRequest" ]     ] [
    fhir:name [ fhir:v "findMedicationExt" ] ;
          ( fhir:source [
    fhir:context [ fhir:v "qr" ] ;
    fhir:element [ fhir:v "extension" ] ;
    fhir:listMode [ fhir:v "first" ] ;
    fhir:variable [ fhir:v "ext" ]       ] ) ;
          ( fhir:rule [
    fhir:name [ fhir:v "accessMedication" ] ;
            ( fhir:source [
    fhir:context [ fhir:v "ext" ] ;
    fhir:element [ fhir:v "valueCodeableConcept" ] ;
    fhir:variable [ fhir:v "medCC" ]         ] ) ;
            ( fhir:target [
    fhir:context [ fhir:v "medReq" ] ;
    fhir:element [ fhir:v "medication" ] ;
    fhir:variable [ fhir:v "med" ]         ] ) ;
            ( fhir:rule [
    fhir:name [ fhir:v "setMedConcept" ] ;
              ( fhir:source [
    fhir:context [ fhir:v "medCC" ]           ] ) ;
              ( fhir:target [
    fhir:context [ fhir:v "med" ] ;
    fhir:element [ fhir:v "concept" ] ;
    fhir:transform [ fhir:v "copy" ] ;
                ( fhir:parameter [
    fhir:value [
    a fhir:Id ;
    fhir:v "medCC"               ]             ] )           ] )         ] )       ] ) ;
    fhir:documentation [ fhir:v "Medication as CodeableReference from QR extension (using concept)" ]     ] [
    fhir:name [ fhir:v "findPriority" ] ;
          ( fhir:source [
    fhir:context [ fhir:v "prescriptionGroup" ] ;
    fhir:element [ fhir:v "item" ] ;
    fhir:variable [ fhir:v "priorityItem" ] ;
    fhir:condition [ fhir:v "(linkId = 'priority')" ]       ] ) ;
          ( fhir:rule [
    fhir:name [ fhir:v "extractPriority" ] ;
            ( fhir:source [
    fhir:context [ fhir:v "priorityItem" ] ;
    fhir:element [ fhir:v "answer" ] ;
    fhir:listMode [ fhir:v "first" ] ;
    fhir:variable [ fhir:v "priorityAns" ]         ] ) ;
            ( fhir:rule [
    fhir:name [ fhir:v "extractPriorityCode" ] ;
              ( fhir:source [
    fhir:context [ fhir:v "priorityAns" ] ;
    fhir:element [ fhir:v "valueCoding" ] ;
    fhir:variable [ fhir:v "priorityCoding" ]           ] ) ;
              ( fhir:rule [
    fhir:name [ fhir:v "setPriorityCode" ] ;
                ( fhir:source [
    fhir:context [ fhir:v "priorityCoding" ] ;
    fhir:element [ fhir:v "code" ] ;
    fhir:variable [ fhir:v "pCode" ]             ] ) ;
                ( fhir:target [
    fhir:context [ fhir:v "medReq" ] ;
    fhir:element [ fhir:v "priority" ] ;
    fhir:transform [ fhir:v "copy" ] ;
                  ( fhir:parameter [
    fhir:value [
    a fhir:Id ;
    fhir:v "pCode"                 ]               ] )             ] )           ] )         ] )       ] ) ;
    fhir:documentation [ fhir:v "Priority" ]     ] [
    fhir:name [ fhir:v "createDosage" ] ;
          ( fhir:source [
    fhir:context [ fhir:v "qr" ]       ] ) ;
          ( fhir:target [
    fhir:context [ fhir:v "medReq" ] ;
    fhir:element [ fhir:v "dosageInstruction" ] ;
    fhir:variable [ fhir:v "dosage" ] ;
    fhir:transform [ fhir:v "create" ] ;
            ( fhir:parameter [
    fhir:value [
    a fhir:String ;
    fhir:v "Dosage"           ]         ] )       ] ) ;
          ( fhir:rule [
    fhir:name [ fhir:v "buildDosage" ] ;
            ( fhir:source [
    fhir:context [ fhir:v "prescriptionGroup" ]         ] ) ;
            ( fhir:target [
    fhir:transform [ fhir:v "copy" ] ;
              ( fhir:parameter [
    fhir:value [
    a fhir:Id ;
    fhir:v "dosage"             ]           ] )         ] ) ;
            ( fhir:dependent [
    fhir:name [ fhir:v "BuildDosage" ] ;
              ( fhir:parameter [
    fhir:value [
    a fhir:Id ;
    fhir:v "prescriptionGroup"             ]           ] [
    fhir:value [
    a fhir:Id ;
    fhir:v "dosage"             ]           ] )         ] )       ] ) ;
    fhir:documentation [ fhir:v "Dosage Instruction" ]     ] [
    fhir:name [ fhir:v "findSubst" ] ;
          ( fhir:source [
    fhir:context [ fhir:v "prescriptionGroup" ] ;
    fhir:element [ fhir:v "item" ] ;
    fhir:variable [ fhir:v "substItem" ] ;
    fhir:condition [ fhir:v "(linkId = 'substitutable')" ]       ] ) ;
          ( fhir:rule [
    fhir:name [ fhir:v "extractSubst" ] ;
            ( fhir:source [
    fhir:context [ fhir:v "substItem" ] ;
    fhir:element [ fhir:v "answer" ] ;
    fhir:listMode [ fhir:v "first" ] ;
    fhir:variable [ fhir:v "substAns" ]         ] ) ;
            ( fhir:rule [
    fhir:name [ fhir:v "createSubst" ] ;
              ( fhir:source [
    fhir:context [ fhir:v "substAns" ] ;
    fhir:element [ fhir:v "valueBoolean" ] ;
    fhir:variable [ fhir:v "substBool" ]           ] ) ;
              ( fhir:target [
    fhir:context [ fhir:v "medReq" ] ;
    fhir:element [ fhir:v "substitution" ] ;
    fhir:variable [ fhir:v "subst" ]           ] ) ;
              ( fhir:rule [
    fhir:name [ fhir:v "setSubstValue" ] ;
                ( fhir:source [
    fhir:context [ fhir:v "substBool" ]             ] ) ;
                ( fhir:target [
    fhir:context [ fhir:v "subst" ] ;
    fhir:element [ fhir:v "allowedBoolean" ] ;
    fhir:transform [ fhir:v "copy" ] ;
                  ( fhir:parameter [
    fhir:value [
    a fhir:Id ;
    fhir:v "substBool"                 ]               ] )             ] )           ] )         ] )       ] ) ;
    fhir:documentation [ fhir:v "Substitution" ]     ] [
    fhir:name [ fhir:v "createDispReq" ] ;
          ( fhir:source [
    fhir:context [ fhir:v "qr" ]       ] ) ;
          ( fhir:target [
    fhir:context [ fhir:v "medReq" ] ;
    fhir:element [ fhir:v "dispenseRequest" ] ;
    fhir:variable [ fhir:v "dispReq" ]       ] ) ;
          ( fhir:rule [
    fhir:name [ fhir:v "buildDispReq" ] ;
            ( fhir:source [
    fhir:context [ fhir:v "prescriptionGroup" ]         ] ) ;
            ( fhir:target [
    fhir:transform [ fhir:v "copy" ] ;
              ( fhir:parameter [
    fhir:value [
    a fhir:Id ;
    fhir:v "dispReq"             ]           ] )         ] ) ;
            ( fhir:dependent [
    fhir:name [ fhir:v "BuildDispenseRequest" ] ;
              ( fhir:parameter [
    fhir:value [
    a fhir:Id ;
    fhir:v "qr"             ]           ] [
    fhir:value [
    a fhir:Id ;
    fhir:v "prescriptionGroup"             ]           ] [
    fhir:value [
    a fhir:Id ;
    fhir:v "dispReq"             ]           ] )         ] )       ] ) ;
    fhir:documentation [ fhir:v "Dispense Request" ]     ] [
    fhir:name [ fhir:v "setMedReqIdAndFullUrl" ] ;
          ( fhir:source [
    fhir:context [ fhir:v "qr" ]       ] ) ;
          ( fhir:target [
    fhir:context [ fhir:v "medReq" ] ;
    fhir:element [ fhir:v "id" ] ;
    fhir:transform [ fhir:v "uuid" ]       ] ) ;
          ( fhir:dependent [
    fhir:name [ fhir:v "SetMedicationRequestFullUrl" ] ;
            ( fhir:parameter [
    fhir:value [
    a fhir:Id ;
    fhir:v "medReq"           ]         ] [
    fhir:value [
    a fhir:Id ;
    fhir:v "entry"           ]         ] )       ] ) ;
    fhir:documentation [ fhir:v "Set ID and FullUrl" ]     ] [
    fhir:name [ fhir:v "entryRequest" ] ;
          ( fhir:source [
    fhir:context [ fhir:v "qr" ]       ] ) ;
          ( fhir:target [
    fhir:context [ fhir:v "entry" ] ;
    fhir:element [ fhir:v "request" ] ;
    fhir:variable [ fhir:v "request" ]       ] ) ;
          ( fhir:rule [
    fhir:name [ fhir:v "reqMethod" ] ;
            ( fhir:source [
    fhir:context [ fhir:v "qr" ]         ] ) ;
            ( fhir:target [
    fhir:context [ fhir:v "request" ] ;
    fhir:element [ fhir:v "method" ] ;
    fhir:transform [ fhir:v "copy" ] ;
              ( fhir:parameter [
    fhir:value [
    a fhir:String ;
    fhir:v "POST"             ]           ] )         ] )       ] [
    fhir:name [ fhir:v "reqUrl" ] ;
            ( fhir:source [
    fhir:context [ fhir:v "qr" ]         ] ) ;
            ( fhir:target [
    fhir:context [ fhir:v "request" ] ;
    fhir:element [ fhir:v "url" ] ;
    fhir:transform [ fhir:v "copy" ] ;
              ( fhir:parameter [
    fhir:value [
    a fhir:String ;
    fhir:v "MedicationRequest"             ]           ] )         ] )       ] ) ;
    fhir:documentation [ fhir:v "Entry request for transaction bundle" ]     ] )
      ] [
    fhir:name [ fhir:v "BuildDosage" ] ;
        ( fhir:input [
    fhir:name [ fhir:v "prescriptionGroup" ] ;
    fhir:mode [ fhir:v "source" ]     ] [
    fhir:name [ fhir:v "dosage" ] ;
    fhir:type [ fhir:v "Dosage" ] ;
    fhir:mode [ fhir:v "target" ]     ] ) ;
        ( fhir:rule [
    fhir:name [ fhir:v "accessTiming" ] ;
          ( fhir:source [
    fhir:context [ fhir:v "prescriptionGroup" ]       ] ) ;
          ( fhir:target [
    fhir:context [ fhir:v "dosage" ] ;
    fhir:element [ fhir:v "timing" ] ;
    fhir:variable [ fhir:v "timing" ]       ] ) ;
          ( fhir:rule [
    fhir:name [ fhir:v "accessRepeat" ] ;
            ( fhir:source [
    fhir:context [ fhir:v "prescriptionGroup" ]         ] ) ;
            ( fhir:target [
    fhir:context [ fhir:v "timing" ] ;
    fhir:element [ fhir:v "repeat" ] ;
    fhir:variable [ fhir:v "repeat" ]         ] ) ;
            ( fhir:rule [
    fhir:name [ fhir:v "findFreq" ] ;
              ( fhir:source [
    fhir:context [ fhir:v "prescriptionGroup" ] ;
    fhir:element [ fhir:v "item" ] ;
    fhir:variable [ fhir:v "freqItem" ] ;
    fhir:condition [ fhir:v "(linkId = 'frequency')" ]           ] ) ;
              ( fhir:rule [
    fhir:name [ fhir:v "extractFreq" ] ;
                ( fhir:source [
    fhir:context [ fhir:v "freqItem" ] ;
    fhir:element [ fhir:v "answer" ] ;
    fhir:listMode [ fhir:v "first" ] ;
    fhir:variable [ fhir:v "freqAns" ]             ] ) ;
                ( fhir:rule [
    fhir:name [ fhir:v "setFreqOD" ] ;
                  ( fhir:source [
    fhir:context [ fhir:v "freqAns" ] ;
    fhir:element [ fhir:v "valueCoding" ] ;
    fhir:variable [ fhir:v "freqCoding" ] ;
    fhir:condition [ fhir:v "(code = 'OD')" ]               ] ) ;
                  ( fhir:target [
    fhir:context [ fhir:v "repeat" ] ;
    fhir:element [ fhir:v "frequency" ] ;
    fhir:transform [ fhir:v "copy" ] ;
                    ( fhir:parameter [
    fhir:value [
    a fhir:String ;
    fhir:v "1"                   ]                 ] )               ] )             ] [
    fhir:name [ fhir:v "setFreqBD" ] ;
                  ( fhir:source [
    fhir:context [ fhir:v "freqAns" ] ;
    fhir:element [ fhir:v "valueCoding" ] ;
    fhir:variable [ fhir:v "freqCoding" ] ;
    fhir:condition [ fhir:v "(code = 'BD')" ]               ] ) ;
                  ( fhir:target [
    fhir:context [ fhir:v "repeat" ] ;
    fhir:element [ fhir:v "frequency" ] ;
    fhir:transform [ fhir:v "copy" ] ;
                    ( fhir:parameter [
    fhir:value [
    a fhir:String ;
    fhir:v "2"                   ]                 ] )               ] )             ] [
    fhir:name [ fhir:v "setFreqTID" ] ;
                  ( fhir:source [
    fhir:context [ fhir:v "freqAns" ] ;
    fhir:element [ fhir:v "valueCoding" ] ;
    fhir:variable [ fhir:v "freqCoding" ] ;
    fhir:condition [ fhir:v "(code = 'TID')" ]               ] ) ;
                  ( fhir:target [
    fhir:context [ fhir:v "repeat" ] ;
    fhir:element [ fhir:v "frequency" ] ;
    fhir:transform [ fhir:v "copy" ] ;
                    ( fhir:parameter [
    fhir:value [
    a fhir:String ;
    fhir:v "3"                   ]                 ] )               ] )             ] [
    fhir:name [ fhir:v "setFreqQID" ] ;
                  ( fhir:source [
    fhir:context [ fhir:v "freqAns" ] ;
    fhir:element [ fhir:v "valueCoding" ] ;
    fhir:variable [ fhir:v "freqCoding" ] ;
    fhir:condition [ fhir:v "(code = 'QID')" ]               ] ) ;
                  ( fhir:target [
    fhir:context [ fhir:v "repeat" ] ;
    fhir:element [ fhir:v "frequency" ] ;
    fhir:transform [ fhir:v "copy" ] ;
                    ( fhir:parameter [
    fhir:value [
    a fhir:String ;
    fhir:v "4"                   ]                 ] )               ] )             ] )           ] ) ;
    fhir:documentation [ fhir:v "Frequency (OD, BD, TID, QID)" ]         ] [
    fhir:name [ fhir:v "setPeriod" ] ;
              ( fhir:source [
    fhir:context [ fhir:v "prescriptionGroup" ]           ] ) ;
              ( fhir:target [
    fhir:context [ fhir:v "repeat" ] ;
    fhir:element [ fhir:v "period" ] ;
    fhir:transform [ fhir:v "copy" ] ;
                ( fhir:parameter [
    fhir:value [
    a fhir:String ;
    fhir:v "1"               ]             ] )           ] ) ;
    fhir:documentation [ fhir:v "Period (1 day)" ]         ] [
    fhir:name [ fhir:v "setPeriodUnit" ] ;
              ( fhir:source [
    fhir:context [ fhir:v "prescriptionGroup" ]           ] ) ;
              ( fhir:target [
    fhir:context [ fhir:v "repeat" ] ;
    fhir:element [ fhir:v "periodUnit" ] ;
    fhir:transform [ fhir:v "copy" ] ;
                ( fhir:parameter [
    fhir:value [
    a fhir:String ;
    fhir:v "d"               ]             ] )           ] )         ] [
    fhir:name [ fhir:v "findDuration" ] ;
              ( fhir:source [
    fhir:context [ fhir:v "prescriptionGroup" ] ;
    fhir:element [ fhir:v "item" ] ;
    fhir:variable [ fhir:v "durItem" ] ;
    fhir:condition [ fhir:v "(linkId = 'duration')" ]           ] ) ;
              ( fhir:rule [
    fhir:name [ fhir:v "extractDuration" ] ;
                ( fhir:source [
    fhir:context [ fhir:v "durItem" ] ;
    fhir:element [ fhir:v "answer" ] ;
    fhir:listMode [ fhir:v "first" ] ;
    fhir:variable [ fhir:v "durAns" ]             ] ) ;
                ( fhir:rule [
    fhir:name [ fhir:v "setDuration" ] ;
                  ( fhir:source [
    fhir:context [ fhir:v "durAns" ] ;
    fhir:element [ fhir:v "valueInteger" ] ;
    fhir:variable [ fhir:v "durValue" ]               ] ) ;
                  ( fhir:target [
    fhir:context [ fhir:v "repeat" ] ;
    fhir:element [ fhir:v "duration" ] ;
    fhir:transform [ fhir:v "copy" ] ;
                    ( fhir:parameter [
    fhir:value [
    a fhir:Id ;
    fhir:v "durValue"                   ]                 ] )               ] )             ] )           ] ) ;
    fhir:documentation [ fhir:v "Duration" ]         ] [
    fhir:name [ fhir:v "findDurUom" ] ;
              ( fhir:source [
    fhir:context [ fhir:v "prescriptionGroup" ] ;
    fhir:element [ fhir:v "item" ] ;
    fhir:variable [ fhir:v "durUomItem" ] ;
    fhir:condition [ fhir:v "(linkId = 'duration-uom')" ]           ] ) ;
              ( fhir:rule [
    fhir:name [ fhir:v "extractDurUom" ] ;
                ( fhir:source [
    fhir:context [ fhir:v "durUomItem" ] ;
    fhir:element [ fhir:v "answer" ] ;
    fhir:listMode [ fhir:v "first" ] ;
    fhir:variable [ fhir:v "durUomAns" ]             ] ) ;
                ( fhir:rule [
    fhir:name [ fhir:v "extractDurUomCode" ] ;
                  ( fhir:source [
    fhir:context [ fhir:v "durUomAns" ] ;
    fhir:element [ fhir:v "valueCoding" ] ;
    fhir:variable [ fhir:v "durUomCoding" ]               ] ) ;
                  ( fhir:rule [
    fhir:name [ fhir:v "setDurationUnit" ] ;
                    ( fhir:source [
    fhir:context [ fhir:v "durUomCoding" ] ;
    fhir:element [ fhir:v "code" ] ;
    fhir:variable [ fhir:v "durUomCode" ]                 ] ) ;
                    ( fhir:target [
    fhir:context [ fhir:v "repeat" ] ;
    fhir:element [ fhir:v "durationUnit" ] ;
    fhir:transform [ fhir:v "copy" ] ;
                      ( fhir:parameter [
    fhir:value [
    a fhir:Id ;
    fhir:v "durUomCode"                     ]                   ] )                 ] )               ] )             ] )           ] ) ;
    fhir:documentation [ fhir:v "Duration UOM - directly use the code from unitsofmeasure.org (h, d, wk, mo, a)" ]         ] [
    fhir:name [ fhir:v "findWhen" ] ;
              ( fhir:source [
    fhir:context [ fhir:v "prescriptionGroup" ] ;
    fhir:element [ fhir:v "item" ] ;
    fhir:variable [ fhir:v "whenItem" ] ;
    fhir:condition [ fhir:v "(linkId = 'when-to-take')" ]           ] ) ;
              ( fhir:rule [
    fhir:name [ fhir:v "extractWhen" ] ;
                ( fhir:source [
    fhir:context [ fhir:v "whenItem" ] ;
    fhir:element [ fhir:v "answer" ] ;
    fhir:listMode [ fhir:v "first" ] ;
    fhir:variable [ fhir:v "whenAns" ]             ] ) ;
                ( fhir:rule [
    fhir:name [ fhir:v "extractWhenCode" ] ;
                  ( fhir:source [
    fhir:context [ fhir:v "whenAns" ] ;
    fhir:element [ fhir:v "valueCoding" ] ;
    fhir:variable [ fhir:v "whenCoding" ]               ] ) ;
                  ( fhir:rule [
    fhir:name [ fhir:v "setWhenCode" ] ;
                    ( fhir:source [
    fhir:context [ fhir:v "whenCoding" ] ;
    fhir:element [ fhir:v "code" ] ;
    fhir:variable [ fhir:v "whenCode" ]                 ] ) ;
                    ( fhir:target [
    fhir:context [ fhir:v "repeat" ] ;
    fhir:element [ fhir:v "when" ] ;
    fhir:transform [ fhir:v "copy" ] ;
                      ( fhir:parameter [
    fhir:value [
    a fhir:Id ;
    fhir:v "whenCode"                     ]                   ] )                 ] )               ] )             ] )           ] ) ;
    fhir:documentation [ fhir:v "When to take - directly use the code (AC, PC, ACM, ACD, ACV, PCM, PCD, PCV, etc.)" ]         ] [
    fhir:name [ fhir:v "findStartDate" ] ;
              ( fhir:source [
    fhir:context [ fhir:v "prescriptionGroup" ] ;
    fhir:element [ fhir:v "item" ] ;
    fhir:variable [ fhir:v "startItem" ] ;
    fhir:condition [ fhir:v "(linkId = 'start-date')" ]           ] ) ;
              ( fhir:rule [
    fhir:name [ fhir:v "extractStartDate" ] ;
                ( fhir:source [
    fhir:context [ fhir:v "startItem" ] ;
    fhir:element [ fhir:v "answer" ] ;
    fhir:listMode [ fhir:v "first" ] ;
    fhir:variable [ fhir:v "startAns" ]             ] ) ;
                ( fhir:rule [
    fhir:name [ fhir:v "createBoundsPeriod" ] ;
                  ( fhir:source [
    fhir:context [ fhir:v "startAns" ] ;
    fhir:element [ fhir:v "valueDate" ] ;
    fhir:variable [ fhir:v "startDate" ]               ] ) ;
                  ( fhir:target [
    fhir:context [ fhir:v "repeat" ] ;
    fhir:element [ fhir:v "boundsPeriod" ] ;
    fhir:variable [ fhir:v "boundsPeriod" ]               ] ) ;
                  ( fhir:rule [
    fhir:name [ fhir:v "setBoundsStart" ] ;
                    ( fhir:source [
    fhir:context [ fhir:v "startDate" ]                 ] ) ;
                    ( fhir:target [
    fhir:context [ fhir:v "boundsPeriod" ] ;
    fhir:element [ fhir:v "start" ] ;
    fhir:transform [ fhir:v "copy" ] ;
                      ( fhir:parameter [
    fhir:value [
    a fhir:Id ;
    fhir:v "startDate"                     ]                   ] )                 ] )               ] [
    fhir:name [ fhir:v "findEndDate" ] ;
                    ( fhir:source [
    fhir:context [ fhir:v "prescriptionGroup" ] ;
    fhir:element [ fhir:v "item" ] ;
    fhir:variable [ fhir:v "endItem" ] ;
    fhir:condition [ fhir:v "(linkId = 'end-date')" ]                 ] ) ;
                    ( fhir:rule [
    fhir:name [ fhir:v "extractEndDate" ] ;
                      ( fhir:source [
    fhir:context [ fhir:v "endItem" ] ;
    fhir:element [ fhir:v "answer" ] ;
    fhir:listMode [ fhir:v "first" ] ;
    fhir:variable [ fhir:v "endAns" ]                   ] ) ;
                      ( fhir:rule [
    fhir:name [ fhir:v "setBoundsEnd" ] ;
                        ( fhir:source [
    fhir:context [ fhir:v "endAns" ] ;
    fhir:element [ fhir:v "valueDate" ] ;
    fhir:variable [ fhir:v "endDate" ]                     ] ) ;
                        ( fhir:target [
    fhir:context [ fhir:v "boundsPeriod" ] ;
    fhir:element [ fhir:v "end" ] ;
    fhir:transform [ fhir:v "copy" ] ;
                          ( fhir:parameter [
    fhir:value [
    a fhir:Id ;
    fhir:v "endDate"                         ]                       ] )                     ] )                   ] )                 ] )               ] )             ] )           ] ) ;
    fhir:documentation [ fhir:v "Bounds Period from start-date and end-date" ]         ] )       ] )     ] [
    fhir:name [ fhir:v "findRoute" ] ;
          ( fhir:source [
    fhir:context [ fhir:v "prescriptionGroup" ] ;
    fhir:element [ fhir:v "item" ] ;
    fhir:variable [ fhir:v "routeItem" ] ;
    fhir:condition [ fhir:v "(linkId = 'route')" ]       ] ) ;
          ( fhir:rule [
    fhir:name [ fhir:v "extractRoute" ] ;
            ( fhir:source [
    fhir:context [ fhir:v "routeItem" ] ;
    fhir:element [ fhir:v "answer" ] ;
    fhir:listMode [ fhir:v "first" ] ;
    fhir:variable [ fhir:v "routeAns" ]         ] ) ;
            ( fhir:rule [
    fhir:name [ fhir:v "setRouteCC" ] ;
              ( fhir:source [
    fhir:context [ fhir:v "routeAns" ] ;
    fhir:element [ fhir:v "valueCoding" ] ;
    fhir:variable [ fhir:v "routeCoding" ]           ] ) ;
              ( fhir:target [
    fhir:context [ fhir:v "dosage" ] ;
    fhir:element [ fhir:v "route" ] ;
    fhir:variable [ fhir:v "routeCC" ] ;
    fhir:transform [ fhir:v "create" ] ;
                ( fhir:parameter [
    fhir:value [
    a fhir:String ;
    fhir:v "CodeableConcept"               ]             ] )           ] ) ;
              ( fhir:rule [
    fhir:name [ fhir:v "setRouteCoding" ] ;
                ( fhir:source [
    fhir:context [ fhir:v "routeCoding" ]             ] ) ;
                ( fhir:target [
    fhir:context [ fhir:v "routeCC" ] ;
    fhir:element [ fhir:v "coding" ] ;
    fhir:transform [ fhir:v "copy" ] ;
                  ( fhir:parameter [
    fhir:value [
    a fhir:Id ;
    fhir:v "routeCoding"                 ]               ] )             ] )           ] [
    fhir:name [ fhir:v "setRouteText" ] ;
                ( fhir:source [
    fhir:context [ fhir:v "routeCoding" ] ;
    fhir:element [ fhir:v "display" ] ;
    fhir:variable [ fhir:v "disp" ]             ] ) ;
                ( fhir:target [
    fhir:context [ fhir:v "routeCC" ] ;
    fhir:element [ fhir:v "text" ] ;
    fhir:transform [ fhir:v "copy" ] ;
                  ( fhir:parameter [
    fhir:value [
    a fhir:Id ;
    fhir:v "disp"                 ]               ] )             ] )           ] )         ] )       ] ) ;
    fhir:documentation [ fhir:v "Route" ]     ] [
    fhir:name [ fhir:v "findDose" ] ;
          ( fhir:source [
    fhir:context [ fhir:v "prescriptionGroup" ] ;
    fhir:element [ fhir:v "item" ] ;
    fhir:variable [ fhir:v "doseItem" ] ;
    fhir:condition [ fhir:v "(linkId = 'dose')" ]       ] ) ;
          ( fhir:rule [
    fhir:name [ fhir:v "extractDoseAns" ] ;
            ( fhir:source [
    fhir:context [ fhir:v "doseItem" ] ;
    fhir:element [ fhir:v "answer" ] ;
    fhir:listMode [ fhir:v "first" ] ;
    fhir:variable [ fhir:v "doseAns" ]         ] ) ;
            ( fhir:rule [
    fhir:name [ fhir:v "createDoseAndRate" ] ;
              ( fhir:source [
    fhir:context [ fhir:v "doseAns" ] ;
    fhir:element [ fhir:v "valueInteger" ] ;
    fhir:variable [ fhir:v "doseValue" ]           ] ) ;
              ( fhir:target [
    fhir:context [ fhir:v "dosage" ] ;
    fhir:element [ fhir:v "doseAndRate" ] ;
    fhir:variable [ fhir:v "doseRate" ]           ] [
    fhir:context [ fhir:v "doseRate" ] ;
    fhir:element [ fhir:v "doseQuantity" ] ;
    fhir:variable [ fhir:v "doseQty" ]           ] ) ;
              ( fhir:rule [
    fhir:name [ fhir:v "setDoseValue" ] ;
                ( fhir:source [
    fhir:context [ fhir:v "doseValue" ]             ] ) ;
                ( fhir:target [
    fhir:context [ fhir:v "doseQty" ] ;
    fhir:element [ fhir:v "value" ] ;
    fhir:transform [ fhir:v "copy" ] ;
                  ( fhir:parameter [
    fhir:value [
    a fhir:Id ;
    fhir:v "doseValue"                 ]               ] )             ] )           ] [
    fhir:name [ fhir:v "findDoseUnit" ] ;
                ( fhir:source [
    fhir:context [ fhir:v "prescriptionGroup" ] ;
    fhir:element [ fhir:v "item" ] ;
    fhir:variable [ fhir:v "doseUnitItem" ] ;
    fhir:condition [ fhir:v "(linkId = 'dosage-unit')" ]             ] ) ;
                ( fhir:rule [
    fhir:name [ fhir:v "extractDoseUnitAns" ] ;
                  ( fhir:source [
    fhir:context [ fhir:v "doseUnitItem" ] ;
    fhir:element [ fhir:v "answer" ] ;
    fhir:listMode [ fhir:v "first" ] ;
    fhir:variable [ fhir:v "doseUnitAns" ]               ] ) ;
                  ( fhir:rule [
    fhir:name [ fhir:v "extractUnitCoding" ] ;
                    ( fhir:source [
    fhir:context [ fhir:v "doseUnitAns" ] ;
    fhir:element [ fhir:v "valueCoding" ] ;
    fhir:variable [ fhir:v "unitCoding" ]                 ] ) ;
                    ( fhir:rule [
    fhir:name [ fhir:v "setDoseUnit" ] ;
                      ( fhir:source [
    fhir:context [ fhir:v "unitCoding" ] ;
    fhir:element [ fhir:v "display" ] ;
    fhir:variable [ fhir:v "unitDisp" ]                   ] ) ;
                      ( fhir:target [
    fhir:context [ fhir:v "doseQty" ] ;
    fhir:element [ fhir:v "unit" ] ;
    fhir:transform [ fhir:v "copy" ] ;
                        ( fhir:parameter [
    fhir:value [
    a fhir:Id ;
    fhir:v "unitDisp"                       ]                     ] )                   ] )                 ] [
    fhir:name [ fhir:v "setDoseCode" ] ;
                      ( fhir:source [
    fhir:context [ fhir:v "unitCoding" ] ;
    fhir:element [ fhir:v "code" ] ;
    fhir:variable [ fhir:v "unitCode" ]                   ] ) ;
                      ( fhir:target [
    fhir:context [ fhir:v "doseQty" ] ;
    fhir:element [ fhir:v "code" ] ;
    fhir:transform [ fhir:v "copy" ] ;
                        ( fhir:parameter [
    fhir:value [
    a fhir:Id ;
    fhir:v "unitCode"                       ]                     ] )                   ] )                 ] [
    fhir:name [ fhir:v "setDoseSystem" ] ;
                      ( fhir:source [
    fhir:context [ fhir:v "unitCoding" ] ;
    fhir:element [ fhir:v "system" ] ;
    fhir:variable [ fhir:v "unitSys" ]                   ] ) ;
                      ( fhir:target [
    fhir:context [ fhir:v "doseQty" ] ;
    fhir:element [ fhir:v "system" ] ;
    fhir:transform [ fhir:v "copy" ] ;
                        ( fhir:parameter [
    fhir:value [
    a fhir:Id ;
    fhir:v "unitSys"                       ]                     ] )                   ] )                 ] )               ] )             ] )           ] )         ] )       ] ) ;
    fhir:documentation [ fhir:v "Dose and Rate" ]     ] [
    fhir:name [ fhir:v "findDosageInstr" ] ;
          ( fhir:source [
    fhir:context [ fhir:v "prescriptionGroup" ] ;
    fhir:element [ fhir:v "item" ] ;
    fhir:variable [ fhir:v "instrItem" ] ;
    fhir:condition [ fhir:v "(linkId = 'dosage-instructions')" ]       ] ) ;
          ( fhir:rule [
    fhir:name [ fhir:v "extractInstr" ] ;
            ( fhir:source [
    fhir:context [ fhir:v "instrItem" ] ;
    fhir:element [ fhir:v "answer" ] ;
    fhir:listMode [ fhir:v "first" ] ;
    fhir:variable [ fhir:v "instrAns" ]         ] ) ;
            ( fhir:rule [
    fhir:name [ fhir:v "setPatientInstruction" ] ;
              ( fhir:source [
    fhir:context [ fhir:v "instrAns" ] ;
    fhir:element [ fhir:v "valueString" ] ;
    fhir:variable [ fhir:v "instrText" ]           ] ) ;
              ( fhir:target [
    fhir:context [ fhir:v "dosage" ] ;
    fhir:element [ fhir:v "patientInstruction" ] ;
    fhir:transform [ fhir:v "copy" ] ;
                ( fhir:parameter [
    fhir:value [
    a fhir:Id ;
    fhir:v "instrText"               ]             ] )           ] )         ] )       ] ) ;
    fhir:documentation [ fhir:v "Dosage Instructions (patient instruction)" ]     ] [
    fhir:name [ fhir:v "findAddInstr" ] ;
          ( fhir:source [
    fhir:context [ fhir:v "prescriptionGroup" ] ;
    fhir:element [ fhir:v "item" ] ;
    fhir:variable [ fhir:v "addInstrItem" ] ;
    fhir:condition [ fhir:v "(linkId = 'additional-instructions')" ]       ] ) ;
          ( fhir:rule [
    fhir:name [ fhir:v "extractAddInstr" ] ;
            ( fhir:source [
    fhir:context [ fhir:v "addInstrItem" ] ;
    fhir:element [ fhir:v "answer" ] ;
    fhir:listMode [ fhir:v "first" ] ;
    fhir:variable [ fhir:v "addInstrAns" ]         ] ) ;
            ( fhir:rule [
    fhir:name [ fhir:v "setDosageText" ] ;
              ( fhir:source [
    fhir:context [ fhir:v "addInstrAns" ] ;
    fhir:element [ fhir:v "valueString" ] ;
    fhir:variable [ fhir:v "addInstrText" ]           ] ) ;
              ( fhir:target [
    fhir:context [ fhir:v "dosage" ] ;
    fhir:element [ fhir:v "text" ] ;
    fhir:transform [ fhir:v "copy" ] ;
                ( fhir:parameter [
    fhir:value [
    a fhir:Id ;
    fhir:v "addInstrText"               ]             ] )           ] )         ] )       ] ) ;
    fhir:documentation [ fhir:v "Additional Instructions (text)" ]     ] )
      ] [
    fhir:name [ fhir:v "BuildDispenseRequest" ] ;
        ( fhir:input [
    fhir:name [ fhir:v "qr" ] ;
    fhir:type [ fhir:v "QR" ] ;
    fhir:mode [ fhir:v "source" ]     ] [
    fhir:name [ fhir:v "prescriptionGroup" ] ;
    fhir:mode [ fhir:v "source" ]     ] [
    fhir:name [ fhir:v "dispReq" ] ;
    fhir:mode [ fhir:v "target" ]     ] ) ;
        ( fhir:rule [
    fhir:name [ fhir:v "findRefills" ] ;
          ( fhir:source [
    fhir:context [ fhir:v "prescriptionGroup" ] ;
    fhir:element [ fhir:v "item" ] ;
    fhir:variable [ fhir:v "refillsItem" ] ;
    fhir:condition [ fhir:v "(linkId = 'refills')" ]       ] ) ;
          ( fhir:rule [
    fhir:name [ fhir:v "extractRefills" ] ;
            ( fhir:source [
    fhir:context [ fhir:v "refillsItem" ] ;
    fhir:element [ fhir:v "answer" ] ;
    fhir:listMode [ fhir:v "first" ] ;
    fhir:variable [ fhir:v "refillsAns" ]         ] ) ;
            ( fhir:rule [
    fhir:name [ fhir:v "setRefills" ] ;
              ( fhir:source [
    fhir:context [ fhir:v "refillsAns" ] ;
    fhir:element [ fhir:v "valueInteger" ] ;
    fhir:variable [ fhir:v "refillsValue" ]           ] ) ;
              ( fhir:target [
    fhir:context [ fhir:v "dispReq" ] ;
    fhir:element [ fhir:v "numberOfRepeatsAllowed" ] ;
    fhir:transform [ fhir:v "copy" ] ;
                ( fhir:parameter [
    fhir:value [
    a fhir:Id ;
    fhir:v "refillsValue"               ]             ] )           ] )         ] )       ] ) ;
    fhir:documentation [ fhir:v "Refills" ]     ] [
    fhir:name [ fhir:v "findValidityStart" ] ;
          ( fhir:source [
    fhir:context [ fhir:v "prescriptionGroup" ] ;
    fhir:element [ fhir:v "item" ] ;
    fhir:variable [ fhir:v "startItem" ] ;
    fhir:condition [ fhir:v "(linkId = 'start-date')" ]       ] ) ;
          ( fhir:rule [
    fhir:name [ fhir:v "extractValidityStart" ] ;
            ( fhir:source [
    fhir:context [ fhir:v "startItem" ] ;
    fhir:element [ fhir:v "answer" ] ;
    fhir:listMode [ fhir:v "first" ] ;
    fhir:variable [ fhir:v "startAns" ]         ] ) ;
            ( fhir:rule [
    fhir:name [ fhir:v "createValidityPeriod" ] ;
              ( fhir:source [
    fhir:context [ fhir:v "startAns" ] ;
    fhir:element [ fhir:v "valueDate" ] ;
    fhir:variable [ fhir:v "startDate" ]           ] ) ;
              ( fhir:target [
    fhir:context [ fhir:v "dispReq" ] ;
    fhir:element [ fhir:v "validityPeriod" ] ;
    fhir:variable [ fhir:v "validPeriod" ]           ] ) ;
              ( fhir:rule [
    fhir:name [ fhir:v "setValidityStart" ] ;
                ( fhir:source [
    fhir:context [ fhir:v "startDate" ]             ] ) ;
                ( fhir:target [
    fhir:context [ fhir:v "validPeriod" ] ;
    fhir:element [ fhir:v "start" ] ;
    fhir:transform [ fhir:v "copy" ] ;
                  ( fhir:parameter [
    fhir:value [
    a fhir:Id ;
    fhir:v "startDate"                 ]               ] )             ] )           ] [
    fhir:name [ fhir:v "findValidityEnd" ] ;
                ( fhir:source [
    fhir:context [ fhir:v "prescriptionGroup" ] ;
    fhir:element [ fhir:v "item" ] ;
    fhir:variable [ fhir:v "endItem" ] ;
    fhir:condition [ fhir:v "(linkId = 'end-date')" ]             ] ) ;
                ( fhir:rule [
    fhir:name [ fhir:v "extractValidityEnd" ] ;
                  ( fhir:source [
    fhir:context [ fhir:v "endItem" ] ;
    fhir:element [ fhir:v "answer" ] ;
    fhir:listMode [ fhir:v "first" ] ;
    fhir:variable [ fhir:v "endAns" ]               ] ) ;
                  ( fhir:rule [
    fhir:name [ fhir:v "setValidityEnd" ] ;
                    ( fhir:source [
    fhir:context [ fhir:v "endAns" ] ;
    fhir:element [ fhir:v "valueDate" ] ;
    fhir:variable [ fhir:v "endDate" ]                 ] ) ;
                    ( fhir:target [
    fhir:context [ fhir:v "validPeriod" ] ;
    fhir:element [ fhir:v "end" ] ;
    fhir:transform [ fhir:v "copy" ] ;
                      ( fhir:parameter [
    fhir:value [
    a fhir:Id ;
    fhir:v "endDate"                     ]                   ] )                 ] )               ] )             ] )           ] )         ] )       ] ) ;
    fhir:documentation [ fhir:v "Validity Period from start-date and end-date" ]     ] [
    fhir:name [ fhir:v "findSupplyDuration" ] ;
          ( fhir:source [
    fhir:context [ fhir:v "prescriptionGroup" ] ;
    fhir:element [ fhir:v "item" ] ;
    fhir:variable [ fhir:v "durItem" ] ;
    fhir:condition [ fhir:v "(linkId = 'duration')" ]       ] ) ;
          ( fhir:rule [
    fhir:name [ fhir:v "extractSupplyDuration" ] ;
            ( fhir:source [
    fhir:context [ fhir:v "durItem" ] ;
    fhir:element [ fhir:v "answer" ] ;
    fhir:listMode [ fhir:v "first" ] ;
    fhir:variable [ fhir:v "durAns" ]         ] ) ;
            ( fhir:rule [
    fhir:name [ fhir:v "createSupplyDuration" ] ;
              ( fhir:source [
    fhir:context [ fhir:v "durAns" ] ;
    fhir:element [ fhir:v "valueInteger" ] ;
    fhir:variable [ fhir:v "durValue" ]           ] ) ;
              ( fhir:target [
    fhir:context [ fhir:v "dispReq" ] ;
    fhir:element [ fhir:v "expectedSupplyDuration" ] ;
    fhir:variable [ fhir:v "supplyDur" ]           ] ) ;
              ( fhir:rule [
    fhir:name [ fhir:v "setSupplyDurValue" ] ;
                ( fhir:source [
    fhir:context [ fhir:v "durValue" ]             ] ) ;
                ( fhir:target [
    fhir:context [ fhir:v "supplyDur" ] ;
    fhir:element [ fhir:v "value" ] ;
    fhir:transform [ fhir:v "copy" ] ;
                  ( fhir:parameter [
    fhir:value [
    a fhir:Id ;
    fhir:v "durValue"                 ]               ] )             ] )           ] [
    fhir:name [ fhir:v "findSupplyDurUom" ] ;
                ( fhir:source [
    fhir:context [ fhir:v "prescriptionGroup" ] ;
    fhir:element [ fhir:v "item" ] ;
    fhir:variable [ fhir:v "durUomItem" ] ;
    fhir:condition [ fhir:v "(linkId = 'duration-uom')" ]             ] ) ;
                ( fhir:rule [
    fhir:name [ fhir:v "extractSupplyDurUomAns" ] ;
                  ( fhir:source [
    fhir:context [ fhir:v "durUomItem" ] ;
    fhir:element [ fhir:v "answer" ] ;
    fhir:listMode [ fhir:v "first" ] ;
    fhir:variable [ fhir:v "durUomAns" ]               ] ) ;
                  ( fhir:rule [
    fhir:name [ fhir:v "extractSupplyDurUom" ] ;
                    ( fhir:source [
    fhir:context [ fhir:v "durUomAns" ] ;
    fhir:element [ fhir:v "valueCoding" ] ;
    fhir:variable [ fhir:v "durUomCoding" ]                 ] ) ;
                    ( fhir:rule [
    fhir:name [ fhir:v "setSupplyDurCode" ] ;
                      ( fhir:source [
    fhir:context [ fhir:v "durUomCoding" ] ;
    fhir:element [ fhir:v "code" ] ;
    fhir:variable [ fhir:v "uomCode" ]                   ] ) ;
                      ( fhir:target [
    fhir:context [ fhir:v "supplyDur" ] ;
    fhir:element [ fhir:v "code" ] ;
    fhir:transform [ fhir:v "copy" ] ;
                        ( fhir:parameter [
    fhir:value [
    a fhir:Id ;
    fhir:v "uomCode"                       ]                     ] )                   ] )                 ] [
    fhir:name [ fhir:v "setSupplyDurUnit" ] ;
                      ( fhir:source [
    fhir:context [ fhir:v "durUomCoding" ] ;
    fhir:element [ fhir:v "display" ] ;
    fhir:variable [ fhir:v "uomDisplay" ]                   ] ) ;
                      ( fhir:target [
    fhir:context [ fhir:v "supplyDur" ] ;
    fhir:element [ fhir:v "unit" ] ;
    fhir:transform [ fhir:v "copy" ] ;
                        ( fhir:parameter [
    fhir:value [
    a fhir:Id ;
    fhir:v "uomDisplay"                       ]                     ] )                   ] )                 ] [
    fhir:name [ fhir:v "setSupplyDurSystem" ] ;
                      ( fhir:source [
    fhir:context [ fhir:v "durUomCoding" ] ;
    fhir:element [ fhir:v "system" ] ;
    fhir:variable [ fhir:v "uomSystem" ]                   ] ) ;
                      ( fhir:target [
    fhir:context [ fhir:v "supplyDur" ] ;
    fhir:element [ fhir:v "system" ] ;
    fhir:transform [ fhir:v "copy" ] ;
                        ( fhir:parameter [
    fhir:value [
    a fhir:Id ;
    fhir:v "uomSystem"                       ]                     ] )                   ] )                 ] )               ] )             ] )           ] )         ] )       ] ) ;
    fhir:documentation [ fhir:v "Expected Supply Duration" ]     ] [
    fhir:name [ fhir:v "setDispenser" ] ;
          ( fhir:source [
    fhir:context [ fhir:v "qr" ] ;
    fhir:element [ fhir:v "source" ] ;
    fhir:variable [ fhir:v "src" ]       ] ) ;
          ( fhir:target [
    fhir:context [ fhir:v "dispReq" ] ;
    fhir:element [ fhir:v "dispenser" ] ;
    fhir:transform [ fhir:v "copy" ] ;
            ( fhir:parameter [
    fhir:value [
    a fhir:Id ;
    fhir:v "src"           ]         ] )       ] ) ;
    fhir:documentation [ fhir:v "Dispenser - from QuestionnaireResponse.source (Organization)" ]     ] )
      ] [
    fhir:name [ fhir:v "SetMedicationRequestFullUrl" ] ;
        ( fhir:input [
    fhir:name [ fhir:v "medReq" ] ;
    fhir:type [ fhir:v "MedicationRequest" ] ;
    fhir:mode [ fhir:v "source" ]     ] [
    fhir:name [ fhir:v "entry" ] ;
    fhir:mode [ fhir:v "target" ]     ] ) ;
        ( fhir:rule [
    fhir:name [ fhir:v "assignFullUrl" ] ;
          ( fhir:source [
    fhir:context [ fhir:v "medReq" ] ;
    fhir:element [ fhir:v "id" ] ;
    fhir:variable [ fhir:v "id" ]       ] ) ;
          ( fhir:target [
    fhir:context [ fhir:v "entry" ] ;
    fhir:element [ fhir:v "fullUrl" ] ;
    fhir:transform [ fhir:v "append" ] ;
            ( fhir:parameter [
    fhir:value [
    a fhir:String ;
    fhir:v "https://fhir.slade360.co.ke/fhir/MedicationRequest/"           ]         ] [
    fhir:value [
    a fhir:Id ;
    fhir:v "id"           ]         ] )       ] )     ] )
      ] ) . #