<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns="http://crown.esrd.net/crown"
  targetNamespace="http://crown.esrd.net/crown" 
  xmlns:crown="http://crown.esrd.net/crown"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  
  <xsd:include schemaLocation="crown-global.xsd" />

  <xsd:complexType name="ReportingMeasure">
    <xsd:sequence>
      <xsd:element name="orgAffiliation" type="OrganizationAffiliation" />
      <xsd:element name="patientReportingMeasure" type="PatientReportingMeasure"
        maxOccurs="unbounded" />
    </xsd:sequence>
  </xsd:complexType>
  
  <xsd:complexType name="PatientReportingMeasure">
    <xsd:annotation>
      <xsd:documentation>
        Patient Reporting Measure data submission.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:sequence>
      <xsd:element name="orgFacilityCode" type="xsd:string" />
      <xsd:element name="orgPatientId" type="xsd:string" />
      <xsd:element name="timePeriod" type="TimePeriod" />
      <xsd:element name="reportingMeasureType" type="ReportingMeasureType"/>
      <xsd:element name="reportingOption" type="xsd:integer" />
    </xsd:sequence>
  </xsd:complexType>
  
  <xsd:complexType name="TimePeriod">
  	<xsd:annotation>
  		<xsd:documentation>
  		A time period for a PatientReportingMeasure consists of an
  		assessment start and end date for which the selected option applies
  		</xsd:documentation>
  	</xsd:annotation>
  	<xsd:sequence>
  		<xsd:element name="assessmentStartDate" type="xsd:date" />
  		<xsd:element name="assessmentEndDate" type="xsd:date" />
  	</xsd:sequence>
  </xsd:complexType>
  
  <xsd:simpleType name="ReportingMeasureType">
  	<xsd:annotation>
  		<xsd:documentation>
  			Reporting Measure types:
  				Clinical Depression
  				Pain Assessment
  		</xsd:documentation>
  	</xsd:annotation>
  	 <xsd:restriction base="xsd:string">
      <xsd:enumeration value="ClinicalDepression"  />
      <xsd:enumeration value="PainAssessment" />
    </xsd:restriction>
  </xsd:simpleType>
  
</xsd:schema>