<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="AllergyIntolerance" />
  <url value="http://ontariohealth.ca/fhir/ehr/StructureDefinition/profile-allergyIntolerance" />
  <version value="1.0.0" />
  <name value="AllergyIntoleranceEHR" />
  <title value="AllergyIntolerance EHR" />
  <status value="active" />
  <description value="Risk of harmful or undesirable, physiological response which is unique to an individual and associated with exposure to a substance." />
  <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.contained">
      <path value="AllergyIntolerance.contained" />
      <short value="A person that is related to a patient, but who is not a direct target of care" />
      <definition value="Information about a person that is involved in the care for a patient, but who is not the target of healthcare, nor has a formal responsibility in the care process." />
      <type>
        <code value="Resource" />
        <profile value="http://ontariohealth.ca/fhir/ehr/StructureDefinition/proifle-relatedPerson" />
      </type>
      <constraint>
        <key value="dom-2" />
        <severity value="error" />
        <human value="If the resource is contained in another resource, it SHALL NOT contain nested Resources" />
        <expression value="contained.contained.empty()" />
        <xpath value="not(parent::f:contained and f:contained)" />
        <source value="http://hl7.org/fhir/StructureDefinition/DomainResource" />
      </constraint>
      <constraint>
        <key value="dom-4" />
        <severity value="error" />
        <human value="If a resource is contained in another resource, it SHALL NOT have a meta.versionId or a meta.lastUpdated" />
        <expression value="contained.meta.versionId.empty() and contained.meta.lastUpdated.empty()" />
        <xpath value="not(exists(f:contained/*/f:meta/f:versionId)) and not(exists(f:contained/*/f:meta/f:lastUpdated))" />
        <source value="http://hl7.org/fhir/StructureDefinition/DomainResource" />
      </constraint>
      <constraint>
        <key value="dom-3" />
        <severity value="error" />
        <human value="If the resource is contained in another resource, it SHALL be referred to from elsewhere in the resource or SHALL refer to the containing resource" />
        <expression value="contained.where((('#'+id in (%resource.descendants().reference | %resource.descendants().as(canonical) | %resource.descendants().as(uri) | %resource.descendants().as(url))) or descendants().where(reference = '#').exists() or descendants().where(as(canonical) = '#').exists() or descendants().where(as(canonical) = '#').exists()).not()).trace('unmatched', id).empty()" />
        <xpath value="not(exists(for $id in f:contained/*/f:id/@value return $contained[not(parent::*/descendant::f:reference/@value=concat('#', $contained/*/id/@value) or descendant::f:reference[@value='#'])]))" />
        <source value="http://hl7.org/fhir/StructureDefinition/DomainResource" />
      </constraint>
      <constraint>
        <key value="dom-6" />
        <severity value="warning" />
        <human value="A resource should have narrative for robust management" />
        <expression value="text.`div`.exists()" />
        <xpath value="exists(f:text/h:div)" />
        <source value="http://hl7.org/fhir/StructureDefinition/DomainResource" />
      </constraint>
      <constraint>
        <key value="dom-5" />
        <severity value="error" />
        <human value="If a resource is contained in another resource, it SHALL NOT have a security label" />
        <expression value="contained.meta.security.empty()" />
        <xpath value="not(exists(f:contained/*/f:meta/f:security))" />
        <source value="http://hl7.org/fhir/StructureDefinition/DomainResource" />
      </constraint>
      <mustSupport value="true" />
      <mapping>
        <identity value="rim" />
        <map value="Entity. Role, or Act" />
      </mapping>
      <mapping>
        <identity value="rim" />
        <map value="N/A" />
      </mapping>
      <mapping>
        <identity value="rim" />
        <map value="role" />
      </mapping>
    </element>
    <element id="AllergyIntolerance.extension:abatement">
      <path value="AllergyIntolerance.extension" />
      <sliceName value="abatement" />
      <type>
        <code value="Extension" />
        <profile value="http://hl7.org/fhir/StructureDefinition/allergyintolerance-abatement" />
      </type>
    </element>
    <element id="AllergyIntolerance.category">
      <path value="AllergyIntolerance.category" />
      <mustSupport value="true" />
    </element>
    <element id="AllergyIntolerance.code">
      <path value="AllergyIntolerance.code" />
      <min value="1" />
      <type>
        <code value="CodeableConcept" />
        <profile value="http://ontariohealth.ca/fhir/ehr/StructureDefinition/CodeableConcept-oh-ehr" />
      </type>
      <mustSupport value="true" />
      <binding>
        <extension url="http://hl7.org/fhir/tools/StructureDefinition/additional-binding">
          <extension url="purpose">
            <valueCode value="candidate" />
          </extension>
          <extension url="valueSet">
            <valueCanonical value="https://fhir.infoway-inforoute.ca/ValueSet/prescriptionmedicinalproduct" />
          </extension>
          <extension url="documentation">
            <valueMarkdown value="Canadian Clinical Drug Data Set providing codes for identification of medications and medical devices in Canada. While not the preferred terminology for broader pan-Canadian exchange use cases, this additional binding is surfaced to socialize the value sets that may be more commonly in use. Where multiple codings can be supplied, it is encouraged to supply the original coding alongside the pan-Canadian preferred terminology." />
          </extension>
          <extension url="key">
            <valueId value="prescriptionMedicinalProduct" />
          </extension>
        </extension>
        <extension url="http://hl7.org/fhir/tools/StructureDefinition/additional-binding">
          <extension url="purpose">
            <valueCode value="candidate" />
          </extension>
          <extension url="valueSet">
            <valueCanonical value="https://fhir.infoway-inforoute.ca/ValueSet/LicensedNaturalHealthProducts" />
          </extension>
          <extension url="documentation">
            <valueMarkdown value="All Natural Product Number (NPN) and Homeopathic Medicine Number (DIN-HM) codes that are licensed by Health Canada and present in the Licensed Natural Health Products Database." />
          </extension>
          <extension url="key">
            <valueId value="licensedNaturalHealthProducts" />
          </extension>
        </extension>
        <extension url="http://hl7.org/fhir/tools/StructureDefinition/additional-binding">
          <extension url="purpose">
            <valueCode value="candidate" />
          </extension>
          <extension url="valueSet">
            <valueCanonical value="http://hl7.org/fhir/uv/ips/ValueSet/absent-or-unknown-allergies-uv-ips" />
          </extension>
          <extension url="documentation">
            <valueMarkdown value="A code that classifies a use of Contrast for an MI procedure. This is used for searching, sorting and display purposes." />
          </extension>
          <extension url="key">
            <valueId value="absentUnknownAllergiesIPS" />
          </extension>
        </extension>
        <strength value="preferred" />
        <valueSet value="https://fhir.infoway-inforoute.ca/ValueSet/pharmaceuticalbiologicproductandsubstancecode" />
      </binding>
    </element>
    <element id="AllergyIntolerance.code.coding.display.extension:translation">
      <path value="AllergyIntolerance.code.coding.display.extension" />
      <sliceName value="translation" />
    </element>
    <element id="AllergyIntolerance.code.coding.display.extension:translation.extension">
      <path value="AllergyIntolerance.code.coding.display.extension.extension" />
      <min value="2" />
    </element>
    <element id="AllergyIntolerance.patient">
      <path value="AllergyIntolerance.patient" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://ontariohealth.ca/fhir/ehr/StructureDefinition/profile-patient" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="AllergyIntolerance.patient.reference">
      <path value="AllergyIntolerance.patient.reference" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="AllergyIntolerance.encounter">
      <path value="AllergyIntolerance.encounter" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://ontariohealth.ca/fhir/ehr/StructureDefinition/profile-encounter" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="AllergyIntolerance.encounter.reference">
      <path value="AllergyIntolerance.encounter.reference" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="AllergyIntolerance.onset[x]">
      <path value="AllergyIntolerance.onset[x]" />
      <slicing>
        <discriminator>
          <type value="type" />
          <path value="$this" />
        </discriminator>
        <ordered value="false" />
        <rules value="open" />
      </slicing>
      <mustSupport value="true" />
    </element>
    <element id="AllergyIntolerance.onset[x]:onsetDateTime">
      <path value="AllergyIntolerance.onset[x]" />
      <sliceName value="onsetDateTime" />
      <type>
        <code value="dateTime" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="AllergyIntolerance.onset[x]:onsetString">
      <path value="AllergyIntolerance.onset[x]" />
      <sliceName value="onsetString" />
      <type>
        <code value="string" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="AllergyIntolerance.recordedDate">
      <path value="AllergyIntolerance.recordedDate" />
      <mustSupport value="true" />
    </element>
    <element id="AllergyIntolerance.recorder">
      <path value="AllergyIntolerance.recorder" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://ontariohealth.ca/fhir/ehr/StructureDefinition/profile-practitioner" />
        <targetProfile value="http://ontariohealth.ca/fhir/ehr/StructureDefinition/profile-practitionerRole" />
        <targetProfile value="http://ontariohealth.ca/fhir/ehr/StructureDefinition/profile-patient" />
        <targetProfile value="http://ontariohealth.ca/fhir/ehr/StructureDefinition/proifle-relatedPerson" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="AllergyIntolerance.lastOccurrence">
      <path value="AllergyIntolerance.lastOccurrence" />
      <mustSupport value="true" />
    </element>
    <element id="AllergyIntolerance.reaction">
      <path value="AllergyIntolerance.reaction" />
      <mustSupport value="true" />
    </element>
    <element id="AllergyIntolerance.reaction.manifestation">
      <path value="AllergyIntolerance.reaction.manifestation" />
      <type>
        <code value="CodeableConcept" />
        <profile value="http://ontariohealth.ca/fhir/ehr/StructureDefinition/CodeableConcept-oh-ehr" />
      </type>
      <mustSupport value="true" />
      <binding>
        <strength value="preferred" />
        <valueSet value="https://fhir.infoway-inforoute.ca/ValueSet/clinicalfindingcode" />
      </binding>
    </element>
    <element id="AllergyIntolerance.reaction.manifestation.coding.display.extension:translation">
      <path value="AllergyIntolerance.reaction.manifestation.coding.display.extension" />
      <sliceName value="translation" />
    </element>
    <element id="AllergyIntolerance.reaction.manifestation.coding.display.extension:translation.extension">
      <path value="AllergyIntolerance.reaction.manifestation.coding.display.extension.extension" />
      <min value="2" />
    </element>
    <element id="AllergyIntolerance.reaction.severity">
      <path value="AllergyIntolerance.reaction.severity" />
      <mustSupport value="true" />
    </element>
  </differential>
</StructureDefinition>