Advertisement
temaon_lieto

SQL chronic_diseases/employees

Feb 12th, 2024
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- http://localhost:4000/api/v1/chronic_diseases/employees
  2.  
  3. MainApplication::Dbo::LegalEntity Load (1.8ms)
  4. SELECT "dbo"."LegalEntities".* FROM "dbo"."LegalEntities" WHERE "dbo"."LegalEntities"."Id" = $1 LIMIT $2  [["Id", 3228], ["LIMIT", 1]]
  5.  
  6. View::MvStatistic::Level0::Employee Load (7.4ms)
  7. SELECT mv_stat_lvl_0_employees.id,
  8. mv_stat_lvl_0_employees.full_name,
  9. COUNT(DISTINCT mv_stat_lvl_0_declarations.patient_id) AS total_counter,
  10. COUNT(DISTINCT mv_stat_lvl_1_patients.id) filter (WHERE mv_stat_lvl_1_patients.is_smoking = true AND mv_stat_lvl_1_patients.age BETWEEN 18 AND 69) AS smoking_counter,
  11. COUNT(DISTINCT mv_stat_lvl_2_imt_indices.patient_id) filter (WHERE mv_stat_lvl_1_patients.age BETWEEN 18 AND 69 AND mv_stat_lvl_2_imt_indices.imt_index > 25 AND mv_stat_lvl_2_imt_indices.asserted_date BETWEEN '2024-01-01 00:00:00' AND '2024-02-12 23:59:59.999999' ) AS overweight_counter,
  12. COUNT(DISTINCT mv_stat_lvl_1_ehr_conditions.patient_id) filter (WHERE mv_stat_lvl_1_ehr_conditions.code IN ('K85', 'K86', 'K87') AND mv_stat_lvl_1_ehr_conditions.asserted_date BETWEEN '2024-01-01 00:00:00' AND '2024-02-12 23:59:59.999999' ) AS hypertension_counter,
  13. COUNT(DISTINCT mv_stat_lvl_1_ehr_conditions.patient_id) filter (WHERE mv_stat_lvl_1_ehr_conditions.code IN ('T90') AND mv_stat_lvl_1_ehr_conditions.asserted_date BETWEEN '2024-01-01 00:00:00' AND '2024-02-12 23:59:59.999999') AS diabetes_counter,
  14. COUNT(DISTINCT mv_stat_lvl_1_ehr_conditions.patient_id) filter (WHERE mv_stat_lvl_1_ehr_conditions.code IN ('R96') AND mv_stat_lvl_1_ehr_conditions.asserted_date BETWEEN '2024-01-01 00:00:00' AND '2024-02-12 23:59:59.999999') AS asthma_counter,
  15. COUNT(DISTINCT mv_stat_lvl_1_ehr_conditions.patient_id) filter (WHERE mv_stat_lvl_1_ehr_conditions.code LIKE 'P%' AND mv_stat_lvl_1_ehr_conditions.asserted_date BETWEEN '2024-01-01 00:00:00' AND '2024-02-12 23:59:59.999999') AS derangement_counter,
  16. COUNT(DISTINCT mv_stat_lvl_0_receptions.patient_id) filter (WHERE mv_stat_lvl_0_receptions.asserted_date BETWEEN '2024-01-01 00:00:00' AND '2024-02-12 23:59:59.999999') AS reception_counter FROM "mv_stat_lvl_0_employees" LEFT OUTER JOIN "mv_stat_lvl_0_receptions" ON "mv_stat_lvl_0_receptions"."employee_id" = "mv_stat_lvl_0_employees"."id" LEFT OUTER JOIN "mv_stat_lvl_0_declarations" ON "mv_stat_lvl_0_declarations"."employee_id" = "mv_stat_lvl_0_employees"."id" LEFT OUTER JOIN "mv_stat_lvl_2_imt_indices" ON "mv_stat_lvl_2_imt_indices"."patient_id" = "mv_stat_lvl_0_declarations"."patient_id" LEFT OUTER JOIN "mv_stat_lvl_1_ehr_conditions" ON "mv_stat_lvl_1_ehr_conditions"."patient_id" = "mv_stat_lvl_0_declarations"."patient_id" LEFT OUTER JOIN "mv_stat_lvl_1_patients" ON "mv_stat_lvl_1_patients"."id" = "mv_stat_lvl_0_declarations"."patient_id" WHERE "mv_stat_lvl_0_employees"."legal_entity_id" = $1 AND "mv_stat_lvl_0_employees"."employee_type_ref_value" = $2 GROUP BY mv_stat_lvl_0_employees.id, mv_stat_lvl_0_employees.full_name  [["legal_entity_id", 3228], ["employee_type_ref_value", "DOCTOR"]]
  17.  
  18. View::MvStatistic::Level0::Declaration Count (1.0ms)
  19. SELECT COUNT(DISTINCT mv_stat_lvl_2_imt_indices.patient_id) FROM "mv_stat_lvl_0_declarations" INNER JOIN "mv_stat_lvl_1_patients" ON "mv_stat_lvl_1_patients"."id" = "mv_stat_lvl_0_declarations"."patient_id" INNER JOIN "mv_stat_lvl_2_imt_indices" ON "mv_stat_lvl_2_imt_indices"."patient_id" = "mv_stat_lvl_0_declarations"."patient_id" WHERE "mv_stat_lvl_0_declarations"."legal_entity_id" = $1 AND "mv_stat_lvl_1_patients"."age" BETWEEN $2 AND $3 AND "mv_stat_lvl_2_imt_indices"."asserted_date" BETWEEN $4 AND $5  [["legal_entity_id", 3228], ["age", "18.0"], ["age", "69.0"], ["asserted_date", "2024-01-01 00:00:00"], ["asserted_date", "2024-02-12 23:59:59.999999"]]
  20.  
  21. View::MvStatistic::Level0::Declaration Count (0.5ms)  
  22. SELECT COUNT("mv_stat_lvl_0_declarations"."id") FROM "mv_stat_lvl_0_declarations" INNER JOIN "mv_stat_lvl_1_patients" ON "mv_stat_lvl_1_patients"."id" = "mv_stat_lvl_0_declarations"."patient_id" WHERE "mv_stat_lvl_0_declarations"."legal_entity_id" = $1  [["legal_entity_id", 3228]]
  23.  
  24.  
  25. View::MvStatistic::Level0::Employee Count (0.3ms)  
  26. SELECT COUNT("mv_stat_lvl_0_employees"."id") FROM "mv_stat_lvl_0_employees" WHERE "mv_stat_lvl_0_employees"."legal_entity_id" = $1 AND "mv_stat_lvl_0_employees"."employee_type_ref_value" = $2  [["legal_entity_id", 3228], ["employee_type_ref_value", "DOCTOR"]]
  27.  
  28.  View::MvStatistic::Level0::Declaration Count (0.5ms)
  29.  SELECT COUNT("mv_stat_lvl_1_patients"."id") FROM "mv_stat_lvl_0_declarations" INNER JOIN "mv_stat_lvl_1_patients" ON "mv_stat_lvl_1_patients"."id" = "mv_stat_lvl_0_declarations"."patient_id" WHERE "mv_stat_lvl_0_declarations"."legal_entity_id" = $1 AND "mv_stat_lvl_1_patients"."age" BETWEEN $2 AND $3 AND "mv_stat_lvl_1_patients"."is_smoking" = $4  [["legal_entity_id", 3228], ["age", "18.0"], ["age", "69.0"], ["is_smoking", true]]
  30.  
  31. View::MvStatistic::Level0::Declaration Count (0.7ms)  
  32. SELECT COUNT(DISTINCT mv_stat_lvl_1_ehr_conditions.patient_id) FROM "mv_stat_lvl_0_declarations" INNER JOIN "mv_stat_lvl_1_patients" ON "mv_stat_lvl_1_patients"."id" = "mv_stat_lvl_0_declarations"."patient_id" INNER JOIN "mv_stat_lvl_1_ehr_conditions" ON "mv_stat_lvl_1_ehr_conditions"."patient_id" = "mv_stat_lvl_0_declarations"."patient_id" WHERE "mv_stat_lvl_0_declarations"."legal_entity_id" = $1 AND "mv_stat_lvl_1_ehr_conditions"."code" IN ($2, $3, $4) AND "mv_stat_lvl_1_ehr_conditions"."asserted_date" BETWEEN $5 AND $6  [["legal_entity_id", 3228], ["code", "K85"], ["code", "K86"], ["code", "K87"], ["asserted_date", "2024-01-01 00:00:00"], ["asserted_date", "2024-02-12 23:59:59.999999"]]
  33.  
  34. View::MvStatistic::Level0::Declaration Count (0.6ms)  
  35. SELECT COUNT(DISTINCT mv_stat_lvl_1_ehr_conditions.patient_id) FROM "mv_stat_lvl_0_declarations" INNER JOIN "mv_stat_lvl_1_patients" ON "mv_stat_lvl_1_patients"."id" = "mv_stat_lvl_0_declarations"."patient_id" INNER JOIN "mv_stat_lvl_1_ehr_conditions" ON "mv_stat_lvl_1_ehr_conditions"."patient_id" = "mv_stat_lvl_0_declarations"."patient_id" WHERE "mv_stat_lvl_0_declarations"."legal_entity_id" = $1 AND "mv_stat_lvl_1_ehr_conditions"."code" = $2 AND "mv_stat_lvl_1_ehr_conditions"."asserted_date" BETWEEN $3 AND $4  [["legal_entity_id", 3228], ["code", "T90"], ["asserted_date", "2024-01-01 00:00:00"], ["asserted_date", "2024-02-12 23:59:59.999999"]]
  36.  
  37.  
  38. View::MvStatistic::Level0::Declaration Count (0.6ms)
  39. SELECT COUNT(DISTINCT mv_stat_lvl_1_ehr_conditions.patient_id) FROM "mv_stat_lvl_0_declarations" INNER JOIN "mv_stat_lvl_1_patients" ON "mv_stat_lvl_1_patients"."id" = "mv_stat_lvl_0_declarations"."patient_id" INNER JOIN "mv_stat_lvl_1_ehr_conditions" ON "mv_stat_lvl_1_ehr_conditions"."patient_id" = "mv_stat_lvl_0_declarations"."patient_id" WHERE "mv_stat_lvl_0_declarations"."legal_entity_id" = $1 AND "mv_stat_lvl_1_ehr_conditions"."code" = $2 AND "mv_stat_lvl_1_ehr_conditions"."asserted_date" BETWEEN $3 AND $4  [["legal_entity_id", 3228], ["code", "R96"], ["asserted_date", "2024-01-01 00:00:00"], ["asserted_date", "2024-02-12 23:59:59.999999"]]
  40.  
  41. View::MvStatistic::Level0::Declaration Count (0.6ms)  
  42. SELECT COUNT(DISTINCT mv_stat_lvl_1_ehr_conditions.patient_id) FROM "mv_stat_lvl_0_declarations" INNER JOIN "mv_stat_lvl_1_patients" ON "mv_stat_lvl_1_patients"."id" = "mv_stat_lvl_0_declarations"."patient_id" INNER JOIN "mv_stat_lvl_1_ehr_conditions" ON "mv_stat_lvl_1_ehr_conditions"."patient_id" = "mv_stat_lvl_0_declarations"."patient_id" WHERE "mv_stat_lvl_0_declarations"."legal_entity_id" = $1 AND (mv_stat_lvl_1_ehr_conditions.code LIKE 'P%') AND "mv_stat_lvl_1_ehr_conditions"."asserted_date" BETWEEN $2 AND $3  [["legal_entity_id", 3228], ["asserted_date", "2024-01-01 00:00:00"], ["asserted_date", "2024-02-12 23:59:59.999999"]]
  43.   ↳ app/services/calculators/chronic_diseases/general_count_service.rb:77:in `derangement_counter'
  44.  CACHE View::MvStatistic::Level0::Declaration Count (0.0ms)  SELECT COUNT("mv_stat_lvl_0_declarations"."id") FROM "mv_stat_lvl_0_declarations" INNER JOIN "mv_stat_lvl_1_patients" ON "mv_stat_lvl_1_patients"."id" = "mv_stat_lvl_0_declarations"."patient_id" WHERE "mv_stat_lvl_0_declarations"."legal_entity_id" = $1  [["legal_entity_id", 3228]]
  45.  
  46. View::MvStatistic::Level0::Employee Load (2.2ms)
  47. SELECT mv_stat_lvl_0_employees.id,
  48. mv_stat_lvl_0_employees.full_name,
  49. COUNT(DISTINCT mv_stat_lvl_0_declarations.patient_id) AS total_counter,
  50. COUNT(DISTINCT mv_stat_lvl_1_patients.id) filter (WHERE mv_stat_lvl_1_patients.is_smoking = true AND mv_stat_lvl_1_patients.age BETWEEN 18 AND 69) AS smoking_counter,
  51. COUNT(DISTINCT mv_stat_lvl_2_imt_indices.patient_id) filter (WHERE mv_stat_lvl_1_patients.age BETWEEN 18 AND 69 AND mv_stat_lvl_2_imt_indices.imt_index > 25 AND mv_stat_lvl_2_imt_indices.asserted_date BETWEEN '2024-01-01 00:00:00' AND '2024-02-12 23:59:59.999999' ) AS overweight_counter,
  52. COUNT(DISTINCT mv_stat_lvl_1_ehr_conditions.patient_id) filter (WHERE mv_stat_lvl_1_ehr_conditions.code IN ('K85', 'K86', 'K87') AND mv_stat_lvl_1_ehr_conditions.asserted_date BETWEEN '2024-01-01 00:00:00' AND '2024-02-12 23:59:59.999999' ) AS hypertension_counter,
  53. COUNT(DISTINCT mv_stat_lvl_1_ehr_conditions.patient_id) filter (WHERE mv_stat_lvl_1_ehr_conditions.code IN ('T90') AND mv_stat_lvl_1_ehr_conditions.asserted_date BETWEEN '2024-01-01 00:00:00' AND '2024-02-12 23:59:59.999999') AS diabetes_counter,
  54. COUNT(DISTINCT mv_stat_lvl_1_ehr_conditions.patient_id) filter (WHERE mv_stat_lvl_1_ehr_conditions.code IN ('R96') AND mv_stat_lvl_1_ehr_conditions.asserted_date BETWEEN '2024-01-01 00:00:00' AND '2024-02-12 23:59:59.999999') AS asthma_counter,
  55. COUNT(DISTINCT mv_stat_lvl_1_ehr_conditions.patient_id) filter (WHERE mv_stat_lvl_1_ehr_conditions.code LIKE 'P%' AND mv_stat_lvl_1_ehr_conditions.asserted_date BETWEEN '2024-01-01 00:00:00' AND '2024-02-12 23:59:59.999999') AS derangement_counter,
  56. COUNT(DISTINCT mv_stat_lvl_0_receptions.patient_id) filter (WHERE mv_stat_lvl_0_receptions.asserted_date BETWEEN '2024-01-01 00:00:00' AND '2024-02-12 23:59:59.999999') AS reception_counter FROM "mv_stat_lvl_0_employees" LEFT OUTER JOIN "mv_stat_lvl_0_receptions" ON "mv_stat_lvl_0_receptions"."employee_id" = "mv_stat_lvl_0_employees"."id" LEFT OUTER JOIN "mv_stat_lvl_0_declarations" ON "mv_stat_lvl_0_declarations"."employee_id" = "mv_stat_lvl_0_employees"."id" LEFT OUTER JOIN "mv_stat_lvl_2_imt_indices" ON "mv_stat_lvl_2_imt_indices"."patient_id" = "mv_stat_lvl_0_declarations"."patient_id" LEFT OUTER JOIN "mv_stat_lvl_1_ehr_conditions" ON "mv_stat_lvl_1_ehr_conditions"."patient_id" = "mv_stat_lvl_0_declarations"."patient_id" LEFT OUTER JOIN "mv_stat_lvl_1_patients" ON "mv_stat_lvl_1_patients"."id" = "mv_stat_lvl_0_declarations"."patient_id" WHERE "mv_stat_lvl_0_employees"."legal_entity_id" = $1 AND "mv_stat_lvl_0_employees"."employee_type_ref_value" = $2 GROUP BY mv_stat_lvl_0_employees.id, mv_stat_lvl_0_employees.full_name LIMIT $3 OFFSET $4  [["legal_entity_id", 3228], ["employee_type_ref_value", "DOCTOR"], ["LIMIT", 15], ["OFFSET", 0]]
  57.  
  58. Completed 200 OK in 88ms (Views: 0.4ms | ActiveRecord: 21.5ms | Allocations: 41999)
  59.  
Tags: 3 page
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement