<?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.xs">
	<!--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="DBQ_LIST_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 entryPointFilter for PatientEnteredData 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>
	<!-- ClinicalDocumentEvent 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="xpathFilter" type="filter:XpathFilter" minOccurs="0"/>
			<xs:element name="otherQueryParameters" type="filter:AdditionalParameters" minOccurs="1"/>
		</xs:sequence>
		<xs:attribute name="queryName" type="xs:ID" use="required"/>
		<xs:attribute name="isPatientCentric" type="xs:boolean" use="required" fixed="false"/>
		<xs:attribute name="pageNumber" type="xs:integer" default="0"/>
		<xs:attribute name="pageSize" type="xs:integer" default="500"/>
	</xs:complexType>
	<xs:complexType name="XpathFilter">
		<xs:sequence>
			<xs:element name="expression" type="xs:string"/>
		</xs:sequence>
	</xs:complexType>
	<xs:complexType name="AdditionalParameters">
		<xs:sequence maxOccurs="unbounded">
			<xs:element name="documentType" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
			<xs:choice maxOccurs="unbounded">
				<xs:element name="approvedFlag" type="xs:string"/>
				<xs:element name="claimNumber" type="xs:string"/>
				<xs:element name="facilityIdentifiers" type="filter:HL72OrganizationIdentifier"/>
				<xs:element name="aprvPractitionerIdentifiers" type="filter:HL72PersonIdentifier"/>
				<xs:element name="aprvPractitionerNames" type="filter:HL72PersonName"/>
				<xs:element name="authPractitionerIdentifiers" type="filter:HL72PersonIdentifier"/>
				<xs:element name="authPractitionerNames" type="filter:HL72PersonName"/>
			</xs:choice>
		</xs:sequence>
	</xs:complexType>
	<xs:complexType name="HL72PersonName">
		<xs:annotation>
			<xs:documentation>The name of the person.  Uses the ClinicInHand VIM Model-constrained Person Name data type.</xs:documentation>
		</xs:annotation>
		<xs:all>
			<xs:element name="prefix" type="xs:string" minOccurs="0">
				<xs:annotation>
					<xs:documentation>"A prefix has a strong association to the immediately following name part. A prefix has no implicit trailing white space (it has implicit leading white space though). Note that prefixes can be inverted" (HL7)
A Person Name Prefix is usually an academic or nobility title. An Academic title includes a prefix like "Dr." There are still people with nobility titles (aristocrats). German "von" is generally a nobility title, not a mere voorvoegsel. Others are "Earl of" or "His Majesty King of..." etc. Rarely used nowadays, but some systems do keep track of this.
</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="given" type="xs:string" minOccurs="0">
				<xs:annotation>
					<xs:documentation>"Given name (don't call it "first name" since this given names do not always come first)" (HL7)
</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="middle" type="xs:string" minOccurs="0">
				<xs:annotation>
					<xs:documentation>"A callme name is (usually a given name) that is preferred when a person is directly addressed." (HL7)
</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="family" type="xs:string">
				<xs:annotation>
					<xs:documentation>"Family name, this is the name that links to the genealogy" (HL7)
</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="suffix" type="xs:string" minOccurs="0">
				<xs:annotation>
					<xs:documentation>"A suffix has a strong association to the immediately preceding name part. A prefix has no implicit leading white space (it has implicit trailing white space though). Suffices can not be inverted" (HL7)
</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="title" type="xs:string" minOccurs="0">
				<xs:annotation>
					<xs:documentation>"Indicates that a prefix or a suffix is a title that applies to the whole name, not just the adjacent name part"  (HL7).  This attribute is a SFX that has been qualified with a TITLE.  Used for "MD", "RN", etc.
</xs:documentation>
				</xs:annotation>
			</xs:element>
		</xs:all>
	</xs:complexType>
	<xs:complexType name="HL72PersonIdentifier">
		<xs:all>
			<xs:element name="identity" type="xs:string"/>
			<xs:element name="assigningFacility" type="xs:string"/>
			<xs:element name="assigningAuthority" type="xs:string"/>
		</xs:all>
	</xs:complexType>
	<xs:complexType name="HL72OrganizationIdentifier">
		<xs:sequence>
			<xs:element name="identity" type="xs:string"/>
			<xs:element name="name" type="xs:string"/>
			<xs:element name="assigningAuthority" type="xs:string"/>
		</xs:sequence>
	</xs:complexType>
	<xs:simpleType name="DateParameter">
		<xs:restriction base="xs:date"/>
	</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="QuestionnaireResult"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="DateTimeParameter">
		<xs:restriction base="xs:dateTime"/>
	</xs:simpleType>
</xs:schema>
