<StructureDefinition xmlns="http://hl7.org/fhir">
  <url value="http://electronichealth.se/fhir/StructureDefinition/NLLDataLock" />
  <name value="NLLDataLock" />
  <status value="draft" />
  <fhirVersion value="4.0.0" />
  <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="EHM" />
    <uri value="http://ehalsomyndigheten.se" />
  </mapping>
  <kind value="resource" />
  <abstract value="false" />
  <type value="Basic" />
  <baseDefinition value="http://hl7.org/fhir/StructureDefinition/Basic" />
  <derivation value="constraint" />
  <differential>
    <element id="Basic">
      <path value="Basic" />
      <short value="Information showing that the target resource has an integrity or secrecy lock" />
      <definition value="As described in Lag (2018:1212) om nationell läkemedelslista, chapter 4 it must be possible for a patient or practitioner to lock parts of a prescription. An active DataLock referencing a resource shows that parts of, or the full resource, should be filtered based on who/what tries to access the information. The filtering is done by NLL, given which role tries to acess the resource (target of the DataLock) and purpose of the access. Creating or in-activating a DataLock is done by the client." />
    </element>
    <element id="Basic.extension">
      <path value="Basic.extension" />
      <slicing>
        <discriminator>
          <type value="value" />
          <path value="url" />
        </discriminator>
        <rules value="open" />
      </slicing>
    </element>
    <element id="Basic.extension:nllTargetPatient">
      <path value="Basic.extension" />
      <sliceName value="nllTargetPatient" />
      <short value="Reference to patient affected by this lock" />
      <definition value="Reference to the patient affected by the lock. Normally, there is also a defined prescription chain which is affected. If the lock applies to all MedicationDispenses without target (sv: lösa uttag), there will only be a reference to the patient and no prescription chain is defined." />
      <max value="1" />
      <type>
        <code value="Extension" />
        <profile value="http://electronichealth.se/fhir/StructureDefinition/NLLDataLockTarget" />
      </type>
      <mapping>
        <identity value="EHM" />
        <map value="Referens till patient" />
      </mapping>
    </element>
    <element id="Basic.extension:nllPrescriptionChain">
      <path value="Basic.extension" />
      <sliceName value="nllPrescriptionChain" />
      <short value="Prescription chain id, for the prescription where data lock applies" />
      <definition value="If the lock applies to a MedicationRequest, then the prescription chain id should be referred since the lock applies to the full chain." />
      <max value="1" />
      <type>
        <code value="Extension" />
        <profile value="http://electronichealth.se/fhir/StructureDefinition/NLLPrescriptionChain" />
      </type>
      <mapping>
        <identity value="EHM" />
        <map value="Kedje-id" />
      </mapping>
    </element>
    <element id="Basic.extension:eventHistory">
      <path value="Basic.extension" />
      <sliceName value="eventHistory" />
      <type>
        <code value="Extension" />
        <profile value="http://electronichealth.se/fhir/StructureDefinition/NLLDataLockEventHistory" />
      </type>
    </element>
    <element id="Basic.extension:nllDataLockType">
      <path value="Basic.extension" />
      <sliceName value="nllDataLockType" />
      <short value="Type of lock, SEKRETESS | INTEGRITET" />
      <definition value="The selected type is related to who the lock applies to. An integrity lock affects health care pracititioners while a security lock affects how the patient can see information on a MedicationRequest with a DataLock when accessed." />
      <min value="1" />
      <max value="1" />
      <type>
        <code value="Extension" />
        <profile value="http://electronichealth.se/fhir/StructureDefinition/NLLDataLockType" />
      </type>
      <binding>
        <strength value="required" />
        <valueSet value="http://electronichealth.se/fhir/ValueSet/data-lock-type" />
      </binding>
      <mapping>
        <identity value="EHM" />
        <map value="Spärrtyp" />
      </mapping>
    </element>
    <element id="Basic.extension:nllLockedSubjectType">
      <path value="Basic.extension" />
      <sliceName value="nllLockedSubjectType" />
      <short value="Type of information locked" />
      <definition value="Type of information locked by the presence of this resource. Can be treatment reason (sv: behandlingsorsak), a complete MedicationRequest (sv: förskrivning), or all MedicationDispenses without target (sv: lösa uttag)" />
      <min value="1" />
      <max value="1" />
      <type>
        <code value="Extension" />
        <profile value="http://electronichealth.se/fhir/StructureDefinition/NLLLockedSubjectType" />
      </type>
      <binding>
        <strength value="required" />
        <valueSet value="http://electronichealth.se/fhir/ValueSet/locked-subject" />
      </binding>
      <mapping>
        <identity value="EHM" />
        <map value="SpärradUppgift" />
      </mapping>
    </element>
    <element id="Basic.extension:status">
      <path value="Basic.extension" />
      <sliceName value="status" />
      <short value="The status of the lock, reflects if it is active or not" />
      <definition value="The status of the lock, reflects if it is active or not" />
      <min value="1" />
      <max value="1" />
      <type>
        <code value="Extension" />
        <profile value="http://electronichealth.se/fhir/StructureDefinition/NLLDataLockStatus" />
      </type>
    </element>
    <element id="Basic.extension:status.value[x]">
      <path value="Basic.extension.value[x]" />
      <binding>
        <strength value="required" />
        <valueSet value="http://electronichealth.se/fhir/ValueSet/data-lock-status" />
      </binding>
    </element>
    <element id="Basic.code">
      <path value="Basic.code" />
      <fixedCodeableConcept>
        <text value="NLLDataLock" />
      </fixedCodeableConcept>
    </element>
  </differential>
</StructureDefinition>