<?xml version="1.0" encoding="UTF-8"?>
<!-- 
  Copyright (c) 2011-2013, HL7, Inc.
  All rights reserved.
  
  Redistribution and use in source and binary forms, with or without modification, 
  are permitted provided that the following conditions are met:
  
   * Redistributions of source code must retain the above copyright notice, this 
     list of conditions and the following disclaimer.
   * Redistributions in binary form must reproduce the above copyright notice, 
     this list of conditions and the following disclaimer in the documentation 
     and/or other materials provided with the distribution.
   * Neither the name of HL7 nor the names of its contributors may be used to 
     endorse or promote products derived from this software without specific 
     prior written permission.
  
  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
  POSSIBILITY OF SUCH DAMAGE.
  

  Generated on Tue, Sep 30, 2014 18:08+1000 for FHIR v0.0.82 
-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://hl7.org/fhir" xmlns:xhtml="http://www.w3.org/1999/xhtml" targetNamespace="http://hl7.org/fhir" elementFormDefault="qualified" version="0.0.82">
  <xs:include schemaLocation="fhir-base.xsd"/>
  <xs:element name="MedicationDispense" type="MedicationDispense">
    <xs:annotation>
      <xs:documentation>Dispensing a medication to a named patient.  This includes a description of the supply provided and the instructions for administering the medication.</xs:documentation>
    </xs:annotation>
  </xs:element>
  <xs:complexType name="MedicationDispense">
    <xs:annotation>
      <xs:documentation>Dispensing a medication to a named patient.  This includes a description of the supply provided and the instructions for administering the medication.</xs:documentation>
      <xs:documentation>If the element is present, it must have either a @value, an @id, or extensions</xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="Resource">
        <xs:sequence>
          <xs:element name="identifier" minOccurs="0" maxOccurs="1" type="Identifier">
            <xs:annotation>
              <xs:documentation>Identifier assigned by the dispensing facility - this is an identifier assigned outside FHIR.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:element name="status" minOccurs="0" maxOccurs="1" type="MedicationDispenseStatus">
            <xs:annotation>
              <xs:documentation>A code specifying the state of the set of dispense events.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:element name="patient" minOccurs="0" maxOccurs="1" type="ResourceReference">
            <xs:annotation>
              <xs:documentation>A link to a resource representing the person to whom the medication will be given.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:element name="dispenser" minOccurs="0" maxOccurs="1" type="ResourceReference">
            <xs:annotation>
              <xs:documentation>The individual responsible for dispensing the medication.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:element name="authorizingPrescription" minOccurs="0" maxOccurs="unbounded" type="ResourceReference">
            <xs:annotation>
              <xs:documentation>Indicates the medication order that is being dispensed against.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:element name="dispense" type="MedicationDispense.Dispense" minOccurs="0" maxOccurs="unbounded">
            <xs:annotation>
              <xs:documentation>Indicates the details of the dispense event such as the days supply and quantity of medication dispensed.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:element name="substitution" type="MedicationDispense.Substitution" minOccurs="0" maxOccurs="1">
            <xs:annotation>
              <xs:documentation>Indicates whether or not substitution was made as part of the dispense.  In some cases substitution will be expected but doesn't happen, in other cases substitution is not expected but does happen.  This block explains what substitition did or did not happen and why.</xs:documentation>
           </xs:annotation>
          </xs:element>
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="MedicationDispense.Dispense">
    <xs:annotation>
      <xs:documentation>Dispensing a medication to a named patient.  This includes a description of the supply provided and the instructions for administering the medication.</xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="BackboneElement">
        <xs:sequence>
          <xs:element name="identifier" minOccurs="0" maxOccurs="1" type="Identifier">
            <xs:annotation>
              <xs:documentation>Identifier assigned by the dispensing facility.   This is an identifier assigned outside FHIR.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:element name="status" minOccurs="0" maxOccurs="1" type="MedicationDispenseStatus">
            <xs:annotation>
              <xs:documentation>A code specifying the state of the dispense event.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:element name="type" minOccurs="0" maxOccurs="1" type="CodeableConcept">
            <xs:annotation>
              <xs:documentation>Indicates the type of dispensing event that is performed. Examples include: Trial Fill, Completion of Trial, Partial Fill, Emergency Fill, Samples, etc.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:element name="quantity" minOccurs="0" maxOccurs="1" type="Quantity">
            <xs:annotation>
              <xs:documentation>The amount of medication that has been dispensed. Includes unit of measure.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:element name="medication" minOccurs="0" maxOccurs="1" type="ResourceReference">
            <xs:annotation>
              <xs:documentation>Identifies the medication being administered. This is either a link to a resource representing the details of the medication or a simple attribute carrying a code that identifies the medication from a known list of medications.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:element name="whenPrepared" minOccurs="0" maxOccurs="1" type="dateTime">
            <xs:annotation>
              <xs:documentation>The time when the dispensed product was packaged and reviewed.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:element name="whenHandedOver" minOccurs="0" maxOccurs="1" type="dateTime">
            <xs:annotation>
              <xs:documentation>The time the dispensed product was provided to the patient or their representative.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:element name="destination" minOccurs="0" maxOccurs="1" type="ResourceReference">
            <xs:annotation>
              <xs:documentation>Identification of the facility/location where the medication was shipped to, as part of the dispense event.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:element name="receiver" minOccurs="0" maxOccurs="unbounded" type="ResourceReference">
            <xs:annotation>
              <xs:documentation>Identifies the person who picked up the medication.  This will usually be a patient or their carer, but some cases exist where it can be a healthcare professional.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:element name="dosage" type="MedicationDispense.Dosage" minOccurs="0" maxOccurs="unbounded">
            <xs:annotation>
              <xs:documentation>Indicates how the medication is to be used by the patient.</xs:documentation>
           </xs:annotation>
          </xs:element>
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="MedicationDispense.Dosage">
    <xs:annotation>
      <xs:documentation>Dispensing a medication to a named patient.  This includes a description of the supply provided and the instructions for administering the medication.</xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="BackboneElement">
        <xs:sequence>
          <xs:element name="additionalInstructions" minOccurs="0" maxOccurs="1" type="CodeableConcept">
            <xs:annotation>
              <xs:documentation>Additional instructions such as &quot;Swallow with plenty of water&quot; which may or may not be coded.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:choice minOccurs="0" maxOccurs="1" >
            <xs:annotation>
              <xs:documentation>The timing schedule for giving the medication to the patient.  The Schedule data type allows many different expressions, for example.  &quot;Every  8 hours&quot;; &quot;Three times a day&quot;; &quot;1/2 an hour before breakfast for 10 days from 23-Dec 2011:&quot;;  &quot;15 Oct 2013, 17 Oct 2013 and 1 Nov 2013&quot;.</xs:documentation>
            </xs:annotation>
            <xs:element name="timingDateTime" type="dateTime"/>
            <xs:element name="timingPeriod" type="Period"/>
            <xs:element name="timingSchedule" type="Schedule"/>
          </xs:choice>
          <xs:choice minOccurs="0" maxOccurs="1" >
            <xs:annotation>
              <xs:documentation>If set to true or if specified as a CodeableConcept, indicates that the medication is only taken when needed within the specified schedule rather than at every scheduled dose.  If a CodeableConcept is present, it indicates the pre-condition for taking the Medication.</xs:documentation>
            </xs:annotation>
            <xs:element name="asNeededBoolean" type="boolean"/>
            <xs:element name="asNeededCodeableConcept" type="CodeableConcept"/>
          </xs:choice>
          <xs:element name="site" minOccurs="0" maxOccurs="1" type="CodeableConcept">
            <xs:annotation>
              <xs:documentation>A coded specification of the anatomic site where the medication first enters the body.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:element name="route" minOccurs="0" maxOccurs="1" type="CodeableConcept">
            <xs:annotation>
              <xs:documentation>A code specifying the route or physiological path of administration of a therapeutic agent into or onto a subject.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:element name="method" minOccurs="0" maxOccurs="1" type="CodeableConcept">
            <xs:annotation>
              <xs:documentation>A coded value indicating the method by which the medication is introduced into or onto the body. Most commonly used for injections.  Examples:  Slow Push; Deep IV.

