Ver Fonte

Merge branch 'dev' into dev-vj

Vijayakrishnan há 4 anos atrás
pai
commit
5ca51de926

+ 19 - 0
app/Helpers/helpers.php

@@ -80,6 +80,25 @@ if(!function_exists('friendly_date_time_short_with_tz_from_timestamp')) {
     }
 }
 
+if(!function_exists('friendly_date_time_short_with_tz_from_timestamp_divide1000')) {
+    function friendly_date_time_short_with_tz_from_timestamp_divide1000($value, $tz='UTC', $default = '-') {
+
+        if(!$value || empty($value)) return $default;
+        try {
+            $value = (floor($value / 1000));
+            $realTimezone = resolve_timezone($tz);
+            $date = new DateTime("@$value");
+            $date->setTimezone(new DateTimeZone($realTimezone));
+
+            return $date->format("m/d/y, h:iA");
+
+        }
+        catch (Exception $e) {
+            return $e->getMessage();
+        }
+    }
+}
+
 if(!function_exists('friendly_date')) {
     function friendly_date($value) {
         if(!$value || empty($value)) return '';

+ 10 - 2
app/Http/Controllers/PracticeManagementController.php

@@ -3,6 +3,7 @@
 namespace App\Http\Controllers;
 
 use App\Models\AppSession;
+use App\Models\Measurement;
 use App\Models\Bill;
 use App\Models\Claim;
 use App\Models\Client;
@@ -423,19 +424,20 @@ class PracticeManagementController extends Controller
         $targetPro = null;
         $allPros = [];
         $expectedForHcp = null;
+
         if ($performerPro->pro_type == 'ADMIN') {
             $allPros = Pro::all();
             $targetPro = Pro::where('uid', $proUid)->first();
         } else {
             $targetPro = $performerPro;
         }
-        $bills = [];
+        $rows = [];
         if ($targetPro) {
             $rows = DB::select(DB::raw("SELECT * FROM aemish_bill_report WHERE hcp_pro_id = :targetProID"), ['targetProID' => $targetPro->id]);
         } else {
             $rows = DB::select(DB::raw("SELECT * FROM aemish_bill_report"));
         }
-        return view('app.practice-management.hcp-bill-matrix', compact('bills', 'allPros', 'expectedForHcp', 'targetPro', 'proUid'));
+        return view('app.practice-management.hcp-bill-matrix', compact('rows', 'allPros', 'expectedForHcp', 'targetPro', 'proUid'));
     }
 
     public function billingManager(Request $request, $proUid = null)
@@ -483,4 +485,10 @@ class PracticeManagementController extends Controller
         $tickets = Ticket::orderBy('created_at', 'desc')->paginate();
         return view('app.practice-management.tickets', compact('tickets'));
     }
+
+    public function cellularMeasurements(Request $request){
+        $measurements = Measurement::orderBy('ts', 'desc')->whereNotNull('ts')->paginate();
+        return view('app.practice-management.cellular-measurements', compact('measurements'));
+    }
+
 }

+ 5 - 0
app/Models/BDTMeasurement.php

@@ -10,4 +10,9 @@ class BDTMeasurement extends Model
         return $this->hasOne(BDTDevice::class, 'id', 'device_id');
     }
 
+    public function clientBDTMeasurements()
+    {
+        return $this->hasMany(ClientBDTMeasurement::class, 'bdt_measurement_id', 'id');
+    }
+
 }

+ 9 - 0
app/Models/Client.php

@@ -121,6 +121,15 @@ class Client extends Model
             ->orderBy('effective_date', 'desc');
     }
 
+    public function nonZeroMeasurements()
+    {
+        return $this->hasMany(Measurement::class, 'client_id', 'id')
+            /*->distinct('label')*/
+            ->where('is_removed', false)
+            ->where('is_cellular_zero', false)
+            ->orderBy('effective_date', 'desc');
+    }
+
     public function currentCareMonth()
     {
         $cmStartDate = strtotime(date('Y-m-d'));

+ 5 - 0
app/Models/ClientBDTMeasurement.php

@@ -9,4 +9,9 @@ class ClientBDTMeasurement extends Model
     public function measurement() {
         return $this->hasOne(BDTMeasurement::class, 'id', 'bdt_measurement_id');
     }
+
+    public function client() {
+        return $this->hasOne(Client::class, 'id', 'client_id');
+    }
+
 }

