<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.wcbsask.com/claims/eBilling/eBillBatchInvoice.xsd" xmlns:wcb="http://www.wcbsask.com/claims/eBilling/eBillBatchInvoice.xsd" elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.0">

    <xs:annotation>
    	<xs:documentation>This schema describes the structure of XML files that are submitted by caregivers to Saskatchewan Workers' Compensation Board for reimbursement of services provided to injured workers.  Types that are not prefixed by "xs:" are internally defined</xs:documentation>
	</xs:annotation>
    <xs:element name="invoice" type="wcb:invoiceType">
    	<xs:annotation>
    		<xs:documentation>This is the root element and, as such, can only appear once in the XML document.  It corresponds to a group (which could be 1 but may be more) of invoices a caregiver is submitting.  This group of invoices may be referred to as a "batch" or "batch submission".</xs:documentation>
    	</xs:annotation>
    </xs:element>

<!-- more restrictions on field lengths and types may be added -->
	<xs:complexType name="detailType">
        <xs:annotation>
        	<xs:documentation>The detail complex type</xs:documentation>
        </xs:annotation>
        <xs:attribute name="feeCode" use="required">
            <xs:annotation>
            	<xs:documentation>The MSB/WCB fee code that corresponds to the service that was performed.</xs:documentation>
            </xs:annotation>
            <xs:simpleType>
                <xs:annotation>
                	<xs:documentation>The fee code must be 4 characters or less.</xs:documentation>
                </xs:annotation>
                <xs:restriction base="wcb:nonEmptyAnyStringSimpleType">
  					<xs:maxLength value="4"/>
  				</xs:restriction>
  			</xs:simpleType>
		</xs:attribute>
		<xs:attribute name="date" type="xs:date" use="required">
			<xs:annotation>
				<xs:documentation>The service date the treatment was performed.  When the treatment is for physiotherapy treatment, this should correspond to the billing start date.
Only in that case, the date doesn't necessarily correspond to the date the treatment was performed.  If a billing period exists, this date must fall within that period.
When a billing period is specified (due to certain fee codes requiring a billing period), the fee codes that are causing the requirement for a billing period to exist must have treatment service dates matching the billing period start date.
				</xs:documentation>
			</xs:annotation></xs:attribute>
		<xs:attribute name="units" use="required">
            <xs:annotation>
            	<xs:documentation>The number of times a treatment was performed.  Usually, this is 1.  However, when the treatment is for physiotherapy treatment, the value is often 2 or more.
This situation indicates a number of the same treatments within a billing period that may not have actually occurred on the same date.
This value can only be greater than 1 if the fee code specified can be invoiced multiple times on the same service date.
If treatments are associated with a multiple unit fee code, those treatments must be rolled up into one line item. For example, do not include 3 line items for fee code 2008, each for 1 unit; rather, calculate the sum of the units for the line items and include only 1 line item (1 line item for 3 units of fee code 2008).
</xs:documentation>
            </xs:annotation>
            <xs:simpleType>
                <xs:annotation>
                	<xs:documentation>This is usually 1, but can range from 0 to 1000.  Decimals are allowed, to some degree.</xs:documentation>
                </xs:annotation>
                <xs:restriction base="xs:decimal">
  					<xs:fractionDigits value="2"/>
  					<xs:totalDigits value="4"/>
  					<xs:minExclusive value="0"/>
  					<xs:maxInclusive value="1000"/>
  				</xs:restriction>
  			</xs:simpleType>		
		</xs:attribute>
		<xs:attribute name="alternateAmount" use="optional">
            <xs:annotation>
            	<xs:documentation>The base amount used by WCB is not valid in some situations and must be specified by the caregiver.  This field's purpose is to capture that amount.
The field may only be specified when the base amount can be overridden.</xs:documentation>
            </xs:annotation>
            <xs:simpleType>
                <xs:annotation>
                	<xs:documentation>This is a dollar amount and must be greater than 0.</xs:documentation>
                </xs:annotation>
                <xs:restriction base="xs:decimal">
  					<xs:fractionDigits value="2"/>
  					<xs:minExclusive value="0"/>
  					<xs:maxInclusive value="9999999999"/>
  				</xs:restriction>
  			</xs:simpleType>		
		</xs:attribute>
		<xs:attribute name="drugName" type="wcb:nonEmptyAnyStringSimpleType" use="optional">
			<xs:annotation>
				<xs:documentation>This field specifies the drug name that was prescribed by the caregiver.  It should only be specified when the "Prescription Drugs" fee code is used.</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="prescribingPhysician" type="wcb:nonEmptyAnyStringSimpleType" use="optional">
			<xs:annotation>
				<xs:documentation>The name of the doctor that prescribed the drugs on the invoice. It should only be specified when the "Prescription Drugs" fee code is used and when the caregiver is a DRG caregiver type (pharmacy).</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="applianceName" type="wcb:nonEmptyAnyStringSimpleType" use="optional">
			<xs:annotation>
				<xs:documentation>This field specifies the appliance name that was prescribed by the caregiver.  It should only be specified when the "Appliance" fee codes are used.</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="internationalDescription" type="wcb:nonEmptyAnyStringSimpleType" use="optional">
			<xs:annotation>
				<xs:documentation>This field specifies the description of the service provided that was out of Canada.  It should only be specified when the "Out of Canada Services - All" fee code is used.</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="productType" type="wcb:nonEmptyAnyStringSimpleType" use="optional">
			<xs:annotation>
				<xs:documentation>This field specifies the product type (relating to Cannabis) that was prescribed by the caregiver.  It should only be specified when the "Cannabis" fee code is used.</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="ratio" type="wcb:nonEmptyAnyStringSimpleType" use="optional">
			<xs:annotation>
				<xs:documentation>This field specifies the ratio (relating to Cannabis) that was prescribed by the caregiver.  It should only be specified when the "Cannabis" fee code is used.</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="otherTaxType" type="wcb:nonEmptyAnyStringSimpleType" use="optional">
			<xs:annotation>
				<xs:documentation>This field specifies the tax type (relating to Cannabis) that was prescribed by the caregiver.  It should only be specified when the Cannabis tax fee codes is used.</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="psychologistName" type="wcb:nonEmptyAnyStringSimpleType" use="optional">
			<xs:annotation>
				<xs:documentation>This field specifies the name of the Psychologist.  It should only be specified when the "Psychologist" fee codes is used.</xs:documentation>
			</xs:annotation>
		</xs:attribute>
	</xs:complexType>

	<xs:complexType name="dateRangeType">
        <xs:annotation>
        	<xs:documentation>The date range complex type</xs:documentation>
        </xs:annotation>
        <xs:sequence>
			<xs:element name="start" minOccurs="1" maxOccurs="1">
				<xs:annotation>
					<xs:documentation>The start date of a date range</xs:documentation>
				</xs:annotation>
				<xs:simpleType>
					<xs:restriction base="xs:date"/>
				</xs:simpleType>				
			</xs:element>
			<xs:element name="end" minOccurs="1" maxOccurs="1">
				<xs:annotation>
					<xs:documentation>The end date of a date range</xs:documentation>
				</xs:annotation>
				<xs:simpleType>
					<xs:restriction base="xs:date"/>
				</xs:simpleType>				
			</xs:element>
		</xs:sequence>
	</xs:complexType>
	
	<xs:complexType name="billingPeriodType">
        <xs:annotation>
        	<xs:documentation>The billing period complex type. The period during which all services for the invoice were performed.
This is only required when a detail in the treatment describes physiotherapy treatment. 
The treatment service date must fall inside this date range. 
The billing period is expected to be a standard date range of monthly or bi-weekly, except for certain circumstances.        	
An example of a non-standard billing period is when one of the primary, secondary, tertiary or mental health care dates
falls within the billing period. For example, if the treatment was performed in the month of June,
the primary care date is June 3, and the billing period is normally monthly,
the billing period can be adjusted from June 1 - June 30 to June 3 - June 30.	
        	</xs:documentation>
        </xs:annotation>
        <xs:complexContent>
			<xs:extension base="wcb:dateRangeType"/>
		</xs:complexContent>		
	</xs:complexType>

	<xs:complexType name="fourDatesType">
        <xs:annotation>
        	<xs:documentation>The three dates complex type</xs:documentation>
        </xs:annotation>
        <xs:sequence>
			<xs:element name="primary" minOccurs="0">
				<xs:annotation>
					<xs:documentation>This is primary care date.  This is only required when a detail in the treatment describes therapist treatment.
This field or one of the other 2 care dates are required when a detail in the treatment describes physiotherapy treatment.</xs:documentation>
				</xs:annotation>
				<xs:simpleType>
					<xs:restriction base="xs:date"/>
				</xs:simpleType>				
			</xs:element>
			<xs:element name="secondary" minOccurs="0">
				<xs:annotation>
					<xs:documentation>This is the secondary care date.  This field or one of the other 2 care dates are required when a detail in the treatment describes physiotherapy treatment.</xs:documentation>
				</xs:annotation>
				<xs:simpleType>
					<xs:restriction base="xs:date"/>
				</xs:simpleType>				
			</xs:element>
			<xs:element name="tertiary" minOccurs="0">
				<xs:annotation>
					<xs:documentation>This is the tertiary care date.  This field or one of the other 2 care dates are required when a detail in the treatment describes physiotherapy treatment.</xs:documentation>
				</xs:annotation>
				<xs:simpleType>
					<xs:restriction base="xs:date"/>
				</xs:simpleType>				
			</xs:element>
			<xs:element name="mentalHealth" minOccurs="0">
				<xs:annotation>
					<xs:documentation>This is the mental health date.</xs:documentation>
				</xs:annotation>
				<xs:simpleType>
					<xs:restriction base="xs:date"/>
				</xs:simpleType>				
			</xs:element>
		</xs:sequence>
	</xs:complexType>

	<xs:complexType name="careDatesType">
        <xs:annotation>
        	<xs:documentation>The care dates complex type</xs:documentation>
        </xs:annotation>
        <xs:complexContent>
			<xs:extension base="wcb:fourDatesType"/>
		</xs:complexContent>
	</xs:complexType>

	<xs:complexType name="documentationType">
        <xs:annotation>
        	<xs:documentation>The documentation complex type</xs:documentation>
        </xs:annotation>
        <xs:sequence>
			<xs:element name="partOfBody" minOccurs="0">
				<xs:annotation>
					<xs:documentation>The part of the worker's body that was injured.  This is only required when a detail in the treatment describes chiropractor treatment, general practitioner/specialist treatment,
