{
  "resourceType": "StructureDefinition",
  "url": "http://electronichealth.se/fhir/StructureDefinition/NLLProvenance",
  "name": "NLLProvenance",
  "status": "draft",
  "fhirVersion": "4.0.0",
  "mapping": [
    {
      "identity": "EHM",
      "name": "E-hälsomyndigheten internal model"
    }
  ],
  "kind": "resource",
  "abstract": false,
  "type": "Provenance",
  "baseDefinition": "http://hl7.org/fhir/StructureDefinition/Provenance",
  "derivation": "constraint",
  "differential": {
    "element": [
      {
        "id": "Provenance",
        "path": "Provenance",
        "short": "Who, What, When describing a change on the patient medications list",
        "definition": "NLLProvenance describes a change made on a resource affecting a patient medications list, e.g. a MedicationRequest, MedicationDispense or resource related to multi dose dispensing (sv: dosunderlag, dossamtycke). The change is 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.",
        "mapping": [
          {
            "identity": "EHM",
            "map": "Händelse avseende patients läkemedelslista"
          }
        ]
      },
      {
        "id": "Provenance.extension",
        "path": "Provenance.extension",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "url"
            }
          ],
          "rules": "open"
        }
      },
      {
        "id": "Provenance.extension:nllReasonNote",
        "path": "Provenance.extension",
        "sliceName": "nllReasonNote",
        "short": "Reason note for change/cancellation",
        "definition": "Optional reason note (max 512 characters) which may be added. This element is ONLY used when an optional note is added to describe change/cancellation when a code other than OTH is used.",
        "min": 0,
        "max": "1",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "http://electronichealth.se/fhir/StructureDefinition/NLLReasonDescription"
            ]
          }
        ],
        "mapping": [
          {
            "identity": "EHM",
            "map": "Beskrivning händelseorsak",
            "comment": "For other, optional cases besides OTH"
          }
        ]
      },
      {
        "id": "Provenance.extension:nllReasonNote.value[x]",
        "extension": [
          {
            "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-standards-status",
            "valueCode": "normative"
          },
          {
            "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-normative-version",
            "valueCode": "4.0.0"
          }
        ],
        "path": "Provenance.extension.value[x]",
        "maxLength": 512
      },
      {
        "id": "Provenance.target",
        "path": "Provenance.target",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://electronichealth.se/fhir/StructureDefinition/NLLMedicationRequest",
              "http://electronichealth.se/fhir/StructureDefinition/NLLMultiDoseDispMedList",
              "http://electronichealth.se/fhir/StructureDefinition/NLLMedicationDispense",
              "http://electronichealth.se/fhir/StructureDefinition/NLLMultiDoseDispConsent"
            ],
            "aggregation": [
              "referenced"
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "Provenance.occurred[x]",
        "path": "Provenance.occurred[x]",
        "type": [
          {
            "code": "dateTime"
          }
        ],
        "mustSupport": true,
        "mapping": [
          {
            "identity": "EHM",
            "map": "Händelse.Tidpunkt"
          }
        ]
      },
      {
        "id": "Provenance.reason",
        "path": "Provenance.reason",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "coding.system"
            }
          ],
          "rules": "open"
        },
        "definition": "The reason that the activity was taking place, in NLL used to describe the reqason for change e.g. wrong patient (sv: FEL_PATIENT), medication interaction (sv: interaktion, 404204005), side effects noticed.",
        "max": "1",
        "mustSupport": true,
        "mapping": [
          {
            "identity": "EHM",
            "map": "Händelseorsak"
          }
        ]
      },
      {
        "id": "Provenance.reason:nllReasonForChange",
        "path": "Provenance.reason",
        "sliceName": "nllReasonForChange",
        "max": "1",
        "binding": {
          "extension": [
            {
              "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName",
              "valueString": "ProvenanceReason"
            }
          ],
          "strength": "required",
          "description": "This slice is used when provenance describes cancelling a medication request",
          "valueSet": "http://electronichealth.se/fhir/ValueSet/nll-snomed-andringsorsak"
        }
      },
      {
        "id": "Provenance.reason:nllReasonForChange.text",
        "extension": [
          {
            "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-translatable",
            "valueBoolean": true
          }
        ],
        "path": "Provenance.reason.text",
        "short": "Plain text description, only when code OTH is used",
        "definition": "Plain text description of the reason, should only be used when the code OTH is selected. Note describing the reason for the activity (sv: beskrivning orsak)",
        "maxLength": 512,
        "mustSupport": true,
        "mapping": [
          {
            "identity": "EHM",
            "map": "Beskrivning händelseorsak"
          }
        ]
      },
      {
        "id": "Provenance.reason:nllReasonForCancellation",
        "path": "Provenance.reason",
        "sliceName": "nllReasonForCancellation",
        "max": "1",
        "binding": {
          "extension": [
            {
              "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName",
              "valueString": "ProvenanceReason"
            }
          ],
          "strength": "required",
          "description": "This slice is used when provenance describes cancelling a medication request",
          "valueSet": "http://electronichealth.se/fhir/ValueSet/nll-felregistreringsorsak"
        }
      },
      {
        "id": "Provenance.reason:nllReasonForCancellation.coding",
        "path": "Provenance.reason.coding",
        "max": "1"
      },
      {
        "id": "Provenance.activity",
        "path": "Provenance.activity",
        "definition": "This type describes the activity that occurred, e.g. change on a MedicationRequest (sv: UPPDATERA_FORSKRVNING), cancelling a MedicationRequest (sv: MAKULERA_FORSKRIVNING)",
        "min": 1,
        "mustSupport": true,
        "binding": {
          "strength": "required",
          "valueSet": "http://electronichealth.se/fhir/ValueSet/ml-activity-types"
        },
        "mapping": [
          {
            "identity": "EHM",
            "map": "Händelsetyp"
          }
        ]
      },
      {
        "id": "Provenance.agent",
        "path": "Provenance.agent",
        "definition": "Allowed actors in NLL 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",
        "mapping": [
          {
            "identity": "EHM",
            "map": "Uppdragsgivare / Utförare"
          }
        ]
      },
      {
        "id": "Provenance.agent.type",
        "path": "Provenance.agent.type",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Provenance.agent.who",
        "path": "Provenance.agent.who",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://electronichealth.se/fhir/StructureDefinition/NLLPractitioner"
            ],
            "aggregation": [
              "contained",
              "referenced"
            ]
          }
        ],
        "mustSupport": true,
        "mapping": [
          {
            "identity": "EHM",
            "map": "Uppdragsgivare / Utförare",
            "comment": "Depending on type, this is the practitioner acting as the performer (sv: utförare) or author (sv: uppdragsgivare)"
          }
        ]
      }
    ]
  }
}