This query calculates the average, maximum and minimum cost per pill for a given list of drug concepts. Cost per pill is defined here as total cost divided by the quantity taken.
SELECT t.drug_concept_id,
avg(t.cost_per_pill) avg_val_num,
max(t.cost_per_pill) max_val_num,
min(t.cost_per_pill) min_val_num
from (
SELECT c.total_paid/d.quantity as cost_per_pill, d.drug_concept_id
FROM @cdm.cost c
JOIN @cdm.drug_exposure d
ON d.drug_exposure_id = c.cost_event_id
WHERE d.quantity > 0
AND d.drug_concept_id IN (906805, 1517070, 19010522)
) t
GROUP BY t.drug_concept_id
ORDER BY t.drug_concept_id;
| Parameter | Example | Mandatory | Notes | | --- | --- | --- | --- | | list of drug_concept_id | 906805, 1517070, 19010522 | Yes |
| Field | Description | | --- | --- | | drug_concept_id | Drug concept id | | avg_val_num | Average cost per pill | | max_val_num | Max cost per pill | | min_val_num | Min cost per pill |
| Field | Description | | --- | --- | | drug_concept_id | 19010522 | | avg_val_num | 2.6983903185925794872997154 | | max_val_num | 3197.50 | | min_val_num | 0 |
https://github.com/OHDSI/CommonDataModel/wiki/
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.