Procházet zdrojové kódy

Merge branch 'master' into dev-vj

Vijayakrishnan před 3 roky
rodič
revize
1d0d2255ad

+ 12 - 11
app/Http/Controllers/AdminController.php

@@ -158,16 +158,17 @@ class AdminController extends Controller
             }
         }
 
-        switch($request->input('status')) {
-            case 'ACTIVE':
-                $patients->where('is_active', true)->where('has_mcp_done_onboarding_visit', true);
-                break;
-            case 'AWAITING_VISIT':
-                $patients->where('is_active', true)->where('has_mcp_done_onboarding_visit', false);
-                break;
-            case 'INACTIVE':
-                $patients->where('is_active', '<>', true);
-                break;
+        $status = $request->input('status');
+        if($status){
+            if($status == 'ACTIVE'){
+                $patients->where('is_active', true)->where(function($q) use ($status){
+                    return $q->where('client_engagement_status_category', $status)
+                    ->orWhereNull('client_engagement_status_category');
+                });    
+            }else {
+                $patients->where('client_engagement_status_category', $status);
+            }
+
         }
 
         $initiative = $request->input('initiative');
@@ -177,7 +178,7 @@ class AdminController extends Controller
         }
 
         $include_test_records = $request->input('include_test_records');
-        if(!$include_test_records){
+        if(!$include_test_records && $status != 'DUMMY'){
             $patients = $patients->where(function ($q) {
                 $q->whereNull('client_engagement_status_category')
                     ->orWhere('client_engagement_status_category', '<>', 'DUMMY');

+ 5 - 0
app/Http/Controllers/PatientController.php

@@ -285,6 +285,11 @@ class PatientController extends Controller
         return view('app.patient.sms', compact('patient'));
     }
 
+    public function outgoingSmsLog(Request $request, Client $patient )
+    {
+        return view('app.patient.outgoing-sms-log', compact('patient'));
+    }
+
     public function smsNumbers(Request $request, Client $patient )
     {
         return view('app.patient.sms-numbers', compact('patient'));

+ 32 - 0
app/Models/Client.php

@@ -321,6 +321,12 @@ class Client extends Model
             ->orderBy('created_at', 'desc');
     }
 
+    public function ismses()
+    {
+        return $this->hasMany(Isms::class, 'client_id', 'id')
+            ->orderBy('created_at', 'desc');
+    }
+
     public function documents()
     {
         return $this->hasMany(ClientDocument::class, 'client_id', 'id')
@@ -930,6 +936,13 @@ ORDER BY m.ts DESC
         return $this->hasOne(Status::class, 'id', 'client_engagement_status_id');
     }
 
+    public function getDeviceDeliveryStatus($productId){
+        $result =  DB::select("SELECT sh.status FROM shipment sh LEFT JOIN supply_order so ON so.shipment_id = sh.id WHERE so.product_id  = ".$productId." AND so.client_id = ".$this->id." ORDER BY sh.created_at DESC LIMIT 1");
+        if (count($result)){
+            return $result[0]->status; 
+        }
+        return '';
+    }
     public function hasDataInCanvas($_type) {
         $page = Page::where('client_id', $this->id)->where('category', 'CANVAS')->where('key', $_type)->first();
         $contentData = [];
@@ -961,4 +974,23 @@ ORDER BY m.ts DESC
         return false;
     }
 
+    // 4 Infra-red Temperature gun 
+    public function temparatureGunDeliveryStatus(){
+       return $this->getDeviceDeliveryStatus(4);
+    }
+
+    // 3 Pulse Oximeter (
+    public function pulseOximeterDeliveryStatus(){
+        return $this->getDeviceDeliveryStatus(3);
+    }
+    // 1 Cellular BP - Standard Arm Cuff (if delivered, then it should show its status as Delivered, Dispatched, In-transit, Returned)
+    public function cellularBPDeliveryStatus(){
+        return $this->getDeviceDeliveryStatus(1);
+    }
+    // 2 Weight scale 
+    public function weightScaleDeliveryStatus(){
+        return $this->getDeviceDeliveryStatus(2);
+    }
+
+
 }

+ 11 - 0
app/Models/Isms.php

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

+ 12 - 2
resources/views/app/admin/patients-table-extended.blade.php

@@ -14,6 +14,7 @@
                 <th class="border-0">MCP</th>
                 <th class="border-0">NA</th>
                 <th class="border-0">Initiative</th>
+                <th class="border-9">Status</th>
                 <th class="border-0">Source</th>
             @endif
             <th class="border-0">Mailing Address State</th>
@@ -42,6 +43,10 @@
             <th class="border-0">Assigned On</th>
             
 	        <th class="border-0">Email Address</th>
+            <th class="border-0">Temparature Gun Delivery Status</th>
+            <th class="border-0">Pulse Oximeter Delivery Status</th>
+            <th class="border-0">Cellular Bp Delivery Status</th>
+            <th class="border-0">Weight Scale Delivery Status</th>
         </tr>
         </thead>
         <tbody>
@@ -61,6 +66,7 @@
                     <td>{{@$patient->mcp ? $patient->mcp->displayName() : '--'}}</td>
                     <td>{{@$patient->defaultNaPro ? $patient->defaultNaPro->displayName() : '--'}}</td>
                     <td>{{$patient->initiative}}</td>
+                    <td>{{$patient->client_engagement_status_category == 'DUMMY'? 'Test Record': $patient->client_engagement_status_category}}</td>
                     <td>{{$patient->source}}</td>
                 @endif
                 <td>{{$patient->mailing_address_state}}</td>
@@ -76,8 +82,8 @@
                         {{$patient->nextMcpAppointment ? $patient->nextMcpAppointment->status : '-'}}
                     </div>
                 </td>
-                <td>{{ friendlier_date_time($patient->most_recent_cellular_bp_measurement_at, false) }}</td>
-                <td>{{ friendlier_date_time($patient->most_recent_cellular_weight_measurement_at, false) }}</td>
+                <td>{{ friendlier_date_time($patient->most_recent_cellular_bp_measurement_at) }}</td>
+                <td>{{ friendlier_date_time($patient->most_recent_cellular_weight_measurement_at) }}</td>
                 <td>
                     <div title="{{friendly_date_time($patient->created_at)}}">{{friendly_date_time($patient->created_at, false)}}</div>
                     <div class="mt-1" if-details-view>
@@ -320,6 +326,10 @@
                 <td>{{count($patient->cellularMeasurements)}}</td>
                 <td>{{$patient->getMcpAssignedOn()}}</td>
                 <td>{{$patient->email_address}}</td>
+                <td>{{$patient->temparatureGunDeliveryStatus()}}</td>
+                <td>{{$patient->pulseOximeterDeliveryStatus()}}</td>
+                <td>{{$patient->hasBPDevice()?'DELIVERED':''}}</td>
+                <td>{{$patient->hasWeightScaleDevice()?'DELIVERED':''}}</td>
             </tr>
         @endforeach
 

+ 8 - 3
resources/views/app/admin/patients_filters.blade.php

@@ -166,9 +166,14 @@
 			<label>Status:</label>
 			<select name="status" class="form-control input-sm" v-model="filters.status">
 				<option value="">All</option>
-				<option value="ACTIVE">Active</option>
-				<option value="AWAITING_VISIT">Awaiting Visit</option>
-				<option value="INACTIVE">Inactive</option>
+ 				<option value="ACTIVE">Active</option>
+ 				<option value="DUMMY">Test Record</option>
+ 				<option value="NO_LONGER_INTERESTED">No Longer Interested</option>
+ 				<option value="INACTIVE">Inactive</option>
+ 				<option value="ENTRY_ERROR">Entry Error</option>
+ 				<option value="DUPLICATE">Duplicate</option>
+ 				<option value="DECEASED">Deceased</option>
+ 				<option value="BAD_RECORD">Bad Record</option>
 			</select>
 		</div>
 	</div>

+ 29 - 0
resources/views/app/patient/outgoing-sms-log.blade.php

@@ -0,0 +1,29 @@
+@extends ('layouts.patient')
+@section('inner-content')
+    <div class="">
+        <div class="d-flex align-items-center pb-2">
+            <h4 class="font-weight-bold m-0">Outgoing SMS Messages</h4>
+        </div>
+        <table class="table table-striped table-sm table-bordered">
+            <thead class="bg-light">
+            <tr>
+                <th class="border-0 text-secondary text-nowrap">Date &amp; Time</th>
+                <th class="border-0 text-secondary w-25">From</th>
+                <th class="border-0 text-secondary w-25">To</th>
+                <th class="border-0 text-secondary w-50">Content</th>               
+            </tr>
+            </thead>
+            <tbody>
+            @foreach($patient->ismses as $sms)
+                <tr class="{{$sms->created_at > $patient->last_sms_sent_to_client_at && $sms->is_reply_needed == 'YES' ? 'bg-warning': ''}}">
+                    <td class="text-nowrap">{{ friendly_date_time($sms->created_at) }}</td>
+                    <td>{{ $sms->from_number }}</td>
+                    <td>{{ $sms->to_number }}</td>
+                    <td>{{ $sms->message }}</td>
+                </tr>
+            @endforeach
+            </tbody>
+        </table>
+    </div>
+    
+@endsection

+ 1 - 0
resources/views/app/patient/sms.blade.php

@@ -93,4 +93,5 @@
             </tbody>
         </table>
     </div>
+    
 @endsection

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

@@ -227,6 +227,10 @@ $isOldClient = (date_diff(date_create(config('app.point_impl_date')), date_creat
 							<a class="nav-link {{ strpos($routeName, 'patients.view.sms-numbers') === 0 ? 'active' : '' }}"
 							   href="{{ route('patients.view.sms-numbers', ['patient' => $patient]) }}">SMS Numbers</a>
 						</li>
+						<li class="nav-item">
+							<a class="nav-link {{ $routeName === 'patients.view.outgoing-sms-log' ? 'active' : '' }}"
+							   href="{{ route('patients.view.outgoing-sms-log', ['patient' => $patient]) }}">Outgoing SMS Log</a>
+						</li>
 						<li class="nav-item">
 							<a class="nav-link {{ strpos($routeName, 'patients.view.documents') === 0 ? 'active' : '' }}"
 							   href="{{ route('patients.view.documents', ['patient' => $patient]) }}">Documents</a>

+ 1 - 0
routes/web.php

@@ -459,6 +459,7 @@ Route::middleware('pro.auth')->group(function () {
             Route::get('history', 'PatientController@history')->name('history');
             Route::get('memos', 'PatientController@memos')->name('memos');
             Route::get('sms', 'PatientController@sms')->name('sms');
+            Route::get('outgoing-sms-log', 'PatientController@outgoingSmsLog')->name('outgoing-sms-log');
             Route::get('sms-numbers', 'PatientController@smsNumbers')->name('sms-numbers');
             Route::get('immunizations', 'PatientController@immunizations')->name('immunizations');
             Route::get('allergies', 'PatientController@allergies')->name('allergies');