Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- OLD QUERY
- WITH "items" AS (SELECT "mv_stat_lvl_0_ehr_service_requests".*
- FROM ((SELECT "mv_stat_lvl_0_ehr_service_requests".*
- FROM ((SELECT mv_stat_lvl_0_ehr_service_requests.id,
- mv_stat_lvl_0_ehr_service_requests.asserted_date,
- mv_stat_lvl_0_ehr_service_requests.code,
- mv_stat_lvl_0_ehr_service_requests.item_type,
- mv_stat_lvl_0_ehr_service_requests.status::VARCHAR,
- mv_stat_lvl_0_ehr_service_requests.title,
- mv_stat_lvl_0_ehr_service_requests.employee_id,
- mv_stat_lvl_0_ehr_service_requests.legal_entity_id,
- mv_stat_lvl_0_ehr_service_requests.patient_id
- FROM "mv_stat_lvl_0_ehr_service_requests"
- WHERE "mv_stat_lvl_0_ehr_service_requests"."asserted_date" BETWEEN '2024-01-01 00:00:00' AND '2024-04-05 23:59:59.999999'
- AND "mv_stat_lvl_0_ehr_service_requests"."legal_entity_id" = 8507
- AND "mv_stat_lvl_0_ehr_service_requests"."code" IN
- ('T34006', 'T34011', 'T34013', 'T34024', 'T34001', 'T34004', 'T34005', 'T34023',
- 'T34025', 'T34038', 'U67002', 'Y34011', 'Y34003', 'Х41941', 'X41973', '59300-00',
- '55070-00', '55076-00', 'D36003', 'D67006', '32084-00', '32090-00', '32084-02',
- '32090-02', 'B33006', 'B33012', '14743-9'))
- UNION
- (SELECT mv_stat_lvl_0_ehr_diagnostic_reports.id,
- mv_stat_lvl_0_ehr_diagnostic_reports.asserted_date,
- mv_stat_lvl_0_ehr_diagnostic_reports.code,
- mv_stat_lvl_0_ehr_diagnostic_reports.item_type,
- mv_stat_lvl_0_ehr_diagnostic_reports.status::VARCHAR,
- mv_stat_lvl_0_ehr_diagnostic_reports.title,
- mv_stat_lvl_0_ehr_diagnostic_reports.employee_id,
- mv_stat_lvl_0_ehr_diagnostic_reports.legal_entity_id,
- mv_stat_lvl_0_ehr_diagnostic_reports.patient_id
- FROM "mv_stat_lvl_0_ehr_diagnostic_reports"
- WHERE "mv_stat_lvl_0_ehr_diagnostic_reports"."asserted_date" BETWEEN '2024-01-01 00:00:00' AND '2024-04-05 23:59:59.999999'
- AND "mv_stat_lvl_0_ehr_diagnostic_reports"."legal_entity_id" = 8507
- AND "mv_stat_lvl_0_ehr_diagnostic_reports"."code" IN
- ('T34006', 'T34011', 'T34013', 'T34024', 'T34001', 'T34004', 'T34005', 'T34023',
- 'T34025', 'T34038', 'U67002', 'Y34011', 'Y34003', 'Х41941', 'X41973', '59300-00',
- '55070-00', '55076-00', 'D36003', 'D67006', '32084-00', '32090-00', '32084-02',
- '32090-02', 'B33006', 'B33012', '14743-9'))) "mv_stat_lvl_0_ehr_service_requests")
- UNION
- (SELECT mv_stat_lvl_1_ehr_observations.id,
- mv_stat_lvl_1_ehr_observations.asserted_date,
- mv_stat_lvl_1_ehr_observations.code,
- 1 AS item_type,
- 'final'::VARCHAR AS status,
- mv_stat_lvl_1_ehr_observations.title,
- mv_stat_lvl_1_ehr_observations.employee_id,
- mv_stat_lvl_1_ehr_observations.legal_entity_id,
- mv_stat_lvl_1_ehr_observations.patient_id
- FROM "mv_stat_lvl_1_ehr_observations"
- WHERE "mv_stat_lvl_1_ehr_observations"."asserted_date" BETWEEN '2024-01-01 00:00:00' AND '2024-04-05 23:59:59.999999'
- AND "mv_stat_lvl_1_ehr_observations"."legal_entity_id" = 8507
- AND "mv_stat_lvl_1_ehr_observations"."code" IN
- ('T34006', 'T34011', 'T34013', 'T34024', 'T34001', 'T34004', 'T34005', 'T34023', 'T34025',
- 'T34038', 'U67002', 'Y34011', 'Y34003', 'Х41941', 'X41973', '59300-00', '55070-00',
- '55076-00', 'D36003', 'D67006', '32084-00', '32090-00', '32084-02', '32090-02', 'B33006',
- 'B33012', '14743-9'))) "mv_stat_lvl_0_ehr_service_requests")
- SELECT COUNT(items.id) as counter
- FROM items;
- -- NEW QUERY
- SELECT COUNT(mv_stat_lvl_2_joined_items.id) as counter
- FROM mv_stat_lvl_2_joined_items
- WHERE mv_stat_lvl_2_joined_items.asserted_date BETWEEN '2024-01-01 00:00:00' AND '2024-04-05 23:59:59.999999'
- AND mv_stat_lvl_2_joined_items.legal_entity_id = 8507
- AND mv_stat_lvl_2_joined_items.code IN
- ('T34006', 'T34011', 'T34013', 'T34024', 'T34001', 'T34004', 'T34005', 'T34023', 'T34025',
- 'T34038', 'U67002', 'Y34011', 'Y34003', 'Х41941', 'X41973', '59300-00', '55070-00',
- '55076-00', 'D36003', 'D67006', '32084-00', '32090-00', '32084-02', '32090-02', 'B33006',
- 'B33012', '14743-9');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement