Skip to content
Partner Developer Portal

Definition

The Carerecord Problemdeletionhistory model records patient problem deletion history, including the action, reason, timestamp and user-in-role identifier. It also holds deleted-problem and corrected-problem information in XML and a correction-code identifier, together with identifiers for the patient and history record.

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

carerecord.problemdeletionhistory with dbo.patient and dbo.userinrole details

Section titled “carerecord.problemdeletionhistory with dbo.patient and dbo.userinrole details”

Return records alongside descriptive values from the related tables.

SELECT
m."problemdeletionhistoryid",
m."patientid",
p1."displayname" AS "patient_displayname",
m."userinroleid",
p2."contractualrelationship" AS "userinrole_contractualrelationship"
FROM carerecord.problemdeletionhistory AS m
LEFT JOIN dbo.patient AS p1
ON p1."patientid" = m."patientid"
AND p1."organisation" = m."organisation"
LEFT JOIN dbo.userinrole AS p2
ON p2."userinroleid" = m."userinroleid"
AND p2."organisation" = m."organisation";

Count carerecord.problemdeletionhistory records for each dbo.patient value, joined on patientid.

SELECT
p."displayname" AS "patient_displayname",
COUNT(*) AS row_count
FROM carerecord.problemdeletionhistory AS m
INNER JOIN dbo.patient AS p
ON p."patientid" = m."patientid"
AND p."organisation" = m."organisation"
GROUP BY p."displayname"
ORDER BY row_count DESC;

Row count by dbo.userinrole contractualrelationship

Section titled “Row count by dbo.userinrole contractualrelationship”

Count carerecord.problemdeletionhistory records for each dbo.userinrole value, joined on userinroleid.

SELECT
p."contractualrelationship" AS "userinrole_contractualrelationship",
COUNT(*) AS row_count
FROM carerecord.problemdeletionhistory AS m
INNER JOIN dbo.userinrole AS p
ON p."userinroleid" = m."userinroleid"
AND p."organisation" = m."organisation"
GROUP BY p."contractualrelationship"
ORDER BY row_count DESC;