hospital treatment, miscellaneous caregiver treatment, physiotherapy treatment, massage treatment or audiology treatment.</xs:documentation>
				</xs:annotation>
				<xs:simpleType>
					<xs:restriction base="wcb:nonEmptyAnyStringSimpleType"/>
				</xs:simpleType>				
			</xs:element>
			<xs:element name="referredFrom" minOccurs="0">
				<xs:annotation>
					<xs:documentation>The name of the care provider that referred the patient. Not specifying this field indicates that the patient was not referred by another care provider.</xs:documentation>
				</xs:annotation>
				<xs:simpleType>
					<xs:restriction base="wcb:nonEmptyAnyStringSimpleType"/>
				</xs:simpleType>				
			</xs:element>
			<xs:element name="attendingPhysician" minOccurs="0">
				<xs:annotation>
					<xs:documentation>The name of the caregiver that performed the services.  This is only required when a detail in the treatment describes hospital treatment.</xs:documentation>
				</xs:annotation>
				<xs:simpleType>
					<xs:restriction base="wcb:nonEmptyAnyStringSimpleType"/>
				</xs:simpleType>				
			</xs:element>
			<xs:element name="billingPeriod" type="wcb:billingPeriodType" minOccurs="0">
				<xs:annotation>
					<xs:documentation>The period during which all services for the invoice were performed. 
					This is only required when a detail in the treatment describes treatment. 
					The treatment service date must fall inside this date range. 
					The billing period is expected to be a standard date range of monthly or bi-weekly, except for certain circumstances. 
					An example of a non-standard billing period is when one of the primary, secondary, tertiary or mental health care dates
					falls within the billing period. For example, if the treatment was performed in the month of June,
					the primary care date is June 3, and the billing period is normally monthly,
					the billing period can be adjusted from June 1 - June 30 to June 3 - June 30.					
					</xs:documentation>
				</xs:annotation></xs:element>
			<xs:element name="careDates" type="wcb:careDatesType" minOccurs="0">
				<xs:annotation>
					<xs:documentation>Dates that care was started.  This is only required when a detail in the treatment describes physiotherapy treatment.</xs:documentation>
				</xs:annotation></xs:element>
		</xs:sequence>
	</xs:complexType>

	<xs:simpleType name="nonEmptyAnyStringSimpleType">
		<xs:restriction base="xs:string">
			 <xs:pattern value="[ ]*\S+[ \S]*"/>
		</xs:restriction>
	</xs:simpleType>

	<xs:complexType name="personTypeName">
        <xs:annotation>
        	<xs:documentation>The person complex type</xs:documentation>
        </xs:annotation>
		<xs:attribute name="first" use="required" type="wcb:nonEmptyAnyStringSimpleType">
			<xs:annotation>
				<xs:documentation>The person's first name.</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="last" use="required" type="wcb:nonEmptyAnyStringSimpleType">
			<xs:annotation>
				<xs:documentation>The person's last name.</xs:documentation>
			</xs:annotation>
		</xs:attribute>
	</xs:complexType>

	<xs:simpleType name="phnTypeRestriction">
        <xs:annotation>
        	<xs:documentation>The provincial health number.  This is only required if the provincial health number is from Saskatchewan.</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
		</xs:restriction>
	</xs:simpleType>

	<xs:complexType name="phnType">
        <xs:annotation>
        	<xs:documentation>The provincial health number complex type</xs:documentation>
        </xs:annotation>
        <xs:simpleContent>
			<xs:extension base="wcb:phnTypeRestriction">
				<xs:attribute name="local" type="xs:boolean">
					<xs:annotation>
						<xs:documentation>This should be set to true if the provincial health number is from Saskatchewan; false, otherwise.</xs:documentation>
					</xs:annotation></xs:attribute>
			</xs:extension>
		</xs:simpleContent>
	</xs:complexType>

	<xs:simpleType name="postalZipCodeTypeRestriction">
        <xs:annotation>
        	<xs:documentation>This must be a valid postal code or zip code.</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
  			<xs:pattern value="\d{5}-\d{4}|\d{5}|[ABCEGHJKLMNPRSTVXY]\d[A-Z]\d[A-Z]\d"/>
		</xs:restriction>
	</xs:simpleType>	

	<xs:complexType name="dobType">
		<xs:simpleContent>
			<xs:extension base="wcb:simpleDateTypeRestriction"/>
		</xs:simpleContent>
	</xs:complexType>

	<xs:simpleType name="simpleDateTypeRestriction">
        <xs:restriction base="xs:date"/>
	</xs:simpleType>

	<xs:complexType name="injuryDateType">
		<xs:simpleContent>
			<xs:extension base="wcb:simpleDateTypeRestriction"/>
		</xs:simpleContent>
	</xs:complexType>

	<xs:complexType name="postalZipCodeType">
        <xs:annotation>
        	<xs:documentation>Postal code or zip code complex type</xs:documentation>
        </xs:annotation>	
		<xs:simpleContent>
			<xs:extension base="wcb:postalZipCodeTypeRestriction"/>
		</xs:simpleContent>
	</xs:complexType>		

	<xs:complexType name="addressType">
        <xs:annotation>
        	<xs:documentation>The address complex type</xs:documentation>
        </xs:annotation>
        <xs:sequence>
			<xs:element name="addressLine" minOccurs="1" maxOccurs="3">
				<xs:annotation>
					<xs:documentation>Address of residence</xs:documentation>
				</xs:annotation>
				<xs:simpleType>
					<xs:restriction base="wcb:nonEmptyAnyStringSimpleType"/>
				</xs:simpleType>				
			</xs:element>
			<xs:element name="city" minOccurs="1" maxOccurs="1">
				<xs:annotation>
					<xs:documentation>City of residence</xs:documentation>
				</xs:annotation>
				<xs:simpleType>
					<xs:restriction base="wcb:nonEmptyAnyStringSimpleType"/>
				</xs:simpleType>				
			</xs:element>
			<xs:element name="provinceOrState" minOccurs="1" maxOccurs="1">
                <xs:annotation>
                	<xs:documentation>Province or state of residence</xs:documentation>
                </xs:annotation>
                <xs:simpleType>
                    <xs:annotation>
                    	<xs:documentation>This must be a valid province from Canada or state from the United States.  The abbreviation definitions can be found on the Canada Post website: http://www.canadapost.ca</xs:documentation>
                    </xs:annotation>
                    <xs:restriction base="xs:string">
						<xs:enumeration value="AB"/>
						<xs:enumeration value="BC"/>
						<xs:enumeration value="MB"/>
						<xs:enumeration value="NB"/>
						<xs:enumeration value="NL"/>
						<xs:enumeration value="NT"/>
						<xs:enumeration value="NS"/>
						<xs:enumeration value="NU"/>
						<xs:enumeration value="ON"/>
						<xs:enumeration value="PE"/>
						<xs:enumeration value="QC"/>
						<xs:enumeration value="SK"/>
						<xs:enumeration value="YT"/>
						<xs:enumeration value="AL"/>
						<xs:enumeration value="AK"/>
						<xs:enumeration value="AZ"/>
						<xs:enumeration value="AR"/>
						<xs:enumeration value="CA"/>
						<xs:enumeration value="CO"/>
						<xs:enumeration value="CT"/>
						<xs:enumeration value="DE"/>
						<xs:enumeration value="DC"/>
						<xs:enumeration value="FL"/>
						<xs:enumeration value="GA"/>
						<xs:enumeration value="HI"/>
						<xs:enumeration value="ID"/>
						<xs:enumeration value="IL"/>
						<xs:enumeration value="IN"/>
						<xs:enumeration value="IA"/>
						<xs:enumeration value="KS"/>
						<xs:enumeration value="KY"/>
						<xs:enumeration value="LA"/>
						<xs:enumeration value="ME"/>
						<xs:enumeration value="MD"/>
						<xs:enumeration value="MA"/>
						<xs:enumeration value="MI"/>
						<xs:enumeration value="MN"/>
						<xs:enumeration value="MS"/>
						<xs:enumeration value="MO"/>
						<xs:enumeration value="MT"/>
						<xs:enumeration value="NE"/>
						<xs:enumeration value="NV"/>
						<xs:enumeration value="NH"/>
						<xs:enumeration value="NJ"/>
						<xs:enumeration value="NM"/>
						<xs:enumeration value="NY"/>
						<xs:enumeration value="NC"/>
						<xs:enumeration value="ND"/>
						<xs:enumeration value="OH"/>
						<xs:enumeration value="OK"/>
						<xs:enumeration value="OR"/>
						<xs:enumeration value="PA"/>
						<xs:enumeration value="RI"/>
						<xs:enumeration value="SC"/>
						<xs:enumeration value="SD"/>
						<xs:enumeration value="TN"/>
						<xs:enumeration value="TX"/>
						<xs:enumeration value="UT"/>
						<xs:enumeration value="VT"/>
						<xs:enumeration value="VA"/>
						<xs:enumeration value="WA"/>
						<xs:enumeration value="WV"/>
						<xs:enumeration value="WI"/>
						<xs:enumeration value="WY"/>			  			
					</xs:restriction>
				</xs:simpleType>
			</xs:element>
			<xs:element name="postalOrZipCode" minOccurs="1" maxOccurs="1" type="wcb:postalZipCodeType">
                <xs:annotation>
                	<xs:documentation>Postal code or zip code of residence</xs:documentation>
                </xs:annotation>
			</xs:element>
			<xs:element name="country" minOccurs="1" maxOccurs="1">
                <xs:annotation>
                	<xs:documentation>Country of residence.</xs:documentation>
                </xs:annotation>
                <xs:simpleType>
                    <xs:annotation>
                    	<xs:documentation>This must be Canada or the United States.</xs:documentation>
                    </xs:annotation>
                    <xs:restriction base="xs:string">
						<xs:enumeration value="CA"/>
						<xs:enumeration value="US"/>
					</xs:restriction>
				</xs:simpleType>			
			</xs:element>
		</xs:sequence>
	</xs:complexType>

	<xs:complexType name="workerType">
        <xs:annotation>
        	<xs:documentation>The worker complex type</xs:documentation>
        </xs:annotation>
        <xs:sequence>
			<xs:element name="name" type="wcb:personTypeName" minOccurs="1" maxOccurs="1">
				<xs:annotation>
					<xs:documentation>The worker's name.</xs:documentation>
				</xs:annotation></xs:element>
			<xs:element name="phn" type="wcb:phnType" minOccurs="1" maxOccurs="1">
				<xs:annotation>
					<xs:documentation>The worker's provincial health number information.</xs:documentation>
				</xs:annotation></xs:element>
			<xs:element name="address" type="wcb:addressType" minOccurs="1" maxOccurs="1">
				<xs:annotation>
					<xs:documentation>The worker's address.</xs:documentation>
				</xs:annotation></xs:element>
			<xs:element name="dob" minOccurs="1" maxOccurs="1" type="wcb:dobType">
				<xs:annotation>
					<xs:documentation>The worker's date of birth.</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="injuryDate" minOccurs="1" maxOccurs="1" type="wcb:injuryDateType">
				<xs:annotation>
					<xs:documentation>The date the worker was injured.</xs:documentation>
				</xs:annotation>
			</xs:element>
		</xs:sequence>
	</xs:complexType>

	<xs:complexType name="invoiceReferenceType">
        <xs:annotation>
        	<xs:documentation>The invoice reference complex type</xs:documentation>
        </xs:annotation>
        <xs:attribute name="number" use="required">
            <xs:annotation>
            	<xs:documentation>The invoice reference number</xs:documentation>
            </xs:annotation>
            <xs:simpleType>
                <xs:annotation>
                	<xs:documentation>The value may be any string that is 30 characters or less.</xs:documentation>
                </xs:annotation>
                <xs:restriction base="xs:string">
  					<xs:maxLength value="30"/>
  				</xs:restriction>
  			</xs:simpleType>		
		</xs:attribute>
	</xs:complexType>

	<xs:complexType name="treatmentType">
        <xs:annotation>
        	<xs:documentation>The treatment complex type</xs:documentation>
        </xs:annotation>
        <xs:sequence>
			<xs:element name="invoiceReference" type="wcb:invoiceReferenceType" minOccurs="0" maxOccurs="1">
				<xs:annotation>
					<xs:documentation>Each invoice that is submitted may have a reference number that is meaningful to the caregiver.</xs:documentation>
				</xs:annotation></xs:element>
			<xs:element name="worker" type="wcb:workerType" minOccurs="0" maxOccurs="1">
				<xs:annotation>
					<xs:documentation>The treatment is performed on an injured worker.  This information is not required but it is best to include to reduce errors.</xs:documentation>
				</xs:annotation></xs:element>
			<xs:element name="detail" type="wcb:detailType" minOccurs="1" maxOccurs="unbounded">
				<xs:annotation>
					<xs:documentation>The treatment must include at least one detail that describes what service was performed.
