Skip to content
Partner Developer Portal

Definition

The Audit Careraudit model records carer audit events associated with patient associates. It holds date stamps, event and before-event XML, activity-context and mode-type identifiers, and a carer-lock flag, 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.careraudit with audit.activitycontext, audit.modetype and dbo.patientassociate details

Section titled “audit.careraudit with audit.activitycontext, audit.modetype and dbo.patientassociate details”

Return records alongside descriptive values from the related tables.

SELECT
m."carerauditid",
m."activitycontextid",
p1."activitycontextdescription" AS "activitycontextdescription",
m."modetypeid",
p2."description" AS "modetype_description",
m."patientassociateid",
p3."displayname" AS "patientassociate_displayname"
FROM audit.careraudit AS m
LEFT JOIN audit.activitycontext AS p1
ON p1."activitycontextid" = m."activitycontextid"
AND p1."organisation" = m."organisation"
LEFT JOIN audit.modetype AS p2
ON p2."modetypeid" = m."modetypeid"
AND p2."organisation" = m."organisation"
LEFT JOIN dbo.patientassociate AS p3
ON p3."patientassociateid" = m."patientassociateid"
AND p3."organisation" = m."organisation";

Row count by audit.activitycontext activitycontextdescription

Section titled “Row count by audit.activitycontext activitycontextdescription”

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

SELECT
p."activitycontextdescription" AS "activitycontextdescription",
COUNT(*) AS row_count
FROM audit.careraudit 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;

Count audit.careraudit records for each audit.modetype value, joined on modetypeid.

SELECT
p."description" AS "modetype_description",
COUNT(*) AS row_count
FROM audit.careraudit AS m
INNER JOIN audit.modetype AS p
ON p."modetypeid" = m."modetypeid"
AND p."organisation" = m."organisation"
GROUP BY p."description"
ORDER BY row_count DESC;