Skip to content
Partner Developer Portal

Definition

The Audit Patientaudit model records patient audit events and the items identified in those events. It holds date stamps, event and before-event XML, item identifiers and activity-context and mode-type identifiers, together with user-role display information, impersonated-user names and organisation information.

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

audit.patientaudit with audit.activitycontext, audit.itemtype and audit.modetype details

Section titled “audit.patientaudit with audit.activitycontext, audit.itemtype and audit.modetype details”

Return records alongside descriptive values from the related tables.

SELECT
m."patientauditid",
m."activitycontextid",
p1."activitycontextdescription" AS "activitycontextdescription",
m."itemtypeid",
p2."itemtypedescription" AS "itemtypedescription",
m."modetypeid",
p3."description" AS "modetype_description"
FROM audit.patientaudit AS m
LEFT JOIN audit.activitycontext AS p1
ON p1."activitycontextid" = m."activitycontextid"
AND p1."organisation" = m."organisation"
LEFT JOIN audit.itemtype AS p2
ON p2."itemtypeid" = m."itemtypeid"
AND p2."organisation" = m."organisation"
LEFT JOIN audit.modetype AS p3
ON p3."modetypeid" = m."modetypeid"
AND p3."organisation" = m."organisation";

Row count by audit.activitycontext activitycontextdescription

Section titled “Row count by audit.activitycontext activitycontextdescription”

Count audit.patientaudit records for each audit.activitycontext value, joined on activitycontextid.

SELECT
p."activitycontextdescription" AS "activitycontextdescription",
COUNT(*) AS row_count
FROM audit.patientaudit AS m
INNER JOIN audit.activitycontext AS p
ON p."activitycontextid" = m."activitycontextid"
AND p."organisation" = m."organisation"
GROUP BY p."activitycontextdescription"
ORDER BY row_count DESC;

Row count by audit.itemtype itemtypedescription

Section titled “Row count by audit.itemtype itemtypedescription”

Count audit.patientaudit records for each audit.itemtype value, joined on itemtypeid.

SELECT
p."itemtypedescription" AS "itemtypedescription",
COUNT(*) AS row_count
FROM audit.patientaudit AS m
INNER JOIN audit.itemtype AS p
ON p."itemtypeid" = m."itemtypeid"
AND p."organisation" = m."organisation"
GROUP BY p."itemtypedescription"
ORDER BY row_count DESC;