Vijayakrishnan 3 лет назад
Родитель
Сommit
7b5973fee2

+ 2 - 2
app/Models/CareMonth.php

@@ -117,11 +117,11 @@ class CareMonth extends Model
 
     public function mcpRmGenericBill()
     {
-        return $this->hasOne(Bill::class, 'id', 'mcp_rm_generic_bill_id');
+        return $this->hasOne(Bill::class, 'id', 'mcp_rm_generic_bill_id')->where('is_cancelled', false)->where('is_cancelled_by_administrator', false);
     }
     public function rmmRmGenericBill()
     {
-        return $this->hasOne(Bill::class, 'id', 'rmm_rm_generic_bill_id');
+        return $this->hasOne(Bill::class, 'id', 'rmm_rm_generic_bill_id')->where('is_cancelled', false)->where('is_cancelled_by_administrator', false);
     }
 
     public function showMeasurementDaysWarning(){

+ 274 - 0
resources/views/app/generic-bills/inline-for-cm.blade.php

@@ -0,0 +1,274 @@
+<?php
+
+use App\Models\Note;
+use App\Models\Pro;
+use App\Models\Client;
+
+/** @var Note $note */
+/** @var Pro $genericPro */
+/** @var Pro $pro */
+/** @var Client $patient */
+/** @var $entityType */
+/** @var $entityUid */
+
+$genericBills = genericBills($pro, @$patient, @$entityType, @$entityUid);
+?>
+
+@if(!count($genericBills))
+    <div class="{{@$class ? $class : ''}} d-flex align-items-center">
+        <p class="font-weight-bold mb-0">No {{@$label ? $label : 'Admin.'}} Bills</p>
+    </div>
+@else
+    <div class="{{@$class ? $class : ''}}">
+        <div class="d-flex align-items-center mb-2">
+            <p class="font-weight-bold m-0">{{@$label ? $label : 'Admin.'}} Bills</p>
+        </div>
+            <table class="table table-sm table-striped mb-0 table-bordered">
+                <thead class="bg-light">
+                <tr class="text-secondary">
+                    <th class="border-bottom-0">Date</th>
+                    <th class="border-bottom-0">Pro</th>
+                    <th class="border-bottom-0 screen-only">Total</th>
+                    <th class="border-bottom-0">Sign</th>
+                    <th class="border-bottom-0">Cancellation</th>
+                    <th class="border-bottom-0">Verification</th>
+                    @if($pro->pro_type === 'ADMIN')
+                    <th class="border-bottom-0 screen-only">Payment</th>
+                    @endif
+                </tr>
+                </thead>
+                <tbody>
+                @foreach ($genericBills as $bill)
+                    <tr class="{{$bill->is_cancelled ? 'bg-light text-secondary' : ''}}">
+                        <td class="text-nowrap">{{friendlier_date_time($bill->effective_date ?: $bill->created_at, false)}}</td>
+                        <td class="">
+                            <div class="text-nowrap font-weight-bold text-secondary">{{ $bill->genericPro->displayName() }}</div>
+                            <div class="text-nowrap mt-1 screen-only">
+                                <span class="text-secondary">Paid: </span>
+                                <span>{{ $bill->has_generic_pro_been_paid ? 'Yes' : 'No' }}</span>
+                            </div>
+                            @if(!$bill->has_generic_pro_been_paid)
+                                <div class="text-nowrap mt-1 screen-only">
+                                    <span class="text-secondary">Expected: </span>
+                                    <span class="font-weight-bold">${{ round($bill->total_expected, 2) }}</span>
+                                </div>
+                            @else
+                                <div class="text-nowrap mt-1 screen-only">
+                                    <span class="text-secondary">Amount: </span>
+                                    <span class="font-weight-bold">${{ round($bill->total_paid, 2) }}</span>
+                                </div>
+                            @endif
+                            <div class="mt-1">
+                                Company Pro: <b>{{$bill->genericCompanyPro ? $bill->genericCompanyPro->company->name : '-'}}</b>
+                            </div>
+                            <div moe class="">
+                                <a class="text-primary" href="" show start>Swap Company Pro</a>
+                                <form url="/api/bill/swapGenericCompanyPro">
+                                    <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                    <div class="mb-2">
+                                        <select name="genericCompanyProUid" class="form-control form-control-sm">
+                                            <option value="">-- select --</option>
+                                            @foreach($bill->genericPro->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-default border btn-sm" cancel>Cancel</button>
+                                    </div>
+                                </form>
+                            </div>
+                        </td>
+                        <td class="pr-3 screen-only text-nowrap">
+                            @if($bill->has_generic_pro_been_paid)
+                                <span class="text-secondary">Paid. </span>
+                                <span class="font-weight-bold">${{ round($bill->total_paid, 2) }}</span>
+                            @else
+                                <span class="text-secondary">Exp. </span>
+                                <span class="font-weight-bold">{{ $bill->total_expected ? '$' . round($bill->total_expected, 2) : '-' }}</span>
+                            @endif
+                        </td>
+                        <td>
+                            @if(!$bill->is_cancelled)
+                                @if($bill->is_signed_by_generic_pro)
+                                    <div class="d-block text-secondary text-nowrap">
+                                        <i class="fa fa-check"></i>
+                                        Signed
+                                    </div>
+                                @else
+                                    <div moe
+                                          class="d-block {{ $bill->generic_pro_id !== $pro->id ? 'moe-disabled' : '' }}"
+                                          title="{{ $bill->generic_pro_id !== $pro->id ? 'Only the bill\'s pro can sign' : '' }}">
+                                        <a class="text-nowrap" href="" show start>Sign</a>
+                                        <form url="/api/bill/signAsGenericPro">
+                                            <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                            <p>Sign this bill?</p>
+                                            <div class="mb-0">
+                                                <button class="btn btn-success btn-sm" submit>Sign</button>
+                                                <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                            </div>
+                                        </form>
+                                    </div>
+                                @endif
+                            @endif
+                        </td>
+                        <td>  <!-- cancellation -->
+                            @if($bill->is_cancelled)
+                                <div class="text-warning-mellow font-weight-bold">Cancelled</div>
+                                @if($bill->cancellation_memo)
+                                    <div class="text-dark text-sm font-italic my-1">{{$bill->cancellation_memo}}</div>
+                                @endif
+                                @if($bill->is_cancelled_by_administrator)
+                                    <div class="text-secondary text-sm text-nowrap">(by Administrator)</div>
+                                @endif
+                                <div moe class="mt-1">
+                                    <a class="text-nowrap" href="" show start>Update Memo</a>
+                                    <form url="/api/bill/updateCancellationMemo">
+                                        <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                        <p>Update Cancellation Memo</p>
+                                        <div class="mb-2">
+                                            <textarea class="text form-control form-control-sm" name="cancellationMemo"
+                                                      placeholder="">{{$bill->cancellation_memo ? $bill->cancellation_memo : ($pro->pro_type === 'ADMIN' ? 'Please contact billing.' : '')}}</textarea>
+                                        </div>
+                                        <div>
+                                            <button class="btn btn-success btn-sm" submit>Submit</button>
+                                            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                        </div>
+                                    </form>
+                                </div>
+                            @else
+                                <div class="d-block" moe relative="">
+                                    <a class="text-danger" href="" show start>Cancel</a>
+                                    <form url="/api/bill/markCancelled" right="">
+                                        <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                        <p class="mb-2">Cancel this bill?</p>
+                                        <div class="mb-2">
+                                            <label class="mb-1 text-secondary">Cancellation Memo</label>
+                                            <textarea type="text" name="memo" placeholder="Memo" class="form-control form-control-sm">@if($pro->pro_type === 'ADMIN')Please contact billing.@endif</textarea>
+                                        </div>
+                                        <div class="mb-0">
+                                            <button class="btn btn-danger btn-sm" submit>Yes</button>
+                                            <button class="btn btn-default border btn-sm" cancel>No</button>
+                                        </div>
+                                    </form>
+                                </div>
+                            @endif
+
+                            @if($bill->is_cancelled && !$bill->is_cancellation_acknowledged)
+                                <div class="mt-2 text-secondary text-nowrap">
+                                    <i class="fa fa-exclamation-triangle"></i>
+                                    Not Ack.
+                                </div>
+                                <div class="d-block mt-1" moe>
+                                    <a class="text-nowrap" href="" show start>Ack. Cancellation</a>
+                                    <form url="/api/bill/acknowledgeCancellation">
+                                        <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                        <p>Acknowledge Cancellation?</p>
+                                        <div class="mb-0">
+                                            {{--<input type="text" class="text form-control form-control-sm" name="cancellationMemo" value="{{$bill->cancellation_memo}}" placeholder=""><br>--}}
+                                            <button class="btn btn-primary btn-sm" submit>Submit</button>
+                                            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                        </div>
+                                    </form>
+                                </div>
+                            @endif
+
+                            @if($bill->is_cancellation_acknowledged)
+                                <div class="mt-2 text-secondary">
+                                    <i class="fa fa-check"></i>
+                                    Ack.
+                                </div>
+                                <div class="d-block mt-1" moe>
+                                    <a class="text-nowrap" href="" show start>Undo Cancellation Ack.</a>
+                                    <form url="/api/bill/undoAcknowledgeCancellation">
+                                        <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                        <p>Undo Acknowledge Cancellation?</p>
+                                        <div class="mb-0">
+                                            <button class="btn btn-success btn-sm" submit>Submit</button>
+                                            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                        </div>
+                                    </form>
+                                </div>
+                            @endif
+
+                        </td>
+                        @if($pro->pro_type === 'ADMIN')
+                        <td> <!-- verification -->
+                            @if(!$bill->genericCompanyPro)
+                                <div class="mb-1 text-danger">
+                                    <i class="fa fa-exclamation-triangle"></i>
+                                    Company Pro isn't set on the bill
+                                </div>
+                            @else
+                                @if(!$bill->is_cancelled)
+                                    @if(!$bill->is_verified)
+                                        <div class="text-warning-mellow font-weight-bold text-nowrap">Not Verified</div>
+                                        <div class="d-block mt-1" moe>
+                                            <a href="" show start>Mark Verified</a>
+                                            <form url="/api/bill/markAsVerified">
+                                                <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                <p>Mark As Verified?</p>
+                                                <div class="mb-0">
+                                                    <button class="btn btn-success btn-sm" submit>Submit</button>
+                                                    <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                </div>
+                                            </form>
+                                        </div>
+                                    @else
+                                        <div class="text-success font-weight-bold"><i class="fa fa-check"></i> Verified</div>
+                                        <div class="d-block mt-1" moe>
+                                            <a class="" href="" show start>Undo</a>
+                                            <form url="/api/bill/undoMarkAsVerified">
+                                                <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                <p>Undo Mark As Verified?</p>
+                                                <div class="mb-0">
+                                                    <button class="btn btn-success btn-sm" submit>Submit</button>
+                                                    <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                </div>
+                                            </form>
+                                        </div>
+                                    @endif
+                                @endif
+                            @endif
+                        </td>
+                        <td class="screen-only"> <!-- submit payment -->
+                            <div class="my-1">
+                                @if(!$bill->is_cancelled && !$bill->has_generic_pro_been_paid )
+                                    @if(+$bill->total_expected && $bill->is_signed_by_generic_pro)
+                                        <div class="d-block" moe relative="">
+                                            <a class="font-weight-bold text-nowrap" href="" show start>Submit Payment</a>
+                                            <form url="/api/bill/payGenericProAmount" right>
+                                                <input type="hidden" name="uid" value="{{$bill->uid}}">
+                                                <p>Submit Payment</p>
+                                                <div class="mb-0">
+                                                    <input type="text" class="text form-control form-control-sm" name="genericProPaymentAmount" value="{{$bill->total_expected}}" placeholder="amount"><br>
+                                                    <button class="btn btn-success btn-sm" submit>Submit</button>
+                                                    <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                                </div>
+                                            </form>
+                                        </div>
+                                    @else
+                                        @if(!+$bill->total_expected)
+                                            <div class="mb-1 text-danger">
+                                                <i class="fa fa-exclamation-triangle"></i>
+                                                Pro expected amount is invalid
+                                            </div>
+                                        @endif
+                                        @if(!$bill->is_signed_by_generic_pro)
+                                            <div class="mb-1 text-danger">
+                                                <i class="fa fa-exclamation-triangle"></i>
+                                                Pro has not signed the bill
+                                            </div>
+                                        @endif
+                                    @endif
+                                @endif
+                            </div>
+                        </td>
+                        @endif
+                    </tr>
+                @endforeach
+                </tbody>
+            </table>
+    </div>
+@endif

+ 23 - 405
resources/views/app/patient/care-month/dashboard.blade.php

@@ -321,13 +321,9 @@
                                     @include('app.practice-management.care_month_add_entry_form')
                                 </div>
 
-                                <div class="mt-2">
-                                    {{-- rm reasons --}}
-                                    <div class="mb-2">
-                                        @include('app/patient/care-month/rm-reasons')
-                                    </div>
-                                </div>
-
+                                <div class="mt-2 d-flex align-items-baseline">
+                                    <span class="font-weight-bold text-secondary mr-1">Billing:</span>
+                                    <div>
                                 @if($careMonth->mcpRmGenericBill == null )
                                     
                                     @php 
@@ -338,8 +334,8 @@
                                         <div class="alert alert-info">{{$rpmBillability['reason']}}</div>
                                     @else 
                                         <div moe relative class="d-inline-block">
-                                            <a class="font-weight-bold" href="" show start>Bill for {{$rpmBillability['amount']}}</a>
-                                            <form url="/api/careMonth/generateRmGenericBillForMcpAndAutoSign" right>
+                                            <a class="font-weight-bold" href="" show start>Bill ${{$rpmBillability['amount']}}</a>
+                                            <form url="/api/careMonth/generateRmGenericBillForMcpAndAutoSign">
                                                 <input type="hidden" name="uid" value="{{$careMonth->uid}}">
                                                 <p>Bill ${{$rpmBillability['amount']}} for this care month?</p>
                                                 <div class="mb-0">
@@ -350,12 +346,13 @@
                                         </div>   
                                     @endif
                                 @else 
-                                    <div class="font-weight-bold">
-                                        Billed: ${{$careMonth->mcpRmGenericBill->generic_pro_expected_payment_amount}} 
+                                    <div class="font-weight-bold text-success d-inline-flex align-items-baseline">
+                                        <i class="fa fa-check mr-1"></i>
+                                        <span>Billed: ${{$careMonth->mcpRmGenericBill->generic_pro_expected_payment_amount}}</span>
                                         @if($careMonth->mcpRmGenericBill->is_signed_by_generic_pro)
-                                            <span class="text-success"><i class="fa fa-check"></i> Signed </span>
+                                            <span class="text-success ml-1 text-sm">(Signed)</span>
                                         @else 
-                                            <div moe relative class="d-inline-block">
+                                            <div moe relative class="d-inline-block text-sm ml-2">
                                                 <a class="font-weight-bold" href="" show start>Sign</a>
                                                 <form url="/api/bill/signAsGenericPro" right>
                                                     <input type="hidden" name="uid" value="{{$careMonth->mcpRmGenericBill->uid}}">
@@ -369,6 +366,15 @@
                                         @endif 
                                     </div>
                                 @endif
+                                    </div>
+                                </div>
+
+                                <div class="mt-2">
+                                    {{-- rm reasons --}}
+                                    <div class="mb-2">
+                                        @include('app/patient/care-month/rm-reasons')
+                                    </div>
+                                </div>
                             </div>
                         </div>
                     </div>
@@ -906,403 +912,15 @@
 
         @if($careMonth->number_of_days_with_remote_measurements >= 16)
 
-            <hr class="m-negator mt-4 mb-3">
+            <hr class="m-negator mt-4 mb-0">
 
             {{-- bills --}} {{-- only admins --}}
             @if($pro->pro_type === 'ADMIN')
-                @if($careMonth->bills->count())
-                    <div class="">
-                        <div class="d-flex align-items-center mb-2">
-                            <p class="font-weight-bold font-size-13 m-0">RM Bills</p>
-                            @include('app/patient/care-month/_create-bill')
-                        </div>
-
-                        @if($pro->pro_type === 'ADMIN')
-                            <table class="table table-sm tabe-striped mb-0 table-bordered">
-                                <thead class="bg-light">
-                                <tr class="text-secondary">
-                                    <th class="border-bottom-0">Date</th>
-                                    <th class="border-bottom-0">Service</th>
-                                    <th class="border-bottom-0">Billable</th>
-                                    <th class="border-bottom-0">Pro</th>
-                                    <th class="border-bottom-0">Total</th>
-                                    <th class="border-bottom-0">Sign</th>
-                                    <th class="border-bottom-0">Bal Post Date</th>
-                                    <th class="border-bottom-0">Verification</th>
-                                    <th class="border-bottom-0">Cancellation</th>
-                                    <th class="border-bottom-0">Payment</th>
-                                </tr>
-                                </thead>
-                                <tbody>
-                                @foreach ($careMonth->bills as $bill)
-                                    <tr class="{{$bill->is_cancelled ? 'bg-light text-secondary' : ''}}">
-                                        <td class="text-nowrap">{{friendlier_date_time($bill->careMonth->end_date, false)}}</td>
-                                        <td>{{$bill->code}} {{$bill->cm_or_rm}} {{$bill->is_cancelled}}</td>
-                                        <td class="">
-                                            @if(strpos(strtolower($bill->code), 'treatment services') !== FALSE)
-                                                <?php
-                                                $totalSeconds = $bill->number_of_units * 3600;
-                                                $remainder = $totalSeconds % 60;
-                                                if ($remainder !== 0) {
-                                                    if ($remainder < 30) {
-                                                        $totalSeconds = $totalSeconds - $remainder;
-                                                    }
-                                                    else {
-                                                        $totalSeconds = $totalSeconds + (60 - $remainder);
-                                                    }
-                                                }
-                                                ?>
-                                                {{ time_in_hrminsec($totalSeconds) }}
-                                            @else
-                                                @if(!!$bill->number_of_units)
-                                                    {{ $bill->number_of_units }} unit(s)
-                                                @else
-                                                    -
-                                                @endif
-                                            @endif
-                                        </td>
-                                        <td class="">
-                                            <div class="text-nowrap font-weight-bold text-secondary">{{ $bill->genericPro ? $bill->genericPro->displayName() : '' }} (HCP)</div>
-                                            <div class="text-nowrap mt-1">
-                                                <span class="text-secondary">Paid: </span>
-                                                <span>{{ $bill->has_generic_pro_been_paid ? 'Yes' : 'No' }}</span>
-                                            </div>
-                                            @if(!$bill->has_hcp_been_paid)
-                                                <div class="text-nowrap mt-1">
-                                                    <span class="text-secondary">Expected: </span>
-                                                    <span class="font-weight-bold">${{ $bill->generic_pro_expected_payment_amount }}</span>
-                                                </div>
-                                            @else
-                                                <div class="text-nowrap mt-1">
-                                                    <span class="text-secondary">Amount: </span>
-                                                    <span class="font-weight-bold">${{ $bill->generic_pro_payment_amount }}</span>
-                                                </div>
-                                            @endif
-                                        </td>
-                                        <td class="pr-3">
-                                            @if($bill->has_hcp_been_paid)
-                                                <span class="text-secondary">Paid. </span>
-                                                <span class="font-weight-bold">${{ friendly_money($bill->total_paid) }}</span>
-                                            @else
-                                                <span class="text-secondary">Exp. </span>
-                                                <span class="font-weight-bold">{{ $bill->total_expected ? '$' . friendly_money($bill->total_expected) : '-' }}</span>
-                                            @endif
-                                        </td>
-                                        <td>
-                                            @if(!$bill->is_cancelled)
-                                                @if($bill->is_signed_by_generic_pro)
-                                                    <span class="d-block text-secondary text-nowrap">
-                                                            <i class="fa fa-check"></i>
-                                                            Pro Signed
-                                                        </span>
-                                                @else
-                                                    <span moe
-                                                          class="d-block {{ $bill->hcp_pro_id !== $pro->id && $pro->pro_type !== 'ADMIN' ? 'moe-disabled' : '' }}"
-                                                          title="{{ $bill->hcp_pro_id !== $pro->id  && $pro->pro_type !== 'ADMIN' ? 'Only the bill\'s Pro can sign' : '' }}">
-                                                        <a class="" href="" show start>Sign As HCP</a>
-                                                        <form url="/api/bill/signAsGenericPro">
-                                                            <input type="hidden" name="uid" value="{{$bill->uid}}">
-                                                            <p>Sign this bill?</p>
-                                                            <div class="mb-0">
-                                                                <button class="btn btn-success btn-sm" submit>Sign</button>
-                                                                <button class="btn btn-default border btn-sm" cancel>Cancel</button>
-                                                            </div>
-                                                        </form>
-                                                    </span>
-                                                @endif
-                                            @endif
-                                        </td>
-                                        <td>
-                                            @if(!$bill->is_cancelled)
-                                                <span class="d-block" moe>
-                                                    <a class="" href="" show start>
-                                                        {{$bill->balance_post_date ? friendlier_date_time($bill->balance_post_date, false) : '(not set)' }}
-                                                    </a>
-                                                    <form url="/api/bill/updateBalancePostDate">
-                                                        <input type="hidden" name="uid" value="{{$bill->uid}}">
-                                                        <p>Update Balance Post Date</p>
-                                                        <div class="mb-0">
-                                                            <input type="date" class="text form-control form-control-sm" name="balancePostDate" value="{{$bill->balance_post_date}}" placeholder="balance post date"><br>
-                                                            <button class="btn btn-success btn-sm" submit>Submit</button>
-                                                            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
-                                                        </div>
-                                                    </form>
-                                                </span>
-                                            @endif
-                                        </td>
-                                        <td> <!-- verification -->
-                                            @if($pro->pro_type === 'ADMIN' && !$bill->is_cancelled)
-                                                @if(!$bill->is_verified)
-                                                    <div class="text-warning-mellow font-weight-bold">Not Verified</div>
-                                                    <span class="d-block mt-1" moe>
-                                                        <a href="" show start>Mark Verified</a>
-                                                        <form url="/api/bill/markAsVerified">
-                                                            <input type="hidden" name="uid" value="{{$bill->uid}}">
-                                                            <p>Mark As Verfified?</p>
-                                                            <div class="mb-0">
-                                                                <button class="btn btn-success btn-sm" submit>Submit</button>
-                                                                <button class="btn btn-default border btn-sm" cancel>Cancel</button>
-                                                            </div>
-                                                        </form>
-                                                    </span>
-                                                @else
-                                                    <div class="text-success font-weight-bold"><i class="fa fa-check"></i> Verified</div>
-                                                    <span class="d-block mt-1" moe>
-                                                        <a class="" href="" show start>Undo</a>
-                                                        <form url="/api/bill/undoMarkAsVerified">
-                                                            <input type="hidden" name="uid" value="{{$bill->uid}}">
-                                                            <p>Undo Mark As Verfified?</p>
-                                                            <div class="mb-0">
-                                                                <button class="btn btn-success btn-sm" submit>Submit</button>
-                                                                <button class="btn btn-default border btn-sm" cancel>Cancel</button>
-                                                            </div>
-                                                        </form>
-                                                    </span>
-                                                @endif
-                                            @endif
-                                        </td>
-                                        <td>  <!-- cancellation -->
-                                            @if($bill->is_cancelled)
-                                                <div class="text-warning-mellow font-weight-bold">Cancelled</div>
-                                                @if($bill->cancellation_memo)
-                                                    <div class="text-dark text-sm font-italic my-1">{{$bill->cancellation_memo}}</div>
-                                                @endif
-                                                @if($bill->is_cancelled_by_administrator)
-                                                    <div class="text-secondary text-sm">(by Administrator)</div>
-                                                @endif
-                                                <div moe class="mt-1">
-                                                    <a class="" href="" show start>Update Memo</a>
-                                                    <form url="/api/bill/updateCancellationMemo">
-                                                        <input type="hidden" name="uid" value="{{$bill->uid}}">
-                                                        <p>Update Cancellation Memo</p>
-                                                        <div class="mb-2">
-                                                            <textarea class="text form-control form-control-sm" name="cancellationMemo"
-                                                                      placeholder="">{{$bill->cancellation_memo ? $bill->cancellation_memo : 'Please contact billing.'}}</textarea>
-                                                        </div>
-                                                        <div>
-                                                            <button class="btn btn-success btn-sm" submit>Submit</button>
-                                                            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
-                                                        </div>
-                                                    </form>
-                                                </div>
-                                            @else
-                                                <span class="d-block" moe relative="">
-                                                    <a class="text-danger" href="" show start>Cancel</a>
-                                                    <form url="/api/bill/markCancelled" right="">
-                                                        <input type="hidden" name="uid" value="{{$bill->uid}}">
-                                                        <p class="mb-2">Cancel this bill?</p>
-                                                        <div class="mb-2">
-                                                            <label class="mb-1 text-secondary">Cancellation Memo</label>
-                                                            <textarea type="text" name="memo" placeholder="Memo" class="form-control form-control-sm">Please contact billing.</textarea>
-                                                        </div>
-                                                        <div class="mb-0">
-                                                            <button class="btn btn-danger btn-sm" submit>Yes</button>
-                                                            <button class="btn btn-default border btn-sm" cancel>No</button>
-                                                        </div>
-                                                    </form>
-                                                </span>
-                                            @endif
-
-                                            @if($bill->is_cancelled && !$bill->is_cancellation_acknowledged)
-                                                <div class="mt-2 text-secondary">
-                                                    <i class="fa fa-exclamation-triangle"></i>
-                                                    Not Ack.
-                                                </div>
-                                                <div class="d-block mt-1" moe>
-                                                    <a class="" href="" show start>Ack. Cancellation</a>
-                                                    <form url="/api/bill/acknowledgeCancellation">
-                                                        <input type="hidden" name="uid" value="{{$bill->uid}}">
-                                                        <p>Acknowledge Cancellation?</p>
-                                                        <div class="mb-0">
-                                                            {{--<input type="text" class="text form-control form-control-sm" name="cancellationMemo" value="{{$bill->cancellation_memo}}" placeholder=""><br>--}}
-                                                            <button class="btn btn-primary btn-sm" submit>Submit</button>
-                                                            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
-                                                        </div>
-                                                    </form>
-                                                </div>
-                                            @endif
 
-                                            @if($bill->is_cancellation_acknowledged && !$careMonth->is_billing_marked_done)
-                                                <div class="mt-2 text-secondary">
-                                                    <i class="fa fa-check"></i>
-                                                    Ack.
-                                                </div>
-                                                <div class="d-block mt-1" moe>
-                                                    <a class="" href="" show start>Undo Cancellation Ack.</a>
-                                                    <form url="/api/bill/undoAcknowledgeCancellation">
-                                                        <input type="hidden" name="uid" value="{{$bill->uid}}">
-                                                        <p>Undo Acknowledge Cancellation?</p>
-                                                        <div class="mb-0">
-                                                            <button class="btn btn-success btn-sm" submit>Submit</button>
-                                                            <button class="btn btn-default border btn-sm" cancel>Cancel</button>
-                                                        </div>
-                                                    </form>
-                                                </div>
-                                            @endif
+                <div class="screen-only m-neg-4 mb-3">
+                    @include('app.generic-bills.inline-for-cm', ['patient' => $patient, 'careMonth' => $careMonth, 'class' => 'p-3 border-bottom', 'label' => 'MCP', 'entityType' => 'CareMonth', 'entityUid' => $careMonth->uid])
+                </div>
 
-                                        </td>
-                                        <td> <!-- submit payment -->
-                                            <div class="my-1">
-                                                @if(!$bill->is_cancelled && !$bill->has_hcp_been_paid)
-                                                    <span class="d-block" moe relative="">
-                                                        <a class="font-weight-bold" href="" show start>Submit Payment For HCP</a>
-                                                        <form url="/api/bill/payHcpAmount" right>
-                                                            <input type="hidden" name="uid" value="{{$bill->uid}}">
-                                                            <p>Submit Payment</p>
-                                                            <div class="mb-0">
-                                                                <input type="text" class="text form-control form-control-sm" name="hcpPaymentAmount" value="{{$bill->hcp_expected_payment_amount}}" placeholder="amount"><br>
-                                                                <button class="btn btn-success btn-sm" submit>Submit</button>
-                                                                <button class="btn btn-default border btn-sm" cancel>Cancel</button>
-                                                            </div>
-                                                        </form>
-                                                    </span>
-                                                @endif
-                                            </div>
-                                            <div class="my-1">
-                                                @if(!$bill->is_cancelled && !$bill->has_na_been_paid && $bill->ally)
-                                                    <span class="d-block" moe relative="">
-                                                        <a class="font-weight-bold" href="" show start>Submit Payment For NA</a>
-                                                        <form url="/api/bill/payNaAmount" right>
-                                                            <input type="hidden" name="uid" value="{{$bill->uid}}">
-                                                            <p>Submit Payment For NA</p>
-                                                            <div class="mb-0">
-                                                                <input type="text" class="text form-control form-control-sm" name="naPaymentAmount" value="{{$bill->na_expected_payment_amount}}" placeholder="amount"><br>
-                                                                <button class="btn btn-success btn-sm" submit>Submit</button>
-                                                                <button class="btn btn-default border btn-sm" cancel>Cancel</button>
-                                                            </div>
-                                                        </form>
-                                                    </span>
-                                                @endif
-                                            </div>
-                                        </td>
-                                    </tr>
-                                @endforeach
-                                </tbody>
-                            </table>
-                        @else
-                            <table class="table table-sm tabe-striped mb-3 border-left border-right border-bottom">
-                                <thead class="bg-light">
-                                <tr>
-                                    <th class="border-bottom-0 pl-3">HCP</th>
-                                    <th class="border-bottom-0 w-25 pl-3">Service</th>
-                                    {{--<th class="border-bottom-0 w-25 pl-2">Reason</th>--}}
-                                    <th class="border-bottom-0 pl-3">Billable</th>
-                                    <th class="border-bottom-0 pl-2">Amount</th>
-                                    <th class="border-bottom-0"></th>
-                                </tr>
-                                </thead>
-                                <tbody>
-                                @foreach ($careMonth->bills as $bill)
-                                    <tr>
-                                        <td class="pl-3">{{ $bill->hcp->displayName() }}</td>
-                                        <td class="pl-3 {{ $bill->is_cancelled ? 'text-secondary' : '' }}">{{$bill->code}}</td>
-                                        {{--<td class="pl-2">
-                                            {{ $bill->reason1 }}
-                                            <div class="text-secondary small">{{ $bill->reason2 }}</div>
-                                        </td>--}}
-                                        <td class="pl-3">
-                                            @if(strpos(strtolower($bill->code), 'treatment services') !== FALSE)
-                                                <?php
-                                                $totalSeconds = $bill->number_of_units * 3600;
-                                                $remainder = $totalSeconds % 60;
-                                                if ($remainder !== 0) {
-                                                    if ($remainder < 30) {
-                                                        $totalSeconds = $totalSeconds - $remainder;
-                                                    }
-                                                    else {
-                                                        $totalSeconds = $totalSeconds + (60 - $remainder);
-                                                    }
-                                                }
-                                                ?>
-                                                {{ time_in_hrminsec($totalSeconds) }}
-                                            @else
-                                                @if(!!$bill->number_of_units)
-                                                    {{ $bill->number_of_units }} unit(s)
-                                                @else
-                                                    -
-                                                @endif
-                                            @endif
-                                        </td>
-                                        <td class="pl-2">
-                                            @if($bill->has_hcp_been_paid)
-                                                <span class="text-dark">Processed:</span><span class="font-weight-bold text-success ml-2">${{ $bill->hcp_payment_amount }}</span>
-                                            @else
-                                                <span class="text-dark">Expected:</span><span class="font-weight-bold text-dark ml-2">{{ $bill->hcp_expected_payment_amount ? '$' . $bill->hcp_expected_payment_amount : '-' }}</span>
-                                            @endif
-                                        </td>
-                                        <td>
-                                            <div class="d-flex align-items-center">
-                                                @if(!$bill->is_cancelled)
-                                                    @if($bill->is_signed_by_hcp)
-                                                        <span class="d-block text-secondary">
-                                                            <i class="fa fa-check"></i>
-                                                            HCP Signed
-                                                        </span>
-                                                    @else
-                                                        <span moe
-                                                              class="d-block {{ $bill->hcp_pro_id !== $pro->id   ? 'moe-disabled' : '' }}"
-                                                              title="{{ $bill->hcp_pro_id !== $pro->id ? 'Only the bill\'s HCP can sign' : '' }}">
-                                                            <a class="" href="" show start>Sign</a>
-                                                            <form url="/api/bill/signAsHcp">
-                                                                <input type="hidden" name="uid" value="{{$bill->uid}}">
-                                                                <p>Sign this bill as HCP?</p>
-                                                                <div class="mb-0">
-                                                                    <button class="btn btn-success btn-sm" submit>Sign</button>
-                                                                    <button class="btn btn-default border btn-sm" cancel>Cancel</button>
-                                                                </div>
-                                                            </form>
-                                                        </span>
-                                                    @endif
-                                                @endif
-                                                @if(!$bill->has_hcp_been_paid && $pro->pro_type === 'ADMIN')
-                                                    <span class="mx-2 text-secondary">|</span>
-                                                    <span class="d-block" moe>
-                                                        <a class="text-danger" href="" show start>Submit Payment</a>
-                                                        <form url="/api/bill/payHcpAmount">
-                                                            <input type="hidden" name="uid" value="{{$bill->uid}}">
-                                                            <p>Submit payment:</p>
-                                                            <div class="mb-0">
-                                                                <input type="text" class="text form-control form-control-sm" name="hcpPaymentAmount" value="{{$bill->hcp_expected_payment_amount}}" placeholder="amount"><br>
-                                                                <button class="btn btn-success btn-sm" submit>Submit</button>
-                                                                <button class="btn btn-default border btn-sm" cancel>Cancel</button>
-                                                            </div>
-                                                        </form>
-                                                    </span>
-                                                @endif
-                                                @if($bill->is_cancelled)
-                                                    <span class="mx-2 text-secondary">|</span>
-                                                    <span class="d-block text-secondary">
-                                                        Cancelled
-                                                    </span>
-                                                @else
-                                                    <span class="mx-2 text-secondary">|</span>
-                                                    <span class="d-block" moe>
-                                                        <a class="text-danger" href="" show start>Cancel</a>
-                                                        <form url="/api/bill/markCancelled" right>
-                                                            <input type="hidden" name="uid" value="{{$bill->uid}}">
-                                                            <p>Cancel this bill?</p>
-                                                            <div class="mb-0">
-                                                                <button class="btn btn-danger btn-sm" submit>Yes</button>
-                                                                <button class="btn btn-default border btn-sm" cancel>No</button>
-                                                            </div>
-                                                        </form>
-                                                    </span>
-                                                @endif
-                                            </div>
-                                        </td>
-                                    </tr>
-                                @endforeach
-                                </tbody>
-                            </table>
-                        @endif
-                    </div>
-                @else
-                    <div class="d-flex">
-                        <p class="font-weight-bold mb-0">No bills in this care month</p>
-                        @include('app/patient/care-month/_create-bill')
-                    </div>
-                @endif
-                <hr class="m-negator mt-4 mb-3">
             @endif
 
             {{-- claims --}} {{-- only admins --}}

+ 0 - 609
resources/views/app/patient/note/dashboard_script-bu-b4-oure-soap.blade.php

@@ -1,609 +0,0 @@
-<script>
-        (function() {
-
-            let numSectionsPendingInitialization = 0;
-
-            function init() {
-
-                // on note-section hover, highlight the according left-tree node(s)
-                $(document)
-                    .off('mouseenter', '.note-section')
-                    .on('mouseenter', '.note-section', function(){
-                        $('.note-tree-node').removeClass('hovered');
-                        let target = $('.note-tree-node a[data-segment-uid="' + $(this).attr('data-segment-uid') + '"]');
-                        target.parent().addClass('hovered');
-                        target.parent().parents('.note-tree-node').addClass('hovered');
-                        return false;
-                    });
-
-                $(document)
-                    .off('mouseenter', '[data-non-segment-section]')
-                    .on('mouseenter', '[data-non-segment-section]', function(){
-                        $('.note-tree-node').removeClass('hovered');
-                        let target = $('.note-tree-node a[data-non-segment-target="' + $(this).attr('data-non-segment-section') + '"]');
-                        target.parent().addClass('hovered');
-                        target.parent().parents('.note-tree-node').addClass('hovered');
-                        return false;
-                    });
-
-                $(document)
-                    .off('mouseleave', '.note-section')
-                    .on('mouseleave', '.note-section', () => {
-                        $('.note-tree-node').removeClass('hovered');
-                        return false;
-                    });
-
-                // print note
-                $(document)
-                    .off('click.print', '.print-note')
-                    .on('click.print', '.print-note', () => {
-                        window.print();
-                        return false;
-                    });
-                $('.print-note').removeClass('invisible');
-
-                $('.note-method-select').change(function() {
-                    let form = $(this).closest('form');
-                    if(this.value === 'IN_CLINIC') {
-                        form.find('.if-in-clinic').show();
-                    }
-                    else {
-                        form.find('.if-in-clinic').hide();
-                    }
-                });
-
-                $('.note-method-select').each(function() {
-                    let form = $(this).closest('form');
-                    if(this.value === 'IN_CLINIC') {
-                        form.find('.if-in-clinic').show();
-                    }
-                    else {
-                        form.find('.if-in-clinic').hide();
-                    }
-                });
-
-                $('textarea[rte]').each(function() {
-
-                    $(this).wrap(
-                        $('<div class="border-left border-right rte-holder"/>')
-                            .attr('data-shortcuts', '')
-                    );
-
-                    // give a unique id to this editor instance
-                    var editorID = Math.ceil(Math.random() * 99999),
-                        fieldName = this.name;
-
-                    var ti = $('<input type="hidden" />')
-                        .val(this.value)
-                        .attr('name', this.name)
-                        .insertBefore(this);
-                    var ce = $('<div data-editor-id="' + editorID + '" data-field="' + this.name + '"/>')
-                        .html(this.value)
-                        .insertBefore(this);
-                    $(this).remove();
-
-                    var qe = new Quill('[data-editor-id="' + editorID + '"]', {
-                        theme: 'snow',
-                        modules: stagQuillConfig
-                    });
-                    var toolbar = $(qe.container).prev('.ql-toolbar');
-
-                    // add button for new shortcut
-                    var newSCButton = $('<button class="btn bg-white btn-sm btn-default text-primary w-auto px-2 border py-0 ' +
-                        'text-sm add-shortcut" data-editor-id="' + editorID + '">+ Shortcut</button>');
-                    toolbar.append(newSCButton);
-
-                    qe.on('text-change', function() {
-                        ti.val(qe.root.innerHTML);
-                    });
-
-                    $(qe.container)
-                        .find('.ql-editor[contenteditable]')
-                            .attr('data-field', fieldName)
-                            .attr('data-editor-id', editorID)
-                            .attr('with-shortcuts', 1);
-
-                });
-
-                $(document)
-                    .off('click.edit-trigger', '.edit-trigger:not(.edit)')
-                    .on('click.edit-trigger', '.edit-trigger:not(.edit)', function() {
-
-                        if($('.note-section>.stag-popup:visible').length) return;
-
-                        let editParent = $(this).closest('.note-section');
-
-                        // TEMP: disable edit mode for medrisk_vigilance
-                        // TODO: do this in the proper place
-                        if(editParent.is('[data-segment-template-name="medrisk_vigilence"]')) return false;
-
-                        // TEMP: show wizard for allergies, rx, dx, goals
-                        if(editParent.is('[data-segment-template-name="plan_allergies"]') ||
-                            editParent.is('[data-segment-template-name="intake_allergies"]')) {
-                            $('.note-bottom-toolbar .allergies-center-trigger').trigger('click');
-                            return false;
-                        }
-                        else if(editParent.is('[data-segment-template-name="plan_problems"]') ||
-                            editParent.is('[data-segment-template-name="intake_problems"]')) {
-                            $('.note-bottom-toolbar .problems-center-trigger').trigger('click');
-                            return false;
-                        }
-                        else if(editParent.is('[data-segment-template-name="plan_medications"]') ||
-                            editParent.is('[data-segment-template-name="intake_medications"]')) {
-                            $('.note-bottom-toolbar .medications-center-trigger').trigger('click');
-                            return false;
-                        }
-                        else if(editParent.is('[data-segment-template-name="plan_goals"]') ||
-                            editParent.is('[data-segment-template-name="intake_goals"]')) {
-                            $('.note-bottom-toolbar .goals-center-trigger').trigger('click');
-                            return false;
-                        }
-                        else if(editParent.is('[data-segment-template-name="plan_care_team"]') ||
-                            editParent.is('[data-segment-template-name="intake_care_team"]')) {
-                            $('.note-bottom-toolbar .careteam-center-trigger').trigger('click');
-                            return false;
-                        }
-                        else if(editParent.is('[data-segment-template-name="plan_supplements"]') ||
-                            editParent.is('[data-segment-template-name="intake_supplements"]')) {
-                            $('.note-bottom-toolbar .supplements-center-trigger').trigger('click');
-                            return false;
-                        }
-
-                        // TEMP: open in popup if LS segment
-                        if(editParent.is('[data-segment-template-name^="lifestyle_"]')) {
-                            showStagPopup('segment-popup-' + editParent.attr('data-segment-template-name'), true);
-                            return false;
-                        }
-
-                        if(editParent.is('[data-segment-template-name="plan_nutrition"]') ||
-                            editParent.is('[data-segment-template-name="intake_nutrition"]')) {
-                            openDynamicStagPopup('/nutrition-center/{{$note->client->uid}}/{{$note->uid}}',
-                                'nutrition-center-{{$note->id}}',
-                                '<img src="/img/nutrition-rx.png" class=""/> Nutrition Rx',
-                                false,
-                                "overflow-visible");
-                            return false;
-                        }
-
-                        if(editParent.is('[data-segment-template-name="plan_exercise"]') ||
-                            editParent.is('[data-segment-template-name="intake_exercise"]')) {
-                            openDynamicStagPopup('/exercise-center/{{$note->client->uid}}/{{$note->uid}}',
-                                'exercise-center-{{$note->id}}',
-                                '<img src="/img/exercise-rx.png" class=""/> Exercise Rx',
-                                false,
-                                "overflow-visible");
-                            return false;
-                        }
-
-                        if(editParent.is('[data-segment-template-name="plan_behavior"]') ||
-                            editParent.is('[data-segment-template-name="intake_behavior"]')) {
-                            openDynamicStagPopup('/behavior-center/{{$note->client->uid}}/{{$note->uid}}',
-                                'behavior-center-{{$note->id}}',
-                                '<img src="/img/behavior-rx.png" class=""/> Behavior Rx',
-                                false,
-                                "overflow-visible");
-                            return false;
-                        }
-
-                        <?php
-                        $rosSegment = $note->getSegmentByInternalName('ros');
-                        ?>
-                        @if($rosSegment)
-                        if(editParent.is('[data-segment-template-name="ros"]')) {
-                            openDynamicStagPopup('/note-segment-view/{{$note->client->uid}}/{{$note->uid}}/{{$rosSegment->uid}}/ros/edit',
-                                'init-ros-{{$note->id}}',
-                                'Review of Systems',
-                                false,
-                                "overflow-visible");
-                            return false;
-                        }
-                        @endif
-
-                        // OPEN popup for if note-segment-view exists
-                        if($('.' + editParent.attr('data-segment-template-name') + '-trigger').length) {
-                            $('.' + editParent.attr('data-segment-template-name') + '-trigger').trigger('click');
-                            return false;
-                        }
-
-                        if(editParent.is('.edit')) {
-                            editParent.removeClass('edit');
-                        }
-                        else {
-                            let docRoot = $('html');
-                            let prevEffectiveTop = editParent.offset().top - docRoot.scrollTop();
-                            $('.note-section.edit').removeClass('edit');
-                            editParent.addClass('edit');
-                            let newEffectiveTop = editParent.offset().top - docRoot.scrollTop();
-                            if(newEffectiveTop < prevEffectiveTop) {
-                                docRoot.scrollTop(docRoot.scrollTop() - (prevEffectiveTop - newEffectiveTop));
-                            }
-                        }
-
-                        let visitTreeLink = $('.note-tree-node a[data-segment-internal-name="' + editParent.attr('data-segment-template-name') + '"]');
-                        if(visitTreeLink.length) {
-                            $('.note-tree-node.active').removeClass('active');
-                            visitTreeLink.closest('.note-tree-node').addClass('active');
-                        }
-
-                        return false;
-                    });
-
-                $('.note-templates-trigger')
-                    .off('click.note-templates-trigger')
-                    .on('click.note-templates-trigger', function() {
-                        $('.note-templates-underlay').show();
-                        let container = $(this).closest('.note-section').find('.note-template-container');
-                        container.find('.note-template-children').hide();
-                        container.find('.note-template-item.selected').removeClass('selected');
-                        container.find('.note-template-item[prefix]').removeAttr('prefix');
-                        container.find('input[type="checkbox"]').prop('checked', false);
-                        container.find('.note-template-output-text').empty();
-                        container.show();
-                        loadTemplateSet(container.find('.note-template-set-chooser'));
-                        loadExamTemplateSet(container.find('.note-exam-template-set-chooser'),
-                            container.find('.note-exam-exam-chooser').val(),
-                            container.find('.note-exam-template-set-chooser').val());
-                        return false;
-                    });
-
-                $(document)
-                    .off('click.note-templates-trigger-assessment', '.note-templates-trigger-assessment')
-                    .on('click.note-templates-trigger-assessment', '.note-templates-trigger-assessment', function() {
-                        $('.note-templates-underlay').show();
-                        let container = $(this).closest('.note-section').find('.note-template-container');
-                        container.find('.note-template-children').hide();
-                        container.find('.note-template-item.selected').removeClass('selected');
-                        container.find('.note-template-item[prefix]').removeAttr('prefix');
-                        container.find('input[type="checkbox"]').prop('checked', false);
-                        container.find('.note-template-output-text').empty();
-                        container.attr('data-editor-id', $(this).attr('data-editor-id'));
-                        container.show();
-                        container.css({
-                            left: ($(this).position().left - 140) + 'px',
-                            top: ($(this).position().top + 22) + 'px',
-                        });
-                        loadTemplateSet(container.find('.note-template-set-chooser'));
-                        loadExamTemplateSet(container.find('.note-exam-template-set-chooser'),
-                            container.find('.note-exam-exam-chooser').val(),
-                            container.find('.note-exam-template-set-chooser').val());
-                        return false;
-                    });
-
-                $(document)
-                    .off('click.note-templates-underlay', '.note-templates-underlay, .note-template-close-trigger')
-                    .on('click.note-templates-underlay', '.note-templates-underlay, .note-template-close-trigger', function() {
-                        $('.note-templates-underlay').hide();
-                         $('.note-template-container').hide();
-                    });
-
-                $(document)
-                    .off('click.note-template-label', '.note-template-item .label')
-                    .on('click.note-template-label', '.note-template-item .label', function() {
-                        let item = $(this).closest('.note-template-item');
-                        let isChecked = $(this).find('>input[type="checkbox"]').prop('checked');
-                        let hasChildren = !!item.find('>.note-template-children').length,
-                            childrenShown = item.find('>.note-template-children:visible').length;
-
-                        if(isChecked && hasChildren && !childrenShown) { // just show
-                            $('.note-template-children').hide();
-                            $(this).parents('.note-template-children').show();
-                            item.find('>.note-template-children').show()
-                                .find('>textarea,>input[type="number"],>input[type="date"]').first().focus();
-                            return false;
-                        }
-
-                        $(this).find('>input[type="checkbox"]').prop('checked', !isChecked);
-                        isChecked = !isChecked;
-                        if(isChecked) {
-                            item.addClass('selected');
-                        }
-                        else {
-                            item.removeClass('selected');
-                        }
-                        $('.note-template-children').hide();
-                        $(this).parents('.note-template-children').show();
-                        if(isChecked) {
-                            item.find('>.note-template-children')
-                                .show()
-                                .find('>textarea,>input[type="number"],>input[type="date"]')
-                                .first().focus();
-                        }
-
-                        generateTemplateOutput();
-
-                        return false;
-                    });
-
-                $(document)
-                    .off('mousedown.note-templates-apply', '.note-template-apply-trigger')
-                    .on('mousedown.note-templates-apply', '.note-template-apply-trigger', function() {
-                        let templateContainer = $('.note-template-container:visible').first();
-                        let result = $('.note-template-output-text:visible').first().html();
-                        $('.note-templates-underlay').hide();
-                        $('.note-template-container').hide();
-                        let editor = null;
-                        if($(this).closest('.assessment-detail-template').length) {
-                            editor  = $('.ql-editor[data-editor-id="' + templateContainer.attr('data-editor-id') + '"]:visible').first();
-                        }
-                        else {
-                            editor  = $('.ql-editor[contenteditable]:visible').first();
-                        }
-                        if(editor && editor.length) {
-                            result = $.trim(editor.text() !== '' ? editor.html() : '') + result;
-                            editor.html(result).focus();
-                        }
-                        return false;
-                    });
-
-                $(document)
-                    .off('input paste change', '.note-template-item textarea, .note-template-item input[type="number"], .note-template-item input[type="date"]')
-                    .on('input paste change', '.note-template-item textarea, .note-template-item input[type="number"], .note-template-item input[type="date"]', function() {
-                        generateTemplateOutput();
-                    });
-
-                $(document)
-                    .off('click.plus-trigger', '.note-template-item .plus-trigger')
-                    .on('click.plus-trigger', '.note-template-item .plus-trigger', function() {
-                        let item = $(this).closest('.note-template-item');
-                        if(item.attr('prefix') === '(+)') {
-                            item.removeAttr('prefix');
-                            item.find('>.note-template-text>.label>input[type="checkbox"]').prop('checked', false);
-                            item.removeClass('selected');
-                        }
-                        else {
-                            item.attr('prefix', '(+)');
-                            item.find('>.note-template-text>.label>input[type="checkbox"]').prop('checked', true);
-                            item.addClass('selected');
-                        }
-                        generateTemplateOutput();
-                        return false;
-                    });
-
-                $(document)
-                    .off('click.minus-trigger', '.note-template-item .minus-trigger')
-                    .on('click.minus-trigger', '.note-template-item .minus-trigger', function() {
-                        let item = $(this).closest('.note-template-item');
-                        if(item.attr('prefix') === '(-)') {
-                            item.removeAttr('prefix');
-                            item.find('>.note-template-text>.label>input[type="checkbox"]').prop('checked', false);
-                            item.removeClass('selected');
-                        }
-                        else {
-                            item.attr('prefix', '(-)');
-                            item.find('>.note-template-text>.label>input[type="checkbox"]').prop('checked', true);
-                            item.addClass('selected');
-                        }
-                        generateTemplateOutput();
-                        return false;
-                    });
-
-                $(document)
-                    .off('change.note-template-set-chooser', '.note-template-set-chooser')
-                    .on('change.note-template-set-chooser', '.note-template-set-chooser', function() {
-                        return loadTemplateSet($(this));
-                    });
-
-                $(document)
-                    .off('change.note-exam-template-set-chooser', '.note-exam-template-set-chooser')
-                    .on('change.note-exam-template-set-chooser', '.note-exam-template-set-chooser', function() {
-                        $(this).closest('.note-template-container')
-                            .find('.note-exam-exam-chooser')
-                                .val($(this).find('option:selected').attr('exam'));
-                        return loadExamTemplateSet($(this),
-                            $(this).closest('.note-template-container').find('.note-exam-exam-chooser').first().val(),
-                            $(this).val());
-                    });
-
-                $(document)
-                    .off('change.note-exam-exam-chooser', '.note-exam-exam-chooser')
-                    .on('change.note-exam-exam-chooser', '.note-exam-exam-chooser', function() {
-                        return loadExamTemplateSet($(this),
-                            $(this).val(),
-                            $(this).closest('.note-template-container').find('.note-exam-template-set-chooser').first().val());
-                    });
-
-                $('.remove-section-trigger').click(function() {
-                    $.post('/api/section/deactivate', {
-                        uid: $(this).attr('data-uid'),
-                        memo: 'Deactivated from note',
-                    }, function(_data) {
-                        if(_data) {
-                            if(_data.success) {
-                                fastReload();
-                            }
-                            else {
-                                toastr.error(_data.message);
-                            }
-                        }
-                        else {
-                            toastr.error('Unable to remove section!');
-                        }
-                    }, 'json');
-                    // $(this).closest('.note-section').removeClass('edit');
-                    return false;
-                });
-
-                @if(!$note->visitTemplate)
-                $(document)
-                    .off('mousedown.enable-edit', '.note-section:not(.edit):not(.page-driven)')
-                    .on('mousedown.enable-edit', '.note-section:not(.edit):not(.page-driven)', function(e) {
-                        if($(this).closest('.note-signed-by-hcp').length) return;
-                        e.stopPropagation();
-                        e.preventDefault();
-                        $(this).find('.edit-trigger').first().click();
-                        return false;
-                    });
-                @endif
-
-                $(document)
-                    .off('keydown.collapse-active-segment')
-                    .on('keydown.collapse-active-segment', function(e) {
-                        if(e.which === 27) {
-                            if(!isEventConsumed(e)) {
-                                if($('.visit-segment.edit').length) {
-                                    $('.visit-segment.edit').first().find('.edit-trigger').first().click();
-                                    markEventAsConsumed(e);
-                                    return false;
-                                }
-                            }
-                            else {
-                                // event already consumed!
-                            }
-                        }
-                    });
-
-                scrollToLatest();
-
-                function __moveSection(_uid, _direction) {
-                    $.post('/api/section/move' + _direction, {
-                        uid: _uid
-                    }, function(_data) {
-                        if(_data && _data.success) {
-                            fastReload();
-                        }
-                        else {
-                            if(_data) {
-                                toastr.error(_data.message);
-                            }
-                            else {
-                                toastr.error('Unknown error while moving section');
-                            }
-                        }
-                    }, 'json')
-                }
-
-                $('.move-up-trigger').click(function() {
-                    __moveSection($(this).attr('data-uid'), 'Up');
-                });
-
-                $('.move-down-trigger').click(function() {
-                    __moveSection($(this).attr('data-uid'), 'Down');
-                });
-
-                // refresh once ticket popup is closed
-                /*$('body').off('stag-popup-closed')
-                $('body').on('stag-popup-closed', function() {
-                    if($('#note-single-header').length) {
-                        fastReload();
-                    }
-                });*/
-                // ticket-popup
-                $(document)
-                    .off('click', '.ticket-popup-trigger.note-dashboard-action')
-                    .on('click', '.ticket-popup-trigger.note-dashboard-action', function() {
-                        showMask();
-                        window.noMc = true;
-                        $.get(this.href, (_data) => {
-
-                            if(!$('.ticket-popup').length) {
-                                $('main.stag-content').append('<div class="stag-popup stag-popup-lg ticket-popup mcp-theme-1" stag-popup-key="ticket-popup"></div>');
-                            }
-
-                            $('.ticket-popup').html(_data);
-                            showStagPopup('ticket-popup', true);
-                            $('.ticket-popup .stag-popup.stag-slide').attr('close-all-with-self', 1);
-                            runMCInitializer('patient-tickets'); // run specific mc initer
-                            hideMask();
-                        });
-                        return false;
-                    });
-
-            }
-
-            // scroll to latest created section
-            function scrollToLatest() {
-                window.setTimeout(function() {
-                    let latestSectionTS = $('.latest-section-ts');
-                    if(latestSectionTS.length) {
-                        let latestSection = $('.note-section[data-ts="' + latestSectionTS.text() + '"]');
-                        if(latestSection.length) {
-                            latestSection[0].scrollIntoView({behavior: "smooth", block: "center"});
-                            // latestSection.find('.edit-trigger').first().click();
-                            console.log('DONE!');
-                        }
-                    }
-                }, 100);
-            }
-
-            function loadTemplateSet(_chooser) {
-                if(!_chooser.length || !_chooser.val()) return false;
-                let container = _chooser.closest('.note-template-container');
-                container.find('>.note-template-item').remove();
-                container.find('.please-wait').remove();
-                container.append('<p class="please-wait my-2 text-secondary text-center">Please wait ...</p>');
-                $.get('/note-template-set/' + _chooser.attr('data-section') + '/' + _chooser.val(), function(_html) {
-                    container.find('.please-wait').remove();
-                    container.append(_html);
-                });
-                return false;
-            }
-
-            function loadExamTemplateSet(_chooser, _exam, _templateSet) {
-                if(!_chooser.length || !_chooser.val()) return false;
-                let container = _chooser.closest('.note-template-container');
-                container.find('>.note-template-item').remove();
-                container.find('.please-wait').remove();
-                container.append('<p class="please-wait my-2 text-secondary text-center">Please wait ...</p>');
-                $.get('/note-template-set/exam/' + _exam + '/' + _templateSet, function(_html) {
-                    container.find('.please-wait').remove();
-                    container.append(_html);
-                });
-                return false;
-            }
-
-            function generateOutputForNode(_node) {
-                let template = (_node.attr('prefix') ? _node.attr('prefix') : '') + _node.attr('template'),
-                    value = template;
-                let hasChildText = !!_node.find('>.note-template-children>textarea,>.note-template-children>input[type="number"],>.note-template-children>input[type="date"]').length;
-                let hasChildren = !!_node.find('>.note-template-children>.note-template-item').length;
-                if(hasChildText) {
-                    value = value.replace('{text}',
-                        _node
-                            .find('>.note-template-children')
-                                .find('>textarea,>input[type="number"],>input[type="date"]').first().val());
-                }
-                else if(hasChildren) {
-                    let values = [];
-                    _node.find('>.note-template-children>.note-template-item.selected').each(function() {
-                        values.push(generateOutputForNode($(this)));
-                    });
-                    let combined = '';
-                    for (let i = 0; i < values.length; i++) {
-                        combined += values[i];
-                        if(values.length > 1 && i <= values.length - 2) {
-                            if(i === values.length - 2) {
-                                combined += ' and ';
-                            }
-                            else {
-                                combined += ', ';
-                            }
-                        }
-                    }
-                    value = value.replace('{children}', ' ' + combined).replace('{text}', ' ' + combined);
-                }
-                return value;
-            }
-
-            function generateTemplateOutput() {
-                let container = $('.note-template-container:visible').first();
-                if(!container.length) return '';
-                let lines = [];
-                if(container.find('.note-template-set-chooser').length) {
-                    lines.push('<b>' + container.find('.note-template-set-chooser').first().find('option:selected').text() + '</b>');
-                }
-                else if(container.find('.note-exam-template-set-chooser').length && container.find('.note-exam-exam-chooser').length) {
-                    lines.push('<b>' +
-                        container.find('.note-exam-template-set-chooser').first().find('option:selected').text() +
-                        ': ' +
-                        container.find('.note-exam-exam-chooser').first().find('option:selected').text() +
-                        '</b>');
-                }
-                container.find('>.note-template-item.selected').each(function() {
-                    lines.push('<p class="note-template-output-line">' + generateOutputForNode($(this)) + '</p>');
-                });
-                $('.note-template-output-text:visible').first().html(lines.join(''));
-            }
-
-            addMCInitializer('note-single', init, '#note-single-header');
-        })();
-    </script>

+ 0 - 609
resources/views/app/patient/note/dashboard_script-bu-b4-pure-soap.blade.php

@@ -1,609 +0,0 @@
-<script>
-        (function() {
-
-            let numSectionsPendingInitialization = 0;
-
-            function init() {
-
-                // on note-section hover, highlight the according left-tree node(s)
-                $(document)
-                    .off('mouseenter', '.note-section')
-                    .on('mouseenter', '.note-section', function(){
-                        $('.note-tree-node').removeClass('hovered');
-                        let target = $('.note-tree-node a[data-segment-uid="' + $(this).attr('data-segment-uid') + '"]');
-                        target.parent().addClass('hovered');
-                        target.parent().parents('.note-tree-node').addClass('hovered');
-                        return false;
-                    });
-
-                $(document)
-                    .off('mouseenter', '[data-non-segment-section]')
-                    .on('mouseenter', '[data-non-segment-section]', function(){
-                        $('.note-tree-node').removeClass('hovered');
-                        let target = $('.note-tree-node a[data-non-segment-target="' + $(this).attr('data-non-segment-section') + '"]');
-                        target.parent().addClass('hovered');
-                        target.parent().parents('.note-tree-node').addClass('hovered');
-                        return false;
-                    });
-
-                $(document)
-                    .off('mouseleave', '.note-section')
-                    .on('mouseleave', '.note-section', () => {
-                        $('.note-tree-node').removeClass('hovered');
-                        return false;
-                    });
-
-                // print note
-                $(document)
-                    .off('click.print', '.print-note')
-                    .on('click.print', '.print-note', () => {
-                        window.print();
-                        return false;
-                    });
-                $('.print-note').removeClass('invisible');
-
-                $('.note-method-select').change(function() {
-                    let form = $(this).closest('form');
-                    if(this.value === 'IN_CLINIC') {
-                        form.find('.if-in-clinic').show();
-                    }
-                    else {
-                        form.find('.if-in-clinic').hide();
-                    }
-                });
-
-                $('.note-method-select').each(function() {
-                    let form = $(this).closest('form');
-                    if(this.value === 'IN_CLINIC') {
-                        form.find('.if-in-clinic').show();
-                    }
-                    else {
-                        form.find('.if-in-clinic').hide();
-                    }
-                });
-
-                $('textarea[rte]').each(function() {
-
-                    $(this).wrap(
-                        $('<div class="border-left border-right rte-holder"/>')
-                            .attr('data-shortcuts', '')
-                    );
-
-                    // give a unique id to this editor instance
-                    var editorID = Math.ceil(Math.random() * 99999),
-                        fieldName = this.name;
-
-                    var ti = $('<input type="hidden" />')
-                        .val(this.value)
-                        .attr('name', this.name)
-                        .insertBefore(this);
-                    var ce = $('<div data-editor-id="' + editorID + '" data-field="' + this.name + '"/>')
-                        .html(this.value)
-                        .insertBefore(this);
-                    $(this).remove();
-
-                    var qe = new Quill('[data-editor-id="' + editorID + '"]', {
-                        theme: 'snow',
-                        modules: stagQuillConfig
-                    });
-                    var toolbar = $(qe.container).prev('.ql-toolbar');
-
-                    // add button for new shortcut
-                    var newSCButton = $('<button class="btn bg-white btn-sm btn-default text-primary w-auto px-2 border py-0 ' +
-                        'text-sm add-shortcut" data-editor-id="' + editorID + '">+ Shortcut</button>');
-                    toolbar.append(newSCButton);
-
-                    qe.on('text-change', function() {
-                        ti.val(qe.root.innerHTML);
-                    });
-
-                    $(qe.container)
-                        .find('.ql-editor[contenteditable]')
-                            .attr('data-field', fieldName)
-                            .attr('data-editor-id', editorID)
-                            .attr('with-shortcuts', 1);
-
-                });
-
-                $(document)
-                    .off('click.edit-trigger', '.edit-trigger:not(.edit)')
-                    .on('click.edit-trigger', '.edit-trigger:not(.edit)', function() {
-
-                        if($('.note-section>.stag-popup:visible').length) return;
-
-                        let editParent = $(this).closest('.note-section');
-
-                        // TEMP: disable edit mode for medrisk_vigilance
-                        // TODO: do this in the proper place
-                        if(editParent.is('[data-segment-template-name="medrisk_vigilence"]')) return false;
-
-                        // TEMP: show wizard for allergies, rx, dx, goals
-                        if(editParent.is('[data-segment-template-name="plan_allergies"]') ||
-                            editParent.is('[data-segment-template-name="intake_allergies"]')) {
-                            $('.note-bottom-toolbar .allergies-center-trigger').trigger('click');
-                            return false;
-                        }
-                        else if(editParent.is('[data-segment-template-name="plan_problems"]') ||
-                            editParent.is('[data-segment-template-name="intake_problems"]')) {
-                            $('.note-bottom-toolbar .problems-center-trigger').trigger('click');
-                            return false;
-                        }
-                        else if(editParent.is('[data-segment-template-name="plan_medications"]') ||
-                            editParent.is('[data-segment-template-name="intake_medications"]')) {
-                            $('.note-bottom-toolbar .medications-center-trigger').trigger('click');
-                            return false;
-                        }
-                        else if(editParent.is('[data-segment-template-name="plan_goals"]') ||
-                            editParent.is('[data-segment-template-name="intake_goals"]')) {
-                            $('.note-bottom-toolbar .goals-center-trigger').trigger('click');
-                            return false;
-                        }
-                        else if(editParent.is('[data-segment-template-name="plan_care_team"]') ||
-                            editParent.is('[data-segment-template-name="intake_care_team"]')) {
-                            $('.note-bottom-toolbar .careteam-center-trigger').trigger('click');
-                            return false;
-                        }
-                        else if(editParent.is('[data-segment-template-name="plan_supplements"]') ||
-                            editParent.is('[data-segment-template-name="intake_supplements"]')) {
-                            $('.note-bottom-toolbar .supplements-center-trigger').trigger('click');
-                            return false;
-                        }
-
-                        // TEMP: open in popup if LS segment
-                        if(editParent.is('[data-segment-template-name^="lifestyle_"]')) {
-                            showStagPopup('segment-popup-' + editParent.attr('data-segment-template-name'), true);
-                            return false;
-                        }
-
-                        if(editParent.is('[data-segment-template-name="plan_nutrition"]') ||
-                            editParent.is('[data-segment-template-name="intake_nutrition"]')) {
-                            openDynamicStagPopup('/nutrition-center/{{$note->client->uid}}/{{$note->uid}}',
-                                'nutrition-center-{{$note->id}}',
-                                '<img src="/img/nutrition-rx.png" class=""/> Nutrition Rx',
-                                false,
-                                "overflow-visible");
-                            return false;
-                        }
-
-                        if(editParent.is('[data-segment-template-name="plan_exercise"]') ||
-                            editParent.is('[data-segment-template-name="intake_exercise"]')) {
-                            openDynamicStagPopup('/exercise-center/{{$note->client->uid}}/{{$note->uid}}',
-                                'exercise-center-{{$note->id}}',
-                                '<img src="/img/exercise-rx.png" class=""/> Exercise Rx',
-                                false,
-                                "overflow-visible");
-                            return false;
-                        }
-
-                        if(editParent.is('[data-segment-template-name="plan_behavior"]') ||
-                            editParent.is('[data-segment-template-name="intake_behavior"]')) {
-                            openDynamicStagPopup('/behavior-center/{{$note->client->uid}}/{{$note->uid}}',
-                                'behavior-center-{{$note->id}}',
-                                '<img src="/img/behavior-rx.png" class=""/> Behavior Rx',
-                                false,
-                                "overflow-visible");
-                            return false;
-                        }
-
-                        <?php
-                        $rosSegment = $note->getSegmentByInternalName('ros');
-                        ?>
-                        @if($rosSegment)
-                        if(editParent.is('[data-segment-template-name="ros"]')) {
-                            openDynamicStagPopup('/note-segment-view/{{$note->client->uid}}/{{$note->uid}}/{{$rosSegment->uid}}/ros/edit',
-                                'init-ros-{{$note->id}}',
-                                'Review of Systems',
-                                false,
-                                "overflow-visible");
-                            return false;
-                        }
-                        @endif
-
-                        // OPEN popup for if note-segment-view exists
-                        if($('.' + editParent.attr('data-segment-template-name') + '-trigger').length) {
-                            $('.' + editParent.attr('data-segment-template-name') + '-trigger').trigger('click');
-                            return false;
-                        }
-
-                        if(editParent.is('.edit')) {
-                            editParent.removeClass('edit');
-                        }
-                        else {
-                            let docRoot = $('html');
-                            let prevEffectiveTop = editParent.offset().top - docRoot.scrollTop();
-                            $('.note-section.edit').removeClass('edit');
-                            editParent.addClass('edit');
-                            let newEffectiveTop = editParent.offset().top - docRoot.scrollTop();
-                            if(newEffectiveTop < prevEffectiveTop) {
-                                docRoot.scrollTop(docRoot.scrollTop() - (prevEffectiveTop - newEffectiveTop));
-                            }
-                        }
-
-                        let visitTreeLink = $('.note-tree-node a[data-segment-internal-name="' + editParent.attr('data-segment-template-name') + '"]');
-                        if(visitTreeLink.length) {
-                            $('.note-tree-node.active').removeClass('active');
-                            visitTreeLink.closest('.note-tree-node').addClass('active');
-                        }
-
-                        return false;
-                    });
-
-                $('.note-templates-trigger')
-                    .off('click.note-templates-trigger')
-                    .on('click.note-templates-trigger', function() {
-                        $('.note-templates-underlay').show();
-                        let container = $(this).closest('.note-section').find('.note-template-container');
-                        container.find('.note-template-children').hide();
-                        container.find('.note-template-item.selected').removeClass('selected');
-                        container.find('.note-template-item[prefix]').removeAttr('prefix');
-                        container.find('input[type="checkbox"]').prop('checked', false);
-                        container.find('.note-template-output-text').empty();
-                        container.show();
-                        loadTemplateSet(container.find('.note-template-set-chooser'));
-                        loadExamTemplateSet(container.find('.note-exam-template-set-chooser'),
-                            container.find('.note-exam-exam-chooser').val(),
-                            container.find('.note-exam-template-set-chooser').val());
-                        return false;
-                    });
-
-                $(document)
-                    .off('click.note-templates-trigger-assessment', '.note-templates-trigger-assessment')
-                    .on('click.note-templates-trigger-assessment', '.note-templates-trigger-assessment', function() {
-                        $('.note-templates-underlay').show();
-                        let container = $(this).closest('.note-section').find('.note-template-container');
-                        container.find('.note-template-children').hide();
-                        container.find('.note-template-item.selected').removeClass('selected');
-                        container.find('.note-template-item[prefix]').removeAttr('prefix');
-                        container.find('input[type="checkbox"]').prop('checked', false);
-                        container.find('.note-template-output-text').empty();
-                        container.attr('data-editor-id', $(this).attr('data-editor-id'));
-                        container.show();
-                        container.css({
-                            left: ($(this).position().left - 140) + 'px',
-                            top: ($(this).position().top + 22) + 'px',
-                        });
-                        loadTemplateSet(container.find('.note-template-set-chooser'));
-                        loadExamTemplateSet(container.find('.note-exam-template-set-chooser'),
-                            container.find('.note-exam-exam-chooser').val(),
-                            container.find('.note-exam-template-set-chooser').val());
-                        return false;
-                    });
-
-                $(document)
-                    .off('click.note-templates-underlay', '.note-templates-underlay, .note-template-close-trigger')
-                    .on('click.note-templates-underlay', '.note-templates-underlay, .note-template-close-trigger', function() {
-                        $('.note-templates-underlay').hide();
-                         $('.note-template-container').hide();
-                    });
-
-                $(document)
-                    .off('click.note-template-label', '.note-template-item .label')
-                    .on('click.note-template-label', '.note-template-item .label', function() {
-                        let item = $(this).closest('.note-template-item');
-                        let isChecked = $(this).find('>input[type="checkbox"]').prop('checked');
-                        let hasChildren = !!item.find('>.note-template-children').length,
-                            childrenShown = item.find('>.note-template-children:visible').length;
-
-                        if(isChecked && hasChildren && !childrenShown) { // just show
-                            $('.note-template-children').hide();
-                            $(this).parents('.note-template-children').show();
-                            item.find('>.note-template-children').show()
-                                .find('>textarea,>input[type="number"],>input[type="date"]').first().focus();
-                            return false;
-                        }
-
-                        $(this).find('>input[type="checkbox"]').prop('checked', !isChecked);
-                        isChecked = !isChecked;
-                        if(isChecked) {
-                            item.addClass('selected');
-                        }
-                        else {
-                            item.removeClass('selected');
-                        }
-                        $('.note-template-children').hide();
-                        $(this).parents('.note-template-children').show();
-                        if(isChecked) {
-                            item.find('>.note-template-children')
-                                .show()
-                                .find('>textarea,>input[type="number"],>input[type="date"]')
-                                .first().focus();
-                        }
-
-                        generateTemplateOutput();
-
-                        return false;
-                    });
-
-                $(document)
-                    .off('mousedown.note-templates-apply', '.note-template-apply-trigger')
-                    .on('mousedown.note-templates-apply', '.note-template-apply-trigger', function() {
-                        let templateContainer = $('.note-template-container:visible').first();
-                        let result = $('.note-template-output-text:visible').first().html();
-                        $('.note-templates-underlay').hide();
-                        $('.note-template-container').hide();
-                        let editor = null;
-                        if($(this).closest('.assessment-detail-template').length) {
-                            editor  = $('.ql-editor[data-editor-id="' + templateContainer.attr('data-editor-id') + '"]:visible').first();
-                        }
-                        else {
-                            editor  = $('.ql-editor[contenteditable]:visible').first();
-                        }
-                        if(editor && editor.length) {
-                            result = $.trim(editor.text() !== '' ? editor.html() : '') + result;
-                            editor.html(result).focus();
-                        }
-                        return false;
-                    });
-
-                $(document)
-                    .off('input paste change', '.note-template-item textarea, .note-template-item input[type="number"], .note-template-item input[type="date"]')
-                    .on('input paste change', '.note-template-item textarea, .note-template-item input[type="number"], .note-template-item input[type="date"]', function() {
-                        generateTemplateOutput();
-                    });
-
-                $(document)
-                    .off('click.plus-trigger', '.note-template-item .plus-trigger')
-                    .on('click.plus-trigger', '.note-template-item .plus-trigger', function() {
-                        let item = $(this).closest('.note-template-item');
-                        if(item.attr('prefix') === '(+)') {
-                            item.removeAttr('prefix');
-                            item.find('>.note-template-text>.label>input[type="checkbox"]').prop('checked', false);
-                            item.removeClass('selected');
-                        }
-                        else {
-                            item.attr('prefix', '(+)');
-                            item.find('>.note-template-text>.label>input[type="checkbox"]').prop('checked', true);
-                            item.addClass('selected');
-                        }
-                        generateTemplateOutput();
-                        return false;
-                    });
-
-                $(document)
-                    .off('click.minus-trigger', '.note-template-item .minus-trigger')
-                    .on('click.minus-trigger', '.note-template-item .minus-trigger', function() {
-                        let item = $(this).closest('.note-template-item');
-                        if(item.attr('prefix') === '(-)') {
-                            item.removeAttr('prefix');
-                            item.find('>.note-template-text>.label>input[type="checkbox"]').prop('checked', false);
-                            item.removeClass('selected');
-                        }
-                        else {
-                            item.attr('prefix', '(-)');
-                            item.find('>.note-template-text>.label>input[type="checkbox"]').prop('checked', true);
-                            item.addClass('selected');
-                        }
-                        generateTemplateOutput();
-                        return false;
-                    });
-
-                $(document)
-                    .off('change.note-template-set-chooser', '.note-template-set-chooser')
-                    .on('change.note-template-set-chooser', '.note-template-set-chooser', function() {
-                        return loadTemplateSet($(this));
-                    });
-
-                $(document)
-                    .off('change.note-exam-template-set-chooser', '.note-exam-template-set-chooser')
-                    .on('change.note-exam-template-set-chooser', '.note-exam-template-set-chooser', function() {
-                        $(this).closest('.note-template-container')
-                            .find('.note-exam-exam-chooser')
-                                .val($(this).find('option:selected').attr('exam'));
-                        return loadExamTemplateSet($(this),
-                            $(this).closest('.note-template-container').find('.note-exam-exam-chooser').first().val(),
-                            $(this).val());
-                    });
-
-                $(document)
-                    .off('change.note-exam-exam-chooser', '.note-exam-exam-chooser')
-                    .on('change.note-exam-exam-chooser', '.note-exam-exam-chooser', function() {
-                        return loadExamTemplateSet($(this),
-                            $(this).val(),
-                            $(this).closest('.note-template-container').find('.note-exam-template-set-chooser').first().val());
-                    });
-
-                $('.remove-section-trigger').click(function() {
-                    $.post('/api/section/deactivate', {
-                        uid: $(this).attr('data-uid'),
-                        memo: 'Deactivated from note',
-                    }, function(_data) {
-                        if(_data) {
-                            if(_data.success) {
-                                fastReload();
-                            }
-                            else {
-                                toastr.error(_data.message);
-                            }
-                        }
-                        else {
-                            toastr.error('Unable to remove section!');
-                        }
-                    }, 'json');
-                    // $(this).closest('.note-section').removeClass('edit');
-                    return false;
-                });
-
-                @if(!$note->visitTemplate)
-                $(document)
-                    .off('mousedown.enable-edit', '.note-section:not(.edit):not(.page-driven)')
-                    .on('mousedown.enable-edit', '.note-section:not(.edit):not(.page-driven)', function(e) {
-                        if($(this).closest('.note-signed-by-hcp').length) return;
-                        e.stopPropagation();
-                        e.preventDefault();
-                        $(this).find('.edit-trigger').first().click();
-                        return false;
-                    });
-                @endif
-
-                $(document)
-                    .off('keydown.collapse-active-segment')
-                    .on('keydown.collapse-active-segment', function(e) {
-                        if(e.which === 27) {
-                            if(!isEventConsumed(e)) {
-                                if($('.visit-segment.edit').length) {
-                                    $('.visit-segment.edit').first().find('.edit-trigger').first().click();
-                                    markEventAsConsumed(e);
-                                    return false;
-                                }
-                            }
-                            else {
-                                // event already consumed!
-                            }
-                        }
-                    });
-
-                scrollToLatest();
-
-                function __moveSection(_uid, _direction) {
-                    $.post('/api/section/move' + _direction, {
-                        uid: _uid
-                    }, function(_data) {
-                        if(_data && _data.success) {
-                            fastReload();
-                        }
-                        else {
-                            if(_data) {
-                                toastr.error(_data.message);
-                            }
-                            else {
-                                toastr.error('Unknown error while moving section');
-                            }
-                        }
-                    }, 'json')
-                }
-
-                $('.move-up-trigger').click(function() {
-                    __moveSection($(this).attr('data-uid'), 'Up');
-                });
-
-                $('.move-down-trigger').click(function() {
-                    __moveSection($(this).attr('data-uid'), 'Down');
-                });
-
-                // refresh once ticket popup is closed
-                /*$('body').off('stag-popup-closed')
-                $('body').on('stag-popup-closed', function() {
-                    if($('#note-single-header').length) {
-                        fastReload();
-                    }
-                });*/
-                // ticket-popup
-                $(document)
-                    .off('click', '.ticket-popup-trigger.note-dashboard-action')
-                    .on('click', '.ticket-popup-trigger.note-dashboard-action', function() {
-                        showMask();
-                        window.noMc = true;
-                        $.get(this.href, (_data) => {
-
-                            if(!$('.ticket-popup').length) {
-                                $('main.stag-content').append('<div class="stag-popup stag-popup-lg ticket-popup mcp-theme-1" stag-popup-key="ticket-popup"></div>');
-                            }
-
-                            $('.ticket-popup').html(_data);
-                            showStagPopup('ticket-popup', true);
-                            $('.ticket-popup .stag-popup.stag-slide').attr('close-all-with-self', 1);
-                            runMCInitializer('patient-tickets'); // run specific mc initer
-                            hideMask();
-                        });
-                        return false;
-                    });
-
-            }
-
-            // scroll to latest created section
-            function scrollToLatest() {
-                window.setTimeout(function() {
-                    let latestSectionTS = $('.latest-section-ts');
-                    if(latestSectionTS.length) {
-                        let latestSection = $('.note-section[data-ts="' + latestSectionTS.text() + '"]');
-                        if(latestSection.length) {
-                            latestSection[0].scrollIntoView({behavior: "smooth", block: "center"});
-                            // latestSection.find('.edit-trigger').first().click();
-                            console.log('DONE!');
-                        }
-                    }
-                }, 100);
-            }
-
-            function loadTemplateSet(_chooser) {
-                if(!_chooser.length || !_chooser.val()) return false;
-                let container = _chooser.closest('.note-template-container');
-                container.find('>.note-template-item').remove();
-                container.find('.please-wait').remove();
-                container.append('<p class="please-wait my-2 text-secondary text-center">Please wait ...</p>');
-                $.get('/note-template-set/' + _chooser.attr('data-section') + '/' + _chooser.val(), function(_html) {
-                    container.find('.please-wait').remove();
-                    container.append(_html);
-                });
-                return false;
-            }
-
-            function loadExamTemplateSet(_chooser, _exam, _templateSet) {
-                if(!_chooser.length || !_chooser.val()) return false;
-                let container = _chooser.closest('.note-template-container');
-                container.find('>.note-template-item').remove();
-                container.find('.please-wait').remove();
-                container.append('<p class="please-wait my-2 text-secondary text-center">Please wait ...</p>');
-                $.get('/note-template-set/exam/' + _exam + '/' + _templateSet, function(_html) {
-                    container.find('.please-wait').remove();
-                    container.append(_html);
-                });
-                return false;
-            }
-
-            function generateOutputForNode(_node) {
-                let template = (_node.attr('prefix') ? _node.attr('prefix') : '') + _node.attr('template'),
-                    value = template;
-                let hasChildText = !!_node.find('>.note-template-children>textarea,>.note-template-children>input[type="number"],>.note-template-children>input[type="date"]').length;
-                let hasChildren = !!_node.find('>.note-template-children>.note-template-item').length;
-                if(hasChildText) {
-                    value = value.replace('{text}',
-                        _node
-                            .find('>.note-template-children')
-                                .find('>textarea,>input[type="number"],>input[type="date"]').first().val());
-                }
-                else if(hasChildren) {
-                    let values = [];
-                    _node.find('>.note-template-children>.note-template-item.selected').each(function() {
-                        values.push(generateOutputForNode($(this)));
-                    });
-                    let combined = '';
-                    for (let i = 0; i < values.length; i++) {
-                        combined += values[i];
-                        if(values.length > 1 && i <= values.length - 2) {
-                            if(i === values.length - 2) {
-                                combined += ' and ';
-                            }
-                            else {
-                                combined += ', ';
-                            }
-                        }
-                    }
-                    value = value.replace('{children}', ' ' + combined).replace('{text}', ' ' + combined);
-                }
-                return value;
-            }
-
-            function generateTemplateOutput() {
-                let container = $('.note-template-container:visible').first();
-                if(!container.length) return '';
-                let lines = [];
-                if(container.find('.note-template-set-chooser').length) {
-                    lines.push('<b>' + container.find('.note-template-set-chooser').first().find('option:selected').text() + '</b>');
-                }
-                else if(container.find('.note-exam-template-set-chooser').length && container.find('.note-exam-exam-chooser').length) {
-                    lines.push('<b>' +
-                        container.find('.note-exam-template-set-chooser').first().find('option:selected').text() +
-                        ': ' +
-                        container.find('.note-exam-exam-chooser').first().find('option:selected').text() +
-                        '</b>');
-                }
-                container.find('>.note-template-item.selected').each(function() {
-                    lines.push('<p class="note-template-output-line">' + generateOutputForNode($(this)) + '</p>');
-                });
-                $('.note-template-output-text:visible').first().html(lines.join(''));
-            }
-
-            addMCInitializer('note-single', init, '#note-single-header');
-        })();
-    </script>

+ 35 - 28
resources/views/app/practice-management/remote-monitoring-row-markup-by-pro-type.blade.php

@@ -234,44 +234,51 @@
     <td>
         @if($mode === 'mcp')
             @if($lastVisitWithin90Days && $iPatient->has_mcp_interacted_with_client_about_rm && $iPatient->number_of_days_with_remote_measurements >= 16 && $iPatient->rm_total_time_in_seconds_by_mcp >= 1200)
-                <span class="text-success font-weight-bold">
-                    <i class="fa fa-check"></i>
-                    ${{friendly_money($pro->mcp_rpm_payment_amount, 0)}}
-                </span>
-                {{--
-                @if($iPatient->mcp_rm_generic_bill_uid)
-                    ${{friendly_money($iPatient->mcp_rm_generic_bill_expected_payment_amount)}}
-                    @if($iPatient->mcp_rm_generic_bill_signed)
-                        <div moe relative
-                             class="d-inline-block {{ $iPatient->mcp_rm_generic_bill_generic_pro_id !== $pro->id ? 'moe-disabled' : '' }}"
-                             title="{{ $iPatient->mcp_rm_generic_bill_generic_pro_id !== $pro->id ? 'Only the bill\'s pro can sign' : '' }}">
-                            <a class="font-weight-bold" href="" show start>Sign</a>
-                            <form url="/api/bill/signAsGenericPro" right>
-                                <input type="hidden" name="uid" value="{{$iPatient->mcp_rm_generic_bill_uid}}">
-                                <p>Sign this bill?</p>
+                @php
+                    $careMonth = \App\Models\CareMonth::where('uid', $iPatient->care_month_uid)->first();
+                @endphp
+                @if($careMonth->mcpRmGenericBill == null )
+
+                    @php
+                        $rpmBillability = $careMonth->calculateBillabilityForMcp();
+                    @endphp
+
+                    @if(!$rpmBillability['billable'])
+                        <div class="alert alert-info">{{$rpmBillability['reason']}}</div>
+                    @else
+                        <div moe relative class="d-inline-block">
+                            <a class="font-weight-normal" href="" show start>Bill ${{$rpmBillability['amount']}}</a>
+                            <form url="/api/careMonth/generateRmGenericBillForMcpAndAutoSign" right>
+                                <input type="hidden" name="uid" value="{{$careMonth->uid}}">
+                                <p>Bill ${{$rpmBillability['amount']}} for this care month?</p>
                                 <div class="mb-0">
-                                    <button class="btn btn-success btn-sm" submit>Sign</button>
+                                    <button class="btn btn-success btn-sm" submit>Bill &amp; Sign</button>
                                     <button class="btn btn-default border btn-sm" cancel>Cancel</button>
                                 </div>
                             </form>
                         </div>
-                    @else
-                        <span class="text-success">Signed</span>
                     @endif
                 @else
-                    <div moe relative class="d-inline-block">
-                        <a class="font-weight-bold" href="" show start>Bill</a>
-                        <form url="/api/careMonth/generateRmGenericBillForMcpAndAutoSign" right>
-                            <input type="hidden" name="uid" value="{{$iPatient->care_month_uid}}">
-                            <p>Bill for this care month and sign it?</p>
-                            <div class="mb-0">
-                                <button class="btn btn-success btn-sm" submit>Bill &amp; Sign</button>
-                                <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                    <div class="font-weight-bold">
+                        <span class="text-success font-weight-normal">
+                            Billed: ${{$careMonth->mcpRmGenericBill->generic_pro_expected_payment_amount}}
+                            <i class="fa fa-check"></i>
+                        </span>
+                        @if(!$careMonth->mcpRmGenericBill->is_signed_by_generic_pro)
+                            <div moe relative class="d-inline-block ml-1">
+                                <a class="font-weight-bold" href="" show start>Sign</a>
+                                <form url="/api/bill/signAsGenericPro" right>
+                                    <input type="hidden" name="uid" value="{{$careMonth->mcpRmGenericBill->uid}}">
+                                    <p>Sign this bill?</p>
+                                    <div class="mb-0">
+                                        <button class="btn btn-success btn-sm" submit>Sign</button>
+                                        <button class="btn btn-default border btn-sm" cancel>Cancel</button>
+                                    </div>
+                                </form>
                             </div>
-                        </form>
+                        @endif
                     </div>
                 @endif
-                --}}
             @else
                 <span class="text-danger font-weight-normal">
                     No