<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns="http://www.eyetrack.com.au/schema"
           targetNamespace="http://www.eyetrack.com.au/schema"
           elementFormDefault="unqualified">

  <xs:include schemaLocation="OrderBaseTypes.xsd"/>
  
  <xs:element name="JobOrders">
    <xs:complexType>
      <xs:sequence>
        <xs:element maxOccurs="unbounded" ref="JobOrder"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="JobOrder">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="ContentVersion"/>
        <xs:element minOccurs="0" ref="SendingApplication"/>
        <xs:element minOccurs="0" ref="Authentication"/>
        <xs:element ref="TimingInformation"/>
        <xs:element ref="SupplierInformation"/>
        <xs:element ref="DeliveryInformation"/>
        <xs:element ref="InvoiceInformation"/>
        <xs:element ref="TrackingInformation"/>
        <xs:element minOccurs="0" ref="RemakeInformation"/>
        <xs:element minOccurs="0" ref="LabelInformation"/>
        <xs:element ref="PatientInformation"/>
        <xs:element minOccurs="0" ref="FrameDefinition"/>
        <xs:element ref="LensDefinition"/>
        <xs:element ref="ScriptDefinition"/>
        <xs:element ref="RequirementsDefinition"/>
        <xs:element ref="ExtrasDefinition"/>
        <xs:element ref="FinancialDefinition"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="PatientInformation">
    <xs:complexType>
      <xs:sequence>
        <xs:group ref="Person"/>
        <xs:element minOccurs="0" ref="ContactDetails"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="FrameDefinition">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="FrameItemCode"/>
        <xs:element ref="FrameBarcode"/>
        <xs:element ref="FrameModel"/>
        <xs:element ref="FrameColour"/>
        <xs:element ref="FrameSize"/>
        <xs:element ref="FrameEdgeType"/>
        <xs:element ref="FrameDescription"/>
        <xs:element minOccurs="1" ref="BoxA"/>
        <xs:element minOccurs="1" ref="BoxB"/>
        <xs:element minOccurs="1" ref="FrameBridge"/>
        <xs:element minOccurs="1" ref="EffectiveDiameter"/>
        <xs:element minOccurs="0" ref="EffectiveDiameterAxis"/>
        <xs:element minOccurs="0" ref="Shape"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="FrameItemCode" type="xs:string"/>
  <xs:element name="FrameBarcode" type="xs:string"/>
  <xs:element name="FrameModel" type="xs:string"/>
  <xs:element name="FrameColour" type="xs:string"/>
  <xs:element name="FrameSize" type="xs:string"/>
  <xs:element name="BoxA" type="min10Max100Dec"/>
  <xs:element name="BoxB" type="min10Max100Dec"/>
  <xs:element name="FrameBridge" type="min10Max100Dec"/>
  <xs:element name="EffectiveDiameter" type="min10Max100Dec"/>
  <xs:element name="EffectiveDiameterAxis" type="xs:decimal"/>
  <xs:simpleType name="min10Max100Dec">
    <xs:restriction base="xs:decimal">
      <xs:minInclusive value="10"/>
      <xs:maxInclusive value="100"/>
    </xs:restriction>
  </xs:simpleType>
  <xs:element name="FrameEdgeType">
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:pattern value="PLASTIC|METAL|RIMLESS|NYLON">
          <xs:annotation>
            <xs:documentation>The only allowable values for the FrameEdgeType are listed here</xs:documentation>
          </xs:annotation>
        </xs:pattern>
        <xs:enumeration value="PLASTIC">
          <xs:annotation>
            <xs:documentation>Plastic / Shell frame edge</xs:documentation>
          </xs:annotation>
        </xs:enumeration>
        <xs:enumeration value="METAL">
          <xs:annotation>
            <xs:documentation>Metal frame edge</xs:documentation>
          </xs:annotation>
        </xs:enumeration>
        <xs:enumeration value="REVERSE_BEVEL">
          <xs:annotation>
            <xs:documentation>Deprecated - No longer available (refer to sales staff)</xs:documentation>
          </xs:annotation>
        </xs:enumeration>
        <xs:enumeration value="RIMLESS">
          <xs:annotation>
            <xs:documentation>Rimless Screw Frame (requires additional edge thickness)</xs:documentation>
          </xs:annotation>
        </xs:enumeration>
        <xs:enumeration value="NYLON">
          <xs:annotation>
            <xs:documentation>Rimless Nylon Frame (requires additional edge thickness)</xs:documentation>
          </xs:annotation>
        </xs:enumeration>
        <xs:enumeration value="FACET">
          <xs:annotation>
            <xs:documentation>Deprecated - No longer available (refer to sales staff)</xs:documentation>
          </xs:annotation>
        </xs:enumeration>       
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
  <xs:element name="Shape">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" ref="PredefinedShapeClass"/>
        <xs:group minOccurs="0" ref="FD"/>
        <xs:element minOccurs="0" ref="FrameTrace"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="PredefinedShapeClass">
    <xs:annotation>
      <xs:documentation>Shape as per Essilor standard shape definition set</xs:documentation>
    </xs:annotation>
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:pattern value="OBLONG|OVAL_OR_ROUND|AVIATOR|CATS_EYES|SYMMETRIC_OVAL|CUT_AWAY_RECTANGLE|RECTANGLE|NASAL_CUT_AWAY_OVAL">
          <xs:annotation>
            <xs:documentation>The only allowable values for the PredefinedShapeClass are listed here</xs:documentation>
          </xs:annotation>
        </xs:pattern>
        <xs:enumeration value="OBLONG"/>
        <xs:enumeration value="OVAL_OR_ROUND"/>
        <xs:enumeration value="AVIATOR"/>
        <xs:enumeration value="CATS_EYES"/>
        <xs:enumeration value="SYMMETRIC_OVAL"/>
        <xs:enumeration value="CUT_AWAY_RECTANGLE"/>
        <xs:enumeration value="RECTANGLE"/>
        <xs:enumeration value="NASAL_CUT_AWAY_OVAL"/>
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
  <xs:group name="FD">
    <xs:sequence>
      <xs:element minOccurs="0" ref="Fd8"/>
      <xs:element minOccurs="0" ref="Fa8"/>
    </xs:sequence>
  </xs:group>
  <xs:element name="Fd8" type="eightDecimals"/>
  <xs:element name="Fa8" type="eightDecimals"/>
    <xs:simpleType name="eightDecimals">
      <xs:restriction base="xs:string">
        <xs:pattern value="([0-9]*\.?[0-9]*\s){7}([0-9]+\.?[0-9]*)"/>
      </xs:restriction>
    </xs:simpleType>
  <xs:element name="FrameTrace">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="FrameTraceType"/>
        <xs:element ref="FrameTraceContent"/>
        <xs:element ref="FrameTraceLibraryCode"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="FrameTraceType">
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:enumeration value="TRACE_36_POINTS"/>
        <xs:enumeration value="TRACE_360_POINTS"/>
        <xs:enumeration value="TRACE_800_POINTS_ESSILOR"/>
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
  <xs:element name="FrameTraceContent" type="xs:string"/>
  <xs:element name="FrameTraceLibraryCode" type="xs:string"/>
  <xs:element name="FrameDescription" type="xs:string"/>
  <xs:element name="LensDefinition">
    <xs:complexType>
      <xs:sequence>
        <xs:element maxOccurs="1" ref="RightEyeLens"/>
        <xs:element maxOccurs="1" ref="LeftEyeLens"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="RightEyeLens" type="EyeLens"/>
  <xs:element name="LeftEyeLens" type="EyeLens"/>
  <xs:complexType name="EyeLens">
    <xs:sequence>
      <xs:element ref="Code"/>
      <xs:element minOccurs="0" ref="Barcode"/>
      <xs:element minOccurs="0" ref="SourceCode"/>
      <xs:element minOccurs="0" ref="SourceDescription"/>
      <xs:element minOccurs="0" ref="LensForm"/>
    </xs:sequence>
  </xs:complexType>
  <xs:element name="LensForm">
      <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:pattern value="SEMI_FINISHED|FINISHED">
          <xs:annotation>
            <xs:documentation>The only allowable values for the LensForm are listed here</xs:documentation>
          </xs:annotation>
        </xs:pattern>
        <xs:enumeration value="SEMI_FINISHED"/>
        <xs:enumeration value="FINISHED"/>
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
  <xs:element name="ScriptDefinition">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="1" maxOccurs="2" ref="ScriptSingleEye"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="ScriptSingleEye">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="Eye"/>
        <xs:element ref="Sphere"/>
        <xs:element ref="Cylinder"/>
        <xs:element ref="Axis"/>
        <xs:element minOccurs="0" ref="Addition"/>
        <xs:element minOccurs="0" ref="Additions"/>
        <xs:element ref="Pd"/>
        <xs:element minOccurs="0" ref="PdNear"/>
        <xs:element minOccurs="0" ref="FreeformParameters"/>
        <xs:element minOccurs="0" ref="Prism"/>
        <xs:element minOccurs="0" ref="SingleVisionParameters"/>
        <xs:element minOccurs="0" ref="MultifocalParameters"/>
        <xs:element minOccurs="0" ref="Restrictions"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="Eye">
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:pattern value="RIGHT|LEFT">
          <xs:annotation>
            <xs:documentation>The only allowable values for Eye are listed here</xs:documentation>
          </xs:annotation>
        </xs:pattern>
        <xs:enumeration value="RIGHT"/>
        <xs:enumeration value="LEFT"/>
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
  <xs:element name="Sphere">
    <xs:simpleType>
      <xs:restriction base="xs:decimal">
        <xs:minInclusive value="-20"/>
        <xs:maxInclusive value="20"/>
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
  <xs:element name="Cylinder" type="xs:decimal"/>
  <xs:element name="Axis" type="xs:decimal"/>
  <xs:element name="Additions">
    <xs:complexType>
      <xs:sequence>
          <xs:element ref="Addition1"/>
          <xs:element ref="Addition2"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="Addition" type="xs:decimal"/>
  <xs:element name="Addition1" type="xs:decimal"/>
  <xs:element name="Addition2" type="xs:decimal"/>
  <xs:element name="Pd" type="xs:decimal"/>
  <xs:element name="PdNear" type="xs:decimal"/>
  <xs:element name="FreeformParameters">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="PupillaryDistance"/>
        <xs:element ref="Height"/>
        <xs:element ref="Tilt"/>
        <xs:element ref="Vertex"/>
        <xs:element ref="Wrap"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="PupillaryDistance" type="xs:decimal"/>
  <xs:element name="Height" type="xs:decimal"/>
  <xs:element name="Tilt" type="xs:decimal"/>
  <xs:element name="Vertex" type="xs:decimal"/>
  <xs:element name="Wrap" type="xs:decimal"/>
  <xs:element name="Prism">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" ref="PrescribedPrismUp"/>
        <xs:element minOccurs="0" ref="PrescribedPrismDown"/>
        <xs:element minOccurs="0" ref="PrescribedPrismIn"/>
        <xs:element minOccurs="0" ref="PrescribedPrismOut"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="PrescribedPrismUp" type="xs:decimal"/>
  <xs:element name="PrescribedPrismDown" type="xs:decimal"/>
  <xs:element name="PrescribedPrismIn" type="xs:decimal"/>
  <xs:element name="PrescribedPrismOut" type="xs:decimal"/>
  <xs:element name="SingleVisionParameters">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" ref="OpticalCentreDistanceBelowDatum"/>
        <xs:element minOccurs="0" ref="OpticalCentreHeightAboveRim"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="OpticalCentreDistanceBelowDatum" type="xs:decimal"/>
  <xs:element name="OpticalCentreHeightAboveRim" type="xs:decimal"/>
  <xs:element name="MultifocalParameters">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" ref="SegDistanceBelowDatum"/>
        <xs:element minOccurs="0" ref="SegHeightAboveRim"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="SegDistanceBelowDatum" type="xs:decimal"/>
  <xs:element name="SegHeightAboveRim" type="xs:decimal"/>
  <xs:element name="Restrictions">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" ref="RestrictionBase"/>
        <xs:element minOccurs="0" ref="RestrictionForceCribDiameter"/>
        <xs:element minOccurs="0" ref="RestrictionForceBaseCurve"/>
        <xs:element minOccurs="0" ref="RestrictionForceCentreThickness"/>
        <xs:element minOccurs="0" ref="RestrictionMinimumCentreThickness"/>
        <xs:element minOccurs="0" ref="RestrictionMinimumEdgeThickness"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="RestrictionBase">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="MinimumNominalBaseCurve"/>
        <xs:element ref="MaximumNominalBaseCurve"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="MinimumNominalBaseCurve" type="gte_zero_lte_twenty"/>
  <xs:element name="MaximumNominalBaseCurve" type="gte_zero_lte_twenty"/>
  <xs:element name="RestrictionForceCribDiameter" type="xs:decimal"/>
  <xs:element name="RestrictionForceBaseCurve" type="gte_zero_lte_twenty"/>
  <xs:element name="RestrictionForceCentreThickness" type="xs:decimal"/>
  <xs:element name="RestrictionMinimumCentreThickness" type="xs:decimal"/>
  <xs:element name="RestrictionMinimumEdgeThickness" type="xs:decimal"/>
  <xs:simpleType name="gte_zero_lte_twenty">
    <xs:restriction base="xs:decimal">
      <xs:minInclusive value="0"/>
      <xs:maxInclusive value="20"/>
    </xs:restriction>
  </xs:simpleType>
  <xs:element name="RequirementsDefinition">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="LensSource"/>
        <xs:element ref="SupplyProcess"/>
        <xs:element ref="FrameSource"/>
        <xs:element ref="SafetyClass"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="LensSource">
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:pattern value="SUPPLY_LENS_BOTH|SUPPLY_LENS_RIGHT|SUPPLY_LENS_LEFT|CUSTOMER_SUPPLIED">
          <xs:annotation>
            <xs:documentation>The only allowable values for the LensSource are listed here</xs:documentation>
          </xs:annotation>
        </xs:pattern>
        <xs:enumeration value="SUPPLY_LENS_BOTH">
          <xs:annotation>
            <xs:documentation>The recipient of this XML packet is to supply both lenses for this order.</xs:documentation>
          </xs:annotation>
        </xs:enumeration>
        <xs:enumeration value="SUPPLY_LENS_RIGHT">
          <xs:annotation>
            <xs:documentation>The recipient of this XML packet is to supply only the right lens for this order.</xs:documentation>
          </xs:annotation>
        </xs:enumeration>
        <xs:enumeration value="SUPPLY_LENS_LEFT">
          <xs:annotation>
            <xs:documentation>The recipient of this XML packet is to supply only the left lens for this order.</xs:documentation>
          </xs:annotation>
        </xs:enumeration>
        <xs:enumeration value="CUSTOMER_SUPPLIED">
          <xs:annotation>
            <xs:documentation>The sender of this XML will provide the lenses to be used for this order (this is a relatively infrequent special case, and generally would imply a FIT_ONLY order).</xs:documentation>
          </xs:annotation>
        </xs:enumeration>
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
  <xs:element name="SupplyProcess">
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:pattern value="GRIND_AND_FIT|GRIND_ONLY|FIT_ONLY">
          <xs:annotation>
            <xs:documentation>The only allowable values for the SupplyProcess are listed here</xs:documentation>
          </xs:annotation>
        </xs:pattern>
        <xs:enumeration value="GRIND_AND_FIT">
          <xs:annotation>
            <xs:documentation>The recipient of this XML packet is to Grind a lens (or supply stock lens) and fit it to a frame. The frame source is specified by the FrameSource tag.</xs:documentation>
          </xs:annotation>
        </xs:enumeration>
        <xs:enumeration value="GRIND_ONLY">
          <xs:annotation>
            <xs:documentation>The recipient of this XML packet is to Grind a lens (or supply stock lens) and supply uncut (or potentially edged-to-size, depending on business agreements and availability of appropriate trace data).</xs:documentation>
          </xs:annotation>
        </xs:enumeration>
        <xs:enumeration value="FIT_ONLY">
          <xs:annotation>
            <xs:documentation>The recipient of this XML packet is to Fit a lens into a frame. The source of the lens and frame is defined in the LensSource and FrameSource tags.</xs:documentation>
          </xs:annotation>
        </xs:enumeration>
        <!-- plus additions -->
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
  <xs:element name="FrameSource">
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:pattern value="SUPPLY_FRAME|CUSTOMER_SUPPLIED|NO_FRAME">
          <xs:annotation>
            <xs:documentation>The only allowable values for the FrameSource are listed here</xs:documentation>
          </xs:annotation>
        </xs:pattern>
        <xs:enumeration value="SUPPLY_FRAME">
          <xs:annotation>
            <xs:documentation>The frame will be supplied by whoever is receiving this XML packet</xs:documentation>
          </xs:annotation>
        </xs:enumeration>
        <xs:enumeration value="CUSTOMER_SUPPLIED">
          <xs:annotation>
            <xs:documentation>The frame will be supplied by whoever is sending this XML</xs:documentation>
          </xs:annotation>
        </xs:enumeration>
        <xs:enumeration value="NO_FRAME">
          <xs:annotation>
            <xs:documentation>There is no frame involved in this order (e.g. supply of an uncut lens)</xs:documentation>
          </xs:annotation>
        </xs:enumeration>
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
  <xs:element name="SafetyClass">
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:pattern value="MEDIUM_IMPACT|NON_SAFETY">
          <xs:annotation>
            <xs:documentation>The only allowable values for the SafetyClass are listed here</xs:documentation>
          </xs:annotation>
        </xs:pattern>
        <xs:enumeration value="MEDIUM_IMPACT"/>
        <xs:enumeration value="NON_SAFETY"/>
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
  <xs:element name="ExtrasDefinition">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="Line"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="Line">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="1" ref="Code">
          <xs:annotation>
            <xs:documentation>The Essilor code for this extra</xs:documentation>
          </xs:annotation>
        </xs:element>
        <xs:element minOccurs="1" ref="Quantity">
          <xs:annotation>
            <xs:documentation>Quantity of this extra to be supplied</xs:documentation>
          </xs:annotation>
        </xs:element>
        <xs:element minOccurs="0" ref="SourceDescription">
          <xs:annotation>
            <xs:documentation>Description from the sending application, to be used for descriptive labelling purposes if possible</xs:documentation>
          </xs:annotation>
        </xs:element>
        <xs:element minOccurs="0" ref="Eye">
          <xs:annotation>
            <xs:documentation>If this extra is applicable to only one eye, then this tag specifies which eye</xs:documentation>
          </xs:annotation>
        </xs:element>
        </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>
