Skip to content
Partner Developer Portal

Definition

The Prescribing Drugrecord model holds patient medication records, including the prescribed item, dosage, quantity and course duration. It also records authorisation, review and expiry details, issue history and compliance values, patient and pharmacy text, and prescribing flags alongside patient and organisation identifiers.

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

prescribing.drugrecord with prescribing.localmixture, dbo.organisation and dbo.patient details

Section titled “prescribing.drugrecord with prescribing.localmixture, dbo.organisation and dbo.patient details”

Return records alongside descriptive values from the related tables.

SELECT
m."drugrecordid",
m."localmixtureid",
p1."localmixturename" AS "localmixturename",
m."organisationid",
p2."organisationdisplayname" AS "organisationdisplayname",
m."patientid",
p3."displayname" AS "patient_displayname"
FROM prescribing.drugrecord AS m
LEFT JOIN prescribing.localmixture AS p1
ON p1."localmixtureid" = m."localmixtureid"
AND p1."organisation" = m."organisation"
LEFT JOIN dbo.organisation AS p2
ON p2."organisationid" = m."organisationid"
AND p2."organisation" = m."organisation"
LEFT JOIN dbo.patient AS p3
ON p3."patientid" = m."patientid"
AND p3."organisation" = m."organisation";

carerecord.problemdrugrecord count per prescribing.drugrecord

Section titled “carerecord.problemdrugrecord count per prescribing.drugrecord”

Count related carerecord.problemdrugrecord records for each prescribing.drugrecord record, joined on drugrecordid.

SELECT
m."drugrecordid",
m."originalterm",
COUNT(c."drugrecordid") AS problemdrugrecord_count
FROM prescribing.drugrecord AS m
LEFT JOIN carerecord.problemdrugrecord AS c
ON m."drugrecordid" = c."drugrecordid"
AND m."organisation" = c."organisation"
GROUP BY m."drugrecordid", m."originalterm"
ORDER BY problemdrugrecord_count DESC;

Row count by prescribing.localmixture localmixturename

Section titled “Row count by prescribing.localmixture localmixturename”

Count prescribing.drugrecord records for each prescribing.localmixture value, joined on localmixtureid.

SELECT
p."localmixturename" AS "localmixturename",
COUNT(*) AS row_count
FROM prescribing.drugrecord AS m
INNER JOIN prescribing.localmixture AS p
ON p."localmixtureid" = m."localmixtureid"
AND p."organisation" = m."organisation"
GROUP BY p."localmixturename"
ORDER BY row_count DESC;