SELECT (CASE WHEN o.totalObs = 0 THEN 0 ELSE 100*(e.totExposure*1.0/o.totalObs*1.0) END)::numeric as proportion
FROM
(
SELECT SUM(date_part('day',r.drug_era_end_date) - date_part('day',r.drug_era_start_date)) AS totExposure,
r.person_id
FROM @cdm.drug_era r
WHERE
r.drug_concept_id = $1
group by r.person_id
) e,
(
SELECT sum(date_part('day',p.observation_period_end_date)-date_part('day',p.observation_period_start_date)) AS totalObs,
p.person_id FROM @cdm.observation_period p
group by p.person_id
) o
where
o.person_id = e.person_id
| Parameter | Example | Mandatory | Notes | | --- | --- | --- | --- | | drug_concept_id | 1549080 | Yes | Estrogens, Conjugated (USP) |
| Field | Description | | --- | --- | | proportion | proportion of observation time is a person exposed to a given drug |
| Field | Value | | --- | --- | | proportion | 0.1 |
https://github.com/OHDSI/CommonDataModel/wiki/
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.