|
@@ -57,12 +57,6 @@ select
|
|
|
c.most_recent_cellular_weight_value,
|
|
|
c.next_mcp_appointment_date,
|
|
|
|
|
|
-
|
|
|
- (select content from client_memo where client_id = c.id order by created_at desc LIMIT 1) as last_memo_content,
|
|
|
- (select category from client_memo where client_id = c.id order by created_at desc LIMIT 1) as last_memo_category,
|
|
|
- (select name_first||' '||name_last from pro where id = (select client_memo.created_by_pro_id from client_memo where client_id = c.id order by created_at desc LIMIT 1)) as last_memo_created_by_pro_display_name,
|
|
|
- (select count(*) from note where client_id = c.id and is_cancelled is not true ) as active_notes_count,
|
|
|
-
|
|
|
nmcpa.status as next_mcp_appointment_status,
|
|
|
nmcpa.raw_date as next_mcp_appointment_raw_date,
|
|
|
nmcpa.raw_start_time as next_mcp_appointment_start_time,
|
|
@@ -77,13 +71,7 @@ select
|
|
|
|
|
|
c.created_at as client_created_at,
|
|
|
|
|
|
- (creator.name_first||' '||creator.name_last) as creator_display_name,
|
|
|
-
|
|
|
- (select created_at from client_pro_change where new_pro_id = c.mcp_pro_id and responsibility_type = 'MCP' order by created_at DESC LIMIT 1) as mcp_assigned_on,
|
|
|
-
|
|
|
(dna.name_first|| ' '||dna.name_last ) as dna_display_name,
|
|
|
- (SELECT sh.status FROM shipment sh LEFT JOIN supply_order so ON so.shipment_id = sh.id WHERE so.product_id = 4 AND so.client_id = c.id ORDER BY sh.created_at DESC LIMIT 1) as temparature_gun_delivery_status,
|
|
|
- (SELECT sh.status FROM shipment sh LEFT JOIN supply_order so ON so.shipment_id = sh.id WHERE so.product_id = 5 AND so.client_id = c.id ORDER BY sh.created_at DESC LIMIT 1) as oximeter_delivery_status,
|
|
|
|
|
|
(select value from measurement where client_id = c.id AND bdt_measurement_id IS NOT NULL AND ts IS NOT NULL AND is_cellular_zero IS FALSE AND is_active IS TRUE AND label = 'Wt. (lbs.)' order by ts desc LIMIT 1) as last_measurement_of_type_weight,
|
|
|
(select value from measurement where client_id = c.id AND bdt_measurement_id IS NOT NULL AND ts IS NOT NULL AND is_cellular_zero IS FALSE AND is_active IS TRUE AND label = 'BP' order by ts desc LIMIT 1) as last_measurement_of_type_bp,
|
|
@@ -101,5 +89,4 @@ from client c
|
|
|
left join note mrcn on mrcn.id = c.most_recent_completed_mcp_note_id
|
|
|
left join measurement mrwm on mrwm.id = c.most_recent_weight_measurement_id
|
|
|
left join measurement mrbpm on mrbpm.id = c.most_recent_bp_measurement_id
|
|
|
- left join pro creator on creator.id = c.created_by_pro_id
|
|
|
left join pro dna on dna.id = c.default_na_pro_id;
|