Parcourir la source

Updated appointments

Samson Mutunga il y a 1 an
Parent
commit
3a73cf9e2b

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

@@ -625,8 +625,7 @@ class PatientController extends Controller
 
     public function appointments(Request $request, Client $patient, $forPro = 'all', $status = 'all') {
         $pros = $this->pros;
-        $appointments = $patient->appointmentsForProByStatus($forPro, strtoupper($status));
-        $appointments = $appointments->with('pro');
+        $appointments = $patient->appointmentsViewForProByStatus($forPro, strtoupper($status));
         $appointmentProIDs = $appointments->map(function($_item) {
             return $_item->pro_id;
         });

+ 13 - 0
app/Models/AppointmentView.php

@@ -0,0 +1,13 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Relations\HasOne;
+
+# use Illuminate\Database\Eloquent\Model;
+
+class AppointmentView extends Model
+{
+    protected $table = 'appointment_view';
+
+}

+ 14 - 0
app/Models/Client.php

@@ -444,6 +444,20 @@ class Client extends Model
         return $appointments->get();
     }
 
+    public function appointmentsViewForProByStatus($forPro = 'all', $status = 'all')
+    {
+        $appointments = AppointmentView::where('client_id', $this->id);
+        if($forPro !== 'all') {
+            $forPro = Pro::where('uid', $forPro)->first();
+            $appointments = $appointments->where('pro_id', $forPro->id);
+        }
+        if($status !== 'ALL') {
+            $appointments = $appointments->where('status', $status);
+        }
+        $appointments = $appointments->orderBy('raw_date', 'desc')->orderBy('raw_start_time', 'desc');
+        return $appointments->get();
+    }
+
     public function rmCompany() {
         return $this->hasOne(Company::class, 'id', 'rm_company_id');
     }

+ 2 - 2
resources/views/app/patient/appointments.blade.php

@@ -42,7 +42,7 @@
                                 {{friendly_date($appointment->raw_date) . ' ' . friendly_time($appointment->raw_start_time)}} <span class="text-sm">{{friendly_timezone($appointment->timezone)}}</span>
                             </a>
                         </td>
-                        <td>{{ $appointment->pro->displayName() }}</pre></td>
+                        <td>{{ $appointment->ppro_display_name }}</pre></td>
                         <td>{{ $appointment->title }}</td>
                         <td>{{ $appointment->description }}</td>
                         <td>
@@ -54,7 +54,7 @@
                         </td>
                         <td>
                             @if($appointment->status !== 'CANCELLED' && $appointment->status !== 'COMPLETED')
-                            @include('app.patient.partials.appointment-confirmation')
+                            @include('app.patient.partials.appointment-confirmation-light')
                             @endif
                         </td>
                         <td>

+ 0 - 182
resources/views/app/patient/care-months.blade copy.php

