This query is to determine the distribution of distinct drugs patients are
exposed to during a certain time period. If the time period is omitted,
the entire time span of the database is considered.
Input:
Parameter | Example | Mandatory | Notes | date from
| 01-Jan-2008 | Yes
|
| date to | 31-Dec-2008 | Yes | |
Sample query run:
The following is a sample run of the query. The input parameters are highlighted in blue.
SELECT MIN ( drugs ) AS min
, PERCENTILE_DISC(0.25) WITHIN GROUP( ORDER BY drugs )
AS percentile_25
, ROUND ( AVG ( drugs ), 2 ) AS mean
, PERCENTILE_DISC(0.5) WITHIN GROUP (ORDER BY drugs )
AS median
, PERCENTILE_DISC(0.75) WITHIN GROUP (ORDER BY drugs )
AS percential_75
, MAX ( drugs ) AS max , ROUND ( STDDEV ( drugs ), 1 ) AS stdDev
FROM -- distinct person/drug
(SELECT person_id, NVL( drugs, 0 ) AS drugs
FROM person
LEFT OUTER JOIN
( SELECT person_id, COUNT( DISTINCT drug_concept_id ) AS drugs
FROM drug_exposure
WHERE drug_exposure_start_date BETWEEN '01-Jan-2008' AND '31-Dec-2008'
GROUP BY person_id
) USING( person_id )
);
Output:
Output field list: Field |
Description |
min
|
The minimum number of drugs taken by a patient
|
percentile_25 |
The 25th percentile of the distibution
| mean
| The mean or average of drugs taken by patients
|
median
|
The median number of drugs take
|
percentile_75 |
The 75th percentile of the distribution
|
max
|
The maximum number of drugs taken by a patient
|
stddev
| The standard deviation of the age distribution |
Sample output record: Field |
Content |
min
|
0 |
percentile_25 |
0 |
mean
| 1.73
|
median
|
0 |
percentile_75 |
1
|
max
|
141
|
stddev
| 4.2 |
|
|