+ 4 - 2
app/Models/Pro.php

@@ -333,6 +333,8 @@ class Pro extends Model
         if ($_onlyUnstamped) {
             $measurementsQuery
                 ->whereNotNull('client_bdt_measurement_id')
+                ->whereNotNull('ts')
+                ->where('is_cellular_zero', '!=', true)
                 ->where(function ($q) {
                     $q->whereNull('status')
                         ->orWhere(function ($q2) {
@@ -342,7 +344,7 @@ class Pro extends Model
                 });
         }
 	$x = [];
-        $measurements = $measurementsQuery->orderBy('id', 'desc')->paginate(50);
+        $measurements = $measurementsQuery->orderBy('ts', 'desc')->paginate(50);
 
         // eager load stuff needed in JS
         foreach ($measurements as $measurement) {
@@ -366,7 +368,7 @@ class Pro extends Model
 	        // }
 	        $x[] = $measurement;
 	    }
-	
+
         return $measurements;
     }
 }

+ 10 - 10
resources/views/app/dashboard/measurements.blade.php

@@ -15,7 +15,7 @@
     </thead>
     <tbody>
         @if(count($measurements))
-            <?php foreach($measurements as $measurement): ?> 
+            <?php foreach($measurements as $measurement): ?>
                 <?php if(in_array($measurement->label, ['SBP', 'DBP']) ) continue; ?>
                 <tr>
                     <td class="px-2">
@@ -27,23 +27,23 @@
                     <td class="px-2">
                         @if(!$measurement->clientBDTMeasurement)
                          <div><b>{{ $measurement->value }}</b></div>
-                        @else 
+                        @else
                         <div>
                             @if($measurement->label == 'BP')
                             <div>
-                                <b>{{ $measurement->clientBdtMeasurement->measurement->systolic_bp_in_mm_hg }}</b>/<b>{{ $measurement->clientBdtMeasurement->measurement->diastolic_bp_in_mm_hg }}</b> mmHg
+                                <b>{{ $measurement->sbp_mm_hg }}</b>/<b>{{ $measurement->dbp_mm_hg }}</b> mmHg
                             </div>
                             @endif
                             @if($measurement->label == 'Wt. (lbs.)')
                             <div>
-                                <b>{{ floor($measurement->clientBdtMeasurement->measurement->weight_in_pounds)}}</b> lbs
+                                <b>{{ round($measurement->numeric_value, 1)}}</b> lbs
                             </div>
                             @endif
                         </div>
                         @endif
                     </td>
                     <td>
-                        {{$measurement->timestamp}}
+                        {{$measurement->ts}}
                     </td>
                     <td class="px-2">
                         @if($measurement->careMonth)
@@ -51,14 +51,14 @@
                         @endif
                     </td>
                     <td colspan="px-2">
-                        @if($measurement->clientBdtMeasurement) 
+                        @if($measurement->clientBdtMeasurement)
                         <span moe large relative>
                             <a start show class="py-0 mb-3 font-weight-bold">Update status</a>
-                            <form url="/api/measurement/updateStatus" right>   
+                            <form url="/api/measurement/updateStatus" right>
                                 <input type="hidden" name="uid" value="{{$measurement->uid}}">
                                 <select name="status" id="" class="form-control input-sm">
                                     <option value="">--select--</option>
-                                    <option value="ACK">Ok</option> 
+                                    <option value="ACK">Ok</option>
                                     <option value="INVALID_ACK">Invalid</option>
                                 </select>
                                 <div class="d-flex align-items-center mt-2">
@@ -89,7 +89,7 @@
                                             <span class="width-50px text-left text-secondary">Value</span>
                                             @if(!$measurement->clientBDTMeasurement)
                                                 <div><b>{{ $measurement->value }}</b></div>
-                                            @else 
+                                            @else
                                                 <div>
                                                     @if($measurement->label == 'BP')
                                                     <div>
