|
@@ -179,6 +179,26 @@ class Point extends Model
|
|
|
return $points;
|
|
|
}
|
|
|
|
|
|
+ public static function getIntakePointsWithChildReview(Client $_patient, Note $_note, $_assoc = false) {
|
|
|
+ $points = Point
|
|
|
+ ::where('client_id', $_patient->id)
|
|
|
+ ->where('is_removed_due_to_entry_error', false)
|
|
|
+ ->whereRaw("(is_removed = TRUE OR addition_reason_category != 'DURING_VISIT' OR added_in_note_id != {$_note->id})")
|
|
|
+ ->where(function ($query1) use ($_note) {
|
|
|
+ $query1
|
|
|
+ ->where('last_child_review_point_scoped_note_id', $_note->id)
|
|
|
+ ->orWhereRaw("(SELECT count(id) from note_point WHERE is_active IS TRUE AND note_id = {$_note->id} AND point_id = point.id) > 0");
|
|
|
+ })
|
|
|
+ ->orderBy('created_at')
|
|
|
+ ->get();
|
|
|
+ foreach ($points as $point) {
|
|
|
+ if ($point->data) {
|
|
|
+ $point->data = json_decode($point->data, $_assoc);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $points;
|
|
|
+ }
|
|
|
+
|
|
|
public static function getPlanPointsOfCategory(Client $_patient, String $_category, Note $_note, $_assoc = false) {
|
|
|
$points = Point
|
|
|
::where('client_id', $_patient->id)
|