<StructureDefinition xmlns="http://hl7.org/fhir">
  <url value="http://electronichealth.se/fhir/StructureDefinition/NLLProvenance" />
  <version value="2.0.0" />
  <name value="NLLProvenance" />
  <status value="active" />
  <experimental value="false" />
  <date value="2024-12-17" />
  <publisher value="Swedish eHealth Agency" />
  <description value="A profile of Provenance that is compatible with all scenarios in the Swedish National Medication List." />
  <fhirVersion value="4.0.1" />
  <mapping>
    <identity value="EHM" />
    <name value="E-hälsomyndigheten concept" />
  </mapping>
  <kind value="resource" />
  <abstract value="false" />
  <type value="Provenance" />
  <baseDefinition value="http://hl7.org/fhir/StructureDefinition/Provenance" />
  <derivation value="constraint" />
  <differential>
    <element id="Provenance">
      <path value="Provenance" />
      <short value="When a change is made in the patient´s medication list a provenance provides information about who, what, when and where from the change is made." />
      <definition value="NLLProvenance describes a change that has been made on a resource affecting a patient medications list, e.g. a MedicationRequest, MedicationDispense or resource related to multi dose dispensing (sv: dosunderlag, dossamtycke) or a change affecting a data lock (sv spärr). The change describes What - in the form of which resource is the target in combination with a reason and activity. It describes by Who - in the form of agent and it describes When it occurred.&#xD;&#xA;A Provenance resource is created fron the X-Provenance header wich is mandatory in a number of scenarios." />
      <mapping>
        <identity value="EHM" />
        <map value="Händelse" />
      </mapping>
    </element>
    <element id="Provenance.id">
      <path value="Provenance.id" />
      <mustSupport value="true" />
      <mapping>
        <identity value="EHM" />
        <map value="Händelse-id" />
      </mapping>
    </element>
    <element id="Provenance.target">
      <path value="Provenance.target" />
      <definition value="The Reference(s) that were generated or updated by  the activity described in this resource. A provenance can point to more than one target if multiple resources were created/updated by the same activity.&#xD;&#xA;The Reference is set by the Swedish eHealth Agency to the resource in the body of the request containing the X-Provenance header, and in some cases the target may also point to additional affected resources ." />
      <type>
        <code value="Reference" />
        <targetProfile value="http://electronichealth.se/fhir/StructureDefinition/NLLMedicationRequest" />
        <targetProfile value="http://electronichealth.se/fhir/StructureDefinition/NLLMedicationDispense" />
        <targetProfile value="http://electronichealth.se/fhir/StructureDefinition/NLLMultiDoseDispConsent" />
        <targetProfile value="http://electronichealth.se/fhir/StructureDefinition/NLLMultiDoseDispensingBasis" />
        <targetProfile value="http://electronichealth.se/fhir/StructureDefinition/NLLDispensePaperPrescription" />
        <targetProfile value="http://electronichealth.se/fhir/StructureDefinition/NLLDataLock" />
        <targetProfile value="http://electronichealth.se/fhir/StructureDefinition/NLLAccessConsent" />
        <aggregation value="referenced" />
      </type>
      <mustSupport value="true" />
      <mapping>
        <identity value="EHM" />
        <map value="Resursreferenser" />
      </mapping>
      <mapping>
        <identity value="EHM" />
        <map value="Referens till spärr" />
      </mapping>
    </element>
    <element id="Provenance.occurred[x]">
      <path value="Provenance.occurred[x]" />
      <comment value="This value is set by the system to reflect the date and time when the request was received" />
      <type>
        <code value="dateTime" />
      </type>
      <mapping>
        <identity value="EHM" />
        <map value="Tidpunkt" />
      </mapping>
    </element>
    <element id="Provenance.recorded">
      <path value="Provenance.recorded" />
      <definition value="The instant of time at which the activity was recorded by the Swedish eHealth Agency." />
      <mustSupport value="true" />
      <mapping>
        <identity value="EHM" />
        <map value="Händelsetidpunkt" />
      </mapping>
    </element>
    <element id="Provenance.reason">
      <path value="Provenance.reason" />
      <definition value="The reason for the change. &lt;br&gt;&#xD;&#xA;For prescriptions, codes can be used to describe either a reason for change or a reason for cancellation.&#xD;&#xA;For other scenarios regarding prescriptions, only the text element is allowed (in combination with the code OTH).&#xD;&#xA;For all scenarios regarding medication dispense, only the text element is allowed.&#xD;&#xA;For all scenarios regarding Consents (NLLMultiDoseDispConsent (sv Dossamtycke), NLLAccessConsent (sv. Åtkomstsamtycke)), NLLMultiDoseDispensingBasis (sv Dosunderlag) and NLLDataLock (sv Spärr) no reason is allowed." />
      <comment value="_" />
      <max value="1" />
      <mustSupport value="true" />
      <binding>
        <strength value="extensible" />
        <valueSet value="http://electronichealth.se/fhir/ValueSet/nll-reason-for-provenance" />
      </binding>
      <mapping>
        <identity value="EHM" />
        <map value="Händelseorsak" />
      </mapping>
    </element>
    <element id="Provenance.reason.coding">
      <path value="Provenance.reason.coding" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Provenance.reason.coding.system">
      <path value="Provenance.reason.coding.system" />
      <mustSupport value="true" />
    </element>
    <element id="Provenance.reason.coding.version">
      <path value="Provenance.reason.coding.version" />
      <mustSupport value="true" />
    </element>
    <element id="Provenance.reason.coding.code">
      <path value="Provenance.reason.coding.code" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Provenance.reason.text">
      <path value="Provenance.reason.text" />
      <definition value="Plain text representation of the reason that the activity was taking place. &#xD;&#xA;Mandatory when the code &quot;OTH&quot; (other) is used.&#xD;&#xA;Can be used for all scenarios regarding prescriptions and dispenses that does not require a code." />
      <comment value="Maximum string length: 256&#xD;&#xA;For reasons related to dispensens for paper prescriptions the maximum string length is: 50" />
      <mustSupport value="true" />
      <mapping>
        <identity value="EHM" />
        <map value="Beskrivning händelseorsak" />
      </mapping>
    </element>
    <element id="Provenance.activity">
      <path value="Provenance.activity" />
      <definition value="This type describes the activity that occurred. This could both be a medication list activity type concerning a MedicationRequest for example, or a data lock activity type." />
      <comment value="_" />
      <min value="1" />
      <mustSupport value="true" />
      <binding>
        <strength value="required" />
        <valueSet value="http://ehalsomyndigheten.se/fhir/ValueSet/provenance-activity-types" />
      </binding>
      <mapping>
        <identity value="EHM" />
        <map value="Händelsetyp" />
      </mapping>
    </element>
    <element id="Provenance.activity.coding">
      <path value="Provenance.activity.coding" />
      <min value="1" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Provenance.activity.coding.system">
      <path value="Provenance.activity.coding.system" />
      <mustSupport value="true" />
    </element>
    <element id="Provenance.activity.coding.version">
      <path value="Provenance.activity.coding.version" />
      <mustSupport value="true" />
    </element>
    <element id="Provenance.activity.coding.code">
      <path value="Provenance.activity.coding.code" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Provenance.agent">
      <path value="Provenance.agent" />
      <definition value="Allowed actors are: enterer (sv: utförare) and author (sv: uppdragsgivare). Enterer MUST always be present, author CAN be present in case a practitioner is performing a change on behalf of someone" />
      <requirements value="_" />
      <mustSupport value="true" />
      <mapping>
        <identity value="EHM" />
        <map value="Uppdragsgivare" />
      </mapping>
      <mapping>
        <identity value="EHM" />
        <map value="Utförare" />
      </mapping>
    </element>
    <element id="Provenance.agent.type">
      <path value="Provenance.agent.type" />
      <comment value="_" />
      <min value="1" />
      <mustSupport value="true" />
      <binding>
        <strength value="extensible" />
        <valueSet value="http://electronichealth.se/fhir/ValueSet/provenance-participant-types" />
      </binding>
    </element>
    <element id="Provenance.agent.who">
      <path value="Provenance.agent.who" />
      <definition value="The individual that participated in the event. NB! Only a DataLock Provenance can contain a reference to a Patient resource." />
      <type>
        <code value="Reference" />
        <targetProfile value="http://electronichealth.se/fhir/StructureDefinition/NLLPractitioner" />
        <targetProfile value="http://electronichealth.se/fhir/StructureDefinition/NLLPatient" />
        <aggregation value="contained" />
        <aggregation value="referenced" />
      </type>
      <mustSupport value="true" />
      <mapping>
        <identity value="EHM" />
        <map value="Uppdragsgivare / Utförare" />
        <comment value="Depending on type, this is the practitioner acting as the performer (sv: utförare) or author (sv: uppdragsgivare)" />
      </mapping>
    </element>
  </differential>
</StructureDefinition>