{
  "resourceType": "StructureDefinition",
  "id": "EPMedicationDispensation-34856b75-10d1-4b4c-9c21-a7573de635c0",
  "extension": [
    {
      "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-category",
      "valueString": "Clinical.Medications"
    },
    {
      "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-security-category",
      "valueCode": "business"
    }
  ],
  "url": "https://www.esante.lu/fhir-spec/StructureDefinition/EPMedicationDispensation",
  "version": "0.1.0",
  "name": "EPMedicationDispensation",
  "status": "draft",
  "fhirVersion": "4.0.1",
  "mapping": [
    {
      "identity": "script10.6",
      "uri": "http://ncpdp.org/SCRIPT10_6",
      "name": "Mapping to NCPDP SCRIPT 10.6"
    },
    {
      "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": "Medication",
  "baseDefinition": "http://hl7.org/fhir/StructureDefinition/Medication",
  "derivation": "constraint",
  "differential": {
    "element": [
      {
        "id": "Medication",
        "path": "Medication",
        "condition": [
          "val-medSameIdentifierDisp"
        ],
        "constraint": [
          {
            "key": "val-medSameIdentifierDisp",
            "severity": "error",
            "human": "The identifier SHALL be the same as the code in the domain of the dispensable medication",
            "expression": "Medication.identifier[0].value=Medication.code.coding.where(system='urn:oid:1.3.182.5.48').code",
            "source": "https://www.esante.lu/fhir-spec/StructureDefinition/EPMedicationDispensation-34856b75-10d1-4b4c-9c21-a7573de635c0"
          }
        ]
      },
      {
        "id": "Medication.id",
        "path": "Medication.id",
        "definition": "The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes.\r\nIs assigned by the server, do not provide a value."
      },
      {
        "id": "Medication.meta",
        "path": "Medication.meta",
        "min": 1
      },
      {
        "id": "Medication.meta.id",
        "path": "Medication.meta.id",
        "max": "0"
      },
      {
        "id": "Medication.meta.versionId",
        "path": "Medication.meta.versionId",
        "max": "0"
      },
      {
        "id": "Medication.meta.lastUpdated",
        "path": "Medication.meta.lastUpdated",
        "max": "0"
      },
      {
        "id": "Medication.meta.source",
        "path": "Medication.meta.source",
        "max": "0"
      },
      {
        "id": "Medication.meta.profile",
        "path": "Medication.meta.profile",
        "min": 1,
        "max": "1",
        "fixedCanonical": "https://www.esante.lu/fhir-spec/StructureDefinition/EPMedicationDispensation"
      },
      {
        "id": "Medication.meta.security",
        "path": "Medication.meta.security",
        "max": "0"
      },
      {
        "id": "Medication.meta.tag",
        "path": "Medication.meta.tag",
        "max": "0"
      },
      {
        "id": "Medication.implicitRules",
        "path": "Medication.implicitRules",
        "max": "0"
      },
      {
        "id": "Medication.language",
        "path": "Medication.language",
        "max": "0"
      },
      {
        "id": "Medication.text",
        "path": "Medication.text",
        "max": "0"
      },
      {
        "id": "Medication.contained",
        "path": "Medication.contained",
        "max": "0"
      },
      {
        "id": "Medication.extension",
        "path": "Medication.extension",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "url"
            }
          ],
          "rules": "closed"
        },
        "min": 1
      },
      {
        "id": "Medication.extension:packaging",
        "path": "Medication.extension",
        "sliceName": "packaging",
        "min": 1,
        "max": "1",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "https://www.esante.lu/fhir-specs/StructureDefinition/EPPackagingExt"
            ]
          }
        ]
      },
      {
        "id": "Medication.identifier",
        "path": "Medication.identifier",
        "short": "Identifier",
        "min": 1,
        "max": "1"
      },
      {
        "id": "Medication.identifier.id",
        "path": "Medication.identifier.id",
        "max": "0"
      },
      {
        "id": "Medication.identifier.use",
        "path": "Medication.identifier.use",
        "max": "0"
      },
      {
        "id": "Medication.identifier.type",
        "path": "Medication.identifier.type",
        "max": "0"
      },
      {
        "id": "Medication.identifier.system",
        "path": "Medication.identifier.system",
        "short": "Fixed value",
        "min": 1,
        "fixedUri": "urn:oid:1.3.182.5.48"
      },
      {
        "id": "Medication.identifier.value",
        "path": "Medication.identifier.value",
        "short": "Identifier",
        "min": 1
      },
      {
        "id": "Medication.identifier.period",
        "path": "Medication.identifier.period",
        "max": "0"
      },
      {
        "id": "Medication.identifier.assigner",
        "path": "Medication.identifier.assigner",
        "max": "0"
      },
      {
        "id": "Medication.code.id",
        "path": "Medication.code.id",
        "max": "0"
      },
      {
        "id": "Medication.code.coding",
        "path": "Medication.code.coding",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "system"
            }
          ],
          "rules": "closed"
        },
        "min": 3
      },
      {
        "id": "Medication.code.coding:atcCode",
        "path": "Medication.code.coding",
        "sliceName": "atcCode",
        "short": "One or several ATC codes",
        "min": 0,
        "max": "*"
      },
      {
        "id": "Medication.code.coding:atcCode.id",
        "path": "Medication.code.coding.id",
        "max": "0"
      },
      {
        "id": "Medication.code.coding:atcCode.system",
        "path": "Medication.code.coding.system",
        "min": 1,
        "fixedUri": "http://www.whocc.no/atc"
      },
      {
        "id": "Medication.code.coding:atcCode.version",
        "path": "Medication.code.coding.version",
        "max": "0"
      },
      {
        "id": "Medication.code.coding:atcCode.code",
        "path": "Medication.code.coding.code",
        "short": "The ATC code",
        "min": 1
      },
      {
        "id": "Medication.code.coding:atcCode.userSelected",
        "path": "Medication.code.coding.userSelected",
        "max": "0"
      },
      {
        "id": "Medication.code.coding:prescCode",
        "path": "Medication.code.coding",
        "sliceName": "prescCode",
        "short": "The code of the prescription medication linked",
        "definition": "The code of the prescription medication linked",
        "min": 1,
        "max": "1"
      },
      {
        "id": "Medication.code.coding:prescCode.id",
        "path": "Medication.code.coding.id",
        "max": "0"
      },
      {
        "id": "Medication.code.coding:prescCode.system",
        "path": "Medication.code.coding.system",
        "min": 1,
        "fixedUri": "urn:oid:1.3.182.5.47"
      },
      {
        "id": "Medication.code.coding:prescCode.version",
        "path": "Medication.code.coding.version",
        "max": "0"
      },
      {
        "id": "Medication.code.coding:prescCode.code",
        "path": "Medication.code.coding.code",
        "short": "The code of the prescription medication linked",
        "min": 1
      },
      {
        "id": "Medication.code.coding:prescCode.userSelected",
        "path": "Medication.code.coding.userSelected",
        "max": "0"
      },
      {
        "id": "Medication.code.coding:numnatCode",
        "path": "Medication.code.coding",
        "sliceName": "numnatCode",
        "short": "The numero national code",
        "min": 1,
        "max": "1"
      },
      {
        "id": "Medication.code.coding:numnatCode.id",
        "path": "Medication.code.coding.id",
        "max": "0"
      },
      {
        "id": "Medication.code.coding:numnatCode.system",
        "path": "Medication.code.coding.system",
        "min": 1,
        "fixedUri": "https://www.esante.lu/fhir-spec/CodeSystem/MedNumNat"
      },
      {
        "id": "Medication.code.coding:numnatCode.version",
        "path": "Medication.code.coding.version",
        "max": "0"
      },
      {
        "id": "Medication.code.coding:numnatCode.code",
        "path": "Medication.code.coding.code",
        "short": "The numero national code",
        "min": 1
      },
      {
        "id": "Medication.code.coding:numnatCode.userSelected",
        "path": "Medication.code.coding.userSelected",
        "max": "0"
      },
      {
        "id": "Medication.code.coding:ammCode",
        "path": "Medication.code.coding",
        "sliceName": "ammCode",
        "short": "The AMM code",
        "definition": "The AMM code",
        "min": 1,
        "max": "1"
      },
      {
        "id": "Medication.code.coding:ammCode.id",
        "path": "Medication.code.coding.id",
        "max": "0"
      },
      {
        "id": "Medication.code.coding:ammCode.system",
        "path": "Medication.code.coding.system",
        "min": 1,
        "fixedUri": "https://www.esante.lu/fhir-spec/CodeSystem/MedAMM"
      },
      {
        "id": "Medication.code.coding:ammCode.version",
        "path": "Medication.code.coding.version",
        "max": "0"
      },
      {
        "id": "Medication.code.coding:ammCode.code",
        "path": "Medication.code.coding.code",
        "short": "The AMM code",
        "min": 1
      },
      {
        "id": "Medication.code.coding:ammCode.userSelected",
        "path": "Medication.code.coding.userSelected",
        "max": "0"
      },
      {
        "id": "Medication.code.text",
        "path": "Medication.code.text",
        "max": "0"
      },
      {
        "id": "Medication.status",
        "path": "Medication.status",
        "short": "active | inactive",
        "min": 1,
        "condition": [
          "val-activeInactive"
        ],
        "constraint": [
          {
            "key": "val-activeInactive",
            "severity": "error",
            "human": "active or inactive",
            "expression": "$this = 'active' or $this='inactive'",
            "source": "https://www.esante.lu/fhir-spec/StructureDefinition/EPMedicationDispensation"
          }
        ]
      },
      {
        "id": "Medication.manufacturer",
        "path": "Medication.manufacturer",
        "max": "0"
      },
      {
        "id": "Medication.form",
        "path": "Medication.form",
        "short": "Pharmaceutical form",
        "min": 1
      },
      {
        "id": "Medication.form.id",
        "path": "Medication.form.id",
        "max": "0"
      },
      {
        "id": "Medication.form.coding",
        "path": "Medication.form.coding",
        "min": 1,
        "max": "1",
        "binding": {
          "strength": "required",
          "valueSet": "https://www.esante.lu/fhir-spec/ValueSet/PharFormCodes"
        }
      },
      {
        "id": "Medication.form.coding.id",
        "path": "Medication.form.coding.id",
        "max": "0"
      },
      {
        "id": "Medication.form.coding.system",
        "path": "Medication.form.coding.system",
        "min": 1
      },
      {
        "id": "Medication.form.coding.version",
        "path": "Medication.form.coding.version",
        "max": "0"
      },
      {
        "id": "Medication.form.coding.code",
        "path": "Medication.form.coding.code",
        "short": "Code of the pharmaceutical form",
        "min": 1
      },
      {
        "id": "Medication.form.coding.userSelected",
        "path": "Medication.form.coding.userSelected",
        "max": "0"
      },
      {
        "id": "Medication.form.text",
        "path": "Medication.form.text",
        "max": "0"
      },
      {
        "id": "Medication.amount",
        "path": "Medication.amount",
        "max": "0"
      },
      {
        "id": "Medication.ingredient",
        "path": "Medication.ingredient",
        "short": "Active ingredients"
      },
      {
        "id": "Medication.ingredient.id",
        "path": "Medication.ingredient.id",
        "max": "0"
      },
      {
        "id": "Medication.ingredient.item[x]",
        "path": "Medication.ingredient.item[x]",
        "short": "The actual ingredient",
        "type": [
          {
            "code": "CodeableConcept"
          }
        ]
      },
      {
        "id": "Medication.ingredient.item[x].id",
        "path": "Medication.ingredient.item[x].id",
        "max": "0"
      },
      {
        "id": "Medication.ingredient.item[x].coding",
        "path": "Medication.ingredient.item[x].coding",
        "min": 1,
        "max": "1",
        "binding": {
          "strength": "required",
          "valueSet": "https://www.esante.lu/fhir-spec/ValueSet/PharActivIngrCodes"
        }
      },
      {
        "id": "Medication.ingredient.item[x].coding.id",
        "path": "Medication.ingredient.item[x].coding.id",
        "max": "0"
      },
      {
        "id": "Medication.ingredient.item[x].coding.system",
        "path": "Medication.ingredient.item[x].coding.system",
        "min": 1
      },
      {
        "id": "Medication.ingredient.item[x].coding.version",
        "path": "Medication.ingredient.item[x].coding.version",
        "max": "0"
      },
      {
        "id": "Medication.ingredient.item[x].coding.code",
        "path": "Medication.ingredient.item[x].coding.code",
        "short": "Code of the ingredient",
        "min": 1
      },
      {
        "id": "Medication.ingredient.item[x].coding.userSelected",
        "path": "Medication.ingredient.item[x].coding.userSelected",
        "max": "0"
      },
      {
        "id": "Medication.ingredient.item[x].text",
        "path": "Medication.ingredient.item[x].text",
        "max": "0"
      },
      {
        "id": "Medication.ingredient.isActive",
        "path": "Medication.ingredient.isActive",
        "max": "0"
      },
      {
        "id": "Medication.ingredient.strength",
        "path": "Medication.ingredient.strength",
        "definition": "Specifies how many (or how much) of the items there are in this Medication.",
        "min": 1
      },
      {
        "id": "Medication.ingredient.strength.id",
        "path": "Medication.ingredient.strength.id",
        "max": "0"
      },
      {
        "id": "Medication.ingredient.strength.numerator",
        "path": "Medication.ingredient.strength.numerator",
        "short": "The strength",
        "definition": "In our case, the strength is fully defined by the numerator element and shall not be understood as a ration.",
        "min": 1
      },
      {
        "id": "Medication.ingredient.strength.numerator.id",
        "path": "Medication.ingredient.strength.numerator.id",
        "max": "0"
      },
      {
        "id": "Medication.ingredient.strength.numerator.value",
        "path": "Medication.ingredient.strength.numerator.value",
        "min": 1
      },
      {
        "id": "Medication.ingredient.strength.numerator.comparator",
        "path": "Medication.ingredient.strength.numerator.comparator",
        "max": "0"
      },
      {
        "id": "Medication.ingredient.strength.numerator.unit",
        "path": "Medication.ingredient.strength.numerator.unit",
        "max": "0"
      },
      {
        "id": "Medication.ingredient.strength.numerator.system",
        "path": "Medication.ingredient.strength.numerator.system",
        "min": 1,
        "fixedUri": "urn:oid:1.3.182.5.55"
      },
      {
        "id": "Medication.ingredient.strength.numerator.code",
        "path": "Medication.ingredient.strength.numerator.code",
        "min": 1,
        "binding": {
          "strength": "required",
          "valueSet": "https://www.esante.lu/fhir-spec/ValueSet/MedUnits"
        }
      },
      {
        "id": "Medication.ingredient.strength.denominator",
        "path": "Medication.ingredient.strength.denominator",
        "definition": "The denominator is always 1 because the quantity in our case is not defined as a ratio",
        "min": 1
      },
      {
        "id": "Medication.ingredient.strength.denominator.id",
        "path": "Medication.ingredient.strength.denominator.id",
        "max": "0"
      },
      {
        "id": "Medication.ingredient.strength.denominator.value",
        "path": "Medication.ingredient.strength.denominator.value",
        "short": "Fixed value",
        "min": 1,
        "fixedDecimal": 1
      },
      {
        "id": "Medication.ingredient.strength.denominator.comparator",
        "path": "Medication.ingredient.strength.denominator.comparator",
        "max": "0"
      },
      {
        "id": "Medication.ingredient.strength.denominator.unit",
        "path": "Medication.ingredient.strength.denominator.unit",
        "max": "0"
      },
      {
        "id": "Medication.ingredient.strength.denominator.system",
        "path": "Medication.ingredient.strength.denominator.system",
        "max": "0"
      },
      {
        "id": "Medication.ingredient.strength.denominator.code",
        "path": "Medication.ingredient.strength.denominator.code",
        "max": "0"
      },
      {
        "id": "Medication.batch",
        "path": "Medication.batch",
        "max": "0"
      }
    ]
  }
}