<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="EPMedPrescriptionBundle-5bb8442b-ce86-41fa-8c43-7dd413e82be6" />
  <extension url="http://hl7.org/fhir/StructureDefinition/structuredefinition-category">
    <valueString value="Foundation.Other" />
  </extension>
  <extension url="http://hl7.org/fhir/StructureDefinition/structuredefinition-security-category">
    <valueCode value="not-classified" />
  </extension>
  <url value="https://www.esante.lu/fhir-spec/StructureDefinition/EPMedPrescriptionBundle" />
  <version value="0.1.0" />
  <name value="EPMedPrescriptionBundle" />
  <status value="draft" />
  <fhirVersion value="4.0.1" />
  <mapping>
    <identity value="v2" />
    <uri value="http://hl7.org/v2" />
    <name value="HL7 v2 Mapping" />
  </mapping>
  <mapping>
    <identity value="rim" />
    <uri value="http://hl7.org/v3" />
    <name value="RIM Mapping" />
  </mapping>
  <mapping>
    <identity value="cda" />
    <uri value="http://hl7.org/v3/cda" />
    <name value="CDA (R2)" />
  </mapping>
  <mapping>
    <identity value="w5" />
    <uri value="http://hl7.org/fhir/fivews" />
    <name value="FiveWs Pattern Mapping" />
  </mapping>
  <kind value="resource" />
  <abstract value="false" />
  <type value="Bundle" />
  <baseDefinition value="http://hl7.org/fhir/StructureDefinition/Bundle" />
  <derivation value="constraint" />
  <differential>
    <element id="Bundle">
      <path value="Bundle" />
      <condition value="val-SamePatientMedPres" />
      <condition value="val-SamePSMedPresc" />
      <constraint>
        <key value="val-SamePSMedPresc" />
        <severity value="error" />
        <human value="Health professional SHALL be the same" />
        <expression value="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 value="https://www.esante.lu/fhir-spec/StructureDefinition/EPMedPrescriptionBundle-5bb8442b-ce86-41fa-8c43-7dd413e82be6" />
      </constraint>
      <constraint>
        <key value="val-SamePatientMedPres" />
        <severity value="error" />
        <human value="Patient SHALL be the same" />
        <expression value="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 value="https://www.esante.lu/fhir-spec/StructureDefinition/EPMedPrescriptionBundle-5bb8442b-ce86-41fa-8c43-7dd413e82be6" />
      </constraint>
    </element>
    <element id="Bundle.id">
      <path value="Bundle.id" />
      <definition value="The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes.&#xD;&#xA;Is assigned by the server, do not provide a value." />
    </element>
    <element id="Bundle.meta">
      <path value="Bundle.meta" />
      <min value="1" />
    </element>
    <element id="Bundle.meta.id">
      <path value="Bundle.meta.id" />
      <max value="0" />
    </element>
    <element id="Bundle.meta.versionId">
      <path value="Bundle.meta.versionId" />
      <max value="0" />
    </element>
    <element id="Bundle.meta.lastUpdated">
      <path value="Bundle.meta.lastUpdated" />
      <max value="0" />
    </element>
    <element id="Bundle.meta.source">
      <path value="Bundle.meta.source" />
      <max value="0" />
    </element>
    <element id="Bundle.meta.profile">
      <path value="Bundle.meta.profile" />
      <min value="1" />
      <max value="1" />
      <fixedCanonical value="https://www.esante.lu/fhir-spec/StructureDefinition/EPMedPrescriptionBundle" />
    </element>
    <element id="Bundle.meta.security">
      <path value="Bundle.meta.security" />
      <max value="0" />
    </element>
    <element id="Bundle.meta.tag">
      <path value="Bundle.meta.tag" />
      <max value="0" />
    </element>
    <element id="Bundle.implicitRules">
      <path value="Bundle.implicitRules" />
      <max value="0" />
    </element>
    <element id="Bundle.language">
      <path value="Bundle.language" />
      <max value="0" />
    </element>
    <element id="Bundle.identifier">
      <path value="Bundle.identifier" />
      <max value="0" />
    </element>
    <element id="Bundle.type">
      <path value="Bundle.type" />
      <definition value="Constant" />
      <fixedCode value="transaction" />
    </element>
    <element id="Bundle.timestamp">
      <path value="Bundle.timestamp" />
      <max value="0" />
    </element>
    <element id="Bundle.total">
      <path value="Bundle.total" />
      <max value="0" />
    </element>
    <element id="Bundle.link">
      <path value="Bundle.link" />
      <max value="0" />
    </element>
    <element id="Bundle.entry">
      <path value="Bundle.entry" />
      <slicing>
        <discriminator>
          <type value="value" />
          <path value="resource.meta.profile" />
        </discriminator>
        <rules value="closed" />
      </slicing>
      <min value="2" />
    </element>
    <element id="Bundle.entry:prescription">
      <path value="Bundle.entry" />
      <sliceName value="prescription" />
      <short value="The prescription" />
      <min value="1" />
      <max value="1" />
    </element>
    <element id="Bundle.entry:prescription.id">
      <path value="Bundle.entry.id" />
      <max value="0" />
    </element>
    <element id="Bundle.entry:prescription.link">
      <path value="Bundle.entry.link" />
      <max value="0" />
    </element>
    <element id="Bundle.entry:prescription.fullUrl">
      <path value="Bundle.entry.fullUrl" />
      <short value="UUID of the resource" />
      <definition value="This is a UUID to identify the element inside the Bundle.&#xD;&#xA;It 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 value="1" />
      <example>
        <label value="Valid example" />
        <valueUri value="urn:uuid:d00069b7-1fc8-4397-bc7c-c9571319d890" />
      </example>
      <condition value="val-uuid" />
      <constraint>
        <key value="val-uuid" />
        <severity value="error" />
        <human value="SHALL be a v4 UUID prefixed by urn:uuid:" />
        <expression value="startsWith('urn:uuid:') and length()=45" />
        <source value="https://www.esante.lu/fhir-spec/StructureDefinition/EPMedPrescriptionBundle" />
      </constraint>
    </element>
    <element id="Bundle.entry:prescription.resource">
      <path value="Bundle.entry.resource" />
      <short value="The prescription" />
      <min value="1" />
      <type>
        <code value="CarePlan" />
        <profile value="https://www.esante.lu/fhir-spec/StructureDefinition/EPMedPrescription" />
      </type>
    </element>
    <element id="Bundle.entry:prescription.search">
      <path value="Bundle.entry.search" />
      <max value="0" />
    </element>
    <element id="Bundle.entry:prescription.request">
      <path value="Bundle.entry.request" />
      <min value="1" />
    </element>
    <element id="Bundle.entry:prescription.request.id">
      <path value="Bundle.entry.request.id" />
      <max value="0" />
    </element>
    <element id="Bundle.entry:prescription.request.method">
      <path value="Bundle.entry.request.method" />
      <definition value="Constant" />
      <fixedCode value="POST" />
    </element>
    <element id="Bundle.entry:prescription.request.url">
      <path value="Bundle.entry.request.url" />
      <short value="Constant" />
      <fixedUri value="CarePlan" />
    </element>
    <element id="Bundle.entry:prescription.request.ifNoneMatch">
      <path value="Bundle.entry.request.ifNoneMatch" />
      <max value="0" />
    </element>
    <element id="Bundle.entry:prescription.request.ifModifiedSince">
      <path value="Bundle.entry.request.ifModifiedSince" />
      <max value="0" />
    </element>
    <element id="Bundle.entry:prescription.request.ifMatch">
      <path value="Bundle.entry.request.ifMatch" />
      <max value="0" />
    </element>
    <element id="Bundle.entry:prescription.request.ifNoneExist">
      <path value="Bundle.entry.request.ifNoneExist" />
      <max value="0" />
    </element>
    <element id="Bundle.entry:prescription.response">
      <path value="Bundle.entry.response" />
      <max value="0" />
    </element>
    <element id="Bundle.entry:prescriptionLine">
      <path value="Bundle.entry" />
      <sliceName value="prescriptionLine" />
      <short value="The prescription lines" />
      <min value="1" />
      <max value="*" />
    </element>
    <element id="Bundle.entry:prescriptionLine.id">
      <path value="Bundle.entry.id" />
      <max value="0" />
    </element>
    <element id="Bundle.entry:prescriptionLine.link">
      <path value="Bundle.entry.link" />
      <max value="0" />
    </element>
    <element id="Bundle.entry:prescriptionLine.fullUrl">
      <path value="Bundle.entry.fullUrl" />
      <short value="UUID of the resource" />
      <definition value="This is a UUID to identify the element inside the Bundle.&#xD;&#xA;It 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 value="1" />
      <condition value="val-uuid" />
      <constraint>
        <key value="val-uuid" />
        <severity value="error" />
        <human value="SHALL be a v4 UUID prefixed by urn:uuid:" />
        <expression value="startsWith('urn:uuid:') and length()=45" />
        <source value="https://www.esante.lu/fhir-spec/StructureDefinition/EPMedPrescriptionBundle" />
      </constraint>
    </element>
    <element id="Bundle.entry:prescriptionLine.resource">
      <path value="Bundle.entry.resource" />
      <min value="1" />
      <type>
        <code value="MedicationRequest" />
        <profile value="https://www.esante.lu/fhir-spec/StructureDefinition/EPMedPrescriptionLine" />
      </type>
    </element>
    <element id="Bundle.entry:prescriptionLine.search">
      <path value="Bundle.entry.search" />
      <max value="0" />
    </element>
    <element id="Bundle.entry:prescriptionLine.request">
      <path value="Bundle.entry.request" />
      <min value="1" />
    </element>
    <element id="Bundle.entry:prescriptionLine.request.id">
      <path value="Bundle.entry.request.id" />
      <max value="0" />
    </element>
    <element id="Bundle.entry:prescriptionLine.request.method">
      <path value="Bundle.entry.request.method" />
      <definition value="Constant" />
      <fixedCode value="POST" />
    </element>
    <element id="Bundle.entry:prescriptionLine.request.url">
      <path value="Bundle.entry.request.url" />
      <short value="Constant" />
      <fixedUri value="MedicationRequest" />
    </element>
    <element id="Bundle.entry:prescriptionLine.request.ifNoneMatch">
      <path value="Bundle.entry.request.ifNoneMatch" />
      <max value="0" />
    </element>
    <element id="Bundle.entry:prescriptionLine.request.ifModifiedSince">
      <path value="Bundle.entry.request.ifModifiedSince" />
      <max value="0" />
    </element>
    <element id="Bundle.entry:prescriptionLine.request.ifMatch">
      <path value="Bundle.entry.request.ifMatch" />
      <max value="0" />
    </element>
    <element id="Bundle.entry:prescriptionLine.request.ifNoneExist">
      <path value="Bundle.entry.request.ifNoneExist" />
      <max value="0" />
    </element>
    <element id="Bundle.entry:prescriptionLine.response">
      <path value="Bundle.entry.response" />
      <max value="0" />
    </element>
    <element id="Bundle.entry:pdfDocument">
      <path value="Bundle.entry" />
      <sliceName value="pdfDocument" />
      <short value="The prescription as PDF" />
      <min value="0" />
      <max value="*" />
    </element>
    <element id="Bundle.entry:pdfDocument.id">
      <path value="Bundle.entry.id" />
      <max value="0" />
    </element>
    <element id="Bundle.entry:pdfDocument.link">
      <path value="Bundle.entry.link" />
      <max value="0" />
    </element>
    <element id="Bundle.entry:pdfDocument.fullUrl">
      <path value="Bundle.entry.fullUrl" />
      <short value="UUID of the resource" />
      <definition value="This is a UUID to identify the element inside the Bundle.&#xD;&#xA;It 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 value="1" />
      <constraint>
        <key value="val-uuid" />
        <severity value="error" />
        <human value="SHALL be a v4 UUID prefixed by urn:uuid:" />
        <expression value="startsWith('urn:uuid:') and length()=45" />
        <source value="https://www.esante.lu/fhir-spec/StructureDefinition/EPMedPrescriptionBundle" />
      </constraint>
    </element>
    <element id="Bundle.entry:pdfDocument.resource">
      <path value="Bundle.entry.resource" />
      <min value="1" />
      <type>
        <code value="DocumentReference" />
        <profile value="https://www.esante.lu/fhir-spec/StructureDefinition/EPMedDocumentRef" />
      </type>
    </element>
    <element id="Bundle.entry:pdfDocument.search">
      <path value="Bundle.entry.search" />
      <max value="0" />
    </element>
    <element id="Bundle.entry:pdfDocument.request">
      <path value="Bundle.entry.request" />
      <min value="1" />
    </element>
    <element id="Bundle.entry:pdfDocument.request.id">
      <path value="Bundle.entry.request.id" />
      <max value="0" />
    </element>
    <element id="Bundle.entry:pdfDocument.request.method">
      <path value="Bundle.entry.request.method" />
      <short value="Constant" />
      <fixedCode value="POST" />
    </element>
    <element id="Bundle.entry:pdfDocument.request.url">
      <path value="Bundle.entry.request.url" />
      <short value="Constant" />
      <fixedUri value="DocumentReference" />
    </element>
    <element id="Bundle.entry:pdfDocument.request.ifNoneMatch">
      <path value="Bundle.entry.request.ifNoneMatch" />
      <max value="0" />
    </element>
    <element id="Bundle.entry:pdfDocument.request.ifModifiedSince">
      <path value="Bundle.entry.request.ifModifiedSince" />
      <max value="0" />
    </element>
    <element id="Bundle.entry:pdfDocument.request.ifMatch">
      <path value="Bundle.entry.request.ifMatch" />
      <max value="0" />
    </element>
    <element id="Bundle.entry:pdfDocument.request.ifNoneExist">
      <path value="Bundle.entry.request.ifNoneExist" />
      <max value="0" />
    </element>
    <element id="Bundle.entry:pdfDocument.response">
      <path value="Bundle.entry.response" />
      <max value="0" />
    </element>
    <element id="Bundle.entry:nonRefMedication">
      <path value="Bundle.entry" />
      <sliceName value="nonRefMedication" />
      <min value="0" />
      <max value="*" />
    </element>
    <element id="Bundle.entry:nonRefMedication.id">
      <path value="Bundle.entry.id" />
      <max value="0" />
    </element>
    <element id="Bundle.entry:nonRefMedication.link">
      <path value="Bundle.entry.link" />
      <max value="0" />
    </element>
    <element id="Bundle.entry:nonRefMedication.fullUrl">
      <path value="Bundle.entry.fullUrl" />
      <short value="UUID of the resource" />
      <definition value="This is a UUID to identify the element inside the Bundle.&#xD;&#xA;It 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 value="1" />
    </element>
    <element id="Bundle.entry:nonRefMedication.resource">
      <path value="Bundle.entry.resource" />
      <short value="A reference to a medication" />
      <min value="1" />
      <type>
        <code value="Medication" />
        <profile value="https://www.esante.lu/fhir-spec/StructureDefinition/EPMedicationNoRef" />
      </type>
    </element>
    <element id="Bundle.entry:nonRefMedication.search">
      <path value="Bundle.entry.search" />
      <max value="0" />
    </element>
    <element id="Bundle.entry:nonRefMedication.request">
      <path value="Bundle.entry.request" />
      <min value="1" />
    </element>
    <element id="Bundle.entry:nonRefMedication.request.id">
      <path value="Bundle.entry.request.id" />
      <max value="0" />
    </element>
    <element id="Bundle.entry:nonRefMedication.request.method">
      <path value="Bundle.entry.request.method" />
      <short value="Constant" />
      <fixedCode value="POST" />
    </element>
    <element id="Bundle.entry:nonRefMedication.request.url">
      <path value="Bundle.entry.request.url" />
      <short value="Constant" />
      <fixedUri value="Medication" />
    </element>
    <element id="Bundle.entry:nonRefMedication.request.ifNoneMatch">
      <path value="Bundle.entry.request.ifNoneMatch" />
      <max value="0" />
    </element>
    <element id="Bundle.entry:nonRefMedication.request.ifModifiedSince">
      <path value="Bundle.entry.request.ifModifiedSince" />
      <max value="0" />
    </element>
    <element id="Bundle.entry:nonRefMedication.request.ifMatch">
      <path value="Bundle.entry.request.ifMatch" />
      <max value="0" />
    </element>
    <element id="Bundle.entry:nonRefMedication.request.ifNoneExist">
      <path value="Bundle.entry.request.ifNoneExist" />
      <max value="0" />
    </element>
    <element id="Bundle.entry:nonRefMedication.response">
      <path value="Bundle.entry.response" />
      <max value="0" />
    </element>
    <element id="Bundle.signature">
      <path value="Bundle.signature" />
      <max value="0" />
    </element>
  </differential>
</StructureDefinition>