Samson Mutunga 3 years ago
parent
commit
cb72166ccd

+ 11 - 0
app/Http/Controllers/DnaController.php

@@ -98,6 +98,17 @@ class DnaController extends Controller
         return view('app.dna.appointments', compact('appointments', 'filters'));
     }
 
+    public function careMonths(Request $request){
+        $filters = $request->all();
+        $careMonths = CareMonth::select('care_month.*')
+                        ->join('client', 'client.id', '=', 'care_month.client_id')
+                        ->where('client.default_na_pro_id', $this->performer->pro->id);
+        $this->filterMultiQuery($request, $careMonths, 'raw_date', 'date_category', 'date_value_1', 'date_value_2');
+        $this->filterSimpleQuery($request, $careMonths, 'status', 'status');
+        $careMonths = $careMonths->orderBy('created_at', 'DESC')->paginate(20);
+        return view('app.dna.care-months', compact('careMonths', 'filters'));
+    }
+
     public function bills(Request $request)
     {
         $data = [];

+ 5 - 0
app/Models/CareMonth.php

@@ -109,4 +109,9 @@ class CareMonth extends Model
         return $this->hasOne(Note::class, 'id', 'most_recent_mcp_note_id');
     }
 
+    public function note()
+    {
+        return $this->hasOne(Note::class, 'id', 'note_id');
+    }
+
 }

+ 93 - 0
resources/views/app/dna/care-months.blade.php

@@ -0,0 +1,93 @@
+@extends ('layouts/template')
+
+@section('content')
+<div class="p-3 mcp-theme-1" id="patients-list">
+    <div class="card">
+
+        <div class="card-header px-3 py-2 d-flex align-items-center">
+            <strong class="mr-4">
+                <i class="fas fa-calendar-alt"></i>
+                Care Months
+            </strong>
+        </div>
+
+        <div class="card-body p-0">
+            <div class="p-3">
+                <!-- Filter -->
+            </div>
+            <table class="table table-condensed p-0 m-0">
+                <thead class="bg-light">
+                    <tr>
+                        <th class="px-3 border-0">Chart #</th>
+                        <th class="px-3 border-0">Name</th>
+                        <th class="px-3 border-0">DOB</th>
+                        <th class="px-3 border-0">Age</th>
+                        <th class="px-3 border-0">Sex</th>
+                        <th class="px-3 border-0">Insurance</th>
+                        <th class="px-3 border-0">MCP</th>
+                        <th class="px-3 border-0"># Meas. this mt.</th>
+                        <th class="px-3 border-0">My Bill</th>
+                    </tr>
+                </thead>
+                <tbody>
+                    @foreach($careMonths as $careMonth)
+                    <tr>
+
+                        <td class="px-3 text-nowrap">
+                            <a native target="_blank" href="{{route('patients.view.dashboard', $careMonth->client)}}">
+                                {{$careMonth->client->chart_number}}
+                            </a>
+                        </td>
+                        <td class="px-3 text-nowrap">
+                            <a native target="_blank" href="{{route('patients.view.dashboard', $careMonth->client)}}">
+                                {{$careMonth->client->displayName()}}
+                            </a>
+                        </td>
+                        <td class="text-nowrap">{{ friendly_date_time($careMonth->client->dob, false) }}</td>
+                        <td>{{ $careMonth->client->age_in_years ?  $careMonth->client->age_in_years : '-' }}</td>
+                        <td>{{ $careMonth->client->sex }}</td>
+                        <td>
+                            <?php $coverageStatus = $careMonth->client->getPrimaryCoverageStatus(); ?>
+                            <div class="text-nowrap">
+                                @if($coverageStatus === 'YES')
+                                <i class="fa fa-check-circle text-success" data-toggle="tooltip" data-placement="bottom" title="Covered"></i>
+                                @elseif($coverageStatus === 'NO')
+                                <i class="fa fa-times text-danger" data-toggle="tooltip" data-placement="bottom" title="Not Covered"></i>
+                                @else
+                                <i class="fa fa-exclamation-triangle text-warning-mellow" data-toggle="tooltip" data-placement="bottom" title="Unknown"></i>
+                                @endif
+                                <?php $coverage = $careMonth->client->getPrimaryCoverage(); ?>
+                                @if($coverage)
+                                {{$coverage->insuranceDisplayName()}}
+                                @endif
+                            </div>
+                        </td>
+                        <td>{{ $careMonth->client->mcp->displayName() }}</td>
+                        <td>{{ $careMonth->number_of_days_with_remote_measurements }}</td>
+                        <td>
+                            <?php $bill = $careMonth->rmBill; ?>
+                            @if($bill)
+                            <div class="d-flex flex-column">
+                                <span>Code: {{ $bill->code }}</span>
+                                <a href="/patients/view/{{ $bill->note->client->uid }}/notes/view/{{ $bill->note->uid }}" class="font-weight-bold">Note</a>
+                            </div>
+                            @endif
+                        </td>
+                    </tr>
+                    @endforeach
+
+                    @if(count($careMonths) === 0)
+                    <tr>
+                        <td colspan="9">No records found!</td>
+                    </tr>
+                    @endif
+                </tbody>
+
+            </table>
+            <div class="ml-2 mt-2">
+                {{ $careMonths->appends(request()->input())->links() }}
+            </div>
+        </div>
+    </div>
+</div>
+@endsection