@@ -1,182 +0,0 @@
-@extends ('layouts.patient')
-
-@section('inner-content')
-
-    @if($patient->has_mcp_done_onboarding_visit !== 'YES')
-        <div class="pt-2 d-flex align-items-start">
-            <h6 class="my-0 text-secondary d-flex align-items-start">
-                <div>
-                    <div>
-                        <span class="text-dark font-weight-bold">Care Months</span>
-                    </div>
-                    <div class="text-dark d-inline-flex align-items-center mt-2">
-                                    <span class="mr-2">
-                                        <i class="fa fa-exclamation-triangle"></i>
-                                        MCP Onboarding Visit Pending
-                                    </span>
-                        <div moe>
-                            <a start show>Update</a>
-                            <form url="/api/client/updateMcpOnboardingVisitInfo" class="mcp-theme-1">
-                                <input type="hidden" name="uid" value="{{$patient->uid}}">
-                                <div class="mb-2">
-                                    <select name="hasMcpDoneOnboardingVisit"
-                                            class="form-control form-control-sm"
-                                            onchange="toggleDisabledAsNeeded(this, 'YES', 'if-visit-done')">
-                                        <option value="">-- Select Status --</option>
-                                        <option value="YES" {{ $patient->has_mcp_done_onboarding_visit === 'YES' ? 'selected' : '' }}>YES</option>
-                                        <option value="NO" {{ $patient->has_mcp_done_onboarding_visit === 'NO' ? 'selected' : '' }}>NO</option>
-                                        <option value="UNKNOWN" {{ $patient->has_mcp_done_onboarding_visit === 'UNKNOWN' ? 'selected' : '' }}>UNKNOWN</option>
-                                    </select>
-                                </div>
-                                <div class="mb-2">
-                                    <input type="date" class="if-visit-done form-control form-control-sm" disabled name="mcpOnboardingVisitDate" max="{{ date('Y-m-d') }}">
-                                </div>
-                                <div class="mb-2">
-                                    <select name="mcpOnboardingVisitNoteUid" disabled
-                                            class="form-control form-control-sm if-visit-done"
-                                            onchange="toggleVisibilityAsNeeded(this, '', 'if-note-outside-system')">
-                                        <option value="">-- Visit Note --</option>
-                                        @foreach ($notes as $note)
-                                            @if(!empty($note->title) && $note->client_id === $patient->id && !$note->is_cancelled)
-                                                <option value="{{$note->uid}}">{{$note->hcpPro->displayName()}} ({{friendly_date_time($note->effective_dateest, false)}})</option>
-                                            @endif
-                                        @endforeach
-                                    </select>
-                                </div>
-                                <div class="mb-2 if-note-outside-system">
-                                                <textarea class="form-control form-control-sm"
-                                                          name="reasonOnboardingVisitNoteOutsideSystem"
-                                                          placeholder="Visit note outside the system reason"></textarea>
-                                </div>
-                                <div>
-                                    <button submit class="btn btn-sm btn-primary mr-1">Submit</button>
-                                    <button cancel class="btn btn-sm btn-default border">Cancel</button>
-                                </div>
-                            </form>
-                        </div>
-                    </div>
-                </div>
-            </h6>
-        </div>
-    @else
-
-    <div class="">
-        <div class="d-flex align-items-center pt-2">
-            <h6 class="my-0 font-weight-bold font-size-16">Care Months</h6>
-            <span class="mx-2 text-secondary">|</span>
-            <div moe>
-                <a start show class="py-0 mb-3">Add</a>
-                <form url="/api/careMonth/create" redir="patients/view/{{ $patient->uid }}/care-months/view/[data]">
-                    <input type="hidden" name="clientUid" value="{{ $patient->uid }}">
-                    <div class="mb-2">
-                        <label class="text-secondary text-sm mb-1">Month *</label>
-                        <select name="startMonth" class="form-control form-control-sm" required>
-                            <option value="">-- Start Month --</option>
-                            <option value="1" {{ date('n') === '1' ? 'selected' : '' }}>January</option>
-                            <option value="2" {{ date('n') === '2' ? 'selected' : '' }}>February</option>
-                            <option value="3" {{ date('n') === '3' ? 'selected' : '' }}>March</option>
-                            <option value="4" {{ date('n') === '4' ? 'selected' : '' }}>April</option>
-                            <option value="5" {{ date('n') === '5' ? 'selected' : '' }}>May</option>
-                            <option value="6" {{ date('n') === '6' ? 'selected' : '' }}>June</option>
-                            <option value="7" {{ date('n') === '7' ? 'selected' : '' }}>July</option>
-                            <option value="8" {{ date('n') === '8' ? 'selected' : '' }}>August</option>
-                            <option value="9" {{ date('n') === '9' ? 'selected' : '' }}>September</option>
-                            <option value="10" {{ date('n') === '10' ? 'selected' : '' }}>October</option>
-                            <option value="11" {{ date('n') === '11' ? 'selected' : '' }}>November</option>
-                            <option value="12" {{ date('n') === '12' ? 'selected' : '' }}>December</option>
-                        </select>
-                    </div>
-                    <div class="mb-2">
-                        <label class="text-secondary text-sm mb-1">Year *</label>
-                        <select name="startYear" class="form-control form-control-sm" required>
-                            <option value="2023" {{ date('Y') === '2023' ? 'selected' : '' }}>2023</option>
-                        </select>
-                    </div>
-                    <div class="d-flex align-items-center">
-                        <button class="btn btn-sm btn-primary mr-2" submit>Save</button>
-                        <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
-                    </div>
-                </form>
-            </div>
-        </div>
-        <table class="table table-striped table-sm table-bordered mt-2 mb-0">
-            <thead class="bg-light">
-            <tr>
-                <th class="text-secondary border-bottom-0">Start Date</th>
-                <th class="text-secondary border-bottom-0"># Days w/ Remote Meas.</th>
-                <th class="text-secondary border-bottom-0">Total Time</th>
-                <th class="text-secondary border-bottom-0">Bill</th>
-                <th class="text-secondary border-bottom-0">MCP</th>
-                <th class="text-secondary border-bottom-0">RMM</th>
-                <th class="text-secondary border-bottom-0">RME</th>
-                <th class="text-secondary border-bottom-0">ICDs</th>
-                @if($pro->pro_type === 'ADMIN')
-                    <th class="text-secondary border-bottom-0">Claims</th>
-                @endif
-                <th class="text-secondary border-bottom-0">Matrix</th>
-            </tr>
-            </thead>
-            <tbody>
-            @foreach($careMonths as $careMonth)
-                <tr>
-                    <td>
-                        <a href="/patients/view/{{ $patient->uid }}/care-months/view/{{ $careMonth->uid }}">
-                            {{friendly_date($careMonth->start_date)}}
-
-                            @if($careMonth->was_rm_setup_performed)
-                            <i class="fas fa-clipboard-check text-success" title="RM setup was performed on this care month."></i>
-                            @endif
-                        </a>
-                    </td>
-			<td>{{ $careMonth->number_of_days_with_remote_measurements }}</td>
-                    <td>{{time_in_hrminsec($careMonth->rm_total_time_in_seconds)}}</td>
-                    <td>
-                        @if($careMonth->rm_bill_code)
-                            {{ $careMonth->rm_bill_code }}
-                        @else
-                            -
-                        @endif
-                    </td>
-                    <td>{{$careMonth->mcp_pro_display_name ? $careMonth->mcp_pro_display_name : '-'}}</td>
-                    <td>{{$careMonth->rmm_pro_display_name ? $careMonth->rmm_pro_display_name : '-'}}</td>
-                    <td>{{$careMonth->rme_pro_display_name ? $careMonth->rme_pro_display_name : '-'}}</td>
-                    <td>
-                        <div class="d-flex flex-column">
-                            <?php $careMonthCmReasonCodes = json_decode($careMonth->cm_claim_codes); ?>
-                            {{ implode(', ', $careMonthCmReasonCodes) }}
-                        </div>
-                        <div class="d-flex flex-column">
-                            <?php $careMonthRmReasonCodes = $careMonth->rmReasons->pluck('code')->toArray(); ?>
-                            {{ implode(', ', $careMonthRmReasonCodes) }}
-                        </div>
-                    </td>
-                    @if($pro->pro_type === 'ADMIN')
-                    <td>
-                        @foreach($careMonth->claims as $claim)
-                            <?php
-                                $claimCpts = $claim->lines->pluck('cpt')->toArray();
-                            ?>
-                            <div>
-                                {{ friendly_date($claim->created_at) }} | ${{$claim->expected_total}} | CPTs: {{ implode(', ', $claimCpts) }} | {{$claim->status}}
-                                
-                            </div>
-                        @endforeach
-                    </td>
-                    @endif
-                    <td>
-                        <a native target="_blank"
-                           open-in-stag-popup
-                           mc-initer="cm-matrix-{{$patient->id}}"
-                           title="Care Month Matrix: {{date('M Y', strtotime($careMonth->start_date))}}"
-                           href="/patient-care-month-matrix/{{$careMonth->uid}}">
-                            View
-                        </a>
-                    </td>
-                </tr>
-            @endforeach
-            </tbody>
-        </table>
-    </div>
-
-    @endif
-@endsection

