<!-- 
  Copyright (c) 2011+, 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 Wed, Apr 19, 2017 07:44+1000 for FHIR v3.0.1 

  Note: the schemas &amp; schematrons do not contain all of the rules about what makes resources
  valid. Implementers will still need to be familiar with the content of the specification and with
  any profiles that apply to the resources in order to make a conformant implementation.

-->
<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="1.0">
  <xs:include schemaLocation="fhir-base.xsd" />
  <xs:element name="MedicationRequest" type="MedicationRequest">
    <xs:annotation>
      <xs:documentation xml:lang="en">An order or request for both supply of the medication and the instructions for administration of the medication to a patient. The resource is called "MedicationRequest" rather than "MedicationPrescription" or "MedicationOrder" to generalize the use across inpatient and outpatient settings, including care plans, etc., and to harmonize with workflow patterns.</xs:documentation>
    </xs:annotation>
  </xs:element>
  <xs:complexType name="MedicationRequest">
    <xs:annotation>
      <xs:documentation xml:lang="en">An order or request for both supply of the medication and the instructions for administration of the medication to a patient. The resource is called "MedicationRequest" rather than "MedicationPrescription" or "MedicationOrder" to generalize the use across inpatient and outpatient settings, including care plans, etc., and to harmonize with workflow patterns.</xs:documentation>
      <xs:documentation xml:lang="en">If the element is present, it must have either a @value, an @id, or extensions</xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="DomainResource">
        <xs:sequence>
          <xs:element name="identifier" minOccurs="0" maxOccurs="unbounded" type="Identifier">
            <xs:annotation>
              <xs:documentation xml:lang="en">This records identifiers associated with this medication request that are defined by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate. For example a re-imbursement system might issue its own id for each prescription that is created.  This is particularly important where FHIR only provides part of an entire workflow process where records must be tracked through an entire system.</xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="definition" minOccurs="0" maxOccurs="unbounded" type="Reference">
            <xs:annotation>
              <xs:documentation xml:lang="en">Protocol or definition followed by this request.</xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="basedOn" minOccurs="0" maxOccurs="unbounded" type="Reference">
            <xs:annotation>
              <xs:documentation xml:lang="en">A plan or request that is fulfilled in whole or in part by this medication request.</xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="groupIdentifier" minOccurs="0" maxOccurs="1" type="Identifier">
            <xs:annotation>
              <xs:documentation xml:lang="en">A shared identifier common to all requests that were authorized more or less simultaneously by a single author, representing the identifier of the requisition or prescription.</xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="status" minOccurs="0" maxOccurs="1" type="MedicationRequestStatus">
            <xs:annotation>
              <xs:documentation xml:lang="en">A code specifying the current state of the order.  Generally this will be active or completed state.</xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="intent" minOccurs="1" maxOccurs="1" type="MedicationRequestIntent">
            <xs:annotation>
              <xs:documentation xml:lang="en">Whether the request is a proposal, plan, or an original order.</xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="category" minOccurs="0" maxOccurs="1" type="CodeableConcept">
            <xs:annotation>
              <xs:documentation xml:lang="en">Indicates the type of medication order and where the medication is expected to be consumed or administered.</xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="priority" minOccurs="0" maxOccurs="1" type="MedicationRequestPriority">
            <xs:annotation>
              <xs:documentation xml:lang="en">Indicates how quickly the Medication Request should be addressed with respect to other requests.</xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:choice minOccurs="1" maxOccurs="1">
            <xs:annotation>
              <xs:documentation xml:lang="en">Identifies the medication being requested. This is a link to a resource that represents the medication which may be the details of the medication or simply an attribute carrying a code that identifies the medication from a known list of medications.</xs:documentation>
            </xs:annotation>
            <xs:element name="medicationCodeableConcept" type="CodeableConcept" />
            <xs:element name="medicationReference" type="Reference" />
          </xs:choice>
          <xs:element name="subject" minOccurs="1" maxOccurs="1" type="Reference">
            <xs:annotation>
              <xs:documentation xml:lang="en">A link to a resource representing the person or set of individuals to whom the medication will be given.</xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="context" minOccurs="0" maxOccurs="1" type="Reference">
            <xs:annotation>
              <xs:documentation xml:lang="en">A link to an encounter, or episode of care, that identifies the particular occurrence or set occurrences of contact between patient and health care provider.</xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="supportingInformation" minOccurs="0" maxOccurs="unbounded" type="Reference">
            <xs:annotation>
              <xs:documentation xml:lang="en">Include additional information (for example, patient height and weight) that supports the ordering of the medication.</xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="authoredOn" minOccurs="0" maxOccurs="1" type="dateTime">
            <xs:annotation>
              <xs:documentation xml:lang="en">The date (and perhaps time) when the prescription was initially written or authored on.</xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="requester" type="MedicationRequest.Requester" minOccurs="0" maxOccurs="1">
            <xs:annotation>
              <xs:documentation xml:lang="en">The individual, organization or device that initiated the request and has responsibility for its activation.</xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="recorder" minOccurs="0" maxOccurs="1" type="Reference">
            <xs:annotation>
              <xs:documentation xml:lang="en">The person who entered the order on behalf of another individual for example in the case of a verbal or a telephone order.</xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="reasonCode" minOccurs="0" maxOccurs="unbounded" type="CodeableConcept">
            <xs:annotation>
              <xs:documentation xml:lang="en">The reason or the indication for ordering the medication.</xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="reasonReference" minOccurs="0" maxOccurs="unbounded" type="Reference">
            <xs:annotation>
              <xs:documentation xml:lang="en">Condition or observation that supports why the medication was ordered.</xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="note" minOccurs="0" maxOccurs="unbounded" type="Annotation">
            <xs:annotation>
              <xs:documentation xml:lang="en">Extra information about the prescription that could not be conveyed by the other attributes.</xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="dosageInstruction" minOccurs="0" maxOccurs="unbounded" type="Dosage">
            <xs:annotation>
              <xs:documentation xml:lang="en">Indicates how the medication is to be used by the patient.</xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="dispenseRequest" type="MedicationRequest.DispenseRequest" minOccurs="0" maxOccurs="1">
            <xs:annotation>
              <xs:documentation xml:lang="en">Indicates the specific details for the dispense or medication supply part of a medication request (also known as a Medication Prescription or Medication Order).  Note that this information is not always sent with the order.  There may be in some settings (e.g. hospitals) institutional or system support for completing the dispense details in the pharmacy department.</xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="substitution" type="MedicationRequest.Substitution" minOccurs="0" maxOccurs="1">
            <xs:annotation>
              <xs:documentation xml:lang="en">Indicates whether or not substitution can or should be part of the dispense. In some cases substitution must happen, in other cases substitution must not happen. This block explains the prescriber's intent. If nothing is specified substitution may be done.</xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="priorPrescription" minOccurs="0" maxOccurs="1" type="Reference">
            <xs:annotation>
              <xs:documentation xml:lang="en">A link to a resource representing an earlier order related order or prescription.</xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="detectedIssue" minOccurs="0" maxOccurs="unbounded" type="Reference">
            <xs:annotation>
              <xs:documentation xml:lang="en">Indicates an actual or potential clinical issue with or between one or more active or proposed clinical actions for a patient; e.g. Drug-drug interaction, duplicate therapy, dosage alert etc.</xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="eventHistory" minOccurs="0" maxOccurs="unbounded" type="Reference">
            <xs:annotation>
              <xs:documentation xml:lang="en">Links to Provenance records for past versions of this resource or fulfilling request or event resources that identify key state transitions or updates that are likely to be relevant to a user looking at the current version of the resource.</xs:documentation>
            </xs:annotation>
          </xs:element>
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="MedicationRequest.Requester">
    <xs:annotation>
      <xs:documentation xml:lang="en">An order or request for both supply of the medication and the instructions for administration of the medication to a patient. The resource is called "MedicationRequest" rather than "MedicationPrescription" or "MedicationOrder" to generalize the use across inpatient and outpatient settings, including care plans, etc., and to harmonize with workflow patterns.</xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="BackboneElement">
        <xs:sequence>
          <xs:element name="agent" minOccurs="1" maxOccurs="1" type="Reference">
            <xs:annotation>
              <xs:documentation xml:lang="en">The healthcare professional responsible for authorizing the initial prescription.</xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="onBehalfOf" minOccurs="0" maxOccurs="1" type="Reference">
            <xs:annotation>
              <xs:documentation xml:lang="en">The organization the device or practitioner was acting on behalf of.</xs:documentation>
            </xs:annotation>
          </xs:element>
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="MedicationRequest.DispenseRequest">
    <xs:annotation>
      <xs:documentation xml:lang="en">An order or request for both supply of the medication and the instructions for administration of the medication to a patient. The resource is called "MedicationRequest" rather than "MedicationPrescription" or "MedicationOrder" to generalize the use across inpatient and outpatient settings, including care plans, etc., and to harmonize with workflow patterns.</xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="BackboneElement">
        <xs:sequence>
          <xs:element name="validityPeriod" minOccurs="0" maxOccurs="1" type="Period">
            <xs:annotation>
              <xs:documentation xml:lang="en">This indicates the validity period of a prescription (stale dating the Prescription).</xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="numberOfRepeatsAllowed" minOccurs="0" maxOccurs="1" type="positiveInt">
            <xs:annotation>
              <xs:documentation xml:lang="en">An integer indicating the number of times, in addition to the original dispense, (aka refills or repeats) that the patient can receive the prescribed medication. Usage Notes: This integer does not include the original order dispense. This means that if an order indicates dispense 30 tablets plus "3 repeats", then the order can be dispensed a total of 4 times and the patient can receive a total of 120 tablets.</xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="quantity" minOccurs="0" maxOccurs="1" type="Quantity">
            <xs:annotation>
              <xs:documentation xml:lang="en">The amount that is to be dispensed for one fill.</xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="expectedSupplyDuration" minOccurs="0" maxOccurs="1" type="Duration">
            <xs:annotation>
              <xs:documentation xml:lang="en">Identifies the period time over which the supplied product is expected to be used, or the length of time the dispense is expected to last.</xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="performer" minOccurs="0" maxOccurs="1" type="Reference">
            <xs:annotation>
              <xs:documentation xml:lang="en">Indicates the intended dispensing Organization specified by the prescriber.</xs:documentation>
            </xs:annotation>
          </xs:element>
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="MedicationRequest.Substitution">
    <xs:annotation>
      <xs:documentation xml:lang="en">An order or request for both supply of the medication and the instructions for administration of the medication to a patient. The resource is called "MedicationRequest" rather than "MedicationPrescription" or "MedicationOrder" to generalize the use across inpatient and outpatient settings, including care plans, etc., and to harmonize with workflow patterns.</xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="BackboneElement">
        <xs:sequence>
          <xs:element name="allowed" minOccurs="1" maxOccurs="1" type="boolean">
            <xs:annotation>
              <xs:documentation xml:lang="en">True if the prescriber allows a different drug to be dispensed from what was prescribed.</xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="reason" minOccurs="0" maxOccurs="1" type="CodeableConcept">
            <xs:annotation>
              <xs:documentation xml:lang="en">Indicates the reason for the substitution, or why substitution must or must not be performed.</xs:documentation>
            </xs:annotation>
          </xs:element>
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:simpleType name="MedicationRequestStatus-list">
    <xs:restriction base="code-primitive">
      <xs:enumeration value="active">
        <xs:annotation>
          <xs:documentation xml:lang="en">Active</xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="on-hold">
        <xs:annotation>
          <xs:documentation xml:lang="en">On Hold</xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="cancelled">
        <xs:annotation>
          <xs:documentation xml:lang="en">Cancelled</xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="completed">
        <xs:annotation>
          <xs:documentation xml:lang="en">Completed</xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="entered-in-error">
        <xs:annotation>
          <xs:documentation xml:lang="en">Entered In Error</xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="stopped">
        <xs:annotation>
          <xs:documentation xml:lang="en">Stopped</xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="draft">
        <xs:annotation>
          <xs:documentation xml:lang="en">Draft</xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="unknown">
        <xs:annotation>
          <xs:documentation xml:lang="en">Unknown</xs:documentation>
        </xs:annotation>
      </xs:enumeration>
    </xs:restriction>
  </xs:simpleType>
  <xs:complexType name="MedicationRequestStatus">
    <xs:annotation>
      <xs:documentation xml:lang="en">A coded concept specifying the state of the prescribing event. Describes the lifecycle of the prescription</xs:documentation>
      <xs:documentation xml:lang="en">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="MedicationRequestStatus-list" use="optional" />
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:simpleType name="MedicationRequestPriority-list">
    <xs:restriction base="code-primitive">
      <xs:enumeration value="routine">
        <xs:annotation>
          <xs:documentation xml:lang="en">Routine</xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="urgent">
        <xs:annotation>
          <xs:documentation xml:lang="en">Urgent</xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="stat">
        <xs:annotation>
          <xs:documentation xml:lang="en">Stat</xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="asap">
        <xs:annotation>
          <xs:documentation xml:lang="en">ASAP</xs:documentation>
        </xs:annotation>
      </xs:enumeration>
    </xs:restriction>
  </xs:simpleType>
  <xs:complexType name="MedicationRequestPriority">
    <xs:annotation>
      <xs:documentation xml:lang="en">Identifies the level of importance to be assigned to actioning the request</xs:documentation>
      <xs:documentation xml:lang="en">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="MedicationRequestPriority-list" use="optional" />
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:simpleType name="MedicationRequestIntent-list">
    <xs:restriction base="code-primitive">
      <xs:enumeration value="proposal">
        <xs:annotation>
          <xs:documentation xml:lang="en">Proposal</xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="plan">
        <xs:annotation>
          <xs:documentation xml:lang="en">Plan</xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="order">
        <xs:annotation>
          <xs:documentation xml:lang="en">Order</xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="instance-order">
        <xs:annotation>
          <xs:documentation xml:lang="en">Instance Order</xs:documentation>
        </xs:annotation>
      </xs:enumeration>
    </xs:restriction>
  </xs:simpleType>
  <xs:complexType name="MedicationRequestIntent">
    <xs:annotation>
      <xs:documentation xml:lang="en">The kind of medication order</xs:documentation>
      <xs:documentation xml:lang="en">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="MedicationRequestIntent-list" use="optional" />
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
</xs:schema>