瀏覽代碼

Client > handouts UI

Vijayakrishnan 4 年之前
父節點
當前提交
69900aaea7

+ 8 - 1
app/Http/Controllers/PatientController.php

@@ -9,6 +9,7 @@ use App\Models\Client;
 use App\Models\ClientBDTDevice;
 use App\Models\ClientInfoLine;
 use App\Models\Facility;
+use App\Models\Handout;
 use App\Models\NoteTemplate;
 use App\Models\Pro;
 use App\Models\SectionTemplate;
@@ -152,7 +153,7 @@ class PatientController extends Controller
     {
         $pros = Pro::all();
         $sections = $patient->sections;
-    
+
         $allSections = SectionTemplate::where('is_active', true)->get();
         foreach ($allSections as $section) {
             $section->used = false;
@@ -167,6 +168,12 @@ class PatientController extends Controller
         return view('app.patient.sections', compact('patient', 'pros', 'allSections'));
     }
 
+    public function handouts(Request $request, Client $patient )
+    {
+        $handouts = Handout::where('is_active', true)->get();
+        return view('app.patient.handouts', compact('patient', 'handouts'));
+    }
+
     public function flowSheets(Request $request, Client $patient )
     {
         return view('app.patient.flowsheets', compact('patient'));

+ 16 - 1
app/Models/Client.php

@@ -3,6 +3,7 @@
 namespace App\Models;
 
 use Illuminate\Database\Eloquent\Relations\HasOne;
+use Illuminate\Support\Collection;
 
 # use Illuminate\Database\Eloquent\Model;
 
@@ -35,7 +36,21 @@ class Client extends Model
     }
 
     public function sections() {
-        return $this->hasMany(Section::class, 'client_id', 'id')->where('is_active', true)->orderBy('created_at', 'asc');
+        return $this->hasMany(Section::class, 'client_id', 'id')
+            ->where('is_active', true)
+            ->orderBy('created_at', 'asc');
+    }
+
+    public function handouts() {
+        $mappings = HandoutClient::where('client_id', $this->id)->get();
+        $handouts = new Collection();
+        foreach ($mappings as $mapping) {
+            $handout = Handout::where('id', $mapping->handout_id)->first();
+            $handout->handout_client_uid = $mapping->uid;
+            $handouts->add($handout);
+        }
+        $handouts = $handouts->sortBy('created_at');
+        return $handouts;
     }
 
     public function duplicateOf() {

+ 11 - 0
app/Models/Handout.php

@@ -0,0 +1,11 @@
+<?php
+
+namespace App\Models;
+
+# use Illuminate\Database\Eloquent\Model;
+
+class Handout extends Model
+{
+    protected $table = 'handout';
+
+}

+ 11 - 0
app/Models/HandoutClient.php

@@ -0,0 +1,11 @@
+<?php
+
+namespace App\Models;
+
+# use Illuminate\Database\Eloquent\Model;
+
+class HandoutClient extends Model
+{
+    protected $table = 'handout_client';
+
+}

+ 50 - 0
resources/views/app/patient/handouts.blade.php

@@ -0,0 +1,50 @@
+@extends ('layouts.patient')
+
+@section('inner-content')
+    <div class="">
+        <div class="d-flex align-items-center pb-2">
+            <h4 class="font-weight-bold m-0">Handouts</h4>
+            <span class="mx-2 text-secondary">|</span>
+            <div moe>
+                <a start show class="">Add</a>
+                <form url="/api/handoutClient/create">
+                    <input type="hidden" name="clientUid" value="{{ $patient->uid }}">
+                    <div class="mb-2">
+                        <select name="handoutUid" class="form-control form-control-sm">
+                            <option value=""> --select-- </option>
+                            @foreach($handouts as $handout)
+                                <option value="{{$handout->uid}}">
+                                    {{$handout->display_name}}
+                                </option>
+                            @endforeach
+                        </select>
+                    </div>
+                    <div class="d-flex align-items-center">
+                        <button class="btn btn-sm btn-primary mr-2" submit>Save</button>
+                        <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
+                    </div>
+                </form>
+            </div>
+        </div>
+        <table class="table table-striped table-sm table-bordered m-0">
+            <thead>
+            <tr>
+                <th class="px-2 text-secondary">Internal Name</th>
+                <th class="px-2 text-secondary">Display Name</th>
+                <th class="px-2 text-secondary">View</th>
+                <th class="px-2 text-secondary w-50">Shareable Link</th>
+            </tr>
+            </thead>
+            <tbody>
+            @foreach($patient->handouts() as $handout)
+                <tr>
+                    <td class="px-2">{{$handout->internal_name}}</td>
+                    <td class="px-2">{{$handout->display_name}}</td>
+                    <td class="px-2"><a href="#">View</a></td>
+                    <td class="px-2">{{ env('APP_URL') }}/guest/handout/{{ $handout->handout_client_uid }}</td>
+                </tr>
+            @endforeach
+            </tbody>
+        </table>
+    </div>
+@endsection

+ 4 - 0
resources/views/layouts/patient.blade.php

@@ -37,6 +37,10 @@
                             <a class="nav-link {{ strpos($routeName, 'patients.view.sections') === 0 ? 'active' : '' }}"
                                href="{{ route('patients.view.sections', ['patient' => $patient]) }}">Sections</a>
                         </li>
+                        <li class="nav-item">
+                            <a class="nav-link {{ strpos($routeName, 'patients.view.handouts') === 0 ? 'active' : '' }}"
+                               href="{{ route('patients.view.handouts', ['patient' => $patient]) }}">Handouts</a>
+                        </li>
                         <li class="nav-item">
                             <a class="nav-link {{ strpos($routeName, 'patients.view.action-items') === 0 ? 'active' : '' }}"
                                href="{{ route('patients.view.action-items', ['patient' => $patient]) }}">ERx/Orders</a>

+ 2 - 1
routes/web.php

@@ -101,6 +101,7 @@ Route::middleware('pro.auth')->group(function () {
             Route::get('', 'NoteController@dashboard')->name('dashboard');
         });
         Route::get('sections', 'PatientController@sections')->name('sections');
+        Route::get('handouts', 'PatientController@handouts')->name('handouts');
         Route::get('flowsheets', 'PatientController@flowSheets')->name('flowsheets');
         Route::get('settings', 'PatientController@settings')->name('settings');
         Route::get('account', 'PatientController@account')->name('account');
@@ -160,7 +161,7 @@ Route::middleware('pro.auth')->group(function () {
     Route::get('/note/{note_uid}', 'NoteController@renderNote')->name('render-note');
     Route::get('/section_create_form/{note_uid}/{section_template_uid}', 'NoteController@sectionCreateForm')->name('section_create_form');
     Route::get('/section_update_form/{section_uid}', 'NoteController@sectionUpdateForm')->name('section_update_form');
-   
+
 
     Route::get("/log_in_as", 'HomeController@logInAs')->name('log-in-as');
     Route::post("/process-log_in_as", 'HomeController@processLogInAs')->name('process-log-in-as');