Bläddra i källkod

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

= 3 år sedan
förälder
incheckning
bea096013f
38 ändrade filer med 1667 tillägg och 679 borttagningar
  1. 19 0
      app/Helpers/helpers.php
  2. 12 1
      app/Http/Controllers/HomeController.php
  3. 130 8
      app/Http/Controllers/PracticeManagementController.php
  4. 8 0
      app/Models/Bill.php
  5. 26 0
      app/Models/CareMonth.php
  6. 10 0
      app/Models/CareMonthCmRmReason.php
  7. 58 3
      app/Models/Client.php
  8. 10 0
      app/Models/ClientCmRmReason.php
  9. 4 0
      app/Models/ClientProChange.php
  10. 5 0
      app/Models/CompanyPro.php
  11. 4 0
      app/Models/IncomingReport.php
  12. 5 0
      app/Models/Note.php
  13. 10 0
      app/Models/Pro.php
  14. 8 0
      app/Models/ProTransaction.php
  15. 4 0
      app/Models/Ticket.php
  16. 30 0
      resources/views/app/generic-bills/add-bill-form/Note.blade.php
  17. 3 3
      resources/views/app/generic-bills/add-bill-form/_default-fields.blade.php
  18. 33 5
      resources/views/app/generic-bills/add-bill-form/default.blade.php
  19. 21 24
      resources/views/app/patient/care-month/_create-claim.blade.php
  20. 0 144
      resources/views/app/patient/care-month/_create-rm-reason.blade.php
  21. 114 73
      resources/views/app/patient/care-month/dashboard.blade.php
  22. 54 17
      resources/views/app/patient/care-month/rm-reasons.blade.php
  23. 117 80
      resources/views/app/patient/note/dashboard.blade.php
  24. 5 5
      resources/views/app/patient/notes.blade.php
  25. 0 135
      resources/views/app/patient/partials/_create-rm-reason.blade.php
  26. 54 17
      resources/views/app/patient/partials/rm-reasons.blade.php
  27. 47 8
      resources/views/app/patient/rm-setup.blade.php
  28. 133 0
      resources/views/app/patient/settings.blade.php
  29. 47 1
      resources/views/app/patient/shipments.blade.php
  30. 116 46
      resources/views/app/patient/supply-orders.blade.php
  31. 2 0
      resources/views/app/practice-management/bills.blade.php
  32. 194 33
      resources/views/app/practice-management/cellular-device-manager.blade.php
  33. 109 3
      resources/views/app/practice-management/financial-transactions.blade.php
  34. 14 2
      resources/views/app/practice-management/pro-financials.blade.php
  35. 32 5
      resources/views/app/practice-management/process-claims.blade.php
  36. 144 66
      resources/views/app/practice-management/processing-bill-matrix.blade.php
  37. 84 0
      resources/views/app/practice-management/rm-launch-and-clean.blade.php
  38. 1 0
      routes/web.php

+ 19 - 0
app/Helpers/helpers.php

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

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

@@ -1038,6 +1038,17 @@ WHERE measurement.label NOT IN ('SBP', 'DBP')
     }
 
     public function genericBill(Request $request, $entityType, $entityUid) {
-        return view('app.generic-bills.inline', ['class' => 'p-3 border-top mt-3', 'entityType' => $entityType, 'entityUid' => $entityUid]);
+        $patient = null;
+        if ($entityType && $entityUid) {
+            try {
+                $entityClass = "\\App\\Models\\" . $entityType;
+                $entity = $entityClass::where('uid', $entityUid)->first();
+                if ($entity->client) {
+                    $patient = $entity->client;
+                }
+            } catch (\Exception $e) {
+            }
+        }
+        return view('app.generic-bills.inline', ['class' => 'p-3 border-top mt-3', 'entityType' => $entityType, 'entityUid' => $entityUid, 'patient' => $patient]);
     }
 }

+ 130 - 8
app/Http/Controllers/PracticeManagementController.php

@@ -6,6 +6,7 @@ use App\Models\AppSession;
 use App\Models\BillingReport;
 use App\Models\CareMonth;
 use App\Models\ClaimEDI;
+use App\Models\Company;
 use App\Models\Handout;
 use App\Models\MBClaim;
 use App\Models\Measurement;
@@ -79,8 +80,46 @@ class PracticeManagementController extends Controller
 
     public function financialTransactions(Request $request)
     {
-        $transactions = ProTransaction::where('pro_id', $this->performer()->pro->id)->orderBy('created_at', 'desc')->get();
-        return view('app.practice-management.financial-transactions', compact('transactions'));
+        $pro = $this->performer()->pro;
+        $transactions = null;
+        if($pro->pro_type === 'ADMIN') {
+            $transactions = ProTransaction::whereNotNull('id');
+        }
+        else {
+            $transactions = ProTransaction::where('pro_id', $pro->id);
+        }
+
+        $filter = $request->input('p');
+        if ($filter) {
+            $filterPro = Pro::where('uid', $filter)->first();
+            if($filterPro) {
+                $transactions = $transactions->where('pro_id', '=', $filterPro->id);
+            }
+        }
+
+        $filter = $request->input('t');
+        if ($filter) {
+            $transactions = $transactions->where('plus_or_minus', '=', $filter);
+        }
+
+        $filter = $request->input('c');
+        if ($filter) {
+            $transactions = $transactions->where('company_id', '=', $filter);
+        }
+
+        $filter = $request->input('bs');
+        if ($filter) {
+            $transactions = $transactions->where('created_at', '>=', $filter);
+        }
+
+        $filter = $request->input('be');
+        if ($filter) {
+            $transactions = $transactions->where('created_at', '<=', $filter);
+        }
+
+        $transactions = $transactions->orderBy('created_at', 'desc')->paginate();
+        $companies = Company::where('is_active', true)->orderBy('name')->get();
+        return view('app.practice-management.financial-transactions', compact('transactions', 'companies'));
     }
 
     public function pendingBillsToSign(Request $request)
@@ -198,6 +237,21 @@ class PracticeManagementController extends Controller
 
             // more cases can be added as needed
             default:
+                $query = $query
+                    ->where(function ($q) use ($proID) {
+                        $q->where(function ($q2) use ($proID) {
+                            $q2->where('hcp_pro_id', $proID);
+                        })
+                            ->orWhere(function ($q2) use ($proID) {
+                                $q2->where('cm_pro_id', $proID);
+                            })
+                            ->orWhere(function ($q2) use ($proID) {
+                                $q2->where('rme_pro_id', $proID);
+                            })
+                            ->orWhere(function ($q2) use ($proID) {
+                                $q2->where('rmm_pro_id', $proID);
+                            });
+                    });
                 break;
         }
         $bills = $query->orderBy('created_at', 'desc')->get();
@@ -510,21 +564,19 @@ class PracticeManagementController extends Controller
         $proUid = $proUid ? $proUid : $request->get('pro-uid');
         $performerPro = $this->performer->pro;
         $targetPro = null;
-        $allPros = [];
         $expectedForHcp = null;
         if ($performerPro->pro_type == 'ADMIN') {
-            $allPros = Pro::all();
             $targetPro = Pro::where('uid', $proUid)->first();
         } else {
             $targetPro = $performerPro;
         }
         $clients = [];
         if ($targetPro) {
-            $clients = Client::where('mcp_pro_id', $targetPro->id)->orderBy('created_at', 'desc')->paginate(100);
+            $clients = Client::where('mcp_pro_id', $targetPro->id)->orderBy('created_at', 'desc')->paginate(20);
         } else {
-            $clients = Client::orderBy('created_at', 'desc')->paginate(100);
+            $clients = Client::orderBy('created_at', 'desc')->paginate(20);
         }
-        return view('app.practice-management.cellular-device-manager', compact('clients', 'allPros', 'targetPro', 'proUid'));
+        return view('app.practice-management.cellular-device-manager', compact('clients', 'targetPro', 'proUid'));
     }
 
     public function treatmentServiceUtil(Request $request)
@@ -558,6 +610,9 @@ class PracticeManagementController extends Controller
             if ($targetPro) {
                 $bills = $bills->where('hcp_pro_id', $targetPro->id);
             }
+            if($request->input('c')) {
+                $bills = $bills->whereRaw('(SELECT company_id from company_pro where id = hcp_company_pro_id) = ' . $request->input('c'));
+            }
         }
         else if($request->input('t') === 'na') {
             $bills = $bills
@@ -566,6 +621,9 @@ class PracticeManagementController extends Controller
             if ($targetPro) {
                 $bills = $bills->where('generic_pro_id', $targetPro->id);
             }
+            if($request->input('c')) {
+                $bills = $bills->whereRaw('(SELECT company_id from company_pro where id = generic_company_pro_id) = ' . $request->input('c'));
+            }
         }
 
         $filter = $request->input('f');
@@ -588,13 +646,24 @@ class PracticeManagementController extends Controller
             $bills = $bills->where('balance_post_date', '<=', $filter);
         }
 
+        $filter = $request->input('s');
+        if ($filter) {
+            $bills = $bills->where('code', '=', $filter);
+        }
+
         $bills = $bills->orderBy('effective_date', 'desc')->paginate();
 
+        $companies = Company::where('is_active', true)->orderBy('name')->get();
+
+        $codes = DB::select(DB::raw("SELECT code, count(*) as count FROM bill WHERE is_cancelled IS FALSE GROUP BY code ORDER BY code"));
+
         $viewData = [
             'bills' => $bills,
             'targetPro' => $targetPro,
             'performerPro' => $performerPro,
-            'proUid' => $proUid
+            'proUid' => $proUid,
+            'companies' => $companies,
+            'codes' => $codes
         ];
         return view('app.practice-management.processing-bill-matrix', $viewData);
     }
@@ -1284,6 +1353,7 @@ SELECT claim.uid AS uid,
        note.uid AS note_uid,
        note.method,
        note.new_or_fu_or_na,
+       care_month.uid AS care_month_uid,
        -- claim.status_updated_at,
        (DATE(claim.status_updated_at) || ' ' ||
             LPAD(EXTRACT(hour FROM claim.status_updated_at)::text, 2, '0') || ':' ||
@@ -1295,6 +1365,7 @@ FROM claim
     join client on claim.client_id = client.id
     join pro cp on claim.pro_id = cp.id
     left join note on claim.note_id = note.id
+    left join care_month on claim.cm_id = care_month.id
     left join app_session on claim.status_updated_by_session_id = app_session.id
     left join pro sp on app_session.pro_id = sp.id
 --WHERE claim.status IS NULL OR claim.status = 'NEW'
@@ -1318,6 +1389,57 @@ ORDER BY claim.created_at ASC
         return  view('app.practice-management.process-claims', compact('claims', 'status'));
     }
 
+    public function rmLaunchAndClean(Request  $request) {
+
+        $keyNumbers = [];
+
+        $keyNumbers['careMonthsEligibleForBillGeneration_RM30_HCP_PLUS_NONHCP40'] = CareMonth::where('is_bill_closed', false)
+            ->whereNotNull('company_pro_id')
+            ->whereNotNull('company_pro_payer_id')
+            ->whereNotNull('company_location_id')
+            ->whereRaw('(SELECT count(id) FROM care_month_cm_rm_reason WHERE care_month_id = care_month.id) > 0')
+            ->where('rm_total_time_in_seconds_by_mcp', '>=', 1800)
+            ->where('rm_total_time_in_seconds', '>=', 4200) // at 4200 (70 minutes, it becomes eligible for plus40)
+            ->count();
+
+        $keyNumbers['careMonthsEligibleForBillGeneration_RM30_HCP_PLUS_NONHCP20'] = CareMonth::where('is_bill_closed', false)
+            ->whereNotNull('company_pro_id')
+            ->whereNotNull('company_pro_payer_id')
+            ->whereNotNull('company_location_id')
+            ->whereRaw('(SELECT count(id) FROM care_month_cm_rm_reason WHERE care_month_id = care_month.id) > 0')
+            ->where('rm_total_time_in_seconds_by_mcp', '>=', 1800)
+            ->where('rm_total_time_in_seconds', '<', 4200)
+            ->where('rm_total_time_in_seconds', '>=', 3000) // at 3000 (50 minutes, it becomes eligible for plus20)
+            ->count();
+
+        $keyNumbers['careMonthsEligibleForBillGeneration_RM30_HCP'] = CareMonth::where('is_bill_closed', false)
+            ->whereNotNull('company_pro_id')
+            ->whereNotNull('company_pro_payer_id')
+            ->whereNotNull('company_location_id')
+            ->whereRaw('(SELECT count(id) FROM care_month_cm_rm_reason WHERE care_month_id = care_month.id) > 0')
+            ->where('rm_total_time_in_seconds_by_mcp', '>=', 1800)
+            ->where('rm_total_time_in_seconds', '<', 3000)
+            ->count();
+
+        $keyNumbers['careMonthsWithoutCompanyProInfo'] = CareMonth::where('is_bill_closed', false)
+            ->where(function ($q) {
+                $q->whereNull('company_pro_id')
+                    ->orWhereNull('company_pro_payer_id')
+                    ->orWhereNull('company_location_id');
+            })
+            ->count();
+
+        /*$keyNumbers['careMonthsWithoutRMReasons'] = CareMonth::where('is_bill_closed', false)
+            ->whereRaw('(SELECT count(id) FROM care_month_cm_rm_reason WHERE care_month_id = care_month.id) = 0')
+            ->count();*/
+
+        $keyNumbers['careMonthsUnder30RMMinutes'] = CareMonth::where('is_bill_closed', false)
+            ->where('rm_total_time_in_seconds', '<', 1800)
+            ->count();
+
+        return  view('app.practice-management.rm-launch-and-clean', compact('keyNumbers'));
+    }
+
     public function processNotes(Request  $request) {
 
         $mode = $request->input('mode') ? $request->input('mode') : '1';

+ 8 - 0
app/Models/Bill.php

@@ -32,4 +32,12 @@ class Bill extends Model
     public function genericPro() {
         return $this->hasOne(Pro::class, 'id', 'generic_pro_id');
     }
+
+    public function hcpCompanyPro() {
+        return $this->hasOne(CompanyPro::class, 'id', 'hcp_company_pro_id');
+    }
+
+    public function genericCompanyPro() {
+        return $this->hasOne(CompanyPro::class, 'id', 'generic_company_pro_id');
+    }
 }

+ 26 - 0
app/Models/CareMonth.php

@@ -14,6 +14,10 @@ class CareMonth extends Model
         return $this->hasOne(Client::class, 'id', 'client_id');
     }
 
+    public function client(){
+        return $this->hasOne(Client::class, 'id', 'client_id');
+    }
+
     public function mcp(){
         return $this->hasOne(Pro::class, 'id', 'mcp_pro_id');
     }
@@ -57,6 +61,11 @@ class CareMonth extends Model
         return $this->hasOne(Bill::class, 'id', 'rm_bill_id');
     }
 
+    public function companyPro()
+    {
+        return $this->hasOne(CompanyPro::class, 'id', 'company_pro_id');
+    }
+
     public function company()
     {
         return $this->hasOne(Company::class, 'id', 'company_id');
@@ -71,4 +80,21 @@ class CareMonth extends Model
     {
         return $this->hasOne(CompanyLocation::class, 'id', 'company_location_id');
     }
+
+
+    public function cmReasons()
+    {
+        return $this->hasMany(CareMonthCmRmReason::class, 'care_month_id', 'id')
+            ->where('cm_or_rm', 'CM')
+            ->orderBy('position_index', 'ASC')
+            ->orderBy('code', 'ASC');
+    }
+
+    public function rmReasons()
+    {
+        return $this->hasMany(CareMonthCmRmReason::class, 'care_month_id', 'id')
+            ->where('cm_or_rm', 'RM')
+            ->orderBy('position_index', 'ASC')
+            ->orderBy('code', 'ASC');
+    }
 }

+ 10 - 0
app/Models/CareMonthCmRmReason.php

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

+ 58 - 3
app/Models/Client.php

@@ -344,14 +344,30 @@ class Client extends Model
     {
     }
 
+    public function supplyOrderForCellularBPDevice() {
+        return SupplyOrder::where('product_id', 1)
+            ->where('is_cancelled', false)
+            ->where('client_id', $this->id)
+            ->orderBy('id', 'desc')
+            ->first();
+    }
+
+    public function supplyOrderForCellularWeightScale() {
+        return SupplyOrder::where('product_id', 2)
+            ->where('is_cancelled', false)
+            ->where('client_id', $this->id)
+            ->orderBy('id', 'desc')
+            ->first();
+    }
+
     public function firstCellularBPDevice()
     {
-        $devices = $this->devices();
+        $devices = $this->devices;
         $x = null;
         foreach($devices as $device){
             if($device->device->category == 'BP'){
                 $x = $device;
-                continue;
+                break;
             }
         }
         return $x;
@@ -371,7 +387,15 @@ class Client extends Model
 
     public function firstCellularWeightDevice()
     {
-
+        $devices = $this->devices;
+        $x = null;
+        foreach($devices as $device){
+            if($device->device->category == 'WEIGHT'){
+                $x = $device;
+                break;
+            }
+        }
+        return $x;
     }
 
     public function getFirstCellularWeightMeasurementAt()
@@ -562,4 +586,35 @@ class Client extends Model
             ->first();
     }
 
