<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="f06c6e96-4495-4afa-b688-02bef19f2d6d" />
  <meta>
    <versionId value="1" />
    <lastUpdated value="2025-07-04T16:22:51.3438447+00:00" />
  </meta>
  <url value="http://electronichealth.se/fhir/StructureDefinition/NLLMedicationDispense" />
  <version value="1.3.0" />
  <name value="NLLMedicationDispense" />
  <status value="active" />
  <date value="2025-07-04" />
  <publisher value="Swedish eHealth Agency" />
  <fhirVersion value="4.0.1" />
  <mapping>
    <identity value="EHM" />
    <name value="E-hälsomyndigheten concept" />
  </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 prescription" />
      <definition value="A medication dispense to a specific patient authorzied by a prescription in electronic format. Medication dispenses authorized by paper based prescriptions must use the profile NLLDispensePaperPrescription." />
    </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" />
      </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" />
      </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="3" />
    </element>
    <element id="MedicationDispense.extension:nllNumberOfPackagesDispensed">
      <path value="MedicationDispense.extension" />
      <sliceName value="nllNumberOfPackagesDispensed" />
      <short value="Number of packages dispensed" />
      <definition value="The number of packages that were included in the dispense. Shall not be set for dose dispensed dispenses." />
      <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 actor's dispatch in which the dispense was made" />
      <comment value="Maximum string length: 12" />
      <min value="1" />
      <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: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 .&#xD;&#xA;The identifier of the dispatch in which the dispense was made." />
      <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:nllBenefitChoiceCode">
      <path value="MedicationDispense.extension" />
      <sliceName value="nllBenefitChoiceCode" />
      <short value="Benefit choice" />
      <definition value="Type of benefit for the dispense." />
      <min value="1" />
      <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: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." />
      <min value="1" />
      <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:nllDeductedQuantity">
      <path value="MedicationDispense.extension" />
      <sliceName value="nllDeductedQuantity" />
      <short value="Deducted quantity" />
      <definition value="The quantity that is deducted form the prescription's remaining quantity.&#xD;&#xA;Only used if the deducted quantity should differ from the dispensed quantity." />
      <type>
        <code value="Extension" />
        <profile value="http://electronichealth.se/fhir/StructureDefinition/NLLDeductedQuantity" />
      </type>
      <mustSupport value="true" />
      <mapping>
        <identity value="EHM" />
        <map value="Avräknad mängd" />
      </mapping>
    </element>
    <element id="MedicationDispense.extension:nllCompletePrescriptionChoice">
      <path value="MedicationDispense.extension" />
      <sliceName value="nllCompletePrescriptionChoice" />
      <short value="Prescription completion choice" />
      <definition value="Only used for input.&#xD;&#xA;When 12% or less of the total quantity of the prescribed medication is left, the prescription will automatically be set to status &quot;Completed&quot;. &#xD;&#xA;A pharmacist can make a descision to overrule the automatic rules by either choosing to set the prescription status to &quot;Completed&quot; or to keep the status &quot;Active&quot;." />
      <max value="1" />
      <type>
        <code value="Extension" />
        <profile value="http://electronichealth.se/fhir/StructureDefinition/NLLCompletePrescriptionChoice" />
      </type>
      <mustSupport value="true" />
      <binding>
        <strength value="required" />
        <valueSet value="http://ehalsomyndigheten.se/fhir/ValueSet/complete-prescription-choices" />
      </binding>
      <mapping>
        <identity value="EHM" />
        <map value="Beslut slutexpediering" />
      </mapping>
    </element>
    <element id="MedicationDispense.extension:nllDispenseCrediting">
      <path value="MedicationDispense.extension" />
      <sliceName value="nllDispenseCrediting" />
      <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" />
      <short value="Credit date and time" />
      <definition value="The date and time when the dispense was credited." />
      <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" />
      <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 or reimbursed consumable" />
      <definition value="Identifies the medication or reimbursed consumable being dispensed. &#xD;&#xA;The codes used are Swedish NplId for medical products, 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 dispensing a medication.&#xD;&#xA;For a reimbursed consumable, only Varunr shall be provided." />
      <comment value="If more information is required, then the use of the medication resource is recommended." />
      <type>
        <code value="CodeableConcept" />
      </type>
      <mustSupport value="true" />
      <binding>
        <strength value="required" />
      </binding>
      <mapping>
        <identity value="EHM" />
        <map value="Expedierad artikel" />
      </mapping>
    </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.authorizingPrescription">
      <path value="MedicationDispense.authorizingPrescription" />
      <short value="MedicationRequest that authorizes the dispense" />
      <definition value="Reference to the MedicationRequest that was dispatched. Note that authorizingprescription must include the version of the medication request. That is done by using the /_history/ suffix." />
      <min value="1" />
      <max value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://electronichealth.se/fhir/StructureDefinition/NLLMedicationRequest" />
        <aggregation value="referenced" />
        <versioning value="specific" />
      </type>
      <mustSupport value="true" />
      <mapping>
        <identity value="EHM" />
        <map value="Förskrivningsversion" />
      </mapping>
    </element>
    <element id="MedicationDispense.type">
      <path value="MedicationDispense.type" />
      <short value="Type of dispense" />
      <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)." />
      <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" />
      <definition value="The amount of the article that has been dispensed." />
      <comment value="When dispensing an article (not for dose dispenses), this will be either set by the pharmacy or calculated based on the number of packages and the package size. &lt;br&gt;&#xD;&#xA;If complete packages are dispensed, the quantity is calculated by the Swedish eHealth Agency. In this scenarion only the number of packages should be entered (no quantity).&lt;br&gt;&#xD;&#xA;If only a part of a package is dispensed (sv bruten helförpackning), the pharmacy must enter both the quantity and the number of packages that was dispensed. &lt;br&gt;" />
      <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" />
      <mustSupport value="true" />
      <mapping>
        <identity value="EHM" />
        <map value="Expeditionstidpunkt" />
      </mapping>
    </element>
    <element id="MedicationDispense.note">
      <path value="MedicationDispense.note" />
      <short value="Pharmacists note" />
      <definition value="The pharmacists note about the dispense." />
      <comment value="Maximum string length: 1016" />
      <max value="1" />
      <mustSupport value="true" />
      <mapping>
        <identity value="EHM" />
        <map value="Uttagsnotering" />
      </mapping>
    </element>
    <element id="MedicationDispense.note.text">
      <path value="MedicationDispense.note.text" />
      <mustSupport value="true" />
    </element>
    <element id="MedicationDispense.note.text.extension:NLLdataAbsentReason">
      <path value="MedicationDispense.note.text.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>
      <isModifier value="false" />
      <binding>
        <strength value="required" />
        <valueSet value="http://electronichealth.se/fhir/ValueSet/data-absent-reason" />
      </binding>
    </element>
    <element id="MedicationDispense.dosageInstruction">
      <path value="MedicationDispense.dosageInstruction" />
      <comment value="A medication dispense is always based/dispatched on a specific version of a medication request. &lt;br&gt;&#xD;&#xA;A dosage instruction must be provided of there is a unique dosage for the medication dispense which differs from the dosage instruction on the medication request version. &lt;br&gt;&#xD;&#xA;The dosage instruction on the medication request version is used as the valid dosage if no other dosage instruction is provided on the medication dispense. &lt;br&gt;&#xD;&#xA;If a new dosage instruction should be in effect for the current and following medication dispenses, the medication request needs to be updated before the medication dispense is made.&lt;br&gt;&#xD;&#xA;For a read-operation on a medication dispense, the dosage instruction must be read from the medication request version if there is no dosage instruction on the specific medication dispense resource." />
      <type>
        <code value="Dosage" />
        <profile value="http://electronichealth.se/fhir/StructureDefinition/NLLDosage" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="MedicationDispense.dosageInstruction.sequence">
      <path value="MedicationDispense.dosageInstruction.sequence" />
      <definition value="Indicates the order in which the dosage instructions should be applied or interpreted ." />
    </element>
    <element id="MedicationDispense.substitution">
      <path value="MedicationDispense.substitution" />
      <definition value="Indicates whether or not substitution was made as part of the dispense.  In some cases, substitution will be expected but does not happen, in other cases substitution is not expected but does happen.  This block explains what substitution did or did not happen.  If nothing is specified, substitution was not done." />
      <mustSupport value="true" />
      <mapping>
        <identity value="EHM" />
        <map value="Generikautbyte utfört" />
      </mapping>
    </element>
    <element id="MedicationDispense.substitution.wasSubstituted">
      <path value="MedicationDispense.substitution.wasSubstituted" />
      <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="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>