<?xml version="1.0" encoding="UTF-8"?>
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
  <sch:ns prefix="f" uri="http://hl7.org/fhir"/>
  <sch:ns prefix="h" uri="http://www.w3.org/1999/xhtml"/>
  <!-- 
    This file contains just the constraints for the profile AuditEvent
    It includes the base constraints for the resource as well.
    Because of the way that schematrons and containment work, 
    you may need to use this schematron fragment to build a, 
    single schematron that validates contained resources (if you have any) 
  -->
  <sch:pattern>
    <sch:title>f:AuditEvent</sch:title>
    <sch:rule context="f:AuditEvent">
      <sch:assert test="count(f:extension[@url = 'http://hl7.org/fhir/4.0/StructureDefinition/extension-AuditEvent.period|0.1.0']) &lt;= 1">extension with URL = 'http://hl7.org/fhir/4.0/StructureDefinition/extension-AuditEvent.period|0.1.0': maximum cardinality of 'extension' is 1</sch:assert>
      <sch:assert test="count(f:extension[@url = 'http://hl7.org/fhir/4.0/StructureDefinition/extension-AuditEvent.outcomeDesc|0.1.0']) &lt;= 1">extension with URL = 'http://hl7.org/fhir/4.0/StructureDefinition/extension-AuditEvent.outcomeDesc|0.1.0': maximum cardinality of 'extension' is 1</sch:assert>
    </sch:rule>
  </sch:pattern>
  <sch:pattern>
    <sch:title>f:AuditEvent/f:outcome/f:code</sch:title>
    <sch:rule context="f:AuditEvent/f:outcome/f:code">
      <sch:assert test="count(f:id) &lt;= 1">id: maximum cardinality of 'id' is 1</sch:assert>
      <sch:assert test="count(f:extension[@url = 'http://hl7.org/fhir/4.0/StructureDefinition/extension-AuditEvent.outcome|0.1.0']) &lt;= 1">extension with URL = 'http://hl7.org/fhir/4.0/StructureDefinition/extension-AuditEvent.outcome|0.1.0': maximum cardinality of 'extension' is 1</sch:assert>
      <sch:assert test="count(f:system) &lt;= 1">system: maximum cardinality of 'system' is 1</sch:assert>
      <sch:assert test="count(f:version) &lt;= 1">version: maximum cardinality of 'version' is 1</sch:assert>
      <sch:assert test="count(f:code) &lt;= 1">code: maximum cardinality of 'code' is 1</sch:assert>
      <sch:assert test="count(f:display) &lt;= 1">display: maximum cardinality of 'display' is 1</sch:assert>
      <sch:assert test="count(f:userSelected) &lt;= 1">userSelected: maximum cardinality of 'userSelected' is 1</sch:assert>
    </sch:rule>
  </sch:pattern>
  <sch:pattern>
    <sch:title>f:AuditEvent/f:agent</sch:title>
    <sch:rule context="f:AuditEvent/f:agent">
      <sch:assert test="count(f:extension[@url = 'http://hl7.org/fhir/4.0/StructureDefinition/extension-AuditEvent.agent.altId|0.1.0']) &lt;= 1">extension with URL = 'http://hl7.org/fhir/4.0/StructureDefinition/extension-AuditEvent.agent.altId|0.1.0': maximum cardinality of 'extension' is 1</sch:assert>
      <sch:assert test="count(f:extension[@url = 'http://hl7.org/fhir/4.0/StructureDefinition/extension-AuditEvent.agent.name|0.1.0']) &lt;= 1">extension with URL = 'http://hl7.org/fhir/4.0/StructureDefinition/extension-AuditEvent.agent.name|0.1.0': maximum cardinality of 'extension' is 1</sch:assert>
      <sch:assert test="count(f:extension[@url = 'http://hl7.org/fhir/4.0/StructureDefinition/extension-AuditEvent.agent.media|0.1.0']) &lt;= 1">extension with URL = 'http://hl7.org/fhir/4.0/StructureDefinition/extension-AuditEvent.agent.media|0.1.0': maximum cardinality of 'extension' is 1</sch:assert>
      <sch:assert test="count(f:extension[@url = 'http://hl7.org/fhir/4.0/StructureDefinition/extension-AuditEvent.agent.network.address|0.1.0']) &lt;= 1">extension with URL = 'http://hl7.org/fhir/4.0/StructureDefinition/extension-AuditEvent.agent.network.address|0.1.0': maximum cardinality of 'extension' is 1</sch:assert>
      <sch:assert test="count(f:extension[@url = 'http://hl7.org/fhir/4.0/StructureDefinition/extension-AuditEvent.agent.network.type|0.1.0']) &lt;= 1">extension with URL = 'http://hl7.org/fhir/4.0/StructureDefinition/extension-AuditEvent.agent.network.type|0.1.0': maximum cardinality of 'extension' is 1</sch:assert>
    </sch:rule>
  </sch:pattern>
  <sch:pattern>
    <sch:title>f:AuditEvent/f:source/f:site</sch:title>
    <sch:rule context="f:AuditEvent/f:source/f:site">
      <sch:assert test="count(f:id) &lt;= 1">id: maximum cardinality of 'id' is 1</sch:assert>
      <sch:assert test="count(f:extension[@url = 'http://hl7.org/fhir/4.0/StructureDefinition/extension-AuditEvent.source.site|0.1.0']) &lt;= 1">extension with URL = 'http://hl7.org/fhir/4.0/StructureDefinition/extension-AuditEvent.source.site|0.1.0': maximum cardinality of 'extension' is 1</sch:assert>
      <sch:assert test="count(f:reference) &lt;= 1">reference: maximum cardinality of 'reference' is 1</sch:assert>
      <sch:assert test="count(f:type) &lt;= 1">type: maximum cardinality of 'type' is 1</sch:assert>
      <sch:assert test="count(f:identifier) &lt;= 1">identifier: maximum cardinality of 'identifier' is 1</sch:assert>
      <sch:assert test="count(f:display) &lt;= 1">display: maximum cardinality of 'display' is 1</sch:assert>
    </sch:rule>
  </sch:pattern>
  <sch:pattern>
    <sch:title>f:AuditEvent/f:entity</sch:title>
    <sch:rule context="f:AuditEvent/f:entity">
      <sch:assert test="count(f:extension[@url = 'http://hl7.org/fhir/4.0/StructureDefinition/extension-AuditEvent.entity.type|0.1.0']) &lt;= 1">extension with URL = 'http://hl7.org/fhir/4.0/StructureDefinition/extension-AuditEvent.entity.type|0.1.0': maximum cardinality of 'extension' is 1</sch:assert>
      <sch:assert test="count(f:extension[@url = 'http://hl7.org/fhir/4.0/StructureDefinition/extension-AuditEvent.entity.lifecycle|0.1.0']) &lt;= 1">extension with URL = 'http://hl7.org/fhir/4.0/StructureDefinition/extension-AuditEvent.entity.lifecycle|0.1.0': maximum cardinality of 'extension' is 1</sch:assert>
      <sch:assert test="count(f:extension[@url = 'http://hl7.org/fhir/4.0/StructureDefinition/extension-AuditEvent.entity.name|0.1.0']) &lt;= 1">extension with URL = 'http://hl7.org/fhir/4.0/StructureDefinition/extension-AuditEvent.entity.name|0.1.0': maximum cardinality of 'extension' is 1</sch:assert>
      <sch:assert test="count(f:extension[@url = 'http://hl7.org/fhir/4.0/StructureDefinition/extension-AuditEvent.entity.description|0.1.0']) &lt;= 1">extension with URL = 'http://hl7.org/fhir/4.0/StructureDefinition/extension-AuditEvent.entity.description|0.1.0': maximum cardinality of 'extension' is 1</sch:assert>
    </sch:rule>
  </sch:pattern>
  <sch:pattern>
    <sch:title>f:AuditEvent/f:entity/f:detail/f:type</sch:title>
    <sch:rule context="f:AuditEvent/f:entity/f:detail/f:type">
      <sch:assert test="count(f:id) &lt;= 1">id: maximum cardinality of 'id' is 1</sch:assert>
      <sch:assert test="count(f:extension[@url = 'http://hl7.org/fhir/4.0/StructureDefinition/extension-AuditEvent.entity.detail.type|0.1.0']) &gt;= 1">extension with URL = 'http://hl7.org/fhir/4.0/StructureDefinition/extension-AuditEvent.entity.detail.type|0.1.0': minimum cardinality of 'extension' is 1</sch:assert>
      <sch:assert test="count(f:extension[@url = 'http://hl7.org/fhir/4.0/StructureDefinition/extension-AuditEvent.entity.detail.type|0.1.0']) &lt;= 1">extension with URL = 'http://hl7.org/fhir/4.0/StructureDefinition/extension-AuditEvent.entity.detail.type|0.1.0': maximum cardinality of 'extension' is 1</sch:assert>
      <sch:assert test="count(f:text) &lt;= 1">text: maximum cardinality of 'text' is 1</sch:assert>
    </sch:rule>
  </sch:pattern>
</sch:schema>
