Skip to content
Partner Developer Portal

Definition

The Audit Accessaudit model records access audit events with their date stamps, access-type identifiers and event details. It holds patient, organisation and user-role information, including account and display names, alongside impersonated-user details, session and message identifiers and a MAC-address value.

_deleted indicates whether the record has been deleted in the source system.

audit.accessaudit with audit.accesstype, dbo.organisation and dbo.patient details

Section titled “audit.accessaudit with audit.accesstype, dbo.organisation and dbo.patient details”

Return records alongside descriptive values from the related tables.

SELECT
m."accessauditid",
m."accesstypeid",
p1."accesstypedescription" AS "accesstypedescription",
m."organisationid",
p2."organisationdisplayname" AS "organisationdisplayname",
m."patientid",
p3."displayname" AS "patient_displayname"
FROM audit.accessaudit AS m
LEFT JOIN audit.accesstype AS p1
ON p1."accesstypeid" = m."accesstypeid"
AND p1."organisation" = m."organisation"
LEFT JOIN dbo.organisation AS p2
ON p2."organisationid" = m."organisationid"
AND p2."organisation" = m."organisation"
LEFT JOIN dbo.patient AS p3
ON p3."patientid" = m."patientid"
AND p3."organisation" = m."organisation";

Row count by audit.accesstype accesstypedescription

Section titled “Row count by audit.accesstype accesstypedescription”

Count audit.accessaudit records for each audit.accesstype value, joined on accesstypeid.

SELECT
p."accesstypedescription" AS "accesstypedescription",
COUNT(*) AS row_count
FROM audit.accessaudit AS m
INNER JOIN audit.accesstype AS p
ON p."accesstypeid" = m."accesstypeid"
AND p."organisation" = m."organisation"
GROUP BY p."accesstypedescription"
ORDER BY row_count DESC;

Row count by dbo.organisation organisationdisplayname

Section titled “Row count by dbo.organisation organisationdisplayname”

Count audit.accessaudit records for each dbo.organisation value, joined on organisationid.

SELECT
p."organisationdisplayname" AS "organisationdisplayname",
COUNT(*) AS row_count
FROM audit.accessaudit AS m
INNER JOIN dbo.organisation AS p
ON p."organisationid" = m."organisationid"
AND p."organisation" = m."organisation"
GROUP BY p."organisationdisplayname"
ORDER BY row_count DESC;