Переглянути джерело

Merge branch 'dev' into dev-vj

Vijayakrishnan 4 роки тому
батько
коміт
74c443c888

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

@@ -10,6 +10,7 @@ use App\Models\ClientBDTDevice;
 use App\Models\ClientInfoLine;
 use App\Models\Facility;
 use App\Models\Handout;
+use App\Models\MBPayer;
 use App\Models\NoteTemplate;
 use App\Models\Pro;
 use App\Models\Product;
@@ -386,4 +387,9 @@ class PatientController extends Controller
     public function eligibleRefreshes(Request $request, Client $patient) {
         return view('app.patient.eligible-refreshes', compact('patient'));
     }
+
+    public function insuranceCoverage(Request $request, Client $patient) {
+        $mbPayers = MBPayer::paginate(50);
+        return view('app.patient.insurance-coverage', compact('patient', 'mbPayers'));
+    }
 }

+ 29 - 20
app/Http/Controllers/PracticeManagementController.php

@@ -340,29 +340,38 @@ class PracticeManagementController extends Controller
     // poll to check if there are patients with active mcp requests
     public function getPatientsInQueue(Request $request)
     {
-        $requests = McpRequest::where('is_active', true)->where('was_claimed', false)->limit(3)->get();
+
+        $myInitiatives = $this->performer->pro->initiatives;
+        if($myInitiatives){
+            $myInitiatives = strtoupper($myInitiatives);
+        }
+        $myInitiativesList = explode('|', $myInitiatives);
+
+        $myForeignLanguages = $this->performer->pro->foreign_languages;
+        if($myForeignLanguages){
+            $myForeignLanguages = strtoupper($myForeignLanguages);
+        }
+        $myForeignLanguagesList = explode('|', $myForeignLanguages);
+
+        $clients = Client::whereNotNull('active_mcp_request_id')->where(function($query) use ($myInitiativesList){
+            $query->whereNull('initiative')->orWhereIn('initiative', $myInitiativesList);
+        }) 
+        ->where(function($query) use ($myForeignLanguagesList) {
+            $query->whereNull('preferred_foreign_language')->orWhereIn('preferred_foreign_language', $myForeignLanguagesList);
+        })->limit(3)->get();
         $results = [];
-        if ($requests && count($requests)) {
-            foreach ($requests as $mcpRequest) {
-                $client = $mcpRequest->client;
-                // if ($client->initiative) {
-                //     if (strpos($this->performer->pro->initiative, $client->initiative) !== false) {
-                //         $results[] = [
-                //             "clientUid" => $client->uid,
-                //             "name" => $client->displayName(),
-                //             "initials" => substr($client->name_first, 0, 1) . substr($client->name_last, 0, 1)
-                //         ];
-                //     }
-                // } else {
-                $results[] = [
-                    "clientUid" => $client->uid,
-                    "name" => $client->displayName(),
-                    "initials" => substr($client->name_first, 0, 1) . substr($client->name_last, 0, 1)
-                ];
-                //}
-            }
+      
+
+        foreach($clients as $client){
+            $results[] = [
+                'clientUid' => $client->uid, 
+                'name' => $client->displayName(),
+                'initials'=> substr($client->name_first, 0, 1) . substr($client->name_last, 0, 1)
+            ];
         }
+
         return json_encode($results);
+
     }
 
     public function currentWork(Request $request)

+ 13 - 0
app/Models/Client.php

@@ -253,6 +253,13 @@ class Client extends Model
             ->orderBy('created_at', 'desc');
     }
 
+    public function deactivatedDevices()
+    {
+        return $this->hasMany(ClientBDTDevice::class, 'client_id', 'id')
+            ->where('is_active', false)
+            ->orderBy('created_at', 'desc');
+    }
+
     public function hasDevice($_device)
     {
         $count = ClientBDTDevice::where('client_id', $this->id)
@@ -397,6 +404,12 @@ class Client extends Model
             ->orderBy('created_at', 'desc');
     }
 