+    public function cmReasons()
+    {
+        return $this->hasMany(ClientCmRmReason::class, 'client_id', 'id')
+            ->where('cm_or_rm', 'CM')
+            ->orderBy('position_index', 'ASC')
+            ->orderBy('code', 'ASC');
+    }
+
+    public function rmReasons()
+    {
+        return $this->hasMany(ClientCmRmReason::class, 'client_id', 'id')
+            ->where('cm_or_rm', 'RM')
+            ->orderBy('position_index', 'ASC')
+            ->orderBy('code', 'ASC');
+    }
+
+    public function defaultMcpCompanyPro()
+    {
+        return $this->hasOne(CompanyPro::class, 'id', 'default_mcp_company_pro_id');
+    }
+
+    public function defaultMcpCompanyProPayer()
+    {
+        return $this->hasOne(CompanyProPayer::class, 'id', 'default_mcp_company_pro_payer_id');
+    }
+
+    public function defaultMcpCompanyLocation()
+    {
+        return $this->hasOne(CompanyLocation::class, 'id', 'default_mcp_company_location_id');
+    }
+
 }

+ 10 - 0
app/Models/ClientCmRmReason.php

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

+ 4 - 0
app/Models/ClientProChange.php

@@ -12,4 +12,8 @@ class ClientProChange extends Model
     public function patient(){
         return $this->hasOne(Client::class, 'id', 'client_id');
     }
+
+    public function client(){
+        return $this->hasOne(Client::class, 'id', 'client_id');
+    }
 }

+ 5 - 0
app/Models/CompanyPro.php

@@ -19,4 +19,9 @@ class CompanyPro extends Model
         return $this->hasOne(Pro::class, 'id', 'pro_id');
     }
 
+    public function companyProPayers()
+    {
+        return $this->hasMany(CompanyProPayer::class, 'company_pro_id', 'id');
+    }
+
 }

+ 4 - 0
app/Models/IncomingReport.php

@@ -15,4 +15,8 @@ class IncomingReport extends Model
     public function patient(){
         return $this->hasOne(Client::class, 'id', 'client_id');
     }
+
+    public function client(){
+        return $this->hasOne(Client::class, 'id', 'client_id');
+    }
 }

+ 5 - 0
app/Models/Note.php

@@ -18,6 +18,11 @@ class Note extends Model
         return $this->hasOne(Pro::class, 'id', 'hcp_pro_id');
     }
 
+    public function hcpCompanyPro()
+    {
+        return $this->hasOne(CompanyPro::class, 'id', 'hcp_company_pro_id');
+    }
+
     public function noteTemplate()
     {
         return $this->hasOne(NoteTemplate::class, 'id', 'note_template_id');

+ 10 - 0
app/Models/Pro.php

@@ -516,6 +516,12 @@ class Pro extends Model
         return $measurements;
     }
 
+    public function companyPros()
+    {
+        return $this->hasMany(CompanyPro::class, 'pro_id', 'id')
+            ->where('is_active', true);
+    }
+
     public function companyProPayers()
     {
         return $this->hasMany(CompanyProPayer::class, 'pro_id', 'id');
@@ -566,4 +572,8 @@ class Pro extends Model
         return $this->hasOne(Client::class, 'id', 'shadow_client_id');
     }
 
+    public function defaultCompanyPro() {
+        return $this->hasOne(CompanyPro::class, 'id', 'default_company_pro_id');
+    }
+
 }

+ 8 - 0
app/Models/ProTransaction.php

@@ -15,4 +15,12 @@ class ProTransaction extends Model
     public function bill() {
         return $this->belongsTo(Bill::class);
     }
+
+    public function pro() {
+        return $this->hasOne(Pro::class, 'id', 'pro_id');
+    }
+
+    public function company() {
+        return $this->hasOne(Company::class, 'id', 'company_id');
+    }
 }

+ 4 - 0
app/Models/Ticket.php

@@ -28,6 +28,10 @@ class Ticket extends Model
         return $this->hasOne(Client::class, 'id', 'client_id');
     }
 
+    public function client(){
+        return $this->hasOne(Client::class, 'id', 'client_id');
+    }
+
     public function faxes(){
         return $this->hasMany(TicketFax::class, 'ticket_id', 'id')
             ->orderBy('sent_at', 'desc');

+ 30 - 0
resources/views/app/generic-bills/add-bill-form/Note.blade.php

@@ -1,5 +1,32 @@
 <?php $genericPro = @$note && $note->allyPro ? $note->allyPro : $pro; ?>
 <?php $genericRates = $genericPro->genericRates(); ?>
+<?php $genericCompanyPro = $genericPro->defaultCompanyPro; ?>
+
+{{-- if no defaultCompanyPro on this pro, STOP --}}
+@if(!$genericPro->defaultCompanyPro)
+    <form url="/api/bill/createForGeneric">
+        <div class="border rounded bg-aliceblue p-2 text-nowrap">
+            <div class="mb-2 font-weight-bold">
+                <i class="fa fa-exclamation-triangle text-warning-mellow mr-2"></i>
+                Cannot create bill!
+            </div>
+            Default company pro is not set.
+        </div>
+    </form>
+@else
+    {{-- if no generic rates for this pro, STOP --}}
+    @if(!$genericRates || !count($genericRates))
+        <form url="/api/bill/createForGeneric">
+            <div class="border rounded bg-aliceblue p-2 text-nowrap">
+                <div class="mb-2 font-weight-bold">
+                    <i class="fa fa-exclamation-triangle text-warning-mellow mr-2"></i>
+                    Cannot create bill!
+                </div>
+                No generic rates found for pro.
+            </div>
+        </form>
+    @else
+
 <form url="/api/bill/createForGeneric">
     @if(hasActiveGenericBill($genericPro, @$patient, @$entityType, @$entityUid))
         <div class="border rounded bg-aliceblue p-2 width-200px">
@@ -34,3 +61,6 @@
     @endif
 </form>
 @include('app.generic-bills.add-bill-form._default-script')
+
+    @endif
+@endif

+ 3 - 3
resources/views/app/generic-bills/add-bill-form/_default-fields.blade.php

@@ -1,8 +1,8 @@
 <div class="mb-2 min-width-300px">
-    <label for="" class="text-secondary text-sm">Pro</label>
-    <input type="text" class="form-control form-control-sm" value="{{$genericPro->displayName()}}" readonly>
+    <label for="" class="text-secondary text-sm">Company Pro</label>
+    <div class="p-2 border bg-light rounded">{{$genericCompanyPro->pro->displayName()}} / {{$genericCompanyPro->company->name}}</div>
 </div>
-<input type="hidden" name="genericProUid" value="{{$genericPro->uid}}">
+<input type="hidden" name="genericCompanyProUid" value="{{$genericCompanyPro->uid}}">
 @if(@$note)
     <input type="hidden" name="optionalNoteUid" value="{{$note->uid}}">
 @endif

+ 33 - 5
resources/views/app/generic-bills/add-bill-form/default.blade.php

@@ -1,8 +1,36 @@
 <?php $genericPro = @$note && $note->allyPro ? $note->allyPro : $pro; ?>
 <?php $genericRates = $genericPro->genericRates(); ?>
-<form url="/api/bill/createForGeneric">
-    @include('app.generic-bills.add-bill-form._default-fields')
-    @include('app.generic-bills.add-bill-form._default-actions')
-</form>
-@include('app.generic-bills.add-bill-form._default-script')
+<?php $genericCompanyPro = $genericPro->defaultCompanyPro; ?>
+
+{{-- if no defaultCompanyPro on this pro, STOP --}}
+@if(!$genericCompanyPro)
+    <form url="/api/bill/createForGeneric">
+        <div class="border rounded bg-aliceblue p-2 text-nowrap">
+            <div class="mb-2 font-weight-bold">
+                <i class="fa fa-exclamation-triangle text-warning-mellow mr-2"></i>
+                Cannot create bill!
+            </div>
+            Default company pro is not set.
+        </div>
+    </form>
+@else
+    {{-- if no generic rates for this pro, STOP --}}
+    @if(!$genericRates || !count($genericRates))
+        <form url="/api/bill/createForGeneric">
+            <div class="border rounded bg-aliceblue p-2 text-nowrap">
+                <div class="mb-2 font-weight-bold">
+                    <i class="fa fa-exclamation-triangle text-warning-mellow mr-2"></i>
+                    Cannot create bill!
+                </div>
+                No generic rates found for pro.
+            </div>
+        </form>
+    @else
+        <form url="/api/bill/createForGeneric">
+            @include('app.generic-bills.add-bill-form._default-fields')
+            @include('app.generic-bills.add-bill-form._default-actions')
+        </form>
+        @include('app.generic-bills.add-bill-form._default-script')
+    @endif
+@endif
 

+ 21 - 24
resources/views/app/patient/care-month/_create-claim.blade.php

@@ -1,5 +1,9 @@
-<span class="mx-2 text-secondary">|</span>
-<a href="#" onclick="return showStagPopup('create-claim')">Create Claim</a>
+@if($careMonth->is_claim_closed)
+    <b class="ml-2 text-info">[CLAIMING CLOSED]</b>
+@else
+    <span class="mx-2 text-secondary">|</span>
+    <a href="#" onclick="return showStagPopup('create-claim')">Create Claim</a>
+@endif
 @if($pro->pro_type === 'ADMIN')
     @if(!$careMonth->is_claim_closed)
         <span class="mx-2 text-secondary">|</span>
@@ -43,7 +47,7 @@
         </span>
     @endif
 @endif
-<div class="stag-popup stag-popup-md mcp-theme-1" stag-popup-key="create-claim">
+<div class="stag-popup stag-popup-md mcp-theme-1" style="width:100%" stag-popup-key="create-claim">
     <form action="/api/claim/createForCareMonth" id="createCareMonthClaimApp">
         <h3 class="stag-popup-title border-bottom-0 mb-0">
             <span>Create Claim</span>
@@ -56,8 +60,9 @@
         <table class="table table-sm table-condensed mb-3 border-left border-right border-bottom">
             <thead>
             <tr class="bg-light">
-                <th class="width-100px border-bottom-0">CPT Code</th>
-                <th class="width-100px border-bottom-0">Date of Service</th>
+                <th style="min-width: 100px;" class="border-bottom-0">CPT Code</th>
+                <th style="min-width: 100px;" class="border-bottom-0">DOS</th>
+                <th class="border-bottom-0">Units</th>
                 <th class="border-bottom-0">ICDs</th>
                 <th class="border-bottom-0">&nbsp;</th>
             </tr>
@@ -70,6 +75,9 @@
                 <td class="py-2">
                     <input required type="date" class="min-width-unset form-control form-control-sm" v-model="line.dateOfService">
                 </td>
+                <td class="py-2">
+                    <input required type="number" class="min-width-unset form-control form-control-sm" v-model="line.numberOfUnits">
+                </td>
                 <td class="p-2 bg-light">
                     <div class="d-flex align-items-baseline">
                         <a href="#" class="text-nowrap text-primary mr-2"
@@ -113,6 +121,7 @@
     </form>
 </div>
 <script>
+    window.rmReasons = [];
     window.createCareMonthClaimApp = new Vue({
         el: '#createCareMonthClaimApp',
         delimiters: ['@{{', '}}'],
@@ -122,12 +131,8 @@
                     {
                         cpt: '',
                         dateOfService: '{{date_format($careMonth->created_at, 'Y-m-d')}}',
-                        icds: window.rmReasons.map(_x => {
-                            return {
-                                code: _x.icd,
-                                description: _x.description
-                            };
-                        })
+                        icds: JSON.parse(JSON.stringify(window.rmReasons)),
+                        numberOfUnits: 1
                     }
                 ]
             }
@@ -137,12 +142,8 @@
                 this.payload.lines.push({
                     cpt: '',
                     dateOfService: '{{date('Y-m-d')}}',
-                    icds: window.rmReasons.map(_x => {
-                        return {
-                            code: _x.icd,
-                            description: _x.description
-                        };
-                    })
+                    icds: JSON.parse(JSON.stringify(window.rmReasons)),
+                    numberOfUnits: 1
                 });
                 Vue.nextTick(() => {
                     this.initICDAutoSuggest();
@@ -222,12 +223,8 @@
                 this.payload.lines = [{
                     cpt: '',
                     dateOfService: '{{date('Y-m-d')}}',
-                    icds: window.rmReasons.map(_x => {
-                        return {
-                            code: _x.icd,
-                            description: _x.description
-                        };
-                    })
+                    icds: JSON.parse(JSON.stringify(window.rmReasons)),
+                    numberOfUnits: 1
                 }];
             }
         },
@@ -235,5 +232,5 @@
             this.initICDAutoSuggest();
             this.getPrefillValues();
         }
-    })
+    });
 </script>

+ 0 - 144
resources/views/app/patient/care-month/_create-rm-reason.blade.php

@@ -1,144 +0,0 @@
-<script>
-    window.rmReasons = [];
-    <?php
-    $rmReasons = [];
-    if($careMonth->rm_reasons) {
-        $rmReasons = json_decode($careMonth->rm_reasons);
-    }
-    ?>
-    @if(count($rmReasons))
-        @foreach($rmReasons as $reason)
-        window.rmReasons.push({
-            icd: '{{$reason->icd}}',
-            description: '{{$reason->description}}'
-        });
-        @endforeach
-    @endif
-</script>
-<div moe wide class="" id="careMonth_rmReasonsComponent">
-    <a class="" href="" show start><i class="fa fa-edit"></i></a>
-    <form url="/api/careMonth/updateRmReasons">
-        <input type="hidden" name="uid" value="{{$careMonth->uid}}">
-        <table class="table table-sm table-condensed table-borderless my-0" id="rm-reasons-table">
-            <thead>
-                <tr>
-                    <th class="pl-0">Code</th>
-                    <th>Description</th>
-                    <th></th>
-                </tr>
-            </thead>
-            <tbody>
-                @if(count($rmReasons))
-                    @foreach($rmReasons as $reason)
-                    <tr class="data-row">
-                        <td class="pl-0"><input type="text" class="form-control rm-reason-icd" data-index="{{$loop->index}}" id="rm_icd_{{$loop->index}}" value="{{$reason->icd}}"></td>
-                        <td class=""><input type="text" class="form-control rm-reason-description" data-index="{{$loop->index}}" id="rm_description_{{$loop->index}}" value="{{$reason->description}}"></td>
-                        <td class="pr-0 align-middle"><a href="#" class="btn-remove-row text-danger"><i class="fa fa-trash-alt"></i></a></td>
-                    </tr>
-                    @endforeach
-                @else
-                <tr class="data-row">
-                    <td class="pl-0"><input type="text" class="form-control rm-reason-icd"  data-index="0" id="rm_icd_0" name="rmReasonDTOs[0].code"></td>
-                    <td class=""><input type="text" class="form-control rm-reason-description" data-index="0" id="rm_description_0" name="rmReasonDTOs[0].description"></td>
-                    <td class="pr-0 align-middle"><a href="#" class="btn-remove-row text-danger"><i class="fa fa-trash-alt"></i></a></td>
-                </tr>
-                <tr class="data-row">
-                    <td class="pl-0"><input type="text" class="form-control rm-reason-icd" data-index="1" id="rm_icd_1" name="rmReasonDTOs[1].code"></td>
-                    <td class=""><input type="text" class="form-control rm-reason-description" data-index="1" id="rm_description_1" name="rmReasonDTOs[1].description"></td>
-                    <td class="pr-0 align-middle"><a href="#" class="btn-remove-row text-danger"><i class="fa fa-trash-alt"></i></a></td>
-                </tr>
-                <tr class="data-row">
-                    <td class="pl-0"><input type="text" class="form-control rm-reason-icd" data-index="2" id="rm_icd_2" name="rmReasonDTOs[2].code"></td>
-                    <td class=""><input type="text" class="form-control rm-reason-description" data-index="2" id="rm_description_2" name="rmReasonDTOs[2].description"></td>
-                    <td class="pr-0 align-middle"><a href="#" class="btn-remove-row text-danger"><i class="fa fa-trash-alt"></i></a></td>
-                </tr>
-                @endif
-            </tbody>
-        </table>
-        <div class="form-group my-2">
-            <button class="btn btn-outline-primary btn-sm btn-add-row">Add row</button>
-        </div>
-        <div class="form-group mb-0">
-            <button class="btn btn-primary btn-sm" id="btnUpdateRmReasons" type="button">Submit</button>
-            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
-        </div>
-    </form>
-</div>
-<script>
-    (function() {
-
-        function init() {
-            $("#careMonth_rmReasonsComponent .btn-add-row").click(function() {
-                var rowCount = $('#rm-reasons-table').find('tr').length;
-                var nextIndex = rowCount -1;
-                var clone = $('#rm-reasons-table tr.data-row:first').clone();
-                clone.find('input').attr('data-index', nextIndex);
-                clone.find('input.rm-reason-icd').attr('name','rmReasonDTOs['+nextIndex+'].code').val('');
-                clone.find('input.rm-reason-icd').attr('id','rm_icd_'+nextIndex);
-                clone.find('input.rm-reason-description').attr('name','rmReasonDTOs['+nextIndex+'].description').val('');
-                clone.find('input.rm-reason-description').attr('id','rm_description_'+nextIndex);
-                $('#rm-reasons-table').append(clone);
-                attachAutocompleterToField(nextIndex);
-                return false;
-            });
-
-            $('#rm-reasons-table').on('click', '.btn-remove-row', function() {
-                $(this).closest('tr').remove();
-                return false;
-            });
-
-            $('#rm-reasons-table .rm-reason-icd').each(function(i,e) {
-                var fieldIndex = $(e).attr('data-index');
-                attachAutocompleterToField(fieldIndex);
-            });
-
-            $("#careMonth_rmReasonsComponent #btnUpdateRmReasons").click(function() {
-                let rmReasons = [];
-                $('tr.data-row').each(function() {
-                    let icd = $.trim($(this).find('input.rm-reason-icd').val());
-                    if(icd) {
-                        rmReasons.push({
-                            icd: icd,
-                            description: $.trim($(this).find('input.rm-reason-description').val())
-                        });
-                    }
-                });
-                if(!rmReasons.length) return false;
-                showMask();
-                rmReasons = JSON.stringify(rmReasons);
-                $.post('/api/careMonth/updateRmReasons', {
-                    uid: '{{$careMonth->uid}}',
-                    rmReasons: rmReasons
-                }, (_data) => {
-                    hideMask();
-                    if(_data && _data.success) {
-                        fastReload();
-                    }
-                    else {
-                        toastr.error(_data.message ? _data.message : 'Unable to update RM reasons!');
-                    }
-                }, 'json');
-                return false;
-            });
-
-            function attachAutocompleterToField(fieldIndex){
-                var e = $('#rm_icd_'+fieldIndex)[0];
-                new Def.Autocompleter.Search('rm_icd_'+fieldIndex, 'https://clinicaltables.nlm.nih.gov/api/icd10cm/v3/search?sf=code,name', {
-                    tableFormat: true,
-                    valueCols: [1],
-                    colHeaders: ['Code', 'Name']
-                });
-                Def.Autocompleter.Event.observeListSelections('rm_icd_'+fieldIndex, function(data) {
-                    console.log("Setting value of e to : ", data.item_code);
-                    $('#rm_icd_'+fieldIndex).val(data.item_code);
-                    $('#rm_description_'+fieldIndex).val(data.final_val);
-                    $('#rm_icd_'+fieldIndex).focus();
-                    return false;
-                });
-            }
-        }
-
-        addMCInitializer('careMonth_rmReasonsComponent', init, '#careMonth_rmReasonsComponent');
-
-    })();
-</script>

