{
  "resourceType": "StructureDefinition",
  "id": "EPMedPrescriptionBundle-5bb8442b-ce86-41fa-8c43-7dd413e82be6",
  "extension": [
    {
      "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-category",
      "valueString": "Foundation.Other"
    },
    {
      "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-security-category",
      "valueCode": "not-classified"
    }
  ],
  "url": "https://www.esante.lu/fhir-spec/StructureDefinition/EPMedPrescriptionBundle",
  "version": "0.1.0",
  "name": "EPMedPrescriptionBundle",
  "status": "draft",
  "fhirVersion": "4.0.1",
  "mapping": [
    {
      "identity": "v2",
      "uri": "http://hl7.org/v2",
      "name": "HL7 v2 Mapping"
    },
    {
      "identity": "rim",
      "uri": "http://hl7.org/v3",
      "name": "RIM Mapping"
    },
    {
      "identity": "cda",
      "uri": "http://hl7.org/v3/cda",
      "name": "CDA (R2)"
    },
    {
      "identity": "w5",
      "uri": "http://hl7.org/fhir/fivews",
      "name": "FiveWs Pattern Mapping"
    }
  ],
  "kind": "resource",
  "abstract": false,
  "type": "Bundle",
  "baseDefinition": "http://hl7.org/fhir/StructureDefinition/Bundle",
  "derivation": "constraint",
  "differential": {
    "element": [
      {
        "id": "Bundle",
        "path": "Bundle",
        "condition": [
          "val-SamePatientMedPres",
          "val-SamePSMedPresc"
        ],
        "constraint": [
          {
            "key": "val-SamePSMedPresc",
            "severity": "error",
            "human": "Health professional SHALL be the same",
            "expression": "Bundle.entry.resource.ofType(MedicationRequest).requester.reference.union(Bundle.entry.resource.ofType(CarePlan).author.reference).union(Bundle.entry.resource.ofType(DocumentReference).author.reference).count()=1",
            "source": "https://www.esante.lu/fhir-spec/StructureDefinition/EPMedPrescriptionBundle-5bb8442b-ce86-41fa-8c43-7dd413e82be6"
          },
          {
            "key": "val-SamePatientMedPres",
            "severity": "error",
            "human": "Patient SHALL be the same",
            "expression": "Bundle.entry.resource.ofType(MedicationRequest).subject.reference.union(Bundle.entry.resource.ofType(CarePlan).subject.reference).union(Bundle.entry.resource.ofType(DocumentReference).subject.reference).count()=1",
            "source": "https://www.esante.lu/fhir-spec/StructureDefinition/EPMedPrescriptionBundle-5bb8442b-ce86-41fa-8c43-7dd413e82be6"
          }
        ]
      },
      {
        "id": "Bundle.id",
        "path": "Bundle.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": "Bundle.meta",
        "path": "Bundle.meta",
        "min": 1
      },
      {
        "id": "Bundle.meta.id",
        "path": "Bundle.meta.id",
        "max": "0"
      },
      {
        "id": "Bundle.meta.versionId",
        "path": "Bundle.meta.versionId",
        "max": "0"
      },
      {
        "id": "Bundle.meta.lastUpdated",
        "path": "Bundle.meta.lastUpdated",
        "max": "0"
      },
      {
        "id": "Bundle.meta.source",
        "path": "Bundle.meta.source",
        "max": "0"
      },
      {
        "id": "Bundle.meta.profile",
        "path": "Bundle.meta.profile",
        "min": 1,
        "max": "1",
        "fixedCanonical": "https://www.esante.lu/fhir-spec/StructureDefinition/EPMedPrescriptionBundle"
      },
      {
        "id": "Bundle.meta.security",
        "path": "Bundle.meta.security",
        "max": "0"
      },
      {
        "id": "Bundle.meta.tag",
        "path": "Bundle.meta.tag",
        "max": "0"
      },
      {
        "id": "Bundle.implicitRules",
        "path": "Bundle.implicitRules",
        "max": "0"
      },
      {
        "id": "Bundle.language",
        "path": "Bundle.language",
        "max": "0"
      },
      {
        "id": "Bundle.identifier",
        "path": "Bundle.identifier",
        "max": "0"
      },
      {
        "id": "Bundle.type",
        "path": "Bundle.type",
        "definition": "Constant",
        "fixedCode": "transaction"
      },
      {
        "id": "Bundle.timestamp",
        "path": "Bundle.timestamp",
        "max": "0"
      },
      {
        "id": "Bundle.total",
        "path": "Bundle.total",
        "max": "0"
      },
      {
        "id": "Bundle.link",
        "path": "Bundle.link",
        "max": "0"
      },
      {
        "id": "Bundle.entry",
        "path": "Bundle.entry",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "resource.meta.profile"
            }
          ],
          "rules": "closed"
        },
        "min": 2
      },
      {
        "id": "Bundle.entry:prescription",
        "path": "Bundle.entry",
        "sliceName": "prescription",
        "short": "The prescription",
        "min": 1,
        "max": "1"
      },
      {
        "id": "Bundle.entry:prescription.id",
        "path": "Bundle.entry.id",
        "max": "0"
      },
      {
        "id": "Bundle.entry:prescription.link",
        "path": "Bundle.entry.link",
        "max": "0"
      },
      {
        "id": "Bundle.entry:prescription.fullUrl",
        "path": "Bundle.entry.fullUrl",
        "short": "UUID of the resource",
        "definition": "This is a UUID to identify the element inside the Bundle.\r\nIt SHALL start with urn:uuid: and then an UUID version 4 randomly generated. Its scope is only the Bundle, it is not linked outside from it and not saved.",
        "min": 1,
        "example": [
          {
            "label": "Valid example",
            "valueUri": "urn:uuid:d00069b7-1fc8-4397-bc7c-c9571319d890"
          }
        ],
        "condition": [
          "val-uuid"
        ],
        "constraint": [
          {
            "key": "val-uuid",
            "severity": "error",
            "human": "SHALL be a v4 UUID prefixed by urn:uuid:",
            "expression": "startsWith('urn:uuid:') and length()=45",
            "source": "https://www.esante.lu/fhir-spec/StructureDefinition/EPMedPrescriptionBundle"
          }
        ]
      },
      {
        "id": "Bundle.entry:prescription.resource",
        "path": "Bundle.entry.resource",
        "short": "The prescription",
        "min": 1,
        "type": [
          {
            "code": "CarePlan",
            "profile": [
              "https://www.esante.lu/fhir-spec/StructureDefinition/EPMedPrescription"
            ]
          }
        ]
      },
      {
        "id": "Bundle.entry:prescription.search",
        "path": "Bundle.entry.search",
        "max": "0"
      },
      {
        "id": "Bundle.entry:prescription.request",
        "path": "Bundle.entry.request",
        "min": 1
      },
      {
        "id": "Bundle.entry:prescription.request.id",
        "path": "Bundle.entry.request.id",
        "max": "0"
      },
      {
        "id": "Bundle.entry:prescription.request.method",
        "path": "Bundle.entry.request.method",
        "definition": "Constant",
        "fixedCode": "POST"
      },
      {
        "id": "Bundle.entry:prescription.request.url",
        "path": "Bundle.entry.request.url",
        "short": "Constant",
        "fixedUri": "CarePlan"
      },
      {
        "id": "Bundle.entry:prescription.request.ifNoneMatch",
        "path": "Bundle.entry.request.ifNoneMatch",
        "max": "0"
      },
      {
        "id": "Bundle.entry:prescription.request.ifModifiedSince",
        "path": "Bundle.entry.request.ifModifiedSince",
        "max": "0"
      },
      {
        "id": "Bundle.entry:prescription.request.ifMatch",
        "path": "Bundle.entry.request.ifMatch",
        "max": "0"
      },
      {
        "id": "Bundle.entry:prescription.request.ifNoneExist",
        "path": "Bundle.entry.request.ifNoneExist",
        "max": "0"
      },
      {
        "id": "Bundle.entry:prescription.response",
        "path": "Bundle.entry.response",
        "max": "0"
      },
      {
        "id": "Bundle.entry:prescriptionLine",
        "path": "Bundle.entry",
        "sliceName": "prescriptionLine",
        "short": "The prescription lines",
        "min": 1,
        "max": "*"
      },
      {
        "id": "Bundle.entry:prescriptionLine.id",
        "path": "Bundle.entry.id",
        "max": "0"
      },
      {
        "id": "Bundle.entry:prescriptionLine.link",
        "path": "Bundle.entry.link",
        "max": "0"
      },
      {
        "id": "Bundle.entry:prescriptionLine.fullUrl",
        "path": "Bundle.entry.fullUrl",
        "short": "UUID of the resource",
        "definition": "This is a UUID to identify the element inside the Bundle.\r\nIt SHALL start with urn:uuid: and then an UUID version 4 randomly generated. Its scope is only the Bundle, it is not linked outside from it and not saved.",
        "min": 1,
        "condition": [
          "val-uuid"
        ],
        "constraint": [
          {
            "key": "val-uuid",
            "severity": "error",
            "human": "SHALL be a v4 UUID prefixed by urn:uuid:",
            "expression": "startsWith('urn:uuid:') and length()=45",
            "source": "https://www.esante.lu/fhir-spec/StructureDefinition/EPMedPrescriptionBundle"
          }
        ]
      },
      {
        "id": "Bundle.entry:prescriptionLine.resource",
        "path": "Bundle.entry.resource",
        "min": 1,
        "type": [
          {
            "code": "MedicationRequest",
            "profile": [
              "https://www.esante.lu/fhir-spec/StructureDefinition/EPMedPrescriptionLine"
            ]
          }
        ]
      },
      {
        "id": "Bundle.entry:prescriptionLine.search",
        "path": "Bundle.entry.search",
        "max": "0"
      },
      {
        "id": "Bundle.entry:prescriptionLine.request",
        "path": "Bundle.entry.request",
        "min": 1
      },
      {
        "id": "Bundle.entry:prescriptionLine.request.id",
        "path": "Bundle.entry.request.id",
        "max": "0"
      },
      {
        "id": "Bundle.entry:prescriptionLine.request.method",
        "path": "Bundle.entry.request.method",
        "definition": "Constant",
        "fixedCode": "POST"
      },
      {
        "id": "Bundle.entry:prescriptionLine.request.url",
        "path": "Bundle.entry.request.url",
        "short": "Constant",
        "fixedUri": "MedicationRequest"
      },
      {
        "id": "Bundle.entry:prescriptionLine.request.ifNoneMatch",
        "path": "Bundle.entry.request.ifNoneMatch",
        "max": "0"
      },
      {
        "id": "Bundle.entry:prescriptionLine.request.ifModifiedSince",
        "path": "Bundle.entry.request.ifModifiedSince",
        "max": "0"
      },
      {
        "id": "Bundle.entry:prescriptionLine.request.ifMatch",
        "path": "Bundle.entry.request.ifMatch",
        "max": "0"
      },
      {
        "id": "Bundle.entry:prescriptionLine.request.ifNoneExist",
        "path": "Bundle.entry.request.ifNoneExist",
        "max": "0"
      },
      {
        "id": "Bundle.entry:prescriptionLine.response",
        "path": "Bundle.entry.response",
        "max": "0"
      },
      {
        "id": "Bundle.entry:pdfDocument",
        "path": "Bundle.entry",
        "sliceName": "pdfDocument",
        "short": "The prescription as PDF",
        "min": 0,
        "max": "*"
      },
      {
        "id": "Bundle.entry:pdfDocument.id",
        "path": "Bundle.entry.id",
        "max": "0"
      },
      {
        "id": "Bundle.entry:pdfDocument.link",
        "path": "Bundle.entry.link",
        "max": "0"
      },
      {
        "id": "Bundle.entry:pdfDocument.fullUrl",
        "path": "Bundle.entry.fullUrl",
        "short": "UUID of the resource",
        "definition": "This is a UUID to identify the element inside the Bundle.\r\nIt SHALL start with urn:uuid: and then an UUID version 4 randomly generated. Its scope is only the Bundle, it is not linked outside from it and not saved.",
        "min": 1,
        "constraint": [
          {
            "key": "val-uuid",
            "severity": "error",
            "human": "SHALL be a v4 UUID prefixed by urn:uuid:",
            "expression": "startsWith('urn:uuid:') and length()=45",
            "source": "https://www.esante.lu/fhir-spec/StructureDefinition/EPMedPrescriptionBundle"
          }
        ]
      },
      {
        "id": "Bundle.entry:pdfDocument.resource",
        "path": "Bundle.entry.resource",
        "min": 1,
        "type": [
          {
            "code": "DocumentReference",
            "profile": [
              "https://www.esante.lu/fhir-spec/StructureDefinition/EPMedDocumentRef"
            ]
          }
        ]
      },
      {
        "id": "Bundle.entry:pdfDocument.search",
        "path": "Bundle.entry.search",
        "max": "0"
      },
      {
        "id": "Bundle.entry:pdfDocument.request",
        "path": "Bundle.entry.request",
        "min": 1
      },
      {
        "id": "Bundle.entry:pdfDocument.request.id",
        "path": "Bundle.entry.request.id",
        "max": "0"
      },
      {
        "id": "Bundle.entry:pdfDocument.request.method",
        "path": "Bundle.entry.request.method",
        "short": "Constant",
        "fixedCode": "POST"
      },
      {
        "id": "Bundle.entry:pdfDocument.request.url",
        "path": "Bundle.entry.request.url",
        "short": "Constant",
        "fixedUri": "DocumentReference"
      },
      {
        "id": "Bundle.entry:pdfDocument.request.ifNoneMatch",
        "path": "Bundle.entry.request.ifNoneMatch",
        "max": "0"
      },
      {
        "id": "Bundle.entry:pdfDocument.request.ifModifiedSince",
        "path": "Bundle.entry.request.ifModifiedSince",
        "max": "0"
      },
      {
        "id": "Bundle.entry:pdfDocument.request.ifMatch",
        "path": "Bundle.entry.request.ifMatch",
        "max": "0"
      },
      {
        "id": "Bundle.entry:pdfDocument.request.ifNoneExist",
        "path": "Bundle.entry.request.ifNoneExist",
        "max": "0"
      },
      {
        "id": "Bundle.entry:pdfDocument.response",
        "path": "Bundle.entry.response",
        "max": "0"
      },
      {
        "id": "Bundle.entry:nonRefMedication",
        "path": "Bundle.entry",
        "sliceName": "nonRefMedication",
        "min": 0,
        "max": "*"
      },
      {
        "id": "Bundle.entry:nonRefMedication.id",
        "path": "Bundle.entry.id",
        "max": "0"
      },
      {
        "id": "Bundle.entry:nonRefMedication.link",
        "path": "Bundle.entry.link",
        "max": "0"
      },
      {
        "id": "Bundle.entry:nonRefMedication.fullUrl",
        "path": "Bundle.entry.fullUrl",
        "short": "UUID of the resource",
        "definition": "This is a UUID to identify the element inside the Bundle.\r\nIt SHALL start with urn:uuid: and then an UUID version 4 randomly generated. Its scope is only the Bundle, it is not linked outside from it and not saved.",
        "min": 1
      },
      {
        "id": "Bundle.entry:nonRefMedication.resource",
        "path": "Bundle.entry.resource",
        "short": "A reference to a medication",
        "min": 1,
        "type": [
          {
            "code": "Medication",
            "profile": [
              "https://www.esante.lu/fhir-spec/StructureDefinition/EPMedicationNoRef"
            ]
          }
        ]
      },
      {
        "id": "Bundle.entry:nonRefMedication.search",
        "path": "Bundle.entry.search",
        "max": "0"
      },
      {
        "id": "Bundle.entry:nonRefMedication.request",
        "path": "Bundle.entry.request",
        "min": 1
      },
      {
        "id": "Bundle.entry:nonRefMedication.request.id",
        "path": "Bundle.entry.request.id",
        "max": "0"
      },
      {
        "id": "Bundle.entry:nonRefMedication.request.method",
        "path": "Bundle.entry.request.method",
        "short": "Constant",
        "fixedCode": "POST"
      },
      {
        "id": "Bundle.entry:nonRefMedication.request.url",
        "path": "Bundle.entry.request.url",
        "short": "Constant",
        "fixedUri": "Medication"
      },
      {
        "id": "Bundle.entry:nonRefMedication.request.ifNoneMatch",
        "path": "Bundle.entry.request.ifNoneMatch",
        "max": "0"
      },
      {
        "id": "Bundle.entry:nonRefMedication.request.ifModifiedSince",
        "path": "Bundle.entry.request.ifModifiedSince",
        "max": "0"
      },
      {
        "id": "Bundle.entry:nonRefMedication.request.ifMatch",
        "path": "Bundle.entry.request.ifMatch",
        "max": "0"
      },
      {
        "id": "Bundle.entry:nonRefMedication.request.ifNoneExist",
        "path": "Bundle.entry.request.ifNoneExist",
        "max": "0"
      },
      {
        "id": "Bundle.entry:nonRefMedication.response",
        "path": "Bundle.entry.response",
        "max": "0"
      },
      {
        "id": "Bundle.signature",
        "path": "Bundle.signature",
        "max": "0"
      }
    ]
  }
}