inst/QueryLibrary/Aggregate/observation_period/OP02.md

OP02: Distribution of length of observation, in months, among first observation periods across the population

Description

Count distribution of length of observation, in months, among first observation periods across the population.

Query

SELECT
  FLOOR((observation_period_end_date - observation_period_start_date)/30) AS num_months,
  COUNT(DISTINCT person_id)::integer AS num_persons
FROM
  ( SELECT
      person_ID,
      observation_period_START_DATE,
      observation_period_END_DATE,
      rank() OVER (PARTITION BY person_ID ORDER BY observation_period_START_DATE ASC) AS OP_NUMBER
    FROM @cdm.observation_period
  ) AS OP1
WHERE op_number = 1
GROUP BY  FLOOR((observation_period_end_date - observation_period_start_date)/30) 
ORDER BY  FLOOR((observation_period_end_date - observation_period_start_date)/30) ASC
;

Input

None

Output

| Field | Description | | --- | --- | | num_month | Number of month duration | | num_persons | Number of patients whose observation period with num_month duration |

Example output record

| Field | Value | | --- | --- | | num_months | 1 | | num_persons | 4132770 |

Documentation

https://github.com/OHDSI/CommonDataModel/wiki/



sib-swiss/dsQueryLibraryServer documentation built on Feb. 13, 2025, 8:07 p.m.