+ 114 - 73
resources/views/app/patient/care-month/dashboard.blade.php

@@ -521,93 +521,134 @@
 
         <hr class="m-negator mt-0 mb-3">
 
+        <hr class="m-negator mt-0 mb-3">
+
         @if($pro->pro_type === 'ADMIN')
-            <div class="pb-3">
-                <div class="ml-auto d-inline-flex align-items-center">
-
-                    <span class="text-secondary font-weight-bold">Pro:&nbsp;</span>
-                    <b>{{$careMonth->mcp ? $careMonth->mcp->displayName() : '-'}}</b>
-
-                    <span class="mx-3 text-secondary">|</span>
-                    <span>
-                        <span class="text-secondary font-weight-bold">Payer (1°): </span>
-                        <b>{{$careMonth->companyProPayer && $careMonth->companyProPayer->payer ? $careMonth->companyProPayer->payer->name : '-'}}</b>
-                        <span moe class="ml-1">
-                            <a class="text-primary" href="" show start><i class="fa fa-edit"></i></a>
-                            <form url="/api/careMonth/putCompanyProPayer">
-                                <input type="hidden" name="uid" value="{{$careMonth->uid}}">
-                                <div class="mb-2">
-                                    <select name="companyProPayerUid" class="form-control form-control-sm">
-                                        <option value="">-- select --</option>
-                                        @foreach($careMonth->mcp->companyProPayers as $companyProPayer)
-                                            <option value="{{$companyProPayer->uid}}">{{$companyProPayer->company->name}} / {{$companyProPayer->payer->name}}</option>
-                                        @endforeach
-                                    </select>
-                                </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>
-                        @if($careMonth->companyProPayer && $careMonth->companyProPayer->payer)
-                            <span moe class="ml-1">
+            <div class="pb-3 screen-only">
+                <div class="ml-auto d-flex align-items-center">
+
+                    <div class="d-inline-flex align-items-center">
+                        <span class="text-secondary font-weight-bold">Company Pro:&nbsp;</span>
+                        <b>{{$careMonth->companyPro && $careMonth->companyPro->company ? $careMonth->companyPro->pro->displayName() . ' / ' . $careMonth->companyPro->company->name : '-'}}</b>
+                        @if($careMonth->companyPro && $careMonth->companyPro->company)
+                            <div moe class="ml-1">
                                 <a class="text-danger" href="" show start><i class="fa fa-trash-alt"></i></a>
-                                <form url="/api/careMonth/wipeCompanyProPayer">
+                                <form url="/api/careMonth/wipeCompanyPro">
                                     <input type="hidden" name="uid" value="{{$careMonth->uid}}">
-                                    <p>Wipe payer from this care month?</p>
+                                    <p>Wipe company pro from this care month?</p>
                                     <div class="mb-0">
                                         <button class="btn btn-primary btn-sm" submit>Submit</button>
                                         <button class="btn btn-default border btn-sm" cancel>Cancel</button>
                                     </div>
                                 </form>
-                            </span>
-                        @endif
-                    </span>
-
-                    <span class="mx-3 text-secondary">|</span>
-                    <span>
-                        <span class="text-secondary font-weight-bold">Payer (2°): </span>
-                        <b>-</b>
-                    </span>
-
-                    <span class="mx-3 text-secondary">|</span>
-                    <span>
-                        <span class="text-secondary font-weight-bold">Location: </span><b>{{$careMonth->companyLocation ? $careMonth->companyLocation->line1 . ', ' . $careMonth->companyLocation->city : '-'}}</b>
-                        <span moe class="ml-1">
-                            <a class="text-primary" href="" show start><i class="fa fa-edit"></i></a>
-                            <form url="/api/careMonth/putCompanyLocation">
-                                <input type="hidden" name="uid" value="{{$careMonth->uid}}">
-                                <div class="mb-2">
-                                    <select name="companyLocationUid" class="form-control form-control-sm">
-                                        <option value="">-- select --</option>
-                                        @if($careMonth->company && $careMonth->company->locations)
-                                            @foreach($careMonth->company->locations as $location)
-                                                <option value="{{$location->uid}}">{{$location->line1 . ', ' . $location->city}}</option>
-                                            @endforeach
-                                        @endif
-                                    </select>
-                                </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>
-                        @if($careMonth->companyLocation)
-                            <span moe class="ml-1">
-                                <a class="text-danger" href="" show start><i class="fa fa-trash-alt"></i></a>
-                                <form url="/api/careMonth/wipeCompanyLocation">
+                            </div>
+                        @else
+                            <div moe class="ml-1">
+                                <a class="text-primary" href="" show start><i class="fa fa-edit"></i></a>
+                                <form url="/api/careMonth/putCompanyPro">
                                     <input type="hidden" name="uid" value="{{$careMonth->uid}}">
-                                    <p>Wipe location from this care month?</p>
+                                    <div class="mb-2">
+                                        <select name="companyProUid" class="form-control form-control-sm">
+                                            <option value="">-- select --</option>
+                                            @foreach($careMonth->mcp->companyPros as $companyPro)
+                                                <option value="{{$companyPro->uid}}">{{$companyPro->pro->displayName() . ' / ' . $companyPro->company->name}}</option>
+                                            @endforeach
+                                        </select>
+                                    </div>
                                     <div class="mb-0">
-                                        <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                        <button class="btn btn-success btn-sm" submit>Submit</button>
                                         <button class="btn btn-default border btn-sm" cancel>Cancel</button>
                                     </div>
                                 </form>
-                            </span>
+                            </div>
                         @endif
-                    </span>
+                    </div>
+
+                    @if($careMonth->companyPro && $careMonth->companyPro->company)
+                        <span class="mx-2 text-secondary">|</span>
+                        <div class="d-inline-flex align-items-center">
+                            <span class="text-secondary font-weight-bold">Payer 1°:&nbsp;</span>
+                            <b>
+                                {{$careMonth->companyProPayer && $careMonth->companyProPayer->payer ? $careMonth->companyProPayer->payer->name : '-'}}
+                            </b>
+                            @if($careMonth->companyProPayer && $careMonth->companyProPayer->payer)
+                                <div moe class="ml-1">
+                                    <a class="text-danger" href="" show start><i class="fa fa-trash-alt"></i></a>
+                                    <form url="/api/careMonth/wipeCompanyProPayer">
+                                        <input type="hidden" name="uid" value="{{$careMonth->uid}}">
+                                        <p>Wipe payer from this note?</p>
+                                        <div class="mb-0">
+                                            <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                        </div>
+                                    </form>
+                                </div>
+                            @else
+                                <div moe class="ml-1">
+                                    <a class="text-primary" href="" show start><i class="fa fa-edit"></i></a>
+                                    <form url="/api/careMonth/putCompanyProPayer">
+                                        <input type="hidden" name="uid" value="{{$careMonth->uid}}">
+                                        <div class="mb-2">
+                                            <select name="companyProPayerUid" class="form-control form-control-sm">
+                                                <option value="">-- select --</option>
+                                                @foreach($careMonth->companyPro->companyProPayers as $companyProPayer)
+                                                    <option value="{{$companyProPayer->uid}}">{{$companyProPayer->payer->name}}</option>
+                                                @endforeach
+                                            </select>
+                                        </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>
+                                </div>
+                            @endif
+                        </div>
+
+                        <span class="mx-2 text-secondary">|</span>
+                        <span>
+                                <span class="text-secondary font-weight-bold">Payer 2°: </span>
+                            </span>
+
+                        <span class="mx-2 text-secondary">|</span>
+                        <div class="d-inline-flex align-items-center">
+                            <span class="text-secondary font-weight-bold">Location:&nbsp;</span><b>{{$careMonth->companyLocation ? $careMonth->companyLocation->line1 . ', ' . $careMonth->companyLocation->city : '-'}}</b>
+                            @if($careMonth->companyLocation)
+                                <div moe class="ml-1">
+                                    <a class="text-danger" href="" show start><i class="fa fa-trash-alt"></i></a>
+                                    <form url="/api/careMonth/wipeCompanyLocation">
+                                        <input type="hidden" name="uid" value="{{$careMonth->uid}}">
+                                        <p>Wipe location from this note?</p>
+                                        <div class="mb-0">
+                                            <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                        </div>
+                                    </form>
+                                </div>
+                            @else
+                                <div moe class="ml-1">
+                                    <a class="text-primary" href="" show start><i class="fa fa-edit"></i></a>
+                                    <form url="/api/careMonth/putCompanyLocation">
+                                        <input type="hidden" name="uid" value="{{$careMonth->uid}}">
+                                        <div class="mb-2">
+                                            <select name="companyLocationUid" class="form-control form-control-sm">
+                                                <option value="">-- select --</option>
+                                                @if($careMonth->company && $careMonth->company->locations)
+                                                    @foreach($careMonth->company->locations as $location)
+                                                        <option value="{{$location->uid}}">{{$location->line1 . ', ' . $location->city}}</option>
+                                                    @endforeach
+                                                @endif
+                                            </select>
+                                        </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>
+                                </div>
+                            @endif
+                        </div>
+                    @endif
                 </div>
             </div>
         @endif

+ 54 - 17
resources/views/app/patient/care-month/rm-reasons.blade.php

@@ -1,25 +1,62 @@
 <div class="">
     <div class="">
-        <div class="d-flex align-items-center mb-2">
+        <div class="d-flex align-items-center mb-2 border-bottom pb-2">
             <p class="font-weight-bold text-secondary m-0 mr-2">RM Reasons</p>
-            @include('app/patient/care-month/_create-rm-reason')
         </div>
-        <div class="d-flex align-items-start flex-wrap">
-            <?php
-            $rmReasons = [];
-            if($careMonth->rm_reasons) {
-                $rmReasons = json_decode($careMonth->rm_reasons);
-            }
-            ?>
-            @if(count($rmReasons))
-                @foreach ($rmReasons as $reason)
-                    <span class="badge badge-info p-2 mb-2 mr-2">
-                        {{ $reason->description}} ({{ $reason->icd }})
-                    </span>
+        @if(!$careMonth->rmReasons || !count($careMonth->rmReasons))
+            <span class="text-secondary">None</span>
+        @else
+            <div>
+                @foreach($careMonth->rmReasons as $reason)
+                    <div class="border-bottom pb-1 mb-1 d-flex align-items-start">
+                        <b class="width-90px">{{$reason->code}}</b>
+                        <span class="width-200px">{{$reason->description}}</span>
+                        <div moe>
+                            <a start show>Edit</a>
+                            <form url="/api/careMonthCmRmReason/updateBasic" class="mcp-theme-1">
+                                <input type="hidden" name="uid" value="{{$reason->uid}}">
+                                <div class="mb-2">
+                                    <label class="text-sm mb-1 text-secondary">Code *</label>
+                                    <input type="text" class="form-control form-control-sm"
+                                           name="code" value="{{$reason->code}}" required>
+                                </div>
+                                <div class="mb-2">
+                                    <label class="text-sm mb-1 text-secondary">Description</label>
+                                    <input type="text" class="form-control form-control-sm"
+                                           name="description" value="{{$reason->description}}">
+                                </div>
+                                <div>
+                                    <button submit class="btn btn-sm btn-primary mr-1">Submit</button>
+                                    <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                                </div>
+                            </form>
+                        </div>
+                    </div>
                 @endforeach
-            @else
-                <div class="alert alert-info">No RM reasons</div>
-            @endif
+            </div>
+        @endif
+        <div>
+            <div moe>
+                <a start show>+ Add</a>
+                <form url="/api/careMonthCmRmReason/create" class="mcp-theme-1">
+                    <input type="hidden" name="careMonthUid" value="{{$careMonth->uid}}">
+                    <input type="hidden" name="cmOrRm" value="RM">
+                    <div class="mb-2">
+                        <label class="text-sm mb-1 text-secondary">Code *</label>
+                        <input type="text" class="form-control form-control-sm"
+                               name="code" value="" required>
+                    </div>
+                    <div class="mb-2">
+                        <label class="text-sm mb-1 text-secondary">Description</label>
+                        <input type="text" class="form-control form-control-sm"
+                               name="description" value="">
+                    </div>
+                    <div>
+                        <button submit class="btn btn-sm btn-primary mr-1">Submit</button>
+                        <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                    </div>
+                </form>
+            </div>
         </div>
     </div>
 </div>

+ 117 - 80
resources/views/app/patient/note/dashboard.blade.php

@@ -1005,96 +1005,133 @@
                 </div>
                 @endif
 
+                {{-- companyPro, payer and location --}}
                 @if($note->method === 'IN_CLINIC' || $pro->pro_type === 'ADMIN')
                 <div class="p-3 border-bottom screen-only">
-                    <div class="ml-auto d-inline-flex align-items-center">
+                    <div class="ml-auto d-flex align-items-center">
 