Terminologies used often pre-coordinate this term with the route and or form of administration.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:element name="quantity" minOccurs="0" maxOccurs="1" type="Quantity">
            <xs:annotation>
              <xs:documentation>The amount of therapeutic or other substance given at one administration event.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:element name="rate" minOccurs="0" maxOccurs="1" type="Ratio">
            <xs:annotation>
              <xs:documentation>Identifies the speed with which the substance is introduced into the subject. Typically the rate for an infusion. 200ml in 2 hours.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:element name="maxDosePerPeriod" minOccurs="0" maxOccurs="1" type="Ratio">
            <xs:annotation>
              <xs:documentation>The maximum total quantity of a therapeutic substance that may be administered to a subject over the period of time,  e.g. 1000mg in 24 hours.</xs:documentation>
           </xs:annotation>
          </xs:element>
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="MedicationDispense.Substitution">
    <xs:annotation>
      <xs:documentation>Dispensing a medication to a named patient.  This includes a description of the supply provided and the instructions for administering the medication.</xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="BackboneElement">
        <xs:sequence>
          <xs:element name="type" minOccurs="1" maxOccurs="1" type="CodeableConcept">
            <xs:annotation>
              <xs:documentation>A code signifying whether a different drug was dispensed from what was prescribed.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:element name="reason" minOccurs="0" maxOccurs="unbounded" type="CodeableConcept">
            <xs:annotation>
              <xs:documentation>Indicates the reason for the substitution of (or lack of substitution) from what was prescribed.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:element name="responsibleParty" minOccurs="0" maxOccurs="unbounded" type="ResourceReference">
            <xs:annotation>
              <xs:documentation>The person or organization that has primary responsibility for the substitution.</xs:documentation>
           </xs:annotation>
          </xs:element>
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:simpleType name="MedicationDispenseStatus-list">
    <xs:restriction base="xs:string">
      <xs:enumeration value="in progress">
        <xs:annotation>
          <xs:documentation>The dispense has started but has not yet completed.</xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="on hold">
        <xs:annotation>
          <xs:documentation>Actions implied by the administration have been temporarily halted, but are expected to continue later. May also be called &quot;suspended&quot;.</xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="completed">
        <xs:annotation>
          <xs:documentation>All actions that are implied by the dispense have occurred.</xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="entered in error">
        <xs:annotation>
          <xs:documentation>The dispense was entered in error and therefore nullified.</xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="stopped">
        <xs:annotation>
          <xs:documentation>Actions implied by the dispense have been permanently halted, before all of them occurred.</xs:documentation>
        </xs:annotation>
      </xs:enumeration>
    </xs:restriction>
  </xs:simpleType>
  <xs:complexType name="MedicationDispenseStatus">
    <xs:annotation>
      <xs:documentation>A code specifying the state of the dispense event.</xs:documentation>
      <xs:documentation>If the element is present, it must have either a @value, an @id, or extensions</xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="Element">
        <xs:attribute name="value" type="MedicationDispenseStatus-list" use="optional"/>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
</xs:schema>