@@ -98,7 +98,7 @@
                                                     @endif
                                                     @if($measurement->label == 'Wt. (lbs.)')
                                                     <div>
-                                                        <b>{{ floor($measurement->clientBdtMeasurement->measurement->weight_in_pounds)}}</b> lbs 
+                                                        <b>{{ floor($measurement->clientBdtMeasurement->measurement->weight_in_pounds)}}</b> lbs
                                                     </div>
                                                     @endif
                                                 </div>

+ 20 - 1
resources/views/app/patient/measurements.blade.php

@@ -25,6 +25,23 @@
                         </div>
                     </form>
                 </div>
+                @if($performer->pro->pro_type == 'ADMIN')
+                <span class="mx-2 text-secondary">|</span>
+                <div moe>
+                    <a start show class="py-0 font-weight-normal">Process Client BDT Measurements Report</a>
+                    <form url="/api/clientBdtReport/processClientBdtReport">
+                        <input type="hidden" name="uid" value="{{ $patient->uid }}">
+                        <div class="mb-2">
+                            <label for="" class="control-label">Process client bd measurements report?</label>
+                        </div>
+                       
+                        <div class="d-flex align-items-center">
+                            <button class="btn btn-sm btn-primary mr-2" submit>Yes</button>
+                            <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
+                        </div>
+                    </form>
+                </div>
+                @endif
             </div>
             <table class="table table-striped table-sm table-bordered mt-2 mb-0">
                 <thead>
@@ -47,13 +64,15 @@
                                     <?php $timestampInSec = floor($measurement->bdt_measurement_timestamp/1000); ?>
                                     {{ friendly_date_time_short_with_tz_from_timestamp($timestampInSec, 'EASTERN') }}
                                 @else
-                                    {{ friendly_date_time_short_with_tz($measurement->effective_date, true, 'EASTERN') }} 
+                                    {{ friendly_date_time_short_with_tz($measurement->effective_date, true, 'EASTERN') }}
                                 @endif
                             </td>
                             <td class="px-2">{{ $measurement->label }}</td>
                             <td class="px-2">
                                 @if(empty($measurement->client_bdt_measurement_id))
                                     {{ $measurement->value }}
+                                @elseif($measurement->is_cellular_zero)
+                                    <i class="font-size-11 fa fa-rss"></i>
                                 @else
                                     @if($measurement->label === 'BP')
                                         {{ $measurement->clientBDTMeasurement->measurement->systolic_bp_in_mm_hg }}/{{ $measurement->clientBDTMeasurement->measurement->diastolic_bp_in_mm_hg }} mmHg

+ 19 - 13
resources/views/app/patient/partials/measurements.blade.php

@@ -32,6 +32,14 @@
         @foreach($patient->measurements as $measurement)
             @if(1 || !empty($measurement->label) && !in_array($measurement->label, $vitalLabels))
                 @if(!in_array($measurement->label, ["SBP", "DBP"]))
+                    @if(!empty($measurement->client_bdt_measurement_id))
+                        @if($measurement->label === 'BP' && $measurement->dbp_mm_hg == 0)
+                            <?php continue; ?>
+                        @endif
+                        @if($measurement->label === 'Wt. (lbs.)' && $measurement->value == 0)
+                            <?php continue; ?>
+                        @endif
+                    @endif
                 <tr>
                     <td class="text-black p-0 border-0">
                         <div class="d-flex align-items-center">
@@ -69,23 +77,21 @@
                                     </div>
                                 </form>
                             </div>
-                            <span>{{ $measurement->label }}:</span>
+                            <span>
+                                {{ $measurement->label == 'Wt. (lbs.)' ? 'WT' : $measurement->label}}:
+                            </span>
                             <span class="font-weight-bold ml-1">
-                                @if(empty($measurement->client_bdt_measurement_id))
-                                    {{ $measurement->value }}
+                                @if($measurement->label == 'BP')
+                                    {{ $measurement->sbp_mm_hg }}/{{ $measurement->dbp_mm_hg }} mm Hg
+                                @elseif($measurement->label == 'Wt. (lbs.)')
+                                    {{round($measurement->numeric_value, 1)}} lbs.
+                                @elseif($measurement->numeric_value)
+                                    {{round($measurement->numeric_value)}}
                                 @else
