<?xml version="1.0" encoding="utf-8"?>

<!--
© Copyright 2007 Infor Global Solutions Technology GmbH and/or its affiliates and subsidiaries. All rights reserved. The 
word and design marks set forth herein are trademarks and/or registered trademarks of Infor Global Solutions 
Technology GmbH and/or its affiliates and subsidiaries. All rights reserved. All other trademarks listed herein 
are the property of their respective owners.
 
-->

<!--    *****     Update Log     *****
 
Date              By      		Note
12 May 2014        LA            New noun for Quality Test Results - BOD-2518
18 Mar 2016        LA            UserArea added to SpecimenResultType, BOD-3118
        *****     Update End     *****
 
-->

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns="http://schema.infor.com/InforOAGIS/2"
    targetNamespace="http://schema.infor.com/InforOAGIS/2" elementFormDefault="qualified"
    attributeFormDefault="unqualified">
     
    <xsd:include schemaLocation="../Components/Operational/QualityComponents.xsd"/>
    
    <xsd:element name="QualityTestResult" type="QualityTestResultType">
        <xsd:annotation>
            <xsd:documentation>
                Contains all the detailed tests done per sample and the corresponding results. 
                The tests are done according to a QualitySpecification and the linked QualityTestMaster
            </xsd:documentation>
        </xsd:annotation>
    </xsd:element>
    
    <xsd:complexType name="QualityTestResultType">
        <xsd:sequence>
            <xsd:element ref="QualityTestResultHeader" minOccurs="0"/>
            <xsd:element ref="QualityTestResultSample" minOccurs="0" maxOccurs="unbounded"/>
        </xsd:sequence>
    </xsd:complexType>
    
    <xsd:element name="QualityTestResultHeader" type="QualityTestResultHeaderType">
        <xsd:annotation>
            <xsd:documentation>
                Contains the generic details about the test results - and the status of 
                every test result with multiple samples for the same item
            </xsd:documentation>
        </xsd:annotation>
    </xsd:element>
    <xsd:element name="QualityTestResultSample" type="QualityTestResultSampleType">
        <xsd:annotation>
            <xsd:documentation>
                Contains the details about the tests that are picked up for testing for a 
                particular sample 
            </xsd:documentation>
        </xsd:annotation>
    </xsd:element>
    
    <xsd:complexType name="QualityTestResultHeaderType">
        <xsd:complexContent>
            <xsd:extension base="StatusEnabledHeaderType">
                <xsd:sequence>
                    <xsd:element ref="InspectionOrderReference" minOccurs="0">
                        <xsd:annotation>
                            <xsd:documentation>
                                Specifies the correspoinding inspection order for which 
                                the results are published
                            </xsd:documentation>
                        </xsd:annotation>
                    </xsd:element>
                                     
                    <xsd:element ref="QualityTest" minOccurs="0">
                        <xsd:annotation>
                            <xsd:documentation>
                                Is this required - or should this come from inspection order?
                                
                                Specifies the corresponding quality test master based on which
                                the tests are performed
                            </xsd:documentation>
                        </xsd:annotation>
                    </xsd:element>
                    
                    <xsd:element ref="Item" minOccurs="0">
                        <xsd:annotation>
                            <xsd:documentation>
                                Item for which the results are published
                            </xsd:documentation>
                        </xsd:annotation>
                    </xsd:element>
                    <xsd:element ref="UserArea" minOccurs="0"/>
                </xsd:sequence>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>
    
    <xsd:complexType name="QualityTestResultSampleType">
        <xsd:complexContent>
            <xsd:extension base="StatusEnabledLineType">
                <xsd:sequence>
                    <xsd:element ref="BatchDateTime" minOccurs="0">
                        <xsd:annotation>
                            <xsd:documentation>
                                To specify the dateTime of the batch out of which the sample is picked up
                            </xsd:documentation>
                        </xsd:annotation>
                    </xsd:element>
                    <xsd:element ref="SampleDateTime" minOccurs="0">
                        <xsd:annotation>
                            <xsd:documentation>
                            Indicates the date time on which the sample is taken for testing.
                            </xsd:documentation>
                        </xsd:annotation>
                    </xsd:element>
                    <xsd:element ref="SampleQuantity" minOccurs="0">
                        <xsd:annotation>
                            <xsd:documentation>
                                Specifies the sample size 
                            </xsd:documentation>
                        </xsd:annotation> 
                    </xsd:element>
                    <xsd:element ref="SampleLabel" minOccurs="0">
                        <xsd:annotation>
                            <xsd:documentation>
                                Label/identifying text for the current sample 
                            </xsd:documentation>
                        </xsd:annotation>
                    </xsd:element>
                    <xsd:element ref="SampleTestLine" minOccurs="0" maxOccurs="unbounded">
                        <xsd:annotation>
                            <xsd:documentation>
                                Specifies the details of every test performed on the 
                                sample. Note that this would get repeated not only when there are multiple tests 
                                to be performed, but also when test quantity is less than the sample size.
                            </xsd:documentation>
                        </xsd:annotation>
                    </xsd:element>
                    
                    <xsd:element ref="SpecimenResult" minOccurs="0" maxOccurs="unbounded">
                        <xsd:annotation>
                            <xsd:documentation>
                                Contains the results for each specimen/item level irrespective of the
                                characteristic(s) tested - to specify whether a particular item/lot/serial 
                                has passed the test or not.
                            </xsd:documentation>
                        </xsd:annotation>
                    </xsd:element>
