<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
           attributeFormDefault="unqualified">
    <xs:import namespace="http://www.w3.org/2000/09/xmldsig#" schemaLocation="../XUA/xmldsig-core-schema.xsd"/>
    <xs:element name="AuditMessage">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="EventIdentification"
                            type="EventIdentificationType"/>
                <xs:element name="ActiveParticipant"
                            maxOccurs="unbounded">
                    <xs:complexType>
                        <xs:complexContent>
                            <xs:extension base="ActiveParticipantType"/>
                        </xs:complexContent>
                    </xs:complexType>
                </xs:element>
                <xs:element name="AuditSourceIdentification"
                            type="AuditSourceIdentificationType" maxOccurs="unbounded"/>
                <xs:element name="ParticipantObjectIdentification"
                            type="ParticipantObjectIdentificationType" minOccurs="0"
                            maxOccurs="unbounded"/>
                <xs:element ref="ds:Signature" minOccurs="0"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:complexType name="EventIdentificationType">
        <xs:sequence>
            <xs:element name="EventID" type="CodedValueType"/>
            <xs:element name="EventTypeCode" type="CodedValueType"
                        minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
        <xs:attribute name="EventActionCode" use="optional">
            <xs:simpleType>
                <xs:restriction base="xs:string">
                    <xs:enumeration value="C">
                        <xs:annotation>
                            <xs:appinfo>Create</xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="R">
                        <xs:annotation>
                            <xs:appinfo>Read</xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="U">
                        <xs:annotation>
                            <xs:appinfo>Update</xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="D">
                        <xs:annotation>
                            <xs:appinfo>Delete</xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="E">
                        <xs:annotation>
                            <xs:documentation>Execute</xs:documentation>
                        </xs:annotation>
                    </xs:enumeration>
                </xs:restriction>
            </xs:simpleType>
        </xs:attribute>
        <xs:attribute name="EventDateTime" type="xs:dateTime"
                      use="required"/>
        <xs:attribute name="EventOutcomeIndicator" use="required">
            <xs:simpleType>
                <xs:restriction base="xs:integer">
                    <xs:enumeration value="0">
                        <xs:annotation>
                            <xs:appinfo>Success</xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="4">
                        <xs:annotation>
                            <xs:appinfo>Minor failure</xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="8">
                        <xs:annotation>
                            <xs:appinfo>Serious failure</xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="12">
                        <xs:annotation>
                            <xs:appinfo>
                                Major failure; action made unavailable
                            </xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                </xs:restriction>
            </xs:simpleType>
        </xs:attribute>
    </xs:complexType>
    <xs:complexType name="AuditSourceIdentificationType">
        <xs:sequence>
            <xs:element name="AuditSourceTypeCode" type="CodedValueType"
                        minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
        <xs:attribute name="AuditEnterpriseSiteID" type="xs:string"
                      use="optional"/>
        <xs:attribute name="AuditSourceID" type="xs:string"
                      use="required"/>
    </xs:complexType>
    <xs:complexType name="ActiveParticipantType">
        <xs:sequence minOccurs="0">
            <xs:element name="RoleIDCode" type="CodedValueType"
                        minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
        <xs:attribute name="UserID" type="xs:string" use="required"/>
        <xs:attribute name="AlternativeUserID" type="xs:string"
                      use="optional"/>
        <xs:attribute name="UserName" type="xs:string" use="optional"/>
        <xs:attribute name="UserIsRequestor" type="xs:boolean"
                      use="optional" default="true"/>
        <xs:attribute name="NetworkAccessPointID" type="xs:string"
                      use="optional"/>
        <xs:attribute name="NetworkAccessPointTypeCode"
                      use="optional">
            <xs:simpleType>
                <xs:restriction base="xs:unsignedByte">
                    <xs:enumeration value="1">
                        <xs:annotation>
                            <xs:appinfo>
                                Machine Name, including DNS name
                            </xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="2">
                        <xs:annotation>
                            <xs:appinfo>IP Address</xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="3">
                        <xs:annotation>
                            <xs:appinfo>Telephone Number</xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                </xs:restriction>
            </xs:simpleType>
        </xs:attribute>
    </xs:complexType>
    <xs:complexType name="ParticipantObjectIdentificationType">
        <xs:sequence>
            <xs:element name="ParticipantObjectIDTypeCode"
                        type="CodedValueType"/>
            <xs:choice minOccurs="0">
                <xs:element name="ParticipantObjectName"
                            type="xs:string" minOccurs="0"/>
                <xs:element name="ParticipantObjectQuery"
                            type="xs:base64Binary" minOccurs="0"/>
            </xs:choice>
            <xs:element name="ParticipantObjectDetail"
                        type="TypeValuePairType" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
        <xs:attribute name="ParticipantObjectID" type="xs:string"
                      use="required"/>
        <xs:attribute name="ParticipantObjectTypeCode" use="optional">
            <xs:simpleType>
                <xs:restriction base="xs:unsignedByte">
                    <xs:enumeration value="1">
                        <xs:annotation>
                            <xs:appinfo>Person</xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="2">
                        <xs:annotation>
                            <xs:appinfo>System object</xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="3">
                        <xs:annotation>
                            <xs:appinfo>Organization</xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="4">
                        <xs:annotation>
                            <xs:appinfo>Other</xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                </xs:restriction>
            </xs:simpleType>
        </xs:attribute>
        <xs:attribute name="ParticipantObjectTypeCodeRole"
                      use="optional">
            <xs:simpleType>
                <xs:restriction base="xs:unsignedByte">
                    <xs:enumeration value="1">
                        <xs:annotation>
                            <xs:appinfo>Patient</xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="2">
                        <xs:annotation>
                            <xs:appinfo>Location</xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="3">
                        <xs:annotation>
                            <xs:appinfo>Report</xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="4">
                        <xs:annotation>
                            <xs:appinfo>Resource</xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="5">
                        <xs:annotation>
                            <xs:appinfo>Master file</xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="6">
                        <xs:annotation>
                            <xs:appinfo>User</xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="7">
                        <xs:annotation>
                            <xs:appinfo>List</xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="8">
                        <xs:annotation>
                            <xs:appinfo>Doctor</xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="9">
                        <xs:annotation>
                            <xs:appinfo>Subscriber</xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="10">
                        <xs:annotation>
                            <xs:appinfo>Guarantor</xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="11">
                        <xs:annotation>
                            <xs:appinfo>
                                Security User Entity
                            </xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="12">
                        <xs:annotation>
                            <xs:appinfo>Security User Group</xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="13">
                        <xs:annotation>
                            <xs:appinfo>Security Resource</xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="14">
                        <xs:annotation>
                            <xs:appinfo>
                                Security Granualarity Definition
                            </xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="15">
                        <xs:annotation>
                            <xs:appinfo>Provider</xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="16">
                        <xs:annotation>
                            <xs:appinfo>Report Destination</xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="17">
                        <xs:annotation>
                            <xs:appinfo>Report Library</xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="18">
                        <xs:annotation>
                            <xs:appinfo>Schedule</xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="19">
                        <xs:annotation>
                            <xs:appinfo>Customer</xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="20">
                        <xs:annotation>
                            <xs:appinfo>Job</xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="21">
                        <xs:annotation>
                            <xs:appinfo>Job Stream</xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="22">
                        <xs:annotation>
                            <xs:appinfo>Table</xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="23">
                        <xs:annotation>
                            <xs:appinfo>Routing Criteria</xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="24">
                        <xs:annotation>
                            <xs:appinfo>Query</xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                </xs:restriction>
            </xs:simpleType>
        </xs:attribute>
        <xs:attribute name="ParticipantObjectDataLifeCycle"
                      use="optional">
            <xs:simpleType>
                <xs:restriction base="xs:unsignedByte">
                    <xs:enumeration value="1">
                        <xs:annotation>
                            <xs:appinfo>
                                Origination / Creation
                            </xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="2">
                        <xs:annotation>
                            <xs:appinfo>
                                Import / Copy from original
                            </xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="3">
                        <xs:annotation>
                            <xs:appinfo>Amendment</xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="4">
                        <xs:annotation>
                            <xs:appinfo>Verification</xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="5">
                        <xs:annotation>
                            <xs:appinfo>Translation</xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="6">
                        <xs:annotation>
                            <xs:appinfo>Access / Use</xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="7">
                        <xs:annotation>
                            <xs:appinfo>De-identification</xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="8">
                        <xs:annotation>
                            <xs:appinfo>
                                Aggregation, summarization, derivation
                            </xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="9">
                        <xs:annotation>
                            <xs:appinfo>Report</xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="10">
                        <xs:annotation>
                            <xs:appinfo>
                                Export / Copy to target
                            </xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="11">
                        <xs:annotation>
                            <xs:appinfo>Disclosure</xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="12">
                        <xs:annotation>
                            <xs:appinfo>
                                Receipt of disclosure
                            </xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="13">
                        <xs:annotation>
                            <xs:appinfo>Archiving</xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="14">
                        <xs:annotation>
                            <xs:appinfo>Logical deletion</xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                    <xs:enumeration value="15">
                        <xs:annotation>
                            <xs:appinfo>
                                Permanent erasure / Physical destruction
                            </xs:appinfo>
                        </xs:annotation>
                    </xs:enumeration>
                </xs:restriction>
            </xs:simpleType>
        </xs:attribute>
        <xs:attribute name="ParticipantObjectSensitivity"
                      type="xs:string" use="optional"/>
    </xs:complexType>
    <xs:complexType name="CodedValueType">
        <xs:attribute name="code" type="xs:string" use="required"/>
        <xs:attributeGroup ref="CodeSystem"/>
        <xs:attribute name="displayName" type="xs:string"
                      use="optional"/>
        <xs:attribute name="originalText" type="xs:string"
                      use="optional"/>
    </xs:complexType>
    <xs:complexType name="TypeValuePairType">
        <xs:attribute name="type" type="xs:string" use="required"/>
        <xs:attribute name="value" type="xs:base64Binary"
                      use="required"/>
    </xs:complexType>
    <xs:attributeGroup name="CodeSystem">
        <xs:attribute name="codeSystem" type="OID" use="optional"/>
        <xs:attribute name="codeSystemName" type="xs:string"
                      use="optional"/>
    </xs:attributeGroup>
    <xs:simpleType name="OID">
        <xs:restriction base="xs:string">
            <xs:whiteSpace value="collapse"/>
        </xs:restriction>
    </xs:simpleType>
</xs:schema>