-                                    @if($measurement->label === 'BP')
-                                        {{ $measurement->clientBDTMeasurement->measurement->systolic_bp_in_mm_hg }}/{{ $measurement->clientBDTMeasurement->measurement->diastolic_bp_in_mm_hg }} mmHg
-                                    @elseif($measurement->label === 'SBP')
-                                        {{ $measurement->clientBDTMeasurement->measurement->systolic_bp_in_mm_hg }} mmHg
-                                    @elseif($measurement->label === 'DBP')
-                                        {{ $measurement->clientBDTMeasurement->measurement->diastolic_bp_in_mm_hg }} mmHg
-                                    @elseif($measurement->label === 'Wt. (lbs.)')
-                                        {{ round($measurement->clientBDTMeasurement->measurement->weight_in_pounds, 1) }} lbs
-                                    @endif
+                                    {{ $measurement->value }}
                                 @endif
                             </span>
-                            <span class="font-weight-normal text-secondary ml-2 text-sm">(as on {{ friendly_date_time($measurement->effective_date, false) }})</span>
+                            <span class="font-weight-normal text-secondary ml-2 text-sm">({{ $measurement->ts ? friendly_date_time_short_with_tz_from_timestamp_divide1000($measurement->ts, 'EASTERN') : friendly_date_time($measurement->effective_date, false) }})</span>
                         </div>
                     </td>
                 </tr>

+ 5 - 5
resources/views/app/patient/vitals-graph.blade.php

@@ -46,7 +46,7 @@
         $nextDay = date_format(date_add(date_create($nextDay), date_interval_create_from_date_string('1 day')), 'Y-m-d');
     }
 
-    $allMeasurements = $patient->measurements->toArray();
+    $allMeasurements = $patient->nonZeroMeasurements->toArray();
 
     $bpData = [];
     $weightData = [];
@@ -91,7 +91,7 @@
 
         // weight
         $weight = array_filter($allMeasurements, function($_measurement) use ($date) {
-            return $_measurement['label'] === 'WEIGHT' && $_measurement['effective_date'] === $date;
+            return $_measurement['label'] === 'Wt. (lbs.)' && $_measurement['effective_date'] === $date && !!$_measurement['numeric_value'];
         });
         if(count($weight)) {
             $weight = array_values($weight);
@@ -161,8 +161,8 @@
                         },
                     },
                     regions: [
-                        {axis: 'y', start: 100, end: 145, class: 'safe-region', label: 'Safe Systolic BP: 100 to 145 mmHg'},
-                        {axis: 'y', start: 70, end: 90, class: 'safe-region', label: 'Safe Diastolic BP: 70 to 90 mmHg'}
+                        {axis: 'y', start: 100, end: 130, class: 'safe-region', label: 'Safe Systolic BP: 100 to 130 mmHg'},
+                        {axis: 'y', start: 60, end: 90, class: 'safe-region', label: 'Safe Diastolic BP: 60 to 90 mmHg'}
                     ]
                 });
             }
@@ -197,7 +197,7 @@
                         },
                     },
                     regions: [
-                        {axis: 'y', start: 100, end: 140, class: 'safe-region', label: 'Safe Weight: 100 to 140 lbs'},
+                        // {axis: 'y', start: 100, end: 140, class: 'safe-region', label: 'Safe Weight: 100 to 140 lbs'},
                     ]
                 });
             }

+ 36 - 0
resources/views/app/practice-management/cellular-measurements.blade.php

@@ -0,0 +1,36 @@
+@extends ('layouts.template')
+
+@section('content')
+
+    <div class="p-3 mcp-theme-1">
+
+        <div class="card">
+            <div class="card-body p-0">
+                <table class="table table-sm table-condensed p-0 m-0">
+                    <thead class="bg-light">
+                    <tr>
+                        <th class="border-0">ID</th>
+                        <th class="border-0">Patient</th>
+                        <th>IMEI</th>
+                        <th>Time</th>
+                    </tr>
+                    </thead>
+                    <tbody>
+                    @foreach ($measurements as $m)
+                        <tr class="">
+                            <td>{{$m->ts}}</td>
+                            <td><?php dump($m->toJson()) ?></td>
+                            <td></td>
+                            <td></td>
+                        </tr>
+                    @endforeach
+                    </tbody>
+                </table>
+                <div>
+                    {{$measurements->links()}}
+                </div>
+            </div>
+        </div>
+    </div>
+
+@endsection

