|
@@ -645,4 +645,52 @@ class Client extends Model
|
|
|
$notes = $notes->orderBy('effective_dateest', 'DESC')->limit(5)->get();
|
|
|
return $notes;
|
|
|
}
|
|
|
+
|
|
|
+ public function cmMeasurementsMatrix($_careMonth = null) {
|
|
|
+
|
|
|
+ $days = [];
|
|
|
+
|
|
|
+ $matches = DB::select(
|
|
|
+ "
|
|
|
+SELECT m.id AS measurement_id,
|
|
|
+ m.uid AS measurement_uid,
|
|
|
+ cm.id AS care_month_id,
|
|
|
+ cm.uid AS care_month_uid,
|
|
|
+ m.label,
|
|
|
+ m.value,
|
|
|
+ m.dbp_mm_hg,
|
|
|
+ m.sbp_mm_hg,
|
|
|
+ m.value_pulse,
|
|
|
+ m.value_irregular,
|
|
|
+ m.numeric_value,
|
|
|
+ m.effective_date,
|
|
|
+ m.ts
|
|
|
+FROM measurement m
|
|
|
+ JOIN care_month cm ON m.care_month_id = cm.id
|
|
|
+WHERE m.care_month_id = :careMonthID
|
|
|
+ AND m.bdt_measurement_id IS NOT NULL
|
|
|
+ AND m.is_cellular_zero IS FALSE
|
|
|
+ AND m.is_removed IS FALSE
|
|
|
+ORDER BY m.effective_date
|
|
|
+ ",
|
|
|
+ ['careMonthID' => $_careMonth->id]
|
|
|
+ );
|
|
|
+
|
|
|
+ foreach ($matches as $match) {
|
|
|
+ $time = (floor($match->ts / 1000));
|
|
|
+ $realTimezone = resolve_timezone('EASTERN');
|
|
|
+ $date = new \DateTime("@$time");
|
|
|
+ $date->setTimezone(new \DateTimeZone($realTimezone));
|
|
|
+ $match->date = $date->format("m/d/Y");
|
|
|
+ $match->time = $date->format("h:i A");
|
|
|
+
|
|
|
+ if(!isset($days[$match->date])) {
|
|
|
+ $days[$match->date] = [];
|
|
|
+ }
|
|
|
+ $days[$match->date][] = $match;
|
|
|
+ }
|
|
|
+
|
|
|
+ return $days;
|
|
|
+
|
|
|
+ }
|
|
|
}
|