+    public function mbPayerValidationResults()
+    {
+        return $this->hasMany(ClientMBPayerValidationResult::class, 'client_id', 'id')
+            ->orderBy('created_at', 'desc');
+    }
+
     public function supplyOrders()
     {
         return $this->hasMany(SupplyOrder::class, 'client_id', 'id')

+ 19 - 0
app/Models/ClientMBPayerValidationResult.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Models;
+
+use Carbon\Carbon;
+use DateTime;
+
+# use Illuminate\Database\Eloquent\Model;
+
+class ClientMBPayerValidationResult extends Model
+{
+    protected $table = 'client_mb_payer_validation_result';
+
+    public function mbPayer()
+    {
+        return $this->hasOne(MBPayer::class, 'id', 'mb_payer_id');
+    }
+
+}

+ 12 - 0
app/Models/ClientMemo.php

@@ -2,8 +2,20 @@
 
 namespace App\Models;
 
+use Illuminate\Database\Eloquent\Relations\HasMany;
+use Illuminate\Database\Eloquent\Relations\HasOne;
+
 class ClientMemo extends Model
 {
     protected $table = 'client_memo';
 
+    public function createdBy(): HasOne
+    {
+        return $this->hasOne(AppSession::class, 'id', 'created_by_session_id');
+    }
+
+    public function updates(): HasMany{
+        return $this->hasMany(ClientMemoUpdate::class, 'client_memo_id', 'id')->orderBy('created_at', 'DESC');
+    }
+
 }

+ 17 - 0
app/Models/ClientMemoUpdate.php

@@ -0,0 +1,17 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Relations\HasOne;
+
+class ClientMemoUpdate extends Model
+{
+    protected $table = 'client_memo_update';
+
+    public function createdBy(): HasOne
+    {
+        return $this->hasOne(AppSession::class, 'id', 'created_by_session_id');
+    }
+
+}

+ 20 - 0
app/Models/MBPayer.php

@@ -0,0 +1,20 @@
+<?php
+
+namespace App\Models;
+
+# use Illuminate\Database\Eloquent\Model;
+
+class MBPayer extends Model
+{
+    protected $table = 'mb_payer';
+
+   
+    public function name()
+    {
+        $vendorData = json_decode($this->vendor_data_json, true);
+        if(isset($vendorData['names'])){
+            return $vendorData['names'][0];
+        }
+        return "no set";
+    }
+}

+ 32 - 2
resources/views/app/patient/dashboard.blade.php

@@ -874,8 +874,38 @@
                                 @foreach($patient->memos as $memo)
                                     <tr>
                                         <td class="px-2 text-nowrap">{{ $memo->category }}</td>
-                                        <td class="px-2"><pre class="m-0 break-spaces">{{ $memo->content }}</pre></td>
-                                        <td class="px-2 text-nowrap">{{ friendly_date_time($memo->created_at) }}</td>
+                                        <td class="px-2">
+                                            <pre class="m-0 break-spaces">{{ $memo->content }}</pre>
+                                            @if($performer->pro->pro_type == 'ADMIN')
+                                            <div moe>
+                                                <a start show>Show Changelog</a>
+                                                <div action="" url>
+                                                    <table class="table table-condensed table-striped table-sm">
+                                                        <thead>
+                                                        <th>Category</th>
+                                                        <th>Summary</th>
+                                                        <th>Created</th>
+                                                        </thead>
+                                                        <tbody>
+                                                        @foreach($memo->updates as $update)
+                                                            <tr>
+                                                                <td>{{$update->category}}</td>
+                                                                <td>{{$update->content}}</td>
+                                                                <td><strong>{{$update->createdBy->proname_first}} {{$update->createdBy->pro->name_last}}</strong><br/>{{ friendly_date_time($update->created_at) }}</td>
+                                                            </tr>
+                                                        @endforeach
+                                                        </tbody>
+                                                    </table>
+                                                </div>
+                                            </div>
+                                            @endif
+                                        </td>
+                                        <td class="px-2 text-nowrap">
+                                            @if($performer->pro->pro_type == 'ADMIN')
+                                            <strong>{{$memo->createdBy->proname_first}} {{$memo->createdBy->pro->name_last}}</strong><br/>
+                                            @endif
+                                            {{ friendly_date_time($memo->created_at) }}
+                                        </td>
                                         <td class="px-2 text-center delete-column">
                                             <div moe wide relative class="mr-2">
                                                 <a class="on-hover-opaque" start show title="Edit">

+ 57 - 1
resources/views/app/patient/devices.blade.php

@@ -53,6 +53,7 @@
                     <th class="px-2 text-secondary">Created</th>
                     <th class="px-2 text-secondary w-25">Category</th>
                     <th class="px-2 text-secondary w-50">IMEI</th>
+                    <th class="px-2 text-secondary"></th>
                 </tr>
                 </thead>
                 <tbody>
@@ -61,17 +62,72 @@
                         <td class="px-2">{{ friendly_date_time($device->device->created_at) }}</td>
                         <td class="px-2">{{ $device->device->category }}</td>
                         <td class="px-2"><pre class="m-0">{{ $device->device->imei }}</pre></td>
+                        <td>
+                            <div moe relative>
+                                <a start show class="on-hover-opaque">Deactivate</a>
+                                <form url="/api/clientBdtDevice/deactivate" right>
+                                    <input type="hidden" name="uid" value="{{ $device->uid }}">
+                                    <p class="small">Are you sure you want to deactivate this device?</p>
+                                    <div class="d-flex align-items-center">
+                                        <button class="btn btn-sm btn-danger mr-2" submit>Deactivate</button>
+                                        <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
+                                    </div>
+                                </form>
+                            </div>
+                        </td>
                     </tr>
                 @endforeach
                 </tbody>
             @else
                 <tbody>
                     <tr>
-                        <td class="text-secondary p-3">No devices for this patient</td>
+                        <td class="text-secondary p-3">No active devices for this patient</td>
                     </tr>
                 </tbody>
             @endif
         </table>
+        <hr>
+        <h2>Deactivated Devices</h2>
+        <table class="table table-striped table-sm table-bordered mb-0">
+            @if($patient->deactivatedDevices && count($patient->deactivatedDevices))
+                <thead>
+                <tr>
+                    <th class="px-2 text-secondary">Created</th>
+                    <th class="px-2 text-secondary w-25">Category</th>
+                    <th class="px-2 text-secondary w-50">IMEI</th>
+                    <th class="px-2 text-secondary"></th>
+                </tr>
+                </thead>
+                <tbody>
+                @foreach($patient->deactivatedDevices as $deactivatedDevice)
+                    <tr>
+                        <td class="px-2">{{ friendly_date_time($deactivatedDevice->device->created_at) }}</td>
+                        <td class="px-2">{{ $deactivatedDevice->device->category }}</td>
+                        <td class="px-2"><pre class="m-0">{{ $deactivatedDevice->device->imei }}</pre></td>
+                        <td>
+                            <div moe relative>
+                                <a start show class="on-hover-opaque">Reactivate</a>
+                                <form url="/api/clientBdtDevice/reactivate" right>
+                                    <input type="hidden" name="uid" value="{{ $deactivatedDevice->uid }}">
+                                    <p class="small">Are you sure you want to reactivate this device?</p>
+                                    <div class="d-flex align-items-center">
+                                        <button class="btn btn-sm btn-danger mr-2" submit>Reactivate</button>
+                                        <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
+                                    </div>
+                                </form>
+                            </div>
+                        </td>
+                    </tr>
+                @endforeach
+                </tbody>
+            @else
+                <tbody>
+                <tr>
+                    <td class="text-secondary p-3">No deactivated devices for this patient</td>
+                </tr>
+                </tbody>
+            @endif
+        </table>
     </div>
     <script>
         (function() {

+ 111 - 0
resources/views/app/patient/insurance-coverage.blade.php

@@ -0,0 +1,111 @@
+@extends ('layouts.patient')
+
+@section('inner-content')
+    <?php
+    function toHumanReadable($name) {
+        return ucwords(preg_replace("/[^0-9a-z]/i", " ", $name));
+    }
+    function parseRender($_data) {
+        if($_data) {
+            $type = gettype($_data);
+            if(is_string($_data) || is_numeric($_data)) {
+                echo $_data;
+            }
+            else {
+                echo "<table class='table table-sm border w-100'>";
+                foreach($_data as $k => $v) {
+                    echo "<tr>";
+                    echo "<td><b class='text-secondary'>" . toHumanReadable($k) . "</b></td>";
+                    echo "<td>";
+                    if(is_object($v)) {
+                        parseRender($v);
+                    }
+                    elseif(is_array($v)) {
+                        foreach($v as $k2 => $v2) {
+                            parseRender($v2);
+                        }
+                    }
+                    else {
+                        echo $v;
+                    }
+                    echo "</td>";
+                    echo "</tr>";
+                }
+                echo "</table>";
+            }
+        }
+    }
+    ?>
+    <style>
+        .eligible-table td {
+            white-space: nowrap;
+        }
+    </style>
+<div>
+    <div class="d-flex align-items-center">
+        <h4 class="font-weight-bold m-0 font-size-16">Insurance Coverage</h4>
+        <div class="ml-3">
+            <div moe relative>
+                <a href="" start show class="btn btn-sm btn-primary text-white font-weight-bold small">Add</a>
+                <form url="/api/client/validateAgainstMBPayer" class="mcp-theme-1">
+                    <input type="hidden" name="uid" value="{{$patient->uid}}">
+                    <div class="form-group">
+                        <select name="mbPayerUid"  class="form-control">
+                            <option value=""></option>
+                            @foreach($mbPayers as $mbPayer)
+                            <option value="{{$mbPayer->uid}}">{{$mbPayer->name()}}</option>
+                            @endforeach
+                        </select>
+                    </div>
+                    <div class="form-group">
+                        <label class="control-label">Member Id</label>
+                        <input type="text" name="memberId" class="form-control">
+                    </div>
+                    <div class="form-group">
+                        <label class="control-label">Member First Name</label>
+                        <input type="text" name="memberFirstName" class="form-control">
+                    </div>
+                    <div class="form-group">
+                        <label class="control-label">Member Last Name</label>
+                        <input type="text" name="memberLastName" class="form-control">
+                    </div>
+                    <div class="form-group">
+                        <label class="control-label">Member Dob</label>
+                        <input type="date" name="memberDOB" class="form-control">
+                    </div>
+                    <div>
+                        <button submit class="btn btn-sm btn-primary mr-2">Yes</button>
+                        <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                    </div>
+                </form>
+            </div>
+        </div>
+    </div>
+
+    <table class="table table-sm table-bordered mt-3 mb-0">
+        <thead>
+        <tr>
+            <th>Created At</th>
+            <th class="border-bottom-0 w-25">Payer Name </th>
+            <th class="border-bottom-0 w-25">Eligible Payer ID</th>
+            <th class="border-bottom-0 w-25">Member Details</th>
+            <th class="border-bottom-0">Result</th>
+        </tr>
+        </thead>
+        <tbody>
+        @foreach($patient->mbPayerValidationResults as $mbpvResult)
+            <tr>
+                <td class="text-nowrap">{{friendly_date_time($mbpvResult->created_at)}}</td>
+                <td>{{$mbpvResult->mbPayer->vendor_identifier}}</td>
+                <td>{{$mbpvResult->mbPayer->name()}}</td>
+                <td># {{$mbpvResult->member_id}} | {{$mbpvResult->member_first_name}} | {{$mbpvResult->member_last_name}} | {{$mbpvResult->member_dob}}</td>
+                <td class="">
+                    <pre>
+                    {{json_encode(json_decode($mbpvResult->validation_result_json), JSON_PRETTY_PRINT)}}</td>
+                    </pre>
+            </tr>
+        @endforeach
+        </tbody>
+    </table>
+</div>
+@endsection

+ 2 - 1
resources/views/app/video/call-minimal.blade.php

@@ -277,7 +277,8 @@
                 );
 
                 // refresh to non-client page
-                window.location.href = '/pro/meet/';
+                // window.location.href = '{{ config('app.url') }}/pro/meet/';
+                window.location.reload()
 
             },
 

+ 2 - 1
resources/views/app/video/check-video-minimal.blade.php

@@ -280,7 +280,8 @@
                 );
 
                 // refresh to non-client page