+ 35 - 104
resources/views/app/practice-management/hcp-bill-matrix.blade.php

@@ -23,122 +23,53 @@
                 <table class="table table-sm table-condensed p-0 m-0">
                     <thead class="bg-light">
                     <tr>
-                        <th class="border-0">Patient</th>
-                        <th class="border-0">Note Eff. Date</th>
-
-
-                        <th class="border-0">HCP</th>
-
-                        <th class="border-0">Note Signed?</th>
-
-                        <th>Service</th>
-                        <th># of units</th>
-                        <th>Bill Signed?</th>
-                        <th>Cancelled?</th>
-                        <th>HCP ex. amount</th>
-
-                        @if($performer->pro->pro_type == 'ADMIN' && false)
-                            <th class="border-0">Assessments</th>
-                        @endif
-
-                        @if($performer->pro->pro_type == 'ADMIN' && false)
-                            <th class="border-0">Claims</th>
-                        @endif
-                        <th class="px-3 border-0">Created</th>
+                        <th>Name Last</th>
+                        <th>Name First</th>
+                        <th>Eff. Date</th>
+                        <th>New/FU</th>
+                        <th>Note Signed by HCP?</th>
+                        <th>Note Link</th>
+                        <th>Note Cancelled?</th>
+                        <th>HCP Last</th>
+                        <th>HCP First</th>
+                        <th>HCP Pro Link</th>
+                        <th>Bill Signed by HCP?</th>
+                        <th>Code</th>
+                        <th># Units</th>
+                        <th>HCP Expected Payment</th>
+                        <th>HCP Paid?</th>
+                        <th>HCP Paid Amount</th>
+                        <th>Bill Cancelled?</th>
                     </tr>
                     </thead>
                     <tbody>
                     @foreach ($rows as $row)
                         <tr class="">
-                            <td class="">
+                            <td>{{$row->name_last}}</td>
+                            <td>{{$row->name_first}}</td>
+                            <td>{{$row->effective_dateest}}</td>
+                            <td>{{$row->new_or_fu_or_na}}</td>
+                            <td>{{$row->is_note_signed_by_hcp}}</td>
+                            <td>
                                 <a href="/patients/view/{{ $row->client_uid }}/notes/view/{{ $row->note_uid }}">
-                                    {{ $row->client->name_last . ', ', $row->name_first }}
+                                    Note Link
                                 </a>
                             </td>
