{
  "resourceType": "StructureDefinition",
  "url": "http://electronichealth.se/fhir/StructureDefinition/NLLDataLock",
  "name": "NLLDataLock",
  "status": "draft",
  "fhirVersion": "4.0.0",
  "mapping": [
    {
      "identity": "rim",
      "uri": "http://hl7.org/v3",
      "name": "RIM Mapping"
    },
    {
      "identity": "w5",
      "uri": "http://hl7.org/fhir/fivews",
      "name": "FiveWs Pattern Mapping"
    },
    {
      "identity": "EHM",
      "uri": "http://ehalsomyndigheten.se"
    }
  ],
  "kind": "resource",
  "abstract": false,
  "type": "Basic",
  "baseDefinition": "http://hl7.org/fhir/StructureDefinition/Basic",
  "derivation": "constraint",
  "differential": {
    "element": [
      {
        "id": "Basic",
        "path": "Basic",
        "short": "Information showing that the target resource has an integrity or secrecy lock",
        "definition": "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."
      },
      {
        "id": "Basic.extension",
        "path": "Basic.extension",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "url"
            }
          ],
          "rules": "open"
        }
      },
      {
        "id": "Basic.extension:nllTargetPatient",
        "path": "Basic.extension",
        "sliceName": "nllTargetPatient",
        "short": "Reference to patient affected by this lock",
        "definition": "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": "1",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "http://electronichealth.se/fhir/StructureDefinition/NLLDataLockTarget"
            ]
          }
        ],
        "mapping": [
          {
            "identity": "EHM",
            "map": "Referens till patient"
          }
        ]
      },
      {
        "id": "Basic.extension:nllPrescriptionChain",
        "path": "Basic.extension",
        "sliceName": "nllPrescriptionChain",
        "short": "Prescription chain id, for the prescription where data lock applies",
        "definition": "If the lock applies to a MedicationRequest, then the prescription chain id should be referred since the lock applies to the full chain.",
        "max": "1",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "http://electronichealth.se/fhir/StructureDefinition/NLLPrescriptionChain"
            ]
          }
        ],
        "mapping": [
          {
            "identity": "EHM",
            "map": "Kedje-id"
          }
        ]
      },
      {
        "id": "Basic.extension:eventHistory",
        "path": "Basic.extension",
        "sliceName": "eventHistory",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "http://electronichealth.se/fhir/StructureDefinition/NLLDataLockEventHistory"
            ]
          }
        ]
      },
      {
        "id": "Basic.extension:nllDataLockType",
        "path": "Basic.extension",
        "sliceName": "nllDataLockType",
        "short": "Type of lock, SEKRETESS | INTEGRITET",
        "definition": "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": 1,
        "max": "1",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "http://electronichealth.se/fhir/StructureDefinition/NLLDataLockType"
            ]
          }
        ],
        "binding": {
          "strength": "required",
          "valueSet": "http://electronichealth.se/fhir/ValueSet/data-lock-type"
        },
        "mapping": [
          {
            "identity": "EHM",
            "map": "Spärrtyp"
          }
        ]
      },
      {
        "id": "Basic.extension:nllLockedSubjectType",
        "path": "Basic.extension",
        "sliceName": "nllLockedSubjectType",
        "short": "Type of information locked",
        "definition": "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": 1,
        "max": "1",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "http://electronichealth.se/fhir/StructureDefinition/NLLLockedSubjectType"
            ]
          }
        ],
        "binding": {
          "strength": "required",
          "valueSet": "http://electronichealth.se/fhir/ValueSet/locked-subject"
        },
        "mapping": [
          {
            "identity": "EHM",
            "map": "SpärradUppgift"
          }
        ]
      },
      {
        "id": "Basic.extension:status",
        "path": "Basic.extension",
        "sliceName": "status",
        "short": "The status of the lock, reflects if it is active or not",
        "definition": "The status of the lock, reflects if it is active or not",
        "min": 1,
        "max": "1",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "http://electronichealth.se/fhir/StructureDefinition/NLLDataLockStatus"
            ]
          }
        ]
      },
      {
        "id": "Basic.extension:status.value[x]",
        "path": "Basic.extension.value[x]",
        "binding": {
          "strength": "required",
          "valueSet": "http://electronichealth.se/fhir/ValueSet/data-lock-status"
        }
      },
      {
        "id": "Basic.code",
        "path": "Basic.code",
        "fixedCodeableConcept": {
          "text": "NLLDataLock"
        }
      }
    ]
  }
}