Explorar o código

Care month refactor

Samson Mutunga hai 1 ano
pai
achega
1d96ebb0f9

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

@@ -12,8 +12,9 @@ use Illuminate\Support\Facades\File;
 
 class CareMonthController extends Controller
 {
-    public function dashboard(Request $request, Client $patient, CareMonth $careMonth )
+    public function dashboard(Request $request, Client $patient, $careMonth )
     {
+        $careMonth = CareMonth::where('uid', $careMonth)->first();
         $files = File::allFiles(resource_path('views/app/entry-templates/cm'));
         $cmTemplates = [];
         foreach ($files as $file) {

+ 4 - 3
app/Http/Controllers/PatientController.php

@@ -30,6 +30,7 @@ use App\Models\ProProAccess;
 use App\Models\SectionTemplate;
 use App\Models\Shipment;
 use App\Models\SupplyOrder;
+use App\Models\CareMonthView;
 use App\Models\Ticket;
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\DB;
@@ -414,9 +415,8 @@ class PatientController extends Controller
 
     public function careMonths(Request $request, Client $patient )
     {
-        $careMonths = CareMonth::where('client_id', $patient->id)->with('rmBill', 'mcp', 'rmmPro', 'rmePro', 'cmReasons', 'claims')->orderBy('start_date', 'desc')->get();
-        $notes = Note::where('is_cancelled', false)->get();
-        return view('app.patient.care-months', compact('patient', 'careMonths', 'notes'));
+        $careMonths = CareMonthView::where('client_id', $patient->id)->orderBy('start_date', 'desc')->get();
+        return view('app.patient.care-months', compact('patient', 'careMonths'));
     }
 
     public function presence(Request $request, Client $patient )
@@ -626,6 +626,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');
         $appointmentProIDs = $appointments->map(function($_item) {
             return $_item->pro_id;
         });

+ 13 - 0
app/Models/CareMonthView.php

@@ -0,0 +1,13 @@
+<?php
+
+namespace App\Models;
+
+# use Illuminate\Database\Eloquent\Model;
+
+use DateTime;
+use Illuminate\Support\Collection;
+
+class CareMonthView extends Model
+{
+    protected $table = 'care_month_view';
+}

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

@@ -0,0 +1,182 @@
+@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

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

@@ -131,33 +131,33 @@
 			<td>{{ $careMonth->number_of_days_with_remote_measurements }}</td>
                     <td>{{time_in_hrminsec($careMonth->rm_total_time_in_seconds)}}</td>
                     <td>
-                        @if($careMonth->rmBill)
-                            {{ $careMonth->rmBill->code }}
+                        @if($careMonth->rm_bill_code)
+                            {{ $careMonth->rm_bill_code }}
                         @else
                             -
                         @endif
                     </td>
-                    <td>{{$careMonth->mcp ? $careMonth->mcp->displayName() : '-'}}</td>
-                    <td>{{$careMonth->rmmPro ? $careMonth->rmmPro->displayName() : '-'}}</td>
-                    <td>{{$careMonth->rmePro ? $careMonth->rmePro->displayName() : '-'}}</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 = $careMonth->cmReasons->pluck('code')->toArray(); ?>
-                            {{ implode(', ', $careMonthCmReasonCodes) }}
+                            <?php $careMonthCmReasonCodes = json_decode($careMonth->cm_reason_codes); ?>
+                            {{ implode(', ', $careMonthCmReasonCodes ?? []) }}
                         </div>
                         <div class="d-flex flex-column">
-                            <?php $careMonthRmReasonCodes = $careMonth->rmReasons->pluck('code')->toArray(); ?>
-                            {{ implode(', ', $careMonthRmReasonCodes) }}
+                            <?php $careMonthRmReasonCodes = json_decode($careMonth->cm_rm_reason_codes); ?>
+                            {{ implode(', ', $careMonthRmReasonCodes ?? []) }}
                         </div>
                     </td>
                     @if($pro->pro_type === 'ADMIN')
                     <td>
-                        @foreach($careMonth->claims as $claim)
                             <?php
-                                $claimCpts = $claim->lines->pluck('cpt')->toArray();
+                                $claims = json_decode($careMonth->claims ?? '[]');
                             ?>
+                            @foreach($claims as $claim)
                             <div>
-                                {{ friendly_date($claim->created_at) }} | ${{$claim->expected_total}} | CPTs: {{ implode(', ', $claimCpts) }} | {{$claim->status}}
+                                {{ friendly_date($claim->created_at) }} | ${{$claim->expected_total}} | CPTs: {{ implode(', ', []) }} | {{$claim->status}}
                                 
                             </div>
                         @endforeach