<?xml version="1.0" standalone="yes"?>
<xs:schema xmlns:sc="SurveysCommon" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:basedatatypes="Basedatatypes" xmlns:common="Common" targetNamespace="SurveysCommon" elementFormDefault="unqualified" attributeFormDefault="unqualified">
	<xs:import namespace="Basedatatypes" schemaLocation="Basedatatypes.xsd"/>
	<xs:import namespace="Common" schemaLocation="Common.xsd"/>
	<!-- ================================================== -->
	<!-- =====  Complex Type Definitions  -->
	<!-- ================================================== -->
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<!--  SurveyResponse  -->
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<xs:complexType name="SurveyResponse">
		<xs:sequence>
			<xs:element name="xmlVersion" type="xs:string" minOccurs="0"/>
			<xs:element name="survey" type="sc:Survey" minOccurs="0"/>
			<xs:element name="surveyPatient" type="sc:SurveyPatient"/>
			<xs:element name="enrollmentDate" type="xs:date" minOccurs="0"/>
			<xs:element name="disenrollmentDate" type="xs:date" nillable="true" minOccurs="0"/>
			<xs:element name="activationDate" type="xs:date" nillable="true" minOccurs="0"/>
			<xs:element name="inactivationDate" type="xs:date" nillable="true" minOccurs="0"/>
			<xs:element name="facility" type="sc:Facility"/>
			<xs:element name="vendor" type="sc:Vendor"/>
			<xs:element name="careCoordinator" type="sc:CareCoordinator" minOccurs="0"/>
			<xs:element name="scheduledDate" type="xs:date" nillable="true" minOccurs="0"/>
			<xs:element name="completedDate" type="xs:dateTime" minOccurs="0"/>
			<xs:element name="currentDialogueName" type="xs:string" minOccurs="0"/>
			<xs:element name="programName" type="xs:string" minOccurs="0"/>
			<xs:element name="deviceName" type="xs:string" minOccurs="0"/>
			<xs:element name="responseStatus" type="xs:string" minOccurs="0"/>
			<xs:element name="recordSource" type="basedatatypes:HL72FacilityIdentifier"/>
			<xs:element name="recordUpdateTime" type="basedatatypes:PointInTime"/>
			<xs:choice>
				<xs:element name="surveyQuestionsAndAnswers" type="sc:SurveyQuestionsAndAnswers" minOccurs="0"/>
				<xs:element name="surveyQuestionsAndAnswersWithScores" type="sc:SurveyQuestionsAndAnswersWithScores" minOccurs="0"/>
			</xs:choice>
		</xs:sequence>
	</xs:complexType>
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<!--  SurveyType  -->
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<xs:complexType name="Survey">
		<xs:sequence>
			<xs:element name="title" type="sc:NonEmptyString"/>
			<xs:element name="version" type="xs:string"/>
		</xs:sequence>
	</xs:complexType>
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<!--  SurveyPersonName  -->
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<xs:complexType name="SurveyPersonName">
		<xs:complexContent>
			<xs:restriction base="basedatatypes:HL72PersonName">
				<xs:sequence>
					<xs:element name="given" type="xs:string" minOccurs="0"/>
					<xs:element name="middle" type="xs:string" minOccurs="0"/>
					<xs:element name="family" type="xs:string"/>
				</xs:sequence>
			</xs:restriction>
		</xs:complexContent>
	</xs:complexType>
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<!--  SurveyPatient  -->
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<xs:complexType name="SurveyPatient">
		<xs:sequence>
			<xs:element name="patient" type="common:PatientLite" minOccurs="0"/>
			<xs:element name="vendorMRN" type="xs:string"/>
			<xs:element name="icn" type="xs:string" minOccurs="0"/>
			<xs:element name="ssn" type="xs:string" minOccurs="0"/>
			<xs:element name="name" type="sc:SurveyPersonName" minOccurs="0"/>
			<xs:element name="birthdate" type="xs:date" minOccurs="0"/>
		</xs:sequence>
	</xs:complexType>
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<!--  ICN type  -->
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<xs:simpleType name="ICNType">
		<xs:restriction base="xs:token">
			<xs:pattern value="()|([\d]{10}[Vv][\d]{6})"/>
		</xs:restriction>
	</xs:simpleType>
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<!--  Facility  -->
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<xs:complexType name="Facility">
		<xs:sequence>
			<xs:element name="location" type="xs:string"/>
		</xs:sequence>
	</xs:complexType>
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<!--  Vendor  -->
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<xs:complexType name="Vendor">
		<xs:sequence>
			<xs:element name="number" type="xs:string"/>
			<xs:element name="name" type="xs:string"/>
		</xs:sequence>
	</xs:complexType>
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<!--  CareCoordinator  -->
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<xs:complexType name="CareCoordinator">
		<xs:sequence>
			<xs:element name="id" type="xs:string" minOccurs="0"/>
			<xs:element name="facilityNumber" type="xs:string" minOccurs="0"/>
			<xs:element name="name" type="sc:SurveyPersonName" minOccurs="0"/>
		</xs:sequence>
	</xs:complexType>
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<!--  SurveyQuestionsAndAnswers  -->
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<xs:complexType name="SurveyQuestionsAndAnswers">
		<xs:sequence>
			<xs:element name="surveyQuestionAndAnswer" type="sc:SurveyQuestionAndAnswer" minOccurs="1" maxOccurs="100"/>
		</xs:sequence>
	</xs:complexType>
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<!--  SurveyQuestionAndAnswer  -->
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<xs:complexType name="SurveyQuestionAndAnswer">
		<xs:sequence>
			<xs:element name="questionNumber" type="sc:Question"/>
			<xs:element name="answer" type="sc:Answer" minOccurs="0"/>
		</xs:sequence>
	</xs:complexType>
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<!--  SurveyQuestionsAndAnswers  -->
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<xs:complexType name="SurveyQuestionsAndAnswersWithScores">
		<xs:sequence>
			<xs:element name="surveyQuestionAndAnswerWithScore" type="sc:SurveyQuestionAndAnswerWithScore" minOccurs="1" maxOccurs="100"/>
		</xs:sequence>
	</xs:complexType>
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<!--  SurveyQuestionsAndAnswersWithScore  -->
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<xs:complexType name="SurveyQuestionAndAnswerWithScore">
		<xs:complexContent>
			<xs:extension base="sc:SurveyQuestionAndAnswer">
				<xs:sequence>
					<xs:element name="score" type="sc:Score" minOccurs="0"/>
				</xs:sequence>
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<!--  Question type  -->
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<xs:simpleType name="Question">
		<xs:restriction base="xs:integer">
			<xs:minInclusive value="1"/>
		</xs:restriction>
	</xs:simpleType>
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<!--  Answer type  -->
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<xs:simpleType name="Answer">
		<xs:restriction base="xs:integer">
			<xs:minInclusive value="0"/>
		</xs:restriction>
	</xs:simpleType>
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<!--  Score type  -->
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<xs:simpleType name="Score">
		<xs:restriction base="xs:integer">
			<xs:minInclusive value="0"/>
		</xs:restriction>
	</xs:simpleType>
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<!-- Empty string  -->
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<xs:simpleType name="EmptyString">
		<xs:annotation>
			<xs:documentation>null (null element)</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:pattern value=""/>
		</xs:restriction>
	</xs:simpleType>
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<!-- Name string  -->
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<xs:simpleType name="NameString">
		<xs:annotation>
			<xs:documentation>Only alphabetic characters</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:pattern value="[a-z A-Z]*"/>
		</xs:restriction>
	</xs:simpleType>
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<!-- Name string  -->
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<xs:simpleType name="MiddleNameString">
		<xs:annotation>
			<xs:documentation>Only a single alphabetic character followed by a dot or alphabetic characters</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:pattern value="[a-zA-Z][.]|[a-zA-Z]*"/>
		</xs:restriction>
	</xs:simpleType>
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<!-- Non Empty Name string  -->
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<xs:simpleType name="NonEmptyNameString">
		<xs:annotation>
			<xs:documentation>Only alphabetic characters, must contain at least one character</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:pattern value="[\w]+"/>
		</xs:restriction>
	</xs:simpleType>
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<!-- Non Empty Name string  -->
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<xs:simpleType name="NonEmptyString">
		<xs:annotation>
			<xs:documentation>Only alphabetic characters, must contain at least one character</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:minLength value="1"/>
		</xs:restriction>
	</xs:simpleType>
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<!-- Name with spaces string  -->
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<xs:simpleType name="WSNameString">
		<xs:annotation>
			<xs:documentation>Only alphabetic characters or space, must contain at least one character</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:pattern value="\w*|(\w+ \w+)*"/>
		</xs:restriction>
	</xs:simpleType>
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<!--  Non white space string  -->
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<xs:simpleType name="NonWSString">
		<xs:restriction base="xs:string">
			<xs:pattern value="[^\s]*"/>
			<!--
			<xs:minLength value="0"/>
			<xs:pattern value="\w*"/> alows digits as well [a-zA-Z0-9] but no white space
			<xs:pattern value="[^\d\s]*"/> allows [a-zA-Z] but no white space
			-->
		</xs:restriction>
	</xs:simpleType>
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<!--  Non white space non digit string  -->
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<xs:simpleType name="NonWSNonDigitString">
		<xs:restriction base="xs:string">
			<xs:pattern value="[^\d\s]*"/>
		</xs:restriction>
	</xs:simpleType>
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<!--  Non empty non white space string  -->
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<xs:simpleType name="nonEmptyNonWSString">
		<xs:restriction base="xs:string">
			<xs:pattern value="[^\s]+"/>
		</xs:restriction>
	</xs:simpleType>
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<!--  Non empty non white space string  -->
	<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
	<xs:simpleType name="nonEmptyNonWSNonDigitString">
		<xs:restriction base="xs:string">
			<xs:pattern value="[^\d\s]+"/>
		</xs:restriction>
	</xs:simpleType>
</xs:schema>
