Explorar o código

Care months, cm/rm entries [WIP]

Vijayakrishnan Krishnan %!s(int64=5) %!d(string=hai) anos
pai
achega
f57788f8d4

+ 15 - 0
app/Helpers/helpers.php

@@ -13,3 +13,18 @@ if(!function_exists('get_current_session')) {
         return AppSession::where('session_key', request()->cookie('sessionKey'))->first();
     }
 }
+
+if(!function_exists('friendly_date_time')) {
+    function friendly_date_time($value, $includeTime = true) {
+        if(!$value || empty($value)) return "-";
+        try {
+            $result = strtotime($value);
+            $result = date("j M o" . ($includeTime ? ", H:i" : ""), $result);
+            return $result;
+        }
+        catch (Exception $e) {
+            return $value;
+        }
+    }
+}
+

+ 19 - 0
app/Http/Controllers/CareMonthController.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\Models\CareMonth;
+use App\Models\CareMonthEntry;
+use App\Models\Client;
+use App\Models\Pro;
+use App\Models\SectionTemplate;
+use Illuminate\Http\Request;
+
+class CareMonthController extends Controller
+{
+    public function dashboard(Request $request, Client $patient, CareMonth $careMonth )
+    {
+        return view('app.patient.care-month.dashboard', compact('patient', 'careMonth'));
+    }
+
+}

+ 7 - 0
app/Http/Controllers/PatientController.php

@@ -2,6 +2,7 @@
 
 namespace App\Http\Controllers;
 
+use App\Models\CareMonth;
 use App\Models\Client;
 use App\Models\Pro;
 use App\Models\SectionTemplate;
@@ -106,4 +107,10 @@ class PatientController extends Controller
     {
         return view('app.patient.duplicate', compact('patient'));
     }
+
+    public function careMonths(Request $request, Client $patient )
+    {
+        $careMonths = CareMonth::where('client_id', $patient->id)->get();
+        return view('app.patient.care-months', compact('patient', 'careMonths'));
+    }
 }

+ 13 - 0
app/Models/CareMonth.php

@@ -7,4 +7,17 @@ namespace App\Models;
 class CareMonth extends Model
 {
     protected $table = 'care_month';
+
+    public function patient(){
+        return $this->hasOne(Client::class, 'id', 'client_id');
+    }
+
+    public function mcp(){
+        return $this->hasOne(Pro::class, 'id', 'mcp_pro_id');
+    }
+
+    public function entries() {
+        return $this->hasMany(CareMonthEntry::class, 'care_month_id', 'id');
+    }
+
 }

+ 4 - 0
app/Models/CareMonthEntry.php

@@ -7,4 +7,8 @@ namespace App\Models;
 class CareMonthEntry extends Model
 {
     protected $table = 'care_month_entry';
+
+    public function careMonth() {
+        return $this->belongsTo(CareMonth::class, 'care_month_id', 'id');
+    }
 }

+ 5 - 0
public/css/style.css

