{
  "resourceType": "StructureDefinition",
  "id": "EPMedDispense-aa94b2a8-85f6-4239-a94c-bb18092ef09e",
  "extension": [
    {
      "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-category",
      "valueString": "Base.Management"
    },
    {
      "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-security-category",
      "valueCode": "patient"
    }
  ],
  "url": "https://www.esante.lu/fhir-spec/StructureDefinition/EPMedDispense",
  "version": "0.1.0",
  "name": "EPMedDispense",
  "status": "draft",
  "fhirVersion": "4.0.1",
  "mapping": [
    {
      "identity": "workflow",
      "uri": "http://hl7.org/fhir/workflow",
      "name": "Workflow Pattern"
    },
    {
      "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": "Encounter",
  "baseDefinition": "http://hl7.org/fhir/StructureDefinition/Encounter",
  "derivation": "constraint",
  "differential": {
    "element": [
      {
        "id": "Encounter.id",
        "path": "Encounter.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": "Encounter.meta",
        "path": "Encounter.meta",
        "min": 1
      },
      {
        "id": "Encounter.meta.id",
        "path": "Encounter.meta.id",
        "max": "0"
      },
      {
        "id": "Encounter.meta.versionId",
        "path": "Encounter.meta.versionId",
        "max": "0"
      },
      {
        "id": "Encounter.meta.lastUpdated",
        "path": "Encounter.meta.lastUpdated",
        "max": "0"
      },
      {
        "id": "Encounter.meta.source",
        "path": "Encounter.meta.source",
        "max": "0"
      },
      {
        "id": "Encounter.meta.profile",
        "path": "Encounter.meta.profile",
        "min": 1,
        "max": "1",
        "fixedCanonical": "https://www.esante.lu/fhir-spec/StructureDefinition/EPMedDispense"
      },
      {
        "id": "Encounter.meta.security",
        "path": "Encounter.meta.security",
        "max": "0"
      },
      {
        "id": "Encounter.meta.tag",
        "path": "Encounter.meta.tag",
        "max": "0"
      },
      {
        "id": "Encounter.implicitRules",
        "path": "Encounter.implicitRules",
        "max": "0"
      },
      {
        "id": "Encounter.language",
        "path": "Encounter.language",
        "max": "0"
      },
      {
        "id": "Encounter.text",
        "path": "Encounter.text",
        "max": "0"
      },
      {
        "id": "Encounter.contained",
        "path": "Encounter.contained",
        "max": "0"
      },
      {
        "id": "Encounter.extension",
        "path": "Encounter.extension",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "url"
            }
          ],
          "rules": "closed"
        },
        "min": 1
      },
      {
        "id": "Encounter.extension:trigger",
        "path": "Encounter.extension",
        "sliceName": "trigger",
        "min": 1,
        "max": "1",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "https://www.esante.lu/fhir-spec/StructureDefinition/EPTriggerExt"
            ]
          }
        ]
      },
      {
        "id": "Encounter.identifier",
        "path": "Encounter.identifier",
        "short": "An identifier for the dispense",
        "min": 1,
        "max": "1",
        "type": [
          {
            "code": "Identifier",
            "profile": [
              "https://www.esante.lu/fhir-spec/StructureDefinition/EPSimpleIdentifier"
            ]
          }
        ]
      },
      {
        "id": "Encounter.status",
        "path": "Encounter.status",
        "definition": "Constant",
        "fixedCode": "finished"
      },
      {
        "id": "Encounter.statusHistory",
        "path": "Encounter.statusHistory",
        "max": "0"
      },
      {
        "id": "Encounter.class",
        "path": "Encounter.class",
        "definition": "Constant",
        "fixedCoding": {
          "code": "AMB",
          "system": "http://terminology.hl7.org/CodeSystem/v3-ActCode"
        }
      },
      {
        "id": "Encounter.class.id",
        "path": "Encounter.class.id",
        "max": "0"
      },
      {
        "id": "Encounter.class.system",
        "path": "Encounter.class.system",
        "min": 1
      },
      {
        "id": "Encounter.class.version",
        "path": "Encounter.class.version",
        "max": "0"
      },
      {
        "id": "Encounter.class.code",
        "path": "Encounter.class.code",
        "min": 1
      },
      {
        "id": "Encounter.class.display",
        "path": "Encounter.class.display",
        "max": "0"
      },
      {
        "id": "Encounter.class.userSelected",
        "path": "Encounter.class.userSelected",
        "max": "0"
      },
      {
        "id": "Encounter.classHistory",
        "path": "Encounter.classHistory",
        "max": "0"
      },
      {
        "id": "Encounter.type",
        "path": "Encounter.type",
        "definition": "Constant",
        "min": 1,
        "max": "1",
        "fixedCodeableConcept": {
          "coding": [
            {
              "code": "MED_DISP",
              "system": "urn:oid:1.3.182.5.56"
            }
          ]
        }
      },
      {
        "id": "Encounter.type.id",
        "path": "Encounter.type.id",
        "max": "0"
      },
      {
        "id": "Encounter.type.coding",
        "path": "Encounter.type.coding",
        "min": 1,
        "max": "1"
      },
      {
        "id": "Encounter.type.coding.system",
        "path": "Encounter.type.coding.system",
        "min": 1
      },
      {
        "id": "Encounter.type.coding.version",
        "path": "Encounter.type.coding.version",
        "max": "0"
      },
      {
        "id": "Encounter.type.coding.code",
        "path": "Encounter.type.coding.code",
        "definition": "A symbol in syntax defined by the system.",
        "min": 1
      },
      {
        "id": "Encounter.type.coding.display",
        "path": "Encounter.type.coding.display",
        "max": "0"
      },
      {
        "id": "Encounter.type.coding.userSelected",
        "path": "Encounter.type.coding.userSelected",
        "max": "0"
      },
      {
        "id": "Encounter.type.text",
        "path": "Encounter.type.text",
        "max": "0"
      },
      {
        "id": "Encounter.serviceType",
        "path": "Encounter.serviceType",
        "max": "0"
      },
      {
        "id": "Encounter.priority",
        "path": "Encounter.priority",
        "max": "0"
      },
      {
        "id": "Encounter.subject",
        "path": "Encounter.subject",
        "short": "The patient",
        "min": 1,
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://www.esante.lu/fhir-spec/StructureDefinition/EPPatient"
            ],
            "aggregation": [
              "referenced"
            ]
          }
        ]
      },
      {
        "id": "Encounter.subject.id",
        "path": "Encounter.subject.id",
        "max": "0"
      },
      {
        "id": "Encounter.subject.reference",
        "path": "Encounter.subject.reference",
        "short": "The patient refered by its matricule",
        "min": 1,
        "example": [
          {
            "label": "Example",
            "valueString": "Patient?identifier=urn:oid:1.3.182.4.4|1904112000166"
          }
        ],
        "condition": [
          "val-patByMatricule"
        ],
        "constraint": [
          {
            "key": "val-patByMatricule",
            "severity": "error",
            "human": "The Patient SHALL be referenced by its matricule",
            "expression": "startsWith('Patient?identifier=urn:oid:1.3.182.4.4|') and length()=52",
            "source": "https://www.esante.lu/fhir-spec/StructureDefinition/EPMedDispense"
          }
        ]
      },
      {
        "id": "Encounter.subject.type",
        "path": "Encounter.subject.type",
        "max": "0"
      },
      {
        "id": "Encounter.subject.identifier",
        "path": "Encounter.subject.identifier",
        "max": "0"
      },
      {
        "id": "Encounter.subject.display",
        "path": "Encounter.subject.display",
        "max": "0"
      },
      {
        "id": "Encounter.episodeOfCare",
        "path": "Encounter.episodeOfCare",
        "max": "0"
      },
      {
        "id": "Encounter.basedOn",
        "path": "Encounter.basedOn",
        "max": "0"
      },
      {
        "id": "Encounter.participant",
        "path": "Encounter.participant",
        "short": "The pharmacist",
        "min": 1,
        "max": "1"
      },
      {
        "id": "Encounter.participant.id",
        "path": "Encounter.participant.id",
        "max": "0"
      },
      {
        "id": "Encounter.participant.type",
        "path": "Encounter.participant.type",
        "max": "0"
      },
      {
        "id": "Encounter.participant.period",
        "path": "Encounter.participant.period",
        "max": "0"
      },
      {
        "id": "Encounter.participant.individual",
        "path": "Encounter.participant.individual",
        "short": "The pharmacist",
        "min": 1,
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://www.esante.lu/fhir-spec/StructureDefinition/EPPractitioner"
            ],
            "aggregation": [
              "referenced"
            ]
          }
        ]
      },
      {
        "id": "Encounter.participant.individual.id",
        "path": "Encounter.participant.individual.id",
        "max": "0"
      },
      {
        "id": "Encounter.participant.individual.reference",
        "path": "Encounter.participant.individual.reference",
        "short": "The health professional referenced by its eHealthID",
        "min": 1,
        "example": [
          {
            "label": "Example",
            "valueString": "Practitioner?identifier=urn:oid:1.3.182.4.1|2999254871"
          }
        ],
        "constraint": [
          {
            "key": "val-1",
            "severity": "error",
            "human": "A Practitioner SHALL be referenced by its eHealthID",
            "expression": "startsWith('Practitioner?identifier=urn:oid:1.3.182.4.1|2') and length()=54",
            "source": "https://www.esante.lu/fhir-spec/StructureDefinition/EPMedDispense"
          }
        ]
      },
      {
        "id": "Encounter.participant.individual.type",
        "path": "Encounter.participant.individual.type",
        "max": "0"
      },
      {
        "id": "Encounter.participant.individual.identifier",
        "path": "Encounter.participant.individual.identifier",
        "max": "0"
      },
      {
        "id": "Encounter.participant.individual.display",
        "path": "Encounter.participant.individual.display",
        "max": "0"
      },
      {
        "id": "Encounter.appointment",
        "path": "Encounter.appointment",
        "max": "0"
      },
      {
        "id": "Encounter.period",
        "path": "Encounter.period",
        "short": "Dispensation date",
        "definition": "Shall be the same",
        "min": 1,
        "condition": [
          "val-StartEnd"
        ],
        "constraint": [
          {
            "key": "val-StartEnd",
            "severity": "error",
            "human": "start and end SHALL be the same",
            "expression": "start=end",
            "source": "https://www.esante.lu/fhir-spec/StructureDefinition/EPMedDispense"
          }
        ]
      },
      {
        "id": "Encounter.period.id",
        "path": "Encounter.period.id",
        "max": "0"
      },
      {
        "id": "Encounter.period.start",
        "path": "Encounter.period.start",
        "short": "Dispensation date",
        "min": 1
      },
      {
        "id": "Encounter.period.end",
        "path": "Encounter.period.end",
        "short": "Dispensation date",
        "min": 1
      },
      {
        "id": "Encounter.length",
        "path": "Encounter.length",
        "max": "0"
      },
      {
        "id": "Encounter.reasonCode",
        "path": "Encounter.reasonCode",
        "max": "0"
      },
      {
        "id": "Encounter.reasonReference",
        "path": "Encounter.reasonReference",
        "max": "0"
      },
      {
        "id": "Encounter.diagnosis",
        "path": "Encounter.diagnosis",
        "max": "0"
      },
      {
        "id": "Encounter.account",
        "path": "Encounter.account",
        "max": "0"
      },
      {
        "id": "Encounter.hospitalization",
        "path": "Encounter.hospitalization",
        "max": "0"
      },
      {
        "id": "Encounter.location",
        "path": "Encounter.location",
        "max": "0"
      },
      {
        "id": "Encounter.serviceProvider",
        "path": "Encounter.serviceProvider",
        "short": "The pharmacy"
      },
      {
        "id": "Encounter.serviceProvider.id",
        "path": "Encounter.serviceProvider.id",
        "max": "0"
      },
      {
        "id": "Encounter.serviceProvider.reference",
        "path": "Encounter.serviceProvider.reference",
        "short": "The organization referenced by its eHealthID",
        "min": 1,
        "example": [
          {
            "label": "Example",
            "valueString": "Organization?identifier=urn:oid:1.3.182.4.1|1000180763"
          }
        ],
        "condition": [
          "val-orgByEhealthID"
        ],
        "constraint": [
          {
            "key": "val-orgByEhealthID",
            "severity": "error",
            "human": "SHALL reference an organization by its eHealthID",
            "expression": "startsWith('Organization?identifier=urn:oid:1.3.182.4.1|1') and length()=54",
            "source": "https://www.esante.lu/fhir-spec/StructureDefinition/EPMedDispense"
          }
        ]
      },
      {
        "id": "Encounter.serviceProvider.type",
        "path": "Encounter.serviceProvider.type",
        "max": "0"
      },
      {
        "id": "Encounter.serviceProvider.identifier",
        "path": "Encounter.serviceProvider.identifier",
        "max": "0"
      },
      {
        "id": "Encounter.serviceProvider.display",
        "path": "Encounter.serviceProvider.display",
        "max": "0"
      },
      {
        "id": "Encounter.partOf",
        "path": "Encounter.partOf",
        "max": "0"
      }
    ]
  }
}