Definition
Information
Section titled “Information”The Appointment Sessionservice model links appointment sessions with services recorded against them. It holds session and service identifiers, a flag indicating whether the association is primary, and source organisation information describing the organisational context of the recorded association.
Soft-Deleted Records
Section titled “Soft-Deleted Records”_deleted indicates whether the record has been deleted in the source system.
Examples
Section titled “Examples”appointment.sessionservice with appointment.session details
Section titled “appointment.sessionservice with appointment.session details”Return records alongside descriptive values from the related appointment.session record.
SELECT m."_primary_key", m."sessionid", p1."description" AS "session_description"FROM appointment.sessionservice AS mLEFT JOIN appointment.session AS p1 ON p1."sessionid" = m."sessionid" AND p1."organisation" = m."organisation";Row count by appointment.session description
Section titled “Row count by appointment.session description”Count appointment.sessionservice records for each appointment.session value, joined on sessionid.
SELECT p."description" AS "session_description", COUNT(*) AS row_countFROM appointment.sessionservice AS mINNER JOIN appointment.session AS p ON p."sessionid" = m."sessionid" AND p."organisation" = m."organisation"GROUP BY p."description"ORDER BY row_count DESC;Records without a matching appointment.session
Section titled “Records without a matching appointment.session”Find appointment.sessionservice records whose sessionid has no matching appointment.session record.
SELECT COUNT(*) AS unmatched_countFROM appointment.sessionservice AS mLEFT JOIN appointment.session AS p ON p."sessionid" = m."sessionid" AND p."organisation" = m."organisation"WHERE m."sessionid" IS NOT NULL AND p."sessionid" IS NULL;