<?xml version="1.0" encoding="UTF-8"?>
<!-- 
 * #%L
 * org.hl7.fhir.r5
 * %%
 * Copyright (C) 2014 - 2019 Health Level 7
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */

/*
  Copyright (c) 2011+, HL7, Inc.
  All rights reserved.
  
  Redistribution and use in source and binary forms, with or without modification, 
  are permitted provided that the following conditions are met:
  
   * Redistributions of source code must retain the above copyright notice, this 
     list of conditions and the following disclaimer.
   * Redistributions in binary form must reproduce the above copyright notice, 
     this list of conditions and the following disclaimer in the documentation 
     and/or other materials provided with the distribution.
   * Neither the name of HL7 nor the names of its contributors may be used to 
     endorse or promote products derived from this software without specific 
     prior written permission.
  
  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
  POSSIBILITY OF SUCH DAMAGE.
  

  Generated on Mon, Mar 30, 2026 16:23+0000 for FHIR v6.0.0-ballot4 

  Note: the schemas &amp; schematrons do not contain all of the rules about what makes resources
  valid. Implementers will still need to be familiar with the content of the specification and with
  any profiles that apply to the resources in order to make a conformant implementation.

-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://hl7.org/fhir" xmlns:xhtml="http://www.w3.org/1999/xhtml" targetNamespace="http://hl7.org/fhir" elementFormDefault="qualified" version="1.0">
  <xs:include schemaLocation="fhir-base.xsd"/>
  <xs:element name="AuditEvent" type="AuditEvent">
    <xs:annotation>
      <xs:documentation xml:lang="en">A record of an event relevant for purposes such as operations, privacy, security, maintenance, and performance analysis.</xs:documentation>
    </xs:annotation>
  </xs:element>
  <xs:complexType name="AuditEvent">
    <xs:annotation>
      <xs:documentation xml:lang="en">A record of an event relevant for purposes such as operations, privacy, security, maintenance, and performance analysis.</xs:documentation>
      <xs:documentation xml:lang="en">If the element is present, it must have either a @value, an @id, or extensions</xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="DomainResource">
        <xs:sequence>
          <xs:element name="type" minOccurs="1" maxOccurs="1" type="CodeableConcept">
            <xs:annotation>
              <xs:documentation xml:lang="en">Partitions the audit event into one or more categories that can be used to filter searching, to govern access control and/or to guide system behavior.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:element name="subtype" minOccurs="0" maxOccurs="unbounded" type="CodeableConcept">
            <xs:annotation>
              <xs:documentation xml:lang="en">Describes what happened. The most specific codes for the event.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:element name="action" minOccurs="0" maxOccurs="1" type="AuditEventAction">
            <xs:annotation>
              <xs:documentation xml:lang="en">Indicator for type of action performed during the event that generated the audit.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:element name="severity" minOccurs="0" maxOccurs="1" type="AuditEventSeverity">
            <xs:annotation>
              <xs:documentation xml:lang="en">Indicates and enables segmentation of various severity including debugging from critical.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:choice minOccurs="0" maxOccurs="1" >
            <xs:annotation>
              <xs:documentation xml:lang="en">The time or period during which the activity occurred.</xs:documentation>
            </xs:annotation>
            <xs:element name="occurredPeriod" type="Period"/>
            <xs:element name="occurredDateTime" type="dateTime"/>
          </xs:choice>
          <xs:element name="recorded" minOccurs="1" maxOccurs="1" type="instant">
            <xs:annotation>
              <xs:documentation xml:lang="en">The time when the event was recorded.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:element name="outcome" type="AuditEvent.Outcome" minOccurs="0" maxOccurs="1">
            <xs:annotation>
              <xs:documentation xml:lang="en">Indicates whether the event succeeded or failed. A free text descripiton can be given in outcome.text.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:element name="authorization" minOccurs="0" maxOccurs="unbounded" type="CodeableConcept">
            <xs:annotation>
              <xs:documentation xml:lang="en">The authorization (e.g., PurposeOfUse) that was used during the event being recorded.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:element name="basedOn" minOccurs="0" maxOccurs="unbounded" type="Reference">
            <xs:annotation>
              <xs:documentation xml:lang="en">Allows tracing of authorization for the events and tracking whether proposals/recommendations were acted upon.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:element name="patient" minOccurs="0" maxOccurs="1" type="Reference">
            <xs:annotation>
              <xs:documentation xml:lang="en">The patient element is available to enable deterministic tracking of activities that involve the patient as the subject of the data used in an activity.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:element name="encounter" minOccurs="0" maxOccurs="1" type="Reference">
            <xs:annotation>
              <xs:documentation xml:lang="en">This will typically be the encounter the event occurred, but some events MAY be initiated prior to or after the official completion of an encounter but still be tied to the context of the encounter (e.g. pre-admission lab tests).</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:element name="agent" type="AuditEvent.Agent" minOccurs="1" maxOccurs="unbounded">
            <xs:annotation>
              <xs:documentation xml:lang="en">An actor taking an active role in the event or activity that is logged.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:element name="source" type="AuditEvent.Source" minOccurs="1" maxOccurs="1">
            <xs:annotation>
              <xs:documentation xml:lang="en">The actor that is reporting the event.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:element name="entity" type="AuditEvent.Entity" minOccurs="0" maxOccurs="unbounded">
            <xs:annotation>
              <xs:documentation xml:lang="en">Specific instances of data or objects that have been accessed.</xs:documentation>
           </xs:annotation>
          </xs:element>
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="AuditEvent.Outcome">
    <xs:annotation>
      <xs:documentation xml:lang="en">A record of an event relevant for purposes such as operations, privacy, security, maintenance, and performance analysis.</xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="BackboneElement">
        <xs:sequence>
          <xs:element name="code" minOccurs="1" maxOccurs="1" type="Coding">
            <xs:annotation>
              <xs:documentation xml:lang="en">Indicates whether the event succeeded or failed.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:element name="detail" minOccurs="0" maxOccurs="unbounded" type="CodeableConcept">
            <xs:annotation>
              <xs:documentation xml:lang="en">Additional details about the error. This MAY be a text description of the error or a system code that identifies the error.</xs:documentation>
           </xs:annotation>
          </xs:element>
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="AuditEvent.Agent">
    <xs:annotation>
      <xs:documentation xml:lang="en">A record of an event relevant for purposes such as operations, privacy, security, maintenance, and performance analysis.</xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="BackboneElement">
        <xs:sequence>
          <xs:element name="type" minOccurs="0" maxOccurs="1" type="CodeableConcept">
            <xs:annotation>
              <xs:documentation xml:lang="en">The Functional Role of the user when performing the event.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:element name="role" minOccurs="0" maxOccurs="unbounded" type="CodeableConcept">
            <xs:annotation>
              <xs:documentation xml:lang="en">The structural roles of the agent indicating the agent's competency. The security role enabling the agent with respect to the activity.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:element name="who" minOccurs="1" maxOccurs="1" type="Reference">
            <xs:annotation>
              <xs:documentation xml:lang="en">Reference to who this agent is that was involved in the event.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:element name="requestor" minOccurs="0" maxOccurs="1" type="boolean">
            <xs:annotation>
              <xs:documentation xml:lang="en">Indicator that the user is or is not the requestor, or initiator, for the event being audited.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:element name="location" minOccurs="0" maxOccurs="1" type="Reference">
            <xs:annotation>
              <xs:documentation xml:lang="en">Where the agent location is known, the agent location when the event occurred.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:element name="policy" minOccurs="0" maxOccurs="unbounded" type="uri">
            <xs:annotation>
              <xs:documentation xml:lang="en">Where the policy(ies) are known that authorized the agent participation in the event. Typically, a single activity MAY have multiple applicable policies, such as patient consent, guarantor funding, etc. The policy would also indicate the security token used.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:choice minOccurs="0" maxOccurs="1" >
            <xs:annotation>
              <xs:documentation xml:lang="en">When the event utilizes a network there SHOULD be an agent describing the local system, and an agent describing remote system, with the network interface details.</xs:documentation>
            </xs:annotation>
            <xs:element name="networkReference" type="Reference"/>
            <xs:element name="networkUri" type="uri"/>
            <xs:element name="networkString" type="string"/>
          </xs:choice>
          <xs:element name="authorization" minOccurs="0" maxOccurs="unbounded" type="CodeableConcept">
            <xs:annotation>
              <xs:documentation xml:lang="en">The authorization (e.g., PurposeOfUse) that was used during the event being recorded.</xs:documentation>
           </xs:annotation>
          </xs:element>
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="AuditEvent.Source">
    <xs:annotation>
      <xs:documentation xml:lang="en">A record of an event relevant for purposes such as operations, privacy, security, maintenance, and performance analysis.</xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="BackboneElement">
        <xs:sequence>
          <xs:element name="site" minOccurs="0" maxOccurs="1" type="Reference">
            <xs:annotation>
              <xs:documentation xml:lang="en">Logical source location within the healthcare enterprise network.  For example, a hospital or other provider location within a multi-entity provider group.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:element name="observer" minOccurs="1" maxOccurs="1" type="Reference">
            <xs:annotation>
              <xs:documentation xml:lang="en">Identifier of the source where the event was detected.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:element name="type" minOccurs="0" maxOccurs="unbounded" type="CodeableConcept">
            <xs:annotation>
              <xs:documentation xml:lang="en">Code specifying the type of source where event originated.</xs:documentation>
           </xs:annotation>
          </xs:element>
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="AuditEvent.Entity">
    <xs:annotation>
      <xs:documentation xml:lang="en">A record of an event relevant for purposes such as operations, privacy, security, maintenance, and performance analysis.</xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="BackboneElement">
        <xs:sequence>
          <xs:element name="what" minOccurs="0" maxOccurs="1" type="Reference">
            <xs:annotation>
              <xs:documentation xml:lang="en">Identifies a specific instance of the entity. The reference SHOULD be version specific. This is allowed to be a Parameters resource.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:element name="role" minOccurs="0" maxOccurs="1" type="CodeableConcept">
            <xs:annotation>
              <xs:documentation xml:lang="en">Code representing the role the entity played in the event being audited.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:element name="securityLabel" minOccurs="0" maxOccurs="unbounded" type="CodeableConcept">
            <xs:annotation>
              <xs:documentation xml:lang="en">Security labels for the identified entity.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:element name="description" minOccurs="0" maxOccurs="1" type="string">
            <xs:annotation>
              <xs:documentation xml:lang="en">Text that describes the entity in more detail.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:element name="query" minOccurs="0" maxOccurs="1" type="base64Binary">
            <xs:annotation>
              <xs:documentation xml:lang="en">The query parameters for a query-type entities.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:element name="detail" type="AuditEvent.Detail" minOccurs="0" maxOccurs="unbounded">
            <xs:annotation>
              <xs:documentation xml:lang="en">Tagged value pairs for conveying additional information about the entity.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:element name="agent" type="AuditEvent.Agent" minOccurs="0" maxOccurs="unbounded">
            <xs:annotation>
              <xs:documentation xml:lang="en">The entity is attributed to an agent to express the agent's responsibility for that entity in the activity. This is most used to indicate when persistence media (the entity) are used by an agent. For example when importing data from a device, the device would be described in an entity, and the user importing data from that media would be indicated as the entity.agent.</xs:documentation>
           </xs:annotation>
          </xs:element>
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="AuditEvent.Detail">
    <xs:annotation>
      <xs:documentation xml:lang="en">A record of an event relevant for purposes such as operations, privacy, security, maintenance, and performance analysis.</xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="BackboneElement">
        <xs:sequence>
          <xs:element name="type" minOccurs="1" maxOccurs="1" type="CodeableConcept">
            <xs:annotation>
              <xs:documentation xml:lang="en">The name of extra detail provided in the value. This element is the tag for the value. Where a simple string is used for the tag name, use the CodeableConcept.display element.</xs:documentation>
           </xs:annotation>
          </xs:element>
          <xs:choice minOccurs="1" maxOccurs="1" >
            <xs:annotation>
              <xs:documentation xml:lang="en">The  value of the extra detail.</xs:documentation>
            </xs:annotation>
            <xs:element name="valueQuantity" type="Quantity"/>
            <xs:element name="valueCodeableConcept" type="CodeableConcept"/>
            <xs:element name="valueString" type="string"/>
            <xs:element name="valueBoolean" type="boolean"/>
            <xs:element name="valueInteger" type="integer"/>
            <xs:element name="valueRange" type="Range"/>
            <xs:element name="valueRatio" type="Ratio"/>
            <xs:element name="valueTime" type="time"/>
            <xs:element name="valueDateTime" type="dateTime"/>
            <xs:element name="valuePeriod" type="Period"/>
            <xs:element name="valueBase64Binary" type="base64Binary"/>
          </xs:choice>
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:simpleType name="AuditEventActionEnum">
    <xs:restriction base="code-primitive">
      <xs:enumeration value="C">
        <xs:annotation>
          <xs:documentation xml:lang="en">Create</xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="R">
        <xs:annotation>
          <xs:documentation xml:lang="en">Read</xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="U">
        <xs:annotation>
          <xs:documentation xml:lang="en">Update</xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="D">
        <xs:annotation>
          <xs:documentation xml:lang="en">Delete</xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="E">
        <xs:annotation>
          <xs:documentation xml:lang="en">Execute</xs:documentation>
        </xs:annotation>
      </xs:enumeration>
    </xs:restriction>
  </xs:simpleType>
  <xs:complexType name="AuditEventAction">
    <xs:annotation>
      <xs:documentation xml:lang="en">Indicator for type of action performed during the event that generated the event.</xs:documentation>
      <xs:documentation xml:lang="en">If the element is present, it must have either a @value, an @id, or extensions</xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="Element">
        <xs:attribute name="value" type="AuditEventActionEnum" use="optional"/>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  <xs:simpleType name="AuditEventSeverityEnum">
    <xs:restriction base="code-primitive">
      <xs:enumeration value="emergency">
        <xs:annotation>
          <xs:documentation xml:lang="en">Emergency</xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="alert">
        <xs:annotation>
          <xs:documentation xml:lang="en">Alert</xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="critical">
        <xs:annotation>
          <xs:documentation xml:lang="en">Critical</xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="error">
        <xs:annotation>
          <xs:documentation xml:lang="en">Error</xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="warning">
        <xs:annotation>
          <xs:documentation xml:lang="en">Warning</xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="notice">
        <xs:annotation>
          <xs:documentation xml:lang="en">Notice</xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="informational">
        <xs:annotation>
          <xs:documentation xml:lang="en">Informational</xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="debug">
        <xs:annotation>
          <xs:documentation xml:lang="en">Debug</xs:documentation>
        </xs:annotation>
      </xs:enumeration>
    </xs:restriction>
  </xs:simpleType>
  <xs:complexType name="AuditEventSeverity">
    <xs:annotation>
      <xs:documentation xml:lang="en">The severity of the audit entry.</xs:documentation>
      <xs:documentation xml:lang="en">If the element is present, it must have either a @value, an @id, or extensions</xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="Element">
        <xs:attribute name="value" type="AuditEventSeverityEnum" use="optional"/>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
</xs:schema>
