{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://hl7.erp.uno/priv/schema/AllergyIntolerance.schema.json",
  "$ref": "#/definitions/AllergyIntolerance",
  "description": "see https://hl7.org/fhir/R5/json.html for information about the FHIR Json Schemas",
  "definitions": {
    "AllergyIntolerance": {
      "allOf": [
        {
          "$ref": "DomainResource.schema.json#/definitions/DomainResource"
        },
        {
          "description": "Risk of harmful or undesirable, physiological response which is unique to an individual and associated with exposure to a substance.",
          "properties": {
            "resourceType": {
              "description": "This is a AllergyIntolerance resource",
              "type": "string",
              "enum": ["AllergyIntolerance"]
            },
            "identifier": {
              "description": "This records identifiers associated with this allergy/intolerance concern that are defined by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate (e.g. in CDA documents, or in written / printed documentation).",
              "type": "array",
              "items": {
                "$ref": "Identifier.schema.json#/definitions/Identifier"
              }
            },
            "clinicalStatus": {
              "description": "The clinical status of the allergy or intolerance.",
              "enum": ["active", "inactive", "resolved"],
              "type": "string"
            },
            "_clinicalStatus": {
              "description": "Extensions for clinicalStatus",
              "$ref": "Element.schema.json#/definitions/Element"
            },
            "verificationStatus": {
              "description": "Assertion about certainty associated with the propensity, or potential risk, of a reaction to the identified substance (including pharmaceutical product).",
              "enum": [
                "unconfirmed",
                "confirmed",
                "refuted",
                "entered-in-error"
              ],
              "type": "string"
            },
            "_verificationStatus": {
              "description": "Extensions for verificationStatus",
              "$ref": "Element.schema.json#/definitions/Element"
            },
            "type": {
              "description": "Identification of the underlying physiological mechanism for the reaction risk.",
              "enum": ["allergy", "intolerance"],
              "type": "string"
            },
            "_type": {
              "description": "Extensions for type",
              "$ref": "Element.schema.json#/definitions/Element"
            },
            "category": {
              "description": "Category of the identified substance.",
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "_category": {
              "description": "Extensions for category",
              "type": "array",
              "items": {
                "$ref": "Element.schema.json#/definitions/Element"
              }
            },
            "criticality": {
              "description": "Estimate of the potential clinical harm, or seriousness, of the reaction to the identified substance.",
              "enum": ["low", "high", "unable-to-assess"],
              "type": "string"
            },
            "_criticality": {
              "description": "Extensions for criticality",
              "$ref": "Element.schema.json#/definitions/Element"
            },
            "code": {
              "description": "Code for an allergy or intolerance statement (either a positive or a negated/excluded statement).  This may be a code for a substance or pharmaceutical product that is considered to be responsible for the adverse reaction risk (e.g., \"Latex\"), an allergy or intolerance condition (e.g., \"Latex allergy\"), or a negated/excluded code for a specific substance or class (e.g., \"No latex allergy\") or a general or categorical negated statement (e.g.,  \"No known allergy\", \"No known drug allergies\").",
              "$ref": "CodeableConcept.schema.json#/definitions/CodeableConcept"
            },
            "patient": {
              "description": "The patient who has the allergy or intolerance.",
              "$ref": "Reference.schema.json#/definitions/Reference"
            },
            "onsetDateTime": {
              "description": "Estimated or actual date,  date-time, or age when allergy or intolerance was identified.",
              "pattern": "-?([0-9]([0-9]([0-9][1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2][0-9]|3[0-1])(T([01][0-9]|2[0-3]):[0-5][0-9]:([0-5][0-9]|60)(\\.[0-9]+)?(Z|(\\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00)))?)?)?",
              "type": "string"
            },
            "_onsetDateTime": {
              "description": "Extensions for onsetDateTime",
              "$ref": "Element.schema.json#/definitions/Element"
            },
            "onsetAge": {
              "description": "Estimated or actual date,  date-time, or age when allergy or intolerance was identified.",
              "$ref": "Age.schema.json#/definitions/Age"
            },
            "onsetPeriod": {
              "description": "Estimated or actual date,  date-time, or age when allergy or intolerance was identified.",
              "$ref": "Period.schema.json#/definitions/Period"
            },
            "onsetRange": {
              "description": "Estimated or actual date,  date-time, or age when allergy or intolerance was identified.",
              "$ref": "Range.schema.json#/definitions/Range"
            },
            "onsetString": {
              "description": "Estimated or actual date,  date-time, or age when allergy or intolerance was identified.",
              "type": "string"
            },
            "_onsetString": {
              "description": "Extensions for onsetString",
              "$ref": "Element.schema.json#/definitions/Element"
            },
            "assertedDate": {
              "description": "The date on which the existance of the AllergyIntolerance was first asserted or acknowledged.",
              "type": "string",
              "pattern": "-?([0-9]([0-9]([0-9][1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2][0-9]|3[0-1])(T([01][0-9]|2[0-3]):[0-5][0-9]:([0-5][0-9]|60)(\\.[0-9]+)?(Z|(\\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00)))?)?)?"
            },
            "_assertedDate": {
              "description": "Extensions for assertedDate",
              "$ref": "Element.schema.json#/definitions/Element"
            },
            "recorder": {
              "description": "Individual who recorded the record and takes responsibility for its content.",
              "$ref": "Reference.schema.json#/definitions/Reference"
            },
            "asserter": {
              "description": "The source of the information about the allergy that is recorded.",
              "$ref": "Reference.schema.json#/definitions/Reference"
            },
            "lastOccurrence": {
              "description": "Represents the date and/or time of the last known occurrence of a reaction event.",
              "type": "string",
              "pattern": "-?([0-9]([0-9]([0-9][1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2][0-9]|3[0-1])(T([01][0-9]|2[0-3]):[0-5][0-9]:([0-5][0-9]|60)(\\.[0-9]+)?(Z|(\\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00)))?)?)?"
            },
            "_lastOccurrence": {
              "description": "Extensions for lastOccurrence",
              "$ref": "Element.schema.json#/definitions/Element"
            },
            "note": {
              "description": "Additional narrative about the propensity for the Adverse Reaction, not captured in other fields.",
              "type": "array",
              "items": {
                "$ref": "Annotation.schema.json#/definitions/Annotation"
              }
            },
            "reaction": {
              "description": "Details about each adverse reaction event linked to exposure to the identified substance.",
              "type": "array",
              "items": {
                "$ref": "#/definitions/AllergyIntolerance_Reaction"
              }
            }
          },
          "required": ["patient", "resourceType"]
        }
      ]
    },
    "AllergyIntolerance_Reaction": {
      "allOf": [
        {
          "$ref": "BackboneElement.schema.json#/definitions/BackboneElement"
        },
        {
          "description": "Risk of harmful or undesirable, physiological response which is unique to an individual and associated with exposure to a substance.",
          "properties": {
            "substance": {
              "description": "Identification of the specific substance (or pharmaceutical product) considered to be responsible for the Adverse Reaction event. Note: the substance for a specific reaction may be different from the substance identified as the cause of the risk, but it must be consistent with it. For instance, it may be a more specific substance (e.g. a brand medication) or a composite product that includes the identified substance. It must be clinically safe to only process the \u0027code\u0027 and ignore the \u0027reaction.substance\u0027.",
              "$ref": "CodeableConcept.schema.json#/definitions/CodeableConcept"
            },
            "manifestation": {
              "description": "Clinical symptoms and/or signs that are observed or associated with the adverse reaction event.",
              "type": "array",
              "items": {
                "$ref": "CodeableConcept.schema.json#/definitions/CodeableConcept"
              }
            },
            "description": {
              "description": "Text description about the reaction as a whole, including details of the manifestation if required.",
              "type": "string"
            },
            "_description": {
              "description": "Extensions for description",
              "$ref": "Element.schema.json#/definitions/Element"
            },
            "onset": {
              "description": "Record of the date and/or time of the onset of the Reaction.",
              "type": "string",
              "pattern": "-?([0-9]([0-9]([0-9][1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2][0-9]|3[0-1])(T([01][0-9]|2[0-3]):[0-5][0-9]:([0-5][0-9]|60)(\\.[0-9]+)?(Z|(\\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00)))?)?)?"
            },
            "_onset": {
              "description": "Extensions for onset",
              "$ref": "Element.schema.json#/definitions/Element"
            },
            "severity": {
              "description": "Clinical assessment of the severity of the reaction event as a whole, potentially considering multiple different manifestations.",
              "enum": ["mild", "moderate", "severe"],
              "type": "string"
            },
            "_severity": {
              "description": "Extensions for severity",
              "$ref": "Element.schema.json#/definitions/Element"
            },
            "exposureRoute": {
              "description": "Identification of the route by which the subject was exposed to the substance.",
              "$ref": "CodeableConcept.schema.json#/definitions/CodeableConcept"
            },
            "note": {
              "description": "Additional text about the adverse reaction event not captured in other fields.",
              "type": "array",
              "items": {
                "$ref": "Annotation.schema.json#/definitions/Annotation"
              }
            }
          },
          "required": ["manifestation"]
        }
      ]
    }
  }
}
