{
  "resourceType": "StructureDefinition",
  "id": "profile-allergyintolerance",
  "url": "http://hl7.org/fhir/ca/baseline/StructureDefinition/profile-allergyintolerance",
  "version": "1.0.1",
  "name": "AllergyIntoleranceProfile",
  "title": "AllergyIntolerance Profile",
  "status": "draft",
  "date": "2026-01-09",
  "publisher": "HL7 Canada - FHIR Implementation Work Group",
  "contact": [
    {
      "telecom": [
        {
          "system": "url",
          "value": "https://infocentral.infoway-inforoute.ca/en/collaboration/wg/fhir-implementations"
        }
      ]
    }
  ],
  "description": "Proposed constraints and extensions on the AllergyIntolerance Resource",
  "jurisdiction": [
    {
      "coding": [
        {
          "system": "urn:iso:std:iso:3166",
          "code": "CA"
        }
      ]
    }
  ],
  "fhirVersion": "4.0.1",
  "mapping": [
    {
      "identity": "rim",
      "uri": "http://hl7.org/v3",
      "name": "RIM Mapping"
    },
    {
      "identity": "w5",
      "uri": "http://hl7.org/fhir/fivews",
      "name": "FiveWs Pattern Mapping"
    },
    {
      "identity": "v2",
      "uri": "http://hl7.org/v2",
      "name": "HL7 v2 Mapping"
    }
  ],
  "kind": "resource",
  "abstract": false,
  "type": "AllergyIntolerance",
  "baseDefinition": "http://hl7.org/fhir/StructureDefinition/AllergyIntolerance",
  "derivation": "constraint",
  "differential": {
    "element": [
      {
        "id": "AllergyIntolerance",
        "path": "AllergyIntolerance",
        "short": "AllergyIntolerance Profile",
        "definition": "The AllergyIntolerance Profile is based upon the core FHIR AllergyIntolerance Resource",
        "constraint": [
          {
            "key": "ca-baseline-allergy",
            "severity": "error",
            "human": "AllergyIntolerance.verificationStatus SHALL be present if AllergyIntolerance.code represents NullFlavor concept",
            "expression": "code.coding.where(system = 'http://terminology.hl7.org/CodeSystem/v3-NullFlavor').exists() implies verificationStatus.exists()",
            "xpath": "f:code/f:coding/f:system/@value='https://fhir.infoway-inforoute.ca/ValueSet/nullflavor' implies exists(f:verificationStatus)"
          },
          {
            "key": "ca-baseline-allergy-notasked",
            "severity": "error",
            "human": "if AllergyIntolerance.code is a NullFlavor value, then AllergyIntolerance.clinicalStatus, AllergyIntolerance.type, AllergyIntolerance.category, AllergyIntolerance.criticality SHALL NOT be present",
            "expression": "code.coding.where(system = 'http://terminology.hl7.org/CodeSystem/v3-NullFlavor').exists() implies type.exists().not() and category.exists().not() and criticality.exists().not()",
            "xpath": "f:code/f:coding/f:system/@value='http://terminology.hl7.org/CodeSystem/v3-NullFlavor' and exists(f:type).not() and exists(f:category).not() and exists(f:criticality).not()"
          },
          {
            "key": "ca-baseline-allergy-noallergy",
            "severity": "error",
            "human": "if AllergyIntolerance.code is '716186003' No known allergy, then AllergyIntolerance.verificationStatus SHALL be one of the following: confirmed | refuted | entered-in-error",
            "expression": "code.coding.where(system = 'http://snomed.info/sct' and code = '716186003').exists() and verificationStatus.coding.where(code = 'unconfirmed').empty()",
            "xpath": "f:code/f:coding/f:system/@value='http://snomed.info/sct' and exists(f:verificationStatus/f:coding/f:code/@value='unconfirmed').not()"
          }
        ]
      },
      {
        "id": "AllergyIntolerance.extension",
        "path": "AllergyIntolerance.extension",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "url"
            }
          ],
          "ordered": false,
          "rules": "open"
        }
      },
      {
        "id": "AllergyIntolerance.extension:abatement",
        "path": "AllergyIntolerance.extension",
        "sliceName": "abatement",
        "min": 0,
        "max": "1",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "http://hl7.org/fhir/StructureDefinition/allergyintolerance-abatement"
            ]
          }
        ]
      },
      {
        "id": "AllergyIntolerance.identifier",
        "path": "AllergyIntolerance.identifier"
      },
      {
        "id": "AllergyIntolerance.clinicalStatus",
        "path": "AllergyIntolerance.clinicalStatus",
        "isModifier": true,
        "isModifierReason": "This element is labeled as a modifier because the status contains the codes refuted and entered-in-error that mark the AllergyIntolerance as not currently valid."
      },
      {
        "id": "AllergyIntolerance.verificationStatus",
        "path": "AllergyIntolerance.verificationStatus",
        "isModifier": true,
        "isModifierReason": "This element is labeled as a modifier because the status contains the codes refuted and entered-in-error that mark the AllergyIntolerance as not currently valid."
      },
      {
        "id": "AllergyIntolerance.category",
        "path": "AllergyIntolerance.category",
        "comment": "Some implementers may utilize value sets where category is readily distinguishable while others may not, and those that do not use those value sets should consider making category MS in their profiles"
      },
      {
        "id": "AllergyIntolerance.code",
        "path": "AllergyIntolerance.code",
        "binding": {
          "strength": "preferred",
          "valueSet": "https://fhir.infoway-inforoute.ca/ValueSet/pharmaceuticalbiologicproductandsubstancecode"
        }
      },
      {
        "id": "AllergyIntolerance.patient",
        "path": "AllergyIntolerance.patient",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://hl7.org/fhir/ca/baseline/StructureDefinition/profile-patient"
            ]
          }
        ]
      },
      {
        "id": "AllergyIntolerance.encounter",
        "path": "AllergyIntolerance.encounter",
        "short": "Encounter when the allergy or intolerance was asserted",
        "definition": "The encounter when the allergy or intolerance was asserted.",
        "min": 0,
        "max": "1",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://hl7.org/fhir/ca/baseline/StructureDefinition/profile-encounter"
            ]
          }
        ]
      },
      {
        "id": "AllergyIntolerance.onsetDateTime:onsetDateTime",
        "path": "AllergyIntolerance.onsetDateTime",
        "sliceName": "onsetDateTime",
        "comment": "This slice was initially flagged as Must Support, and is considered MS in a handful of Canadian FHIR Implementation Guides. However, while clinically desireable it is not broadly considered MS across all IGuides reviewed during the Due Dilligence Review.",
        "min": 0,
        "type": [
          {
            "code": "dateTime"
          }
        ]
      },
      {
        "id": "AllergyIntolerance.recorder",
        "path": "AllergyIntolerance.recorder",
        "short": "Who recorded the sensitivity",
        "definition": "Individual who recorded the record and takes responsibility for its content.",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://hl7.org/fhir/ca/baseline/StructureDefinition/profile-practitioner",
              "http://hl7.org/fhir/ca/baseline/StructureDefinition/profile-practitionerrole",
              "http://hl7.org/fhir/ca/baseline/StructureDefinition/profile-patient"
            ]
          }
        ]
      },
      {
        "id": "AllergyIntolerance.asserter",
        "path": "AllergyIntolerance.asserter",
        "short": "Source of the information about the allergy",
        "definition": "The source of the information about the allergy that is recorded.",
        "min": 0,
        "max": "1",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://hl7.org/fhir/ca/baseline/StructureDefinition/profile-patient",
              "http://hl7.org/fhir/ca/baseline/StructureDefinition/profile-practitioner",
              "http://hl7.org/fhir/ca/baseline/StructureDefinition/profile-practitionerrole"
            ]
          }
        ]
      },
      {
        "id": "AllergyIntolerance.reaction.substance",
        "path": "AllergyIntolerance.reaction.substance",
        "short": "Specific substance or pharmaceutical product considered to be responsible for event"
      },
      {
        "id": "AllergyIntolerance.reaction.substance.coding",
        "path": "AllergyIntolerance.reaction.substance.coding",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "system"
            }
          ],
          "rules": "closed"
        },
        "comment": "This slice was initially identified with a 1..* cardinality, and has similar constraints in a handful of Canadian FHIR Implementation Guides. However, while clinically desireable to include coding, it was not constrained consistently across all IGuides reviewed during the Due Dilligence Review."
      },
      {
        "id": "AllergyIntolerance.reaction.substance.coding:NonDrugAllergen",
        "path": "AllergyIntolerance.reaction.substance.coding",
        "sliceName": "NonDrugAllergen",
        "short": "Code for the specific non-drug allergen",
        "definition": "Code for the specific non-drug allergen or other agent/substance to which the Client has an allergic reaction.",
        "comment": "The binding strength of this element is [Preferred](https://www.hl7.org/fhir/terminologies.html#strength), meaning that codes are encouraged to draw from the NonDrugAllergenCode value set for interoperability purposes but are not required to do so to be considered conformant.",
        "type": [
          {
            "code": "Coding"
          }
        ],
        "binding": {
          "strength": "preferred",
          "description": "Represents the specific non-drug allergen or other agent/substance to which the Client has an allergic reaction.",
          "valueSet": "https://fhir.infoway-inforoute.ca/ValueSet/nondrugallergencode"
        }
      },
      {
        "id": "AllergyIntolerance.reaction.substance.coding:NonDrugAllergen.system",
        "path": "AllergyIntolerance.reaction.substance.coding.system",
        "min": 1
      },
      {
        "id": "AllergyIntolerance.reaction.substance.coding:NonDrugAllergen.code",
        "path": "AllergyIntolerance.reaction.substance.coding.code",
        "min": 1
      },
      {
        "id": "AllergyIntolerance.reaction.substance.coding:CCDD",
        "path": "AllergyIntolerance.reaction.substance.coding",
        "sliceName": "CCDD",
        "short": "Medicinal products for prescribing",
        "definition": "The subset of codes with commonly used medicinal products that are available for prescribing and dispensing in Canada.",
        "comment": "The binding strength of this element is [Preferred](https://www.hl7.org/fhir/terminologies.html#strength), meaning that codes are encouraged to draw from the PrescriptionMedicinalProduct value set for interoperability purposes but are not required to do so to be considered conformant.",
        "type": [
          {
            "code": "Coding"
          }
        ],
        "binding": {
          "strength": "preferred",
          "description": "Represents subset of codes with commonly used medicinal products that are available for prescribing and dispensing in Canada.",
          "valueSet": "https://fhir.infoway-inforoute.ca/ValueSet/prescriptionmedicinalproduct"
        }
      },
      {
        "id": "AllergyIntolerance.reaction.substance.coding:CCDD.system",
        "path": "AllergyIntolerance.reaction.substance.coding.system",
        "min": 1,
        "patternUri": "https://fhir.infoway-inforoute.ca/CodeSystem/canadianclinicaldrugdataset"
      },
      {
        "id": "AllergyIntolerance.reaction.substance.coding:CCDD.code",
        "path": "AllergyIntolerance.reaction.substance.coding.code",
        "min": 1
      },
      {
        "id": "AllergyIntolerance.reaction.substance.coding:@default",
        "path": "AllergyIntolerance.reaction.substance.coding",
        "sliceName": "@default",
        "short": "Specific substance or pharmaceutical product considered to be responsible for event",
        "definition": "Identification of the specific substance (or pharmaceutical product) considered to be responsible for the Adverse Reaction event.",
        "comment": "The binding strength of this element is [Example](https://hl7.org/fhir/R4/terminologies.html#example), meaning that codes are not expected or even encouraged to draw from the specified value set to be conformant",
        "type": [
          {
            "code": "Coding"
          }
        ],
        "binding": {
          "extension": [
            {
              "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName",
              "valueString": "SubstanceCode"
            }
          ],
          "strength": "example",
          "description": "Codes defining the type of the substance (including pharmaceutical products).",
          "valueSet": "http://hl7.org/fhir/ValueSet/substance-code"
        }
      },
      {
        "id": "AllergyIntolerance.reaction.exposureRoute",
        "path": "AllergyIntolerance.reaction.exposureRoute",
        "short": "How the subject was exposed to the substance",
        "definition": "Identification of the route by which the subject was exposed to the substance.",
        "comment": "The binding strength of this element is [Preferred](https://www.hl7.org/fhir/terminologies.html#strength), meaning that codes are encouraged to draw from the RouteOfAdministration value set for interoperability purposes but are not required to do so to be considered conformant.",
        "type": [
          {
            "code": "CodeableConcept"
          }
        ],
        "binding": {
          "strength": "preferred",
          "description": "A coded concept describing the route or physiological path of administration of a therapeutic agent into or onto the body of a subject.",
          "valueSet": "https://fhir.infoway-inforoute.ca/ValueSet/routeofadministration"
        }
      }
    ]
  }
}