@@ -108,3 +108,8 @@ hr.m-negator {
 .mcp-theme-1 a, .mcp-theme-1 a:link {
     color: rgb(13, 89, 175);
 }
+.mcp-theme-1 .btn.btn-primary {
+    background: rgb(13, 89, 175);
+    border-color: rgb(13, 89, 175);
+    box-shadow: none;
+}

+ 142 - 0
resources/views/app/patient/care-month/dashboard.blade.php

@@ -0,0 +1,142 @@
+@extends ('layouts.patient')
+
+@section('inner-content')
+    <div class="">
+        <div class="d-flex align-items-center pt-2">
+            <h6 class="my-0 text-secondary">
+                <a href="/patients/view/{{ $patient->uid }}/care-months" class="small text-decoration-none">
+                    <i class="fa fa-chevron-left mr-2"></i>
+                </a>
+                <span class="font-weight-bold">
+                    Care Month</span> starting <span class="text-dark font-weight-bold">{{ friendly_date_time($careMonth->start_date, false) }}
+                </span>
+            </h6>
+            <span class="mx-2 text-secondary">|</span>
+            <div moe>
+                <a start show class="py-0 mb-3">Add CM Entry</a>
+                <form url="/api/careMonth/create">
+                    <input type="hidden" name="clientUid" value="{{ $patient->uid }}">
+                    <div class="mb-2">
+                        <input type="number" min="1" max="12" class="form-control form-control-sm" name="startMonth"
+                               value="" placeholder="Start Month">
+                    </div>
+                    <div class="mb-2">
+                        <input type="number" min="2020" max="2100" class="form-control form-control-sm" name="startYear"
+                               value="" placeholder="Start Year">
+                    </div>
+                    <div class="d-flex align-items-center">
+                        <button class="btn btn-sm btn-primary mr-2" submit>Save</button>
+                        <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
+                    </div>
+                </form>
+            </div>
+            <span class="mx-2 text-secondary">|</span>
+            <div moe>
+                <a start show class="py-0 mb-3">Add RM Entry</a>
+                <form url="/api/careMonth/create">
+                    <input type="hidden" name="clientUid" value="{{ $patient->uid }}">
+                    <div class="mb-2">
+                        <input type="number" min="1" max="12" class="form-control form-control-sm" name="startMonth"
+                               value="" placeholder="Start Month">
+                    </div>
+                    <div class="mb-2">
+                        <input type="number" min="2020" max="2100" class="form-control form-control-sm" name="startYear"
+                               value="" placeholder="Start Year">
+                    </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>
+
+        <hr class="m-negator">
+
+        <?php
+        $entries = $careMonth->entries;
+        ?>
+
+        <div class="row">
+            <div class="col-6">
+                <h6 class="my-0 text-secondary font-weight-bold text-dark">CM Time Entries</h6>
+                <table class="table table-striped table-sm table-bordered mt-2 mb-0">
+                    <thead>
+                    <tr>
+                        <th class="px-2 text-secondary border-bottom-0">Created</th>
+                        <th class="px-2 text-secondary border-bottom-0">Effective Date</th>
+                        <th class="px-2 text-secondary border-bottom-0">Total Time (s)</th>
+                        <th class="px-2 text-secondary border-bottom-0">Details</th>
+                        <th class="px-2 text-secondary border-bottom-0 delete-column">&nbsp;</th>
+                    </tr>
+                    </thead>
+                    <tbody>
+                    @foreach($entries as $entry)
+                        @if($entry->cm_or_rm === "CM")
+                        <tr>
+                            <td class="px-2">{{friendly_date_time($entry->created_at)}}</td>
+                            <td class="px-2">{{friendly_date_time($entry->effective_date)}}</td>
+                            <td class="px-2">{{$entry->achieved_total_time_in_seconds}}</td>
+                            <td class="px-2">-</td>
+                            <td class="px-2 text-center delete-column">
+                                <div moe relative>
+                                    <a start show><i class="fa fa-trash text-danger"></i></a>
+                                    <form url="/api/careMonthEntry/remove" right>
+                                        <input type="hidden" name="uid" value="{{ $entry->uid }}">
+                                        <p class="small">Are you sure you want to delete this CM entry?</p>
+                                        <div class="d-flex align-items-center">
+                                            <button class="btn btn-sm btn-danger mr-2" submit>Delete</button>
+                                            <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
+                                        </div>
+                                    </form>
+                                </div>
+                            </td>
+                        </tr>
+                        @endif
+                    @endforeach
+                    </tbody>
+                </table>
+            </div>
+            <div class="col-6">
+                <h6 class="my-0 text-secondary font-weight-bold text-dark">RM Time Entries</h6>
+                <table class="table table-striped table-sm table-bordered mt-2 mb-0">
+                    <thead>
+                    <tr>
+                        <th class="px-2 text-secondary border-bottom-0">Created</th>
+                        <th class="px-2 text-secondary border-bottom-0">Effective Date</th>
+                        <th class="px-2 text-secondary border-bottom-0">Total Time (s)</th>
+                        <th class="px-2 text-secondary border-bottom-0">Details</th>
+                        <th class="px-2 text-secondary border-bottom-0 delete-column">&nbsp;</th>
+                    </tr>
+                    </thead>
+                    <tbody>
+                    @foreach($entries as $entry)
+                        @if($entry->cm_or_rm === "RM")
+                            <tr>
+                                <td class="px-2">{{friendly_date_time($entry->created_at)}}</td>
+                                <td class="px-2">{{friendly_date_time($entry->effective_date)}}</td>
+                                <td class="px-2">{{$entry->achieved_total_time_in_seconds}}</td>
+                                <td class="px-2">-</td>
+                                <td class="px-2 text-center delete-column">
+                                    <div moe relative>
+                                        <a start show><i class="fa fa-trash text-danger"></i></a>
+                                        <form url="/api/careMonthEntry/remove" right>
+                                            <input type="hidden" name="uid" value="{{ $entry->uid }}">
+                                            <p class="small">Are you sure you want to delete this RM entry?</p>
+                                            <div class="d-flex align-items-center">
+                                                <button class="btn btn-sm btn-danger mr-2" submit>Delete</button>
+                                                <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
+                                            </div>
+                                        </form>
+                                    </div>
+                                </td>
+                            </tr>
+                        @endif
+                    @endforeach
+                    </tbody>
+                </table>
+            </div>
+        </div>
+
+    </div>
+@endsection

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

@@ -0,0 +1,64 @@
+@extends ('layouts.patient')
+
+@section('inner-content')
+    <div class="">
+        <div class="d-flex align-items-center pt-2">
+            <h6 class="my-0 font-weight-bold text-secondary">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">
+                    <input type="hidden" name="clientUid" value="{{ $patient->uid }}">
+                    <div class="mb-2">
+                        <input type="number" min="1" max="12" class="form-control form-control-sm" name="startMonth"
+                               value="" placeholder="Start Month">
+                    </div>
+                    <div class="mb-2">
+                        <input type="number" min="2020" max="2100" class="form-control form-control-sm" name="startYear"
+                               value="" placeholder="Start Year">
+                    </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>
+            <tr>
+                <th class="px-2 text-secondary border-bottom-0">Start Date</th>
+                <th class="px-2 text-secondary border-bottom-0">CM Total Time</th>
+                <th class="px-2 text-secondary border-bottom-0">MCP</th>
+                <th class="px-2 text-secondary border-bottom-0">Created</th>
+                <th class="px-2 text-secondary border-bottom-0 delete-column">&nbsp;</th>
+            </tr>
+            </thead>
+            <tbody>
+            @foreach($careMonths as $careMonth)
+                <tr>
+                    <td class="px-2">
+                        <a href="/patients/view/{{ $patient->uid }}/care-months/view/{{ $careMonth->uid }}">{{friendly_date_time($careMonth->start_date, false)}}</a>
+                    </td>
+                    <td class="px-2">{{$careMonth->cm_total_time_in_seconds}} seconds</td>
+                    <td class="px-2">{{$careMonth->mcp ? $careMonth->mcp->name_display : '-'}}</td>
+                    <td class="px-2">{{friendly_date_time($careMonth->created_at)}}</td>
+                    <td class="px-2 text-center delete-column">
+                        <div moe relative>
+                            <a start show><i class="fa fa-trash text-danger"></i></a>
+                            <form url="/api/careMonth/remove" right>
+                                <input type="hidden" name="uid" value="{{ $careMonth->uid }}">
+                                <p class="small">Are you sure you want to delete this care-month?</p>
+                                <div class="d-flex align-items-center">
+                                    <button class="btn btn-sm btn-danger mr-2" submit>Delete</button>
+                                    <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
+                                </div>
+                            </form>
+                        </div>
+                    </td>
+                </tr>
+            @endforeach
+            </tbody>
+        </table>
+    </div>
+@endsection

+ 4 - 0
routes/web.php

@@ -65,6 +65,10 @@ Route::middleware('pro.auth')->group(function () {
         Route::get('education', 'PatientController@education')->name('education');
         Route::get('messaging', 'PatientController@messaging')->name('messaging');
         Route::get('duplicate', 'PatientController@duplicate')->name('duplicate');
+        Route::get('care-months', 'PatientController@careMonths')->name('care-months');
+        Route::name('care-months.view.')->prefix('care-months/view/{careMonth}')->group(function () {
+            Route::get('', 'CareMonthController@dashboard')->name('dashboard');
+        });
     });
 
     // 2-pane outer page housing lhs (practice management) and rhs (video call)