-                        <span class="text-secondary font-weight-bold">Pro:&nbsp;</span>
-                        <b>{{$note->hcpPro ? $note->hcpPro->displayName() : '-'}}</b>
+                        <div class="d-inline-flex align-items-center">
+                            <span class="text-secondary font-weight-bold">Company Pro:&nbsp;</span>
+                            <b>{{$note->hcpCompanyPro && $note->hcpCompanyPro->company ? $note->hcpCompanyPro->pro->displayName() . ' / ' . $note->hcpCompanyPro->company->name : '-'}}</b>
+                            @if($note->hcpCompanyPro && $note->hcpCompanyPro->company)
+                                <div moe class="ml-1">
+                                    <a class="text-danger" href="" show start><i class="fa fa-trash-alt"></i></a>
+                                    <form url="/api/note/wipeHcpCompanyPro">
+                                        <input type="hidden" name="uid" value="{{$note->uid}}">
+                                        <p>Wipe company pro from this note?</p>
+                                        <div class="mb-0">
+                                            <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                        </div>
+                                    </form>
+                                </div>
+                            @else
+                                <div moe class="ml-1">
+                                    <a class="text-primary" href="" show start><i class="fa fa-edit"></i></a>
+                                    <form url="/api/note/putHcpCompanyPro">
+                                        <input type="hidden" name="uid" value="{{$note->uid}}">
+                                        <div class="mb-2">
+                                            <select name="hcpCompanyProUid" class="form-control form-control-sm">
+                                                <option value="">-- select --</option>
+                                                @foreach($note->hcpPro->companyPros as $companyPro)
+                                                    <option value="{{$companyPro->uid}}">{{$companyPro->pro->displayName() . ' / ' . $companyPro->company->name}}</option>
+                                                @endforeach
+                                            </select>
+                                        </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>
+                                </div>
+                            @endif
+                        </div>
 
-                        <span class="mx-2 text-secondary">|</span>
-                        <span>
-                            <span class="text-secondary font-weight-bold">Payer 1°: </span>
-                            <b>
-                                {{$note->hcpCompanyProPayer && $note->hcpCompanyProPayer->company ? $note->hcpCompanyProPayer->company->name : '-'}}
-                                /
-                                {{$note->hcpCompanyProPayer && $note->hcpCompanyProPayer->payer ? $note->hcpCompanyProPayer->payer->name : '-'}}
-                            </b>
-                            <span moe class="ml-1">
-                                <a class="text-primary" href="" show start><i class="fa fa-edit"></i></a>
-                                <form url="/api/note/putHcpCompanyProPayer">
-                                    <input type="hidden" name="uid" value="{{$note->uid}}">
-                                    <div class="mb-2">
-                                        <select name="hcpCompanyProPayerUid" class="form-control form-control-sm">
-                                            <option value="">-- select --</option>
-                                            @foreach($note->hcpPro->companyProPayers as $companyProPayer)
-                                                <option value="{{$companyProPayer->uid}}">{{$companyProPayer->company->name}} / {{$companyProPayer->payer->name}}</option>
-                                            @endforeach
-                                        </select>
-                                    </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>
+                        @if($note->hcpCompanyPro && $note->hcpCompanyPro->company)
+                            <span class="mx-2 text-secondary">|</span>
+                            <div class="d-inline-flex align-items-center">
+                                <span class="text-secondary font-weight-bold">Payer 1°:&nbsp;</span>
+                                <b>
+                                    {{$note->hcpCompanyProPayer && $note->hcpCompanyProPayer->payer ? $note->hcpCompanyProPayer->payer->name : '-'}}
+                                </b>
+                                @if($note->hcpCompanyProPayer && $note->hcpCompanyProPayer->payer)
+                                    <div moe class="ml-1">
+                                        <a class="text-danger" href="" show start><i class="fa fa-trash-alt"></i></a>
+                                        <form url="/api/note/wipeHcpCompanyProPayer">
+                                            <input type="hidden" name="uid" value="{{$note->uid}}">
+                                            <p>Wipe payer from this note?</p>
+                                            <div class="mb-0">
+                                                <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                                <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                            </div>
+                                        </form>
                                     </div>
-                                </form>
-                            </span>
-                            @if($note->hcpCompanyProPayer && $note->hcpCompanyProPayer->payer)
-                            <span moe class="ml-1">
-                                <a class="text-danger" href="" show start><i class="fa fa-trash-alt"></i></a>
-                                <form url="/api/note/wipeHcpCompanyProPayer">
-                                    <input type="hidden" name="uid" value="{{$note->uid}}">
-                                    <p>Wipe payer from this note?</p>
-                                    <div class="mb-0">
-                                        <button class="btn btn-primary btn-sm" submit>Submit</button>
-                                        <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                @else
+                                    <div moe class="ml-1">
+                                        <a class="text-primary" href="" show start><i class="fa fa-edit"></i></a>
+                                        <form url="/api/note/putHcpCompanyProPayer">
+                                            <input type="hidden" name="uid" value="{{$note->uid}}">
+                                            <div class="mb-2">
+                                                <select name="hcpCompanyProPayerUid" class="form-control form-control-sm">
+                                                    <option value="">-- select --</option>
+                                                    @foreach($note->hcpCompanyPro->companyProPayers as $companyProPayer)
+                                                        <option value="{{$companyProPayer->uid}}">{{$companyProPayer->payer->name}}</option>
+                                                    @endforeach
+                                                </select>
+                                            </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>
                                     </div>
-                                </form>
-                            </span>
-                            @endif
-                        </span>
+                                @endif
+                            </div>
 
-                        <span class="mx-2 text-secondary">|</span>
-                        <span>
-                            <span class="text-secondary font-weight-bold">Payer 2°: </span>
-                        </span>
+                            <span class="mx-2 text-secondary">|</span>
+                            <span>
+                                <span class="text-secondary font-weight-bold">Payer 2°: </span>
+                            </span>
 
-                        <span class="mx-2 text-secondary">|</span>
-                        <span>
-                            <span class="text-secondary font-weight-bold">Location: </span><b>{{$note->hcpCompanyLocation ? $note->hcpCompanyLocation->line1 . ', ' . $note->hcpCompanyLocation->city : '-'}}</b>
-                            <span moe class="ml-1">
-                                <a class="text-primary" href="" show start><i class="fa fa-edit"></i></a>
-                                <form url="/api/note/putHcpCompanyLocation">
-                                    <input type="hidden" name="uid" value="{{$note->uid}}">
-                                    <div class="mb-2">
-                                        <select name="hcpCompanyLocationUid" class="form-control form-control-sm">
-                                            <option value="">-- select --</option>
-                                            @if($note->hcpCompany && $note->hcpCompany->locations)
-                                                @foreach($note->hcpCompany->locations as $location)
-                                                    <option value="{{$location->uid}}">{{$location->line1 . ', ' . $location->city}}</option>
-                                                @endforeach
-                                            @endif
-                                        </select>
-                                    </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>
+                            <span class="mx-2 text-secondary">|</span>
+                            <div class="d-inline-flex align-items-center">
+                                <span class="text-secondary font-weight-bold">Location:&nbsp;</span><b>{{$note->hcpCompanyLocation ? $note->hcpCompanyLocation->line1 . ', ' . $note->hcpCompanyLocation->city : '-'}}</b>
+                                @if($note->hcpCompanyLocation)
+                                    <div moe class="ml-1">
+                                        <a class="text-danger" href="" show start><i class="fa fa-trash-alt"></i></a>
+                                        <form url="/api/note/wipeHcpCompanyLocation">
+                                            <input type="hidden" name="uid" value="{{$note->uid}}">
+                                            <p>Wipe location from this note?</p>
+                                            <div class="mb-0">
+                                                <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                                <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                            </div>
+                                        </form>
                                     </div>
-                                </form>
-                            </span>
-                            @if($note->hcpCompanyLocation)
-                            <span moe class="ml-1">
-                                <a class="text-danger" href="" show start><i class="fa fa-trash-alt"></i></a>
-                                <form url="/api/note/wipeHcpCompanyLocation">
-                                    <input type="hidden" name="uid" value="{{$note->uid}}">
-                                    <p>Wipe location from this note?</p>
-                                    <div class="mb-0">
-                                        <button class="btn btn-primary btn-sm" submit>Submit</button>
-                                        <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                @else
+                                    <div moe class="ml-1">
+                                        <a class="text-primary" href="" show start><i class="fa fa-edit"></i></a>
+                                        <form url="/api/note/putHcpCompanyLocation">
+                                            <input type="hidden" name="uid" value="{{$note->uid}}">
+                                            <div class="mb-2">
+                                                <select name="hcpCompanyLocationUid" class="form-control form-control-sm">
+                                                    <option value="">-- select --</option>
+                                                    @if($note->hcpCompany && $note->hcpCompany->locations)
+                                                        @foreach($note->hcpCompany->locations as $location)
+                                                            <option value="{{$location->uid}}">{{$location->line1 . ', ' . $location->city}}</option>
+                                                        @endforeach
+                                                    @endif
+                                                </select>
+                                            </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>
                                     </div>
-                                </form>
-                            </span>
-                            @endif
-                        </span>
+                                @endif
+                            </div>
+                        @endif
                     </div>
                 </div>
                 @endif

+ 5 - 5
resources/views/app/patient/notes.blade.php

@@ -11,11 +11,11 @@
                 <form url="/api/note/create" class="mcp-theme-1"
                       redir="patients/view/{{ $patient->uid }}/notes/view/[data]">
                     <input type="hidden" name="clientUid" value="{{$patient->uid}}">
-                    @if($pro->is_hcp)
-                    <input type="hidden" name="hcpProUid" value="{{$pro->uid}}">
-                    @else
-                    <input type="hidden" name="naProUid" value="{{$pro->uid}}">
-                    @endif
+                    <div class="form-group">
+                        <label for="" class="text-secondary text-sm mb-1">Pro *</label>
+                        <select name="hcpProUid" class="form-control" provider-search required data-pro-uid="{{$pro->is_hcp ? $pro->uid : ''}}">
+                        </select>
+                    </div>
                     <input type="hidden" name="effectiveDateEST" value="{{ date('Y-m-d') }}">
                     <div class="form-group">
                         <label for="" class="text-secondary text-sm mb-1">Type *</label>

+ 0 - 135
resources/views/app/patient/partials/_create-rm-reason.blade.php

@@ -1,135 +0,0 @@
-<script>
-    <?php
-    $rmReasons = [];
-    if($patient->rm_reasons) {
-        $rmReasons = json_decode($patient->rm_reasons);
-    }
-    ?>
-</script>
-<div moe wide class="" id="rmReasonsComponent">
-    <a class="" href="" show start><i class="fa fa-edit"></i></a>
-    <form url="/api/client/updateRmReasons">
-        <input type="hidden" name="uid" value="{{$patient->uid}}">
-        <table class="table table-sm table-condensed table-borderless my-0" id="rm-reasons-table">
-            <thead>
-                <tr>
-                    <th class="pl-0">Code</th>
-                    <th>Description</th>
-                    <th></th>
-                </tr>
-            </thead>
-            <tbody>
-                @if(count($rmReasons))
-                    @foreach($rmReasons as $reason)
-                    <tr class="data-row">
-                        <td class="pl-0"><input type="text" class="form-control rm-reason-icd" data-index="{{$loop->index}}" id="rm_icd_{{$loop->index}}" value="{{$reason->icd}}"></td>
-                        <td class=""><input type="text" class="form-control rm-reason-description" data-index="{{$loop->index}}" id="rm_description_{{$loop->index}}" value="{{$reason->description}}"></td>
-                        <td class="pr-0 align-middle"><a href="#" class="btn-remove-row text-danger"><i class="fa fa-trash-alt"></i></a></td>
-                    </tr>
-                    @endforeach
-                @else
-                <tr class="data-row">
-                    <td class="pl-0"><input type="text" class="form-control rm-reason-icd"  data-index="0" id="rm_icd_0" name="rmReasonDTOs[0].code"></td>
-                    <td class=""><input type="text" class="form-control rm-reason-description" data-index="0" id="rm_description_0" name="rmReasonDTOs[0].description"></td>
-                    <td class="pr-0 align-middle"><a href="#" class="btn-remove-row text-danger"><i class="fa fa-trash-alt"></i></a></td>
-                </tr>
-                <tr class="data-row">
-                    <td class="pl-0"><input type="text" class="form-control rm-reason-icd" data-index="1" id="rm_icd_1" name="rmReasonDTOs[1].code"></td>
-                    <td class=""><input type="text" class="form-control rm-reason-description" data-index="1" id="rm_description_1" name="rmReasonDTOs[1].description"></td>
-                    <td class="pr-0 align-middle"><a href="#" class="btn-remove-row text-danger"><i class="fa fa-trash-alt"></i></a></td>
-                </tr>
-                <tr class="data-row">
-                    <td class="pl-0"><input type="text" class="form-control rm-reason-icd" data-index="2" id="rm_icd_2" name="rmReasonDTOs[2].code"></td>
-                    <td class=""><input type="text" class="form-control rm-reason-description" data-index="2" id="rm_description_2" name="rmReasonDTOs[2].description"></td>
-                    <td class="pr-0 align-middle"><a href="#" class="btn-remove-row text-danger"><i class="fa fa-trash-alt"></i></a></td>
-                </tr>
-                @endif
-            </tbody>
-        </table>
-        <div class="form-group my-2">
-            <button class="btn btn-outline-primary btn-sm btn-add-row">Add row</button>
-        </div>
-        <div class="form-group mb-0">
-            <button class="btn btn-primary btn-sm" id="btnUpdateRmReasons" type="button">Submit</button>
-            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
-        </div>
-    </form>
-</div>
-<script>
-    (function() {
-
-        function init() {
-            $("#rmReasonsComponent .btn-add-row").click(function() {
-                var rowCount = $('#rm-reasons-table').find('tr').length;
-                var nextIndex = rowCount -1;
-                var clone = $('#rm-reasons-table tr.data-row:first').clone();
-                clone.find('input').attr('data-index', nextIndex);
-                clone.find('input.rm-reason-icd').attr('name','rmReasonDTOs['+nextIndex+'].code').val('');
-                clone.find('input.rm-reason-icd').attr('id','rm_icd_'+nextIndex);
-                clone.find('input.rm-reason-description').attr('name','rmReasonDTOs['+nextIndex+'].description').val('');
-                clone.find('input.rm-reason-description').attr('id','rm_description_'+nextIndex);
-                $('#rm-reasons-table').append(clone);
-                attachAutocompleterToField(nextIndex);
-                return false;
-            });
-
-            $('#rm-reasons-table').on('click', '.btn-remove-row', function() {
-                $(this).closest('tr').remove();
-                return false;
-            });
-
-            $('#rm-reasons-table .rm-reason-icd').each(function(i,e) {
-                var fieldIndex = $(e).attr('data-index');
-                attachAutocompleterToField(fieldIndex);
-            });
-
-            $("#rmReasonsComponent #btnUpdateRmReasons").click(function() {
-                let rmReasons = [];
-                $('tr.data-row').each(function() {
-                    let icd = $.trim($(this).find('input.rm-reason-icd').val());
-                    if(icd) {
-                        rmReasons.push({
-                            icd: icd,
-                            description: $.trim($(this).find('input.rm-reason-description').val())
-                        });
-                    }
-                });
-                if(!rmReasons.length) return false;
-                showMask();
-                rmReasons = JSON.stringify(rmReasons);
-                $.post('/api/client/updateRmReasons', {
-                    uid: '{{$patient->uid}}',
-                    rmReasons: rmReasons
-                }, (_data) => {
-                    hideMask();
-                    if(_data && _data.success) {
-                        fastReload();
-                    }
-                    else {
-                        toastr.error(_data.message ? _data.message : 'Unable to update RM reasons!');
-                    }
-                }, 'json');
-                return false;
-            });
-
-            function attachAutocompleterToField(fieldIndex){
-                var e = $('#rm_icd_'+fieldIndex)[0];
-                new Def.Autocompleter.Search('rm_icd_'+fieldIndex, 'https://clinicaltables.nlm.nih.gov/api/icd10cm/v3/search?sf=code,name', {
-                    tableFormat: true,
-                    valueCols: [1],
-                    colHeaders: ['Code', 'Name']
-                });
-                Def.Autocompleter.Event.observeListSelections('rm_icd_'+fieldIndex, function(data) {
-                    console.log("Setting value of e to : ", data.item_code);
-                    $('#rm_icd_'+fieldIndex).val(data.item_code);
-                    $('#rm_description_'+fieldIndex).val(data.final_val);
-                    $('#rm_icd_'+fieldIndex).focus();
-                    return false;
-                });
-            }
-        }
-
-        addMCInitializer('rmReasonsComponent', init, '#rmReasonsComponent');
-
-    })();
-</script>

+ 54 - 17
resources/views/app/patient/partials/rm-reasons.blade.php

@@ -1,25 +1,62 @@
 <div class="">
     <div class="">
-        <div class="d-flex align-items-center mb-2">
+        <div class="d-flex align-items-center mb-2 border-bottom pb-2">
             <p class="font-weight-bold text-secondary m-0 mr-2">RM Reasons</p>
-            @include('app/patient/partials/_create-rm-reason')
         </div>
