Drug Era‎ > ‎

DER27: Counts of drug era records per person, stratified by drug and drug type

This query is used to count the number of drug era records (drug_era_id) for all persons, stratified by drug (drug_concept_id) and drug type (drug_type_concept_id). The input to the query is a value (or a comma-separated list of values) for a number of records per person, a drug_concept_id and a drug_concept_type_id. If the input is omitted, all existing value combinations are summarized.

Input:
 Parameter  Example  Mandatory  Notes
drug_concept_id 1300978, 1304643, 1549080 Yes Male, Female
drug_concept_typed_id 38000182 Yes

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

SELECT 
  t.drug_concept_id,
  
                   t.person_id,
  count(1) as stat_value,
  
                   t.drug_TYPE_concept_id

FROM       drug_era t

where      
  t.drug_concept_id in (1300978, 1304643, 1549080) 
                  and
  t.drug_TYPE_concept_id = 38000182

GROUP BY  t.person_id, 
                  t.drug_TYPE_concept_id, 
                  t.drug_concept_id
having count(1) in (3,5)
ORDER BY t.person_id, 
                  t.drug_TYPE_concept_id, 
                  t.drug_concept_id
;

Output:
Output field list:
 Field  Description
drug_concept_id A foreign key that refers to a standard concept identifier in the vocabulary for the drug concept.
person_id A foreign key identifier to the person who is subjected to the drug during the drug era. The demographic details of that person are stored in the person table.
drug_type_concept_id A foreign key to the predefined concept identifier in the vocabulary reflecting the type of drug exposure recorded. It indicates how the drug exposure was represented in the source data: as medication history, filled prescriptions, etc.

Sample output record:
 Field  Description
drug_concept_id
person_id
drug_type_concept_id
Comments