Treatment details must be merged to one invoice, if applicable; they must not be spread out over multiple invoices.					
					</xs:documentation>
				</xs:annotation></xs:element>
			<xs:element name="documentation" type="wcb:documentationType" minOccurs="1" maxOccurs="1">
				<xs:annotation>
					<xs:documentation>Each treatment must contain documentation details about the service performed.  The documentation fields required are dependent on the services provided.  As a guideline, a caregiver should provide as much documentation as is available; WCB will ignore extraneous documentation but will not accept invoices where required documentation is missing.</xs:documentation>
				</xs:annotation></xs:element>
			<xs:element name="comment" minOccurs="0" maxOccurs="1">
                <xs:annotation>
                	<xs:documentation>A caregiver may specify comments about the treatment that is relevant when processing the payment.</xs:documentation>
                </xs:annotation>
                <xs:simpleType>
                    <xs:annotation>
                    	<xs:documentation>A comment must be 200 or fewer characters.</xs:documentation>
                    </xs:annotation>
                    <xs:restriction base="xs:string">
    					<xs:maxLength value="200"/>
    				</xs:restriction>
    			</xs:simpleType>
			</xs:element>
		</xs:sequence>
	</xs:complexType>

	<xs:complexType name="caregiverType">
        <xs:annotation>
        	<xs:documentation>The caregiver complex type</xs:documentation>
        </xs:annotation>
        <xs:sequence>
			<xs:element name="treatment" type="wcb:treatmentType" minOccurs="1" maxOccurs="1">
				<xs:annotation>
					<xs:documentation>For the specified claim, the caregiver provides treatment and this is the description of that treatment.</xs:documentation>
				</xs:annotation></xs:element>
		</xs:sequence>
		<xs:attribute name="number" use="required">
            <xs:annotation>
            	<xs:documentation>Each caregiver has a unique number/type combination assigned by WCB or Saskatchewan Health.  This is the number portion of that combination.</xs:documentation>
            </xs:annotation>
            <xs:simpleType>
                <xs:annotation>
                	<xs:documentation>Each caregiver number must be exactly 6 digits long, right justified, zero-padded, if necessary.</xs:documentation>
                </xs:annotation>
                <xs:restriction base="xs:string">
   					<xs:pattern value="[A-Z0-9]{6}"/>
   				</xs:restriction>
   			</xs:simpleType>			
		</xs:attribute>
		<xs:attribute name="type" use="required">
            <xs:annotation>
            	<xs:documentation>Each caregiver has a unique number/type combination assigned by WCB.  This is the type portion of that combination.</xs:documentation>
            </xs:annotation>
            <xs:simpleType>
                <xs:annotation>
                	<xs:documentation>Each caregiver type must be exactly 3 characters long.  A sample value is "PHY".</xs:documentation>
                </xs:annotation>
                <xs:restriction base="wcb:nonEmptyAnyStringSimpleType">
   					<xs:length value="3"/>
   				</xs:restriction>
   			</xs:simpleType>			
		</xs:attribute>
		<xs:attribute name="clinicType" use="required">
            <xs:annotation>
            	<xs:documentation>Each clinic has a unique number/type combination assigned by WCB.  This is the type portion of that combination.</xs:documentation>
            </xs:annotation>
            <xs:simpleType>
                <xs:annotation>
                	<xs:documentation>Each clinic type must be exactly 2 characters long.  A sample value is "SK".</xs:documentation>
                </xs:annotation>
                <xs:restriction base="wcb:nonEmptyAnyStringSimpleType">
   					<xs:length value="2"/>
   				</xs:restriction>
   			</xs:simpleType>			
		</xs:attribute>
		<xs:attribute name="clinicNumber" use="required">
            <xs:annotation>
            	<xs:documentation>Each clinic has a unique number/type combination assigned by WCB.  This is the number portion of that combination.</xs:documentation>
            </xs:annotation>
            <xs:simpleType>
                <xs:annotation>
                	<xs:documentation>Each clinic number must be exactly 4 digits long, right justified, zero-padded, if necessary.</xs:documentation>
                </xs:annotation>
                <xs:restriction base="xs:string">
   					<xs:pattern value="[A-Z0-9]{4}"/>
   				</xs:restriction>
   			</xs:simpleType>
		</xs:attribute>
	</xs:complexType>

	<xs:complexType name="claimType">
        <xs:annotation>
        	<xs:documentation>The claim complex type</xs:documentation>
        </xs:annotation>
        <xs:sequence>
			<xs:element name="caregiver" type="wcb:caregiverType" minOccurs="1" maxOccurs="unbounded">
				<xs:annotation>
					<xs:documentation>Each submitted claim must have at least one caregiver providing service. Each caregiver element corresponds to one invoice.