-        <div class="d-flex align-items-start flex-wrap">
-            <?php
-            $rmReasons = [];
-            if($patient->rm_reasons) {
-                $rmReasons = json_decode($patient->rm_reasons);
-            }
-            ?>
-            @if(count($rmReasons))
-                @foreach ($rmReasons as $reason)
-                    <span class="badge badge-info p-2 mb-2 mr-2">
-                        {{ $reason->description}} ({{ $reason->icd }})
-                    </span>
+        @if(!$patient->rmReasons || !count($patient->rmReasons))
+            <span class="text-secondary">None</span>
+        @else
+            <div>
+                @foreach($patient->rmReasons as $reason)
+                    <div class="border-bottom pb-1 mb-1 d-flex align-items-start">
+                        <b class="width-90px">{{$reason->code}}</b>
+                        <span class="width-200px">{{$reason->description}}</span>
+                        <div moe>
+                            <a start show>Edit</a>
+                            <form url="/api/clientCmRmReason/updateBasic" class="mcp-theme-1">
+                                <input type="hidden" name="uid" value="{{$reason->uid}}">
+                                <div class="mb-2">
+                                    <label class="text-sm mb-1 text-secondary">Code *</label>
+                                    <input type="text" class="form-control form-control-sm"
+                                           name="code" value="{{$reason->code}}" required>
+                                </div>
+                                <div class="mb-2">
+                                    <label class="text-sm mb-1 text-secondary">Description</label>
+                                    <input type="text" class="form-control form-control-sm"
+                                           name="description" value="{{$reason->description}}">
+                                </div>
+                                <div>
+                                    <button submit class="btn btn-sm btn-primary mr-1">Submit</button>
+                                    <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                                </div>
+                            </form>
+                        </div>
+                    </div>
                 @endforeach
-            @else
-                <div class="alert alert-info">No RM reasons</div>
-            @endif
+            </div>
+        @endif
+        <div>
+            <div moe>
+                <a start show>+ Add</a>
+                <form url="/api/clientCmRmReason/create" class="mcp-theme-1">
+                    <input type="hidden" name="clientUid" value="{{$patient->uid}}">
+                    <input type="hidden" name="cmOrRm" value="RM">
+                    <div class="mb-2">
+                        <label class="text-sm mb-1 text-secondary">Code *</label>
+                        <input type="text" class="form-control form-control-sm"
+                               name="code" value="" required>
+                    </div>
+                    <div class="mb-2">
+                        <label class="text-sm mb-1 text-secondary">Description</label>
+                        <input type="text" class="form-control form-control-sm"
+                               name="description" value="">
+                    </div>
+                    <div>
+                        <button submit class="btn btn-sm btn-primary mr-1">Submit</button>
+                        <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                    </div>
+                </form>
+            </div>
         </div>
     </div>
 </div>

+ 47 - 8
resources/views/app/patient/rm-setup.blade.php

@@ -79,16 +79,53 @@
     <div class="d-flex align-items-baseline mb-3">
         <span class="width-200px">RM Reasons:</span>
         <div class="ml-3">
-            <div class="d-inline-flex align-items-start">
-                <b>{{ $patient->rm_reasons ?: '-' }}</b>
-                <div moe class="ml-2">
-                    <a start show><i class="fa fa-edit"></i></a>
-                    <form url="/api/client/updateRmReasons" class="mcp-theme-1">
-                        <input type="hidden" name="uid" value="{{$patient->uid}}">
+            @if(!$patient->rmReasons || !count($patient->rmReasons))
+                <span class="text-secondary">None</span>
+            @else
+                <div>
+                    @foreach($patient->rmReasons as $reason)
+                        <div class="border-bottom pb-1 mb-1 d-flex align-items-start">
+                            <b class="width-90px">{{$reason->code}}</b>
+                            <span class="width-200px">{{$reason->description}}</span>
+                            <div moe>
+                                <a start show>Edit</a>
+                                <form url="/api/clientCmRmReason/updateBasic" class="mcp-theme-1">
+                                    <input type="hidden" name="uid" value="{{$reason->uid}}">
+                                    <div class="mb-2">
+                                        <label class="text-sm mb-1 text-secondary">Code *</label>
+                                        <input type="text" class="form-control form-control-sm"
+                                               name="code" value="{{$reason->code}}" required>
+                                    </div>
+                                    <div class="mb-2">
+                                        <label class="text-sm mb-1 text-secondary">Description</label>
+                                        <input type="text" class="form-control form-control-sm"
+                                               name="description" value="{{$reason->description}}">
+                                    </div>
+                                    <div>
+                                        <button submit class="btn btn-sm btn-primary mr-1">Submit</button>
+                                        <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                                    </div>
+                                </form>
+                            </div>
+                        </div>
+                    @endforeach
+                </div>
+            @endif
+            <div>
+                <div moe>
+                    <a start show>+ Add</a>
+                    <form url="/api/clientCmRmReason/create" class="mcp-theme-1">
+                        <input type="hidden" name="clientUid" value="{{$patient->uid}}">
+                        <input type="hidden" name="cmOrRm" value="RM">
+                        <div class="mb-2">
+                            <label class="text-sm mb-1 text-secondary">Code *</label>
+                            <input type="text" class="form-control form-control-sm"
+                                   name="code" value="" required>
+                        </div>
                         <div class="mb-2">
-                            <label class="text-sm mb-1 text-secondary">RM Reasons</label>
+                            <label class="text-sm mb-1 text-secondary">Description</label>
                             <input type="text" class="form-control form-control-sm"
-                                   name="rmReasons" value="{{$patient->rm_reasons}}">
+                                   name="description" value="">
                         </div>
                         <div>
                             <button submit class="btn btn-sm btn-primary mr-1">Submit</button>
@@ -327,6 +364,8 @@
         </div>
     @endif
 
+    <?php $datesWithMeasurements = []; ?>
+
     @if($careMonth && ($bpDevice || $weightScale))
         <hr class="m-neg-4">
         <div class="d-flex align-items-baseline mb-1">

+ 133 - 0
resources/views/app/patient/settings.blade.php

@@ -695,6 +695,139 @@
 
 
                 @if($pro->pro_type == 'ADMIN')
+
+                    @if($patient->mcp)
+                        <hr class="m-negator-3 mt-3">
+                        <div>
+                            <span>Default MCP Company Pro:
+                                <b>{{$patient->default_mcp_company_pro_id? $patient->defaultMcpCompanyPro->company->name . ' / ' . $patient->defaultMcpCompanyPro->pro->displayName():'No'}}</b>
+                            </span>
+                            @if($patient->default_mcp_company_pro_id)
+                                <div moe bottom relative class="ml-1">
+                                    <a start show><i class="fa fa-times text-danger"></i></a>
+                                    <form url="/api/client/wipeDefaultMcpCompanyPro"
+                                          class="mcp-theme-1 min-width-200px" right>
+                                        <input type="hidden" name="uid" value="{{$patient->uid}}">
+                                        <p>Remove default MCP company pro?</p>
+                                        <div>
+                                            <button submit class="btn btn-sm btn-primary mr-1">Submit</button>
+                                            <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                                        </div>
+                                    </form>
+                                </div>
+                            @else
+                                <div moe bottom relative class="ml-2">
+                                    <a start show>Edit</a>
+                                    <form url="/api/client/putDefaultMcpCompanyPro"
+                                          class="mcp-theme-1  min-width-200px">
+                                        <input type="hidden" name="uid" value="{{$patient->uid}}">
+                                        <div class="mb-2">
+                                            <label class="text-sm text-secondary mb-1">Payer</label>
+                                            <select name="defaultMcpCompanyProUid" class="form-control form-control-sm">
+                                                <option value="">-- select --</option>
+                                                @foreach($patient->mcp->companyPros as $companyPro)
+                                                    <option value="{{$companyPro->uid}}">{{$companyPro->company->name}}</option>
+                                                @endforeach
+                                            </select>
+                                        </div>
+                                        <div>
+                                            <button submit class="btn btn-sm btn-primary mr-1">Submit</button>
+                                            <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                                        </div>
+                                    </form>
+                                </div>
+                            @endif
+                        </div>
+
+                        @if($patient->default_mcp_company_pro_id)
+                            <hr class="m-negator-3 mt-3">
+                            <div>
+                                <span>Default MCP Company Pro Payer:
+                                    <b>{{$patient->default_mcp_company_pro_payer_id? $patient->defaultMcpCompanyProPayer->payer->name:'No'}}</b>
+                                </span>
+                                @if($patient->default_mcp_company_pro_payer_id)
+                                    <div moe bottom relative class="ml-1">
+                                        <a start show><i class="fa fa-times text-danger"></i></a>
+                                        <form url="/api/client/wipeDefaultMcpCompanyProPayer"
+                                              class="mcp-theme-1 min-width-200px" right>
+                                            <input type="hidden" name="uid" value="{{$patient->uid}}">
+                                            <p>Remove default MCP company pro payer?</p>
+                                            <div>
+                                                <button submit class="btn btn-sm btn-primary mr-1">Submit</button>
+                                                <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                                            </div>
+                                        </form>
+                                    </div>
+                                @else
+                                    <div moe bottom relative class="ml-2">
+                                        <a start show>Edit</a>
+                                        <form url="/api/client/putDefaultMcpCompanyProPayer"
+                                              class="mcp-theme-1  min-width-200px">
+                                            <input type="hidden" name="uid" value="{{$patient->uid}}">
+                                            <div class="mb-2">
+                                                <label class="text-sm text-secondary mb-1">Payer</label>
+                                                <select name="defaultMcpCompanyProPayerUid" class="form-control form-control-sm">
+                                                    <option value="">-- select --</option>
+                                                    @foreach($patient->defaultMcpCompanyPro->companyProPayers as $companyProPayer)
+                                                        <option value="{{$companyProPayer->uid}}">{{$companyProPayer->payer->name}}</option>
+                                                    @endforeach
+                                                </select>
+                                            </div>
+                                            <div>
+                                                <button submit class="btn btn-sm btn-primary mr-1">Submit</button>
+                                                <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                                            </div>
+                                        </form>
+                                    </div>
+                                @endif
+                            </div>
+
+                            <hr class="m-negator-3 mt-3">
+                            <div>
+                                <span>Default MCP Company Location:
+                                    <b>{{$patient->default_mcp_company_location_id? implode(" ", [$patient->defaultMcpCompanyLocation->line1, $patient->defaultMcpCompanyLocation->city, $patient->defaultMcpCompanyLocation->state]):'No'}}</b>
+                                </span>
+                                @if($patient->default_mcp_company_location_id)
+                                    <div moe bottom relative class="ml-1">
+                                        <a start show><i class="fa fa-times text-danger"></i></a>
+                                        <form url="/api/client/wipeDefaultMcpCompanyLocation"
+                                              class="mcp-theme-1 min-width-200px" right>
+                                            <input type="hidden" name="uid" value="{{$patient->uid}}">
+                                            <p>Remove default MCP company location?</p>
+                                            <div>
+                                                <button submit class="btn btn-sm btn-primary mr-1">Submit</button>
+                                                <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                                            </div>
+                                        </form>
+                                    </div>
+                                @else
+                                    <div moe bottom relative class="ml-2">
+                                        <a start show>Edit</a>
+                                        <form url="/api/client/putDefaultMcpCompanyLocation"
+                                              class="mcp-theme-1  min-width-200px">
+                                            <input type="hidden" name="uid" value="{{$patient->uid}}">
+                                            <div class="mb-2">
+                                                <label class="text-sm text-secondary mb-1">Payer</label>
+                                                <select name="defaultCompanyLocationUid" class="form-control form-control-sm">
+                                                    <option value="">-- select --</option>
+                                                    @foreach($patient->defaultMcpCompanyPro->company->locations as $location)
+                                                        <option value="{{$location->uid}}">
+                                                            {{implode(" ", [$location->line1, $location->city, $location->state])}}
+                                                        </option>
+                                                    @endforeach
+                                                </select>
+                                            </div>
+                                            <div>
+                                                <button submit class="btn btn-sm btn-primary mr-1">Submit</button>
+                                                <button cancel class="btn btn-sm btn-default border">Cancel</button>
+                                            </div>
+                                        </form>
+                                    </div>
+                                @endif
+                            </div>
+                        @endif
+                    @endif
+
                 <hr class="m-negator-3 mt-3">
                 <div>
                     <div class="d-flex mb-2 align-items-center">

+ 47 - 1
resources/views/app/patient/shipments.blade.php

@@ -413,7 +413,53 @@
                         </div>
                     @endif
 
-                    <hr class="m-neg-4">
+                    <hr class="m-neg-3">
+                    <div class="mb-3">
+                        <label class="text-secondary text-sm mb-1">Was Client Called and Has Client Acknowledged?</label>
+                        <div class="d-flex align-items-center">
+                            @if($shipment->was_client_called)
+                                <div>
+                                    <div class="mb-1 text-info">Client was called</div>
+                                    <div class="mb-1 text-info">Client has acknowledged receipt of product: {{$shipment->has_client_acknowledged}}</div>
+                                    @if($shipment->has_client_acknowledged === 'YES' && $shipment->client_acknowledgement_memo)
+                                        <div class="mb-1 text-secondary font-italic">{{$shipment->client_acknowledgement_memo}}</div>
+                                    @endif
+                                </div>
+                            @else
+                                <div class="mb-1 text-warning-mellow font-weight-bold">Client has not been called</div>
+                            @endif
+                        </div>
+                        <div class="" moe>
+                            <a start show class="py-0">Update</a>
+                            <form url="/api/shipment/{{$shipment->was_client_called ? 'setWasClientCalledToFalse' : 'setWasClientCalledToTrue'}}">
+                                <input type="hidden" name="uid" value="{{ $shipment->uid }}">
+                                @if($shipment->was_client_called)
+                                    <p>Set to client was not called?</p>
+                                @else
+                                    <p>Set to client was called?</p>
+                                    <div class="mb-2">
+                                        <label class="text-secondary text-sm">Has Client Acknowledged Receipt of Product?</label>
+                                        <select name="hasClientAcknowledged"
+                                                class="form-control form-control-sm">
+                                            <option value="">-- Select Status --</option>
+                                            <option value="YES">YES</option>
+                                            <option value="NO">NO</option>
+                                            <option value="UNKNOWN">UNKNOWN</option>
+                                        </select>
+                                    </div>
+                                    <div class="mb-2">
+                                        <label class="text-secondary text-sm">Client Acknowledgement Memo</label>
+                                        <input type="text" class="form-control form-control-sm" name="clientAcknowledgementMemo">
+                                    </div>
+                                @endif
+                                <div class="d-flex align-items-center">
+                                    <button class="btn btn-sm btn-primary mr-2" type="button" submit>Save</button>
+                                </div>
+                            </form>
+                        </div>
+                    </div>
+
+                    <hr class="m-neg-3">
                     @include('app.generic-bills.inline', ['patient' => $patient, 'entityType' => 'Shipment', 'entityUid' => $shipment->uid])
 
                 </div>

+ 116 - 46
resources/views/app/patient/supply-orders.blade.php

@@ -7,52 +7,78 @@
                 <span class="mx-2 text-secondary">|</span>
                 <div moe large>
                     <a start show href="#">Add</a>
