Drug Exposure‎ > ‎

DEX02: Counts of persons taking a drug, by age, gender, and year of exposure

This query is used to count the persons with exposure to a certain drug (drug_concept_id), grouped by age, gender, and year of exposure. The input to the query is a value (or a comma-separated list of values) of a drug_concept_id. See vocabulary queries for obtaining valid drug_concept_id values. If the input is omitted, all drugs in the data table are summarized.

 Parameter  Example  Mandatory  Notes
list of drug_concept_id 40165254, 40165258
Crestor 20 and 40 mg tablets

Sample query run:
The following is a sample run of the query. The input parameters are highlighted in blue.

SELECT drug.concept_name AS drug_name
     , EXTRACT( YEAR FROM drug_exposure_date ) AS year_of_exposure
     , EXTRACT( YEAR FROM drug_exposure_date ) - year_of_birth AS age
     , gender.concept_name AS gender
     , count(*) AS num_persons
  FROM /* person, first drug exposure date */
     ( SELECT drug_concept_id
            , person_id, year_of_birth, gender_concept_id
            , min( drug_exposure_start_date ) AS drug_exposure_date
         FROM drug_exposure
         JOIN person USING( person_id )
        WHERE drug_concept_id
           IN /* crestor 20 and 40 mg tablets */
            ( 40165254, 40165258 )
        GROUP BY drug_concept_id, person_id, year_of_birth, gender_concept_id
 JOIN vocabulary.concept drug ON drug.concept_id = drug_concept_id
 JOIN vocabulary.concept gender ON gender.concept_id = gender_concept_id
GROUP by drug.concept_name, gender.concept_name
    , EXTRACT( YEAR FROM drug_exposure_date ) - year_of_birth
    , EXTRACT( YEAR FROM drug_exposure_date )
ORDER BY drug_name, year_of_exposure, age, gender

Output field list:
 Field  Description
 concept_name An unambiguous, meaningful and descriptive name for the concept.
 age The age of the person at the time of exposure
 gender The gender of the person.
 num_persons The patient count

Sample output record:
 Field  Content
concept_name  Rosuvastatin calcium 40 MG Oral Tablet [Crestor]
year_of_exposure  2010
gender  Male
num_persons  15