Skip to content
Partner Developer Portal

Definition

The Episodemanagement Diagnosis model records diagnosis associations using observation and referral-observation identifiers. It also holds a primary-diagnosis flag, diagnosis identifier and GUID, together with source organisation information describing the context of the diagnosis association stored in episode management.

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

episodemanagement.diagnosis with carerecord.observation details

Section titled “episodemanagement.diagnosis with carerecord.observation details”

Return records alongside descriptive values from the related carerecord.observation record.

SELECT
m."diagnosisid",
m."observationid",
p1."associatedtext" AS "observation_associatedtext"
FROM episodemanagement.diagnosis AS m
LEFT JOIN carerecord.observation AS p1
ON p1."observationid" = m."observationid"
AND p1."organisation" = m."organisation";

Row count by carerecord.observation associatedtext

Section titled “Row count by carerecord.observation associatedtext”

Count episodemanagement.diagnosis records for each carerecord.observation value, joined on observationid.

SELECT
p."associatedtext" AS "observation_associatedtext",
COUNT(*) AS row_count
FROM episodemanagement.diagnosis AS m
INNER JOIN carerecord.observation AS p
ON p."observationid" = m."observationid"
AND p."organisation" = m."organisation"
GROUP BY p."associatedtext"
ORDER BY row_count DESC;

Records without a matching carerecord.observation

Section titled “Records without a matching carerecord.observation”

Find episodemanagement.diagnosis records whose observationid has no matching carerecord.observation record.

SELECT
COUNT(*) AS unmatched_count
FROM episodemanagement.diagnosis AS m
LEFT JOIN carerecord.observation AS p
ON p."observationid" = m."observationid"
AND p."organisation" = m."organisation"
WHERE m."observationid" IS NOT NULL
AND p."observationid" IS NULL;