<?xml version="1.0" encoding="UTF-8"?>
<xs:schema elementFormDefault="unqualified"
    targetNamespace="http://eudract.ema.europa.eu/schema/clinical_trial_result/adverse_events"
    version="1.1"
    xmlns:tns="http://eudract.ema.europa.eu/schema/clinical_trial_result/adverse_events" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  
    <xs:element name="adverseEvents" type="tns:AdverseEvents"/>
    <xs:complexType name="AdverseEvents">
        <xs:sequence>
            <xs:element minOccurs="0" name="description">
            	<xs:simpleType>
            		<xs:restriction base="xs:string">
            			<xs:maxLength value="350"/>            		
            		</xs:restriction>
            	</xs:simpleType>
            </xs:element> 
            <xs:element minOccurs="0" name="nonSeriousEventFrequencyThreshold">
            	<xs:simpleType>
            		<xs:restriction base="xs:decimal">
            			<xs:minInclusive value="0.00"/>
            			<xs:maxInclusive value="5.00"/>
            		</xs:restriction>
            	</xs:simpleType>
            </xs:element>
            <xs:element minOccurs="0" name="timeFrame">
            	<xs:simpleType>
            		<xs:restriction base="xs:string">
            			<xs:minLength value="1"/>
            			<xs:maxLength value="255"/>
            		</xs:restriction>
            	</xs:simpleType>
            </xs:element>
            <xs:element minOccurs="0" name="assessmentMethod" type="tns:EudractTerm"/>
            <xs:element minOccurs="0" name="dictionary" type="tns:DictionaryDetails"/>
            <xs:element minOccurs="0" name="reportingGroups">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element maxOccurs="unbounded" minOccurs="0"
                        	name="reportingGroup" type="tns:AdverseEventReportingGroup"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
            <xs:element minOccurs="0" name="nonSeriousAdverseEvents">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element maxOccurs="unbounded" minOccurs="0"
                        	name="nonSeriousAdverseEvent" type="tns:NonSeriousAdverseEvent"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
            <xs:element minOccurs="0" name="seriousAdverseEvents">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element maxOccurs="unbounded" minOccurs="0"
                        	name="seriousAdverseEvent" type="tns:SeriousAdverseEvent"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
        </xs:sequence>
    </xs:complexType>    
   <xs:complexType name="DictionaryDetails">
        <xs:sequence>
            <xs:element name="otherName" nillable="true">
            	<xs:simpleType>
            		<xs:restriction base="xs:string">
            			<xs:maxLength value="20"/>
            		</xs:restriction>
            	</xs:simpleType>
            </xs:element>
            <xs:element name="version" nillable="true">
            	<xs:simpleType>
            		<xs:restriction base="xs:string">
            			<xs:maxLength value="10"/>
            		</xs:restriction>
            	</xs:simpleType>
            </xs:element>
            <xs:element name="name" type="tns:EudractTerm" nillable="true"/>
        </xs:sequence>
    </xs:complexType>
    <xs:complexType name="AdverseEventReportingGroup">
        <xs:sequence>
            <xs:element name="title">
            	<xs:simpleType>
            		<xs:restriction base="xs:string">
            			<xs:minLength value="2"/>
            			<xs:maxLength value="62"/>
            		</xs:restriction>
            	</xs:simpleType>
            </xs:element>
            <xs:element name="description" nillable="true">
            	<xs:simpleType>
            		<xs:restriction base="xs:string">
            			<xs:maxLength value="999"/>
            		</xs:restriction>
            	</xs:simpleType>
            </xs:element>
            <xs:element
            	name="subjectsAffectedByNonSeriousAdverseEvents"
                nillable="true">
                <xs:simpleType>
            		<xs:restriction base="xs:int">
            			<xs:minInclusive value="0"/>
            			<xs:maxInclusive value="99999999"/>
            		</xs:restriction>
            	</xs:simpleType>
            </xs:element>
            <xs:element name="subjectsAffectedBySeriousAdverseEvents" nillable="true">
            	<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" nillable="true">
            	<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" nillable="true">
            	<xs:simpleType>
            		<xs:restriction base="xs:int">
            			<xs:minInclusive value="0"/>
            		</xs:restriction>
            	</xs:simpleType>
            </xs:element>
            <xs:element	name="deathsResultingFromAdverseEvents" nillable="true">
                <xs:simpleType>
            		<xs:restriction base="xs:int">
            			<xs:minInclusive value="0"/>
            		</xs:restriction>
            	</xs:simpleType>
			</xs:element>
        </xs:sequence>
        <xs:attribute name="id" type="xs:ID" use="required"/>
    </xs:complexType>
    <xs:complexType name="NonSeriousAdverseEvent">
        <xs:complexContent>
            <xs:extension base="tns:AdverseEvent">
                <xs:sequence>
                    <xs:element minOccurs="0" name="values">
                        <xs:complexType>
                            <xs:sequence>
                                <xs:element maxOccurs="unbounded"
                                    minOccurs="0" name="value" type="tns:ReportingGroupNonSeriousAdverseEventValues"/>
                            </xs:sequence>
                        </xs:complexType>
                    </xs:element>
                </xs:sequence>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
    <xs:complexType abstract="true" name="AdverseEvent">
        <xs:sequence>
            <xs:element minOccurs="0" name="description">
            	<xs:simpleType>
            		<xs:restriction base="xs:string">
            			<xs:maxLength value="250"/>
            		</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 minOccurs="0" name="organSystem" type="tns:ControlledTerm"/>
            <xs:element minOccurs="0" name="assessmentMethod" type="tns:EudractTerm"/>
            <xs:element default="false" name="dictionaryOverridden" type="xs:boolean"/>
            <xs:element minOccurs="0" name="dictionary" type="tns:DictionaryDetails"/>
        </xs:sequence>
    </xs:complexType>
    <xs:complexType name="ReportingGroupNonSeriousAdverseEventValues">
        <xs:complexContent>
            <xs:extension base="tns:ReportingGroupAdverseEventValues">
                <xs:sequence/>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
    <xs:complexType abstract="true" name="ReportingGroupAdverseEventValues">
        <xs:sequence>
            <xs:element minOccurs="0" 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 minOccurs="0" 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 minOccurs="0" name="subjectsExposed">
            	<xs:simpleType>
            		<xs:restriction base="xs:int">
            			<xs:minInclusive value="1"/>
            			<xs:maxInclusive value="99999999"/>
            		</xs:restriction>
            	</xs:simpleType>
            </xs:element>
        </xs:sequence>
        <xs:attribute name="reportingGroupId" type="xs:IDREF" use="required"/>
    </xs:complexType>
    <xs:complexType name="SeriousAdverseEvent">
        <xs:complexContent>
            <xs:extension base="tns:AdverseEvent">
                <xs:sequence>
                    <xs:element minOccurs="0" name="values">
                        <xs:complexType>
                            <xs:sequence>
                                <xs:element maxOccurs="unbounded"
                                    minOccurs="0" name="value" type="tns:ReportingGroupSeriousAdverseEventValues"/>
                            </xs:sequence>
                        </xs:complexType>
                    </xs:element>
                </xs:sequence>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
    <xs:complexType name="ReportingGroupSeriousAdverseEventValues">
        <xs:complexContent>
            <xs:extension base="tns:ReportingGroupAdverseEventValues">
                <xs:sequence>
                    <xs:element minOccurs="0" 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 minOccurs="0" name="fatalities" type="tns:fatalities"/>
                </xs:sequence>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
    <xs:complexType name="fatalities">
        <xs:sequence>
            <xs:element minOccurs="0" 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 minOccurs="0" name="deathsCausallyRelatedToTreatment">
                <xs:simpleType>
            		<xs:restriction base="xs:int">
            			<xs:minInclusive value="0"/>
            			<xs:maxInclusive value="99999999"/>
            		</xs:restriction>
            	</xs:simpleType>
            </xs:element>
        </xs:sequence>
    </xs:complexType>
    <xs:complexType name="EudractTerm">
        <xs:sequence>
            <xs:element name="value" nillable="false">
                <xs:simpleType>
                    <xs:restriction base="xs:string">
                        <xs:minLength value="1"/>
                    </xs:restriction>
                </xs:simpleType>
            </xs:element>
        </xs:sequence>
    </xs:complexType>
    <xs:complexType name="ControlledTerm">
        <xs:sequence>
            <xs:element name="eutctId" type="xs:long"/>
            <xs:element name="version" type="xs:short"/>
        </xs:sequence>
    </xs:complexType>

</xs:schema>