﻿{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "id": "http://hl7.org/fhir/json-schema/Medication",
  "$ref": "#/definitions/Medication",
  "description": "see http://hl7.org/fhir/json.html#schema for information about the FHIR Json Schemas",
  "definitions": {
    "Medication": {
      "allOf": [
        {
          "$ref": "DomainResource.schema.json/definitions/DomainResource"
        },
        {
          "description": "This resource is primarily used for the identification and definition of a medication. It covers the ingredients and the packaging for a medication.",
          "properties": {
            "resourceType": {
              "description": "This is a Medication resource",
              "type": "string",
              "enum": [
                "Medication"
              ]
            },
            "code": {
              "description": "A code (or set of codes) that specify this medication, or a textual description if no code is available. Usage note: This could be a standard medication code such as a code from RxNorm, SNOMED CT, IDMP etc. It could also be a national or local formulary code, optionally with translations to other code systems.",
              "$ref": "CodeableConcept.schema.json/definitions/CodeableConcept"
            },
            "isBrand": {
              "description": "Set to true if the item is attributable to a specific manufacturer.",
              "type": "true | false"
            },
            "isBrand_": {
              "description": "Extensions for isBrand",
              "$ref": "Element.schema.json/definitions/Element"
            },
            "manufacturer": {
              "description": "Describes the details of the manufacturer.",
              "$ref": "Reference.schema.json/definitions/Reference"
            },
            "product": {
              "description": "Information that only applies to products (not packages).",
              "$ref": "#/definitions/Medication.Product"
            },
            "package": {
              "description": "Information that only applies to packages (not products).",
              "$ref": "#/definitions/Medication.Package"
            }
          },
          "required": [
            "resourceType"
          ]
        }
      ]
    },
    "Medication.Product": {
      "allOf": [
        {
          "$ref": "BackboneElement.schema.json/definitions/BackboneElement"
        },
        {
          "description": "This resource is primarily used for the identification and definition of a medication. It covers the ingredients and the packaging for a medication.",
          "properties": {
            "form": {
              "description": "Describes the form of the item.  Powder; tablets; carton.",
              "$ref": "CodeableConcept.schema.json/definitions/CodeableConcept"
            },
            "ingredient": {
              "description": "Identifies a particular constituent of interest in the product.",
              "type": "array",
              "items": {
                "$ref": "#/definitions/Medication.Ingredient"
              }
            },
            "batch": {
              "description": "Information about a group of medication produced or packaged from one production run.",
              "type": "array",
              "items": {
                "$ref": "#/definitions/Medication.Batch"
              }
            }
          }
        }
      ]
    },
    "Medication.Ingredient": {
      "allOf": [
        {
          "$ref": "BackboneElement.schema.json/definitions/BackboneElement"
        },
        {
          "description": "This resource is primarily used for the identification and definition of a medication. It covers the ingredients and the packaging for a medication.",
          "properties": {
            "itemCodeableConcept": {
              "description": "The actual ingredient - either a substance (simple ingredient) or another medication.",
              "$ref": "CodeableConcept.schema.json/definitions/CodeableConcept"
            },
            "itemReference": {
              "description": "The actual ingredient - either a substance (simple ingredient) or another medication.",
              "$ref": "Reference.schema.json/definitions/Reference"
            },
            "amount": {
              "description": "Specifies how many (or how much) of the items there are in this Medication.  For example, 250 mg per tablet.  This is expressed as a ratio where the numerator is 250mg and the denominator is 1 tablet.",
              "$ref": "Ratio.schema.json/definitions/Ratio"
            }
          }
        }
      ]
    },
    "Medication.Batch": {
      "allOf": [
        {
          "$ref": "BackboneElement.schema.json/definitions/BackboneElement"
        },
        {
          "description": "This resource is primarily used for the identification and definition of a medication. It covers the ingredients and the packaging for a medication.",
          "properties": {
            "lotNumber": {
              "description": "The assigned lot number of a batch of the specified product.",
              "type": "string"
            },
            "lotNumber_": {
              "description": "Extensions for lotNumber",
              "$ref": "Element.schema.json/definitions/Element"
            },
            "expirationDate": {
              "description": "When this specific batch of product will expire.",
              "type": "string",
              "pattern": "-?[0-9]{4}(-(0[1-9]|1[0-2])(-(0[0-9]|[1-2][0-9]|3[0-1])(T([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\\.[0-9]+)?(Z|(\\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00)))?)?)?"
            },
            "expirationDate_": {
              "description": "Extensions for expirationDate",
              "$ref": "Element.schema.json/definitions/Element"
            }
          }
        }
      ]
    },
    "Medication.Package": {
      "allOf": [
        {
          "$ref": "BackboneElement.schema.json/definitions/BackboneElement"
        },
        {
          "description": "This resource is primarily used for the identification and definition of a medication. It covers the ingredients and the packaging for a medication.",
          "properties": {
            "container": {
              "description": "The kind of container that this package comes as.",
              "$ref": "CodeableConcept.schema.json/definitions/CodeableConcept"
            },
            "content": {
              "description": "A set of components that go to make up the described item.",
              "type": "array",
              "items": {
                "$ref": "#/definitions/Medication.Content"
              }
            }
          }
        }
      ]
    },
    "Medication.Content": {
      "allOf": [
        {
          "$ref": "BackboneElement.schema.json/definitions/BackboneElement"
        },
        {
          "description": "This resource is primarily used for the identification and definition of a medication. It covers the ingredients and the packaging for a medication.",
          "properties": {
            "itemCodeableConcept": {
              "description": "Identifies one of the items in the package.",
              "$ref": "CodeableConcept.schema.json/definitions/CodeableConcept"
            },
            "itemReference": {
              "description": "Identifies one of the items in the package.",
              "$ref": "Reference.schema.json/definitions/Reference"
            },
            "amount": {
              "description": "The amount of the product that is in the package.",
              "$ref": "SimpleQuantity.schema.json/definitions/SimpleQuantity"
            }
          }
        }
      ]
    }
  }
}