Definition
Information
Section titled “Information”The Carerecord Consultationaccompanyinguser model records accompanying users associated with patient consultations. Each entry holds the consultation, patient and user-in-role identifiers together with source organisation information, identifying the accompanying-user association and the patient consultation context recorded against it.
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.consultationaccompanyinguser with carerecord.consultation, dbo.patient and dbo.userinrole details
Section titled “carerecord.consultationaccompanyinguser with carerecord.consultation, dbo.patient and dbo.userinrole details”Return records alongside descriptive values from the related tables.
SELECT m."_primary_key", m."consultationid", p1."consultationpurposeoriginalterm" AS "consultationpurposeoriginalterm", m."patientid", p2."displayname" AS "patient_displayname", m."userinroleid", p3."contractualrelationship" AS "userinrole_contractualrelationship"FROM carerecord.consultationaccompanyinguser AS mLEFT JOIN carerecord.consultation AS p1 ON p1."consultationid" = m."consultationid" AND p1."organisation" = m."organisation"LEFT JOIN dbo.patient AS p2 ON p2."patientid" = m."patientid" AND p2."organisation" = m."organisation"LEFT JOIN dbo.userinrole AS p3 ON p3."userinroleid" = m."userinroleid" AND p3."organisation" = m."organisation";Row count by carerecord.consultation consultationpurposeoriginalterm
Section titled “Row count by carerecord.consultation consultationpurposeoriginalterm”Count carerecord.consultationaccompanyinguser records for each carerecord.consultation value, joined on consultationid.
SELECT p."consultationpurposeoriginalterm" AS "consultationpurposeoriginalterm", COUNT(*) AS row_countFROM carerecord.consultationaccompanyinguser AS mINNER JOIN carerecord.consultation AS p ON p."consultationid" = m."consultationid" AND p."organisation" = m."organisation"GROUP BY p."consultationpurposeoriginalterm"ORDER BY row_count DESC;Row count by dbo.patient displayname
Section titled “Row count by dbo.patient displayname”Count carerecord.consultationaccompanyinguser records for each dbo.patient value, joined on patientid.
SELECT p."displayname" AS "patient_displayname", COUNT(*) AS row_countFROM carerecord.consultationaccompanyinguser AS mINNER JOIN dbo.patient AS p ON p."patientid" = m."patientid" AND p."organisation" = m."organisation"GROUP BY p."displayname"ORDER BY row_count DESC;