Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT abc.id,
- abc.full_name,
- COUNT(DISTINCT abc.declaration_patient_id) AS total_counter,
- COUNT(DISTINCT abc.patient_id) filter (WHERE abc.is_smoking = TRUE AND
- abc.age BETWEEN 18 AND 69) AS smoking_counter,
- COUNT(DISTINCT abc.imt_patient_id)
- filter (WHERE abc.age BETWEEN 18 AND 69 AND abc.imt_index > 25 AND
- abc.imt_asserted_date BETWEEN '2024-01-01 00:00:00' AND '2024-02-15 23:59:59.999999' ) AS overweight_counter,
- COUNT(DISTINCT abc.condition_patient_id)
- filter (WHERE abc.code IN ('K85', 'K86', 'K87') AND
- abc.condition_asserted_date BETWEEN '2024-01-01 00:00:00' AND '2024-02-15 23:59:59.999999' ) AS hypertension_counter,
- COUNT(DISTINCT abc.condition_patient_id)
- filter (WHERE abc.code IN ('T90') AND
- abc.condition_asserted_date BETWEEN '2024-01-01 00:00:00' AND '2024-02-15 23:59:59.999999') AS diabetes_counter,
- COUNT(DISTINCT abc.condition_patient_id)
- filter (WHERE abc.code IN ('R96') AND
- abc.condition_asserted_date BETWEEN '2024-01-01 00:00:00' AND '2024-02-15 23:59:59.999999') AS asthma_counter,
- COUNT(DISTINCT abc.condition_patient_id)
- filter (WHERE abc.code LIKE 'P%' AND
- abc.condition_asserted_date BETWEEN '2024-01-01 00:00:00' AND '2024-02-15 23:59:59.999999') AS derangement_counter,
- COUNT(DISTINCT abc.reception_patient_id)
- filter (WHERE abc.reception_asserted_date BETWEEN '2024-01-01 00:00:00' AND '2024-02-15 23:59:59.999999') AS reception_counter
- FROM mv_stat_lvl_2_test_view abc
- WHERE "abc"."legal_entity_id" = 3228
- AND "abc"."employee_type_ref_value" = 'DOCTOR'
- GROUP BY abc.id, abc.full_name
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement