<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://www.cnrds.net/schema/patient" xmlns:patient="http://www.cnrds.net/schema/patient">
  <xs:element name="patient">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="patient:doctor" />
      	<xs:element ref="patient:basicInfo"/>
        <xs:element ref="patient:caseHistory"/>
      </xs:sequence>
      <xs:attribute name="id" use="required"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="doctor">
  	<xs:complexType>
  		<xs:attribute name="id" use="required" type="xs:NCName"/>
  	</xs:complexType>
  </xs:element>
  <xs:element name="basicInfo">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="patient:name"/>
        <xs:element ref="patient:nameAbbreviation"/>
        <xs:element ref="patient:birthDay"/>
        <xs:element ref="patient:address"/>
        <xs:element ref="patient:postCode"/>
        <xs:element ref="patient:country"/>
        <xs:element ref="patient:tel"/>
        <xs:element ref="patient:contact"/>
        <xs:element ref="patient:pin"/>
        <xs:element ref="patient:otherPin"/>
        <xs:element ref="patient:patId"/>
        <xs:element ref="patient:organization"/>
        <xs:element ref="patient:firstTreatDate"/>
        <xs:element ref="patient:deathDate"/>
        <xs:element ref="patient:inpatientId"/>
        <xs:element ref="patient:dialysisId"/>
        <xs:element ref="patient:note"/>
        <xs:element ref="patient:dateCreated"/>
        <xs:element ref="patient:lastUpdated"/>
        <xs:element ref="patient:gender"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="nameAbbreviation" type="xs:NCName"/>
  <xs:element name="birthDay" type="xs:NCName"/>
  <xs:element name="address" type="xs:NCName"/>
  <xs:element name="postCode" type="xs:NCName"/>
  <xs:element name="country" type="xs:NCName"/>
  <xs:element name="contact">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="patient:name"/>
        <xs:element ref="patient:tel"/>
        <xs:element ref="patient:mobile"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="mobile" type="xs:NCName"/>
  <xs:element name="otherPin">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="patient:type"/>
        <xs:element ref="patient:pin"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="type" type="xs:NCName"/>
  <xs:element name="patId" type="xs:NCName"/>
  <xs:element name="organization" type="xs:NCName"/>
  <xs:element name="firstTreatDate" type="xs:NCName"/>
  <xs:element name="deathDate" type="xs:NCName"/>
  <xs:element name="inpatientId" type="xs:NCName"/>
  <xs:element name="dialysisId" type="xs:NCName"/>
  <xs:element name="note" type="xs:NCName"/>
  <xs:element name="dateCreated" type="xs:NCName"/>
  <xs:element name="lastUpdated" type="xs:NCName"/>
  <xs:element name="caseHistory">
    <xs:complexType>
      <xs:sequence>
        <xs:element maxOccurs="unbounded" ref="patient:category"/>
      </xs:sequence>
      <xs:attribute name="id" use="required" type="xs:NCName"/>
      <xs:attribute name="name" type="xs:NCName"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="category">
    <xs:complexType>
      <xs:sequence>
        <xs:element maxOccurs="unbounded" ref="patient:item"/>
      </xs:sequence>
      <xs:attribute name="id" use="required" type="xs:NCName"/>
      <xs:attribute name="name"  type="xs:NCName"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="item">
    <xs:complexType>
      <xs:sequence>
        <xs:element maxOccurs="unbounded" ref="patient:attribute"/>
      </xs:sequence>
      <xs:attribute name="id" use="required" type="xs:NCName"/>
      <xs:attribute name="multi"  type="xs:boolean"/>
      <xs:attribute name="name"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="attribute">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" ref="patient:selector"/>
        <xs:element ref="patient:value"/>
      </xs:sequence>
      <xs:attribute name="id" use="required" type="xs:NCName"/>
      <xs:attribute name="name" />
      <xs:attribute name="required"  type="xs:boolean"/>
      <xs:attribute name="type" type="xs:integer"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="selector" type="xs:string"/>
  <xs:element name="value">
    <xs:complexType/>
  </xs:element>
  <xs:element name="name" type="xs:NCName"/>
  <xs:element name="tel" type="xs:NCName"/>
  <xs:element name="pin" type="xs:NCName"/>
  <xs:element name="gender" type="xs:NCName"/>
</xs:schema>
