Advertisement
temaon_lieto

mv_stat_lvl_1_reception_conditions

Nov 28th, 2024
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT
  2.     MAX(ehr_conditions.id)           as id,
  3.     MAX(ehr_conditions.encounter_id) as encounter_id,
  4.     ehr_conditions.patient_id   as patient_id,
  5.     ehr_conditions.employee_id  as employee_id,
  6.     ehr_conditions.code         as code,
  7.     ehr_conditions.title       as title,
  8.     ehr_conditions.role         as role,
  9.     MAX(ehr_conditions.diagnose_id)  as diagnose_id,
  10.     receptions.legal_entity_id  as legal_entity_id,
  11.     CAST(receptions.asserted_date as date)    as asserted_date
  12. FROM mv_stat_lvl_0_ehr_conditions as ehr_conditions
  13.          INNER JOIN mv_stat_lvl_0_receptions receptions ON ehr_conditions.encounter_id = receptions.id
  14. GROUP BY (ehr_conditions.patient_id, ehr_conditions.employee_id, ehr_conditions.code, ehr_conditions.title , ehr_conditions.role,
  15.           CAST(receptions.asserted_date as date), receptions.legal_entity_id)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement