Bläddra i källkod

Merge branch 'dev' of rav.triplestart.com:jmudaka/stagfe2 into dev

= 4 år sedan
förälder
incheckning
e42bb807bd
34 ändrade filer med 2153 tillägg och 181 borttagningar
  1. 23 1
      app/Http/Controllers/HomeController.php
  2. 1 1
      app/Http/Controllers/PatientController.php
  3. 194 6
      app/Http/Controllers/PracticeManagementController.php
  4. 4 0
      app/Models/Bill.php
  5. 24 0
      app/Models/Client.php
  6. 2 1
      app/Models/Note.php
  7. 3 3
      app/Models/Pro.php
  8. 10 0
      app/Models/Shipment.php
  9. 10 0
      app/Models/SupplyOrder.php
  10. 25 0
      public/css/style.css
  11. 8 4
      public/js/mc.js
  12. 2 1
      public/js/yemi.js
  13. 31 2
      resources/views/app/dashboard.blade.php
  14. 7 14
      resources/views/app/dashboard/measurements.blade.php
  15. 140 0
      resources/views/app/new-non-mcn-patient.blade.php
  16. 25 0
      resources/views/app/patient/handouts.blade.php
  17. 1 1
      resources/views/app/patient/insurance-coverage.blade.php
  18. 35 20
      resources/views/app/patient/measurements.blade.php
  19. 4 2
      resources/views/app/patient/note/_create-bill.blade.php
  20. 10 0
      resources/views/app/patient/note/_create-claim.blade.php
  21. 501 13
      resources/views/app/patient/note/dashboard.blade.php
  22. 28 4
      resources/views/app/patient/partials/measurements.blade.php
  23. 24 14
      resources/views/app/patient/shipments.blade.php
  24. 35 39
      resources/views/app/patient/supply-orders.blade.php
  25. 19 30
      resources/views/app/patient/vitals-graph.blade.php
  26. 414 0
      resources/views/app/practice-management/bill-matrix.blade.php
  27. 127 10
      resources/views/app/practice-management/billing-manager.blade.php
  28. 183 0
      resources/views/app/practice-management/shipments.blade.php
  29. 233 0
      resources/views/app/practice-management/supply-orders.blade.php
  30. 9 8
      resources/views/app/video/check-video-minimal.blade.php
  31. 1 0
      resources/views/layouts/empty.blade.php
  32. 8 2
      resources/views/layouts/patient.blade.php
  33. 7 5
      resources/views/layouts/template.blade.php
  34. 5 0
      routes/web.php

+ 23 - 1
app/Http/Controllers/HomeController.php

@@ -7,6 +7,7 @@ use App\Models\Appointment;
 use App\Models\AppSession;
 use App\Models\ClientSMS;
 use App\Models\Facility;
+use App\Models\MBPayer;
 use App\Models\ProProAccess;
 use App\Models\Ticket;
 use DateTime;
@@ -290,7 +291,22 @@ class HomeController extends Controller
 
         $measurements = $performer->pro->getMeasurements();
 
-        return view('app/dashboard', compact('keyNumbers', 'reimbursement', 'milliseconds', 'measurements'));
+        // bills & claims
+        $businessNumbers = [];
+
+        // Notes with bills to resolve
+        $businessNumbers['notesWithBillsToResolve'] = Note::where('is_cancelled', '!=', true)
+            ->where('is_bill_closed', '!=', true)
+            ->whereRaw('(SELECT count(id) FROM bill WHERE note_id = note.id AND is_cancelled = false AND is_verified = false) > 0')
+            ->count();
+
+        // Notes pending bill closure
+        $businessNumbers['notesPendingBillingClosure'] = Note::where('is_cancelled', '!=', true)
+            ->where('is_bill_closed', '!=', true)
+            ->whereRaw('(SELECT count(id) FROM bill WHERE note_id = note.id AND (is_cancelled = true OR is_verified = true)) = 0')
+            ->count();
+
+        return view('app/dashboard', compact('keyNumbers', 'reimbursement', 'milliseconds', 'measurements', 'businessNumbers'));
     }
 
     public function dashboardAppointments(Request $request, $from, $to) {
@@ -472,6 +488,12 @@ class HomeController extends Controller
         return view('app/new-patient');
     }
 
+    public function newNonMcnPatient(Request $request)
+    {
+        $mbPayers = MBPayer::all();
+        return view('app/new-non-mcn-patient', compact('mbPayers'));
+    }
+
     public function mc(Request $request, $fragment = "")
     {
         $page = "/";

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

@@ -389,7 +389,7 @@ class PatientController extends Controller
     }
 
     public function insuranceCoverage(Request $request, Client $patient) {
-        $mbPayers = MBPayer::paginate(50);
+        $mbPayers = MBPayer::all();
         return view('app.patient.insurance-coverage', compact('patient', 'mbPayers'));
     }
 }

+ 194 - 6
app/Http/Controllers/PracticeManagementController.php

@@ -10,6 +10,7 @@ use App\Models\Client;
 use App\Models\McpRequest;
 use App\Models\Note;
 use App\Models\Pro;
+use App\Models\Product;
 use App\Models\ProFavorite;
 use App\Models\ProGeneralAvailability;
 use App\Models\ProProAccess;
@@ -18,6 +19,8 @@ use App\Models\ProSpecificAvailability;
 use App\Models\ProSpecificUnavailability;
 use App\Models\ProTextShortcut;
 use App\Models\ProTransaction;
+use App\Models\Shipment;
+use App\Models\SupplyOrder;
 use App\Models\Ticket;
 use Illuminate\Support\Facades\DB;
 use PDF;
@@ -355,16 +358,16 @@ class PracticeManagementController extends Controller
 
         $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 = [];
-      
+
 
         foreach($clients as $client){
             $results[] = [
-                'clientUid' => $client->uid, 
+                'clientUid' => $client->uid,
                 'name' => $client->displayName(),
                 'initials'=> substr($client->name_first, 0, 1) . substr($client->name_last, 0, 1)
             ];
@@ -501,11 +504,91 @@ class PracticeManagementController extends Controller
         $notes = [];
         if ($targetPro) {
             $expectedForHcp = DB::select(DB::raw("SELECT coalesce(SUM(hcp_expected_payment_amount),0) as expected_pay FROM bill WHERE hcp_pro_id = :targetProID  AND is_signed_by_hcp IS TRUE AND is_cancelled = false"), ['targetProID' => $targetPro->id])[0]->expected_pay;
-            $notes = Note::where('hcp_pro_id', $targetPro->id)->orderBy('effective_dateest', 'desc')->paginate();
+            $notes = Note::where('hcp_pro_id', $targetPro->id);
         } else {
-            $notes = Note::orderBy('effective_dateest', 'desc')->paginate();
+            $notes = Note::where('id', '>', 0);
+        }
+
+        $filters = [];
+        $filters['bills_created'] = $request->input('bills_created');
+        $filters['bills_ready_to_verify'] = $request->input('bills_ready_to_verify');
+        $filters['bills_resolved'] = $request->input('bills_resolved');
+        $filters['bills_closed'] = $request->input('bills_closed');
+        $filters['claims_created'] = $request->input('claims_created');
+        $filters['claims_closed'] = $request->input('claims_closed');
+
+        if($filters['bills_created']) {
+            $notes->where(
+                'bill_total_expected',
+                ($filters['bills_created'] === 'yes' ? '>' : '<='),
+                0);
+        }
+
+        if($filters['bills_ready_to_verify']) {
+            $notes->where(
+                'is_bill_ready_to_verify',
+                ($filters['bills_ready_to_verify'] === 'yes' ? '=' : '!='),
+                true);
+        }
+
+        if($filters['bills_resolved']) {
+            $notes->whereRaw('(SELECT count(id) FROM bill WHERE note_id = note.id) > 0'); // have bills
+            if($filters['bills_resolved'] === 'no') {
+                $notes->whereRaw('(SELECT count(id) FROM bill WHERE note_id = note.id AND is_cancelled = false AND is_verified = false) > 0');
+            }
+            elseif($filters['bills_resolved'] === 'yes') {
+                $notes->whereRaw('(SELECT count(id) FROM bill WHERE note_id = note.id AND (is_cancelled = true OR is_verified = false)) = 0');
+            }
         }
-        return view('app.practice-management.billing-manager', compact('notes', 'allPros', 'expectedForHcp', 'targetPro', 'proUid'));
+
+        if($filters['bills_closed']) {
+            $notes->where(
+                'is_bill_closed',
+                ($filters['bills_closed'] === 'yes' ? '=' : '!='),
+                true);
+        }
+
+        if($filters['claims_created']) {
+            $notes->where(
+                'claim_total_expected',
+                ($filters['claims_created'] === 'yes' ? '>' : '<='),
+                0);
+        }
+
+        if($filters['claims_closed']) {
+            $notes->where(
+                'is_claim_closed',
+                ($filters['claims_closed'] === 'yes' ? '=' : '!='),
+                true);
+        }
+
+        $notes = $notes->orderBy('effective_dateest', 'desc')->paginate();
+
+        return view('app.practice-management.billing-manager', compact('notes', 'allPros', 'expectedForHcp', 'targetPro', 'proUid', 'filters'));
+    }
+
+    public function billMatrix(Request $request) {
+        $bClients = [];
+        $bHCPPros = [];
+        $bNAPros = [];
+
+        $filters = [];
+        $filters['client'] = $request->input('client');
+        $filters['service'] = $request->input('service');
+        $filters['hcp'] = $request->input('hcp');
+        $filters['hcp_paid'] = $request->input('hcp_paid');
+        $filters['expected_op'] = $request->input('expected_op');
+        $filters['expected_value'] = $request->input('expected_value');
+        $filters['paid_op'] = $request->input('paid_op');
+        $filters['paid_value'] = $request->input('paid_value');
+        $filters['bal_post_date_op'] = $request->input('bal_post_date_op');
+        $filters['bal_post_date_value'] = $request->input('bal_post_date_value');
+        $filters['hcp_sign'] = $request->input('hcp_sign');
+        $filters['verified'] = $request->input('verified');
+        $filters['cancelled'] = $request->input('cancelled');
+
+        $bills = Bill::orderBy('effective_date')->paginate();
+        return view('app.practice-management.bill-matrix', compact('bills', 'bClients', 'bHCPPros', 'filters'));
     }
 
     public function claims(Request $request)
@@ -531,6 +614,111 @@ class PracticeManagementController extends Controller
         return view('app.practice-management.tickets', compact('tickets'));
     }
 
+    public function supplyOrders(Request $request) {
+
+        // so clients
+        $soClientIDs = DB::table('supply_order')->select('client_id')->distinct()->get()->toArray();
+        $soClientIDs = array_map(function($_x) {
+            return $_x->client_id;
+        }, $soClientIDs);
+        $soClients = Client::whereIn('id', $soClientIDs)->get();
+
+        // so products
+        $soProductIDs = DB::table('supply_order')->select('product_id')->distinct()->get()->toArray();
+        $soProductIDs = array_map(function($_x) {
+            return $_x->product_id;
+        }, $soProductIDs);
+        $soProducts = Product::whereIn('id', $soProductIDs)->get();
+
+        $filters = [];
+        $filters['client'] = $request->input('client');
+        $filters['product'] = $request->input('product');
+        $filters['reason'] = $request->input('reason');
+        $filters['cu_memo'] = $request->input('cu_memo');
+        $filters['pro_sign'] = $request->input('pro_sign');
+        $filters['client_sign'] = $request->input('client_sign');
+        $filters['shipment'] = $request->input('shipment');
+        $filters['lot_number'] = $request->input('lot_number');
+        $filters['imei'] = $request->input('imei');
+        $filters['cancelled'] = $request->input('cancelled');
+
+        $supplyOrders = SupplyOrder::where('id', '>', 0);
+
+        // apply filters
+        if($filters['client']) $supplyOrders->where('client_id', $filters['client']);
+        if($filters['product']) $supplyOrders->where('product_id', $filters['product']);
+        if($filters['reason']) $supplyOrders->where('reason', 'ILIKE', '%' . $filters['reason'] . '%');
+        if($filters['cu_memo']) $supplyOrders->where('cu_memo', 'ILIKE', '%' . $filters['cu_memo'] . '%');
+        if($filters['pro_sign']) $supplyOrders->where('is_signed_by_pro', ($filters['pro_sign'] === 'signed'));
+
+        if($filters['client_sign']) {
+            if($filters['client_sign'] === 'signed')
+                $supplyOrders->where('is_signed_by_client', true);
+            elseif($filters['client_sign'] === 'waived')
+                $supplyOrders->where('is_client_signature_waived', true);
+            else
+                $supplyOrders->where('is_client_signature_waived', false)->where('is_signed_by_client', false);
+        }
+
+        if ($filters['shipment']) {
+            if ($filters['shipment'] === 'not_cleared_for_shipment')
+                $supplyOrders->whereNull('shipment_id')->where('is_cleared_for_shipment', false);
+            elseif ($filters['shipment'] === 'cleared_for_shipment')
+                $supplyOrders->whereNull('shipment_id')->where('is_cleared_for_shipment', true);
+            else
+                $supplyOrders
+                    ->whereNotNull('shipment_id')
+                    ->whereRaw('(SELECT status FROM shipment WHERE id = shipment_id LIMIT 1) = ?', [$filters['shipment']]);
+        }
+
+        if($filters['lot_number']) $supplyOrders->where('lot_number', 'ILIKE', '%' . $filters['lot_number'] . '%');
+        if($filters['imei']) $supplyOrders->where('imei', 'ILIKE', '%' . $filters['imei'] . '%');
+        if($filters['cancelled']) $supplyOrders->where('is_cancelled', ($filters['cancelled'] === 'cancelled'));
+
+        $supplyOrders = $supplyOrders->orderBy('created_at', 'desc')->paginate();
+
+        return view('app.practice-management.supply-orders',
+            compact('supplyOrders', 'filters',
+                'soClients', 'soProducts'
+            )
+        );
+    }
+
+    public function shipments(Request $request, $filter = null) {
+
+        // so clients
+        $shClientIDs = DB::table('shipment')->select('client_id')->distinct()->get()->toArray();
+        $shClientIDs = array_map(function($_x) {
+            return $_x->client_id;
+        }, $shClientIDs);
+        $shClients = Client::whereIn('id', $shClientIDs)->get();
+
+        $shipments = Shipment::where('id', '>', 0);
+
+        $filters = [];
+        $filters['client'] = $request->input('client');
+        $filters['courier'] = $request->input('courier');
+        $filters['tracking_num'] = $request->input('tracking_num');
+        $filters['label'] = $request->input('label');
+        $filters['status'] = $request->input('status');
+        $filters['cancelled'] = $request->input('cancelled');
+
+        if($filters['client']) $shipments->where('client_id', $filters['client']);
+        if($filters['courier']) $shipments->where('courier', 'ILIKE', '%' . $filters['courier'] . '%');
+        if($filters['tracking_num']) $shipments->where('tracking_number', 'ILIKE', '%' . $filters['tracking_num'] . '%');
+        if($filters['label']) {
+            if($filters['label'] === 'yes')
+                $shipments->whereNotNull('label_system_file_id');
+            else
+                $shipments->whereNull('label_system_file_id');
+        }
+        if($filters['status']) $shipments->where('status', $filters['status']);
+        if($filters['cancelled']) $shipments->where('is_cancelled', ($filters['cancelled'] === 'cancelled'));
+
+        $shipments = $shipments->orderBy('created_at', 'desc')->paginate();
+        return view('app.practice-management.shipments', compact('shipments', 'filters', 'shClients'));
+    }
+
     public function cellularMeasurements(Request $request){
         $measurements = Measurement::orderBy('ts', 'desc')->whereNotNull('ts')->paginate();
         return view('app.practice-management.cellular-measurements', compact('measurements'));

+ 4 - 0
app/Models/Bill.php

@@ -24,4 +24,8 @@ class Bill extends Model
     public function hcp() {
         return $this->hasOne(Pro::class, 'id', 'hcp_pro_id');
     }
+
+    public function ally() {
+        return $this->hasOne(Pro::class, 'id', 'na_pro_id');
+    }
 }

+ 24 - 0
app/Models/Client.php

@@ -130,6 +130,25 @@ class Client extends Model
             ->orderBy('effective_date', 'desc');
     }
 
+    public function getNonZeroBpMeasurements(){
+        return $this->hasMany(Measurement::class, 'client_id', 'id')
+            /*->distinct('label')*/
+            ->where('is_removed', false)
+            ->where('label', '=', 'BP')
+            ->where('sbp_mm_hg', '>', 0)
+            ->where('dbp_mm_hg', '>', 0)
+            ->orderBy('ts', 'desc');
+    }
+
+    public function getNonZeroWeightMeasurements(){
+        return $this->hasMany(Measurement::class, 'client_id', 'id')
+            /*->distinct('label')*/
+            ->where('is_removed', false)
+            ->where('label', '=', 'Wt. (lbs.)')
+            ->where('numeric_value', '>', 0)
+            ->orderBy('ts', 'desc');
+    }
+
     public function currentCareMonth()
     {
         $cmStartDate = strtotime(date('Y-m-d'));
@@ -410,6 +429,11 @@ class Client extends Model
             ->orderBy('created_at', 'desc');
     }
 
+    public function payer()
+    {
+        return $this->hasOne(MBPayer::class, 'id', 'mb_payer_id');
+    }
+
     public function supplyOrders()
     {
         return $this->hasMany(SupplyOrder::class, 'client_id', 'id')

+ 2 - 1
app/Models/Note.php

@@ -35,7 +35,8 @@ class Note extends Model
 
     public function bills()
     {
-        return $this->hasMany(Bill::class, 'note_id', 'id');
+        return $this->hasMany(Bill::class, 'note_id', 'id')
+            ->orderBy('id', 'asc');
     }
 
     public function addendums()

+ 3 - 3
app/Models/Pro.php

@@ -348,9 +348,9 @@ class Pro extends Model
 
         // eager load stuff needed in JS
         foreach ($measurements as $measurement) {
-            if ($measurement->client_bdt_measurement_id) {
-                $measurement->bdtMeasurement = $measurement->clientBDTMeasurement->measurement;
-            }
+//            if ($measurement->client_bdt_measurement_id) {
+//                $measurement->bdtMeasurement = $measurement->clientBDTMeasurement->measurement;
+//            }
             unset($measurement->clientBDTMeasurement); // we do not need this travelling to the frontend
 
             $client = [

+ 10 - 0
app/Models/Shipment.php

@@ -8,6 +8,11 @@ class Shipment extends Model
 {
     protected $table = 'shipment';
 
+    public function client()
+    {
+        return $this->hasOne(Client::class, 'id', 'client_id');
+    }
+
     public function supplyOrders() {
         return $this->hasMany(SupplyOrder::class, 'shipment_id', 'id');
     }
@@ -15,4 +20,9 @@ class Shipment extends Model
     public function labelFile() {
         return $this->hasOne(SystemFile::class, 'id', 'label_system_file_id');
     }
+
+    public function createdSession()
+    {
+        return $this->hasOne(AppSession::class, 'id', 'created_by_session_id');
+    }
 }

+ 10 - 0
app/Models/SupplyOrder.php

@@ -8,6 +8,11 @@ class SupplyOrder extends Model
 {
     protected $table = 'supply_order';
 
+    public function client()
+    {
+        return $this->hasOne(Client::class, 'id', 'client_id');
+    }
+
     public function product()
     {
         return $this->hasOne(Product::class, 'id', 'product_id');
@@ -29,4 +34,9 @@ class SupplyOrder extends Model
     public function clearedForShipmentPro() {
         return $this->hasOne(Pro::class, 'id', 'cleared_for_shipment_by_pro_id');
     }
+
+    public function createdSession()
+    {
+        return $this->hasOne(AppSession::class, 'id', 'created_by_session_id');
+    }
 }

+ 25 - 0
public/css/style.css

@@ -274,6 +274,9 @@ body>nav.navbar {
 .mcp-theme-1 .width-30px {
     width: 30px !important;
 }
+.mcp-theme-1 .width-40px {
+    width: 40px !important;
+}
 .mcp-theme-1 .width-50px {
     width: 50px !important;
 }
@@ -458,6 +461,9 @@ input.search_field, textarea.search_field {
     .navbar.navbar-dark+[role="main"] {
         padding-top: 55px;
     }
+    .stag-popup .navbar.navbar-dark+[role="main"] {
+        padding-top: 0;
+    }
 }
 .font-smaller {
     font-size: 11px !important;
@@ -1467,3 +1473,22 @@ canvas.pdf-viewer-page.pdf-preview-page {
 .bg-aliceblue {
     background: aliceblue !important;
 }
+.filter-head input[type="date"]::-webkit-calendar-picker-indicator {
+    display: none;
+    -webkit-appearance: none;
+}
+.filter-head input[type="number"]::-webkit-inner-spin-button {
+    display: none;
+    -webkit-appearance: none;
+}
+.filter-head input[type="date"] {
+    padding: 0;
+    min-width: 90px;
+}
+.filter-head input[type="number"],
+.filter-head input[type="date"] {
+    min-width: 90px;
+}
+.filter-head select {
+    padding: 0 5px;
+}

+ 8 - 4
public/js/mc.js

@@ -1,3 +1,4 @@
+window.top.currentMcUrl = '';
 window.top.addEventListener('popstate', function (event) {
     window.setTimeout(function () {
         hideMask();
@@ -22,6 +23,8 @@ $(document).ready(function () {
         }
     }
 
+    if(window.noMc) return;
+
     // window.top.ensureRHS();
     $(document).on('click', '.stag_rhs_toggle', function () {
         var state = window.top.toggleRHS(),
@@ -52,7 +55,7 @@ $(document).ready(function () {
     // }
 
     // populate history on fresh load
-    var target = window.top.location.pathname;
+    var target = window.top.location.pathname + window.top.location.search;
     if (target.indexOf('/mc') === 0) {
         target = target.split('/mc')[1];
     }
@@ -162,7 +165,10 @@ function onFastLoaded(_data, _href, _history) {
             initPrimaryForm();
             initPatientPresenceIndicator();
             runMCInitializers();
-            $(window).scrollTop(0);
+            if(window.top.currentMcUrl !== window.top.location.href) {
+                $(window).scrollTop(0);
+            }
+            window.top.currentMcUrl = window.top.location.href;
         }, 50);
         // if(typeof initializeCalendar !== 'undefined') {
         //     initializeCalendar();
@@ -183,8 +189,6 @@ function fastLoad(_href, _history = true, _useCache = true, _replaceState = fals
 
     let domPro = $(window.top.document.body).attr('data-pro-uid'),
         lsPro = window.top.localStorage.currentProUid;
-    console.log('ALIX DOM: ', domPro);
-    console.log('ALIX LS: ', lsPro);
     if(lsPro && domPro && lsPro !== domPro) {
         console.warn('ALIX Looks like you have a session as another pro on another tab. Refreshing window.top...');
         window.top.location.href = _href;

+ 2 - 1
public/js/yemi.js

@@ -195,12 +195,13 @@ var pageReload = function () {
 };
 
 var fastReload = function() {
-    var targetLocation = window.top.location.pathname;
+    var targetLocation = window.top.location.pathname + window.top.location.search;
     if(targetLocation.indexOf('/mc') === 0) {
         targetLocation = targetLocation.substr(3);
     }
     if(targetLocation === '' || targetLocation[0] !== '/') targetLocation = '/' + targetLocation;
     fastLoad(targetLocation, false, false);
+    return false;
 }
 
 if (typeof String.prototype.startsWith != 'function') {

+ 31 - 2
resources/views/app/dashboard.blade.php

@@ -50,9 +50,10 @@
                         </table>
                     </div>
                 </div>
-                <div class="card mt-3">
-                    <div class="card-header">
+                <div class="card mb-4">
+                    <div class="card-header pl-2">
                         <strong>
+                            <i class="fas fa-money-bill"></i>
                             Reimbursement
                         </strong>
                     </div>
@@ -85,6 +86,34 @@
                         </table>
                     </div>
                 </div>
+                @if($pro->pro_type === 'ADMIN')
+                <div class="card mb-4">
+                    <div class="card-header pl-2">
+                        <strong>
+                            <i class="fa fa-receipt"></i>
+                            Bills &amp; Claims
+                        </strong>
+                    </div>
+                    <div class="card-body p-0">
+                        <table class="table mb-0">
+                            <tbody>
+                            <tr>
+                                <th class="border-top-0 px-2 text-center">{{$businessNumbers['notesWithBillsToResolve']}}</th>
+                                <th class="border-top-0 pl-2">
+                                    <a native target="_top" href="/practice-management/billing-manager">Notes with bills to resolve</a>
+                                </th>
+                            </tr>
+                            <tr>
+                                <th class="border-top-0 px-2 text-center">{{$businessNumbers['notesPendingBillingClosure']}}</th>
+                                <th class="border-top-0 pl-2">
+                                    <a native target="_top" href="/practice-management/billing-manager">Notes pending billing closure</a>
+                                </th>
+                            </tr>
+                            </tbody>
+                        </table>
+                    </div>
+                </div>
+                @endif
             </div>
             <div class="col-md-9">
 

+ 7 - 14
resources/views/app/dashboard/measurements.blade.php

@@ -25,21 +25,14 @@
                     </td>
                     <td class="px-2">{{ $measurement->label }}</td>
                     <td class="px-2">
-                        @if(!$measurement->clientBDTMeasurement)
-                         <div><b>{{ $measurement->value }}</b></div>
+                        @if($measurement->is_cellular_zero)
+                            <i class="font-size-11 fa fa-rss"></i>
+                        @elseif($measurement->label === 'BP')
+                            {{ $measurement->sbp_mm_hg }}/{{ $measurement->dbp_mm_hg }} mmHg
+                        @elseif($measurement->label === 'Wt. (lbs.)')
+                            {{ $measurement->numeric_value }} lbs
                         @else
-                        <div>
-                            @if($measurement->label == 'BP')
-                            <div>
-                                <b>{{ $measurement->sbp_mm_hg }}</b>/<b>{{ $measurement->dbp_mm_hg }}</b> mmHg
-                            </div>
-                            @endif
-                            @if($measurement->label == 'Wt. (lbs.)')
-                            <div>
-                                <b>{{ round($measurement->numeric_value, 1)}}</b> lbs
-                            </div>
-                            @endif
-                        </div>
+                            {{ $measurement->value }}
                         @endif
                     </td>
                     <td>

+ 140 - 0
resources/views/app/new-non-mcn-patient.blade.php

@@ -0,0 +1,140 @@
+@extends ('layouts.template')
+
+@section('content')
+
+    <?php $patients = [1,2,3,4]; ?>
+
+    <div class="p-3 mcp-theme-1" id="newPatientContainer">
+        <div class="col-12 col-lg-6 px-0">
+            <div class="card d-block mb-3" moe="">
+
+                <div class="card-header">
+                    <strong>
+                        <i class="fas fa-user-plus"></i>
+                        New Patient
+                    </strong>
+                </div>
+                <div class="card-body">
+                    <form show url="/api/client/createNonMcn" class="px-3 pt-3 pb-1 primary-form" redir="patients/view/[data]">
+                        @if (session('message'))
+                            <div class="alert alert-danger">{{ session('message') }}</div>
+                        @endif
+                        <div class='form-group mb-3'>
+                            <label class='control-label'>How is quarantine treating you?</label>
+                            <textarea class='form-control' type='text' name='howIsQuarantine'></textarea>
+                        </div>
+                        <div class='form-group mb-3'>
+                            <label class='control-label'>First Name *</label>
+                            <input class='form-control' type='text' name='nameFirst' required>
+                        </div>
+                        <div class='form-group mb-3'>
+                            <label class='control-label'>Last Name *</label>
+                            <input class='form-control' type='text' name='nameLast' value='' required>
+                        </div>
+                        <div class='form-group mb-3'>
+                            <label class='control-label'>Sex</label>
+                            <select class='form-control' name='sex' value='' >
+                                <option value=''>-- Select --</option>
+                                <option value='M'>M</option>
+                                <option value='F'>F</option>
+                            </select>
+                        </div>
+                        <div class='form-group mb-3'>
+                            <label class='control-label'>Date Of Birth *</label>
+                            <input class='form-control' type='date' name='dateOfBirth' max="{{ date('Y-m-d') }}" required>
+                        </div>
+                        <div class='form-group mb-3'>
+                            <label class='control-label d-flex align-items-center'>
+                                <span>Home Phone Number</span>
+                                <a href="#"
+                                   class="ml-2 px-1 on-hover-opaque hpn-to-cpn">
+                                    <i class="fa fa-arrow-down"></i>
+                                </a>
+                                <a href="#"
+                                   class="ml-2 px-1 on-hover-opaque swap-pns">
+                                    <i class="fa fa-retweet"></i>
+                                </a>
+                            </label>
+                            <input class='form-control' stag-input-phone type='tel' name='homeNumber'>
+                        </div>
+                        <div class='form-group mb-3'>
+                            <label class='control-label d-flex align-items-center'>
+                                <span>Cell Phone Number</span>
+                                <a href="#"
+                                   class="ml-2 px-1 on-hover-opaque cpn-to-hpn">
+                                    <i class="fa fa-arrow-up"></i>
+                                </a>
+                            </label>
+                            <input class='form-control' stag-input-phone type='tel' name='cellNumber'>
+                        </div>
+                        <div class='form-group mb-3'>
+                            <label class='control-label'>Email Address </label>
+                            <input class='form-control' type='email' name='emailAddress'>
+                        </div>
+                        <div class='form-group mb-3'>
+                            <label class='control-label'>Payer</label>
+                            <select name="mbPayerUid" class="form-control select2">
+                                <option value="">--select--</option>
+                                @foreach($mbPayers as $mbPayer)
+                                <option value="{{$mbPayer->uid}}">{{$mbPayer->name()}}</option>
+                                @endforeach
+                            </select>
+                        </div>
+                        <div class='form-group mb-3'>
+                            <label class='control-label'>Member ID</label>
+                            <input class='form-control' type='text' name='mbPayerMemberId' required>
+                        </div>
+                        <div class='form-group mb-3'>
+                            <label class='control-label'>Initiative</label>
+                            <select name="initiative" class="form-control ">
+                                <option value="">-- select --</option>
+                                @foreach($intiatives as $initiative)
+                                <option value="{{$initiative}}">{{$initiative}}</option>
+                                @endforeach
+                            </select>
+                        </div>
+                    </form>
+                </div>
+                <div class="card-footer">
+                    <button class="btn btn-primary" submit>Create New Patient</button>
+                </div>
+            </div>
+        </div>
+    </div>
+
+    <link href="/select2/select2.min.css" rel="stylesheet" />
+    <script src="/select2/select2.min.js"></script>
+    <script src="/inputmask-5.x/dist/inputmask.js"></script>
+    <script>
+        (function() {
+            function init() {
+                let im = new Inputmask("(999) 999-9999").mask('[stag-input-phone]');
+                $(document)
+                    .off('click.hpn-to-cpn', '.hpn-to-cpn')
+                    .on('click.hpn-to-cpn', '.hpn-to-cpn', function() {
+                        $('[name="cellNumber"]').val($('[name="homeNumber"]').val());
+                        $('[name="homeNumber"]').val('');
+                        return false;
+                    });
+                $(document)
+                    .off('click.cpn-to-hpn', '.cpn-to-hpn')
+                    .on('click.cpn-to-hpn', '.cpn-to-hpn', function() {
+                        $('[name="homeNumber"]').val($('[name="cellNumber"]').val());
+                        $('[name="cellNumber"]').val('');
+                        return false;
+                    });
+                $(document)
+                    .off('click.swap-pns', '.swap-pns')
+                    .on('click.swap-pns', '.swap-pns', function() {
+                        let hpn = $('[name="homeNumber"]').val();
+                        $('[name="homeNumber"]').val($('[name="cellNumber"]').val());
+                        $('[name="cellNumber"]').val(hpn);
+                        return false;
+                    });
+                $('.select2').select2();
+            }
+            addMCInitializer('new-patient', init, '#newPatientContainer');
+        }).call(window);
+    </script>
+
+@endsection

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

@@ -33,6 +33,7 @@
                 <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>
+                <th class="px-2 text-secondary"></th>
             </tr>
             </thead>
             <tbody>
@@ -47,6 +48,30 @@
                         </a>
                     </td>
                     <td class="px-2"><b>{{ $downloadLink }}</b></td>
+                    <td class="px-2">
+                        <div moe="" relative="">
+                            <a start="" show="" href="#">SMS Link</a>
+                            <form url="/api/clientSms/createOutgoing" right="" class="mcp-theme-1">
+                                <input type="hidden" name="uid" value="d5de7592-14f1-4df8-aed3-988b1e50afb2">
+                                <div class="mb-2">
+                                    <label for="" class="text-sm text-secondary mb-1">Cell Number</label>
+                                    <input type="text" class="form-control form-control-sm" name="cellNumber" value="{{ $patient->cell_number }}">
+                                </div>
+                                <div class="mb-2">
+                                    <label for="" class="text-sm text-secondary mb-1">Message</label>
+                                    <textarea type="text" rows="10" class="form-control form-control-sm" name="message"
+                                        >Dear {{$patient->displayName()}}, Access the handout ({{$handout->display_name}}) at the following link: {{$downloadLink}}
+                                    </textarea>
+                                </div>
+                                <div class="d-flex align-items-center">
+                                    <button class="btn btn-sm btn-primary mr-2" submit="">Send</button>
+                                    <button class="btn btn-sm btn-default mr-2 border" cancel="">
+                                        Cancel
+                                    </button>
+                                </div>
+                            </form>
+                        </div>
+                    </td>
                 </tr>
             @endforeach
             </tbody>

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

@@ -50,7 +50,7 @@
                 <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">
+                        <select name="mbPayerUid"  class="form-control" select2>
                             <option value=""></option>
                             @foreach($mbPayers as $mbPayer)
                             <option value="{{$mbPayer->uid}}">{{$mbPayer->name()}}</option>

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

@@ -7,14 +7,36 @@
                 <h6 class="my-0 font-weight-bold text-dark">Measurements</h6>
                 <span class="mx-2 text-secondary">|</span>
                 <div moe>
-                    <a start show class="py-0 font-weight-normal">Add</a>
-                    <form url="/api/measurement/create">
+                    <a start show class="py-0 font-weight-normal">Add BP</a>
+                    <form url="/api/measurement/createForBP">
                         <input type="hidden" name="clientUid" value="{{ $patient->uid }}">
+                        <p class="font-weight-bold text-secondary mb-2">Add BP Measurement</p>
+                        <div class="mb-2">
+                            <label class="text-secondary text-sm mb-1">Systolic BP (mmHg)</label>
+                            <input required autofocus type="number" class="form-control form-control-sm" name="sbpMmHg" value="" placeholder="Systolic BP">
+                        </div>
+                        <div class="mb-2">
+                            <label class="text-secondary text-sm mb-1">Diastolic BP (mmHg)</label>
+                            <input required autofocus type="number" class="form-control form-control-sm" name="dbpMmHg" value="" placeholder="Diastolic BP">
+                        </div>
                         <div class="mb-2">
-                            <input required autofocus type="text" class="form-control form-control-sm" name="label" value="" placeholder="Type">
+                            <input required type="date" class="form-control form-control-sm" name="effectiveDate" max="{{ date('Y-m-d') }}" value="{{ date('Y-m-d') }}">
+                        </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>
+                <span class="mx-2 text-secondary">|</span>
+                <div moe>
+                    <a start show class="py-0 font-weight-normal">Add Weight</a>
+                    <form url="/api/measurement/create">
+                        <input type="hidden" name="clientUid" value="{{ $patient->uid }}">
+                        <input type="hidden" name="label" value="Wt. (lbs.)">
+                        <p class="font-weight-bold text-secondary mb-2">Add Weight Measurement</p>
                         <div class="mb-2">
-                            <input required type="text" class="form-control form-control-sm" name="value" value="" placeholder="Value">
+                            <input required type="number" class="form-control form-control-sm" name="value" value="" placeholder="Weight">
                         </div>
                         <div class="mb-2">
                             <input required type="date" class="form-control form-control-sm" name="effectiveDate" max="{{ date('Y-m-d') }}" value="{{ date('Y-m-d') }}">
@@ -49,8 +71,8 @@
                     <th class="px-2 text-secondary w-25">Effective Date</th>
                     <th class="px-2 text-secondary w-25">Category</th>
                     <th class="px-2 text-secondary w-25">Value</th>
-                    {{--<th class="px-2 text-secondary">Status</th>
-                    <th class="px-2 text-secondary">Memo</th>--}}
+                    <th class="px-2 text-secondary">Source</th>
+                    {{--<th class="px-2 text-secondary">Memo</th>--}}
                     <th class="px-2 text-secondary"></th>
                 </tr>
                 </thead>
@@ -70,24 +92,17 @@
                             </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)
+                                @if($measurement->is_cellular_zero)
                                     <i class="font-size-11 fa fa-rss"></i>
+                                @elseif($measurement->label === 'BP')
+                                    {{ $measurement->sbp_mm_hg }}/{{ $measurement->dbp_mm_hg }} mmHg
+                                @elseif($measurement->label === 'Wt. (lbs.)')
+                                    {{ $measurement->numeric_value }} lbs
                                 @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
                             </td>
-                            {{--<td></td>
-                            <td></td>--}}
+                            <td class="px-2">{{$measurement->source}}</td>
                             <td class="px-2">
                                 <span moe relative class="mr-2">
                                     <a class="on-hover-opaque" start show title="Delete">

+ 4 - 2
resources/views/app/patient/note/_create-bill.blade.php

@@ -6,7 +6,7 @@
         <input type="hidden" name="noteUid" value="{{$note->uid}}">
         <div class="mb-2">
             <label for="" class="text-secondary text-sm">Effective Date</label>
-            <input type="date" name="effectiveDate" class="form-control form-control-sm" value="{{date('Y-m-d')}}" required>
+            <input type="date" name="effectiveDate" class="form-control form-control-sm" value="{{$note->effective_dateest ? $note->effective_dateest : date('Y-m-d')}}" required>
         </div>
         <div class="mb-2">
             @if($noteRates && count($noteRates))
@@ -17,7 +17,9 @@
                     <select autofocus class="form-control" name="code" onchange="switchNumberOfUnitsByType(this)">
                         <option value="">-- Select Code --</option>
                         @foreach($noteRates as $noteRate)
-                            <option data-amount="{{ $noteRate->amount }}" value="{{ $noteRate->code }}">{{ $noteRate->code }} (${{ $noteRate->amount }}/hr)</option>
+                            <option data-amount="{{ $noteRate->amount }}" value="{{ $noteRate->code }}">
+                                {{ $noteRate->code }} (${{ $noteRate->amount }}{{ $noteRate->code === 'Treatment Services' ? '/hr' : '' }})
+                            </option>
                         @endforeach
                     </select>
                 @endif

+ 10 - 0
resources/views/app/patient/note/_create-claim.blade.php

@@ -163,10 +163,20 @@
                         fastReload();
                     }
                 }, 'json')
+            },
+            getPrefillValues: function() {
+                @if(@$note && !empty($note->claim_suggestion_json))
+                    let csj = {!! $note->claim_suggestion_json !!};
+                    if(csj && csj.lines && csj.lines.length) {
+                        this.payload.lines.splice(0, 1);
+                        this.payload.lines = csj.lines;
+                    }
+                @endif
             }
         },
         mounted: function () {
             this.initICDAutoSuggest();
+            this.getPrefillValues();
         }
     })
 </script>

+ 501 - 13
resources/views/app/patient/note/dashboard.blade.php

@@ -173,7 +173,7 @@
             <div class="px-2">
                 <div class="d-flex">
                     <span class="mr-2"><span class="text-secondary">Method:</span> {{$note->method ? $note->method : '-'}}</span>
-                    @if(!$note->is_signed_by_hcp && $note->new_or_fu_or_na !== 'NEW')
+                    @if(!$note->is_signed_by_hcp)
                         <div moe class="ml-auto">
                             <a href="" show start><i class="fa fa-edit"></i></a>
                             <form url="/api/note/updateMethod">
@@ -182,7 +182,9 @@
                                     <select name="method" class="form-control form-control-sm" required>
                                         <option value="">-- select --</option>
                                         <option value="VIDEO" {{ $note->method === "VIDEO" ? "selected" : "" }}>Video</option>
+                                        @if($note->new_or_fu_or_na !== 'NEW')
                                         <option value="AUDIO" {{ $note->method === "AUDIO" ? "selected" : "" }}>Audio</option>
+                                        @endif
                                         <option value="IN_CLINIC" {{ $note->method === "IN_CLINIC" ? "selected" : "" }}>In-Clinic</option>
                                         <option value="HOUSE_CALL" {{ $note->method === "HOUSE_CALL" ? "selected" : "" }}>House Call</option>
                                     </select>
@@ -253,7 +255,7 @@
         </div>
         <div class="card-body p-0">
             <div>
-                <div class="mb-3">
+                <div class="">
                     <div>
                         <?php
                         $shortCutsObject = [];
@@ -283,7 +285,7 @@
 
                 <span class="d-none latest-section-ts">{{ $latestSectionTS }}</span>
 
-                <div class="border-top p-3">
+                <div class="p-3 border-bottom">
                     <div class="">
                         <div class="d-flex align-items-center mb-2">
                             <p class="font-weight-bold text-secondary m-0 mr-2">ICDs</p>
@@ -302,15 +304,456 @@
                         </div>
                     </div>
                 </div>
+                @if($pro->pro_type === 'ADMIN')
+                <div class="p-3 border-bottom">
+                    <div>
+                        <h2 class="font-weight-bold text-secondary">Bills & Claims Summary</h2>
+                        <div class="d-flex justify-content-center align-items-start">
+                            <table class="w-25 flex-grow-1 table-bordered table-condensed table-sm table-striped">
+                                <tbody>
+                                <tr>
+                                    <td class="text-secondary">Bill Total Exp.</td>
+                                    <td>${{friendly_money($note->bill_total_expected)}}</td>
+                                </tr>
+                                <tr>
+                                    <td class="text-secondary">Is Billing Closed</td>
+                                    <td>{{$note->is_bill_closed ? 'Yes' : 'No'}}</td>
+                                </tr>
+                                <tr>
+                                    <td class="text-secondary">Bill Summary</td>
+                                    <td>{{$note->bill_summary ? $note->bill_summary : '-'}}</td>
+                                </tr>
+                                <tr>
+                                    <td class="text-secondary">Bill Total Paid</td>
+                                    <td>${{friendly_money($note->bill_total_paid)}}</td>
+                                </tr>
+                                <tr>
+                                    <td class="text-secondary">Billing Closed At</td>
+                                    <td>{{friendlier_date_time($note->bill_closed_at)}}</td>
+                                </tr>
+                                </tbody>
+                            </table>
+                            <table class="w-25 flex-grow-1 table-bordered table-condensed table-sm table-striped ml-2">
+                                <tbody>
+                                <tr>
+                                    <td class="text-secondary">Claim Total Exp.</td>
+                                    <td>${{friendly_money($note->claim_total_expected)}}</td>
+                                </tr>
+                                <tr>
+                                    <td class="text-secondary">Is Claiming Closed</td>
+                                    <td>{{$note->is_claim_closed ? 'Yes' : 'No'}}</td>
+                                </tr>
+                                <tr>
+                                    <td class="text-secondary">Claim Summary</td>
+                                    <td>{{$note->claim_summary ? $note->claim_summary : '-'}}</td>
+                                </tr>
+                                <tr>
+                                    <td class="text-secondary">Claim Total Paid</td>
+                                    <td>${{friendly_money($note->claim_total_paid)}}</td>
+                                </tr>
+                                <tr>
+                                    <td class="text-secondary">Claiming Closed At</td>
+                                    <td>{{$note->claim_closed_at ? friendlier_date_time($note->claim_closed_at) : '-'}}</td>
+                                </tr>
+                                </tbody>
+                            </table>
+                            <table class="w-25 flex-grow-1 table-bordered table-condensed table-sm table-striped ml-2">
+                                <tbody>
+                                <tr>
+                                    <td class="text-secondary">HCP Bill Total Exp.</td>
+                                    <td>${{friendly_money($note->hcp_bill_total_expected)}}</td>
+                                </tr>
+                                <tr>
+                                    <td class="text-secondary">NA Bill Total Exp.</td>
+                                    <td>${{friendly_money($note->na_bill_total_expected)}}</td>
+                                </tr>
+                                <tr>
+                                    <td class="text-secondary">RMM Bill Total Exp.</td>
+                                    <td>${{friendly_money($note->rmm_bill_total_expected)}}</td>
+                                </tr>
+                                <tr>
+                                    <td class="text-secondary">RME Bill Total Exp.</td>
+                                    <td>${{friendly_money($note->rme_bill_total_expected)}}</td>
+                                </tr>
+                                <tr>
+                                    <td class="text-secondary">RMS Bill Total Exp.</td>
+                                    <td>${{friendly_money($note->rms_bill_total_expected)}}</td>
+                                </tr>
+                                <tr>
+                                    <td class="text-secondary">RMG Bill Total Exp.</td>
+                                    <td>${{friendly_money($note->rmg_bill_total_expected)}}</td>
+                                </tr>
+                                <tr>
+                                    <td class="text-secondary">CM Bill Total Exp.</td>
+                                    <td>${{friendly_money($note->cm_bill_total_expected)}}</td>
+                                </tr>
+                                </tbody>
+                            </table>
+                            <table class="w-25 flex-grow-1 table-bordered table-condensed table-sm table-striped ml-2">
+                                <tbody>
+                                <tr>
+                                    <td class="text-secondary">HCP Bill Total Paid</td>
+                                    <td>${{friendly_money($note->hcp_bill_total_paid)}}</td>
+                                </tr>
+                                <tr>
+                                    <td class="text-secondary">NA Bill Total Paid</td>
+                                    <td>${{friendly_money($note->na_bill_total_paid)}}</td>
+                                </tr>
+                                <tr>
+                                    <td class="text-secondary">RMM Bill Total Paid</td>
+                                    <td>${{friendly_money($note->rmm_bill_total_paid)}}</td>
+                                </tr>
+                                <tr>
+                                    <td class="text-secondary">RME Bill Total Paid</td>
+                                    <td>${{friendly_money($note->rme_bill_total_paid)}}</td>
+                                </tr>
+                                <tr>
+                                    <td class="text-secondary">RMS Bill Total Paid</td>
+                                    <td>${{friendly_money($note->rms_bill_total_paid)}}</td>
+                                </tr>
+                                <tr>
+                                    <td class="text-secondary">RMG Bill Total Paid</td>
+                                    <td>${{friendly_money($note->rmg_bill_total_paid)}}</td>
+                                </tr>
+                                <tr>
+                                    <td class="text-secondary">CM Bill Total Paid</td>
+                                    <td>${{friendly_money($note->cm_bill_total_paid)}}</td>
+                                </tr>
+<!--                                <tr>
+                                    <td class="text-secondary">HCP Company Pro</td>
+                                    <td>{{$note->hcp_company_pro_id}}</td>
+                                </tr>-->
+                                </tbody>
+                            </table>
+                        </div>
+                    </div>
+                </div>
+                @endif
 
                 {{-- bills --}}
                 @if($pro->pro_type === 'ADMIN' || ($note->hcpPro && $pro->id === $note->hcpPro->id))
                 @if($note->bills->count())
-                    <div class="mt-2 px-3">
+                    <div class="p-3 border-bottom">
                         <div class="d-flex align-items-center mb-2">
                             <p class="font-weight-bold text-secondary m-0">Bills</p>
                             @include('app/patient/note/_create-bill')
+                            @if($pro->pro_type === 'ADMIN')
+                                @if(!$note->is_bill_closed)
+                                    <span class="mx-2 text-secondary">|</span>
+                                    <span class="d-block" moe>
+                                        <a class="text-danger" href="" show start>Close Billing</a>
+                                        <form url="/api/note/closeBilling">
+                                            <input type="hidden" name="uid" value="{{$note->uid}}">
+                                            <p>Close billing?</p>
+                                            <div class="mb-0">
+                                                <button class="btn btn-success btn-sm" submit>Submit</button>
+                                                <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                            </div>
+                                        </form>
+                                    </span>
+                                @elseif($note->is_bill_closed)
+                                    <span class="mx-2 text-secondary">|</span>
+                                    <span class="d-block" moe>
+                                        <a class="text-danger" href="" show start>Reopen Billing</a>
+                                        <form url="/api/note/reopenBilling">
+                                            <input type="hidden" name="uid" value="{{$note->uid}}">
+                                            <p>Reopen billing?</p>
+                                            <div class="mb-0">
+                                                <button class="btn btn-success btn-sm" submit>Submit</button>
+                                                <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                            </div>
+                                        </form>
+                                    </span>
+                                @endif
+                            @else
+                                <span class="mx-2 text-secondary">|</span>
+                                @if(!$note->is_bill_ready_to_verify)
+                                    <span class="d-block" moe>
+                                        <a class="text-danger" href="" show start>Mark Ready to Verify</a>
+                                        <form url="/api/note/setIsBillReadyToVerifyToTrue">
+                                            <input type="hidden" name="uid" value="{{$note->uid}}">
+                                            <p>Mark bills on this note as Ready to Verify?</p>
+                                            <div class="mb-0">
+                                                <button class="btn btn-success btn-sm" submit>Submit</button>
+                                                <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                            </div>
+                                        </form>
+                                    </span>
+                                @else
+                                    <span class="d-block" moe>
+                                        <a class="text-danger" href="" show start>Undo Mark Ready to Verify</a>
+                                        <form url="/api/note/setIsBillReadyToVerifyToFalse">
+                                            <input type="hidden" name="uid" value="{{$note->uid}}">
+                                            <p>Mark bills on this note as Not Ready to Verify?</p>
+                                            <div class="mb-0">
+                                                <button class="btn btn-success btn-sm" submit>Submit</button>
+                                                <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                            </div>
+                                        </form>
+                                    </span>
+                                @endif
+                            @endif
                         </div>
+
+                        @if($pro->pro_type === 'ADMIN')
+                        <table class="table table-sm tabe-striped mb-0 table-bordered">
+                            <thead class="bg-light">
+                            <tr class="text-secondary">
+                                <?php /* <th class="border-bottom-0"></th> */ ?>
+                                <th class="border-bottom-0">Date</th>
+                                <th class="border-bottom-0">Service</th>
+                                <th class="border-bottom-0">Billable</th>
+                                <th class="border-bottom-0">HCP</th>
+                                <th class="border-bottom-0">Total</th>
+                                <th class="border-bottom-0">Sign</th>
+                                <th class="border-bottom-0">Bal Post Date</th>
+                                <th class="border-bottom-0">Verification</th>
+                                <th class="border-bottom-0">Cancellation</th>
+                                <th class="border-bottom-0">Payment</th>
+                            </tr>
+                            </thead>
+                            <tbody>
+                            @foreach ($note->bills as $bill)
+                                <tr class="{{$bill->is_cancelled ? 'bg-light text-secondary' : ''}}">
+                                    <?php /* <td class="p-0">
+                                        <table class="table-striped table-sm table-condensed border border-left-0 border-top-0 border-bottom-0">
+                                            <tbody>
+                                                <tr><td>collected_amount</td><td>{{$bill->collected_amount}}</td></tr>
+                                                <tr><td>effective_date</td><td>{{$bill->effective_date}}</td></tr>
+                                                <tr><td>has_hcp_been_paid</td><td>{{$bill->has_hcp_been_paid}}</td></tr>
+                                                <tr><td>hcp_expected_payment_amount</td><td>{{$bill->hcp_expected_payment_amount}}</td></tr>
+                                                <tr><td>hcp_payment_amount</td><td>{{$bill->hcp_payment_amount}}</td></tr>
+                                                <tr><td>is_cancelled</td><td>{{$bill->is_cancelled}}</td></tr>
+                                                <tr><td>hcp_payment_pro_transaction_id</td><td>{{$bill->hcp_payment_pro_transaction_id}}</td></tr>
+                                                <tr><td>balance_post_date</td><td>{{$bill->balance_post_date}}</td></tr>
+                                                <tr><td>is_verified</td><td>{{$bill->is_verified}}</td></tr>
+                                                <tr><td>is_cancellation_acknowledged</td><td>{{$bill->is_cancellation_acknowledged}}</td></tr>
+                                                <tr><td>is_cancelled_by_administrator</td><td>{{$bill->is_cancelled_by_administrator}}</td></tr>
+                                                <tr><td>total_expected</td><td>{{$bill->total_expected}}</td></tr>
+                                                <tr><td>total_paid</td><td>{{$bill->total_paid}}</td></tr>
+                                            </tbody>
+                                        </table>
+                                    </td> */ ?>
+                                    <td class="text-nowrap">{{friendlier_date_time($bill->effective_date, false)}}</td>
+                                    <td>{{$bill->code}}</td>
+                                    <td class="">
+                                        @if(strpos(strtolower($bill->code), 'treatment services') !== FALSE)
+                                            <?php
+                                            $totalSeconds = $bill->number_of_units * 3600;
+                                            $remainder = $totalSeconds % 60;
+                                            if ($remainder !== 0) {
+                                                if ($remainder < 30) {
+                                                    $totalSeconds = $totalSeconds - $remainder;
+                                                }
+                                                else {
+                                                    $totalSeconds = $totalSeconds + (60 - $remainder);
+                                                }
+                                            }
+                                            ?>
+                                            {{ time_in_hrminsec($totalSeconds) }}
+                                        @else
+                                            @if(!!$bill->number_of_units)
+                                                {{ $bill->number_of_units }} unit(s)
+                                            @else
+                                                -
+                                            @endif
+                                        @endif
+                                    </td>
+                                    <td class="">
+                                        <div class="text-nowrap font-weight-bold text-secondary">{{ $bill->hcp->displayName() }}</div>
+                                        <div class="text-nowrap mt-1">
+                                            <span class="text-secondary">Paid: </span>
+                                            <span>{{ $bill->has_hcp_been_paid ? 'Yes' : 'No' }}</span>
+                                        </div>
+                                        @if(!$bill->has_hcp_been_paid)
+                                            <div class="text-nowrap mt-1">
+                                                <span class="text-secondary">Expected: </span>
+                                                <span class="font-weight-bold">${{ $bill->hcp_expected_payment_amount }}</span>
+                                            </div>
+                                        @else
+                                            <div class="text-nowrap mt-1">
+                                                <span class="text-secondary">Amount: </span>
+                                                <span class="font-weight-bold">${{ $bill->hcp_payment_amount }}</span>
+                                            </div>
+                                        @endif
+                                    </td>
+                                    <td class="pr-3">
+                                        @if($bill->has_hcp_been_paid)
+                                            <span class="text-secondary">Paid. </span>
+                                            <span class="font-weight-bold">${{ friendly_money($bill->total_paid) }}</span>
+                                        @else
+                                            <span class="text-secondary">Exp. </span>
+                                            <span class="font-weight-bold">{{ $bill->total_expected ? '$' . friendly_money($bill->total_expected) : '-' }}</span>
+                                        @endif
+                                    </td>
+                                    <td>
+                                        @if(!$bill->is_cancelled)
+                                            @if($bill->is_signed_by_hcp)
+                                                <span class="d-block text-secondary text-nowrap">
+                                                        <i class="fa fa-check"></i>
+                                                        HCP Signed
+                                                    </span>
+                                            @else
+                                                <span moe
+                                                      class="d-block {{ $bill->hcp_pro_id !== $pro->id ? 'moe-disabled' : '' }}"
+                                                      title="{{ $bill->hcp_pro_id !== $pro->id ? 'Only the bill\'s HCP can sign' : '' }}">
+                                                    <a class="" href="" show start>Sign</a>
+                                                    <form url="/api/bill/signAsHcp">
+                                                        <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                        <p>Sign this bill as HCP?</p>
+                                                        <div class="mb-0">
+                                                            <button class="btn btn-success btn-sm" submit>Sign</button>
+                                                            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                        </div>
+                                                    </form>
+                                                </span>
+                                            @endif
+                                        @endif
+                                    </td>
+                                    <td>
+                                        @if(!$bill->is_cancelled)
+                                            <span class="d-block" moe>
+                                                <a class="" href="" show start>
+                                                    {{$bill->balance_post_date ? friendlier_date_time($bill->balance_post_date, false) : '(not set)' }}
+                                                </a>
+                                                <form url="/api/bill/updateBalancePostDate">
+                                                    <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                    <p>Update Balance Post Date</p>
+                                                    <div class="mb-0">
+                                                        <input type="date" class="text form-control form-control-sm" name="balancePostDate" value="{{$bill->balance_post_date}}" placeholder="balance post date"><br>
+                                                        <button class="btn btn-success btn-sm" submit>Submit</button>
+                                                        <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                    </div>
+                                                </form>
+                                            </span>
+                                        @endif
+                                    </td>
+                                    <td> <!-- verification -->
+                                        @if($pro->pro_type === 'ADMIN' && !$bill->is_cancelled)
+                                            @if(!$bill->is_verified)
+                                                <div class="text-warning-mellow font-weight-bold">Not Verified</div>
+                                                <span class="d-block mt-1" moe>
+                                                    <a href="" show start>Mark Verified</a>
+                                                    <form url="/api/bill/markAsVerified">
+                                                        <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                        <p>Mark As Verfified?</p>
+                                                        <div class="mb-0">
+                                                            <button class="btn btn-success btn-sm" submit>Submit</button>
+                                                            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                        </div>
+                                                    </form>
+                                                </span>
+                                            @else
+                                                <div class="text-success font-weight-bold"><i class="fa fa-check"></i> Verified</div>
+                                                <span class="d-block mt-1" moe>
+                                                    <a class="" href="" show start>Undo</a>
+                                                    <form url="/api/bill/undoMarkAsVerified">
+                                                        <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                        <p>Undo Mark As Verfified?</p>
+                                                        <div class="mb-0">
+                                                            <button class="btn btn-success btn-sm" submit>Submit</button>
+                                                            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                        </div>
+                                                    </form>
+                                                </span>
+                                            @endif
+                                        @endif
+                                    </td>
+                                    <td>  <!-- cancellation -->
+                                        @if($bill->is_cancelled)
+                                            <div class="text-warning-mellow font-weight-bold">Cancelled</div>
+                                            @if($bill->is_cancelled_by_administrator)
+                                                <div class="text-secondary text-sm">(by Administrator)</div>
+                                            @endif
+                                            <div moe class="mt-1">
+                                                <a class="" href="" show start>Update Memo</a>
+                                                <form url="/api/bill/updateCancellationMemo">
+                                                    <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                    <p>Update Cancellation Memo</p>
+                                                    <div class="mb-0">
+                                                        <input type="text" class="text form-control form-control-sm" name="updateCancellationMemo" value="{{$bill->cancellation_memo}}" placeholder=""><br>
+                                                        <button class="btn btn-success btn-sm" submit>Submit</button>
+                                                        <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                    </div>
+                                                </form>
+                                            </div>
+                                        @else
+                                            <span class="d-block" moe relative="">
+                                                <a class="text-danger" href="" show start>Cancel</a>
+                                                <form url="/api/bill/markCancelled" right="">
+                                                    <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                    <p class="mb-2">Cancel this bill?</p>
+                                                    <div class="mb-2">
+                                                        <label class="mb-1 text-secondary">Cancellation Memo</label>
+                                                        <input type="text" name="memo" placeholder="Memo" class="form-control form-control-sm">
+                                                    </div>
+                                                    <div class="mb-0">
+                                                        <button class="btn btn-danger btn-sm" submit>Yes</button>
+                                                        <button class="btn btn-default border btn-sm" cancel>No</button>
+                                                    </div>
+                                                </form>
+                                            </span>
+                                        @endif
+
+                                        @if($bill->is_cancelled && !$bill->is_cancellation_acknowledged)
+                                            <div class="mt-2 text-secondary">
+                                                <i class="fa fa-exclamation-triangle"></i>
+                                                Not Acknowledged
+                                            </div>
+                                            <div class="d-block mt-1" moe>
+                                                <a class="" href="" show start>Ack. Cancellation</a>
+                                                <form url="/api/bill/acknowledgeCancellation">
+                                                    <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                    <p>Acknowledge Cancellation?</p>
+                                                    <div class="mb-0">
+                                                        <input type="text" class="text form-control form-control-sm" name="cancellationMemo" value="{{$bill->cancellation_memo}}" placeholder=""><br>
+                                                        <button class="btn btn-success btn-sm" submit>Submit</button>
+                                                        <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                    </div>
+                                                </form>
+                                            </div>
+                                        @endif
+
+                                        @if($bill->is_cancellation_acknowledged)
+                                            <div class="mt-2 text-secondary">
+                                                <i class="fa fa-check"></i>
+                                                Acknowledged
+                                            </div>
+                                            <div class="d-block mt-1" moe>
+                                                <a class="" href="" show start>Undo Cancellation Ack.</a>
+                                                <form url="/api/bill/undoAcknowledgeCancellation">
+                                                    <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                    <p>Undo Acknowledge Cancellation?</p>
+                                                    <div class="mb-0">
+                                                        <button class="btn btn-success btn-sm" submit>Submit</button>
+                                                        <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                    </div>
+                                                </form>
+                                            </div>
+                                        @endif
+
+                                    </td>
+                                    <td> <!-- submit payment -->
+                                        @if($pro->pro_type === 'ADMIN' && !$bill->is_cancelled)
+                                            <span class="d-block" moe relative="">
+                                                <a class="font-weight-bold" href="" show start>Submit Payment</a>
+                                                <form url="/api/bill/payHcpAmount" right>
+                                                    <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                    <p>Submit Payment</p>
+                                                    <div class="mb-0">
+                                                        <input type="text" class="text form-control form-control-sm" name="hcpPaymentAmount" value="{{$bill->hcp_expected_payment_amount}}" placeholder="amount"><br>
+                                                        <button class="btn btn-success btn-sm" submit>Submit</button>
+                                                        <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                    </div>
+                                                </form>
+                                            </span>
+                                        @endif
+                                    </td>
+                                </tr>
+                            @endforeach
+                            </tbody>
+                        </table>
+                        @else
                         <table class="table table-sm tabe-striped mb-3 border-left border-right border-bottom">
                             <thead class="bg-light">
                             <tr>
@@ -371,8 +814,8 @@
                                                     </span>
                                                 @else
                                                     <span moe
-                                                         class="d-block {{ $bill->hcp_pro_id !== $pro->id ? 'moe-disabled' : '' }}"
-                                                         title="{{ $bill->hcp_pro_id !== $pro->id ? 'Only the bill\'s HCP can sign' : '' }}">
+                                                          class="d-block {{ $bill->hcp_pro_id !== $pro->id ? 'moe-disabled' : '' }}"
+                                                          title="{{ $bill->hcp_pro_id !== $pro->id ? 'Only the bill\'s HCP can sign' : '' }}">
                                                         <a class="" href="" show start>Sign</a>
                                                         <form url="/api/bill/signAsHcp">
                                                             <input type="hidden" name="uid" value="{{$bill->uid}}">
@@ -385,9 +828,9 @@
                                                     </span>
                                                 @endif
                                             @endif
-                                                @if(!$bill->has_hcp_been_paid && $pro->pro_type === 'ADMIN')
-                                                    <span class="mx-2 text-secondary">|</span>
-                                                    <span class="d-block" moe>
+                                            @if(!$bill->has_hcp_been_paid && $pro->pro_type === 'ADMIN')
+                                                <span class="mx-2 text-secondary">|</span>
+                                                <span class="d-block" moe>
                                                     <a class="text-danger" href="" show start>Submit Payment</a>
                                                     <form url="/api/bill/payHcpAmount">
                                                         <input type="hidden" name="uid" value="{{$bill->uid}}">
@@ -399,7 +842,7 @@
                                                         </div>
                                                     </form>
                                                 </span>
-                                                @endif
+                                            @endif
                                             @if($bill->is_cancelled)
                                                 <span class="mx-2 text-secondary">|</span>
                                                 <span class="d-block text-secondary">
@@ -409,7 +852,7 @@
                                                 <span class="mx-2 text-secondary">|</span>
                                                 <span class="d-block" moe>
                                                     <a class="text-danger" href="" show start>Cancel</a>
-                                                    <form url="/api/bill/markCancelled">
+                                                    <form url="/api/bill/markCancelled" right>
                                                         <input type="hidden" name="uid" value="{{$bill->uid}}">
                                                         <p>Cancel this bill?</p>
                                                         <div class="mb-0">
@@ -425,9 +868,11 @@
                             @endforeach
                             </tbody>
                         </table>
+                        @endif
+
                     </div>
                 @else
-                    <div class="my-3 px-3 d-flex">
+                    <div class="p-3 d-flex  border-bottom">
                         <p class="font-weight-bold mb-0 text-secondary">No bills in this note</p>
                         @include('app/patient/note/_create-bill')
                     </div>
@@ -437,10 +882,53 @@
                 {{-- claims --}}
                 @if($pro->pro_type === 'ADMIN')
                 @if($note->claims->count())
-                    <div class="mt-2 px-3">
+                    <div class="p-3">
                         <div class="d-flex align-items-center mb-2">
                             <p class="font-weight-bold text-secondary m-0">Claims</p>
                             @include('app/patient/note/_create-claim')
+                            @if($pro->pro_type === 'ADMIN')
+                                @if(!$note->is_claim_closed)
+                                    <span class="mx-2 text-secondary">|</span>
+                                    <span class="d-block" moe>
+                                        <a class="text-danger" href="" show start>Close Claiming</a>
+                                        <form url="/api/note/closeClaiming">
+                                            <input type="hidden" name="uid" value="{{$note->uid}}">
+                                            <p>Close claiming?</p>
+                                            <div class="mb-0">
+                                                <button class="btn btn-success btn-sm" submit>Submit</button>
+                                                <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                            </div>
+                                        </form>
+                                    </span>
+                                @elseif($note->is_claim_closed)
+                                    <span class="mx-2 text-secondary">|</span>
+                                    <span class="d-block" moe>
+                                        <a class="text-danger" href="" show start>Reopen Claiming</a>
+                                        <form url="/api/note/reopenClaiming">
+                                            <input type="hidden" name="uid" value="{{$note->uid}}">
+                                            <p>Reopen claiming?</p>
+                                            <div class="mb-0">
+                                                <button class="btn btn-success btn-sm" submit>Submit</button>
+                                                <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                            </div>
+                                        </form>
+                                    </span>
+                                    <span class="mx-2 text-secondary">|</span>
+                                    <span class="d-block" moe>
+                                        <a class="text-danger" href="" show start>Update Claim Total Paid</a>
+                                        <form url="/api/note/updateClaimTotalPaid">
+                                            <input type="hidden" name="uid" value="{{$note->uid}}">
+                                            <div class="form-group">
+                                                <input type="number" class="form-control" name="claimTotalPaid">
+                                            </div>
+                                            <div class="mb-0">
+                                                <button class="btn btn-success btn-sm" submit>Submit</button>
+                                                <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                            </div>
+                                        </form>
+                                    </span>
+                                @endif
+                            @endif
                         </div>
 
                         <table class="table table-sm tabe-striped mb-3 border-left border-right border-bottom">

+ 28 - 4
resources/views/app/patient/partials/measurements.blade.php

@@ -1,16 +1,39 @@
 <div class="mt-2 mb-3">
     <div class="d-flex align-items-center mb-2 py-2 border-top border-bottom">
         <h6 class="my-0 font-weight-bold text-secondary">Measurements</h6>
+
         <span class="mx-2 text-secondary">|</span>
         <div moe>
-            <a start show class="py-0 font-weight-normal">Add</a>
-            <form url="/api/measurement/create">
+            <a start show class="py-0 font-weight-normal">Add BP</a>
+            <form url="/api/measurement/createForBP">
                 <input type="hidden" name="clientUid" value="{{ $patient->uid }}">
+                <p class="font-weight-bold text-secondary mb-2">Add BP Measurement</p>
+                <div class="mb-2">
+                    <label class="text-secondary text-sm mb-1">Systolic BP (mmHg)</label>
+                    <input required autofocus type="number" class="form-control form-control-sm" name="sbpMmHg" value="" placeholder="Systolic BP">
+                </div>
+                <div class="mb-2">
+                    <label class="text-secondary text-sm mb-1">Diastolic BP (mmHg)</label>
+                    <input required autofocus type="number" class="form-control form-control-sm" name="dbpMmHg" value="" placeholder="Diastolic BP">
+                </div>
                 <div class="mb-2">
-                    <input required autofocus type="text" class="form-control form-control-sm" name="label" value="" placeholder="Type">
+                    <input required type="date" class="form-control form-control-sm" name="effectiveDate" max="{{ date('Y-m-d') }}" value="{{ date('Y-m-d') }}">
+                </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>
+        <span class="mx-2 text-secondary">|</span>
+        <div moe>
+            <a start show class="py-0 font-weight-normal">Add Weight</a>
+            <form url="/api/measurement/create">
+                <input type="hidden" name="clientUid" value="{{ $patient->uid }}">
+                <input type="hidden" name="label" value="Wt. (lbs.)">
+                <p class="font-weight-bold text-secondary mb-2">Add Weight Measurement</p>
                 <div class="mb-2">
-                    <input required type="text" class="form-control form-control-sm" name="value" value="" placeholder="Value">
+                    <input required type="number" class="form-control form-control-sm" name="value" value="" placeholder="Weight">
                 </div>
                 <div class="mb-2">
                     <input required type="date" class="form-control form-control-sm" name="effectiveDate" max="{{ date('Y-m-d') }}" value="{{ date('Y-m-d') }}">
@@ -21,6 +44,7 @@
                 </div>
             </form>
         </div>
+
         <span class="mx-2 text-secondary">|</span>
         <a start show class="py-0 font-weight-normal"
            href="/patients/view/{{ $patient->uid }}/measurements">

+ 24 - 14
resources/views/app/patient/shipments.blade.php

@@ -6,7 +6,7 @@
             <span class="mx-2 text-secondary">|</span>
             <div moe>
                 <a start show href="#">Add</a>
-                <form url="/api/shipment/create">
+                <form url="/api/shipment/create" redir="/patients/view/{{ $patient->uid }}/shipments/[data]">
                     <input type="hidden" name="clientUid" value="{{ $patient->uid }}">
                     <label class="text-secondary font-weight-bold">Add Shipment</label>
 <!--                    <div class="mb-2">
@@ -76,17 +76,16 @@
                     cleared for shipment
                 </div>
             @endif
-            <table class="table table-sm table-bordered mb-0">
+            <table class="table table-sm table-bordered mb-0" style="table-layout: fixed">
                 @if($patient->shipments && count($patient->shipments))
                     <thead>
                     <tr class="bg-light">
-                        <th class="px-2 text-nowrap text-secondary border-bottom-0">Created At</th>
-                        <th class="px-2 text-nowrap text-secondary border-bottom-0">Supply Orders</th>
-                        @if(!$shipment)
-                            <th class="px-2 text-nowrap text-secondary border-bottom-0">Courier</th>
-                            <th class="px-2 text-nowrap text-secondary border-bottom-0">Tracking #</th>
-                            <th class="px-2 text-nowrap text-secondary border-bottom-0">Status</th>
-                        @endif
+                        <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Created At</div></th>
+                        <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Supply Orders</div></th>
+                        <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Label File</div></th>
+                        <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Courier</div></th>
+                        <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Tracking #</div></th>
+                        <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Status</div></th>
                     </tr>
                     </thead>
                     <tbody>
@@ -98,11 +97,18 @@
                                 </a>
                             </td>
                             <td class="px-2">{{count($iShipment->supplyOrders)}}</td>
-                            @if(!$shipment)
-                                <td class="px-2">{{ $iShipment->courier }}</td>
-                                <td class="px-2">{{ $iShipment->tracking_number }}</td>
-                                <td class="px-2">{{ $iShipment->status }}</td>
-                            @endif
+                            <td class="px-2">
+                                @if($iShipment->label_system_file_id)
+                                    <a class="pdf-viewer-trigger" native="" target="_blank"
+                                       href="/api/shipment/downloadLabel/{{$iShipment->uid}}" title="View">
+                                        <i class="fa fa-file-pdf text-danger on-hover-opaque"></i>
+                                        View
+                                    </a>
+                                @endif
+                            </td>
+                            <td class="px-2">{{ $iShipment->courier }}</td>
+                            <td class="px-2">{{ $iShipment->tracking_number }}</td>
+                            <td class="px-2">{{ $iShipment->status }}</td>
                         </tr>
                     @endforeach
                     </tbody>
@@ -218,6 +224,7 @@
                                         </td>
                                         <td class="px-2">
                                             <div moe relative class="d-block">
+                                                @if($iSupplyOrder->product->has_lot)
                                                 <a start show>{{ $iSupplyOrder->lot_number ? $iSupplyOrder->lot_number : '(not set)' }}</a>
                                                 <form url="/api/supplyOrder/updateLotNumber" right>
                                                     <input type="hidden" name="uid" value="{{ $iSupplyOrder->uid }}">
@@ -231,6 +238,9 @@
                                                         <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
                                                     </div>
                                                 </form>
+                                                @else
+                                                    <span class="text-secondary">N/A</span>
+                                                @endif
                                             </div>
                                         </td>
                                         <td class="px-2">

+ 35 - 39
resources/views/app/patient/supply-orders.blade.php

@@ -6,7 +6,7 @@
             <span class="mx-2 text-secondary">|</span>
             <div moe>
                 <a start show href="#">Add</a>
-                <form url="/api/supplyOrder/create">
+                <form url="/api/supplyOrder/create" redir="/patients/view/{{ $patient->uid }}/supply-orders/[data]">
                     <input type="hidden" name="clientUid" value="{{ $patient->uid }}">
                     <label class="text-secondary font-weight-bold">Add Supply Order</label>
                     <div class="mb-2">
@@ -35,18 +35,16 @@
         </div>
         <div class="d-flex align-items-start h-100">
             <div class="flex-grow-1">
-                <table class="table table-sm table-bordered mb-0">
+                <table class="table table-sm table-bordered mb-0" style="table-layout: fixed">
                     @if($patient->supplyOrders && count($patient->supplyOrders))
                         <thead>
                         <tr class="bg-light">
-                            <th class="px-2 text-nowrap text-secondary border-bottom-0">Title</th>
-                            <th class="px-2 text-nowrap text-secondary border-bottom-0">Reason</th>
-                            @if(!$supplyOrder)
-                                <th class="px-2 text-nowrap text-secondary border-bottom-0">Created At</th>
-                                <th class="px-2 text-nowrap text-secondary border-bottom-0">Pro Signed?</th>
-                                <th class="px-2 text-nowrap text-secondary border-bottom-0">Cancelled?</th>
-                                <th class="px-2 text-nowrap text-secondary border-bottom-0">Shipment</th>
-                            @endif
+                            <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Title</div></th>
+                            <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Reason</div></th>
+                            <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Created At</div></th>
+                            <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Pro Signed?</div></th>
+                            <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Cancelled?</div></th>
+                            <th class="px-2 text-nowrap text-secondary border-bottom-0"><div class="text-ellipsis">Shipment</div></th>
                         </tr>
                         </thead>
                         <tbody>
@@ -58,27 +56,25 @@
                                     </a>
                                 </td>
                                 <td class="px-2">{{ $iSupplyOrder->reason }}</td>
-                                @if(!$supplyOrder)
-                                    <td class="px-2">{{ friendlier_date_time($iSupplyOrder->created_at) }}</td>
-                                    <td class="px-2">{{ $iSupplyOrder->is_signed_by_pro ? $iSupplyOrder->signedPro->displayName() : '-' }}</td>
-                                    <td class="px-2">{{ $iSupplyOrder->is_cancelled ? 'Yes' : 'No' }}</td>
-                                    <td class="px-2 text-nowrap">
-                                        @if($iSupplyOrder->shipment_id)
-                                            <i class="fa fa-building"></i>
-                                            {{$iSupplyOrder->shipment->status ? $iSupplyOrder->shipment->status : 'CREATED'}}
-                                        @elseif($iSupplyOrder->is_cleared_for_shipment)
-                                            <span class="text-info">
-                                                <i class="fa fa-user-nurse"></i>
-                                                Cleared for shipment
-                                            </span>
-                                        @else
-                                            <span class="text-warning-mellow">
-                                                <i class="fa fa-user-nurse"></i>
-                                                Not cleared for shipment
-                                            </span>
-                                        @endif
-                                    </td>
-                                @endif
+                                <td class="px-2">{{ friendlier_date_time($iSupplyOrder->created_at) }}</td>
+                                <td class="px-2">{{ $iSupplyOrder->is_signed_by_pro ? $iSupplyOrder->signedPro->displayName() : '-' }}</td>
+                                <td class="px-2">{{ $iSupplyOrder->is_cancelled ? 'Yes' : 'No' }}</td>
+                                <td class="px-2">
+                                    @if($iSupplyOrder->shipment_id)
+                                        <i class="fa fa-building"></i>
+                                        {{$iSupplyOrder->shipment->status ? $iSupplyOrder->shipment->status : 'CREATED'}}
+                                    @elseif($iSupplyOrder->is_cleared_for_shipment)
+                                        <span class="text-info">
+                                            <i class="fa fa-user-nurse"></i>
+                                            Cleared for shipment
+                                        </span>
+                                    @else
+                                        <span class="text-warning-mellow">
+                                            <i class="fa fa-user-nurse"></i>
+                                            Not cleared for shipment
+                                        </span>
+                                    @endif
+                                </td>
                             </tr>
                         @endforeach
                         </tbody>
@@ -103,7 +99,7 @@
                     <div class="mb-3">
                         <label class="text-secondary text-sm mb-1">Reason</label>
                         <div moe class="d-block">
-                            <a start show>{{$supplyOrder->reason}}</a>
+                            <a start show>{{$supplyOrder->reason ? $supplyOrder->reason : '(not set)'}}</a>
                             <form url="/api/supplyOrder/updateReason">
                                 <input type="hidden" name="uid" value="{{ $supplyOrder->uid }}">
                                 <div class="mb-2">
@@ -121,13 +117,13 @@
                     <div class="mb-3">
                         <label class="text-secondary text-sm mb-1">Requested Ship Date</label>
                         <div moe class="d-block">
-                            <a start show>(not set)</a>
-                            <form url="/api/supplyOrder/updateRequestedShipDate">
+                            <a start show>{{$supplyOrder->requested_date ? friendlier_date_time($supplyOrder->requested_date) : '(not set)'}}</a>
+                            <form url="/api/supplyOrder/updateRequestedDate">
                                 <input type="hidden" name="uid" value="{{ $supplyOrder->uid }}">
                                 <div class="mb-2">
                                     <label class="text-secondary mb-1 text-sm">Requested Ship Date</label>
                                     <input type="date" class="form-control form-control-sm"
-                                           name="requestedShipDate" value="">
+                                           name="requestedDate" value="">
                                 </div>
                                 <div class="d-flex align-items-center">
                                     <button class="btn btn-sm btn-primary mr-2" submit>Save</button>
@@ -282,14 +278,14 @@
                         @endif
                     </div>
                     <hr class="my-3">
-                    <div class="d-flex align-items-center mb-2">
+                    <div class="d-flex align-items-center">
                         @if($supplyOrder->is_cleared_for_shipment)
-                            <div class="text-info">
+                            <div class="text-info mb-2">
                                 <i class="fa fa-check"></i> Cleared for shipment by <b>{{$supplyOrder->clearedForShipmentPro->displayName()}}</b>
                                 on {{friendlier_date_time($supplyOrder->cleared_for_shipment_at)}}
                             </div>
-                        @else
-                            <div moe bottom relative="">
+                        @elseif($supplyOrder->is_signed_by_pro && ($supplyOrder->is_signed_by_client || $supplyOrder->is_client_signature_waived))
+                            <div moe bottom relative="" class="mb-2">
                                 <a start show class="py-0 text-success font-weight-bold">Clear for Shipment</a>
                                 <form url="/api/supplyOrder/clearForShipment">
                                     <input type="hidden" name="uid" value="{{ $supplyOrder->uid }}">

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

@@ -46,7 +46,11 @@
         $nextDay = date_format(date_add(date_create($nextDay), date_interval_create_from_date_string('1 day')), 'Y-m-d');
     }
 
-    $allMeasurements = $patient->nonZeroMeasurements->toArray();
+    /** @var \App\Models\Client $patient */
+
+    // BP
+    $bpMeasurements = $patient->getNonZeroBpMeasurements->toArray();
+    $weightMeasurements = $patient->getNonZeroWeightMeasurements->toArray();
 
     $bpData = [];
     $weightData = [];
@@ -55,45 +59,30 @@
 
         $date = $dates[$i];
 
-        // sbp
-        $sbp = array_filter($allMeasurements, function($_measurement) use ($date) {
-            return $_measurement['label'] === 'SBP' && $_measurement['effective_date'] === $date && $_measurement['numeric_value'];
+        // bp
+        $bp = array_filter($bpMeasurements, function($_measurement) use ($date) {
+            return $_measurement['effective_date'] === $date;
         });
-        if(count($sbp)) {
-            $sbp = array_values($sbp);
-            $sbp = $sbp[count($sbp) - 1];
+        if(count($bp)) {
+            $bp = array_values($bp);
+            $bp = $bp[count($bp) - 1];
         }
         else {
-            $sbp = null;
-        }
-        // dbp
-        $dbp = null;
-        if($sbp) {
-            $dbp = array_filter($allMeasurements, function($_measurement) use ($date) {
-                $measurementDate = date('Y-m-d', strtotime($_measurement['effective_date']));
-                return $_measurement['label'] === 'DBP' && $measurementDate === $date && $_measurement['numeric_value'];
-            });
-            if(count($dbp)) {
-                $dbp = array_values($dbp);
-                $dbp = $dbp[count($dbp) - 1];
-            }
-            else {
-                $dbp = null;
-            }
+            $bp = null;
         }
-        if ($sbp && $dbp) {
+
+
+        if ($bp) {
             $bpData[] = [
                 "date" => $date,
-                "sbp" => $sbp["numeric_value"],
-                "dbp" => $dbp["numeric_value"]
+                "sbp" => $bp["sbp_mm_hg"],
+                "dbp" => $bp["dbp_mm_hg"]
             ];
         }
 
         // weight
-        $weight = array_filter($allMeasurements, function($_measurement) use ($date) {
-            return $_measurement['label'] === 'Wt. (lbs.)' &&
-                $_measurement['effective_date'] === $date &&
-                $_measurement['numeric_value'];
+        $weight = array_filter($weightMeasurements, function($_measurement) use ($date) {
+            return $_measurement['effective_date'] === $date;
         });
         if(count($weight)) {
             $weight = array_values($weight);

+ 414 - 0
resources/views/app/practice-management/bill-matrix.blade.php

@@ -0,0 +1,414 @@
+@extends ('layouts/template')
+
+@section('content')
+
+    <div id="practice-bills" class="p-3 mcp-theme-1">
+    <div class="card">
+
+        <div class="card-header px-3 py-2 d-flex align-items-center">
+            <strong class="mr-4">
+                <i class="fas fa-user-injured"></i>
+                Bills
+            </strong>
+            <a href="/practice-management/bill-matrix" class="ml-auto">Clear Filters</a>
+        </div>
+        <div class="card-body p-0 border-0">
+            <table class="table table-sm table-condensed table-bordered border-0 p-0 m-0">
+                <thead class="bg-light">
+                <tr>
+                    <th class="border-bottom-0 border-top-0 border-left-0">Date</th>
+                    <th class="border-bottom-0 border-top-0">Client</th>
+                    <th class="border-bottom-0 border-top-0">Note</th>
+                    <th class="border-bottom-0 border-top-0">Service</th>
+                    <th class="border-bottom-0 border-top-0">Billable</th>
+                    <th class="border-bottom-0 border-top-0">HCP</th>
+                    <th class="border-bottom-0 border-top-0">Expected</th>
+                    <th class="border-bottom-0 border-top-0">Paid</th>
+                    <th class="border-bottom-0 border-top-0">Sign</th>
+                    <th class="border-bottom-0 border-top-0">Bal Post Date</th>
+                    <th class="border-bottom-0 border-top-0">Verification</th>
+                    <th class="border-bottom-0 border-top-0">Cancellation</th>
+                    <th class="border-bottom-0 border-top-0 border-right-0">Payment</th>
+                </tr>
+                <tr class="filter-head">
+                    <th class="p-0 border-bottom-0 border-right border-left-0"></th> <!-- date -->
+                    <th class="p-0 border-bottom-0 border-right"> <!-- client -->
+                        <select class="form-control form-control-sm bg-aliceblue min-width-unset rounded-0 shadow-none border-0"
+                                data-filter="client">
+                            <option value="">All</option>
+                            @foreach($bClients as $bClient)
+                                <option value="{{$bClient->id}}"
+                                    {{$filters['client'] == $bClient->id ? 'selected' : ''}}>{{$bClient->displayName()}}</option>
+                            @endforeach
+                        </select>
+                    </th> <!-- Client -->
+                    <th class="p-0 border-bottom-0 border-right"></th> <!-- Note -->
+                    <th class="p-0 border-bottom-0 border-right"> <!-- service type -->
+                        <select class="form-control form-control-sm bg-aliceblue min-width-unset rounded-0 shadow-none border-0"
+                                data-filter="service">
+                            <option value="">All</option>
+                        </select>
+                    </th> <!-- Service -->
+                    <th class="p-0 border-bottom-0 border-right"></th> <!-- billable -->
+                    <th class="p-0 border-bottom-0 border-right"> <!-- hcp, hcp_paid -->
+                        <div class="d-flex align-items-center">
+                            <select class="form-control form-control-sm bg-aliceblue min-width-unset rounded-0 shadow-none border-left-0 border-top-0 border-bottom-0 border-right w-50"
+                                    data-filter="hcp">
+                                <option value="">All</option>
+                                @foreach($bHCPPros as $bHCPPro)
+                                    <option value="{{$bHCPPro->id}}"
+                                        {{$filters['hcp'] == $bHCPPro->id ? 'selected' : ''}}>{{$bHCPPro->displayName()}}</option>
+                                @endforeach
+                            </select>
+                            <select class="form-control form-control-sm bg-aliceblue min-width-unset rounded-0 shadow-none border-0 w-50"
+                                    data-filter="hcp_paid">
+                                <option value="">All</option>
+                                <option {{$filters['hcp_paid'] == 'yes' ? 'selected' : ''}} value="yes">Paid</option>
+                                <option {{$filters['hcp_paid'] == 'no' ? 'selected' : ''}} value="no">Not Paid</option>
+                            </select>
+                        </div>
+                    </th> <!-- HCP -->
+                    <th class="p-0 border-bottom-0 border-right"> <!-- expected -->
+                        <div class="d-flex align-items-center">
+                            <select class="form-control form-control-sm bg-aliceblue min-width-unset rounded-0 shadow-none border-left-0 border-top-0 border-bottom-0 border-right width-40px p-0"
+                                    data-filter="expected_op">
+                                <option value=""></option>
+                                <option value="<=" {{$filters['expected_op'] == '<=' ? 'selected' : ''}}>&lt;=</option>
+                                <option value=">=" {{$filters['expected_op'] == '>=' ? 'selected' : ''}}>&gt;=</option>
+                                <option value="=" {{$filters['expected_op'] == '=' ? 'selected' : ''}}>=</option>
+                            </select>
+                            <input type="number" class="form-control form-control-sm bg-aliceblue min-width-unset rounded-0 shadow-none border-0"
+                                   data-filter="expected_value"
+                                   value="{{$filters['expected_value']}}" placeholder="Amount">
+                        </div>
+                    </th> <!-- Expected -->
+                    <th class="p-0 border-bottom-0 border-right"> <!-- paid -->
+                        <div class="d-flex align-items-center">
+                            <select class="form-control form-control-sm bg-aliceblue min-width-unset rounded-0 shadow-none border-left-0 border-top-0 border-bottom-0 border-right width-40px p-0"
+                                    data-filter="paid_op">
+                                <option value=""></option>
+                                <option value="<=" {{$filters['paid_op'] == '<=' ? 'selected' : ''}}>&lt;=</option>
+                                <option value=">=" {{$filters['paid_op'] == '>=' ? 'selected' : ''}}>&gt;=</option>
+                                <option value="=" {{$filters['paid_op'] == '=' ? 'selected' : ''}}>=</option>
+                            </select>
+                            <input type="number" class="form-control form-control-sm bg-aliceblue min-width-unset rounded-0 shadow-none border-0"
+                                   data-filter="paid_value"
+                                   value="{{$filters['paid_value']}}" placeholder="Amount">
+                        </div>
+                    </th> <!-- Paid -->
+                    <th class="p-0 border-bottom-0 border-right"> <!-- hcp signed -->
+                        <select class="form-control form-control-sm bg-aliceblue min-width-unset rounded-0 shadow-none border-0"
+                                data-filter="hcp_sign">
+                            <option value="">All</option>
+                            <option {{$filters['hcp_sign'] == 'yes' ? 'selected' : ''}} value="yes">Signed</option>
+                            <option {{$filters['hcp_sign'] == 'no' ? 'selected' : ''}} value="no">Not Signed</option>
+                        </select>
+                    </th> <!-- Sign -->
+                    <th class="p-0 border-bottom-0 border-right">
+                        <div class="d-flex align-items-center">
+                            <select class="form-control form-control-sm bg-aliceblue min-width-unset rounded-0 shadow-none border-left-0 border-top-0 border-bottom-0 border-right width-40px p-0"
+                                    data-filter="bal_post_date_op">
+                                <option value=""></option>
+                                <option value="<=" {{$filters['bal_post_date_op'] == '<=' ? 'selected' : ''}}>&lt;=</option>
+                                <option value=">=" {{$filters['bal_post_date_op'] == '>=' ? 'selected' : ''}}>&gt;=</option>
+                                <option value="=" {{$filters['bal_post_date_op'] == '=' ? 'selected' : ''}}>=</option>
+                            </select>
+                            <input type="date" class="form-control form-control-sm bg-aliceblue min-width-unset rounded-0 shadow-none border-0"
+                                   data-filter="bal_post_date_value"
+                                   value="{{$filters['bal_post_date_value']}}" placeholder="Amount">
+                        </div>
+                    </th> <!-- Bal Post Date -->
+                    <th class="p-0 border-bottom-0 border-right"> <!-- verified -->
+                        <select class="form-control form-control-sm bg-aliceblue min-width-unset rounded-0 shadow-none border-0"
+                                data-filter="verified">
+                            <option value="">All</option>
+                            <option {{$filters['verified'] == 'yes' ? 'selected' : ''}} value="yes">Verified</option>
+                            <option {{$filters['verified'] == 'no' ? 'selected' : ''}} value="no">Not Verified</option>
+                        </select>
+                    </th> <!-- verification -->
+                    <th class="p-0 border-bottom-0 border-right"> <!-- cancelled -->
+                        <select class="form-control form-control-sm bg-aliceblue min-width-unset rounded-0 shadow-none border-0"
+                                data-filter="cancelled">
+                            <option value="">All</option>
+                            <option {{$filters['cancelled'] == 'yes' ? 'selected' : ''}} value="yes">Cancelled</option>
+                            <option {{$filters['cancelled'] == 'no' ? 'selected' : ''}} value="no">Not Cancelled</option>
+                        </select>
+                    </th> <!-- cancellation -->
+                    <th class="p-0 border-bottom-0 border-right-0"></th> <!-- payment -->
+                </tr>
+                </thead>
+                <tbody>
+                @foreach ($bills as $bill)
+                    <tr class="{{$bill->is_cancelled ? 'bg-light' : ''}}">
+                        <td class="text-nowrap border-left-0">{{friendlier_date_time($bill->effective_date, false)}}</td>
+                        <td>
+                            <a href="/patients/view/{{$bill->client->uid}}">{{$bill->client->displayName()}}</a>
+                        </td> <!-- client -->
+                        <td>
+                            @if($bill->note)
+                                <a href="/patients/view/{{$bill->client->uid}}/notes/view/{{$bill->note->uid}}" class="font-weight-bold">View</a>
+                            @else
+                                -
+                            @endif
+                        </td> <!-- note -->
+                        <td>{{$bill->code}}</td> <!-- service type / code -->
+                        <td class="">
+                            @if(strpos(strtolower($bill->code), 'treatment services') !== FALSE)
+                                <?php
+                                $totalSeconds = $bill->number_of_units * 3600;
+                                $remainder = $totalSeconds % 60;
+                                if ($remainder !== 0) {
+                                    if ($remainder < 30) {
+                                        $totalSeconds = $totalSeconds - $remainder;
+                                    }
+                                    else {
+                                        $totalSeconds = $totalSeconds + (60 - $remainder);
+                                    }
+                                }
+                                ?>
+                                {{ time_in_hrminsec($totalSeconds) }}
+                            @else
+                                @if(!!$bill->number_of_units)
+                                    {{ $bill->number_of_units }} unit(s)
+                                @else
+                                    -
+                                @endif
+                            @endif
+                        </td> <!-- minutes / units -->
+                        <td class="">
+                            <div class="text-nowrap font-weight-bold text-secondary">{{ $bill->hcp->displayName() }}</div>
+                            <div class="text-nowrap mt-1">
+                                <span class="text-secondary">Paid: </span>
+                                <span>{{ $bill->has_hcp_been_paid ? 'Yes' : 'No' }}</span>
+                            </div>
+                            @if(!$bill->has_hcp_been_paid)
+                                <div class="text-nowrap mt-1">
+                                    <span class="text-secondary">Expected: </span>
+                                    <span class="">${{ friendly_money($bill->hcp_expected_payment_amount) }}</span>
+                                </div>
+                            @else
+                                <div class="text-nowrap mt-1">
+                                    <span class="text-secondary">Amount: </span>
+                                    <span class="">${{ friendly_money($bill->hcp_payment_amount) }}</span>
+                                </div>
+                            @endif
+                        </td>
+                        <td>
+                            <span class="">${{ friendly_money($bill->total_expected) }}</span>
+                        </td>
+                        <td>
+                            <span class="">${{ friendly_money($bill->total_paid) }}</span>
+                        </td>
+                        <td>
+                            @if(!$bill->is_cancelled)
+                                @if($bill->is_signed_by_hcp)
+                                    <span class="d-block text-secondary text-nowrap">
+                                        <i class="fa fa-check"></i>
+                                        HCP Signed
+                                    </span>
+                                @else
+                                    <span moe
+                                          class="d-block {{ $bill->hcp_pro_id !== $pro->id ? 'moe-disabled' : '' }}"
+                                          title="{{ $bill->hcp_pro_id !== $pro->id ? 'Only the bill\'s HCP can sign' : '' }}">
+                                        <a class="" href="" show start>Sign</a>
+                                        <form url="/api/bill/signAsHcp">
+                                            <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                            <p>Sign this bill as HCP?</p>
+                                            <div class="mb-0">
+                                                <button class="btn btn-success btn-sm" submit>Sign</button>
+                                                <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                            </div>
+                                        </form>
+                                    </span>
+                                @endif
+                            @endif
+                        </td>
+                        <td>
+                            @if(!$bill->is_cancelled)
+                                <span class="d-block" moe>
+                                                <a class="" href="" show start>
+                                                    {{$bill->balance_post_date ? friendlier_date_time($bill->balance_post_date, false) : '(not set)' }}
+                                                </a>
+                                                <form url="/api/bill/updateBalancePostDate">
+                                                    <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                    <p>Update Balance Post Date</p>
+                                                    <div class="mb-0">
+                                                        <input type="date" class="text form-control form-control-sm" name="balancePostDate" value="{{$bill->balance_post_date}}" placeholder="balance post date"><br>
+                                                        <button class="btn btn-success btn-sm" submit>Submit</button>
+                                                        <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                    </div>
+                                                </form>
+                                            </span>
+                            @endif
+                        </td>
+                        <td> <!-- verification -->
+                            @if($pro->pro_type === 'ADMIN' && !$bill->is_cancelled)
+                                @if(!$bill->is_verified)
+                                    <div class="text-warning-mellow font-weight-bold">Not Verified</div>
+                                    <span class="d-block mt-1" moe>
+                                                    <a href="" show start>Mark Verified</a>
+                                                    <form url="/api/bill/markAsVerified">
+                                                        <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                        <p>Mark As Verfified?</p>
+                                                        <div class="mb-0">
+                                                            <button class="btn btn-success btn-sm" submit>Submit</button>
+                                                            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                        </div>
+                                                    </form>
+                                                </span>
+                                @else
+                                    <div class="text-success font-weight-bold"><i class="fa fa-check"></i> Verified</div>
+                                    <span class="d-block mt-1" moe>
+                                                    <a class="" href="" show start>Undo</a>
+                                                    <form url="/api/bill/undoMarkAsVerified">
+                                                        <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                        <p>Undo Mark As Verfified?</p>
+                                                        <div class="mb-0">
+                                                            <button class="btn btn-success btn-sm" submit>Submit</button>
+                                                            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                        </div>
+                                                    </form>
+                                                </span>
+                                @endif
+                            @endif
+                        </td>
+                        <td>  <!-- cancellation -->
+                            @if($bill->is_cancelled)
+                                <div class="text-warning-mellow font-weight-bold">Cancelled</div>
+                                @if($bill->is_cancelled_by_administrator)
+                                    <div class="text-secondary text-sm">(by Administrator)</div>
+                                @endif
+                                <div moe class="mt-1">
+                                    <a class="" href="" show start>Update Memo</a>
+                                    <form url="/api/bill/updateCancellationMemo">
+                                        <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                        <p>Update Cancellation Memo</p>
+                                        <div class="mb-0">
+                                            <input type="text" class="text form-control form-control-sm" name="updateCancellationMemo" value="{{$bill->cancellation_memo}}" placeholder=""><br>
+                                            <button class="btn btn-success btn-sm" submit>Submit</button>
+                                            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                        </div>
+                                    </form>
+                                </div>
+                            @else
+                                <span class="d-block" moe relative="">
+                                                <a class="text-danger" href="" show start>Cancel</a>
+                                                <form url="/api/bill/markCancelled" right="">
+                                                    <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                    <p class="mb-2">Cancel this bill?</p>
+                                                    <div class="mb-2">
+                                                        <label class="mb-1 text-secondary">Cancellation Memo</label>
+                                                        <input type="text" name="memo" placeholder="Memo" class="form-control form-control-sm">
+                                                    </div>
+                                                    <div class="mb-0">
+                                                        <button class="btn btn-danger btn-sm" submit>Yes</button>
+                                                        <button class="btn btn-default border btn-sm" cancel>No</button>
+                                                    </div>
+                                                </form>
+                                            </span>
+                            @endif
+
+                            @if($bill->is_cancelled && !$bill->is_cancellation_acknowledged)
+                                <div class="mt-2 text-secondary">
+                                    <i class="fa fa-exclamation-triangle"></i>
+                                    Not Acknowledged
+                                </div>
+                                <div class="d-block mt-1" moe>
+                                    <a class="" href="" show start>Ack. Cancellation</a>
+                                    <form url="/api/bill/acknowledgeCancellation">
+                                        <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                        <p>Acknowledge Cancellation?</p>
+                                        <div class="mb-0">
+                                            <input type="text" class="text form-control form-control-sm" name="cancellationMemo" value="{{$bill->cancellation_memo}}" placeholder=""><br>
+                                            <button class="btn btn-success btn-sm" submit>Submit</button>
+                                            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                        </div>
+                                    </form>
+                                </div>
+                            @endif
+
+                            @if($bill->is_cancellation_acknowledged)
+                                <div class="mt-2 text-secondary">
+                                    <i class="fa fa-check"></i>
+                                    Acknowledged
+                                </div>
+                                <div class="d-block mt-1" moe>
+                                    <a class="" href="" show start>Undo Cancellation Ack.</a>
+                                    <form url="/api/bill/undoAcknowledgeCancellation">
+                                        <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                        <p>Undo Acknowledge Cancellation?</p>
+                                        <div class="mb-0">
+                                            <button class="btn btn-success btn-sm" submit>Submit</button>
+                                            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                        </div>
+                                    </form>
+                                </div>
+                            @endif
+
+                        </td>
+                        <td class="border-right-0"> <!-- submit payment -->
+                            @if($pro->pro_type === 'ADMIN' && !$bill->is_cancelled)
+                                <span class="d-block" moe relative="">
+                                                <a class="font-weight-bold" href="" show start>Submit Payment</a>
+                                                <form url="/api/bill/payHcpAmount" right>
+                                                    <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                    <p>Submit Payment</p>
+                                                    <div class="mb-0">
+                                                        <input type="text" class="text form-control form-control-sm" name="hcpPaymentAmount" value="{{$bill->hcp_expected_payment_amount}}" placeholder="amount"><br>
+                                                        <button class="btn btn-success btn-sm" submit>Submit</button>
+                                                        <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                    </div>
+                                                </form>
+                                            </span>
+                            @endif
+                        </td>
+                    </tr>
+                @endforeach
+                </tbody>
+            </table>
+            <div>
+                {{$bills->links()}}
+            </div>
+        </div>
+    </div>
+    </div>
+
+    <script>
+        (function() {
+
+            function applyFilters() {
+                let params = {}, queryLine = [];
+                $('[data-filter]').each(function() {
+                    if($.trim($(this).val())) {
+                        params[$(this).attr('data-filter')] = $.trim($(this).val());
+                    }
+                });
+                for(let x in params) {
+                    if(params.hasOwnProperty(x)) {
+                        queryLine.push(x + '=' + encodeURIComponent(params[x]));
+                    }
+                }
+                queryLine = queryLine.join('&');
+
+                fastLoad('/practice-management/bill-matrix?' + queryLine);
+            }
+
+            function init() {
+                $('select[data-filter]')
+                    .off('change')
+                    .on('change', applyFilters);
+                $('input[data-filter]')
+                    .off('keyup')
+                    .on('keyup', function(_event) {
+                        if(_event.which === 13) {
+                            applyFilters();
+                            return false;
+                        }
+                    });
+            }
+
+            addMCInitializer('practice-bills', init, '#practice-bills')
+
+        }).call(window);
+    </script>
+@endsection

+ 127 - 10
resources/views/app/practice-management/billing-manager.blade.php

@@ -2,7 +2,7 @@
 
 @section('content')
 
-    <div class="p-3 mcp-theme-1">
+    <div class="p-3 mcp-theme-1" id="practice-billing-manager">
 
         <div class="card">
 
@@ -19,23 +19,75 @@
                     @endforeach
                 </select>
             </div>
+            <div class="bg-aliceblue border-bottom px-3 py-2 d-flex align-items-center">
+                <div class="d-inline-flex align-items-center">
+                    <span>Bills Created</span>
+                    <select class="form-control form-control-sm min-width-unset width-70px ml-2 {{ !!$filters['bills_created'] ? 'border-info font-weight-bold text-info' : 'text-secondary on-hover-opaque' }}"
+                            data-filter="bills_created">
+                        <option value="">All</option>
+                        <option value="yes" {{$filters['bills_created'] === 'yes' ? 'selected' : ''}}>Yes</option>
+                        <option value="no" {{$filters['bills_created'] === 'no' ? 'selected' : ''}}>No</option>
+                    </select>
+                </div>
+                <div class="d-inline-flex align-items-center ml-3">
+                    <span>Bills Ready to Verify</span>
+                    <select class="form-control form-control-sm min-width-unset width-70px ml-2 {{ !!$filters['bills_ready_to_verify'] ? 'border-info font-weight-bold text-info' : 'text-secondary on-hover-opaque' }}"
+                            data-filter="bills_ready_to_verify">
+                        <option value="">All</option>
+                        <option value="yes" {{$filters['bills_ready_to_verify'] === 'yes' ? 'selected' : ''}}>Yes</option>
+                        <option value="no" {{$filters['bills_ready_to_verify'] === 'no' ? 'selected' : ''}}>No</option>
+                    </select>
+                </div>
+                <div class="d-inline-flex align-items-center ml-3">
+                    <span>Bills Resolved</span>
+                    <select class="form-control form-control-sm min-width-unset width-70px ml-2 {{ !!$filters['bills_resolved'] ? 'border-info font-weight-bold text-info' : 'text-secondary on-hover-opaque' }}"
+                            data-filter="bills_resolved">
+                        <option value="">All</option>
+                        <option value="yes" {{$filters['bills_resolved'] === 'yes' ? 'selected' : ''}}>Yes</option>
+                        <option value="no" {{$filters['bills_resolved'] === 'no' ? 'selected' : ''}}>No</option>
+                    </select>
+                </div>
+                <div class="d-inline-flex align-items-center ml-3">
+                    <span>Bills Closed</span>
+                    <select class="form-control form-control-sm min-width-unset width-70px ml-2 {{ !!$filters['bills_closed'] ? 'border-info font-weight-bold text-info' : 'text-secondary on-hover-opaque' }}"
+                            data-filter="bills_closed">
+                        <option value="">All</option>
+                        <option value="yes" {{$filters['bills_closed'] === 'yes' ? 'selected' : ''}}>Yes</option>
+                        <option value="no" {{$filters['bills_closed'] === 'no' ? 'selected' : ''}}>No</option>
+                    </select>
+                </div>
+                <div class="d-inline-flex align-items-center ml-3">
+                    <span>Claims Created</span>
+                    <select class="form-control form-control-sm min-width-unset width-70px ml-2 {{ !!$filters['claims_created'] ? 'border-info font-weight-bold text-info' : 'text-secondary on-hover-opaque' }}"
+                            data-filter="claims_created">
+                        <option value="">All</option>
+                        <option value="yes" {{$filters['claims_created'] === 'yes' ? 'selected' : ''}}>Yes</option>
+                        <option value="no" {{$filters['claims_created'] === 'no' ? 'selected' : ''}}>No</option>
+                    </select>
+                </div>
+                <div class="d-inline-flex align-items-center ml-3">
+                    <span>Claims Closed</span>
+                    <select class="form-control form-control-sm min-width-unset width-70px ml-2 {{ !!$filters['claims_closed'] ? 'border-info font-weight-bold text-info' : 'text-secondary on-hover-opaque' }}"
+                            data-filter="claims_closed">
+                        <option value="">All</option>
+                        <option value="yes" {{$filters['claims_closed'] === 'yes' ? 'selected' : ''}}>Yes</option>
+                        <option value="no" {{$filters['claims_closed'] === 'no' ? 'selected' : ''}}>No</option>
+                    </select>
+                </div>
+                <a href="/practice-management/billing-manager" class="ml-auto">Clear Filters</a>
+            </div>
             <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">Patient</th>
                         <th class="border-0">Note Eff. Date</th>
-
-
                         <th class="border-0">HCP</th>
-
                         <th class="border-0">Signed?</th>
                         <th class="border-0">Bills</th>
-
                         @if($performer->pro->pro_type == 'ADMIN')
                             <th class="border-0">Assessments</th>
                         @endif
-
                         @if($performer->pro->pro_type == 'ADMIN')
                             <th class="border-0">Claims</th>
                         @endif
@@ -45,14 +97,21 @@
                     <tbody>
                     @foreach ($notes as $note)
                         <tr class="{{ $note->is_cancelled ? 'cancelled-item always-clickable' : '' }}">
-
                             <td class="">
-                                <a href="/patients/view/{{ $note->client->uid }}/notes/view/{{ $note->uid }}">{{ $note->client->displayName() }}</a>
+                                <a href="/patients/view/{{ $note->client->uid }}">{{ $note->client->displayName() }}</a>
                             </td>
                             <td class="">
+                                <div class="font-weight-bold">{{ friendly_date_time($note->effective_dateest, false) }}</div>
+                                <a href="/patients/view/{{ $note->client->uid }}/notes/view/{{ $note->uid }}?popupmode=1"
+                                   native target="_blank"
+                                   class="note-popup-trigger d-block text-nowrap mt-1">
+                                    <i class="fa fa-eye"></i>
+                                    View
+                                </a>
                                 <a href="/patients/view/{{ $note->client->uid }}/notes/view/{{ $note->uid }}"
-                                   class="font-weight-bold">
-                                    {{ friendly_date_time($note->effective_dateest, false) }}
+                                   class="d-block text-nowrap mt-1">
+                                    <i class="fa fa-external-link-alt"></i>
+                                    Open
                                 </a>
                                 <span class="ml-1">{{ $note->is_cancelled ? '[cancelled]' : '' }}</span>
                             </td>
@@ -159,4 +218,62 @@
         </div>
     </div>
 
+    <div class="stag-popup stag-popup-lg mcp-theme-1" stag-popup-key="note-popup">
+        <form method="POST" action="" class="p-0">
+            <h3 class="stag-popup-title mb-0 mt-3 mx-3 pb-0 border-bottom-0">
+                <span>Note Details</span>
+                <a href="#" class="ml-auto text-secondary"
+                   onclick="return closeStagPopup()"><i class="fa fa-times-circle"></i></a>
+            </h3>
+            <div class="pb-3 note-popup-content">
+                <div class="px-3 pt-3 text-secondary font-italic">Loading ...</div>
+            </div>
+        </form>
+    </div>
+
+    <script>
+        (function() {
+
+            function applyFilters() {
+                let params = {}, queryLine = [];
+                $('[data-filter]').each(function() {
+                    if($.trim($(this).val())) {
+                        params[$(this).attr('data-filter')] = $.trim($(this).val());
+                    }
+                });
+                for(let x in params) {
+                    if(params.hasOwnProperty(x)) {
+                        queryLine.push(x + '=' + encodeURIComponent(params[x]));
+                    }
+                }
+                queryLine = queryLine.join('&');
+
+                fastLoad('/practice-management/billing-manager?' + queryLine);
+            }
+
+            function init() {
+                $('select[data-filter]')
+                    .off('change')
+                    .on('change', applyFilters);
+                $('.note-popup-trigger')
+                    .off('click')
+                    .on('click', function() {
+                        window.noMc = true;
+                        $.get(this.href, (_data) => {
+                            $('.note-popup-content').html(_data);
+                            $('.note-popup-content')
+                                .find('a, button, input, select')
+                                    .attr('disabled', 'disabled')
+                                    .attr('tabindex', '-1')
+                                    .css('pointer-events', 'none');
+                        });
+                        showStagPopup('note-popup');
+                        return false;
+                    });
+            }
+
+            addMCInitializer('practice-billing-manager', init, '#practice-billing-manager')
+
+        }).call(window);
+    </script>
 @endsection

+ 183 - 0
resources/views/app/practice-management/shipments.blade.php

@@ -0,0 +1,183 @@
+@extends ('layouts/template')
+
+@section('content')
+
+    <div id="practice-shipments" class="p-3 mcp-theme-1">
+    <div class="card">
+
+        <div class="card-header px-3 py-2 d-flex align-items-center">
+            <strong class="mr-4">
+                <i class="fas fa-user-injured"></i>
+                Shipments
+            </strong>
+            <a href="/practice-management/shipments" class="ml-auto">Clear Filters</a>
+        </div>
+        <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">Client</th>
+                    <th class="border-0 w-25">Supply Orders</th>
+                    <th class="border-0">Courier</th>
+                    <th class="border-0">Tracking #</th>
+                    <th class="border-0">Label File</th>
+                    <th class="border-0">Status</th>
+                    <th class="border-0">Created At</th>
+                    <th class="border-0">Cancelled?</th>
+                </tr>
+                <tr>
+                    <th class="p-0 border-bottom-0 border-right">
+                        <select class="form-control form-control-sm bg-aliceblue min-width-unset rounded-0 shadow-none border-0"
+                                data-filter="client">
+                            <option value="">All</option>
+                            @foreach($shClients as $shClient)
+                                <option value="{{$shClient->id}}"
+                                    {{$filters['client'] == $shClient->id ? 'selected' : ''}}>{{$shClient->displayName()}}</option>
+                            @endforeach
+                        </select>
+                    </th>
+                    <th class="p-0 border-bottom-0 border-right"></th>
+                    <th class="p-0 border-bottom-0 border-right">
+                        <input type="text" class="form-control form-control-sm bg-aliceblue min-width-unset rounded-0 shadow-none border-0"
+                               data-filter="courier"
+                               value="{{$filters['courier']}}" placeholder="Any">
+                    </th>
+                    <th class="p-0 border-bottom-0 border-right">
+                        <input type="text" class="form-control form-control-sm bg-aliceblue min-width-unset rounded-0 shadow-none border-0"
+                               data-filter="tracking_num"
+                               value="{{$filters['tracking_num']}}" placeholder="Any">
+                    </th>
+                    <th class="p-0 border-bottom-0 border-right">
+                        <select class="form-control form-control-sm bg-aliceblue min-width-unset rounded-0 shadow-none border-0"
+                                data-filter="label">
+                            <option value="">All</option>
+                            <option {{$filters['label'] == 'yes' ? 'selected' : ''}} value="yes">Present</option>
+                            <option {{$filters['label'] == 'no' ? 'selected' : ''}} value="no">Absent</option>
+                        </select>
+                    </th>
+                    <th class="p-0 border-bottom-0 border-right">
+                        <select class="form-control form-control-sm bg-aliceblue min-width-unset rounded-0 shadow-none border-0"
+                                data-filter="status">
+                            <option value="">All</option>
+                            <option {{$filters['status'] == 'CREATED' ? 'selected' : ''}} value="CREATED">Created</option>
+                            <option {{$filters['status'] == 'SHIPPED' ? 'selected' : ''}} value="SHIPPED">Shipped</option>
+                            <option {{$filters['status'] == 'DELIVERED' ? 'selected' : ''}} value="DELIVERED">Delivered</option>
+                            <option {{$filters['status'] == 'RETURNED_TO_SENDER' ? 'selected' : ''}} value="RETURNED_TO_SENDER">Returned to Sender</option>
+                            <option {{$filters['status'] == 'CANCELLED' ? 'selected' : ''}} value="CANCELLED">Cancelled</option>
+                        </select>
+                    </th>
+                    <th class="p-0 border-bottom-0 border-right"></th>
+                    <th class="p-0 border-bottom-0 border-right">
+                        <select class="form-control form-control-sm bg-aliceblue min-width-unset rounded-0 shadow-none border-0"
+                                data-filter="cancelled">
+                            <option value="">All</option>
+                            <option {{$filters['cancelled'] == 'not_cancelled' ? 'selected' : ''}} value="not_cancelled">Not Cancelled</option>
+                            <option {{$filters['cancelled'] == 'cancelled' ? 'selected' : ''}} value="cancelled">Cancelled</option>
+                        </select>
+                    </th>
+                </tr>
+                </thead>
+                <tbody>
+                @foreach ($shipments as $shipment)
+                    <tr class="{{$shipment->is_cancelled ? 'bg-light' : ''}}">
+                        <td>{{$shipment->client->displayName()}}</a></td>
+                        <td>
+                            @if($shipment->supplyOrders && count($shipment->supplyOrders))
+                                <table class="table table-sm table-striped table-bordered mb-0 bg-white">
+                                    <thead>
+                                    <tr class="">
+                                        <th class="text-nowrap text-secondary border-bottom-0">Supply Order</th>
+                                        <th class="text-nowrap text-secondary border-bottom-0">IMEI</th>
+                                        <th class="text-nowrap text-secondary border-bottom-0">Lot #</th>
+                                    </tr>
+                                    </thead>
+                                    <tbody>
+                                    @foreach($shipment->supplyOrders as $iSupplyOrder)
+                                        <tr class="">
+                                            <td class="">{{ $iSupplyOrder->product->title }}</td>
+                                            <td class="">{{ $iSupplyOrder->imei }}</td>
+                                            <td class="">{{ $iSupplyOrder->lot_number }}</td>
+                                        </tr>
+                                    @endforeach
+                                    </tbody>
+                                </table>
+                            @else
+                                None
+                            @endif
+                        </td>
+                        <td>{{$shipment->courier}}</td>
+                        <td>{{$shipment->tracking_number}}</td>
+                        <td>
+                            @if($shipment->label_system_file_id)
+                            <a class="pdf-viewer-trigger" native="" target="_blank"
+                               href="/api/shipment/downloadLabel/{{$shipment->uid}}" title="View">
+                                <i class="fa fa-file-pdf text-danger on-hover-opaque"></i>
+                                View
+                            </a>
+                            @endif
+                        </td>
+                        <td>
+                            {{$shipment->status}}
+                            @if($shipment->status === 'DELIVERED' && $shipment->delivered_date)
+                                <div class="text-secondary text-sm mt-1">
+                                    on {{friendlier_date_time($shipment->delivered_date)}}
+                                </div>
+                            @endif
+                        </td>
+                        <td>
+                            {{friendlier_date_time($shipment->created_at)}}
+                            <div class="text-secondary text-sm mt-1">
+                                By {{$shipment->createdSession->pro->displayName()}}
+                            </div>
+                        </td>
+                        <td>{!! $shipment->is_cancelled ? '<b class="text-warning-mellow">Yes</b>' : 'No' !!}</td>
+                    </tr>
+                @endforeach
+                </tbody>
+            </table>
+            <div>
+                {{$shipments->links()}}
+            </div>
+        </div>
+    </div>
+    </div>
+
+    <script>
+        (function() {
+
+            function applyFilters() {
+                let params = {}, queryLine = [];
+                $('[data-filter]').each(function() {
+                    if($.trim($(this).val())) {
+                        params[$(this).attr('data-filter')] = $.trim($(this).val());
+                    }
+                });
+                for(let x in params) {
+                    if(params.hasOwnProperty(x)) {
+                        queryLine.push(x + '=' + encodeURIComponent(params[x]));
+                    }
+                }
+                queryLine = queryLine.join('&');
+
+                fastLoad('/practice-management/shipments?' + queryLine);
+            }
+
+            function init() {
+                $('select[data-filter]')
+                    .off('change')
+                    .on('change', applyFilters);
+                $('input[data-filter]')
+                    .off('keyup')
+                    .on('keyup', function(_event) {
+                        if(_event.which === 13) {
+                            applyFilters();
+                            return false;
+                        }
+                    });
+            }
+
+            addMCInitializer('practice-shipments', init, '#practice-shipments')
+
+        }).call(window);
+    </script>
+@endsection

+ 233 - 0
resources/views/app/practice-management/supply-orders.blade.php

@@ -0,0 +1,233 @@
+@extends ('layouts/template')
+
+@section('content')
+
+    <div id="practice-supply-orders" class="p-3 mcp-theme-1">
+    <div class="card">
+
+        <div class="card-header px-3 py-2 d-flex align-items-center">
+            <strong class="mr-4">
+                <i class="fas fa-user-injured"></i>
+                Supply Orders
+            </strong>
+            <a href="/practice-management/supply-orders" class="ml-auto">Clear Filters</a>
+        </div>
+        <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">Client</th>
+                    <th class="border-0">Product</th>
+                    <th class="border-0">Reason</th>
+                    <th class="border-0">Client Understanding Memo</th>
+                    <th class="border-0">Pro Sign</th>
+                    <th class="border-0">Client Sign</th>
+                    <th class="border-0">Shipment</th>
+                    <th class="border-0">Lot #</th>
+                    <th class="border-0">IMEI</th>
+                    <th class="border-0">Created At</th>
+                    <th class="border-0">Cancelled?</th>
+                </tr>
+                <tr>
+                    <th class="p-0 border-bottom-0 border-right">
+                        <select class="form-control form-control-sm bg-aliceblue min-width-unset rounded-0 shadow-none border-0"
+                                data-filter="client">
+                            <option value="">All</option>
+                            @foreach($soClients as $soClient)
+                                <option value="{{$soClient->id}}"
+                                    {{$filters['client'] == $soClient->id ? 'selected' : ''}}>{{$soClient->displayName()}}</option>
+                            @endforeach
+                        </select>
+                    </th>
+                    <th class="p-0 border-bottom-0 border-right">
+                        <select class="form-control form-control-sm bg-aliceblue min-width-unset rounded-0 shadow-none border-0"
+                                data-filter="product">
+                            <option value="">All</option>
+                            @foreach($soProducts as $soProduct)
+                                <option value="{{$soProduct->id}}"
+                                    {{$filters['product'] == $soProduct->id ? 'selected' : ''}}>{{$soProduct->title}}</option>
+                            @endforeach
+                        </select>
+                    </th>
+                    <th class="p-0 border-bottom-0 border-right">
+                        <input type="text" class="form-control form-control-sm bg-aliceblue min-width-unset rounded-0 shadow-none border-0"
+                               data-filter="reason"
+                               value="{{$filters['reason']}}" placeholder="Any">
+                    </th>
+                    <th class="p-0 border-bottom-0 border-right">
+                        <input type="text" class="form-control form-control-sm bg-aliceblue min-width-unset rounded-0 shadow-none border-0"
+                               data-filter="cu_memo"
+                               value="{{$filters['cu_memo']}}" placeholder="Any">
+                    </th>
+                    <th class="p-0 border-bottom-0 border-right">
+                        <select class="form-control form-control-sm bg-aliceblue min-width-unset rounded-0 shadow-none border-0"
+                                data-filter="pro_sign">
+                            <option value="">All</option>
+                            <option {{$filters['pro_sign'] == 'not_signed' ? 'selected' : ''}} value="not_signed">Not Signed</option>
+                            <option {{$filters['pro_sign'] == 'signed' ? 'selected' : ''}} value="signed">Signed</option>
+                        </select>
+                    </th>
+                    <th class="p-0 border-bottom-0 border-right">
+                        <select class="form-control form-control-sm bg-aliceblue min-width-unset rounded-0 shadow-none border-0"
+                                data-filter="client_sign">
+                            <option value="">All</option>
+                            <option {{$filters['client_sign'] == 'not_signed' ? 'selected' : ''}} value="not_signed">Not Signed</option>
+                            <option {{$filters['client_sign'] == 'signed' ? 'selected' : ''}} value="signed">Signed</option>
+                            <option {{$filters['client_sign'] == 'waived' ? 'selected' : ''}} value="waived">Waived</option>
+                        </select>
+                    </th>
+                    <th class="p-0 border-bottom-0 border-right">
+                        <select class="form-control form-control-sm bg-aliceblue min-width-unset rounded-0 shadow-none border-0"
+                                data-filter="shipment">
+                            <option value="">All</option>
+                            <optgroup label="Pro">
+                                <option {{$filters['shipment'] == 'not_cleared_for_shipment' ? 'selected' : ''}} value="not_cleared_for_shipment">Not Cleared for Shipment</option>
+                                <option {{$filters['shipment'] == 'cleared_for_shipment' ? 'selected' : ''}} value="cleared_for_shipment">Cleared for Shipment</option>
+                            </optgroup>
+                            <optgroup label="Warehouse">
+                                <option {{$filters['shipment'] == 'CREATED' ? 'selected' : ''}} value="CREATED">Created</option>
+                                <option {{$filters['shipment'] == 'SHIPPED' ? 'selected' : ''}} value="SHIPPED">Shipped</option>
+                                <option {{$filters['shipment'] == 'DELIVERED' ? 'selected' : ''}} value="DELIVERED">Delivered</option>
+                                <option {{$filters['shipment'] == 'RETURNED_TO_SENDER' ? 'selected' : ''}} value="RETURNED_TO_SENDER">Returned to Sender</option>
+                                <option {{$filters['shipment'] == 'CANCELLED' ? 'selected' : ''}} value="CANCELLED">Cancelled</option>
+                            </optgroup>
+                        </select>
+                    </th>
+                    <th class="p-0 border-bottom-0 border-right">
+                        <input type="text" class="form-control form-control-sm bg-aliceblue min-width-unset rounded-0 shadow-none border-0"
+                               data-filter="lot_number"
+                               value="{{$filters['lot_number']}}" placeholder="Any">
+                    </th>
+                    <th class="p-0 border-bottom-0 border-right">
+                        <input type="text" class="form-control form-control-sm bg-aliceblue min-width-unset rounded-0 shadow-none border-0"
+                               data-filter="imei"
+                               value="{{$filters['imei']}}" placeholder="Any">
+                    </th>
+                    <th class="p-0 border-bottom-0 border-right">
+
+                    </th>
+                    <th class="p-0 border-bottom-0 border-right">
+                        <select class="form-control form-control-sm bg-aliceblue min-width-unset rounded-0 shadow-none border-0"
+                                data-filter="cancelled">
+                            <option value="">All</option>
+                            <option {{$filters['cancelled'] == 'not_cancelled' ? 'selected' : ''}} value="not_cancelled">Not Cancelled</option>
+                            <option {{$filters['cancelled'] == 'cancelled' ? 'selected' : ''}} value="cancelled">Cancelled</option>
+                        </select>
+                    </th>
+                </tr>
+                </thead>
+                <tbody>
+                @foreach ($supplyOrders as $supplyOrder)
+                    <tr class="{{$supplyOrder->is_cancelled ? 'bg-light' : ''}}">
+                        <td>{{$supplyOrder->client->displayName()}}</a></td>
+                        <td>{{$supplyOrder->product->title}}</td>
+                        <td>{{$supplyOrder->reason}}</td>
+                        <td>{{$supplyOrder->client_understanding_memo}}</td>
+                        <td>
+                            @if($supplyOrder->is_signed_by_pro)
+                                <b>Signed</b>
+                                <div class="text-secondary text-sm mt-1">
+                                    By {{$supplyOrder->signedPro->displayName()}}<br>
+                                    {{friendlier_date_time($supplyOrder->pro_signed_at)}}
+                                </div>
+                            @else
+                                Not Signed
+                            @endif
+                        </td>
+                        <td>
+                            @if($supplyOrder->is_signed_by_client)
+                                <b>Signed</b>
+                                <div class="text-secondary text-sm mt-1">
+                                    By {{$patient->displayName()}}<br>
+                                    On {{friendlier_date_time($supplyOrder->client_signed_at)}}
+                                </div>
+                            @elseif($supplyOrder->is_client_signature_waived)
+                                <b>Waived</b>
+                                <div class="text-secondary text-sm mt-1">
+                                    By {{$supplyOrder->waiverPro->displayName()}}<br>
+                                    on {{friendlier_date_time($supplyOrder->client_signature_waived_at)}}
+                                </div>
+                            @else
+                                Not Signed
+                            @endif
+                        </td>
+                        <td>
+                            @if($supplyOrder->shipment_id)
+                                <i class="fa fa-building"></i>
+                                {{$supplyOrder->shipment->status}}
+                                @if($supplyOrder->shipment && $supplyOrder->shipment->status === 'DELIVERED' && $supplyOrder->shipment->delivered_date)
+                                    <div class="text-secondary text-sm mt-1">
+                                    on {{friendlier_date_time($supplyOrder->shipment->delivered_date)}}
+                                    </div>
+                                @endif
+                            @elseif($supplyOrder->is_cleared_for_shipment)
+                                <i class="fa fa-user-nurse"></i>
+                                Cleared for shipment
+                                <div class="text-secondary text-sm mt-1">
+                                    By {{$supplyOrder->clearedForShipmentPro->displayName()}}<br>
+                                    on {{friendlier_date_time($supplyOrder->cleared_for_shipment_at)}}
+                                </div>
+                            @else
+                                <i class="fa fa-user-nurse"></i>
+                                Not cleared for shipment
+                            @endif
+                        </td>
+                        <td>{{$supplyOrder->lot_number}}</td>
+                        <td>{{$supplyOrder->imei}}</td>
+                        <td>
+                            {{friendlier_date_time($supplyOrder->created_at)}}
+                            <div class="text-secondary text-sm mt-1">
+                                By {{$supplyOrder->createdSession->pro->displayName()}}
+                            </div>
+                        </td>
+                        <td>{!! $supplyOrder->is_cancelled ? '<b class="text-warning-mellow">Yes</b>' : 'No' !!}</td>
+                    </tr>
+                @endforeach
+                </tbody>
+            </table>
+            <div>
+                {{$supplyOrders->links()}}
+            </div>
+        </div>
+    </div>
+    </div>
+
+    <script>
+        (function() {
+
+            function applyFilters() {
+                let params = {}, queryLine = [];
+                $('[data-filter]').each(function() {
+                    if($.trim($(this).val())) {
+                        params[$(this).attr('data-filter')] = $.trim($(this).val());
+                    }
+                });
+                for(let x in params) {
+                    if(params.hasOwnProperty(x)) {
+                        queryLine.push(x + '=' + encodeURIComponent(params[x]));
+                    }
+                }
+                queryLine = queryLine.join('&');
+
+                fastLoad('/practice-management/supply-orders?' + queryLine);
+            }
+
+            function init() {
+                $('select[data-filter]')
+                    .off('change')
+                    .on('change', applyFilters);
+                $('input[data-filter]')
+                    .off('keyup')
+                    .on('keyup', function(_event) {
+                        if(_event.which === 13) {
+                            applyFilters();
+                            return false;
+                        }
+                    });
+            }
+
+            addMCInitializer('practice-supply-orders', init, '#practice-supply-orders')
+
+        }).call(window);
+    </script>
+@endsection

+ 9 - 8
resources/views/app/video/check-video-minimal.blade.php

@@ -30,8 +30,9 @@
 <div class="videos-container">
 
     {{-- check video button --}}
-    <button id="btn-start-video" disabled
-            class="btn btn-primary px-4 font-weight-bold d-none mx-auto my-3">
+    <button id="btn-start-video"
+            onclick="window.StagVideo.init(); return false;"
+            class="btn btn-primary px-4 font-weight-bold d-block mx-auto my-3">
         Check Video
     </button>
 
@@ -161,11 +162,11 @@
                 });
 
                 // event handlers
-                $(document)
-                    .off('click.start-video', '#btn-start-video')
-                    .on('click.start-video', '#btn-start-video', () => {
-                        this.initMedia();
-                    });
+                // $(document)
+                //     .off('click.start-video', '#btn-start-video')
+                //     .on('click.start-video', '#btn-start-video', () => {
+                //         this.initMedia();
+                //     });
 
                 $(document)
                     .off('click.hang-up', '#btn-hang-up')
@@ -698,7 +699,7 @@
 
         };
 
-        window.StagVideo.init();
+        // window.StagVideo.init();
 
     }).call(window);
 </script>

+ 1 - 0
resources/views/layouts/empty.blade.php

@@ -0,0 +1 @@
+@yield('content')

+ 8 - 2
resources/views/layouts/patient.blade.php

@@ -1,10 +1,11 @@
-@extends('layouts.template')
+@extends(request()->input('popupmode') ? 'layouts.empty' : 'layouts.template')
 <?php
 /** @var \App\Models\Client $patient */
 ?>
 @section('content')
     <div class="container-fluid h-100">
-        <div class="main-row h-100">
+        <div class="main-row h-100 {{ !request()->input('popupmode') ? '' : 'px-0' }}">
+            @if(!request()->input('popupmode'))
             <nav id="sidebarMenu" class="d-md-block bg-light sidebar collapse px-0">
                 <div class="sidebar-sticky pt-3">
                     <ul class="nav flex-column mcp-theme-1">
@@ -183,6 +184,7 @@
                     </div>
                 </div>
             </nav>
+            @endif
             <main role="main" class="w-100">
                 <div class="card mt-3">
                     <div class="card-header py-1">
@@ -261,6 +263,8 @@
                                                             @if($patient->mcn)
                                                                 {{$patient->mcn}} Invalid MCN <i
                                                                     class="fa fa-times"></i>
+                                                            @elseif($patient->payer)
+                                                                {{$patient->payer->name()}}
                                                             @else
                                                                 No Info Provided
                                                             @endif
@@ -612,9 +616,11 @@
                                         </div>
                                     </section>
                                     <section class="vbox mt-2 align-self-start ml-1">
+                                        @if($performer->pro->pro_type == 'ADMIN')
                                         <div>
                                             <button class="col-2-button" onclick="return openInRHS('/pro/check-video/{{ $patient->uid }}')">Check Video</button>
                                         </div>
+                                        @endif
                                         <div>
                                             <button class="col-2-button" onclick="return openInRHS('/pro/meet/{{ $patient->uid }}')">Join Video</button>
                                         </div>

+ 7 - 5
resources/views/layouts/template.blade.php

@@ -18,7 +18,7 @@
 
     {{-- Quill RTE --}}
     <script>
-        let stagQuillConfig = {
+        window.stagQuillConfig = {
             toolbar: ['bold', 'italic', 'underline', { 'list': 'ordered'}, { 'list': 'bullet' }],
             keyboard: {
                 bindings: {
@@ -94,6 +94,7 @@
                 <li class="nav-item"><a class="nav-link" href="{{ route('patients') }}"><i class="mr-1 fas fa-user-injured"></i> Patients</a> </li>
                 @if($pro && ($pro->can_add_patients || $pro->pro_type== 'ADMIN'))
                 <li class="nav-item"><a class="nav-link" href="{{ route('new-patient') }}"><i class="mr-1 fas fa-user-plus"></i> New Patient</a> </li>
+                <li class="nav-item"><a class="nav-link" href="{{ route('new-non-mcn-patient') }}"><i class="mr-1 fas fa-user-plus"></i> New Non Medicare Patient</a> </li>
                 @endif
                 <li class="nav-item dropdown">
                     <a class="nav-link dropdown-toggle" href="#" id="practice-management" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="mr-1 fas fa-tasks"></i> Practice</a>
@@ -122,7 +123,9 @@
                             <a class="dropdown-item" href="{{ route('practice-management.claims') }}">Claims</a>
                             <a class="dropdown-item" href="{{ route('practice-management.hcpBillMatrix') }}">HCP Bill Matrix</a>
                             <a class="dropdown-item" href="{{ route('practice-management.treatmentServiceUtil') }}">Treatment Service Util.</a>
-                            <a class="dropdown-item" href="/practice-management/tickets">Tickets</a>
+                            <a class="dropdown-item" href="{{ route('practice-management.tickets') }}">Tickets</a>
+                            <a class="dropdown-item" href="{{ route('practice-management.supply-orders') }}">Supply Orders</a>
+                            <a class="dropdown-item" href="{{ route('practice-management.shipments') }}">Shipments</a>
                         @endif
                     </div>
                 </li>
@@ -131,7 +134,7 @@
             <div class="current-work mr-2">
                 @include('app/current-work')
             </div>
-            <a href="#" class="mr-2 text-white small" onclick="fastReload()"><i class="fa fa-sync"></i></a>
+            <a href="#" class="mr-2 text-white small" onclick="return fastReload()"><i class="fa fa-sync"></i></a>
             <div class="d-inline-flex pr-2 mcp-theme-1 position-relative">
                 <input id="patient-search" type="search" class="form-control form-control-sm outline-0" autocomplete="off" placeholder="Search Patients">
                 <div class="suggestions-outer position-absolute d-none">
@@ -304,8 +307,7 @@
     <script src="/js/option-list.js"></script>
     @include('app/pdf/viewer')
     <script>
-        let socket = new SockJS("{{ config('app.backend_ws_url') }}");
-        window.socketClient = Stomp.over(socket);
+        window.socketClient = Stomp.over(new SockJS("{{ config('app.backend_ws_url') }}"));
         window.socketClient.connect({}, (frame) => {
 
             window.socketClient.send("/app/register", {},     // register self

+ 5 - 0
routes/web.php

@@ -62,6 +62,7 @@ Route::middleware('pro.auth')->group(function () {
     Route::get('/', 'HomeController@dashboard')->name('dashboard');
 
     Route::get('/new-patient', 'HomeController@newPatient')->name('new-patient');
+    Route::get('/new-non-mcn-patient', 'HomeController@newNonMcnPatient')->name('new-non-mcn-patient');
 
     Route::get('/patients/{filter?}', 'HomeController@patients')->name('patients');
 
@@ -99,6 +100,7 @@ Route::middleware('pro.auth')->group(function () {
             Route::get('processing-bill-matrix/{proUid?}', 'PracticeManagementController@processingBillMatrix')->name('processingBillMatrix');
 
             Route::get('hcp-bill-matrix/{proUid?}', 'PracticeManagementController@hcpBillMatrix')->name('hcpBillMatrix');
+            Route::get('bill-matrix/{proUid?}', 'PracticeManagementController@billMatrix')->name('billMatrix');
 
             Route::get('tickets', 'PracticeManagementController@tickets')->name('tickets');
             Route::get('claims', 'PracticeManagementController@claims')->name('claims');
@@ -106,6 +108,9 @@ Route::middleware('pro.auth')->group(function () {
 
             Route::get('treatment-service-util', 'PracticeManagementController@treatmentServiceUtil')->name('treatmentServiceUtil');
 
+            Route::get('supply-orders', 'PracticeManagementController@supplyOrders')->name('supply-orders');
+            Route::get('shipments', 'PracticeManagementController@shipments')->name('shipments');
+
         });
     });