{
  "resourceType": "StructureDefinition",
  "id": "ddd7eac3-0f9e-4b96-9638-92f30392ff9c",
  "meta": {
    "lastUpdated": "2022-06-09T10:17:59.5125235+00:00"
  },
  "url": "http://nhn.no/kj/fhir/StructureDefinition/KjAllergyIntolerance",
  "name": "KjAllergyIntolerance",
  "status": "active",
  "date": "2022-06-09T10:19:04.3111016+00:00",
  "fhirVersion": "4.0.1",
  "kind": "resource",
  "abstract": false,
  "type": "AllergyIntolerance",
  "baseDefinition": "http://hl7.org/fhir/StructureDefinition/AllergyIntolerance",
  "derivation": "constraint",
  "differential": {
    "element": [
      {
        "id": "AllergyIntolerance",
        "path": "AllergyIntolerance",
        "definition": "Risk of harmful or undesirable, physiological response which is unique to an individual and associated with exposure to a substance.s",
        "condition": [
          "kj-ait-7"
        ],
        "constraint": [
          {
            "key": "kj-ait-7",
            "severity": "error",
            "human": "Category must be medication if code.coding is not OtherAllergen. If code.coding is OtherAllergen, category cannot be medication.",
            "expression": "(category='medication' and (code.coding.where(system='http://nhn.no/kj/fhir/CodeSystem/OtherAllergen').exists().not())) or (category!='medication' and (code.coding.where(system='http://nhn.no/kj/fhir/CodeSystem/OtherAllergen').exists()))",
            "source": "http://nhn.no/kj/fhir/StructureDefinition/KjAllergyIntolerance"
          }
        ]
      },
      {
        "id": "AllergyIntolerance.extension",
        "path": "AllergyIntolerance.extension",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "url"
            }
          ],
          "rules": "open"
        },
        "min": 1
      },
      {
        "id": "AllergyIntolerance.extension:updatedDateTime",
        "path": "AllergyIntolerance.extension",
        "sliceName": "updatedDateTime",
        "min": 0,
        "max": "1",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "http://nhn.no/kj/fhir/StructureDefinition/KjUpdatedDateTime"
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "AllergyIntolerance.extension:updatedDateTime.value[x]",
        "path": "AllergyIntolerance.extension.value[x]",
        "slicing": {
          "discriminator": [
            {
              "type": "type",
              "path": "$this"
            }
          ],
          "rules": "open"
        }
      },
      {
        "id": "AllergyIntolerance.extension:updater",
        "path": "AllergyIntolerance.extension",
        "sliceName": "updater",
        "min": 0,
        "max": "1",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "http://nhn.no/kj/fhir/StructureDefinition/KjUpdater"
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "AllergyIntolerance.extension:updater.value[x]",
        "path": "AllergyIntolerance.extension.value[x]",
        "slicing": {
          "discriminator": [
            {
              "type": "type",
              "path": "$this"
            }
          ],
          "rules": "open"
        }
      },
      {
        "id": "AllergyIntolerance.extension:sourceOfInformation",
        "path": "AllergyIntolerance.extension",
        "sliceName": "sourceOfInformation",
        "min": 1,
        "max": "1",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "http://nhn.no/kj/fhir/StructureDefinition/KjSourceOfInformation"
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "AllergyIntolerance.identifier",
        "path": "AllergyIntolerance.identifier",
        "mustSupport": true
      },
      {
        "id": "AllergyIntolerance.clinicalStatus",
        "path": "AllergyIntolerance.clinicalStatus",
        "short": "active | inactive",
        "definition": "Should use inactive if refuted or entered-in-error, otherwise use active. Resolved should not be used.",
        "comment": "Should use inactive if refuted or entered-in-error, otherwise use active. Resolved should not be used.",
        "mustSupport": true,
        "binding": {
          "strength": "required",
          "valueSet": "http://nhn.no/kj/fhir/ValueSet/AllergyIntoleranceClinicalStatus"
        }
      },
      {
        "id": "AllergyIntolerance.verificationStatus",
        "path": "AllergyIntolerance.verificationStatus",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "AllergyIntolerance.verificationStatus.extension",
        "path": "AllergyIntolerance.verificationStatus.extension",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "url"
            }
          ],
          "rules": "open"
        },
        "min": 0
      },
      {
        "id": "AllergyIntolerance.verificationStatus.extension:Presumed",
        "path": "AllergyIntolerance.verificationStatus.extension",
        "sliceName": "Presumed",
        "min": 0,
        "type": [
          {
            "code": "Extension",
            "profile": [
              "http://nhn.no/kj/fhir/StructureDefinition/KjPresumed"
            ]
          }
        ]
      },
      {
        "id": "AllergyIntolerance.category",
        "path": "AllergyIntolerance.category",
        "comment": "Should support all types, but in GUI: Medication is \"Legemiddel\" and all other are \"Annet\"",
        "min": 1,
        "max": "1",
        "mustSupport": true
      },
      {
        "id": "AllergyIntolerance.criticality",
        "path": "AllergyIntolerance.criticality",
        "min": 1,
        "mustSupport": true,
        "binding": {
          "strength": "required",
          "valueSet": "http://hl7.org/fhir/ValueSet/allergy-intolerance-criticality"
        }
      },
      {
        "id": "AllergyIntolerance.code",
        "path": "AllergyIntolerance.code",
        "short": "Different code systems allowed here",
        "min": 1,
        "condition": [
          "kj-ait-4",
          "kj-ait-6"
        ],
        "constraint": [
          {
            "key": "kj-ait-4",
            "severity": "error",
            "human": "If code.coding:OtherAllergen.code has value 15 (Annen viktig allergi), then code.text must be present",
            "expression": "(coding.where(system='http://nhn.no/kj/fhir/CodeSystem/OtherAllergen' and code = '15').exists() and text.exists()) or (coding.where(system='http://nhn.no/kj/fhir/CodeSystem/OtherAllergen' and code = '15').exists().not() and text.empty())",
            "source": "http://nhn.no/kj/fhir/StructureDefinition/KjAllergyIntolerance"
          },
          {
            "key": "kj-ait-6",
            "severity": "error",
            "human": "InactiveIngredient can only be set when coding is DrugTradeName",
            "expression": "coding.where(system='http://nhn.no/kj/fhir/CodeSystem/DrugTradeName').exists() or extension.where(url='http://nhn.no/kj/fhir/StructureDefinition/KjInactiveIngredient').exists().not()",
            "source": "http://nhn.no/kj/fhir/StructureDefinition/KjAllergyIntolerance"
          }
        ],
        "mustSupport": true
      },
      {
        "id": "AllergyIntolerance.code.extension",
        "path": "AllergyIntolerance.code.extension",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "url"
            }
          ],
          "rules": "open"
        },
        "min": 0
      },
      {
        "id": "AllergyIntolerance.code.extension:inactiveIngredient",
        "path": "AllergyIntolerance.code.extension",
        "sliceName": "inactiveIngredient",
        "min": 0,
        "max": "1",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "http://nhn.no/kj/fhir/StructureDefinition/KjInactiveIngredient"
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "AllergyIntolerance.code.coding",
        "path": "AllergyIntolerance.code.coding",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "system"
            }
          ],
          "rules": "closed"
        },
        "min": 1,
        "max": "1",
        "mustSupport": true
      },
      {
        "id": "AllergyIntolerance.code.coding:ATC",
        "path": "AllergyIntolerance.code.coding",
        "sliceName": "ATC",
        "short": "This is the codesystem for ATC - urn:oid:2.16.578.1.12.4.1.1.7180",
        "max": "1"
      },
      {
        "id": "AllergyIntolerance.code.coding:ATC.system",
        "path": "AllergyIntolerance.code.coding.system",
        "fixedUri": "http://nhn.no/kj/fhir/CodeSystem/ATC"
      },
      {
        "id": "AllergyIntolerance.code.coding:ActiveSubstance",
        "path": "AllergyIntolerance.code.coding",
        "sliceName": "ActiveSubstance",
        "short": "This is the codesystem for 'Virkestoff' from FEST",
        "max": "1"
      },
      {
        "id": "AllergyIntolerance.code.coding:ActiveSubstance.system",
        "path": "AllergyIntolerance.code.coding.system",
        "fixedUri": "http://nhn.no/kj/fhir/CodeSystem/ActiveSubstance"
      },
      {
        "id": "AllergyIntolerance.code.coding:OtherAllergen",
        "path": "AllergyIntolerance.code.coding",
        "sliceName": "OtherAllergen",
        "short": "This is the codesystem for defining allergens - urn:oid:2.16.578.1.12.4.1.1.7514",
        "max": "1"
      },
      {
        "id": "AllergyIntolerance.code.coding:OtherAllergen.system",
        "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": "AllergyIntolerance.code.coding.system",
        "fixedUri": "http://nhn.no/kj/fhir/CodeSystem/OtherAllergen"
      },
      {
        "id": "AllergyIntolerance.code.coding:DrugTradeName",
        "path": "AllergyIntolerance.code.coding",
        "sliceName": "DrugTradeName",
        "short": "This is the codesystem for 'Merkevare' from FEST",
        "max": "1"
      },
      {
        "id": "AllergyIntolerance.code.coding:DrugTradeName.system",
        "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": "AllergyIntolerance.code.coding.system",
        "fixedUri": "http://nhn.no/kj/fhir/CodeSystem/DrugTradeName"
      },
      {
        "id": "AllergyIntolerance.code.text",
        "path": "AllergyIntolerance.code.text",
        "short": "Other allergy if no proper code is found",
        "definition": "Use this element if no proper code is found.",
        "condition": [
          "kj-ait-5"
        ],
        "constraint": [
          {
            "key": "kj-ait-5",
            "severity": "error",
            "human": "Text can be maximum 80 characters",
            "expression": "value.length() <= 80",
            "source": "http://nhn.no/kj/fhir/StructureDefinition/KjAllergyIntolerance"
          }
        ],
        "mustSupport": true
      },
      {
        "id": "AllergyIntolerance.patient",
        "path": "AllergyIntolerance.patient",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://hl7.no/fhir/StructureDefinition/no-basis-Patient"
            ],
            "aggregation": [
              "referenced"
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "AllergyIntolerance.onset[x]",
        "path": "AllergyIntolerance.onset[x]",
        "type": [
          {
            "code": "dateTime"
          },
          {
            "code": "Age"
          }
        ],
        "mustSupport": true
      },
      {
        "id": "AllergyIntolerance.recordedDate",
        "path": "AllergyIntolerance.recordedDate",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "AllergyIntolerance.recorder",
        "path": "AllergyIntolerance.recorder",
        "definition": "Who recorded the insensitivity. Should use PractitionerRole for registrate both Practitioner and the Organization the recorder worked at when the registration was performed.",
        "min": 1,
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://nhn.no/kj/fhir/StructureDefinition/KjPractitionerRole"
            ],
            "aggregation": [
              "contained",
              "bundled"
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "AllergyIntolerance.note",
        "path": "AllergyIntolerance.note",
        "max": "1",
        "condition": [
          "kj-ait-3"
        ],
        "constraint": [
          {
            "key": "kj-ait-3",
            "severity": "error",
            "human": "If note is present, then text must be between 0 and 500 characters.",
            "expression": "empty() or (first().text.value.length() >=0 and first().text.value.length() <= 500)",
            "source": "http://nhn.no/kj/fhir/StructureDefinition/KjAllergyIntolerance"
          }
        ],
        "mustSupport": true
      },
      {
        "id": "AllergyIntolerance.reaction",
        "path": "AllergyIntolerance.reaction",
        "min": 1,
        "max": "1",
        "mustSupport": true
      },
      {
        "id": "AllergyIntolerance.reaction.manifestation",
        "path": "AllergyIntolerance.reaction.manifestation",
        "max": "1",
        "mustSupport": true,
        "binding": {
          "strength": "preferred",
          "valueSet": "http://nhn.no/kj/fhir/ValueSet/TypeOfReaction"
        }
      },
      {
        "id": "AllergyIntolerance.reaction.manifestation.coding",
        "path": "AllergyIntolerance.reaction.manifestation.coding",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "system"
            }
          ],
          "rules": "open"
        }
      },
      {
        "id": "AllergyIntolerance.reaction.manifestation.coding:TypeOfReaction",
        "path": "AllergyIntolerance.reaction.manifestation.coding",
        "sliceName": "TypeOfReaction",
        "min": 1,
        "max": "1",
        "mustSupport": true,
        "binding": {
          "strength": "required",
          "valueSet": "http://nhn.no/kj/fhir/ValueSet/TypeOfReaction"
        }
      },
      {
        "id": "AllergyIntolerance.reaction.manifestation.coding:TypeOfReaction.system",
        "path": "AllergyIntolerance.reaction.manifestation.coding.system",
        "fixedUri": "http://nhn.no/kj/fhir/CodeSystem/TypeOfReaction"
      }
    ]
  }
}