+ 7 - 1
resources/views/app/patient/care-months.blade.php

@@ -156,8 +156,14 @@
                                 $claims = json_decode($careMonth->claims ?? '[]');
                             ?>
                             @foreach($claims as $claim)
+                            <?php
+                                $claimCpts = [];
+                                foreach($claim->claim_lines as $line){
+                                    array_push($claimCpts, $line->cpt);
+                                }
+                            ?>
                             <div>
-                                {{ friendly_date($claim->created_at) }} | ${{$claim->expected_total}} | CPTs: {{ implode(', ', []) }} | {{$claim->status}}
+                                {{ friendly_date($claim->created_at) }} | ${{$claim->expected_total}} | CPTs: {{ implode(', ', $claimCpts) }} | {{$claim->status}}
                                 
                             </div>
                         @endforeach

+ 81 - 0
resources/views/app/patient/partials/appointment-confirmation-light.blade.php

@@ -0,0 +1,81 @@
+<div class="d-flex" id="appointment-confirmation">
+    <div class="flex-grow-1">
+        @if($appointment->status === 'PENDING' && !$appointment->latest_confirmation_request_at && !$appointment->latest_confirmation_decision_at)
+            <b class="text-warning-mellow">Not requested yet</b>
+            <div>
+                @include('app.patient.partials.appointment-request-confirmation', ['label' => 'Request Confirmation'])
+            </div>
+        @endif
+        @if($appointment->latest_confirmation_decision_at)
+            @if($appointment->latest_confirmation_decision_enum === 'CONFIRMED')
+                <div class="text-nowrap">
+                    <b class="text-success">{{ucwords($appointment->latest_confirmation_decision_enum)}}</b>
+                    <span class="text-secondary ml-1">on {{friendlier_date_time(convertToTimezone($appointment->latest_confirmation_decision_at, 'US/Eastern'))}}</span>
+                </div>
+            @elseif($appointment->latest_confirmation_decision_enum === 'CANCELLED')
+                <div class="text-nowrap">
+                    <b class="text-warning-mellow">{{ucwords($appointment->latest_confirmation_decision_enum)}}</b>
+                    <span class="text-secondary ml-1">on {{friendlier_date_time(convertToTimezone($appointment->latest_confirmation_decision_at, 'US/Eastern'))}}</span>
+                </div>
+                <div>
+                    <a href="/patients/view/{{$patient->uid}}/calendar/{{$appointment->uid}}" class="font-weight-bold">
+                        Re-schedule
+                    </a>
+                </div>
+            @elseif($appointment->latest_confirmation_decision_enum === 'WAIVED')
+                <div class="text-nowrap">
+                    <b class="text-warning-mellow">{{ucwords($appointment->latest_confirmation_decision_enum)}}</b>
+                    <span class="text-secondary ml-1">on {{friendlier_date_time(convertToTimezone($appointment->latest_confirmation_decision_at, 'US/Eastern'))}}</span>
+                </div>
+            @endif
+            @if($appointment->latest_confirmation_decision_memo)
+                <div class="my-1 border text-sm px-2 py-1 bg-white max-width-300px">
+                    <span>Client feedback:</span>
+                    <span class="pl-2">{{ $appointment->latest_confirmation_decision_memo }}</span>
+                </div>
+            @endif
+        @endif
+        @if($appointment->latest_confirmation_request_at) {{-- requested but not confirmed yet --}}
+            <div class="text-nowrap">
+                <b class="">Requested</b>
+                <span class="text-secondary ml-1">on {{friendlier_date_time(convertToTimezone($appointment->latest_confirmation_request_at, 'US/Eastern'))}}</span>
+            </div>
+            @if($appointment->is_request_pending)
+                <div class="text-sm">
+                    <i class="fa fa-exclamation-triangle text-warning-mellow"></i>
+                    Request Pending
+                </div>
+            @endif
+            @if($appointment->status !== 'COMPLETED' && $appointment->status !== 'CONFIRMED' && $appointment->status !== 'CANCELLED')
+            <div>
+              @include('app.patient.partials.appointment-request-confirmation', ['label' => 'Re-request Confirmation'])
+            </div>
+            @endif
+        @endif
+    </div>
+    @if($appointment->latest_confirmation_request_at || $appointment->latest_confirmation_decision_at)
+        <div class="ml-4 px-2 c-pointer position-relative appointment-confirmation-history-trigger on-hover-show"
+             data-uid="{{$appointment->uid}}">
+            <i class="fa fa-history text-secondary"></i>
+            <div class="appointment-confirmation-history on-hover-content">
+
+            </div>
+        </div>
+    @endif
+</div>
+
+<script>
+    (function() {
+        function init() {
+            $('.appointment-confirmation-history-trigger')
+                .off('mouseenter.appointment-confirmation-history')
+                .on('mouseenter.appointment-confirmation-history', function() {
+                    let container = $(this).find('.appointment-confirmation-history')
+                        .empty()
+                        .append('<span class="text-secondary">Please wait ...</span>');
+                    container.load('/appointment-confirmation-history/' + $(this).attr('data-uid'));
+                });
+        }
+        addMCInitializer('appointment-confirmation', init, '#appointment-confirmation');
+    }).call(window);
+</script>