<?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"
	elementFormDefault="qualified" xmlns:return="http://www.wcbsask.com/claims/eBilling/eBillBatchInvoice.xsd">
	<xs:redefine schemaLocation="http://www.wcbsask.com/claims/eBilling/eBillBatchInvoice.xsd">
        <xs:annotation>
        	<xs:documentation>Extending types from the base schema to include errorCode attributes where necessary.</xs:documentation>
        </xs:annotation>
        <xs:complexType name="invoiceType">
	        <xs:annotation>
	        	<xs:documentation>If an error code occurs at this level, then the entire batch will not be accepted for processing.
				</xs:documentation>
	        </xs:annotation>        
			<xs:complexContent>
				<xs:extension base="return:invoiceType">
					<xs:attribute type="return:errorCodeType" name="errorCode" use="optional"/>
				</xs:extension>
			</xs:complexContent>		
		</xs:complexType>
		<xs:complexType name="claimType">
	        <xs:annotation>
	        	<xs:documentation>If an error code occurs at this level, then this element will not be accepted for processing.
However, adjacent nodes may not contain errors and are processed independently from this node.
				</xs:documentation>
	        </xs:annotation>		
			<xs:complexContent>
				<xs:extension base="return:claimType">
					<xs:attribute type="return:errorCodeType" name="errorCode" use="optional"/>
				</xs:extension>
			</xs:complexContent>		
		</xs:complexType>
		<xs:complexType name="caregiverType">
	        <xs:annotation>
	        	<xs:documentation>If an error code occurs at this level or deeper, then this element will not be accepted for processing.
However, adjacent or parent nodes may not contain errors and are processed independently from this node. Since caregiver nodes correspond to
invoices, an error with one caregiver node will not prevent other caregiver nodes from processing. For example, if a claim element has three
caregiver elements and only one caregiver element contains an error, then the other two caregiver elements will be accepted for processing.
				</xs:documentation>
	        </xs:annotation>		
			<xs:complexContent>
				<xs:extension base="return:caregiverType">
					<xs:attribute type="return:errorCodeType" name="errorCode" use="optional"/>
				</xs:extension>
			</xs:complexContent>		
		</xs:complexType>
		<xs:complexType name="treatmentType">
			<xs:complexContent>
				<xs:extension base="return:treatmentType">
					<xs:attribute type="return:errorCodeType" name="errorCode" use="optional"/>
				</xs:extension>
			</xs:complexContent>		
		</xs:complexType>
		<xs:complexType name="detailType">
			<xs:complexContent>
				<xs:extension base="return:detailType">
					<xs:attribute type="return:errorCodeType" name="errorCode" use="optional"/>
				</xs:extension>
			</xs:complexContent>		
		</xs:complexType>		
		<xs:complexType name="documentationType">
			<xs:complexContent>
				<xs:extension base="return:documentationType">
					<xs:attribute type="return:errorCodeType" name="errorCode" use="optional"/>
				</xs:extension>
			</xs:complexContent>		
		</xs:complexType>
		<xs:complexType name="dobType">
			<xs:simpleContent>
				<xs:extension base="return:dobType">
					<xs:attribute type="return:errorCodeType" name="errorCode" use="optional"/>
				</xs:extension>
			</xs:simpleContent>
		</xs:complexType>
		<xs:complexType name="billingPeriodType">
			<xs:complexContent>
				<xs:extension base="return:billingPeriodType">
					<xs:attribute type="return:errorCodeType" name="errorCode" use="optional"/>
				</xs:extension>
			</xs:complexContent>
		</xs:complexType>
		<xs:complexType name="postalZipCodeType">
			<xs:simpleContent>
				<xs:extension base="return:postalZipCodeType">
					<xs:attribute type="return:errorCodeType" name="errorCode" use="optional"/>
				</xs:extension>
			</xs:simpleContent>
		</xs:complexType>
		<xs:complexType name="phnType">
			<xs:complexContent>
				<xs:extension base="return:phnType">
					<xs:attribute type="return:errorCodeType" name="errorCode" use="optional"/>
				</xs:extension>
			</xs:complexContent>
		</xs:complexType>		
		<xs:complexType name="injuryDateType">
			<xs:complexContent>
				<xs:extension base="return:injuryDateType">
					<xs:attribute type="return:errorCodeType" name="errorCode" use="optional"/>
				</xs:extension>
			</xs:complexContent>
		</xs:complexType>		
	</xs:redefine>
	<xs:simpleType name="errorCodeType">
        <xs:annotation>
        	<xs:documentation>An error code must be 2 alphanumeric characters.  There may be more than one error code per element.  If there is more than one error code, each error code is separated with a comma.</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
			<xs:pattern value="([\w]{2},)*([\w]{2})"></xs:pattern>
		</xs:restriction>
	</xs:simpleType>
</xs:schema> 