Explorar el Código

Point review log tech

Vijayakrishnan hace 3 años
padre
commit
60e4b4a870

+ 11 - 0
app/Http/Controllers/NoteController.php

@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
 
 use App\Models\AppSession;
 use App\Models\Page;
+use App\Models\Point;
 use App\Models\Pro;
 use App\Models\SupplyOrder;
 use App\Models\Ticket;
@@ -276,6 +277,16 @@ class NoteController extends Controller
         ];
     }
 
+    // review log
+    public function reviewLog(Point $point) {
+        return view('app.patient.note.review-log', compact('point'));
+    }
+
+    // plan log
+    public function planLog(Point $point) {
+
+    }
+
     // TODO move to utility
     private function callJava($request, $endPoint, $data, $guestAccessCode = null)
     {

+ 24 - 0
app/Models/Point.php

@@ -8,6 +8,13 @@ class Point extends Model
 {
     protected $table = 'point';
 
+    public function childReviews()
+    {
+        return $this->hasMany(Point::class, 'parent_point_id', 'id')
+            ->where('category', 'REVIEW')
+            ->orderBy('created_at', 'DESC');
+    }
+
     public function lastChildReview()
     {
         return $this->hasOne(Point::class, 'id', 'last_child_review_point_id');
@@ -18,6 +25,13 @@ class Point extends Model
         return $this->hasOne(Note::class, 'id', 'last_child_review_point_scoped_note_id');
     }
 
+    public function childPlans()
+    {
+        return $this->hasMany(Point::class, 'parent_point_id', 'id')
+            ->where('category', 'PLAN')
+            ->orderBy('created_at', 'DESC');
+    }
+
     public function lastChildPlan()
     {
         return $this->hasOne(Point::class, 'id', 'last_child_plan_point_id');
@@ -28,6 +42,16 @@ class Point extends Model
         return $this->hasOne(Note::class, 'id', 'last_child_plan_point_scoped_note_id');
     }
 
+    public function client()
+    {
+        return $this->hasOne(Client::class, 'id', 'client_id');
+    }
+
+    public function note()
+    {
+        return $this->hasOne(Note::class, 'id', 'added_in_note_id');
+    }
+
     public static function getGlobalSingletonOfCategory(Client $_patient, String $_category, $_assoc = false) {
         $point = Point
             ::where('client_id', $_patient->id)

+ 35 - 0
resources/views/app/patient/note/review-log.blade.php

@@ -0,0 +1,35 @@
+<div class="p-3">
+    <?php $numReviews = 0; ?>
+    @foreach($point->childReviews as $record)
+        @if(@$record->data)
+            <?php $numReviews++; ?>
+            <div class="border mb-3">
+                <div class="border-bottom p-2">
+                    <span class="text-secondary text-sm">Reviewed on: </span>
+                    <a native target="_blank" class="text-sm"
+                       href="<?= route('patients.view.notes.view.dashboard', ['patient' => $record->client, 'note' => $record->note]) ?>">
+                        <?= friendlier_date_time($record->created_at) ?>
+                    </a>
+                </div>
+                <div class="p-2">
+                    <?php
+                    if (file_exists(resource_path('views/app/patient/segment-templates/_review/' . strtolower($record->parent_category) . '/view.php'))) {
+                        $review = json_decode($record->data);
+                        include resource_path('views/app/patient/segment-templates/_review/problem/view.php');
+                    } else {
+                        $review = json_decode($record->data);
+                        echo $review->value;
+                    }
+                    ?>
+                </div>
+            </div>
+        @endif
+    @endforeach
+    @if(!$numReviews)
+        <div class="border mb-3">
+            <div class="p-2">
+                No reviews
+            </div>
+        </div>
+    @endif
+</div>

+ 3 - 0
routes/web.php

@@ -304,6 +304,9 @@ Route::middleware('pro.auth')->group(function () {
 
     });
 
+    Route::get('/point/review-log/{point}', 'NoteController@reviewLog')->name('point-review-log');
+    Route::get('/point/plan-log/{point}', 'NoteController@planLog')->name('point-plan-log');
+
     //mb claim single view
     Route::get('mb-claims/view/{mbClaim}', 'PatientController@mbClaim')->name('mb-claim');