<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:vhimversion="Vhimversion" xmlns:filter="Filter"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" targetNamespace="Filter"
	xsi:schemaLocation="Filter C:\data\hdr\cdsn\main\modules\redrock-core\src\main\java\gov\va\med\cds\filter\schema\Filter100.xsd">
	<!--imports for all non target name spaces -->
	<!-- global definition -->
	<xs:element name="filter">
		<xs:complexType>
			<xs:sequence>
				<xs:element name="filterId" type="filter:FilterId" fixed="RX_SINGLE_PATIENT_ALL_DATA_FILTER" />
				<xs:element name="clientName" minOccurs="0">
					<xs:simpleType>
						<xs:restriction base="xs:string">
							<xs:maxLength value="100" />
						</xs:restriction>
					</xs:simpleType>
				</xs:element>
				<xs:element name="clientRequestInitiationTime" type="filter:DateTimeParameter" minOccurs="0" />
				<!-- Single patient -->
				<xs:element name="patients" type="filter:patient" />
				<!-- Single entryPointFilter for OutpatientMedicationPromise ONLY -->
				<xs:element name="entryPointFilter" type="filter:EntryFilter" />
			</xs:sequence>
			<xs:attribute name="vhimVersion" type="xs:string" use="required" fixed="Vhim_4_00" />
		</xs:complexType>
	</xs:element>
	<xs:complexType name="patient">
		<xs:choice>
			<xs:element name="resolvedIdentifiers" type="filter:PersonIdentifier" maxOccurs="unbounded" />
			<xs:sequence>
				<xs:element name="NationalId" type="xs:string" />
				<xs:element name="excludeIdentifiers" type="filter:ExcludeIdentifier" minOccurs="0" maxOccurs="unbounded" />
			</xs:sequence>
		</xs:choice>
	</xs:complexType>
	<xs:complexType name="PersonIdentifier">
		<xs:sequence>
			<xs:element name="assigningAuthority" type="xs:string" />
			<xs:element name="assigningFacility" type="xs:string" />
			<xs:element name="identity" type="xs:string" />
		</xs:sequence>
	</xs:complexType>
	<xs:complexType name="ExcludeIdentifier">
		<xs:sequence>
			<xs:element name="assigningAuthority" type="xs:string" />
			<xs:choice minOccurs="0">
				<xs:sequence>
					<xs:element name="assigningFacility" type="xs:string" />
					<xs:choice minOccurs="0">
						<xs:element name="identity" type="xs:string" />
					</xs:choice>
				</xs:sequence>
			</xs:choice>
		</xs:sequence>
	</xs:complexType>
	<!-- OutpatientMedicationPromise entry filter only -->
	<xs:complexType name="EntryFilter">
		<xs:sequence>
			<xs:element name="domainEntryPoint" type="filter:DomainEntryPoint" />
			<xs:element name="startDate" type="filter:DateParameter" minOccurs="0" />
			<xs:element name="endDate" type="filter:DateParameter" minOccurs="0" />
			<xs:element name="xpathQuery" type="filter:XpathQuery" minOccurs="0" />
			<xs:element name="otherQueryParameters" type="filter:AdditionalParameters" minOccurs="0" />
			<xs:element name="queryTimeoutSeconds" type="xs:string" minOccurs="0" />
		</xs:sequence>
		<xs:attribute name="queryName" type="xs:ID" use="required" />
	</xs:complexType>

	<xs:complexType name="AdditionalParameters">
		<xs:sequence>
			<xs:element name="medication" type="filter:MedicationValue" minOccurs="0" />
			<xs:element name="status" type="xs:string" minOccurs="0" />
			<xs:element name="source" type="xs:string" minOccurs="0" />
			<xs:element name="practitionerGivenName" type="xs:string" minOccurs="0" />
			<xs:element name="practitionerFamilyName" type="xs:string" minOccurs="0" />
		</xs:sequence>
	</xs:complexType>
	<xs:simpleType name="MedicationValue">
		<xs:restriction base="xs:string">
			<xs:minLength value="1" />
		</xs:restriction>
	</xs:simpleType>
	<xs:complexType name="XpathQuery">
		<xs:sequence>
			<xs:element name="xpath" type="filter:XPath" maxOccurs="unbounded" />
		</xs:sequence>
	</xs:complexType>
	<xs:simpleType name="DateParameter">
		<xs:restriction base="xs:date" />
	</xs:simpleType>
	<xs:simpleType name="XPath">
		<xs:restriction base="xs:string" />
	</xs:simpleType>
	<xs:simpleType name="FilterId">
		<xs:restriction base="xs:string" />
	</xs:simpleType>
	<xs:simpleType name="DomainEntryPoint">
		<xs:restriction base="xs:string">
			<xs:enumeration value="OutpatientMedicationPromise" />
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="DateTimeParameter">
		<xs:restriction base="xs:dateTime" />
	</xs:simpleType>
</xs:schema>