-                    <form url="/api/supplyOrder/create" redir="/patients/view/{{ $patient->uid }}/supply-orders/[data]">
-                        <input type="hidden" name="clientUid" value="{{ $patient->uid }}">
-                        <input type="hidden" name="noteUid" value="{{ request()->input('note-uid') }}">
-                        <label class="text-secondary font-weight-bold">Add Supply Order</label>
-                        <div class="mb-2">
-                            <label class="text-secondary text-sm">Product</label>
-                            <select name="productUid" class="form-control form-control-sm">
-                                <option value=""> --select--</option>
-                                @foreach($products as $product)
-                                    <option
-                                        value="{{$product->uid}}">{{$product->title}}</option>
-                                @endforeach
-                            </select>
-                        </div>
-                        <div class="mb-2">
-                            <label class="text-secondary text-sm">Address Line1</label>
-                            <input type="text" class="form-control form-control-sm" name="mailingAddressLine1" value="{{$patient->mailing_address_line1}}">
-                        </div>
-                        <div class="mb-2">
-                            <label class="text-secondary text-sm">Address Line2</label>
-                            <input type="text" class="form-control form-control-sm" name="mailingAddressLine2" value="{{$patient->mailing_address_line2}}">
-                        </div>
-                        <div class="mb-2">
-                            <label class="text-secondary text-sm">Address City</label>
-                            <input type="text" class="form-control form-control-sm" name="mailingAddressCity" value="{{$patient->mailing_address_city}}">
-                        </div>
-                        <div class="mb-2">
-                            <label class="text-secondary text-sm">Address State</label>
-                            <input type="text" class="form-control form-control-sm" name="mailingAddressState" value="{{$patient->mailing_address_state}}">
-                        </div>
-                        <div class="mb-2">
-                            <label class="text-secondary text-sm">Address Zip</label>
-                            <input type="text" class="form-control form-control-sm" name="mailingAddressZip" value="{{$patient->mailing_address_zip}}">
-                        </div>
-                        <div class="mb-2">
-                            <label class="text-secondary text-sm">Reason</label>
-                            <input type="text" class="form-control form-control-sm" name="reason">
-                        </div>
-                        <div class="mb-2">
-                            <label class="text-secondary text-sm">Client Understanding Memo</label>
-                            <input type="text" class="form-control form-control-sm" name="clientUnderstandingMemo">
-                        </div>
-                        <div class="d-flex align-items-center">
-                            <button class="btn btn-sm btn-primary mr-2" type="button" submit>Save</button>
-                        </div>
-                    </form>
+                    @if(($patient->is_eligible_for_cm === 'YES' || ($patient->was_medicare_validation_successful && $patient->is_part_b_primary == 'YES')) && $patient->is_enrolled_in_cm !== 'YES')
+                        <form url="/api/client/setIsEnrolledInCmToTrue">
+                            <p class="font-weight-bold">You need to enroll this patient into CM before adding supply orders.</p>
+                            <input type="hidden" name="uid" value="{{ $patient->uid }}">
+                            <div class="mb-2">
+                                <label class="text-secondary text-sm">CM Enrollment Consent Method</label>
+                                <input type="text" class="form-control form-control-sm" name="cmEnrollmentConsentMethod">
+                            </div>
+                            <div class="mb-2">
+                                <label class="text-secondary text-sm">CM Enrollment Consent Method Memo</label>
+                                <input type="text" class="form-control form-control-sm" name="cmEnrollmentConsentMethodMemo">
+                            </div>
+                            <div class="mb-2">
+                                <label class="text-secondary text-sm">CM Reason 1</label>
+                                <input type="text" class="form-control form-control-sm" name="cmReason1">
+                            </div>
+                            <div class="mb-2">
+                                <label class="text-secondary text-sm">CM Reason 2</label>
+                                <input type="text" class="form-control form-control-sm" name="cmReason2">
+                            </div>
+                            <div class="d-flex align-items-center">
+                                <button class="btn btn-sm btn-primary mr-2" type="button" submit>Enroll</button>
+                            </div>
+                        </form>
+                    @else
+                        <form url="/api/supplyOrder/create" redir="/patients/view/{{ $patient->uid }}/supply-orders/[data]">
+                            <input type="hidden" name="clientUid" value="{{ $patient->uid }}">
+                            <input type="hidden" name="noteUid" value="{{ request()->input('note-uid') }}">
+                            <label class="text-secondary font-weight-bold">Add Supply Order</label>
+                            <div class="mb-2">
+                                <label class="text-secondary text-sm">Product</label>
+                                <select name="productUid" class="form-control form-control-sm">
+                                    <option value=""> --select--</option>
+                                    @foreach($products as $product)
+                                        <option
+                                                value="{{$product->uid}}">{{$product->title}}</option>
+                                    @endforeach
+                                </select>
+                            </div>
+                            <div class="mb-2">
+                                <label class="text-secondary text-sm">Address Line1</label>
+                                <input type="text" class="form-control form-control-sm" name="mailingAddressLine1" value="{{$patient->mailing_address_line1}}">
+                            </div>
+                            <div class="mb-2">
+                                <label class="text-secondary text-sm">Address Line2</label>
+                                <input type="text" class="form-control form-control-sm" name="mailingAddressLine2" value="{{$patient->mailing_address_line2}}">
+                            </div>
+                            <div class="mb-2">
+                                <label class="text-secondary text-sm">Address City</label>
+                                <input type="text" class="form-control form-control-sm" name="mailingAddressCity" value="{{$patient->mailing_address_city}}">
+                            </div>
+                            <div class="mb-2">
+                                <label class="text-secondary text-sm">Address State</label>
+                                <input type="text" class="form-control form-control-sm" name="mailingAddressState" value="{{$patient->mailing_address_state}}">
+                            </div>
+                            <div class="mb-2">
+                                <label class="text-secondary text-sm">Address Zip</label>
+                                <input type="text" class="form-control form-control-sm" name="mailingAddressZip" value="{{$patient->mailing_address_zip}}">
+                            </div>
+                            <div class="mb-2">
+                                <label class="text-secondary text-sm">Reason</label>
+                                <input type="text" class="form-control form-control-sm" name="reason">
+                            </div>
+                            <div class="mb-2">
+                                <label class="text-secondary text-sm">Client Understanding Memo</label>
+                                <input type="text" class="form-control form-control-sm" name="clientUnderstandingMemo">
+                            </div>
+                            <div class="d-flex align-items-center">
+                                <button class="btn btn-sm btn-primary mr-2" type="button" submit>Save</button>
+                            </div>
+                        </form>
+                    @endif
                 </div>
             @endif
             <select class="ml-auto max-width-300px form-control form-control-sm supply-orders-filter">
@@ -363,6 +389,50 @@
                             </div>
                         @endif
                     </div>
+                    <div class="mb-3">
+                        <label class="text-secondary text-sm mb-1">Was Client Called and Has Client Acknowledged?</label>
+                        <div class="d-flex align-items-center">
+                            @if($supplyOrder->was_client_called)
+                                <div>
+                                    <div class="mb-1 text-info">Client was called</div>
+                                    <div class="mb-1 text-info">Client has acknowledged receipt of product: {{$supplyOrder->has_client_acknowledged}}</div>
+                                    @if($supplyOrder->has_client_acknowledged === 'YES' && $supplyOrder->client_acknowledgement_memo)
+                                        <div class="mb-1 text-secondary font-italic">{{$supplyOrder->client_acknowledgement_memo}}</div>
+                                    @endif
+                                </div>
+                            @else
+                                <div class="mb-1 text-warning-mellow font-weight-bold">Client has not been called</div>
+                            @endif
+                        </div>
+                        <div class="" moe>
+                            <a start show class="py-0">Update</a>
+                            <form url="/api/supplyOrder/{{$supplyOrder->was_client_called ? 'setWasClientCalledToFalse' : 'setWasClientCalledToTrue'}}">
+                                <input type="hidden" name="uid" value="{{ $supplyOrder->uid }}">
+                                @if($supplyOrder->was_client_called)
+                                    <p>Set to client was not called?</p>
+                                @else
+                                    <p>Set to client was called?</p>
+                                    <div class="mb-2">
+                                        <label class="text-secondary text-sm">Has Client Acknowledged Receipt of Product?</label>
+                                        <select name="hasClientAcknowledged"
+                                                class="form-control form-control-sm">
+                                            <option value="">-- Select Status --</option>
+                                            <option value="YES">YES</option>
+                                            <option value="NO">NO</option>
+                                            <option value="UNKNOWN">UNKNOWN</option>
+                                        </select>
+                                    </div>
+                                    <div class="mb-2">
+                                        <label class="text-secondary text-sm">Client Acknowledgement Memo</label>
+                                        <input type="text" class="form-control form-control-sm" name="clientAcknowledgementMemo">
+                                    </div>
+                                @endif
+                                <div class="d-flex align-items-center">
+                                    <button class="btn btn-sm btn-primary mr-2" type="button" submit>Save</button>
+                                </div>
+                            </form>
+                        </div>
+                    </div>
                     <hr class="my-3">
                     <div class="d-flex align-items-center">
                         @if($supplyOrder->is_cleared_for_shipment)

+ 2 - 0
resources/views/app/practice-management/bills.blade.php

@@ -35,7 +35,9 @@
                             {{ friendly_date_time($bill->created_at, true) }}
                         </td>
                         <td class="">
+                            @if($bill->client)
                             <a href="/patients/view/{{ $bill->client->uid }}">{{ $bill->client->displayName() }}</a>
+                            @endif
                         </td>
                         <td class="stag-no-wrap-td">
                             @if($bill->careMonth)

+ 194 - 33
resources/views/app/practice-management/cellular-device-manager.blade.php

@@ -7,17 +7,17 @@
         <div class="card">
 
             <div class="card-header px-3 py-2 d-flex align-items-center">
-                <strong class="mr-4">
+                <strong class="mr-4 flex-grow-1">
                     <i class="fas fa-user-injured"></i>
                     Cellular Device Manager
                 </strong>
-                <select class="ml-auto max-width-300px form-control form-control-sm"
-                        onchange="fastLoad('/practice-management/cellular-device-manager/' + this.value, true, false, false)">
-                    <option value="" {{ $proUid === '' ? 'selected' : '' }}>All Pros</option>
-                    @foreach($allPros as $_pro)
-                        <option value="{{$_pro->uid}}" {{ $proUid === $_pro->uid ? 'selected' : '' }}>{{$_pro->displayName()}}</option>
-                    @endforeach
-                </select>
+                <div class="width-200px ml-auto">
+                    <select class="form-control form-control-sm"
+                            provider-search data-pro-uid="{{$proUid}}"
+                            onchange="fastLoad('/practice-management/cellular-device-manager/' + this.value, true, false, false)">
+                        <option value="" {{ $proUid === '' ? 'selected' : '' }}>All Pros</option>
+                    </select>
+                </div>
             </div>
             <style>
                 .cellular-bp {
@@ -28,59 +28,220 @@
                 }
             </style>
             <div class="card-body p-0">
-                <table class="table table-sm table-condensed p-0 m-0">
+                <table class="table table-sm table-condensed table-striped p-0 m-0">
                     <colgroup>
-                        <col span="4">
+                        <col span="8">
                         <col span="4" class="cellular-bp">
                         <col span="4" class="cellular-weight">
                     </colgroup>
                     <thead class="bg-light">
                     <tr>
-                        <th colspan="4"></th>
-                        <th colspan="4">Cellular BP</th>
-                        <th colspan="4">Cellular Weight</th>
-                    </tr>
-                    <tr>
-                        <th class="px-3 border-0">Created</th>
-                        <th class="border-0">Patient</th>
+                        <th class="px-3 border-0">Patient</th>
+                        <th class="border-0">DOB</th>
                         <th class="border-0">MCP</th>
                         <th class="border-0">RME</th>
+                        <th class="border-0">RMM</th>
+                        <th class="border-0">MC</th>
+                        <th class="border-0">MC Part-B</th>
+                        <th class="border-0">SMS Notifs</th>
 
-                        <th class="border-0">Sent?</th>
-                        <th class="border-0">First use</th>
-                        <th class="border-0">Last use</th>
-                        <th class="border-0">Total measurements</th>
-
-                        <th class="border-0">Sent?</th>
-                        <th class="border-0">First use</th>
-                        <th class="border-0">Last use</th>
-                        <th class="border-0">Total measurements</th>
+                        <th class="border-0" colspan="4">Cellular BP</th>
+                        <th class="border-0" colspan="4">Cellular Weight</th>
                     </tr>
                     </thead>
                     <tbody>
                     @foreach ($clients as $client)
                         <tr>
 
-                            <td>{{ $client->created_at }}</td>
-                            <td>{{ $client->displayName() }}</td>
-                            <td>{{ $client->mcpDisplayName() }}</td>
-                            <td>{{ $client->rmeDisplayName() }}</td>
+                            <td class="pl-3">
+                                <a href="{{route('patients.view.dashboard', ['patient' => $client])}}"><b>{{ $client->displayName() }}</b></a>
+                                <div class="mt-1 text-secondary text-sm">{{friendlier_date_time($client->created_at)}}</div>
+                            </td>
+                            <td>{{ friendlier_date_time($client->dob, false) }}</td>
+                            <td>{{ $client->mcp ? $client->mcp->displayName() : '' }}</td>
+                            <td>{{ $client->rme ? $client->rme->displayName() : '' }}</td>
+                            <td>{{ $client->rmm ? $client->rmm->displayName() : '' }}</td>
+
+                            <td>{{ $client->was_medicare_validation_successful ? 'Yes' : '' }}</td>
+                            <td>{{ $client->was_medicare_validation_successful && $client->is_part_b_primary == 'YES' ? 'Yes' : '' }}</td>
+
+                            <td>{{$client->send_sms_on_bdt_measurement ? 'Yes' : ''}}</td>
+
+                            <td colspan="4">
+                                <?php
+                                $bpDevice = $client->firstCellularBPDevice();
+                                $bpMeasurements = [];
+                                if ($bpDevice) {
+                                    $records = \App\Models\Measurement
+                                        ::where('imei', $bpDevice->device->imei)
+                                        ->where('client_id', $client->id)
+                                        ->where('is_cellular_zero', false)
+                                        ->orderBy('ts')
+                                        ->get();
+                                    if(count($records)) {
+                                        $bpMeasurements["first"] = $records[0];
+                                        $bpMeasurements["last"] = $records[count($records) - 1];
+                                        $bpMeasurements["count"] = count($records);
+                                    }
+                                    // get num measurement days
+                                    $dayCount = [];
+                                    for($i = 0; $i<count($records); $i++) {
+                                        $date = friendly_date_short_with_tz_from_timestamp_divide1000($records[$i]->ts);
+                                        if(!in_array($date, $dayCount)) {
+                                            $dayCount[] = $date;
+                                        }
+                                    }
+                                }
+                                ?>
+                                @if($bpDevice)
+                                    <?php $bpSO = $client->supplyOrderForCellularBPDevice(); ?>
+                                    <div class="d-flex align-items-baseline mb-1">
+                                        <span class="width-100px">Ordered:</span>
+                                        <span class="ml-3">{{$bpSO ? 'Yes' : 'No'}}</span>
+                                    </div>
+                                    <div class="d-flex align-items-baseline mb-1">
+                                        <span class="width-100px">Sent:</span>
+                                        <span class="ml-3">{{$bpSO && $bpSO->shipment && $bpSO->shipment->status === 'DISPATCHED' ? 'Yes' : 'No'}}</span>
+                                    </div>
+                                    <div class="d-flex align-items-baseline mb-1">
+                                        <span class="width-100px">IMEI:</span>
+                                        <span class="ml-3">{{$bpDevice->device->imei}}</span>
+                                    </div>
+                                    <div class="d-flex align-items-baseline mb-1">
+                                        <span class="width-100px">First Use:</span>
+                                        @if(@$bpMeasurements["first"])
+                                            <span class="ml-3">{{ $bpMeasurements["first"]->sbp_mm_hg . '/' . $bpMeasurements["first"]->dbp_mm_hg . ' mmHg' }}</span>
+                                            <span class="ml-3 text-secondary">{{date("Y-m-d", $bpMeasurements["first"]->ts/1000)}}</span>
+                                            <span class="ml-3">{{date_diff(date_create(date("Y-m-d", $bpMeasurements["first"]->ts/1000)), date_create('now'))->days}} days ago</span>
+                                        @else
+                                            -
+                                        @endif
+                                    </div>
+                                    <div class="d-flex align-items-baseline mb-1">
+                                        <span class="width-100px">Last Use:</span>
+                                        @if(@$bpMeasurements["last"])
+                                            <span class="ml-3">{{ $bpMeasurements["last"]->sbp_mm_hg . '/' . $bpMeasurements["last"]->dbp_mm_hg . ' mmHg' }}</span>
+                                            <span class="ml-3 text-secondary">{{date("Y-m-d", $bpMeasurements["last"]->ts/1000)}}</span>
+                                            <span class="ml-3">{{date_diff(date_create(date("Y-m-d", $bpMeasurements["last"]->ts/1000)), date_create('now'))->days}} days ago</span>
+                                        @else
+                                            -
+                                        @endif
+                                    </div>
+                                    <div class="d-flex align-items-baseline mb-1">
+                                        <span class="width-100px">Total Meas.:</span>
+                                        @if(@$bpMeasurements["count"])
+                                            <span class="ml-3">{{ $bpMeasurements["count"] }}</span>
+                                        @else
+                                            -
+                                        @endif
+                                    </div>
+                                    <div class="d-flex align-items-baseline mb-1">
+                                        <span class="width-100px">Total Meas. Days:</span>
+                                        @if(@$dayCount)
+                                            <span class="ml-3">{{ count($dayCount) }}</span>
+                                        @else
+                                            -
+                                        @endif
+                                    </div>
+                                @endif
+                            </td>
+
+                            <td colspan="4">
+                                <?php
+                                $weightScale = $client->firstCellularWeightDevice();
+                                $weightMeasurements = [];
+                                if ($weightScale) {
+                                    $records = \App\Models\Measurement
+                                        ::where('imei', $weightScale->device->imei)
+                                        ->where('client_id', $client->id)
+                                        ->where('is_cellular_zero', false)
+                                        ->orderBy('ts')
+                                        ->get();
+                                    if(count($records)) {
+                                        $weightMeasurements["first"] = $records[0];
+                                        $weightMeasurements["last"] = $records[count($records) - 1];
+                                        $weightMeasurements["count"] = count($records);
+                                    }
+                                    // get num measurement days
+                                    $dayCount = [];
+                                    for($i = 0; $i<count($records); $i++) {
+                                        $date = friendly_date_short_with_tz_from_timestamp_divide1000($records[$i]->ts);
+                                        if(!in_array($date, $dayCount)) {
+                                            $dayCount[] = $date;
+                                        }
+                                    }
+                                }
+                                ?>
+                                @if($weightScale)
+                                    <?php $wsSO = $client->supplyOrderForCellularWeightScale(); ?>
+                                    <div class="d-flex align-items-baseline mb-1">
+                                        <span class="width-100px">Ordered:</span>
+                                        <span class="ml-3">{{$wsSO ? 'Yes' : ''}}</span>
+                                    </div>
+                                    <div class="d-flex align-items-baseline mb-1">
+                                        <span class="width-100px">Sent:</span>
+                                        <span class="ml-3">{{$wsSO && $wsSO->shipment && $wsSO->shipment->status === 'DISPATCHED' ? 'Yes' : 'No'}}</span>
+                                    </div>
+                                    <div class="d-flex align-items-baseline mb-1">
+                                        <span class="width-100px">IMEI:</span>
+                                        <span class="ml-3">{{$weightScale->device->imei}}</span>
+                                    </div>
+                                    <div class="d-flex align-items-baseline mb-1">
+                                        <span class="width-100px">First Use:</span>
+                                        @if(@$weightMeasurements["first"])
+                                            <span class="ml-3">{{ round($weightMeasurements["first"]->value, 2) . ' lbs' }}</span>
+                                            <span class="ml-3 text-secondary">{{date("Y-m-d", $weightMeasurements["first"]->ts/1000)}}</span>
+                                            <span class="ml-3">{{date_diff(date_create(date("Y-m-d", $weightMeasurements["first"]->ts/1000)), date_create('now'))->days}} days ago</span>
+                                        @else
+                                            -
+                                        @endif
+                                    </div>
+                                    <div class="d-flex align-items-baseline mb-1">
+                                        <span class="width-100px">Last Use:</span>
+                                        @if(@$weightMeasurements["last"])
+                                            <span class="ml-3">{{ round($weightMeasurements["last"]->value, 2) . ' lbs' }}</span>
+                                            <span class="ml-3 text-secondary">{{date("Y-m-d", $weightMeasurements["last"]->ts/1000)}}</span>
+                                            <span class="ml-3">{{date_diff(date_create(date("Y-m-d", $weightMeasurements["last"]->ts/1000)), date_create('now'))->days}} days ago</span>
+                                        @else
+                                            -
+                                        @endif
+                                    </div>
+                                    <div class="d-flex align-items-baseline mb-1">
+                                        <span class="width-100px">Total Meas.:</span>
+                                        @if(@$weightMeasurements["count"])
+                                            <span class="ml-3">{{ $weightMeasurements["count"] }}</span>
+                                        @else
+                                            -
+                                        @endif
+                                    </div>
+                                    <div class="d-flex align-items-baseline mb-1">
+                                        <span class="width-100px">Total Meas. Days:</span>
+                                        @if(@$dayCount)
+                                            <span class="ml-3">{{ count($dayCount) }}</span>
+                                        @else
+                                            -
+                                        @endif
+                                    </div>
+                                @endif
+                            </td>
 
