<?xml version="1.0"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="unqualified">



  <xs:complexType name="non_serious_type">
    <xs:all>
      <xs:element name="groupTitle">
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:minLength value="4"/>
            <xs:maxLength value="62"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
      <xs:element name="subjectsAffected">
        <xs:simpleType>
          <xs:restriction base="xs:int">
            <xs:minInclusive value="0"/>
            <xs:maxInclusive value="99999999"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
      <xs:element name="occurrences">
        <xs:simpleType>
          <xs:restriction base="xs:int">
            <xs:minInclusive value="0"/>
            <xs:maxInclusive value="99999999"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
      <xs:element name="term">
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:minLength value="2"/>
            <xs:maxLength value="100"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
      <xs:element name="eutctId" type="xs:long"/>
    </xs:all>
  </xs:complexType>


  <xs:complexType name="serious_type">

    <xs:all>
      <xs:element name="groupTitle">
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:minLength value="4"/>
            <xs:maxLength value="62"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
      <xs:element name="subjectsAffected">
        <xs:simpleType>
          <xs:restriction base="xs:int">
            <xs:minInclusive value="0"/>
            <xs:maxInclusive value="99999999"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
      <xs:element name="occurrences">
        <xs:simpleType>
          <xs:restriction base="xs:int">
            <xs:minInclusive value="0"/>
            <xs:maxInclusive value="99999999"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
      <xs:element name="term">
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:minLength value="2"/>
            <xs:maxLength value="100"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
      <xs:element name="eutctId" type="xs:long"/>
      <xs:element  name="occurrencesCausallyRelatedToTreatment">
        <xs:simpleType>
          <xs:restriction base="xs:int">
            <xs:minInclusive value="0"/>
            <xs:maxInclusive value="99999999"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
      <xs:element  name="deaths">
        <xs:simpleType>
          <xs:restriction base="xs:int">
            <xs:minInclusive value="0"/>
            <xs:maxInclusive value="99999999"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
      <xs:element name="deathsCausallyRelatedToTreatment">
        <xs:simpleType>
          <xs:restriction base="xs:int">
            <xs:minInclusive value="0"/>
            <xs:maxInclusive value="99999999"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
    </xs:all>
  </xs:complexType>




  <xs:complexType name="group_type">
    <xs:all>
      <xs:element name="title">
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:minLength value="4"/>
            <xs:maxLength value="62"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
      <xs:element name="deathsResultingFromAdverseEvents">
        <xs:simpleType>
          <xs:restriction base="xs:int">
            <xs:minInclusive value="0"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
      <xs:element name="subjectsAffectedBySeriousAdverseEvents" >
        <xs:simpleType>
          <xs:restriction base="xs:int">
            <xs:minInclusive value="0"/>
            <xs:maxInclusive value="99999999"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
      <xs:element name="subjectsAffectedByNonSeriousAdverseEvents">
        <xs:simpleType>
          <xs:restriction base="xs:int">
            <xs:minInclusive value="0"/>
            <xs:maxInclusive value="99999999"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
      <xs:element name="subjectsExposed">
        <xs:simpleType>
          <xs:restriction base="xs:int">
            <xs:minInclusive value="1"/>
            <xs:maxInclusive value="99999999"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
      <xs:element name="deathsAllCauses">
        <xs:simpleType>
          <xs:restriction base="xs:int">
            <xs:minInclusive value="0"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
    </xs:all>
  </xs:complexType>


  <xs:element name="TABLE">
    <xs:complexType>
       <xs:sequence>
          <xs:element name="GROUP" type="group_type" minOccurs="1" maxOccurs="unbounded"/>
          <xs:element name="NON_SERIOUS" type="non_serious_type" minOccurs="0" maxOccurs="unbounded"/>
          <xs:element name="SERIOUS" type="serious_type"  minOccurs="0" maxOccurs="unbounded"/>
       </xs:sequence>
    </xs:complexType>

    <xs:key name="ref_groups">
            <xs:selector xpath="GROUP"/>
            <xs:field xpath="title"/>
    </xs:key>
    <xs:keyref name="serious_group" refer="ref_groups">
            <xs:selector xpath="SERIOUS"/>
            <xs:field xpath="groupTitle"/>
    </xs:keyref>
    <xs:keyref name="non_serious_group" refer="ref_groups">
            <xs:selector xpath="NON_SERIOUS"/>
            <xs:field xpath="groupTitle"/>
    </xs:keyref>

  </xs:element>

</xs:schema>