-                            <td class="">
-                                <a href="/patients/view/{{ $row->client_uid }}/notes/view/{{ $row->note_uid }}"
-                                   class="font-weight-bold">
-                                    {{ friendly_date_time($row->effective_dateest, false) }}
-                                </a>
-                                <span class="ml-1">{{ $row->is_note_cancelled ? '[cancelled]' : '' }}</span>
-                            </td>
-                            <td>{{$row->hcpPro->name_first}} {{$note->hcpPro->name_first}}</td>
-                            <td>{{$note->is_signed_by_hcp?'Yes':'No'}}</td>
-
-
-                            <td>{{$bill->code}}</td>
-                            @if($bill->code == 'Treatment Services')
-                                <td>{{floor($bill->number_of_units*60)}}m</td>
-                            @else
-                                <td>{{$bill->number_of_units}}</td>
-                            @endif
-                            <td>{{$bill->is_signed_by_hcp?'Yes':'No'}}</td>
-                            <td>{{ $bill->is_cancelled ?'Yes':'No'}}</td>
-                            <td>{{ $bill->hcp_expected_payment_amount }}</td>
-
-                            @if($performer->pro->pro_type == 'ADMIN' && false)
-                                <td>
-                                    <table class="table table-sm table-condensed table-stripe">
-                                        <thead>
-                                        <tr>
-                                            <th>Code</th>
-                                            <th>Description</th>
-                                        </tr>
-                                        </thead>
-                                        <tbody>
-                                        @foreach($note->reasons as $reason)
-                                            <tr>
-                                                <td>{{$reason->code}}</td>
-                                                <td>{{$reason->description}}</td>
-                                            </tr>
-                                        @endforeach
-                                        </tbody>
-                                    </table>
-                                </td>
-                            @endif
-                            @if($performer->pro->pro_type == 'ADMIN' && false)
-                                <td>
-                                    <table class="table table-sm table-condensed table-stripe">
-                                        <tbody>
-                                        @foreach($note->claims as $claim)
-                                            <tr>
-                                                <td>{{$claim->iid}}</td>
-                                                <td>{{$claim->was_submitted?'Yes':'No'}}</td>
-                                            </tr>
-                                            <tr>
-                                                <td colspan="2">
-                                                    <strong>Claim Lines</strong>
-                                                    <table class="table table-sm table-condensed table-striped">
-                                                        <tr>
-                                                            <th>CPT</th>
-                                                            <th>ICDs</th>
-                                                            <th>Date of Service</th>
-                                                        </tr>
-                                                        @foreach($claim->lines as $claimLine)
-                                                            <tr>
-                                                                <td>{{$claimLine->cpt}}</td>
-                                                                <td>{{$claimLine->icds()}}</td>
-                                                                <td>{{$claimLine->date_of_service}}</td>
-                                                            </tr>
-                                                        @endforeach
-                                                    </table>
-                                                </td>
-                                            </tr>
-                                        @endforeach
-                                        </tbody>
-                                    </table>
-                                </td>
-                            @endif
-                            <td class="px-3">
-                                {{ friendly_date_time($note->created_at, true) }}
-                            </td>
+                            <td>{{$row->is_note_cancelled}}</td>
+                            <td>{{$row->hcp_last}}</td>
+                            <td>{{$row->hcp_first}}</td>
+                            <td>{{$row->hcp_pro_uid ? '-' : '--'}}</td>
+                            <td>{{$row->is_bill_signed_by_hcp}}</td>
+                            <td>{{$row->code}}</td>
+                            <td>{{$row->number_of_units}}</td>
+                            <td>{{$row->hcp_expected_payment_amount}}</td>
+                            <td>{{$row->has_hcp_been_paid}}</td>
+                            <td>{{$row->hcp_payment_amount}}</td>
+                            <td>{{$row->is_bill_cancelled}}</td>
                         </tr>
                     @endforeach
                     </tbody>
                 </table>
-                <div>
-                    {{$bills->links()}}
-                </div>
             </div>
         </div>
     </div>

+ 2 - 1
resources/views/layouts/template.blade.php

@@ -116,6 +116,7 @@
                         <a class="dropdown-item" href="{{ route('practice-management.billingManager') }}">Billing Manager</a>
 
                         @if($pro && $pro->pro_type == 'ADMIN')
+                            <a class="dropdown-item" href="{{ route('practice-management.cellularMeasurements') }}">Cellular Measurements</a>
                             <a class="dropdown-item" href="{{ route('practice-management.cellularDeviceManager') }}">Cellular Device Manager</a>
                             <a class="dropdown-item" href="{{ route('practice-management.claims') }}">Claims</a>
                             <a class="dropdown-item" href="{{ route('practice-management.hcpBillMatrix') }}">HCP Bill Matrix</a>
@@ -330,7 +331,7 @@
                 });
             });
 
-            
+
 
         });
     </script>

+ 4 - 0
routes/web.php

@@ -86,8 +86,12 @@ Route::middleware('pro.auth')->group(function () {
 
         Route::get('cellular-device-manager/{proUid?}', 'PracticeManagementController@cellularDeviceManager')->name('cellularDeviceManager');
 
+
+
         Route::middleware('pro.auth.admin')->group(function(){
 
+            Route::get('cellular-measurements', 'PracticeManagementController@cellularMeasurements')->name('cellularMeasurements');
+
             Route::get('hcp-bill-matrix/{proUid?}', 'PracticeManagementController@hcpBillMatrix')->name('hcpBillMatrix');
 
             Route::get('tickets', 'PracticeManagementController@tickets')->name('tickets');