+ 111 - 0
resources/views/app/dna/care_months_filters.blade.php

@@ -0,0 +1,111 @@
+<style>
+	#dna-care-months-filters label {
+		font-weight: bold;
+	}
+
+	#dna-care-months-filters .mw-100px {
+		min-width: 100px;
+	}
+	.filter-container{
+		display: flex;
+		align-items: flex-start;
+		flex-wrap: wrap;
+	}
+	.filter-container >div {
+		width: 165px;
+	}
+	.filter-container >div:not(:last-child) {
+		margin-right: 15px;
+	}
+</style>
+<form id="dna-care-months-filters" method="GET" action="{{ route('dna.careMonths') }}" class="filter-container" v-cloak>
+	   <!-- DATE -->
+	<div class="">
+		<div class="form-group">
+			<label>Date:</label>
+			<select name="date_category" class="form-control input-sm" v-model="filters.date_category">
+				<option value="">All</option>
+				<option value="EXACTLY">Exactly</option>
+				<option value="LESS_THAN">Less Than</option>
+				<option value="GREATER_THAN">Greater Than</option>
+				<option value="BETWEEN">Between</option>
+				<option value="NOT_BETWEEN">Not Between</option>
+			</select>
+			<div v-show="filters.date_category" class="mt-2">
+				<div>
+					<input  name="date_value_1" v-model="filters.date_value_1" type="date" class="form-control input-sm"/>
+				</div>
+				<div v-show="filters.date_category === 'BETWEEN' || filters.date_category === 'NOT_BETWEEN'" class="mt-2">
+					<input name="date_value_2" v-model="filters.date_value_2" type="date" class="form-control input-sm"/>
+				</div>
+			</div>
+		</div>
+	</div>
+	<!-- STATUS -->
+	<div class="">
+		<div class="form-group">
+			<label>Status:</label>
+			<select name="status" class="form-control input-sm" v-model="filters.status">
+				<option value="">All</option>
+				<option value="PENDING">PENDING</option>
+				<option value="CONFIRMED">CONFIRMED</option>
+				<option value="CANCELLED">CANCELLED</option>
+				<option value="COMPLETED">COMPLETED</option>
+			</select>
+		</div>
+	</div>
+
+	<div class="">
+		<div class="form-group">
+			<label>&nbsp;</label>
+			<div class="d-flex">
+				<button type="submit" v-on:click.prevent="doSubmit()" class="btn btn-primary btn-sm mr-2"><i class="fas fa-filter"></i> Filter</button>
+				<a href="#" v-on:click.prevent="fastLoad('{{route('dna.careMonths')}}')" class="btn btn-link btn-sm text-danger">Clear Filters</a>
+			</div>
+		</div>
+	</div>
+</form>
+
+<?php
+$loadedFilters = $filters;
+$allFilterKeys = [
+	'date_category',
+	'date_value_1',
+	'date_value_2',
+	'status'
+];
+for ($i=0; $i < count($allFilterKeys); $i++) {
+	if (!isset($loadedFilters[$allFilterKeys[$i]]) || !$loadedFilters[$allFilterKeys[$i]]) {
+		$loadedFilters[$allFilterKeys[$i]] = '';
+	}
+}
+?>
+
+<script>
+	(function() {
+		function init() {
+			window.apapp = new Vue({
+				el: '#dna-care-months-filters',
+				delimiters: ['@{{', '}}'],
+				data: {
+					filters: <?= json_encode($loadedFilters) ?>
+				},
+				methods: {
+					doSubmit: function() {
+						fastLoad('{{ route("dna.careMonths") }}?' + $('#dna-care-months-filters').serialize());
+						return false;
+					},
+					init: function() {
+
+					}
+				},
+				mounted: function() {
+					this.init();
+				},
+			});
+
+
+		}
+		addMCInitializer('dna-care-months-filters', init, '#dna-care-months-filters');
+	})();
+</script>

+ 1 - 0
resources/views/layouts/template.blade.php

@@ -214,6 +214,7 @@
                             <a class="dropdown-item" href="/practice-management/my-teams">My Teams</a>
                             <a class="dropdown-item" href="{{ route('dna.encounters') }}">Encounters</a>
                             <a class="dropdown-item" href="{{ route('dna.appointments') }}">Appointments</a>
+                            <a class="dropdown-item" href="{{ route('dna.careMonths') }}">Care Months</a>
 
                         @endif
 

+ 2 - 0
routes/web.php

@@ -110,6 +110,8 @@ Route::middleware('pro.auth')->group(function () {
         Route::get('encounters', 'DnaController@encounters')->name('encounters');
         Route::get('notes', 'DnaController@notes')->name('notes');
         Route::get('appointments', 'DnaController@appointments')->name('appointments');
+        Route::get('care-months', 'DnaController@careMonths')->name('careMonths');
+
         Route::get('bills', 'DnaController@bills')->name('bills');
         Route::get('erx-and-orders', 'DnaController@erx_and_orders')->name('erx_and_orders');
         Route::get('reports', 'DnaController@reports')->name('reports');