<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:vhimversion="Vhimversion" xmlns:filter="Filter" targetNamespace="Filter">
	<!--imports for all non target name spaces -->
	<!-- global definition -->
	<xs:element name="filter" type="filter:Filter"/>
	<!--type definitions -->
	<xs:complexType name="Filter">
		<xs:sequence>
			<xs:element name="filterId" type="filter:FilterId" fixed="RDI_IC_Rx_Filter_1"/>
			<xs:element name="clientName" type="xs:string" minOccurs="0"/>
			<xs:element name="clientRequestInitiationTime" type="filter:DateTimeParameter" minOccurs="0"/>
			<xs:element name="patients" type="filter:patient" maxOccurs="unbounded"/>
			<xs:element name="entryPointFilter" type="filter:EntryFilter" maxOccurs="unbounded"/>
			<xs:element name="correlationFilter" type="filter:CorrelationFilter" minOccurs="0" maxOccurs="unbounded"/>
			<xs:element name="aggregationFilter" type="filter:CorrelationFilter" minOccurs="0" maxOccurs="unbounded"/>
		</xs:sequence>
		<xs:attribute name="vhimVersion" type="xs:string" use="required"/>
	</xs:complexType>
	<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>
	<xs:complexType name="EntityIdentifier">
		<xs:sequence>
			<xs:element name="identity" type="xs:string" minOccurs="0"/>
			<xs:element name="namespaceId" type="xs:string" default="VHA" minOccurs="0"/>
			<xs:element name="universalId" type="xs:string" minOccurs="0"/>
			<xs:element name="universalIdType" type="xs:string" minOccurs="0"/>
		</xs:sequence>
	</xs:complexType>
	<xs:complexType name="EntryFilter">
		<xs:sequence>
			<xs:element name="domainEntryPoint" type="xs:string"/>
			<xs:element name="startDate" type="filter:DateParameter" minOccurs="0"/>
			<xs:element name="endDate" type="filter:DateParameter" minOccurs="0"/>
			<xs:element name="recordIdentifiers" type="filter:EntityIdentifier" minOccurs="0" maxOccurs="unbounded"/>
			<xs:element name="xpathQuery" type="filter:XpathQuery" minOccurs="0"/>
		</xs:sequence>
		<xs:attribute name="queryName" type="xs:ID" use="required"/>
	</xs:complexType>
	<xs:complexType name="CorrelationFilter">
		<xs:sequence>
			<xs:element name="xpathQuery" type="filter:XpathQuery"/>
		</xs:sequence>
		<xs:attribute name="queryName" use="required"/>
	</xs:complexType>
	<xs:complexType name="XpathQuery">
		<xs:sequence>
			<xs:element name="xpath" type="filter:XPath"/>
			<xs:element name="parameter" type="filter:Parameter" minOccurs="0" maxOccurs="unbounded"/>
		</xs:sequence>
	</xs:complexType>
	<xs:simpleType name="DateParameter">
		<xs:restriction base="xs:date"/>
		<!--xs:restriction base="xs:dateTime"/ -->
		<!--xs:restriction base="xs:string"> <xs:pattern value="((19\d{2})|(2\d{3}))((0[1-9])|(1[0-2]))((0[1-9])|([1-2])\d|(3[0-1]))"/> </xs:restriction -->
	</xs:simpleType>
	<xs:complexType name="Parameter">
		<xs:all>
			<xs:element name="value">
				<xs:simpleType>
					<xs:restriction base="xs:string"/>
				</xs:simpleType>
			</xs:element>
		</xs:all>
		<xs:attribute name="name" use="required"/>
		<xs:attribute name="type"/>
	</xs:complexType>
	<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="DateTimeParameter">
		<xs:restriction base="xs:dateTime"/>
	</xs:simpleType>
</xs:schema>