Below are the database queries which are used to create this measure. These are run against a copy of the BSA prescribing data which we store in Google BigQuery. We're working on making our BigQuery tables publicly available at which point it will be possible to run and modify these queries yourself. But even where code and database queries are not directly useable by others we believe it is always preferable to make them public.
Description | Prescribing of pregabalin (total mg) per 1000 patients |
---|---|
Why it matters | Pregabalin is increasingly used in neuropathic and other types of pain. There are concerns about the potential for abuse. This measure shows the total amount in milligrams of pregabalin prescribed. |
Tags | Standard, Pain, Safety |
Implies cost savings | No |
Authored by | richard.croker |
Checked by | andrew.brown |
Last reviewed | 2024-08-05 |
Next review due | 2025-08-05 |
History | View change history on GitHub → |
SELECT
CAST(month AS DATE) AS month,
practice AS practice_id,
SUM((p.quantity * i.strnt_nmrtr_val * COALESCE(n.nmtr_unit_conversion,1)) / -- calculate the total unit of drug, and convert if neccesary to miligrams). Uses COALESCE to default to 1 if conversion not available
COALESCE(d.nmtr_unit_conversion * i.strnt_dnmtr_val,1)) AS numerator --divides unit dose if multiple, and converts to mililitre if necessary. Uses COALESCE to default to 1 if conversion or denominator strength not available
FROM hscic.normalised_prescribing p INNER JOIN dmd.vmp v --this joins data table to dm+d vmp table
ON CONCAT(SUBSTR(p.bnf_code,0,9),SUBSTR(p.bnf_code,-2)) = CONCAT(SUBSTR(v.bnf_code,0,9),SUBSTR(v.bnf_code,-2)) --joins both brand and generics to vmp table
INNER JOIN dmd.vpi i -- joins vmp to vpi table to get ingredient strengths
ON v.id = i.vmp
INNER JOIN measures.vw__measure_conversion n -- joins unit conversion view to numerator unit of measure
ON i.strnt_nmrtr_uom = n.cd
LEFT JOIN measures.vw__measure_conversion d -- joins unit conversion view to denominator unit of measure (LEFT join as not all products have a denominator UOM)
ON i.strnt_dnmtr_uom = d.cd
WHERE p.bnf_code LIKE '0408010AE%' --Pregabalin
AND i.ing = 415160008 --Pregabalin
GROUP BY month, practice_id
SELECT
CAST(month AS DATE) AS month,
practice AS practice_id,
SUM(total_list_size / 1000.0) AS denominator
FROM hscic.practice_statistics
GROUP BY month, practice_id