-                window.location.href = '/pro/meet/';
+                // window.location.href = '/pro/meet/';
+                window.location.reload()
 
             },
 

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

@@ -172,6 +172,10 @@
                             <a class="nav-link {{ strpos($routeName, 'patients.view.eligible-refreshes') === 0 ? 'active' : '' }}"
                                href="{{ route('patients.view.eligible-refreshes', $patient) }}">Eligible Refreshes</a>
                         </li>
+                        <li class="nav-item">
+                            <a class="nav-link {{ strpos($routeName, 'patients.view.insurance-coverage') === 0 ? 'active' : '' }}"
+                               href="{{ route('patients.view.insurance-coverage', $patient) }}">Insurance Coverage</a>
+                        </li>
                         @endif
                     </ul>
                     <div class="mt-3 mcp-theme-1">

+ 1 - 0
routes/web.php

@@ -112,6 +112,7 @@ Route::middleware('pro.auth')->group(function () {
     Route::middleware('pro.auth.admin')->group(function(){
         Route::get('patients/view/mcp-requests/{patient?}', 'PatientController@mcpRequests')->name('patients.view.mcp-requests');
         Route::get('patients/view/eligible-refreshes/{patient}', 'PatientController@eligibleRefreshes')->name('patients.view.eligible-refreshes');
+        Route::get('patients/view/insurance-coverage/{patient}', 'PatientController@insuranceCoverage')->name('patients.view.insurance-coverage');
     });
 
     Route::name('patients.view.')->prefix('patients/view/{patient}')->group(function () {