So, if the batch submission contains a claim element with three caregiver elements nested inside of it, three invoices will be generated. Invoices are processed independently.
If one invoice is rejected from processing due to an error, other invoices in a batch may still be accepted for processing.
					</xs:documentation>
				</xs:annotation>
			</xs:element>
		</xs:sequence>
		<xs:attribute name="number" use="optional">
            <xs:annotation>
            	<xs:documentation>WCB creates claim numbers for each injury, one patient can have multiple claims with WCB for different injuries. If you were given or know the claim number, please include it with your invoice to streamline payment.
            	</xs:documentation>
            </xs:annotation>
            <xs:simpleType>
                <xs:annotation>
                	<xs:documentation>Each claim number must be exactly 8 digits long, right justified, zero-padded, if necessary.</xs:documentation>
                </xs:annotation>
                <xs:restriction base="xs:string">
   					<xs:pattern value="\d{8}"/>
   				</xs:restriction>
   			</xs:simpleType>		
		</xs:attribute>
	</xs:complexType>

	<xs:complexType name="invoiceType">
        <xs:annotation>
        	<xs:documentation>The root element complex type</xs:documentation>
        </xs:annotation>
        <xs:sequence>
            <xs:element name="vendor" minOccurs="1" maxOccurs="1">
                <xs:annotation>
                    <xs:documentation>This is the name of the software vendor.</xs:documentation>
                </xs:annotation>
                <xs:simpleType>
                    <xs:restriction base="wcb:nonEmptyAnyStringSimpleType"/>
                </xs:simpleType>
            </xs:element>
			<xs:element name="claim" type="wcb:claimType" minOccurs="1" maxOccurs="unbounded">
				<xs:annotation>
					<xs:documentation>Each batch must contain at least one claim.</xs:documentation>
				</xs:annotation>
            </xs:element>
		</xs:sequence>
		<xs:attribute name="batchNumber" use="required">
			<xs:annotation>
				<xs:documentation>Each batch must have a number which is unique with respect to the caregiver and the sequence of batch submissions; a caregiver may not submit 2 batches with the same number.
The only exception to this rule is when a batch submission is not fully processed due to an internal error or invalid data in the submission.
In that case, the caregiver is notified of the error, the appropriate corrections are made, and resubmission can occur with the same number.</xs:documentation>
			</xs:annotation>
			<xs:simpleType>
                <xs:annotation>
                	<xs:documentation>Each batch number must be 20 characters or less.</xs:documentation>
                </xs:annotation>
				<xs:restriction base="xs:string">
	   				<xs:maxLength value="20"/>
	   				<xs:pattern value="\S+"/>
	   			</xs:restriction>
			</xs:simpleType>
		</xs:attribute>
	</xs:complexType>

</xs:schema>