I am currently using the NHS' prescribing data API to find all the prescriptions of a certain class of drugs. There is an available script, here, which has instructions to pull out data of a single drug, but when I amend the SQL query to look instead for any drug of a given class (denoted by the first four digits, e.g. 0403, 'antidepressant drugs') the script doesn't work.
The script is available here: https://github.com/nhsbsa-data-analytics/open-data-portal-api/blob/master/open-data-portal-api.R
If I amend the following:
SELECT
*
FROM `",
month, "`
WHERE
1=1
AND pco_code = '", pco_code, "'
AND bnf_chemical_substance = '", bnf_chemical_substance, "'
"
)
to e.g.
SELECT
*
FROM `",
month, "`
WHERE
1=1
AND pco_code = '", pco_code, "'
AND bnf_chemical_substance LIKE '0403%'
"
)
This script does not give the required results. How can I have it pull out all the items starting with those digits, rather than an exact code?