{
  "resourceType": "StructureDefinition",
  "id": "EPMedPrescription-8a68addb-3d98-492d-95ef-9a611eb77e36",
  "extension": [
    {
      "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-category",
      "valueString": "Clinical.Care Provision"
    },
    {
      "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-security-category",
      "valueCode": "patient"
    }
  ],
  "url": "https://www.esante.lu/fhir-spec/StructureDefinition/EPMedPrescription",
  "version": "0.1.0",
  "name": "EPMedPrescription",
  "status": "draft",
  "fhirVersion": "4.0.1",
  "mapping": [
    {
      "identity": "workflow",
      "uri": "http://hl7.org/fhir/workflow",
      "name": "Workflow Pattern"
    },
    {
      "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": "CarePlan",
  "baseDefinition": "http://hl7.org/fhir/StructureDefinition/CarePlan",
  "derivation": "constraint",
  "differential": {
    "element": [
      {
        "id": "CarePlan",
        "path": "CarePlan",
        "condition": [
          "val-PrescriptionDate"
        ],
        "constraint": [
          {
            "key": "val-PrescriptionDate",
            "severity": "error",
            "human": "The date of creation of the prescription SHALL match its validity start date",
            "expression": "period.start = created",
            "source": "https://www.esante.lu/fhir-spec/StructureDefinition/EPMedPrescription-8a68addb-3d98-492d-95ef-9a611eb77e36"
          }
        ]
      },
      {
        "id": "CarePlan.id",
        "path": "CarePlan.id",
        "definition": "The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes.\r\nIs assigned by the server, do not provide a value."
      },
      {
        "id": "CarePlan.meta",
        "path": "CarePlan.meta",
        "min": 1
      },
      {
        "id": "CarePlan.meta.id",
        "path": "CarePlan.meta.id",
        "max": "0"
      },
      {
        "id": "CarePlan.meta.versionId",
        "path": "CarePlan.meta.versionId",
        "max": "0"
      },
      {
        "id": "CarePlan.meta.lastUpdated",
        "path": "CarePlan.meta.lastUpdated",
        "max": "0"
      },
      {
        "id": "CarePlan.meta.source",
        "path": "CarePlan.meta.source",
        "max": "0"
      },
      {
        "id": "CarePlan.meta.profile",
        "path": "CarePlan.meta.profile",
        "min": 1,
        "max": "1",
        "fixedCanonical": "https://www.esante.lu/fhir-spec/StructureDefinition/EPMedPrescription"
      },
      {
        "id": "CarePlan.meta.security",
        "path": "CarePlan.meta.security",
        "max": "0"
      },
      {
        "id": "CarePlan.meta.tag",
        "path": "CarePlan.meta.tag",
        "max": "0"
      },
      {
        "id": "CarePlan.implicitRules",
        "path": "CarePlan.implicitRules",
        "max": "0"
      },
      {
        "id": "CarePlan.language",
        "path": "CarePlan.language",
        "max": "0"
      },
      {
        "id": "CarePlan.text",
        "path": "CarePlan.text",
        "max": "0"
      },
      {
        "id": "CarePlan.contained",
        "path": "CarePlan.contained",
        "max": "0"
      },
      {
        "id": "CarePlan.extension",
        "path": "CarePlan.extension",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "url"
            }
          ],
          "rules": "closed"
        },
        "min": 1
      },
      {
        "id": "CarePlan.extension:PatientInstruction",
        "path": "CarePlan.extension",
        "sliceName": "PatientInstruction",
        "min": 0,
        "max": "*",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "https://www.esante.lu/fhir-spec/StructureDefinition/EPPatientInstructionText"
            ]
          }
        ]
      },
      {
        "id": "CarePlan.extension:OrderDetail",
        "path": "CarePlan.extension",
        "sliceName": "OrderDetail",
        "short": "Informations for the dispenser.",
        "min": 0,
        "max": "*",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "https://www.esante.lu/fhir-spec/StructureDefinition/EPOrderDetail"
            ]
          }
        ]
      },
      {
        "id": "CarePlan.extension:contact",
        "path": "CarePlan.extension",
        "sliceName": "contact",
        "short": "Contact",
        "definition": "At least one phone number shall be given so that the fulfiller can call back for questions",
        "min": 1,
        "max": "*",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "https://www.esante.lu/fhir-spec/StructureDefinition/EPContactExtension"
            ]
          }
        ]
      },
      {
        "id": "CarePlan.identifier",
        "path": "CarePlan.identifier",
        "short": "Identifier of the prescription",
        "min": 1,
        "max": "1",
        "type": [
          {
            "code": "Identifier",
            "profile": [
              "https://www.esante.lu/fhir-spec/StructureDefinition/EPSimpleIdentifier"
            ]
          }
        ]
      },
      {
        "id": "CarePlan.instantiatesCanonical",
        "path": "CarePlan.instantiatesCanonical",
        "max": "0"
      },
      {
        "id": "CarePlan.instantiatesUri",
        "path": "CarePlan.instantiatesUri",
        "max": "0"
      },
      {
        "id": "CarePlan.basedOn",
        "path": "CarePlan.basedOn",
        "max": "0"
      },
      {
        "id": "CarePlan.replaces",
        "path": "CarePlan.replaces",
        "max": "0"
      },
      {
        "id": "CarePlan.partOf",
        "path": "CarePlan.partOf",
        "max": "0"
      },
      {
        "id": "CarePlan.status",
        "path": "CarePlan.status",
        "definition": "Normally only active status are sent and retrieved, but a prescription itself may have another statuses",
        "condition": [
          "val-presStatus"
        ],
        "constraint": [
          {
            "key": "val-presStatus",
            "severity": "error",
            "human": "Only the statuses active, completed or revoked are used",
            "expression": "($this = 'active') or ($this = 'completed') or ($this = 'revoked') or ($this = 'entered-in-error')",
            "source": "https://www.esante.lu/fhir-spec/StructureDefinition/EPMedPrescription"
          }
        ]
      },
      {
        "id": "CarePlan.intent",
        "path": "CarePlan.intent",
        "definition": "Constant",
        "fixedCode": "order"
      },
      {
        "id": "CarePlan.category",
        "path": "CarePlan.category",
        "min": 1,
        "max": "1"
      },
      {
        "id": "CarePlan.category.id",
        "path": "CarePlan.category.id",
        "max": "0"
      },
      {
        "id": "CarePlan.category.coding",
        "path": "CarePlan.category.coding",
        "min": 1,
        "max": "1",
        "fixedCoding": {
          "code": "MED_PRESC",
          "system": "urn:oid:1.3.182.5.56"
        }
      },
      {
        "id": "CarePlan.category.coding.id",
        "path": "CarePlan.category.coding.id",
        "max": "0"
      },
      {
        "id": "CarePlan.category.coding.system",
        "path": "CarePlan.category.coding.system",
        "min": 1
      },
      {
        "id": "CarePlan.category.coding.version",
        "path": "CarePlan.category.coding.version",
        "max": "0"
      },
      {
        "id": "CarePlan.category.coding.code",
        "path": "CarePlan.category.coding.code",
        "definition": "A symbol in syntax defined by the system.",
        "min": 1
      },
      {
        "id": "CarePlan.category.coding.display",
        "path": "CarePlan.category.coding.display",
        "max": "0"
      },
      {
        "id": "CarePlan.category.coding.userSelected",
        "path": "CarePlan.category.coding.userSelected",
        "max": "0"
      },
      {
        "id": "CarePlan.category.text",
        "path": "CarePlan.category.text",
        "max": "0"
      },
      {
        "id": "CarePlan.title",
        "path": "CarePlan.title",
        "max": "0"
      },
      {
        "id": "CarePlan.description",
        "path": "CarePlan.description",
        "max": "0"
      },
      {
        "id": "CarePlan.subject",
        "path": "CarePlan.subject",
        "short": "The patient",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://www.esante.lu/fhir-spec/StructureDefinition/EPPatient"
            ],
            "aggregation": [
              "referenced"
            ]
          }
        ]
      },
      {
        "id": "CarePlan.subject.id",
        "path": "CarePlan.subject.id",
        "max": "0"
      },
      {
        "id": "CarePlan.subject.reference",
        "path": "CarePlan.subject.reference",
        "short": "The patient refered by its matricule",
        "min": 1,
        "example": [
          {
            "label": "Example",
            "valueString": "Patient?identifier=urn:oid:1.3.182.4.4|1904112000166"
          }
        ],
        "condition": [
          "val-patByMatricule"
        ],
        "constraint": [
          {
            "key": "val-patByMatricule",
            "severity": "error",
            "human": "The Patient SHALL be referenced by its matricule",
            "expression": "startsWith('Patient?identifier=urn:oid:1.3.182.4.4|') and length()=52",
            "source": "https://www.esante.lu/fhir-spec/StructureDefinition/EPMedPrescription"
          }
        ]
      },
      {
        "id": "CarePlan.subject.type",
        "path": "CarePlan.subject.type",
        "max": "0"
      },
      {
        "id": "CarePlan.subject.identifier",
        "path": "CarePlan.subject.identifier",
        "max": "0"
      },
      {
        "id": "CarePlan.subject.display",
        "path": "CarePlan.subject.display",
        "max": "0"
      },
      {
        "id": "CarePlan.encounter",
        "path": "CarePlan.encounter",
        "max": "0"
      },
      {
        "id": "CarePlan.period",
        "path": "CarePlan.period",
        "short": "Prescription validity",
        "min": 1
      },
      {
        "id": "CarePlan.period.id",
        "path": "CarePlan.period.id",
        "max": "0"
      },
      {
        "id": "CarePlan.period.start",
        "path": "CarePlan.period.start",
        "min": 1,
        "example": [
          {
            "label": "Example",
            "valueDateTime": "2021-10-01"
          }
        ]
      },
      {
        "id": "CarePlan.period.end",
        "path": "CarePlan.period.end",
        "short": "End time with inclusive boundary",
        "example": [
          {
            "label": "Example",
            "valueDateTime": "2022-03-01"
          }
        ]
      },
      {
        "id": "CarePlan.created",
        "path": "CarePlan.created",
        "short": "Date when the prescription was made. SHALL match period.start",
        "min": 1,
        "example": [
          {
            "label": "Example",
            "valueDateTime": "2021-10-01"
          }
        ]
      },
      {
        "id": "CarePlan.author",
        "path": "CarePlan.author",
        "short": "Author of the prescription",
        "min": 1,
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://www.esante.lu/fhir-spec/StructureDefinition/EPPractitioner"
            ],
            "aggregation": [
              "referenced"
            ]
          }
        ]
      },
      {
        "id": "CarePlan.author.id",
        "path": "CarePlan.author.id",
        "max": "0"
      },
      {
        "id": "CarePlan.author.reference",
        "path": "CarePlan.author.reference",
        "short": "The health professional referred by its eHealthID",
        "min": 1,
        "example": [
          {
            "label": "Example",
            "valueString": "Practitioner?identifier=urn:oid:1.3.182.4.1|2999999617"
          }
        ],
        "condition": [
          "val-1"
        ],
        "constraint": [
          {
            "key": "val-1",
            "severity": "error",
            "human": "A Practitioner SHALL be referenced by its eHealthID",
            "expression": "startsWith('Practitioner?identifier=urn:oid:1.3.182.4.1|2') and length()=54",
            "source": "https://www.esante.lu/fhir-spec/StructureDefinition/EPMedPrescription"
          }
        ]
      },
      {
        "id": "CarePlan.author.type",
        "path": "CarePlan.author.type",
        "max": "0"
      },
      {
        "id": "CarePlan.author.identifier",
        "path": "CarePlan.author.identifier",
        "max": "0"
      },
      {
        "id": "CarePlan.author.display",
        "path": "CarePlan.author.display",
        "max": "0"
      },
      {
        "id": "CarePlan.contributor",
        "path": "CarePlan.contributor",
        "short": "The organisation responsible for the prescription",
        "max": "1",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://hl7.org/fhir/StructureDefinition/Organization"
            ],
            "aggregation": [
              "referenced"
            ]
          }
        ]
      },
      {
        "id": "CarePlan.contributor.id",
        "path": "CarePlan.contributor.id",
        "max": "0"
      },
      {
        "id": "CarePlan.contributor.reference",
        "path": "CarePlan.contributor.reference",
        "short": "The organization referenced by its eHealthID",
        "min": 1,
        "example": [
          {
            "label": "Example",
            "valueString": "Organization?identifier=urn:oid:1.3.182.4.1|1000180763"
          }
        ],
        "condition": [
          "val-orgByEhealthID"
        ],
        "constraint": [
          {
            "key": "val-orgByEhealthID",
            "severity": "error",
            "human": "SHALL reference an organization by its eHealthID",
            "expression": "startsWith('Organization?identifier=urn:oid:1.3.182.4.1|1') and length()=54",
            "source": "https://www.esante.lu/fhir-spec/StructureDefinition/EPMedPrescription"
          }
        ]
      },
      {
        "id": "CarePlan.contributor.type",
        "path": "CarePlan.contributor.type",
        "max": "0"
      },
      {
        "id": "CarePlan.contributor.identifier",
        "path": "CarePlan.contributor.identifier",
        "max": "0"
      },
      {
        "id": "CarePlan.contributor.display",
        "path": "CarePlan.contributor.display",
        "max": "0"
      },
      {
        "id": "CarePlan.careTeam",
        "path": "CarePlan.careTeam",
        "max": "0"
      },
      {
        "id": "CarePlan.addresses",
        "path": "CarePlan.addresses",
        "max": "0"
      },
      {
        "id": "CarePlan.supportingInfo",
        "path": "CarePlan.supportingInfo",
        "max": "0",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://www.esante.lu/fhir-spec/StructureDefinition/EPLabObservation",
              "https://www.esante.lu/fhir-spec/StructureDefinition/EPLabCondition",
              "https://www.esante.lu/fhir-spec/StructureDefinition/EPLabMedicationStatement"
            ],
            "aggregation": [
              "referenced"
            ]
          }
        ]
      },
      {
        "id": "CarePlan.supportingInfo.reference",
        "path": "CarePlan.supportingInfo.reference",
        "min": 1
      },
      {
        "id": "CarePlan.supportingInfo.type",
        "path": "CarePlan.supportingInfo.type",
        "max": "0"
      },
      {
        "id": "CarePlan.supportingInfo.identifier",
        "path": "CarePlan.supportingInfo.identifier",
        "max": "0"
      },
      {
        "id": "CarePlan.supportingInfo.display",
        "path": "CarePlan.supportingInfo.display",
        "max": "0"
      },
      {
        "id": "CarePlan.goal",
        "path": "CarePlan.goal",
        "max": "0"
      },
      {
        "id": "CarePlan.activity",
        "path": "CarePlan.activity",
        "short": "The list of prescription lines",
        "min": 1
      },
      {
        "id": "CarePlan.activity.id",
        "path": "CarePlan.activity.id",
        "max": "0"
      },
      {
        "id": "CarePlan.activity.outcomeCodeableConcept",
        "path": "CarePlan.activity.outcomeCodeableConcept",
        "max": "0"
      },
      {
        "id": "CarePlan.activity.outcomeReference",
        "path": "CarePlan.activity.outcomeReference",
        "max": "0"
      },
      {
        "id": "CarePlan.activity.progress",
        "path": "CarePlan.activity.progress",
        "max": "0"
      },
      {
        "id": "CarePlan.activity.reference",
        "path": "CarePlan.activity.reference",
        "min": 1,
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://www.esante.lu/fhir-spec/StructureDefinition/EPMedPrescriptionLine"
            ]
          }
        ]
      },
      {
        "id": "CarePlan.activity.reference.id",
        "path": "CarePlan.activity.reference.id",
        "max": "0"
      },
      {
        "id": "CarePlan.activity.reference.reference",
        "path": "CarePlan.activity.reference.reference",
        "short": "The prescription line identified  by its fullUrl",
        "min": 1,
        "example": [
          {
            "label": "Example",
            "valueString": "MedicationRequest/urn:uuid:bef142ae-5487-45ce-9467-2e59ca8893ac"
          }
        ],
        "condition": [
          "val-refMedRequestLocal"
        ],
        "constraint": [
          {
            "key": "val-refMedRequestLocal",
            "severity": "error",
            "human": "SHALL reference the prescription line by its fullUrl",
            "expression": "startsWith('MedicationRequest/urn:uuid:') and length()=63",
            "source": "https://www.esante.lu/fhir-spec/StructureDefinition/EPMedPrescription"
          }
        ]
      },
      {
        "id": "CarePlan.activity.reference.type",
        "path": "CarePlan.activity.reference.type",
        "max": "0"
      },
      {
        "id": "CarePlan.activity.reference.identifier",
        "path": "CarePlan.activity.reference.identifier",
        "max": "0"
      },
      {
        "id": "CarePlan.activity.reference.display",
        "path": "CarePlan.activity.reference.display",
        "max": "0"
      },
      {
        "id": "CarePlan.activity.detail",
        "path": "CarePlan.activity.detail",
        "max": "0"
      },
      {
        "id": "CarePlan.note",
        "path": "CarePlan.note",
        "max": "0"
      }
    ]
  }
}