-                            <td>{{ $client->firstCellularBPDevice() ? 'Yes' : 'No' }}</td>
+                            {{--
+                            <td>{{ $client->firstCellularBPDevice() ? 'Yes' : '' }}</td>
                             <td>{{ $client->getFirstCellularBPMeasurementAt()  }}</td>
                             <td>{{ $client->getLatestCellularBPMeasurementAt() }}</td>
                             <td>{{ $client->getTotalCellularBPMeasurements() }}</td>
 
-                            <td>{{ $client->firstCellularWeightDevice() ? 'Yes' : 'No' }}</td>
+                            <td>{{ $client->firstCellularWeightDevice() ? 'Yes' : '' }}</td>
                             <td>{{ $client->getFirstCellularWeightMeasurementAt()  }}</td>
                             <td>{{ $client->getLatestCellularWeightMeasurementAt() }}</td>
                             <td>{{ $client->getTotalCellularWeightMeasurements() }}</td>
+                            --}}
 
                         </tr>
                     @endforeach
                     </tbody>
                 </table>
-                <div>
+                <div class="border-top px-3 pt-3">
                     {{$clients->links()}}
                 </div>
             </div>

+ 109 - 3
resources/views/app/practice-management/financial-transactions.blade.php

@@ -9,23 +9,73 @@
                     Financial Transactions
                 </strong>
                 <div class="ml-auto">
-                    <span class="">
+                    <b class="mr-2">{{$pro->displayName()}}</b>
+                    <i class="fa fa-arrow-right mr-2"></i>
+                    <span class="text-secondary">
                         <strong>Current Balance:</strong> ${{ $pro->balance }}
                     </span>&nbsp;
-                    <span>
+                    <span class="text-secondary">
                         <?php $lastPayment = $pro->lastPayment(); ?>
                         <strong>Last Payment:</strong>
                         {{ $lastPayment ? '$' . $lastPayment->amount . ' (' . friendly_date_time($lastPayment->created_at, false) . ')' : '-' }}
                     </span>
                 </div>
             </div>
+            <div class="card-header p-3">
+                <div class="d-flex align-items-center">
+                    <div class="width-200px">
+                        <select provider-search data-pro-uid="{{ request()->input('p') ? request()->input('p') : '' }}"
+                                name="proUid" class="form-control form-control-sm mr-auto width-200px min-width-unset"
+                                onchange="return transactionsFilter('p', this.value)">
+                            <option value="" {{!request()->input('p') ? 'selected' : ''}}>All Pros</option>
+                        </select>
+                    </div>
+                    <select name="filter" class="form-control form-control-sm width-200px ml-2"
+                            onchange="return transactionsFilter('t', this.value)">
+                        <option {{request()->input('t') === '' ? 'selected' : ''}} value="">All Transactions</option>
+                        <option {{request()->input('t') === 'PLUS' ? 'selected' : ''}} value="PLUS">Credits
+                        </option>
+                        <option {{request()->input('t') === 'MINUS' ? 'selected' : ''}} value="MINUS">Debits
+                        </option>
+                    </select>
+                    <select name="filter" class="form-control form-control-sm width-200px ml-2"
+                            onchange="return transactionsFilter('c', this.value)">
+                        <option {{!request()->input('c') ? 'selected' : ''}} value="">All Companies</option>
+                        @foreach($companies as $company)
+                            <option {{request()->input('c') == $company->id ? 'selected' : ''}}
+                                    value="{{$company->id}}">
+                                {{$company->name}}
+                            </option>
+                        @endforeach
+                    </select>
+                    <div class="ml-4 d-inline-flex align-items-center">
+                        <span class="mr-2">Date</span>
+                        <input type="date"
+                               value="{{request()->input('bs')}}"
+                               onchange="return transactionsFilter('bs', this.value)"
+                               class="form-control form-control-sm width-150px" name="bpdFrom">
+                        <span class="mx-2">to</span>
+                        <input type="date"
+                               value="{{request()->input('be')}}"
+                               onchange="return transactionsFilter('be', this.value)"
+                               class="form-control form-control-sm width-150px" name="bpdTo">
+                    </div>
+                    @if(count(array_filter(request()->all(), function($_x) { return !!$_x;})))
+                        <a href="/practice-management/financial-transactions" class="ml-4">Clear Filters</a>
+                    @endif
+                </div>
+            </div>
             <div class="card-body p-0">
-                <table class="table table-sm table-condensed p-0 m-0" style="table-layout: fixed">
+                <table class="table table-sm table-condensed p-0 m-0">
                     <thead class="bg-light">
                         <tr>
                             <th class="px-3 border-0">Date</th>
                             <th class="border-0">Type</th>
                             <th class="border-0">Client</th>
+                            @if($pro->pro_type === 'ADMIN')
+                                <th class="border-0">Pro</th>
+                            @endif
+                            <th class="border-0">Company</th>
                             <th class="border-0">Context</th>
                             <th class="border-0">Amount</th>
                             <th class="border-0">Balance</th>
@@ -49,7 +99,15 @@
                                         -
                                     @endif
                                 </td>
+                                @if($pro->pro_type === 'ADMIN')
+                                    <td>
+                                        {{$transaction->pro ? $transaction->pro->displayName() : ''}}
+                                    </td>
+                                @endif
                                 <td>
+                                    {{$transaction->company ? $transaction->company->name : ''}}
+                                </td>
+                                <td class="text-nowrap">
                                     @if($transaction->bill && $transaction->bill->note)
                                         <a href="{{route('patients.view.notes.view.dashboard', ['patient'=>$transaction->client, 'note'=>$transaction->bill->note])}}">
                                             ({{$transaction->bill->note->effective_dateest}})
@@ -108,5 +166,53 @@
                 </table>
             </div>
         </div>
+
+        <div class="d-flex align-items-center mt-3">
+            {{ $transactions->withQueryString()->links() }}
+        </div>
     </div>
+    <script>
+        (function() {
+            window.transactionsFilter = function(_key, _value) {
+
+                <?php
+                $keys = ['p', 'bs', 'be', 't', 'c'];
+                $currentParams = [];
+                for($i = 0; $i < count($keys); $i++) {
+                    if(!!request()->input($keys[$i])) {
+                        $currentParams[$keys[$i]] = request()->input($keys[$i]);
+                    }
+                }
+                ?>
+
+                let base = '/practice-management/financial-transactions',
+                    keys = ['p', 'bs', 'be', 't', 'c'].filter(_x => _x !== _key),
+                    currentParams = {!! json_encode($currentParams) !!},
+                    url = [];
+
+                // base
+                url.push(base);
+                url.push('?');
+
+                // params
+                let getParams = [];
+                for (let i = 0; i < keys.length; i++) {
+                    if(currentParams[keys[i]]) {
+                        getParams.push(keys[i] + '=' + encodeURIComponent(currentParams[keys[i]]));
+                    }
+                }
+
+                // new params
+                getParams.push(_key + '=' + encodeURIComponent(_value));
+
+                // generate url
+                url.push(getParams.join('&'));
+
+                // go
+                fastLoad(url.join(''));
+
+                return false;
+            };
+        }).call(window);
+    </script>
 @endsection

+ 14 - 2
resources/views/app/practice-management/pro-financials.blade.php

@@ -36,12 +36,24 @@
                     @foreach ($fPros as $row)
                         <tr>
                             <td>{{$row->displayName()}}</td>
-                            <td><b>${{friendly_money($row->balance)}}</b></td>
+                            <td><b>${{friendly_money($row->balance)}}</b>
+                                <div class="mt-2">
+                                    @foreach($row->companyPros as $companyPro)
+                                        @if($companyPro->balance)
+                                            <div class="mb-1 d-flex align-items-center text-secondary">
+                                                <b class="text-sm width-70px text-nowrap">${{$companyPro->balance}}</b>
+                                                <span class="text-sm text-nowrap">{{$companyPro->company->name}}</span>
+                                            </div>
+                                        @endif
+                                    @endforeach
+                                </div>
+                            </td>
                             <td>
                                 @foreach($row->recentDebits() as $debit)
                                     <div class="d-flex align-items-center mb-1">
                                         <span class="width-90px">{{'$' . $debit->amount}}</span>
-                                        <span class="text-secondary">{{friendly_date_time($debit->created_at, false)}}</span>
+                                        <span class="text-secondary width-90px">{{friendly_date_time($debit->created_at, false)}}</span>
+                                        <span class="text-secondary">{{$debit->company ? $debit->company->name : ''}}</span>
                                     </div>
                                 @endforeach
                             </td>

+ 32 - 5
resources/views/app/practice-management/process-claims.blade.php

@@ -52,7 +52,14 @@
                          v-on:click.prevent="setCurrentClaim(claimIndex)">
                         <div class="d-flex align-items-center c-pointer">
 
-                            <b class="p-2 border-right mr-2 bg-aliceblue" :class="claim.status === 'PICKED_UP' ? 'text-dark' : 'text-secondary'">@{{ claim.created }}</b>
+                            <b class="p-2 border-right mr-1 bg-aliceblue" :class="claim.status === 'PICKED_UP' ? 'text-dark' : 'text-secondary'">@{{ claim.created }}</b>
+
+                            <div v-if="claim.care_month_uid" class="rounded text-sm px-2 py-1 font-weight-bold bg-secondary text-white mr-1">
+                                <i class="fa fa-clock mr-1"></i>RM
+                            </div>
+                            <div v-if="claim.note_uid" class="rounded text-sm px-2 py-1 font-weight-bold bg-info text-white mr-1">
+                                <i class="fa fa-stethoscope mr-1"></i>NOTE
+                            </div>
 
                             <span class="text-secondary text-sm mr-1">Patient</span>
                             <span class="" title="Click to copy">@{{ claim.client }}</span>
@@ -198,18 +205,38 @@
                                     <hr class="my-2">
 
                                     <!--visit/note-->
-                                    <div class="d-flex align-items-center mb-1">
+                                    <div v-if="claim.note_uid" class="d-flex align-items-center mb-1">
                                         <div class="text-secondary mr-3 min-width-140px">Note</div>
                                         <div v-if="claim.note_uid">
-                                            <a :href="'/patients/view/' + claim.client_uid + '/notes/view/' + claim.note_uid + '?popupmode=1'"
-                                               native target="_blank"
-                                               class="note-popup-trigger text-nowrap mt-1 mr-1">
+                                            <a native target="_blank"
+                                               class="screen-only"
+                                               open-in-stag-popup
+                                               popup-style="stag-popup-med"
+                                               mc-initer="note-single"
+                                               title="Note"
+                                               :href="'/patients/view/' + claim.client_uid + '/notes/view/' + claim.note_uid">
                                                 View Note
                                             </a>
                                             <span class="ml-1 text-secondary">(@{{ claim.method }})</span>
                                         </div>
                                     </div>
 
+                                    <!-- care month -->
+                                    <div v-if="claim.care_month_uid" class="d-flex align-items-center mb-1">
+                                        <div class="text-secondary mr-3 min-width-140px">Care Month</div>
+                                        <div v-if="claim.care_month_uid">
+                                            <a native target="_blank"
+                                               class="screen-only"
+                                               open-in-stag-popup
+                                               mc-initer="care-month-dashboard"
+                                               title="Care Month"
+                                               :href="'/patients/view/' + claim.client_uid + '/care-months/view/' + claim.care_month_uid">
+                                                View Care Month
+                                            </a>
+<!--                                            <span class="ml-1 text-secondary">(@{{ claim.method }})</span>-->
+                                        </div>
+                                    </div>
+
                                     <hr class="my-2">
 
                                     <!--total-->

+ 144 - 66
resources/views/app/practice-management/processing-bill-matrix.blade.php

@@ -6,91 +6,112 @@
 
         <div class="card">
 
-            <div class="card-header px-3 py-2 d-flex align-items-center">
-                <strong class="text-nowrap">
+            <div class="card-header px-3 py-2">
+                <div class="font-weight-bold text-nowrap mb-2">
                     <i class="fas fa-user-injured"></i>
                     Processing Bills
-                </strong>
-                <span class="mx-2">for</span>
-                <div class="width-200px">
-                    <select provider-search data-pro-uid="{{ @$targetPro->uid }}"
-                            name="proUid" class="form-control form-control-sm mr-auto width-200px min-width-unset"
-                            onchange="fastLoad('/practice-management/processing-bill-matrix/' + this.value + '?f={{request()->input('f')}}&t={{request()->input('t')}}&bs={{request()->input('bs')}}&be={{request()->input('be')}}')">
-                        <option value="" {{!@$targetPro ? 'selected' : ''}}>All Pros</option>
-                    </select>
                 </div>
