Definition
Information
Section titled “Information”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.
Soft-Deleted Records
Section titled “Soft-Deleted Records”_deleted indicates whether the record has been deleted in the source system.
Examples
Section titled “Examples”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 mLEFT 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_countFROM carerecord.consultation AS mLEFT 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_countFROM carerecord.consultation AS mINNER JOIN consultationmode.consultationstyle AS p ON p."consultationstyleid" = m."consultationstyleid" AND p."organisation" = m."organisation"GROUP BY p."name"ORDER BY row_count DESC;