Samson Mutunga 3 年 前
コミット
d0ed6393c7

+ 2 - 1
app/Http/Controllers/StatTreeController.php

@@ -71,6 +71,7 @@ class StatTreeController extends Controller
         $rows = json_decode($data, true);
 
         $statTree = StatTree::where('id', $statTreeID)->first();
+        $model = $statTree->model;
         DB::beginTransaction();
         DB::statement("DELETE FROM stat_tree_line WHERE stat_tree_id = :stat_tree_id", ['stat_tree_id' => $statTree->id]);
 
@@ -92,7 +93,7 @@ class StatTreeController extends Controller
                 $cell = $row[$i];
                 if(!$cell || empty($cell)) continue;
 
-                $clause = Clause::where('label', $cell)->first();
+                $clause = Clause::where('label', $cell)->where('model', 'ilike', $model)->first();
                 if(!$clause){
                     DB::rollBack();
                     return $this->fail('No clause record found!');

+ 1 - 1
app/Http/Controllers/StatTreeLineController.php

@@ -59,7 +59,7 @@ class StatTreeLineController extends Controller
         $statTreeLine = StatTreeLine::where('id', $statTreeLineID)->first();
         if (!$statTreeLine) return $this->fail('Invalid stat tree line!');
 
-        $query = $this->applyStatTreeLineQueryClauses($statTreeLine);
+        $query = $this->applyStatTreeLineQueryClauses($statTreeLine);        
         if ($query) {
             $statTreeLine->last_refresh_count = $query->count();
             $statTreeLine->save();

+ 6 - 0
spec/stat-tree-report-builder-spec.txt

@@ -27,6 +27,8 @@ Client	Active device type?	Weight ONLY	()
 Client	Active device type?	BP ONLY	()
 Client	Active device type?	Weight + BP	()
 Client	Type 2 Diabetic	-	()
+Pro	Active pros?	YES	(is_active IS TRUE)
+Pro	Inactive pros?	NO	(is_active IS FALSE)
 
 			WORK:::::::::::::::
 
@@ -59,6 +61,10 @@ Active patient? NO
 	Has active RM device? YES
 	Has active RM device? NO
 
+
+Active pros? YES
+Inactive pros? NO
+
 	stat_tree_line
 		stat_tree_id
 		tree_order_position_index