Browse Source

fixed measurements is_removed

Josh 3 years ago
parent
commit
c0de25a0b3

+ 3 - 3
app/Http/Controllers/HomeController.php

@@ -557,7 +557,7 @@ WHERE cl.shadow_pro_id IS NULL
             ->whereNotNull('ts')
             ->whereNotIn('label', ['SBP', 'DBP'])
             ->where('is_cellular_zero', '<>', true)
-            ->where('is_removed', false)
+            ->where('is_active', true)
             ->where('has_been_stamped_by_mcp', false)
             ->whereNotNull('client_bdt_measurement_id')
             ->paginate(15);
@@ -991,7 +991,7 @@ FROM measurement
          join client on measurement.client_id = client.id
 WHERE measurement.label NOT IN ('SBP', 'DBP')
   AND (measurement.is_cellular_zero = FALSE or measurement.is_cellular_zero IS NULL)
-  AND measurement.is_removed IS FALSE
+  AND measurement.is_active IS TRUE
   AND measurement.has_been_stamped_by_mcp IS FALSE
   AND measurement.ts IS NOT NULL
   AND measurement.client_bdt_measurement_id IS NOT NULL
@@ -1035,7 +1035,7 @@ FROM measurement
          join care_month on client.id = care_month.client_id
 WHERE measurement.label NOT IN ('SBP', 'DBP')
   AND (measurement.is_cellular_zero = FALSE or measurement.is_cellular_zero IS NULL)
-  AND measurement.is_removed IS FALSE
+  AND measurement.is_active IS TRUE
   AND measurement.has_been_stamped_by_mcp IS FALSE
   AND measurement.ts IS NOT NULL
   AND measurement.client_bdt_measurement_id IS NOT NULL

+ 8 - 8
app/Models/Client.php

@@ -206,7 +206,7 @@ class Client extends Model
     public function recentMeasurements()
     {
         return $this->hasMany(Measurement::class, 'client_id', 'id')
-            ->where('is_removed', false)
+            ->where('is_active', true)
             ->whereNotNull('label')
             ->where('label', '<>', 'SBP')
             ->where('label', '<>', 'DBP')
@@ -219,7 +219,7 @@ class Client extends Model
     {
         return $this->hasMany(Measurement::class, 'client_id', 'id')
             /*->distinct('label')*/
-            ->where('is_removed', false)
+            ->where('is_active', true)
             ->where('is_cellular_zero', false)
             ->orderBy('effective_date', 'desc');
     }
@@ -227,7 +227,7 @@ class Client extends Model
     public function getNonZeroBpMeasurements(){
         return $this->hasMany(Measurement::class, 'client_id', 'id')
             /*->distinct('label')*/
-            ->where('is_removed', false)
+            ->where('is_active', true)
             ->where('label', '=', 'BP')
             ->where('sbp_mm_hg', '>', 0)
             ->where('dbp_mm_hg', '>', 0)
@@ -237,7 +237,7 @@ class Client extends Model
     public function getNonZeroWeightMeasurements(){
         return $this->hasMany(Measurement::class, 'client_id', 'id')
             /*->distinct('label')*/
-            ->where('is_removed', false)
+            ->where('is_active', true)
             ->where('label', '=', 'Wt. (lbs.)')
             ->where('numeric_value', '>', 0)
             ->orderBy('ts', 'desc');
@@ -264,7 +264,7 @@ class Client extends Model
             ::where('client_id', $this->id)
             ->whereRaw('EXTRACT(MONTH FROM effective_date) = ?', [$month])
             ->whereRaw('EXTRACT(YEAR FROM effective_date) = ?', [$year])
-            ->where('is_removed', false)
+            ->where('is_active', true)
             ->orderBy('ts', 'desc')
             ->get();
         return $measurements;
@@ -273,7 +273,7 @@ class Client extends Model
     public function allMeasurements()
     {
         return $this->hasMany(Measurement::class, 'client_id', 'id')
-            ->where('is_removed', false)
+            ->where('is_active', true)
             ->whereNull('parent_measurement_id')
             ->orderBy('label', 'asc')
             ->orderBy('effective_date', 'desc');
@@ -316,7 +316,7 @@ class Client extends Model
             ->whereNotNull('bdt_measurement_id')
             ->whereNotNull('ts')
             ->where('is_cellular_zero', false)
-            ->where('is_removed', false)
+            ->where('is_active', true)
             ->where('label', '=', $_type)
             ->orderBy('ts', 'desc')
             ->first();
@@ -778,7 +778,7 @@ FROM measurement m
 WHERE m.care_month_id = :careMonthID
         AND m.label NOT IN ('SBP', 'DBP')
         AND m.bdt_measurement_id IS NOT NULL
-        AND m.is_removed IS FALSE
+        AND m.is_active IS TRUE
         AND (m.is_cellular_zero = FALSE or m.is_cellular_zero IS NULL)
         AND m.ts IS NOT NULL
         AND m.client_bdt_measurement_id IS NOT NULL

+ 1 - 1
app/Models/Measurement.php

@@ -48,7 +48,7 @@ class Measurement extends Model
 
     public function childMeasurements() {
         return Measurement::where('parent_measurement_id', $this->id)
-            ->where('is_removed', false)
+            ->where('is_active', true)
             ->get();
     }
 }

+ 1 - 1
app/Models/Pro.php

@@ -620,7 +620,7 @@ WHERE mcp_pro_id = :pro_id
         $start *= 1000;
         $end *= 1000;
 
-        $measurementsQuery = Measurement::where('is_removed', false)
+        $measurementsQuery = Measurement::where('is_active', true)
             ->join('client', 'client.id', '=', 'measurement.client_id')
             ->whereNotNull('measurement.client_bdt_measurement_id')
             ->whereNotNull('measurement.ts')

+ 4 - 4
database/seeds/MeasurementSeeder.php

@@ -98,7 +98,7 @@ class MeasurementSeeder extends Seeder
                 'created_at' => date('Y-m-d'),
                 'type' => 'Measurement',
                 'uid' => Str::uuid(),
-                'is_removed' => false,
+                'is_active' => true,
                 'removal_memo' => null,
                 'removed_at' => null,
                 'effective_date' => $date,
@@ -121,7 +121,7 @@ class MeasurementSeeder extends Seeder
                 'created_at' => date('Y-m-d'),
                 'type' => 'Measurement',
                 'uid' => Str::uuid(),
-                'is_removed' => false,
+                'is_active' => true,
                 'removal_memo' => null,
                 'removed_at' => null,
                 'effective_date' => $date,
@@ -144,7 +144,7 @@ class MeasurementSeeder extends Seeder
                 'created_at' => date('Y-m-d'),
                 'type' => 'Measurement',
                 'uid' => Str::uuid(),
-                'is_removed' => false,
+                'is_active' => true,
                 'removal_memo' => null,
                 'removed_at' => null,
                 'effective_date' => $date,
@@ -219,7 +219,7 @@ class MeasurementSeeder extends Seeder
                 'created_at' => date('Y-m-d'),
                 'type' => 'Measurement',
                 'uid' => Str::uuid(),
-                'is_removed' => false,
+                'is_active' => true,
                 'removal_memo' => null,
                 'removed_at' => null,
                 'effective_date' => $date,