<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:clinicaldata="Clinicaldata" xmlns:common="Common" xmlns:ht="HTDataTypes" xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning" targetNamespace="Clinicaldata" elementFormDefault="unqualified" attributeFormDefault="unqualified" vc:minVersion="1.1">
	<xsd:import namespace="Common" schemaLocation="../Common.xsd"/>
	<xsd:import namespace="HTDataTypes" schemaLocation="../HTDataTypes.xsd"/>
	<!-- ================================================== -->
	<!-- =====  Element Declarations  -->
	<!-- ================================================== -->
	<xsd:element name="ClinicalData" type="clinicaldata:ClinicalData"/>
	<!-- ================================================== -->
	<!-- =====  Complex Type Definitions  -->
	<!-- ================================================== -->
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<!--  ClinicalData  -->
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<xsd:complexType name="ClinicalData">
		<xsd:sequence>
			<xsd:annotation>
				<xsd:documentation>Write Request</xsd:documentation>
			</xsd:annotation>
			<xsd:element name="templateId" type="xsd:string" fixed="CensusSurveyCreate40024"/>
			<!--xsd:element name="segment" type="ht:HTCensusSegments"/-->
			<xsd:element name="patients" type="clinicaldata:Patients"/>
		</xsd:sequence>
	</xsd:complexType>
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<!--  Patients  -->
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<xsd:complexType name="Patients">
		<xsd:sequence>
			<xsd:element name="segment" type="ht:HTCensusSegments"/>
			<xsd:element name="routingData" type="clinicaldata:RoutingDataType" minOccurs="1" maxOccurs="unbounded"/>
			<xsd:element name="patient" type="common:ClinicalDataPatient" minOccurs="1" maxOccurs="1000">
				<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
				<!--  Add a unique constraint for Modalities,  modality name is unique     -->
				<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
				<!--xsd:unique name="cencusModalityNameKey">
					<xsd:selector xpath="censusSurveyResponse/modalities/modality"/>
					<xsd:field xpath="modalityName"/>
					<xsd:selector xpath="censusSurveyResponse"/>
					<xsd:field xpath="measurement"/>
				</xsd:unique-->
			</xsd:element>
		</xsd:sequence>
	</xsd:complexType>
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<!-- elements data in RoutingDataType is used to send census acknowledgements at the end of the                           -->
    <!-- census transformation process                                                                                                                        -->
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<xsd:complexType name="RoutingDataType">
		<xsd:sequence>
			<xsd:element name="sendingApplication" type="xsd:string"/>
			<xsd:element name="stationNumber" type="xsd:string"/>
			<xsd:element name="sendingFacility" type="xsd:string"/>
			<xsd:element name="receivingApplication" type="xsd:string"/>
			<xsd:element name="receivingFacility" type="xsd:string"/>
		</xsd:sequence>
	</xsd:complexType>
</xsd:schema>
