<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="nl-vzvz-AuditEvent" />
  <language value="nl-NL" />
  <url value="http://vzvz.nl/fhir/StructureDefinition/nl-vzvz-AuditEvent" />
  <version value="4.0.0-beta.1" />
  <name value="NlVzvzAuditEvent" />
  <status value="draft" />
  <publisher value="VZVZ" />
  <contact>
    <name value="VZVZ" />
    <telecom>
      <system value="email" />
      <value value="standaardisatie@vzvz.nl" />
      <use value="work" />
    </telecom>
  </contact>
  <description value="AuditEvent as used by VZVZ to exchange information on logged activities" />
  <jurisdiction>
    <coding>
      <system value="urn:iso:std:iso:3166" />
      <code value="NL" />
      <display value="Netherlands" />
    </coding>
  </jurisdiction>
  <copyright value="VZVZ" />
  <fhirVersion value="4.0.1" />
  <kind value="resource" />
  <abstract value="false" />
  <type value="AuditEvent" />
  <baseDefinition value="http://hl7.org/fhir/StructureDefinition/AuditEvent" />
  <derivation value="constraint" />
  <differential>
    <element id="AuditEvent.extension:requestId">
      <path value="AuditEvent.extension" />
      <sliceName value="requestId" />
      <short value="id of the request that resulted in this AuditEvent" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="Extension" />
        <profile value="http://vzvz.nl/fhir/StructureDefinition/request-id" />
      </type>
    </element>
    <element id="AuditEvent.extension:traceId">
      <path value="AuditEvent.extension" />
      <sliceName value="traceId" />
      <short value="overarching id for the entire transaction" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="Extension" />
        <profile value="http://vzvz.nl/fhir/StructureDefinition/trace-id" />
      </type>
    </element>
    <element id="AuditEvent.type">
      <path value="AuditEvent.type" />
      <example>
        <label value="FHIR based" />
        <valueCoding>
          <system value="http://terminology.hl7.org/CodeSystem/audit-event-type" />
          <code value="rest" />
        </valueCoding>
      </example>
      <example>
        <label value="v3 based" />
        <valueCoding>
          <system value="http://terminology.hl7.org/CodeSystem/audit-event-type" />
          <code value="hl7-v3" />
        </valueCoding>
      </example>
      <binding>
        <strength value="extensible" />
        <valueSet value="http://vzvz.nl/fhir/ValueSet/audit-event-type" />
      </binding>
    </element>
    <element id="AuditEvent.subtype">
      <path value="AuditEvent.subtype" />
      <comment value="Only used for FHIR events, not used for V3 events." />
      <example>
        <label value="FHIR based" />
        <valueCoding>
          <system value="http://hl7.org/fhir/restful-interaction" />
          <code value="search" />
        </valueCoding>
      </example>
      <example>
        <label value="V3 based" />
        <valueCoding>
          <system value="http://terminology.hl7.org/CodeSystem/audit-event-type" />
          <code value="hl7-v3" />
        </valueCoding>
      </example>
      <binding>
        <strength value="extensible" />
        <valueSet value="http://vzvz.nl/fhir/ValueSet/audit-event-sub-type" />
      </binding>
    </element>
    <element id="AuditEvent.action">
      <path value="AuditEvent.action" />
      <example>
        <label value="FHIR based" />
        <valueCode value="R" />
      </example>
      <example>
        <label value="V3 based" />
        <valueCode value="E" />
      </example>
    </element>
    <element id="AuditEvent.period">
      <path value="AuditEvent.period" />
      <comment value="start = timestamp of request sent&#xD;&#xA;end = timestamp of response received&#xD;&#xA;precision should be at least milliseconds, timezone required" />
      <example>
        <label value="Example" />
        <valuePeriod>
          <start value="2023-09-15T11:38:03.123+02:00" />
          <end value="2023-09-15T11:38:03.600+02:00" />
        </valuePeriod>
      </example>
    </element>
    <element id="AuditEvent.recorded">
      <path value="AuditEvent.recorded" />
      <definition value="The time when the event was recorded. - NEN 7513 7.2-3" />
      <comment value="time precision at least seconds, timezone mandatory" />
      <example>
        <label value="Example" />
        <valueInstant value="2023-09-15T11:38:03+02:00" />
      </example>
    </element>
    <element id="AuditEvent.outcome">
      <path value="AuditEvent.outcome" />
      <comment value="also add value on success (= 0)" />
      <example>
        <label value="FHIR based - HTTP 5xxx" />
        <valueCode value="8" />
      </example>
      <example>
        <label value="V3 based - CE" />
        <valueCode value="4" />
      </example>
    </element>
    <element id="AuditEvent.outcomeDesc">
      <path value="AuditEvent.outcomeDesc" />
      <definition value="A free text description of the outcome of the event. Human readable message containing HTTP response code, description of result or message, include description of problem (e.g. RTEDEST)" />
    </element>
    <element id="AuditEvent.agent">
      <path value="AuditEvent.agent" />
      <comment value="There are at least one agent referring to the source of the event and one agent referring to the destination of the event. Optionally a third agent refers to the patient that is either the initiator of the event and/or the subject." />
    </element>
    <element id="AuditEvent.agent.type">
      <path value="AuditEvent.agent.type" />
      <comment value="The type is required, to indicate if this agent instance defines the source, the destination or the patient." />
      <example>
        <label value="Source" />
        <valueCodeableConcept>
          <coding>
            <system value="http://dicom.nema.org/resources/ontology/DCM" />
            <code value="110153" />
            <display value="Source Role ID" />
          </coding>
        </valueCodeableConcept>
      </example>
      <example>
        <label value="Destination" />
        <valueCodeableConcept>
          <coding>
            <system value="http://dicom.nema.org/resources/ontology/DCM" />
            <code value="110152" />
            <display value="Destination Role ID" />
          </coding>
        </valueCodeableConcept>
      </example>
      <example>
        <label value="Patient" />
        <valueCodeableConcept>
          <coding>
            <system value="http://terminology.hl7.org/CodeSystem/v3-RoleClass" />
            <code value="PAT" />
          </coding>
        </valueCodeableConcept>
      </example>
      <binding>
        <strength value="extensible" />
        <valueSet value="http://vzvz.nl/fhir/ValueSet/participation-role-type" />
      </binding>
    </element>
    <element id="AuditEvent.agent.who">
      <path value="AuditEvent.agent.who" />
      <definition value="Reference to the device or the patient involved in the event. Add the patient always as the subject of the event and indicate if the patient is the requestor." />
      <comment value="This element refers to either a Device or a Patient resource. These resources should be included in the instance as contained resources." />
    </element>
    <element id="AuditEvent.agent.name">
      <path value="AuditEvent.agent.name" />
      <comment value="Not used in VZVZ" />
    </element>
    <element id="AuditEvent.agent.requestor">
      <path value="AuditEvent.agent.requestor" />
      <definition value="Indicator that the user is or is not the requestor, or initiator, for the event being audited. Note that a user can be a person or a device." />
      <comment value="There can only be one initiator. If the initiator is not clear, then do not choose any one agent as the initiator.&#xD;&#xA;Use 'true' for the source and 'false' for the destination." />
      <example>
        <label value="Source" />
        <valueBoolean value="true" />
      </example>
      <example>
        <label value="Destination" />
        <valueBoolean value="false" />
      </example>
      <example>
        <label value="Patient as initiator" />
        <valueBoolean value="true" />
      </example>
      <example>
        <label value="Patient as subject only" />
        <valueBoolean value="false" />
      </example>
    </element>
    <element id="AuditEvent.agent.network">
      <path value="AuditEvent.agent.network" />
      <comment value="Usually used to describe the endpoint for a notification" />
    </element>
    <element id="AuditEvent.agent.network.address">
      <path value="AuditEvent.agent.network.address" />
      <min value="1" />
    </element>
    <element id="AuditEvent.agent.network.type">
      <path value="AuditEvent.agent.network.type" />
      <comment value="Usually set to 'URI'" />
      <min value="1" />
    </element>
    <element id="AuditEvent.source.observer">
      <path value="AuditEvent.source.observer" />
      <comment value="The resource this element refers to should be added as contained resource" />
    </element>
    <element id="AuditEvent.entity">
      <path value="AuditEvent.entity" />
      <definition value="Specific instances of data or objects that have been accessed. - NEN object" />
    </element>
    <element id="AuditEvent.entity.what">
      <path value="AuditEvent.entity.what" />
      <definition value="Identifies a specific instance of the entity. The reference should be version specific. Only relevant for FHIR events." />
    </element>
    <element id="AuditEvent.entity.query">
      <path value="AuditEvent.entity.query" />
      <definition value="Use this element to always record the full url, regardless of the action&#xD;&#xA;- base url: if available&#xD;&#xA;- resource or /&#xD;&#xA;- parameters (incl. operations) if applicable" />
    </element>
  </differential>
</StructureDefinition>