{
  "resourceType": "StructureDefinition",
  "id": "il-core-medication-dispense",
  "extension": [
    {
      "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-standards-status",
      "valueCode": "trial-use"
    },
    {
      "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-fmm",
      "valueInteger": 1
    }
  ],
  "url": "http://fhir.health.gov.il/StructureDefinition/il-core-medication-dispense",
  "version": "0.21.0",
  "name": "ILCoreMedicationDispense",
  "title": "ILCore MedicationDispense Profile",
  "status": "active",
  "date": "2026-03-23",
  "publisher": "Israel Core Team",
  "contact": [
    {
      "telecom": [
        {
          "system": "email",
          "value": "tal.primak@moh.gov.il"
        }
      ]
    }
  ],
  "description": "Israel Core proposed constraints and extensions on the MedicationDispense Resource",
  "fhirVersion": "4.0.1",
  "kind": "resource",
  "abstract": false,
  "type": "MedicationDispense",
  "baseDefinition": "http://hl7.org/fhir/StructureDefinition/MedicationDispense",
  "derivation": "constraint",
  "differential": {
    "element": [
      {
        "id": "MedicationDispense",
        "path": "MedicationDispense",
        "short": "ILCore MedicationDispense Profile",
        "definition": "Israel Core proposed constraints and extensions on the MedicationDispense resource profile.",
        "constraint": [
          {
            "key": "il-medicationdispense-whenhandedover",
            "severity": "error",
            "human": "whenHandedOver SHALL be present if the status is 'completed'",
            "expression": "status='completed' implies whenHandedOver.exists()",
            "source": "http://fhir.health.gov.il/StructureDefinition/il-core-medication-dispense"
          }
        ]
      },
      {
        "id": "MedicationDispense.extension",
        "path": "MedicationDispense.extension",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "url"
            }
          ],
          "ordered": false,
          "rules": "open"
        }
      },
      {
        "id": "MedicationDispense.extension:recorded",
        "path": "MedicationDispense.extension",
        "sliceName": "recorded",
        "short": "Ext: Recorded Time",
        "definition": "Extension: The time in which an event was recorded",
        "min": 0,
        "max": "1",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "http://fhir.health.gov.il/StructureDefinition/ext-medication-recorded-time"
            ]
          }
        ]
      },
      {
        "id": "MedicationDispense.identifier",
        "path": "MedicationDispense.identifier",
        "type": [
          {
            "code": "Identifier",
            "profile": [
              "http://fhir.health.gov.il/StructureDefinition/il-core-identifier"
            ]
          }
        ]
      },
      {
        "id": "MedicationDispense.partOf",
        "path": "MedicationDispense.partOf",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://fhir.health.gov.il/StructureDefinition/il-core-procedure"
            ]
          }
        ]
      },
      {
        "id": "MedicationDispense.status",
        "path": "MedicationDispense.status",
        "short": "ILCore MedicationDispense Status",
        "definition": "ILCore MedicationDispense Status",
        "mustSupport": true
      },
      {
        "id": "MedicationDispense.category",
        "path": "MedicationDispense.category",
        "binding": {
          "strength": "extensible",
          "valueSet": "http://fhir.health.gov.il/ValueSet/il-core-medication-dispense-category"
        }
      },
      {
        "id": "MedicationDispense.medication[x]",
        "path": "MedicationDispense.medication[x]",
        "slicing": {
          "discriminator": [
            {
              "type": "type",
              "path": "$this"
            }
          ],
          "ordered": false,
          "rules": "open"
        },
        "mustSupport": true,
        "binding": {
          "strength": "required",
          "valueSet": "http://fhir.health.gov.il/ValueSet/il-core-medication-code"
        }
      },
      {
        "id": "MedicationDispense.medication[x]:medicationReference",
        "path": "MedicationDispense.medication[x]",
        "sliceName": "medicationReference",
        "min": 0,
        "max": "1",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://fhir.health.gov.il/StructureDefinition/il-core-medication"
            ]
          }
        ]
      },
      {
        "id": "MedicationDispense.subject",
        "path": "MedicationDispense.subject",
        "min": 1,
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://fhir.health.gov.il/StructureDefinition/il-core-patient",
              "http://fhir.health.gov.il/StructureDefinition/il-core-group"
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "MedicationDispense.context",
        "path": "MedicationDispense.context",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://fhir.health.gov.il/StructureDefinition/il-core-encounter",
              "http://fhir.health.gov.il/StructureDefinition/il-core-episode-of-care"
            ]
          }
        ]
      },
      {
        "id": "MedicationDispense.performer",
        "path": "MedicationDispense.performer",
        "mustSupport": true
      },
      {
        "id": "MedicationDispense.performer.actor",
        "path": "MedicationDispense.performer.actor",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://fhir.health.gov.il/StructureDefinition/il-core-practitioner",
              "http://fhir.health.gov.il/StructureDefinition/il-core-practitioner-role",
              "http://fhir.health.gov.il/StructureDefinition/il-core-organization",
              "http://fhir.health.gov.il/StructureDefinition/il-core-patient",
              "http://fhir.health.gov.il/StructureDefinition/il-core-device",
              "http://fhir.health.gov.il/StructureDefinition/il-core-related-person"
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "MedicationDispense.location",
        "path": "MedicationDispense.location",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://fhir.health.gov.il/StructureDefinition/il-core-location"
            ]
          }
        ]
      },
      {
        "id": "MedicationDispense.authorizingPrescription",
        "path": "MedicationDispense.authorizingPrescription",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://fhir.health.gov.il/StructureDefinition/il-core-medication-request"
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "MedicationDispense.type",
        "path": "MedicationDispense.type",
        "mustSupport": true,
        "binding": {
          "strength": "extensible",
          "valueSet": "http://terminology.hl7.org/ValueSet/v3-ActPharmacySupplyType"
        }
      },
      {
        "id": "MedicationDispense.quantity",
        "path": "MedicationDispense.quantity",
        "mustSupport": true,
        "binding": {
          "strength": "extensible",
          "valueSet": "http://fhir.health.gov.il/ValueSet/il-core-common-units-of-measure",
          "extension": [
            {
              "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-maxValueSet",
              "valueCanonical": "http://fhir.health.gov.il/ValueSet/il-core-units-of-measure"
            }
          ]
        }
      },
      {
        "id": "MedicationDispense.whenHandedOver",
        "path": "MedicationDispense.whenHandedOver",
        "mustSupport": true
      },
      {
        "id": "MedicationDispense.destination",
        "path": "MedicationDispense.destination",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://fhir.health.gov.il/StructureDefinition/il-core-location"
            ]
          }
        ]
      },
      {
        "id": "MedicationDispense.receiver",
        "path": "MedicationDispense.receiver",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://fhir.health.gov.il/StructureDefinition/il-core-practitioner",
              "http://fhir.health.gov.il/StructureDefinition/il-core-patient"
            ]
          }
        ]
      },
      {
        "id": "MedicationDispense.dosageInstruction",
        "path": "MedicationDispense.dosageInstruction",
        "type": [
          {
            "code": "Dosage",
            "profile": [
              "http://fhir.health.gov.il/StructureDefinition/il-core-dosage"
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "MedicationDispense.substitution.responsibleParty",
        "path": "MedicationDispense.substitution.responsibleParty",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://fhir.health.gov.il/StructureDefinition/il-core-practitioner",
              "http://fhir.health.gov.il/StructureDefinition/il-core-practitioner-role"
            ]
          }
        ]
      }
    ]
  }
}