<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
  <xs:element name="feescale">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="version" type="xs:string"/>
        <xs:element name="tablename" type="xs:string"/>
        <xs:element name="feescale_description" type="xs:string" minOccurs="1" maxOccurs="1"/>
        <xs:element name="category" type="xs:string" minOccurs="1" maxOccurs="unbounded" />
        <xs:element name="header" minOccurs="1" maxOccurs="unbounded" />
        <xs:element ref="start" minOccurs="1" maxOccurs="1"/>
        <xs:element name="end" minOccurs="0" maxOccurs="1"/>
        <xs:element ref="item" maxOccurs="unbounded"/>
        <xs:element ref="complex_shortcut" minOccurs="0" maxOccurs="unbounded"/>
        <xs:element name="modifier" minOccurs="0" maxOccurs="unbounded"/>
        <xs:element ref="user_display" minOccurs="0" maxOccurs="1"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="header">
    <xs:complexType>
      <xs:attribute name="id" type="xs:integer" use="required"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="start">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="year" type="xs:integer"/>
        <xs:element name="month" type="xs:integer"/>
        <xs:element name="day" type="xs:integer"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="end">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="year" type="xs:integer"/>
        <xs:element name="month" type="xs:integer"/>
        <xs:element name="day" type="xs:integer"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="complex_shortcut">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="shortcut" minOccurs="1" maxOccurs="1"/>
        <xs:element ref="addition" minOccurs="0" maxOccurs="1"/>
        <xs:element ref="removal" minOccurs="0" maxOccurs="1"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="addition">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="case" minOccurs="1" maxOccurs="unbounded" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="removal">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="case" minOccurs="1" maxOccurs="unbounded" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="case">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="remove_item" minOccurs="0" maxOccurs="unbounded"/>
        <xs:element ref="add_item" minOccurs="0" maxOccurs="unbounded"/>
        <xs:element ref="alter_item" minOccurs="0" maxOccurs="unbounded"/>
        <xs:element ref="shortcut_substitution" minOccurs="0"  maxOccurs="1"/>
        <xs:element name="message" minOccurs="0" type="xs:string"/>
      </xs:sequence>
      <xs:attribute name="condition" type="xs:string" use="required"/>
      <xs:attribute name="handled" type="xs:string" use="optional"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="remove_item">
    <xs:complexType>
      <xs:attribute name="id" type="xs:string" use="required"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="add_item">
    <xs:complexType>
      <xs:attribute name="id" type="xs:string" use="required"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="alter_item">
    <xs:complexType>
      <xs:attribute name="id" type="xs:string" use="required"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="shortcut_substitution">
    <xs:complexType>
      <xs:attribute name="find" type="xs:string" use="required"/>
      <xs:attribute name="replace" type="xs:string" use="optional"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="item">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="section" type="xs:string"/>
        <xs:element ref="shortcut" minOccurs="0" maxOccurs="1"/>
        <xs:element name="description" type="xs:string"/>
        <xs:element ref="fee" maxOccurs="unbounded"/>
        <xs:element ref="feescale_forbid" minOccurs="0" maxOccurs="1" />
      </xs:sequence>
      <xs:attribute name="id" type="xs:string" use="required"/>
      <xs:attribute name="obscurity" type="xs:string" use="optional"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="shortcut">
    <xs:complexType mixed="true">
      <xs:attribute name="att" type="xs:string" use="required"/>
      <xs:attribute name="type" type="xs:string" use="optional"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="fee">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="brief_description" type="xs:string" minOccurs="1" maxOccurs="1" />
        <xs:element name="gross" type="xs:integer" minOccurs="1" maxOccurs="1" />
        <xs:element name="charge" type="xs:integer" minOccurs="0" maxOccurs="1" />
      </xs:sequence>
      <xs:attribute name="condition" type="xs:string" use="optional"/>
      <xs:attribute name="shortcut_match" type="xs:string" use="optional"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="feescale_forbid">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="reason" type="xs:string" minOccurs="0" maxOccurs="1"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="user_display">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="crown_chart_button" minOccurs="0" maxOccurs="unbounded"/>
        <xs:element ref="implant_chart_button" minOccurs="0" maxOccurs="unbounded"/>
        <xs:element ref="fs_chart_button" minOccurs="0" maxOccurs="unbounded"/>
        <xs:element ref="endo_chart_button" minOccurs="0" maxOccurs="unbounded"/>
        <xs:element ref="surgical_chart_button" minOccurs="0" maxOccurs="unbounded"/>
        <xs:element ref="post_chart_button" minOccurs="0" maxOccurs="unbounded"/>        
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="crown_chart_button">
    <xs:complexType>
      <xs:attribute name="shortcut" type="xs:string" use="required"/>
      <xs:attribute name="description" type="xs:string" use="required"/>
      <xs:attribute name="tooltip" type="xs:string" use="optional"/>
    </xs:complexType>
  </xs:element>
    <xs:element name="implant_chart_button">
    <xs:complexType>
      <xs:attribute name="shortcut" type="xs:string" use="required"/>
      <xs:attribute name="description" type="xs:string" use="required"/>
      <xs:attribute name="tooltip" type="xs:string" use="optional"/>
    </xs:complexType>
  </xs:element>
    <xs:element name="fs_chart_button">
    <xs:complexType>
      <xs:attribute name="shortcut" type="xs:string" use="required"/>
      <xs:attribute name="description" type="xs:string" use="required"/>
      <xs:attribute name="tooltip" type="xs:string" use="optional"/>
    </xs:complexType>
  </xs:element>
    <xs:element name="endo_chart_button">
    <xs:complexType>
      <xs:attribute name="shortcut" type="xs:string" use="required"/>
      <xs:attribute name="description" type="xs:string" use="required"/>
      <xs:attribute name="tooltip" type="xs:string" use="optional"/>
    </xs:complexType>
  </xs:element>
    <xs:element name="surgical_chart_button">
    <xs:complexType>
      <xs:attribute name="shortcut" type="xs:string" use="required"/>
      <xs:attribute name="description" type="xs:string" use="required"/>
      <xs:attribute name="tooltip" type="xs:string" use="optional"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="post_chart_button">
    <xs:complexType>
      <xs:attribute name="shortcut" type="xs:string" use="required"/>
      <xs:attribute name="description" type="xs:string" use="required"/>
      <xs:attribute name="tooltip" type="xs:string" use="optional"/>
    </xs:complexType>
  </xs:element>
  
  
  
  <xs:element name="modifier">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="condition" type="xs:string" minOccurs="1" maxOccurs="unbounded"/>
        <xs:element ref="item_id_match" minOccurs="1" maxOccurs="unbounded"/>
        <xs:element name="gross" type="xs:integer" minOccurs="0" maxOccurs="1"/>
        <xs:element name="charge" type="xs:integer" minOccurs="0" maxOccurs="1"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="item_id_match">
   <xs:complexType>
    <xs:simpleContent>
      <xs:extension base="xs:string">
        <xs:attribute name="type" type="xs:string" use="optional"/>
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>
  </xs:element>
  
  
  
  
</xs:schema>
