<StructureDefinition xmlns="http://hl7.org/fhir">
  <url value="http://electronichealth.se/fhir/StructureDefinition/NLLDispensePaperPrescription" />
  <version value="1.3.0" />
  <name value="NLLDispensePaperPrescription" />
  <status value="active" />
  <date value="2025-07-04" />
  <publisher value="Swedish eHealth Agency" />
  <fhirVersion value="4.0.1" />
  <mapping>
    <identity value="EHM" />
    <uri value="http://ehalsomyndigheten.se" />
    <name value="E-hälsomyndighetens internal model" />
  </mapping>
  <mapping>
    <identity value="workflow" />
    <uri value="http://hl7.org/fhir/workflow" />
    <name value="Workflow Pattern" />
  </mapping>
  <mapping>
    <identity value="rim" />
    <uri value="http://hl7.org/v3" />
    <name value="RIM Mapping" />
  </mapping>
  <mapping>
    <identity value="w5" />
    <uri value="http://hl7.org/fhir/fivews" />
    <name value="FiveWs Pattern Mapping" />
  </mapping>
  <mapping>
    <identity value="rx-dispense-rmim" />
    <uri value="http://www.hl7.org/v3/PORX_RM020070UV" />
    <name value="V3 Pharmacy Dispense RMIM" />
  </mapping>
  <mapping>
    <identity value="v2" />
    <uri value="http://hl7.org/v2" />
    <name value="HL7 v2 Mapping" />
  </mapping>
  <kind value="resource" />
  <abstract value="false" />
  <type value="MedicationDispense" />
  <baseDefinition value="http://hl7.org/fhir/StructureDefinition/MedicationDispense" />
  <derivation value="constraint" />
  <differential>
    <element id="MedicationDispense">
      <path value="MedicationDispense" />
      <short value="A medication dispense to a specific patient authorzied by a paper prescription" />
      <definition value="A dispense for a paper prescription is a medication dispense where the authorizing prescription is not registererd in the National Swedish Medication List but is instead made based on a prescription in paper format." />
    </element>
    <element id="MedicationDispense.id">
      <path value="MedicationDispense.id" />
      <comment value="The only time that a resource does not have an id is when it is being submitted to the server using a create operation.&#xD;&#xA;This id is identified by the URI http://electronichealth.se/identifier/nllmedicationdispenseid in documentation and external systems." />
      <mustSupport value="true" />
      <mapping>
        <identity value="EHM" />
        <map value="Logiskt id för uttag pappersrecept" />
      </mapping>
    </element>
    <element id="MedicationDispense.meta">
      <path value="MedicationDispense.meta" />
      <mustSupport value="true" />
    </element>
    <element id="MedicationDispense.meta.versionId">
      <path value="MedicationDispense.meta.versionId" />
      <mustSupport value="true" />
      <mapping>
        <identity value="EHM" />
        <map value="Uttagsversion för uttag pappersrecept" />
      </mapping>
    </element>
    <element id="MedicationDispense.meta.security">
      <path value="MedicationDispense.meta.security" />
      <mustSupport value="true" />
      <binding>
        <strength value="extensible" />
        <valueSet value="http://ehalsomyndigheten.se/fhir/ValueSet/security-labels" />
      </binding>
    </element>
    <element id="MedicationDispense.meta.security.system">
      <path value="MedicationDispense.meta.security.system" />
      <mustSupport value="true" />
    </element>
    <element id="MedicationDispense.meta.security.version">
      <path value="MedicationDispense.meta.security.version" />
      <mustSupport value="true" />
    </element>
    <element id="MedicationDispense.meta.security.code">
      <path value="MedicationDispense.meta.security.code" />
      <mustSupport value="true" />
    </element>
    <element id="MedicationDispense.extension">
      <path value="MedicationDispense.extension" />
      <min value="1" />
    </element>
    <element id="MedicationDispense.extension:nllDispatchId">
      <path value="MedicationDispense.extension" />
      <sliceName value="nllDispatchId" />
      <short value="The identifier of the dispatch in which the dispense was made" />
      <definition value="Value is treated as an integer, i.e the String can only contain numbers.&#xD;&#xA;May be entered by the pharmacy, otherwise it is calculated by the Swedish E-health Agency ." />
      <type>
        <code value="Extension" />
        <profile value="http://electronichealth.se/fhir/StructureDefinition/NLLDispatchId" />
      </type>
      <mustSupport value="true" />
      <mapping>
        <identity value="EHM" />
        <map value="Expeditions-id" />
      </mapping>
    </element>
    <element id="MedicationDispense.extension:nllNumberOfPackagesDispensed">
      <path value="MedicationDispense.extension" />
      <sliceName value="nllNumberOfPackagesDispensed" />
      <short value="Number of packages dspensed" />
      <definition value="Number of packages dspensed" />
      <max value="1" />
      <type>
        <code value="Extension" />
        <profile value="http://electronichealth.se/fhir/StructureDefinition/NLLNumberOfPackagesDispensed" />
      </type>
      <mustSupport value="true" />
      <mapping>
        <identity value="EHM" />
        <map value="Antal expedierade förpackningar" />
      </mapping>
    </element>
    <element id="MedicationDispense.extension:nllActorDispatchId">
      <path value="MedicationDispense.extension" />
      <sliceName value="nllActorDispatchId" />
      <short value="The identifier of the actors dispatch in which the dispense was made" />
      <definition value="The identifier of the actors dispatch in which the dispense was made. Mandatory when creating a dispense for a paper prescription. Not present in all legacy data." />
      <comment value="Maximum string length: 12" />
      <type>
        <code value="Extension" />
        <profile value="http://electronichealth.se/fhir/StructureDefinition/NLLActorDispatchId" />
      </type>
      <mustSupport value="true" />
      <mapping>
        <identity value="EHM" />
        <map value="Aktörens expeditions-id" />
      </mapping>
    </element>
    <element id="MedicationDispense.extension:nllDispatchRowNo">
      <path value="MedicationDispense.extension" />
      <sliceName value="nllDispatchRowNo" />
      <short value="Identier for MedicationDispense within dispatch" />
      <definition value="Used when communicationg an error or warning for a MedicationDispense within a dispatch. The DispatchRowNo (ExpeditionsRadNummer) uniquely identifies a MediationDispense within a dispatch.&#xD;&#xA;Mandatory when creating a detached dispense." />
      <max value="1" />
      <type>
        <code value="Extension" />
        <profile value="http://electronichealth.se/fhir/StructureDefinition/NLLDispatchRowNo" />
      </type>
      <mustSupport value="true" />
      <mapping>
        <identity value="EHM" />
        <map value="Aktörens expeditionsradnummer" />
      </mapping>
    </element>
    <element id="MedicationDispense.extension:nllBenefitChoiceCode">
      <path value="MedicationDispense.extension" />
      <sliceName value="nllBenefitChoiceCode" />
      <short value="Benefit choice" />
      <definition value="Type of benefit for the dispense. Only used for validation (input only)." />
      <max value="1" />
      <type>
        <code value="Extension" />
        <profile value="http://electronichealth.se/fhir/StructureDefinition/NLLBenefitChoiceCode" />
      </type>
      <mustSupport value="true" />
      <binding>
        <strength value="required" />
        <valueSet value="http://ehalsomyndigheten.se/fhir/ValueSet/benefit-choices" />
      </binding>
      <mapping>
        <identity value="EHM" />
        <map value="Förmånsval" />
      </mapping>
    </element>
    <element id="MedicationDispense.extension:nllPrescriptionDetails">
      <path value="MedicationDispense.extension" />
      <sliceName value="nllPrescriptionDetails" />
      <short value="Information from the authorizing prescription" />
      <definition value="Information from the authorizing prescription" />
      <type>
        <code value="Extension" />
        <profile value="http://electronichealth.se/fhir/StructureDefinition/NLLPrescriptionDetails" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="MedicationDispense.extension:nllPrescriptionDetails.extension:nllPrescriptionDate">
      <path value="MedicationDispense.extension.extension" />
      <sliceName value="nllPrescriptionDate" />
      <definition value="Date when prescription was initially authored. &lt;br&gt;&#xD;&#xA;Only used for validation (input only)." />
      <comment value="_" />
      <mustSupport value="true" />
    </element>
    <element id="MedicationDispense.extension:nllPrescriptionDetails.extension:nllPrescriber">
      <path value="MedicationDispense.extension.extension" />
      <sliceName value="nllPrescriber" />
      <short value="Prescriber" />
      <definition value="The prescriber as a contained Practitioner resource (confirming to the NLLPractitioner profile)." />
      <comment value="_" />
      <mustSupport value="true" />
    </element>
    <element id="MedicationDispense.extension:nllPrescriptionDetails.extension:nllRegistrationBasis">
      <path value="MedicationDispense.extension.extension" />
      <sliceName value="nllRegistrationBasis" />
      <comment value="_" />
      <mustSupport value="true" />
    </element>
    <element id="MedicationDispense.extension:nllPrescriptionDetails.extension:nllCountryCode">
      <path value="MedicationDispense.extension.extension" />
      <sliceName value="nllCountryCode" />
      <short value="Deprecated. Country code" />
      <definition value="NB! Deprecated, Practitioner.address.country should be used.&#xD;&#xA;&#xD;&#xA;Country code, as defined on the authorizing prescription&#xD;&#xA;ISO 3166-1 alpha-2&#xD;&#xA;Example: NO (Norway)" />
      <comment value="Maximum string length: 2" />
      <mustSupport value="true" />
    </element>
    <element id="MedicationDispense.extension:nllPrescriptionDetails.extension:nllCountryCode.value[x].extension:NLLdataAbsentReason">
      <path value="MedicationDispense.extension.extension.value[x].extension" />
      <sliceName value="NLLdataAbsentReason" />
      <short value="masked" />
      <definition value="Marks masked data, ie why data is missing." />
      <type>
        <code value="Extension" />
        <profile value="http://hl7.org/fhir/StructureDefinition/data-absent-reason" />
      </type>
      <mustSupport value="true" />
      <isModifier value="false" />
      <binding>
        <strength value="required" />
        <valueSet value="http://electronichealth.se/fhir/ValueSet/data-absent-reason" />
      </binding>
    </element>
    <element id="MedicationDispense.extension:nllPrescriptionDetails.extension:nllSubstitutionAllowed">
      <path value="MedicationDispense.extension.extension" />
      <sliceName value="nllSubstitutionAllowed" />
      <definition value="Indicates if medication may be substituted (sv: generisk substitution tillåten) &lt;br&gt;&#xD;&#xA;Only used for validation (input only)." />
      <comment value="_" />
      <mustSupport value="true" />
    </element>
    <element id="MedicationDispense.extension:nllPrescriptionDetails.extension:nllFirstDispenseBefore">
      <path value="MedicationDispense.extension.extension" />
      <sliceName value="nllFirstDispenseBefore" />
      <definition value="Not used for dose dispensed prescriptions&#xD;&#xA;The first dispense must occur before this date. If not, the prescription is invalidated.&lt;br&gt;&#xD;&#xA;Only used for validation (input only)." />
      <comment value="_" />
      <mustSupport value="true" />
    </element>
    <element id="MedicationDispense.extension:nllPrescriptionDetails.extension:nllPrescriberCostCenter">
      <path value="MedicationDispense.extension.extension" />
      <sliceName value="nllPrescriberCostCenter" />
      <short value="The prescribers cost center" />
      <definition value="The prescribers cost center code when making the prescription. Used for benefit billing within the regions." />
      <comment value="Minimum string length: 3&#xD;&#xA;Maximum string length: 13" />
      <mustSupport value="true" />
    </element>
    <element id="MedicationDispense.extension:nllPrescriptionDetails.extension:nllPrescriberCostCenter.value[x].value.extension:NLLdataAbsentReason">
      <path value="MedicationDispense.extension.extension.value[x].value.extension" />
      <sliceName value="NLLdataAbsentReason" />
      <short value="masked" />
      <definition value="Marks masked data, ie why data is missing." />
      <type>
        <code value="Extension" />
        <profile value="http://hl7.org/fhir/StructureDefinition/data-absent-reason" />
      </type>
      <mustSupport value="true" />
      <isModifier value="false" />
      <binding>
        <strength value="required" />
        <valueSet value="http://electronichealth.se/fhir/ValueSet/data-absent-reason" />
      </binding>
    </element>
    <element id="MedicationDispense.extension:nllDispenseCrediting">
      <path value="MedicationDispense.extension" />
      <sliceName value="nllDispenseCrediting" />
      <definition value="Crediting details for a dispense. Only used when crediting a dispense." />
      <type>
        <code value="Extension" />
        <profile value="http://electronichealth.se/fhir/StructureDefinition/NLLDispenseCrediting" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="MedicationDispense.extension:nllDispenseCrediting.extension:creditDate">
      <path value="MedicationDispense.extension.extension" />
      <sliceName value="creditDate" />
      <comment value="_" />
      <mustSupport value="true" />
    </element>
    <element id="MedicationDispense.extension:nllDispenseCrediting.extension:creditDispatchId">
      <path value="MedicationDispense.extension.extension" />
      <sliceName value="creditDispatchId" />
      <mustSupport value="true" />
    </element>
    <element id="MedicationDispense.extension:nllDispenseCrediting.extension:creditDispatchRowNo">
      <path value="MedicationDispense.extension.extension" />
      <sliceName value="creditDispatchRowNo" />
      <mustSupport value="true" />
    </element>
    <element id="MedicationDispense.status">
      <path value="MedicationDispense.status" />
      <short value="cancelled | completed" />
      <definition value="Note! Used in NLL when a dispense is cancelled (sv: uttaget backat eller krediterat)." />
      <mustSupport value="true" />
      <binding>
        <strength value="required" />
        <valueSet value="http://electronichealth.se/fhir/ValueSet/medication-dispense-status" />
      </binding>
      <mapping>
        <identity value="EHM" />
        <map value="Uttagsstatus" />
      </mapping>
    </element>
    <element id="MedicationDispense.medication[x]">
      <path value="MedicationDispense.medication[x]" />
      <short value="Dispensed medication" />
      <definition value="Identifies the medical product being prescribed. The codes used are Swedish NplId from medical product, NplPackId for medicine packages and Varunr for reimbursed consumables. &#xD;&#xA;For a medicine package, both the NplId and the NplPackId shall be provided. Varunr is not allowed to use when prescribing a medication.&#xD;&#xA;For a reimbursed consumable, only Varunr shall be provided." />
      <comment value="_" />
      <type>
        <code value="CodeableConcept" />
      </type>
      <mustSupport value="true" />
      <binding>
        <strength value="required" />
        <description value="Swedish medicine packages and reimbursed consumables." />
        <valueSet value="http://electronichealth.se/fhir/ValueSet/medicines-consumables" />
      </binding>
    </element>
    <element id="MedicationDispense.medication[x].coding">
      <path value="MedicationDispense.medication[x].coding" />
      <slicing>
        <discriminator>
          <type value="value" />
          <path value="system" />
        </discriminator>
        <rules value="open" />
      </slicing>
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="MedicationDispense.medication[x].coding:nplid">
      <path value="MedicationDispense.medication[x].coding" />
      <sliceName value="nplid" />
      <short value="NPL-id" />
      <definition value="A unique identifier of a medical product according to &quot;Nationellt produktregister för läkemedel&quot; provided by the Swedish Medical Products Agency (sv Läkemedelsverket)" />
      <max value="1" />
      <mustSupport value="true" />
      <mapping>
        <identity value="EHM" />
        <map value="NPL-id" />
      </mapping>
    </element>
    <element id="MedicationDispense.medication[x].coding:nplid.system">
      <path value="MedicationDispense.medication[x].coding.system" />
      <min value="1" />
      <fixedUri value="http://electronichealth.se/fhir/NamingSystem/nplid" />
      <mustSupport value="true" />
    </element>
    <element id="MedicationDispense.medication[x].coding:nplid.code">
      <path value="MedicationDispense.medication[x].coding.code" />
      <comment value="Maximum string length: 14" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="MedicationDispense.medication[x].coding:nplpackid">
      <path value="MedicationDispense.medication[x].coding" />
      <sliceName value="nplpackid" />
      <short value="NPL-pack-id" />
      <definition value="A unique identifier of a medical product package according to &quot;Nationellt produktregister för läkemedel&quot; provided by the Swedish Medical Products Agency (sv Läkemedelsverket)" />
      <max value="1" />
      <mustSupport value="true" />
      <mapping>
        <identity value="EHM" />
        <map value="NPL-pack-id" />
      </mapping>
    </element>
    <element id="MedicationDispense.medication[x].coding:nplpackid.system">
      <path value="MedicationDispense.medication[x].coding.system" />
      <min value="1" />
      <fixedUri value="http://electronichealth.se/fhir/NamingSystem/nplpackid" />
      <mustSupport value="true" />
    </element>
    <element id="MedicationDispense.medication[x].coding:nplpackid.code">
      <path value="MedicationDispense.medication[x].coding.code" />
      <comment value="Maximum string length: 14" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="MedicationDispense.medication[x].coding:varunr">
      <path value="MedicationDispense.medication[x].coding" />
      <sliceName value="varunr" />
      <short value="Varunummer" />
      <definition value="A unique identifier of a medical consumable according to &quot;Nationellt produktregister för läkemedel&quot; provided by the Swedish Medical Products Agency (sv Läkemedelsverket)&#xD;&#xA;Also a non-unique identifier of a medical product package." />
      <max value="1" />
      <mustSupport value="true" />
      <mapping>
        <identity value="EHM" />
        <map value="Varunummer" />
      </mapping>
    </element>
    <element id="MedicationDispense.medication[x].coding:varunr.system">
      <path value="MedicationDispense.medication[x].coding.system" />
      <min value="1" />
      <fixedUri value="http://electronichealth.se/fhir/NamingSystem/varunr" />
      <mustSupport value="true" />
    </element>
    <element id="MedicationDispense.medication[x].coding:varunr.code">
      <path value="MedicationDispense.medication[x].coding.code" />
      <comment value="Minimum string length: 6&#xD;&#xA;Maximum string length: 6" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="MedicationDispense.subject">
      <path value="MedicationDispense.subject" />
      <short value="Which patient the dispense is for" />
      <definition value="A patient with personal identification number (sv: personnummer) must be referenced, other cases must be handled by containing the patient resource." />
      <min value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://electronichealth.se/fhir/StructureDefinition/NLLPatient" />
        <aggregation value="contained" />
        <aggregation value="referenced" />
      </type>
      <mustSupport value="true" />
      <mapping>
        <identity value="EHM" />
        <map value="Patient" />
      </mapping>
      <mapping>
        <identity value="EHM" />
        <map value="Patientreferens" />
      </mapping>
    </element>
    <element id="MedicationDispense.authorizingPrescription">
      <path value="MedicationDispense.authorizingPrescription" />
      <definition value="Indicates the medication order that is being dispensed against. In this profile, the authorizing prescription is always in paper form (current format)  and/or there is no electronic presecription in NLL to refer to (sv: uttag där underlaget är ett papper eller ett utländskt e-recept)" />
      <max value="0" />
    </element>
    <element id="MedicationDispense.authorizingPrescription.reference">
      <path value="MedicationDispense.authorizingPrescription.reference" />
      <max value="0" />
    </element>
    <element id="MedicationDispense.authorizingPrescription.identifier">
      <path value="MedicationDispense.authorizingPrescription.identifier" />
      <max value="0" />
    </element>
    <element id="MedicationDispense.type">
      <path value="MedicationDispense.type" />
      <short value="Standard packing fill, Dose dispensed fill or Trial fill" />
      <definition value="Type is used for specifing if the dispense was a &quot;Standard packing fill&quot;, &quot;Trial fill&quot; (startförpackning) or &quot;Dose dispensed fill&quot; in the Swedish National Medication List. (Trial fill is not used for dose dispensed fills).&#xD;&#xA;Dose dispensed fill can no longer occur for a dispense of a paper prescription. The code DD will be removed from the value set used by this profile in a future release." />
      <min value="1" />
      <mustSupport value="true" />
      <binding>
        <strength value="required" />
        <description value="Indicates the type of dispensing event that is performed, e.g. Standard packing fill, Trial fill or Dose dispense refill" />
        <valueSet value="http://electronichealth.se/fhir/ValueSet/dispense-types" />
      </binding>
      <mapping>
        <identity value="EHM" />
        <map value="Uttagstyp" />
      </mapping>
    </element>
    <element id="MedicationDispense.type.coding">
      <path value="MedicationDispense.type.coding" />
      <min value="1" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="MedicationDispense.type.coding.system">
      <path value="MedicationDispense.type.coding.system" />
      <mustSupport value="true" />
    </element>
    <element id="MedicationDispense.type.coding.version">
      <path value="MedicationDispense.type.coding.version" />
      <mustSupport value="true" />
    </element>
    <element id="MedicationDispense.type.coding.code">
      <path value="MedicationDispense.type.coding.code" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="MedicationDispense.quantity">
      <path value="MedicationDispense.quantity" />
      <mustSupport value="true" />
      <mapping>
        <identity value="EHM" />
        <map value="Expedierad mängd" />
      </mapping>
    </element>
    <element id="MedicationDispense.quantity.value">
      <path value="MedicationDispense.quantity.value" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="MedicationDispense.whenHandedOver">
      <path value="MedicationDispense.whenHandedOver" />
      <min value="1" />
      <mustSupport value="true" />
      <mapping>
        <identity value="EHM" />
        <map value="Expedieringstidpunkt" />
      </mapping>
    </element>
    <element id="MedicationDispense.dosageInstruction">
      <path value="MedicationDispense.dosageInstruction" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="MedicationDispense.dosageInstruction.patientInstruction">
      <path value="MedicationDispense.dosageInstruction.patientInstruction" />
      <comment value="Maximum string length: 1016" />
      <min value="1" />
      <mustSupport value="true" />
      <mapping>
        <identity value="EHM" />
        <map value="Doseringsinstruktion" />
      </mapping>
    </element>
    <element id="MedicationDispense.substitution">
      <path value="MedicationDispense.substitution" />
      <mustSupport value="true" />
    </element>
    <element id="MedicationDispense.substitution.wasSubstituted">
      <path value="MedicationDispense.substitution.wasSubstituted" />
      <definition value="True if the dispenser dispensed a different drug or product from what was prescribed.&#xD;&#xA;Only used for validation (input only)." />
      <mustSupport value="true" />
      <mapping>
        <identity value="EHM" />
        <map value="Generikautbyte utfört" />
      </mapping>
    </element>
    <element id="MedicationDispense.detectedIssue">
      <path value="MedicationDispense.detectedIssue" />
      <short value="Automatic Format and Constitution Control warning (AFF varning)" />
      <definition value="FOR FUTURE USE, SHOULD NOT BE USED!&#xD;&#xA;Accepted warnings can be provided when creating a MedicationDispense.&#xD;&#xA;Automatic Format and Constitution Control (AFF) accepted by the pharmacist.&#xD;&#xA;NB! The DetectedIssues are never saved by the Swedish eHealth Agency." />
      <type>
        <code value="Reference" />
        <targetProfile value="http://electronichealth.se/fhir/StructureDefinition/NLLDetectedIssue" />
        <aggregation value="contained" />
      </type>
      <mustSupport value="true" />
      <mapping>
        <identity value="EHM" />
        <map value="Accepterade varningar" />
      </mapping>
    </element>
  </differential>
</StructureDefinition>