-                @if(@$targetPro)
-                    <a href="/practice-management/processing-bill-matrix" class="ml-2">Clear Filter</a>
-                @endif
-                <div class="width-100px ml-2">
-                    <select name="filter" class="form-control form-control-sm mr-auto width-100px"
-                            onchange="fastLoad('/practice-management/processing-bill-matrix/{{@$targetPro ? $targetPro->uid : ''}}?f=' + this.value + '&t={{request()->input('t')}}&bs={{request()->input('bs')}}&be={{request()->input('be')}}')">
-                        <option {{request()->input('f') === '' ? 'selected' : ''}} value="">All Bills</option>
-                        <option {{request()->input('f') === 'verified' ? 'selected' : ''}} value="verified">Verified
-                            Only
-                        </option>
-                        <option {{request()->input('f') === 'not-verified' ? 'selected' : ''}} value="not-verified">Not
-                            Verified Only
-                        </option>
-                    </select>
+                <div class="d-flex align-items-center mb-2">
+                    <div class="width-200px">
+                        <select provider-search data-pro-uid="{{ @$targetPro->uid }}"
+                                name="proUid" class="form-control form-control-sm mr-auto width-200px min-width-unset"
+                                onchange="return billsFilter('', this.value, true)">
+                            <option value="" {{!@$targetPro ? 'selected' : ''}}>All Pros</option>
+                        </select>
+                    </div>
+                    <div class="width-300px ml-2 d-inline-flex">
+                        <select name="filter" class="form-control form-control-sm min-width-unset flex-grow-1"
+                                onchange="return billsFilter('f', this.value)">
+                            <option {{request()->input('f') === '' ? 'selected' : ''}} value="">All Bills</option>
+                            <option {{request()->input('f') === 'verified' ? 'selected' : ''}} value="verified">Verified
+                                Only
+                            </option>
+                            <option {{request()->input('f') === 'not-verified' ? 'selected' : ''}} value="not-verified">Not
+                                Verified Only
+                            </option>
+                        </select>
+                        <select name="filter" class="form-control form-control-sm min-width-unset flex-grow-1 ml-2"
+                                onchange="return billsFilter('t', this.value)">
+                            <option {{!request()->input('t') || request()->input('t') === 'hcp' ? 'selected' : ''}} value="hcp">
+                                HCP Bills
+                            </option>
+                            <option {{request()->input('t') === 'na' ? 'selected' : ''}} value="na">NA Bills</option>
+                        </select>
+                    </div>
+                    <div class="ml-4 d-inline-flex align-items-center">
+                        <span class="mr-2">Bal Post Date</span>
+                        <input type="date"
+                               value="{{request()->input('bs')}}"
+                               onchange="return billsFilter('bs', this.value)"
+                               class="form-control form-control-sm width-150px" name="bpdFrom">
+                        <span class="mx-2">to</span>
+                        <input type="date"
+                               value="{{request()->input('be')}}"
+                               onchange="return billsFilter('be', this.value)"
+                               class="form-control form-control-sm width-150px" name="bpdTo">
+                    </div>
+                    <button class="ml-auto btn btn-sm btn-primary pay-selected-pros px-3 font-weight-bold" disabled>Pay Selected</button>
                 </div>
-                <div class="width-100px ml-2">
-                    <select name="filter" class="form-control form-control-sm mr-auto width-100px"
-                            onchange="fastLoad('/practice-management/processing-bill-matrix/{{@$targetPro ? $targetPro->uid : ''}}?f={{request()->input('f')}}&bs={{request()->input('bs')}}&be={{request()->input('be')}}&t=' + this.value)">
-                        <option {{!request()->input('t') || request()->input('t') === 'hcp' ? 'selected' : ''}} value="hcp">
-                            HCP Bills
-                        </option>
-                        <option {{request()->input('t') === 'na' ? 'selected' : ''}} value="na">NA Bills</option>
+                <div class="d-flex align-items-center">
+                    <select name="filter" class="form-control form-control-sm width-200px"
+                            onchange="return billsFilter('c', this.value)">
+                        <option {{!request()->input('c') ? 'selected' : ''}} value="">All Companies</option>
+                        @foreach($companies as $company)
+                            <option {{request()->input('c') == $company->id ? 'selected' : ''}}
+                                    value="{{$company->id}}">
+                                {{$company->name}}
+                            </option>
+                        @endforeach
                     </select>
+                    <select name="filter" class="form-control form-control-sm width-300px ml-2 "
+                            onchange="return billsFilter('s', this.value)">
+                        <option {{!request()->input('s') ? 'selected' : ''}} value="">All Services</option>
+                        @foreach($codes as $code)
+                            <option {{request()->input('s') == $code->code ? 'selected' : ''}}
+                                    value="{{$code->code}}">
+                                {{$code->code}}
+                            </option>
+                        @endforeach
+                    </select>
+                    @if(@$targetPro || count(array_filter(request()->all(), function($_x) { return !!$_x && $_x !== 'na' && $_x !== 'hcp';})))
+                        <a href="/practice-management/processing-bill-matrix" class="ml-4">Clear Filters</a>
+                    @endif
                 </div>
-                <div class="ml-3 d-inline-flex align-items-center">
-                    <b class="mr-2">Bal Post Date</b>
-                    <input type="date"
-                           value="{{request()->input('bs')}}"
-                           onchange="fastLoad('/practice-management/processing-bill-matrix/{{@$targetPro ? $targetPro->uid : ''}}?f={{request()->input('f')}}&t={{request()->input('t')}}&be={{request()->input('be')}}&bs=' + this.value)"
-                           class="form-control form-control-sm width-150px" name="bpdFrom">
-                    <span class="mx-2">to</span>
-                    <input type="date"
-                           value="{{request()->input('be')}}"
-                           onchange="fastLoad('/practice-management/processing-bill-matrix/{{@$targetPro ? $targetPro->uid : ''}}?f={{request()->input('f')}}&t={{request()->input('t')}}&bs={{request()->input('bs')}}&be=' + this.value)"
-                           class="form-control form-control-sm width-150px" name="bpdTo">
-                </div>
-                <button class="ml-auto btn btn-sm btn-primary pay-selected-pros px-3 font-weight-bold" disabled>Pay Selected</button>
             </div>
             <div class="card-body p-0">
                 <table class="table table-sm table-condensed table-hover p-0 m-0">
                     <thead class="bg-light">
                     <tr>
-                        <th>
+                        <th class="border-bottom-0 border-top-0">
                             <label class="d-flex align-items-center m-0">
                                 <input type="checkbox" class="chk-all-bills" /> <span class="ml-2">All</span>
                             </label>
                         </th>
-                        <th>Context</th>
-                        <td>Effective Date</td>
-                        <td>Balance Post Date</td>
+                        <th class="border-bottom-0 border-top-0">Context</th>
+                        <th class="border-bottom-0 border-top-0">Effective Date</th>
+                        <th class="border-bottom-0 border-top-0">Bal Post Date</th>
                         @if(!request()->input('t') || request()->input('t') === 'hcp')
-                            <td>HCP Pro</td>
+                            <th class="border-bottom-0 border-top-0">HCP Pro</th>
                         @elseif(request()->input('t') === 'na')
-                            <td>NA Pro</td>
+                            <th class="border-bottom-0 border-top-0">NA Pro</th>
                         @endif
-                        <td>Client</td>
-                        <td>Code</td>
-                        <td>Units</td>
-                        <td>Verified?</td>
+                        <th class="border-bottom-0 border-top-0">Client</th>
+                        <th class="border-bottom-0 border-top-0">Code</th>
+                        <th class="border-bottom-0 border-top-0">Units</th>
+                        <th class="border-bottom-0 border-top-0">Verified?</th>
                         @if(!request()->input('t') || request()->input('t') === 'hcp')
-                            <td>HCP Expected Amount</td>
+                            <th class="border-bottom-0 border-top-0">HCP Expected Amount</th>
                         @elseif(request()->input('t') === 'na')
-                            <td>NA Expected Amount</td>
+                            <th class="border-bottom-0 border-top-0">NA Expected Amount</th>
                         @endif
-                        <td>Pro Signed?</td>
-                        <td></td>
+                        <th class="border-bottom-0 border-top-0">Pro Signed?</th>
+                        <th class="border-bottom-0 border-top-0"></th>
                     </tr>
                     </thead>
                     <tbody>
                     @foreach ($bills as $row)
                         <tr>
-                            <td class="align-middle">
+                            <td class="align-top">
                                 @if($row->is_verified)
                                     <input type="checkbox" data-uid="{{$row->uid}}" class="chk-bill align-middle" />
                                 @endif
@@ -110,19 +131,34 @@
                             </td>
                             <td>{{friendly_date($row->effective_date)}}</td>
                             <td>{{friendly_date($row->balance_post_date)}}</td>
-                            @if(!request()->input('t') || request()->input('t') === 'hcp')
-                                <td>{{$row->hcp->name_last}}, {{$row->hcp->name_first}}</td>
-                            @elseif(request()->input('t') === 'na')
-                                <td>{{$row->genericPro->name_last}}, {{$row->genericPro->name_first}}</td>
-                            @endif
+                            <td>
+                                @if(!request()->input('t') || request()->input('t') === 'hcp')
+                                    {{$row->hcp->name_last}}, {{$row->hcp->name_first}}
+                                    <div class="mt-1 text-sm text-secondary font-weight-bold">
+                                        <i class="fa fa-hospital mr-1"></i>
+                                        {{$row->hcpCompanyPro->company->name}}
+                                    </div>
+                                @elseif(request()->input('t') === 'na')
+                                    {{$row->genericPro->name_last}}, {{$row->genericPro->name_first}}
+                                    <div class="mt-1 text-sm text-secondary font-weight-bold">
+                                        <i class="fa fa-hospital mr-1"></i>
+                                        {{$row->genericCompanyPro->company->name}}
+                                    </div>
+                                @endif
+
+                            </td>
                             <td>
                                 @if($row->client)
                                     {{$row->client->name_last}}, {{$row->client->name_first}}
                                 @endif
                             </td>
-                            <td>{{$row->code}}</td>
+                            <td>{{$row->code}}
+                                @if($row->generic_target_entity_type && $row->generic_target_entity_uid)
+                                    <div class="mt-1 text-sm text-secondary font-weight-bold">{{$row->generic_target_entity_type}}</div>
+                                @endif
+                            </td>
                             <td>{{str_contains($row->code, 'Treatment Services') || str_contains($row->code, 'Administrative Services') ? ceil((float) $row->number_of_units * 60) . ' mins' : $row->number_of_units}}</td>
-                            <td>{{$row->is_verified ? 'Verified: ' . friendly_date($row->marked_verified_at, true) : 'Not Verified'}} </td>
+                            <td>{!! $row->is_verified ? 'Yes<br>' . friendly_date($row->marked_verified_at, true) : 'No' !!} </td>
                             @if(!request()->input('t') || request()->input('t') === 'hcp')
                                 <td><b>${{$row->hcp_expected_payment_amount}}</b></td>
                             @elseif(request()->input('t') === 'na')
@@ -150,6 +186,48 @@
     </div>
     <script>
         (function() {
+            window.billsFilter = function(_key, _value, _isClient = false) {
+
+                <?php
+                $keys = ['f', 'bs', 'be', 't', 'c', 's'];
+                $currentParams = [];
+                for($i = 0; $i < count($keys); $i++) {
+                    if(!!request()->input($keys[$i])) {
+                        $currentParams[$keys[$i]] = request()->input($keys[$i]);
+                    }
+                }
+                ?>
+
+                let targetProUid = _isClient ? _value : $('[provider-search]').attr('data-pro-uid'),
+                    base = '/practice-management/processing-bill-matrix' + (targetProUid ? '/' + targetProUid : ''),
+                    keys = ['f', 'bs', 'be', 't', 'c', 's'].filter(_x => _x !== _key),
+                    currentParams = {!! json_encode($currentParams) !!},
+                    url = [];
+
+                // base
+                url.push(base);
+                url.push('?');
+
+                // params
+                let getParams = [];
+                for (let i = 0; i < keys.length; i++) {
+                    if(currentParams[keys[i]]) {
+                        getParams.push(keys[i] + '=' + encodeURIComponent(currentParams[keys[i]]));
+                    }
+                }
+
+                // new params
+                getParams.push(_key + '=' + encodeURIComponent(_value));
+
+                // generate url
+                url.push(getParams.join('&'));
+
+                // go
+                fastLoad(url.join(''));
+
+                return false;
+            };
+
             function init() {
                 $('.pay-bill')
                     .off('click')

+ 84 - 0
resources/views/app/practice-management/rm-launch-and-clean.blade.php

@@ -0,0 +1,84 @@
+@extends ('layouts/template')
+
+@section('content')
+    <div id="rm-launch-and-clean" class="p-3 mcp-theme-1">
+        <div class="d-flex align-items-end mb-3">
+            <div class="font-weight-bold font-size-14 text-secondary">
+                RM - Launch &amp; Clean
+            </div>
+        </div>
+        <table class="table table-striped table-condensed table-bordered table-sm width-300px">
+            <tbody>
+            <tr>
+                <td class="text-nowrap">Care Months Eligible For <b>RM30 HCP + NonHCP 40</b></td>
+                <td class="text-success font-weight-bold px-3">{{$keyNumbers['careMonthsEligibleForBillGeneration_RM30_HCP_PLUS_NONHCP40']}}</td>
+            </tr>
+            <tr>
+                <td class="text-nowrap">Care Months Eligible For <b>RM30 HCP + NonHCP 20</b></td>
+                <td class="text-success font-weight-bold px-3">{{$keyNumbers['careMonthsEligibleForBillGeneration_RM30_HCP_PLUS_NONHCP20']}}</td>
+            </tr>
+            <tr>
+                <td class="text-nowrap">Care Months Eligible For <b>RM30 HCP Only</b></td>
+                <td class="text-success font-weight-bold px-3">{{$keyNumbers['careMonthsEligibleForBillGeneration_RM30_HCP']}}</td>
+            </tr>
+            <tr>
+                <td>Care Months Without Company/Pro Info</td>
+                <td class="text-warning-mellow font-weight-bold">{{$keyNumbers['careMonthsWithoutCompanyProInfo']}}</td>
+            </tr>
+            {{--
+            <tr>
+                <td>Care Months Without RM Reasons</td>
+                <td class="text-warning-mellow font-weight-bold">{{$keyNumbers['careMonthsWithoutRMReasons']}}</td>
+            </tr>
+            --}}
+            <tr>
+                <td>Care Months Under 30 RM Minutes</td>
+                <td class="text-warning-mellow font-weight-bold">{{$keyNumbers['careMonthsUnder30RMMinutes']}}</td>
+            </tr>
+            </tbody>
+        </table>
+        <div class="d-flex align-items-center">
+            <button class="btn btn-sm btn-primary btn-launch px-3 font-weight-bold mr-3"
+                    {{@$keyNumbers['careMonthsEligibleForBillGeneration_RM30_HCP_PLUS_NONHCP40'] ? '' : 'disabled'}}
+                    {{@$keyNumbers['careMonthsEligibleForBillGeneration_RM30_HCP_PLUS_NONHCP40'] ? '' : 'perm-disabled'}}
+                    data-ep="rm-admin-launcher-rm30-hcp-plus-40">Generate RM-30 HCP PLUS NONHCP-40 ({{@$keyNumbers['careMonthsEligibleForBillGeneration_RM30_HCP_PLUS_NONHCP40']}})
+            </button>
+            <button class="btn btn-sm btn-primary btn-launch px-3 font-weight-bold mr-3"
+                    {{@$keyNumbers['careMonthsEligibleForBillGeneration_RM30_HCP_PLUS_NONHCP20'] ? '' : 'disabled'}}
+                    {{@$keyNumbers['careMonthsEligibleForBillGeneration_RM30_HCP_PLUS_NONHCP20'] ? '' : 'perm-disabled'}}
+                    data-ep="rm-admin-launcher-rm30-hcp-plus-20">Generate RM-30 HCP PLUS NONHCP-20 ({{@$keyNumbers['careMonthsEligibleForBillGeneration_RM30_HCP_PLUS_NONHCP20']}})
+            </button>
+            <button class="btn btn-sm btn-primary btn-launch px-3 font-weight-bold mr-3"
+                    {{@$keyNumbers['careMonthsEligibleForBillGeneration_RM30_HCP'] ? '' : 'disabled'}}
+                    {{@$keyNumbers['careMonthsEligibleForBillGeneration_RM30_HCP'] ? '' : 'perm-disabled'}}
+                    data-ep="rm-admin-launch-rm30-hcp">Generate RM-30 HCP ({{@$keyNumbers['careMonthsEligibleForBillGeneration_RM30_HCP']}})
+            </button>
+        </div>
+        <div class="my-3 text-secondary text-sm text-monospace launch-result" style="white-space: pre;">
+
+        </div>
+    </div>
+    <script>
+        (function() {
+            function init() {
+                $('.btn-launch')
+                    .off('click')
+                    .on('click', function () {
+                        $('.launch-result').text('Please wait...');
+                        $('.btn-launch').prop('disabled', true);
+                        $.get('/api/careMonth/' + $(this).attr('data-ep'), _data => {
+                            if(!hasResponseError(_data)) {
+                                if(_data.data && _data.data.length) {
+                                    $('.launch-result').text(_data.data.join("\n"));
+                                }
+                            }
+                        }, 'json')
+                        .then(() => {
+                            $('.btn-launch:not([perm-disabled])').prop('disabled', false);
+                        });
+                    });
+            }
+            addMCInitializer('rm-launch-and-clean', init, '#rm-launch-and-clean');
+        }).call(window);
+    </script>
+@endsection

+ 1 - 0
routes/web.php

@@ -96,6 +96,7 @@ Route::middleware('pro.auth')->group(function () {
 
         Route::get('cellular-device-manager/{proUid?}', 'PracticeManagementController@cellularDeviceManager')->name('cellularDeviceManager');
 
+        Route::get('rm-launch-and-clean', 'PracticeManagementController@rmLaunchAndClean')->name('rm-launch-and-clean');
         Route::get('process-claims', 'PracticeManagementController@processClaims')->name('process-claims');
         Route::get('process-notes', 'PracticeManagementController@processNotes')->name('process-notes');
         Route::get('picked-notes', 'PracticeManagementController@pickedNotes')->name('picked-notes');