|
@@ -379,6 +379,24 @@ class Point extends Model
|
|
|
return $points;
|
|
|
}
|
|
|
|
|
|
+ public static function getPointsOfCategoryExceptEntryError(Client $_patient, Note $_note, String $_category, $_assoc = false) {
|
|
|
+ $points = Point
|
|
|
+ ::where('client_id', $_patient->id)
|
|
|
+ ->where('category', $_category)
|
|
|
+ ->where(function ($query2) use ($_note) {
|
|
|
+ $query2->where('is_removed', false)
|
|
|
+ ->orWhereRaw("(is_removed_due_to_entry_error IS NOT TRUE AND ((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 getNumPointsOfCategory(Client $_patient, String $_category) {
|
|
|
return Point
|
|
|
::where('client_id', $_patient->id)
|