Skip to content
Partner Developer Portal

Definition

The Episodemanagement Carecontact model records patient care contacts, including contact timing, duration, type and attendance status. It also holds appointment offers and replacement offers, cancellation details, earliest recorded offer dates and a first-definitive-treatment flag, alongside episode, consultation, referral and RTT-status identifiers.

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

episodemanagement.carecontact with carerecord.consultation, dbo.organisation and dbo.patient details

Section titled “episodemanagement.carecontact with carerecord.consultation, dbo.organisation and dbo.patient details”

Return records alongside descriptive values from the related tables.

SELECT
m."carecontactid",
m."consultationid",
p1."consultationpurposeoriginalterm" AS "consultationpurposeoriginalterm",
m."organisationid",
p2."organisationdisplayname" AS "organisationdisplayname",
m."patientid",
p3."displayname" AS "patient_displayname"
FROM episodemanagement.carecontact AS m
LEFT JOIN carerecord.consultation AS p1
ON p1."consultationid" = m."consultationid"
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";

appointment.slothistory count per episodemanagement.carecontact

Section titled “appointment.slothistory count per episodemanagement.carecontact”

Count related appointment.slothistory records for each episodemanagement.carecontact record, joined on carecontactid.

SELECT
m."carecontactid",
m."cancellationdate",
COUNT(c."carecontactid") AS slothistory_count
FROM episodemanagement.carecontact AS m
LEFT JOIN appointment.slothistory AS c
ON m."carecontactid" = c."carecontactid"
AND m."organisation" = c."organisation"
GROUP BY m."carecontactid", m."cancellationdate"
ORDER BY slothistory_count DESC;

Row count by carerecord.consultation consultationpurposeoriginalterm

Section titled “Row count by carerecord.consultation consultationpurposeoriginalterm”

Count episodemanagement.carecontact records for each carerecord.consultation value, joined on consultationid.

SELECT
p."consultationpurposeoriginalterm" AS "consultationpurposeoriginalterm",
COUNT(*) AS row_count
FROM episodemanagement.carecontact AS m
INNER JOIN carerecord.consultation AS p
ON p."consultationid" = m."consultationid"
AND p."organisation" = m."organisation"
GROUP BY p."consultationpurposeoriginalterm"
ORDER BY row_count DESC;