<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="ie-core-allergyintolerance" />
  <url value="https://hl7-ie.github.io/ie-core/fhir/ie/core/StructureDefinition/ie-core-allergyintolerance" />
  <name value="IECoreAllergyIntolerance" />
  <title value="IE Core AllergyIntolerance" />
  <status value="draft" />
  <description value="The IE Core AllergyIntolerance profile sets minimum expectations for the AllergyIntolerance resource to record, search, and fetch allergy and intolerance data associated with a patient, based on Irish requirements." />
  <fhirVersion value="4.0.1" />
  <kind value="resource" />
  <abstract value="false" />
  <type value="AllergyIntolerance" />
  <baseDefinition value="http://hl7.org/fhir/StructureDefinition/AllergyIntolerance" />
  <derivation value="constraint" />
  <differential>
    <element id="AllergyIntolerance">
      <path value="AllergyIntolerance" />
      <constraint>
        <key value="ie-allergy-1" />
        <severity value="error" />
        <human value="An allergy or intolerance SHALL have a clinical status unless it was entered in error (HIQA PS 5.3.1, Mandatory; FHIR ait-2 forbids clinicalStatus when entered-in-error)" />
        <expression value="verificationStatus.coding.where(code = 'entered-in-error').exists() or clinicalStatus.exists()" />
        <source value="https://hl7-ie.github.io/ie-core/fhir/ie/core/StructureDefinition/ie-core-allergyintolerance" />
      </constraint>
    </element>
    <element id="AllergyIntolerance.clinicalStatus">
      <path value="AllergyIntolerance.clinicalStatus" />
      <comment value="HIQA PS 5.3.1 Allergies or intolerances status (Mandatory): required unless the record was entered in error (invariant ie-allergy-1; FHIR ait-2 forbids clinicalStatus when entered-in-error)." />
      <mustSupport value="true" />
    </element>
    <element id="AllergyIntolerance.verificationStatus">
      <path value="AllergyIntolerance.verificationStatus" />
      <comment value="HIQA PS 5.3.5 Certainty (Optional)." />
      <mustSupport value="true" />
    </element>
    <element id="AllergyIntolerance.category">
      <path value="AllergyIntolerance.category" />
      <mustSupport value="true" />
    </element>
    <element id="AllergyIntolerance.code">
      <path value="AllergyIntolerance.code" />
      <comment value="HIQA PS 5.3.2 Causative agent or allergen (Mandatory); EP 1.6.2.1 Allergies or intolerances (Required)." />
      <min value="1" />
      <mustSupport value="true" />
      <binding>
        <strength value="extensible" />
        <valueSet value="https://hl7-ie.github.io/ie-core/fhir/ie/core/ValueSet/ie-core-allergy-intolerance-set" />
      </binding>
    </element>
    <element id="AllergyIntolerance.patient">
      <path value="AllergyIntolerance.patient" />
      <type>
        <code value="Reference" />
        <targetProfile value="https://hl7-ie.github.io/ie-core/fhir/ie/core/StructureDefinition/ie-core-patient" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="AllergyIntolerance.onset[x]">
      <path value="AllergyIntolerance.onset[x]" />
      <comment value="HIQA PS 5.3.3 Onset date (Required)." />
      <mustSupport value="true" />
    </element>
    <element id="AllergyIntolerance.recordedDate">
      <path value="AllergyIntolerance.recordedDate" />
      <comment value="HIQA EP 1.6.2.4.3 / PS 19.2.4 Record entry date (Mandatory within the provenance cluster)." />
      <mustSupport value="true" />
    </element>
    <element id="AllergyIntolerance.recorder">
      <path value="AllergyIntolerance.recorder" />
      <comment value="HIQA EP 1.6.2.4.2 / PS 19.2.3 Record entry author (Mandatory within the provenance cluster)." />
      <mustSupport value="true" />
    </element>
    <element id="AllergyIntolerance.asserter">
      <path value="AllergyIntolerance.asserter" />
      <comment value="HIQA EP 1.6.2.4.4 / PS 19.2.5 Record entry source (Optional): patient, contact person or health practitioner." />
    </element>
    <element id="AllergyIntolerance.note">
      <path value="AllergyIntolerance.note" />
      <comment value="HIQA EP 1.6.2.3 Additional information / PS 5.3.6 Note (Optional)." />
    </element>
    <element id="AllergyIntolerance.reaction">
      <path value="AllergyIntolerance.reaction" />
      <mustSupport value="true" />
    </element>
    <element id="AllergyIntolerance.reaction.substance">
      <path value="AllergyIntolerance.reaction.substance" />
      <comment value="HIQA EP 1.6.2.2 Causative agent (Required); PS 5.3.7.1 Allergen (Mandatory within the reaction cluster)." />
      <mustSupport value="true" />
    </element>
    <element id="AllergyIntolerance.reaction.manifestation">
      <path value="AllergyIntolerance.reaction.manifestation" />
      <mustSupport value="true" />
    </element>
    <element id="AllergyIntolerance.reaction.description">
      <path value="AllergyIntolerance.reaction.description" />
      <comment value="HIQA PS 5.3.7.2 Description of reaction (Required)." />
      <mustSupport value="true" />
    </element>
    <element id="AllergyIntolerance.reaction.severity">
      <path value="AllergyIntolerance.reaction.severity" />
      <comment value="HIQA PS 5.3.7.4 Severity (Required)." />
      <mustSupport value="true" />
    </element>
  </differential>
</StructureDefinition>