Skip to content
Partner Developer Portal

Definition

The Carerecord Consultation model records patient consultations, including their effective date, duration, purpose, source and style. It also holds location and external-consulter details, entering and authorising user information, travel and resource details, and recorded completion, visibility and online-access restriction flags.

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

carerecord.consultation with consultationmode.consultationstyle, dbo.location and dbo.organisation details

Section titled “carerecord.consultation with consultationmode.consultationstyle, dbo.location and dbo.organisation details”

Return records alongside descriptive values from the related tables.

SELECT
m."consultationid",
m."consultationstyleid",
p1."name" AS "consultationstyle_name",
m."locationid",
p2."locationname" AS "locationname",
m."organisationid",
p3."organisationdisplayname" AS "organisationdisplayname"
FROM carerecord.consultation AS m
LEFT JOIN consultationmode.consultationstyle AS p1
ON p1."consultationstyleid" = m."consultationstyleid"
AND p1."organisation" = m."organisation"
LEFT JOIN dbo.location AS p2
ON p2."locationid" = m."locationid"
AND p2."organisation" = m."organisation"
LEFT JOIN dbo.organisation AS p3
ON p3."organisationid" = m."organisationid"
AND p3."organisation" = m."organisation";

carerecord.consultationaccompanyinguser count per carerecord.consultation

Section titled “carerecord.consultationaccompanyinguser count per carerecord.consultation”

Count related carerecord.consultationaccompanyinguser records for each carerecord.consultation record, joined on consultationid.

SELECT
m."consultationid",
m."consultationpurposeoriginalterm",
COUNT(c."consultationid") AS consultationaccompanyinguser_count
FROM carerecord.consultation AS m
LEFT JOIN carerecord.consultationaccompanyinguser AS c
ON m."consultationid" = c."consultationid"
AND m."organisation" = c."organisation"
GROUP BY m."consultationid", m."consultationpurposeoriginalterm"
ORDER BY consultationaccompanyinguser_count DESC;

Row count by consultationmode.consultationstyle name

Section titled “Row count by consultationmode.consultationstyle name”

Count carerecord.consultation records for each consultationmode.consultationstyle value, joined on consultationstyleid.

SELECT
p."name" AS "consultationstyle_name",
COUNT(*) AS row_count
FROM carerecord.consultation AS m
INNER JOIN consultationmode.consultationstyle AS p
ON p."consultationstyleid" = m."consultationstyleid"
AND p."organisation" = m."organisation"
GROUP BY p."name"
ORDER BY row_count DESC;