<!--                    <xsd:element ref="TestIteration" minOccurs="0" maxOccurs="unbounded">
                        <xsd:annotation>
                            <xsd:documentation>
                                Specifies the details of every iteration that is performed on the 
                                sample. Number of iterations are defined based on accepted quantity levels - 
                                when it is either fully clear that a sample size picked up for testing is
                                either ok (or not ok), there would not be a need to go for multiple iterations
                                for a given batch. Multiple iterations for the same sample would be needed when 
                                it is not clear whether the accepted quality is within the required tolerances or not.
                                Also, TestIteration would be repeating only when the same sample with the same
                                sampleID is tested again. If the sample is either kept aside to pick a fresh sample 
                                for testing or if it is mixed with the whole lot to pick up the sample again, these
                                would not come with the TestIteration, it would be considered as another QTRSample.
                            </xsd:documentation>
                        </xsd:annotation>
                    </xsd:element>
-->
                    <xsd:element ref="AcceptedQuantity" minOccurs="0">
                        <xsd:annotation>
                            <xsd:documentation>
                                Accepted quantity with the current sample - it is (not?) the sum of  
                                accepted quantities of every iteration. When there is only one iteration, the
                                accepted quantity at the iteration level is same as the accepted quantity at 
                                the sample level
                            </xsd:documentation>
                        </xsd:annotation> 
                    </xsd:element>                     
                    <xsd:element ref="RejectedQuantity" minOccurs="0">
                        <xsd:annotation>
                            <xsd:documentation>
                                Rejected quantity with the current sample - sum of  
                                rejected quantities of every iteration.
                            </xsd:documentation>
                        </xsd:annotation>  
                    </xsd:element>
                    <xsd:element ref="UserArea" minOccurs="0"/>
                </xsd:sequence>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>
    
   <!--
    <xsd:complexType name="TestIterationType">
        <xsd:sequence>
            <xsd:element ref="IterationID" minOccurs="0">
                <xsd:annotation>
                    <xsd:documentation>
                        Identifier for the iteration 
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element ref="Iteration" minOccurs="0"/>
            <xsd:element ref="SampleTestLine" minOccurs="0" maxOccurs="unbounded">
                <xsd:annotation>
                    <xsd:documentation>
                        Specifies the details of every test sequence performed on the 
                        sample. Note that this would get repeated not only when there are multiple tests 
                        to be performed, but also when test quantity is less than the sample size.
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
           
            <xsd:element ref="SpecimenResult" minOccurs="0" maxOccurs="unbounded">
                <xsd:annotation>
                    <xsd:documentation>
                        Contains the results for each specimen/item level irrespective of the
                        characteristic(s) tested - to specify whether a particular item/lot/serial 
                        has passed the test or not.
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element ref="AcceptedQuantity" minOccurs="0">
                <xsd:annotation>
                    <xsd:documentation>
                        Accepted quantity for the current iteration - is it possible to 
                        provide this? This is not the sum of all the accepted quantities of 
                        sampleTestLine - it indicates what the accepted quantity is after all the 
                        tests for the sample quantity
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element ref="RejectedQuantity" minOccurs="0">
                <xsd:annotation>
                    <xsd:documentation>
                        Rejected quantity for the current iteration
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element ref="TestResult" minOccurs="0">
                <xsd:annotation>
                    <xsd:documentation>
                        Iteration result - pass, fail, need one more iteration?
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element ref="UserArea" minOccurs="0"/>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:element name="TestIteration" type="TestIterationType"/>
    -->
    
    <xsd:complexType name="SpecimenResultType">
        <xsd:sequence>
            <xsd:element ref="SamplePartLabel" minOccurs="0">
                <xsd:annotation>
                    <xsd:documentation>
                        In cases where the test quantity is more than, the sample part label is also 
                        required to understand the result.
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element ref="Item" minOccurs="0">
                <xsd:annotation>
                    <xsd:documentation>
                        To specify the actual lot/serial number of the item that was tested
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element ref="FinalResult" minOccurs="0">
                <xsd:annotation>
                    <xsd:documentation>
                        Final result for the specimen - item/lot/serial - pass or fail for the current specimen/item
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element ref="UserArea" minOccurs="0"/>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:element name="SpecimenResult" type="SpecimenResultType"/>
    <xsd:element name="FinalResult" type="CodeType"/>
    
    <xsd:element name="SampleTestLine" type="SampleTestLineType"/>
    <xsd:complexType name="SampleTestLineType">
        <xsd:sequence>
            <xsd:element ref="LineNumber" minOccurs="0">
                <xsd:annotation>
                    <xsd:documentation>
                        Line number
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element ref="TestID" minOccurs="0">
                <xsd:annotation>
                    <xsd:documentation>
                        Unique identifier for the current test
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element ref="Sequence" minOccurs="0">
                <xsd:annotation>
                    <xsd:documentation>
                        Specifies the sequence of the same test - used when the same test is conducted again
                        on the sample
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element ref="InspectionOrderReference" minOccurs="0">
                <xsd:annotation>
                    <xsd:documentation>
                        To specify the related inspection order task line - this would contain the 
                        details of the actual characteristic/aspect of the item that would be tested.
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element ref="TestDateTime" minOccurs="0">
                <xsd:annotation>
                    <xsd:documentation>
                        Indicates when the test is performed for the current test line
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element ref="TestLocation" minOccurs="0">
                <xsd:annotation>
                    <xsd:documentation>
                        Specifies the location (warehouse etc) where the test is being performed
                        Could this get changed with every type of test?
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element ref="TestPersonReference" minOccurs="0">
                <xsd:annotation>
                    <xsd:documentation>
                        Specifies the tester
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element ref="TestQuantity" minOccurs="0">
                <xsd:annotation>
                    <xsd:documentation>
                        Specifies a part of the sample quantity that would be tested 
                        for every characteristic of the item to be tested.  
                        Example: A 5 kg sample will be tested by testing 1 kg at a time - 
                        since the measuring tool can contain only 1 kg.
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element ref="SamplePartLabel" minOccurs="0">
                <xsd:annotation>
                    <xsd:documentation>
                        Any label/ID for the test quantity that is being tested with the current 
                        test line. 
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element ref="MeasurementResourceReference" minOccurs="0">
                <xsd:annotation>
                    <xsd:documentation>
                        Test tool used for measurement
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:choice>
                <xsd:element ref="MeasuredValue" minOccurs="0">
                    <xsd:annotation>
                        <xsd:documentation>
                            To specify the measurement result with a specific UoM when the test result 
                            is measurable - example - 
                        </xsd:documentation>
                    </xsd:annotation>
                </xsd:element>
                <xsd:element ref="MeasuredOption" minOccurs="0">
                    <xsd:annotation>
                        <xsd:documentation>
                            To specify the measurement result from a pre-defined set of 
                            options. For example, color from the set of colors
                        </xsd:documentation>
                    </xsd:annotation>
                </xsd:element>
            </xsd:choice>
            <xsd:element ref="Text" minOccurs="0">
                <xsd:annotation>
                    <xsd:documentation>
                        To specify additional text for the measurements made
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element ref="AcceptedQuantity" minOccurs="0">
                <xsd:annotation>
                    <xsd:documentation>
                        Accepted quantity after performing the test for the current test quantity
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element ref="RejectedQuantity" minOccurs="0">
                <xsd:annotation>
                    <xsd:documentation>
                        Rejected quantity out of the test quantity
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element ref="TestLineResult" minOccurs="0">
                <xsd:annotation>
                    <xsd:documentation>
                        Contains the end result of the test - pass or fail
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element ref="UserArea" minOccurs="0"/>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:element name="TestLineResult" type="CodeType"/>
    <xsd:element name="SamplePartLabel" type="TextType"/> 
</xsd:schema>
