|
@@ -449,10 +449,10 @@ SELECT p.id,
|
|
|
p.addition_reason_category,
|
|
|
p.removed_in_note_id,
|
|
|
p.removal_reason_category,
|
|
|
- n_added.uid as added_note_uid,
|
|
|
- n_added.effective_dateest as added_on,
|
|
|
- n_removed.uid as removed_note_uid,
|
|
|
- n_removed.effective_dateest as removed_on,
|
|
|
+ p.added_in_note_uid as added_note_uid,
|
|
|
+ p.added_in_note_effective_date as added_on,
|
|
|
+ p.removed_in_note_uid as removed_note_uid,
|
|
|
+ p.removed_in_note_effective_dateest as removed_on,
|
|
|
np.uid as note_point_uid,
|
|
|
p.last_child_review_point_id,
|
|
|
p.last_child_review_point_scoped_note_id,
|
|
@@ -460,22 +460,14 @@ SELECT p.id,
|
|
|
p.last_child_plan_point_scoped_note_id,
|
|
|
p.last_child_review_effective_date,
|
|
|
p.last_child_plan_effective_date,
|
|
|
- lcr_point.data as last_child_review_data,
|
|
|
- lcp_point.data as last_child_plan_data,
|
|
|
- (lcr_pro.name_first || ' ' || lcr_pro.name_last) as last_child_review_creator,
|
|
|
- (lcp_pro.name_first || ' ' || lcp_pro.name_last) as last_child_plan_creator,
|
|
|
- lcr_note.uid as last_child_review_note_uid,
|
|
|
- lcp_note.uid as last_child_plan_note_uid
|
|
|
+ p.last_child_review_data,
|
|
|
+ p.last_child_plan_data,
|
|
|
+ (p.last_child_review_creator_pro_first_name || ' ' || p.last_child_review_creator_pro_last_name) as last_child_review_creator,
|
|
|
+ (p.last_child_plan_creator_pro_first_name || ' ' || p.last_child_plan_creator_pro_last_name) as last_child_plan_creator,
|
|
|
+ p.last_child_review_point_scoped_note_uid as last_child_review_note_uid,
|
|
|
+ p.last_child_plan_point_scoped_note_uid as last_child_plan_note_uid
|
|
|
FROM point p
|
|
|
left join note_point np on p.id = np.point_id and np.note_id = {$_note->id}
|
|
|
- left join note n_added on p.added_in_note_id = n_added.id
|
|
|
- left join note n_removed on p.removed_in_note_id = n_removed.id
|
|
|
- left join point lcr_point on p.last_child_review_point_id = lcr_point.id
|
|
|
- left join point lcp_point on p.last_child_plan_point_id = lcp_point.id
|
|
|
- left join pro lcr_pro on lcr_point.created_by_pro_id = lcr_pro.id
|
|
|
- left join pro lcp_pro on lcp_point.created_by_pro_id = lcp_pro.id
|
|
|
- left join note lcr_note on lcr_point.last_child_review_point_scoped_note_id = lcr_note.id
|
|
|
- left join note lcp_note on lcp_point.last_child_plan_point_scoped_note_id = lcp_note.id
|
|
|
WHERE p.client_id = {$_patient->id} AND p.category = '{$_category}'
|
|
|
ORDER BY ((p.data)::json->'{$_sortKey}')::text
|
|
|
";
|