{
  "resourceType": "StructureDefinition",
  "id": "sgrdv-audit-event",
  "url": "http://sante.quebec/fhir/StructureDefinition/sgrdv-audit-event",
  "name": "SGRDVAuditEvent",
  "title": "Événement d'audit SGRDV",
  "status": "draft",
  "experimental": true,
  "description": "Profil unique d'AuditEvent pour les journaux d'audit affaire SGRDV. Porte la direction (extension dédiée), le type de transaction (find, lock, aggregate), les agents source et destination (références vers des SGRDVAuditAgent dans le même Bundle) et la référence au payload de la transaction. Conforme à ADR-016 (Bundle collection auto-portant) et ADR-017 (profil unique avec direction en extension).",
  "fhirVersion": "4.0.1",
  "kind": "resource",
  "abstract": false,
  "type": "AuditEvent",
  "baseDefinition": "http://hl7.org/fhir/StructureDefinition/AuditEvent",
  "derivation": "constraint",
  "differential": {
    "element": [
      {
        "id": "AuditEvent.extension",
        "path": "AuditEvent.extension",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "url"
            }
          ],
          "ordered": false,
          "rules": "open"
        },
        "min": 1
      },
      {
        "id": "AuditEvent.extension:direction",
        "path": "AuditEvent.extension",
        "sliceName": "direction",
        "min": 1,
        "max": "1",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "http://sante.quebec/fhir/StructureDefinition/sgrdv-audit-direction-extension"
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "AuditEvent.extension:direction.value[x]",
        "path": "AuditEvent.extension.value[x]",
        "mustSupport": true
      },
      {
        "id": "AuditEvent.type",
        "path": "AuditEvent.type",
        "mustSupport": true
      },
      {
        "id": "AuditEvent.type.system",
        "path": "AuditEvent.type.system",
        "fixedUri": "http://sante.quebec/fhir/CodeSystem/sgrdv-audit-transaction-type"
      },
      {
        "id": "AuditEvent.type.code",
        "path": "AuditEvent.type.code",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "AuditEvent.action",
        "path": "AuditEvent.action",
        "min": 1,
        "fixedCode": "E",
        "mustSupport": true
      },
      {
        "id": "AuditEvent.recorded",
        "path": "AuditEvent.recorded",
        "mustSupport": true
      },
      {
        "id": "AuditEvent.outcome",
        "path": "AuditEvent.outcome",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "AuditEvent.agent",
        "path": "AuditEvent.agent",
        "slicing": {
          "discriminator": [
            {
              "type": "pattern",
              "path": "type"
            }
          ],
          "rules": "open"
        },
        "min": 2,
        "mustSupport": true
      },
      {
        "id": "AuditEvent.agent:source",
        "path": "AuditEvent.agent",
        "sliceName": "source",
        "min": 1,
        "max": "1",
        "mustSupport": true
      },
      {
        "id": "AuditEvent.agent:source.type",
        "path": "AuditEvent.agent.type",
        "min": 1,
        "patternCodeableConcept": {
          "coding": [
            {
              "code": "source",
              "system": "http://sante.quebec/fhir/CodeSystem/sgrdv-audit-agent-type"
            }
          ]
        },
        "mustSupport": true
      },
      {
        "id": "AuditEvent.agent:source.who",
        "path": "AuditEvent.agent.who",
        "min": 1,
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://sante.quebec/fhir/StructureDefinition/sgrdv-audit-agent"
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "AuditEvent.agent:source.who.reference",
        "path": "AuditEvent.agent.who.reference",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "AuditEvent.agent:source.requestor",
        "path": "AuditEvent.agent.requestor",
        "mustSupport": true
      },
      {
        "id": "AuditEvent.agent:destination",
        "path": "AuditEvent.agent",
        "sliceName": "destination",
        "min": 1,
        "max": "1",
        "mustSupport": true
      },
      {
        "id": "AuditEvent.agent:destination.type",
        "path": "AuditEvent.agent.type",
        "min": 1,
        "patternCodeableConcept": {
          "coding": [
            {
              "code": "destination",
              "system": "http://sante.quebec/fhir/CodeSystem/sgrdv-audit-agent-type"
            }
          ]
        },
        "mustSupport": true
      },
      {
        "id": "AuditEvent.agent:destination.who",
        "path": "AuditEvent.agent.who",
        "min": 1,
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://sante.quebec/fhir/StructureDefinition/sgrdv-audit-agent"
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "AuditEvent.agent:destination.who.reference",
        "path": "AuditEvent.agent.who.reference",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "AuditEvent.agent:destination.requestor",
        "path": "AuditEvent.agent.requestor",
        "mustSupport": true
      },
      {
        "id": "AuditEvent.source",
        "path": "AuditEvent.source",
        "mustSupport": true
      },
      {
        "id": "AuditEvent.source.observer",
        "path": "AuditEvent.source.observer",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://sante.quebec/fhir/StructureDefinition/sgrdv-audit-agent"
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "AuditEvent.source.observer.reference",
        "path": "AuditEvent.source.observer.reference",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "AuditEvent.entity",
        "path": "AuditEvent.entity",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "type.code"
            }
          ],
          "rules": "open"
        },
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "AuditEvent.entity:payload",
        "path": "AuditEvent.entity",
        "sliceName": "payload",
        "min": 1,
        "max": "1",
        "mustSupport": true
      },
      {
        "id": "AuditEvent.entity:payload.what",
        "path": "AuditEvent.entity.what",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "AuditEvent.entity:payload.what.reference",
        "path": "AuditEvent.entity.what.reference",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "AuditEvent.entity:payload.type",
        "path": "AuditEvent.entity.type",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "AuditEvent.entity:payload.type.code",
        "path": "AuditEvent.entity.type.code",
        "min": 1,
        "patternCode": "payload"
      }
    ]
  }
}