{
  "resourceType": "StructureDefinition",
  "id": "db5e6fcc-2f29-42a8-ab29-18faa469d032",
  "url": "https://fhir.nhs.uk/StructureDefinition/NHSDigital-MedicationRequest",
  "name": "NHSDigital-MedicationRequest",
  "status": "draft",
  "fhirVersion": "4.0.1",
  "mapping": [
    {
      "identity": "workflow",
      "uri": "http://hl7.org/fhir/workflow",
      "name": "Workflow Pattern"
    },
    {
      "identity": "script10.6",
      "uri": "http://ncpdp.org/SCRIPT10_6",
      "name": "Mapping to NCPDP SCRIPT 10.6"
    },
    {
      "identity": "rim",
      "uri": "http://hl7.org/v3",
      "name": "RIM Mapping"
    },
    {
      "identity": "w5",
      "uri": "http://hl7.org/fhir/fivews",
      "name": "FiveWs Pattern Mapping"
    },
    {
      "identity": "v2",
      "uri": "http://hl7.org/v2",
      "name": "HL7 v2 Mapping"
    }
  ],
  "kind": "resource",
  "abstract": false,
  "type": "MedicationRequest",
  "baseDefinition": "https://fhir.hl7.org.uk/StructureDefinition/UKCore-MedicationRequest",
  "derivation": "constraint",
  "differential": {
    "element": [
      {
        "id": "MedicationRequest",
        "path": "MedicationRequest",
        "constraint": [
          {
            "key": "eps-1",
            "severity": "error",
            "human": "Only one of medicationReference or medicationCodeableConcept should be provided",
            "expression": "(medicationReference.exists() and medicationCodeableConcept.exists().not()) or (medicationReference.exists().not() and medicationCodeableConcept.exists())",
            "source": "https://fhir.nhs.uk/StructureDefinition/NHSDigital-MedicationRequest"
          }
        ]
      },
      {
        "id": "MedicationRequest.extension",
        "path": "MedicationRequest.extension",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "url"
            }
          ],
          "rules": "open"
        }
      },
      {
        "id": "MedicationRequest.extension:repeatInformation",
        "path": "MedicationRequest.extension",
        "sliceName": "repeatInformation",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "https://fhir.hl7.org.uk/StructureDefinition/Extension-UKCore-MedicationRepeatInformation"
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "MedicationRequest.extension:responsiblePractitioner",
        "path": "MedicationRequest.extension",
        "sliceName": "responsiblePractitioner",
        "max": "1",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "https://fhir.nhs.uk/StructureDefinition/Extension-DM-ResponsiblePractitioner"
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "MedicationRequest.extension:prescriptionEndorsement",
        "path": "MedicationRequest.extension",
        "sliceName": "prescriptionEndorsement",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "https://fhir.nhs.uk/StructureDefinition/Extension-DM-PrescriptionEndorsement"
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "MedicationRequest.extension:prescriptionTaskStatusReason",
        "path": "MedicationRequest.extension",
        "sliceName": "prescriptionTaskStatusReason",
        "definition": "The status history within EPS is primarily a technical Status and the statusReason will reflect current clinical status of the order.",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "https://fhir.nhs.uk/StructureDefinition/Extension-DM-PrescriptionStatusHistory"
            ]
          }
        ]
      },
      {
        "id": "MedicationRequest.extension:NHSBSAprescriptionType",
        "path": "MedicationRequest.extension",
        "sliceName": "NHSBSAprescriptionType",
        "min": 1,
        "type": [
          {
            "code": "Extension",
            "profile": [
              "https://fhir.nhs.uk/StructureDefinition/Extension-DM-PrescriptionType"
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "MedicationRequest.extension:controlledDrug",
        "path": "MedicationRequest.extension",
        "sliceName": "controlledDrug",
        "max": "1",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "https://fhir.nhs.uk/StructureDefinition/Extension-DM-ControlledDrug"
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "MedicationRequest.extension:dispensingInformation",
        "path": "MedicationRequest.extension",
        "sliceName": "dispensingInformation",
        "short": "For EPS use only",
        "definition": "Not to be populated by prescribing systems. Tracking systems only for repeat dispensing.",
        "max": "1",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "https://fhir.nhs.uk/StructureDefinition/Extension-EPS-DispensingInformation"
            ]
          }
        ]
      },
      {
        "id": "MedicationRequest.identifier",
        "path": "MedicationRequest.identifier",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "system"
            }
          ],
          "rules": "open"
        },
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "MedicationRequest.identifier:prescriptionOrderItem",
        "path": "MedicationRequest.identifier",
        "sliceName": "prescriptionOrderItem",
        "short": "Prescription Order Item",
        "definition": "Unique Id of the MedicationRequest within EPS",
        "min": 1,
        "max": "1"
      },
      {
        "id": "MedicationRequest.identifier:prescriptionOrderItem.system",
        "path": "MedicationRequest.identifier.system",
        "min": 1,
        "fixedUri": "https://fhir.nhs.uk/Id/prescription-order-item-number"
      },
      {
        "id": "MedicationRequest.identifier:prescriptionOrderItem.value",
        "path": "MedicationRequest.identifier.value",
        "min": 1
      },
      {
        "id": "MedicationRequest.status",
        "path": "MedicationRequest.status",
        "mustSupport": true
      },
      {
        "id": "MedicationRequest.statusReason",
        "path": "MedicationRequest.statusReason",
        "definition": "Mandatory for cancelled prescription items",
        "mustSupport": true,
        "binding": {
          "strength": "required",
          "valueSet": "https://fhir.nhs.uk/ValueSet/DM-medicationrequest-status-reason"
        }
      },
      {
        "id": "MedicationRequest.statusReason.coding",
        "path": "MedicationRequest.statusReason.coding",
        "min": 1,
        "max": "1"
      },
      {
        "id": "MedicationRequest.statusReason.coding.system",
        "path": "MedicationRequest.statusReason.coding.system",
        "min": 1
      },
      {
        "id": "MedicationRequest.statusReason.coding.code",
        "path": "MedicationRequest.statusReason.coding.code",
        "min": 1
      },
      {
        "id": "MedicationRequest.statusReason.coding.display",
        "path": "MedicationRequest.statusReason.coding.display",
        "min": 1
      },
      {
        "id": "MedicationRequest.category",
        "path": "MedicationRequest.category",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "MedicationRequest.category.coding",
        "path": "MedicationRequest.category.coding",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "system"
            }
          ],
          "rules": "open"
        },
        "min": 1,
        "max": "1"
      },
      {
        "id": "MedicationRequest.category.coding:patientClassFHIR",
        "path": "MedicationRequest.category.coding",
        "sliceName": "patientClassFHIR",
        "max": "1",
        "binding": {
          "strength": "required",
          "valueSet": "https://fhir.nhs.uk/ValueSet/DM-medicationrequest-category"
        }
      },
      {
        "id": "MedicationRequest.category.coding:patientClassFHIR.system",
        "path": "MedicationRequest.category.coding.system",
        "min": 1,
        "fixedUri": "http://terminology.hl7.org/CodeSystem/medicationrequest-category"
      },
      {
        "id": "MedicationRequest.category.coding:patientClassFHIR.code",
        "path": "MedicationRequest.category.coding.code",
        "min": 1
      },
      {
        "id": "MedicationRequest.category.coding:patientClassUK",
        "path": "MedicationRequest.category.coding",
        "sliceName": "patientClassUK",
        "max": "1",
        "binding": {
          "strength": "required",
          "valueSet": "https://fhir.nhs.uk/ValueSet/DM-medicationrequest-category"
        }
      },
      {
        "id": "MedicationRequest.category.coding:patientClassUK.system",
        "path": "MedicationRequest.category.coding.system",
        "min": 1,
        "fixedUri": "https://fhir.nhs.uk/CodeSystem/medicationrequest-category"
      },
      {
        "id": "MedicationRequest.category.coding:patientClassUK.code",
        "path": "MedicationRequest.category.coding.code",
        "min": 1
      },
      {
        "id": "MedicationRequest.medication[x]",
        "path": "MedicationRequest.medication[x]",
        "comment": "Any code from the SnomedCT UK DMD subset for VMP, AMP and VTM concepts",
        "type": [
          {
            "code": "CodeableConcept",
            "profile": [
              "https://fhir.nhs.uk/StructureDefinition/NHSDigital-MedicationRequest-CodeableConcept"
            ]
          },
          {
            "code": "Reference",
            "targetProfile": [
              "https://fhir.nhs.uk/StructureDefinition/NHSDigital-MedicationRequest-Medication"
            ],
            "aggregation": [
              "bundled"
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "MedicationRequest.subject",
        "path": "MedicationRequest.subject",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://fhir.nhs.uk/StructureDefinition/NHSDigital-Patient"
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "MedicationRequest.subject.reference",
        "path": "MedicationRequest.subject.reference",
        "min": 1
      },
      {
        "id": "MedicationRequest.encounter",
        "path": "MedicationRequest.encounter",
        "definition": "Encounter is required for secondary care prescriptions."
      },
      {
        "id": "MedicationRequest.authoredOn",
        "path": "MedicationRequest.authoredOn",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "MedicationRequest.requester",
        "path": "MedicationRequest.requester",
        "min": 1,
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://fhir.nhs.uk/StructureDefinition/NHSDigital-PractitionerRole"
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "MedicationRequest.requester.reference",
        "path": "MedicationRequest.requester.reference",
        "min": 1
      },
      {
        "id": "MedicationRequest.basedOn",
        "path": "MedicationRequest.basedOn",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://hl7.org/fhir/StructureDefinition/ImmunizationRecommendation",
              "https://fhir.nhs.uk/StructureDefinition/NHSDigital-MedicationRequest"
            ]
          }
        ]
      },
      {
        "id": "MedicationRequest.groupIdentifier",
        "path": "MedicationRequest.groupIdentifier",
        "short": "order number for grouped MedicationRequests",
        "definition": "The short form prescription identifier",
        "comment": "ITK HL7v3 Mapping = The groupIdentifier is equivalent to ParentPrescription.id (prescription-order-number). The extension is used to carry the ParentPrescription.id (UUID).",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "MedicationRequest.groupIdentifier.extension",
        "path": "MedicationRequest.groupIdentifier.extension",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "url"
            }
          ],
          "rules": "open"
        }
      },
      {
        "id": "MedicationRequest.groupIdentifier.extension:PrescriptionOrderUUID",
        "path": "MedicationRequest.groupIdentifier.extension",
        "sliceName": "PrescriptionOrderUUID",
        "short": "UUID order number for grouped MedciationRequests",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "https://fhir.nhs.uk/StructureDefinition/Extension-DM-PrescriptionId"
            ]
          }
        ]
      },
      {
        "id": "MedicationRequest.groupIdentifier.extension:PrescriptionOrderUUID.value[x].system",
        "path": "MedicationRequest.groupIdentifier.extension.value[x].system",
        "min": 1
      },
      {
        "id": "MedicationRequest.groupIdentifier.extension:PrescriptionOrderUUID.value[x].value",
        "path": "MedicationRequest.groupIdentifier.extension.value[x].value",
        "min": 1
      },
      {
        "id": "MedicationRequest.groupIdentifier.system",
        "path": "MedicationRequest.groupIdentifier.system",
        "min": 1,
        "fixedUri": "https://fhir.nhs.uk/Id/prescription-order-number"
      },
      {
        "id": "MedicationRequest.groupIdentifier.value",
        "path": "MedicationRequest.groupIdentifier.value",
        "min": 1
      },
      {
        "id": "MedicationRequest.courseOfTherapyType",
        "path": "MedicationRequest.courseOfTherapyType",
        "definition": "The description of the overall pattern of the administration of the medication to the patient.\r\nRequired for prescription-order",
        "comment": "The type of prescription e.g. acute, continuous, etc. Was extension in STU3 https://fhir.hl7.org.uk/STU3/StructureDefinition/Extension-CareConnect-PrescriptionType-1 and Digital Medicine uses international codes, so continuous in place of repeat.",
        "min": 1,
        "mustSupport": true,
        "binding": {
          "strength": "required",
          "valueSet": "https://fhir.nhs.uk/ValueSet/DM-medicationrequest-course-of-therapy"
        }
      },
      {
        "id": "MedicationRequest.courseOfTherapyType.coding",
        "path": "MedicationRequest.courseOfTherapyType.coding",
        "min": 1,
        "max": "1"
      },
      {
        "id": "MedicationRequest.courseOfTherapyType.coding.system",
        "path": "MedicationRequest.courseOfTherapyType.coding.system",
        "min": 1
      },
      {
        "id": "MedicationRequest.courseOfTherapyType.coding.code",
        "path": "MedicationRequest.courseOfTherapyType.coding.code",
        "min": 1
      },
      {
        "id": "MedicationRequest.dosageInstruction",
        "path": "MedicationRequest.dosageInstruction",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "MedicationRequest.dosageInstruction.text",
        "path": "MedicationRequest.dosageInstruction.text",
        "comment": "ITK Mapping = pertinentInformation2.pertinentLineItem.pertinentInformation2.pertinentDosageInstructions.value",
        "min": 1
      },
      {
        "id": "MedicationRequest.dispenseRequest",
        "path": "MedicationRequest.dispenseRequest",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "MedicationRequest.dispenseRequest.extension",
        "path": "MedicationRequest.dispenseRequest.extension",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "url"
            }
          ],
          "rules": "open"
        }
      },
      {
        "id": "MedicationRequest.dispenseRequest.extension:performerSiteType",
        "path": "MedicationRequest.dispenseRequest.extension",
        "sliceName": "performerSiteType",
        "short": "type of dispensing organisation",
        "min": 1,
        "type": [
          {
            "code": "Extension",
            "profile": [
              "https://fhir.nhs.uk/StructureDefinition/Extension-DM-PerformerSiteType"
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "MedicationRequest.dispenseRequest.validityPeriod",
        "path": "MedicationRequest.dispenseRequest.validityPeriod",
        "mustSupport": true
      },
      {
        "id": "MedicationRequest.dispenseRequest.validityPeriod.start",
        "path": "MedicationRequest.dispenseRequest.validityPeriod.start",
        "min": 1
      },
      {
        "id": "MedicationRequest.dispenseRequest.numberOfRepeatsAllowed",
        "path": "MedicationRequest.dispenseRequest.numberOfRepeatsAllowed",
        "mustSupport": true
      },
      {
        "id": "MedicationRequest.dispenseRequest.quantity",
        "path": "MedicationRequest.dispenseRequest.quantity",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "MedicationRequest.dispenseRequest.quantity.value",
        "path": "MedicationRequest.dispenseRequest.quantity.value",
        "min": 1
      },
      {
        "id": "MedicationRequest.dispenseRequest.quantity.unit",
        "path": "MedicationRequest.dispenseRequest.quantity.unit",
        "min": 1
      },
      {
        "id": "MedicationRequest.dispenseRequest.quantity.code",
        "path": "MedicationRequest.dispenseRequest.quantity.code",
        "min": 1
      },
      {
        "id": "MedicationRequest.dispenseRequest.expectedSupplyDuration",
        "path": "MedicationRequest.dispenseRequest.expectedSupplyDuration",
        "mustSupport": true
      },
      {
        "id": "MedicationRequest.dispenseRequest.expectedSupplyDuration.value",
        "path": "MedicationRequest.dispenseRequest.expectedSupplyDuration.value",
        "min": 1
      },
      {
        "id": "MedicationRequest.dispenseRequest.expectedSupplyDuration.code",
        "path": "MedicationRequest.dispenseRequest.expectedSupplyDuration.code",
        "min": 1,
        "fixedCode": "d"
      },
      {
        "id": "MedicationRequest.dispenseRequest.performer",
        "path": "MedicationRequest.dispenseRequest.performer",
        "definition": "Indicates the intended dispensing Pharmacy specified by the patient. Can be sourced from nominatedPharmacy in the Patient Demographics Service (PDS)",
        "mustSupport": true
      },
      {
        "id": "MedicationRequest.dispenseRequest.performer.extension",
        "path": "MedicationRequest.dispenseRequest.performer.extension",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "url"
            }
          ],
          "rules": "open"
        }
      },
      {
        "id": "MedicationRequest.dispenseRequest.performer.extension:practitionerRole",
        "path": "MedicationRequest.dispenseRequest.performer.extension",
        "sliceName": "practitionerRole",
        "max": "1",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "https://fhir.nhs.uk/StructureDefinition/Extension-DM-DispensingPerformer"
            ]
          }
        ]
      },
      {
        "id": "MedicationRequest.dispenseRequest.performer.identifier",
        "path": "MedicationRequest.dispenseRequest.performer.identifier",
        "min": 1
      },
      {
        "id": "MedicationRequest.dispenseRequest.performer.identifier.system",
        "path": "MedicationRequest.dispenseRequest.performer.identifier.system",
        "min": 1,
        "fixedUri": "https://fhir.nhs.uk/Id/ods-organization-code"
      },
      {
        "id": "MedicationRequest.dispenseRequest.performer.identifier.value",
        "path": "MedicationRequest.dispenseRequest.performer.identifier.value",
        "min": 1
      },
      {
        "id": "MedicationRequest.substitution",
        "path": "MedicationRequest.substitution",
        "definition": "Indicates whether or not substitution can or should be part of the dispense. In some cases, substitution must happen, in other cases substitution must not happen. This block explains the prescriber's intent. If nothing is specified substitution may be done. In most cases this should default to false.",
        "comment": "Substituition is a mandatory requirement for EPS.",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "MedicationRequest.substitution.allowed[x]",
        "path": "MedicationRequest.substitution.allowed[x]",
        "type": [
          {
            "code": "boolean"
          }
        ]
      },
      {
        "id": "MedicationRequest.eventHistory",
        "path": "MedicationRequest.eventHistory",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://fhir.nhs.uk/StructureDefinition/DM-Provenance"
            ]
          }
        ]
      }
    ]
  }
}