Samson Mutunga 3 år sedan
förälder
incheckning
4b957aa647

+ 14 - 3
app/Http/Controllers/PracticeManagementController.php

@@ -339,6 +339,11 @@ SELECT effective_date, count(*), sum(number_of_units) as units FROM bill WHERE c
             $query = $query->whereIn('hcp_pro_id', $filterByProsIDs);
         }
 
+        $filterByAllyProsIDs = $request->get('ally_pros');
+        if($filterByAllyProsIDs && count($filterByAllyProsIDs)){
+            $query = $query->whereIn('ally_pro_id', $filterByAllyProsIDs);
+        }
+
         $filterByPatientsIDs = $request->get('patients');
         if($filterByPatientsIDs && count($filterByPatientsIDs)){
             $query = $query->whereIn('client_id', $filterByPatientsIDs);
@@ -347,21 +352,27 @@ SELECT effective_date, count(*), sum(number_of_units) as units FROM bill WHERE c
         $status = $request->get('status');
         if($status){
             if($status == 'CANCELLED') $query = $query->where('is_cancelled', true);
+            if($status == 'SIGNED') $query = $query->where('is_signed_by_hcp', true);
             if($status == 'NOT_YET_SIGNED') $query = $query->where('is_signed_by_hcp', false);
             if($status == 'NOT_YET_SIGNED_BUT_ALLY_SIGNED') $query = $query->where('is_signed_by_hcp', false)->where('is_signed_by_ally', true);
+            if($status == 'WITH_BILLS') $query = $query->where('is_signed_by_hcp', true)->where('is_cancelled', false)->whereHas('bills');
             if($status == 'WITHOUT_BILLS') $query = $query->where('is_signed_by_hcp', true)->where('is_cancelled', false)->whereDoesntHave('bills');
+            
         }
 
         
-        $allProsWithNotesIDs = Note::pluck('hcp_pro_id')->toArray();
+        $allProsWithNotesIDs = DB::table('note')->pluck('hcp_pro_id')->toArray();
         $allProsWithNotes = Pro::whereIn('id', $allProsWithNotesIDs)->get();
 
-        $allPatientsWithNotesIDs = Note::pluck('client_id')->toArray();
+        $allPatientsWithNotesIDs = DB::table('note')->pluck('client_id')->toArray();
         $allPatientsWithNotes = Client::whereIn('id', $allPatientsWithNotesIDs)->get();
 
+        $allAllyProsIDs = DB::table('note')->pluck('ally_pro_id')->toArray();
+        $allAllyPros = Pro::whereIn('id', $allAllyProsIDs)->get();
+
         $notes = $query->orderBy('created_at', 'desc')->paginate(30);
 
-        return view('app.practice-management.all-notes', compact('notes', 'filters','allProsWithNotes', 'allPatientsWithNotes'));
+        return view('app.practice-management.all-notes', compact('notes', 'filters','allProsWithNotes', 'allPatientsWithNotes', 'allAllyPros'));
     }
 
     public function dnaNotesPendingMcpSign(Request $request)

+ 2 - 0
resources/views/app/practice-management/all-notes.blade.php

@@ -25,6 +25,7 @@
                         <th class="border-0">Effective Date</th>
                         <th class="border-0">Patient</th>
                         <th class="border-0">MCP</th>
+                        <th class="border-0">All Pro</th>
                         <th class="border-0 w-50">Content</th>
                     </tr>
                 </thead>
@@ -44,6 +45,7 @@
                             <a href="/patients/view/{{ $note->client->uid }}">{{ $note->client->displayName() }}</a>
                         </td>
                         <td>{{ $note->hcpPro ? $note->hcpPro->displayName() : '-' }}</td>
+                        <td>{{ $note->allyPro ? $note->allyPro->displayName() : '-' }}</td>
                         <td class="">
                             <?php
                             $textContent = strip_tags($note->free_text_html);

+ 13 - 2
resources/views/app/practice-management/notes_filters.blade.php

@@ -75,18 +75,26 @@
 		<div class="form-group">
 			<label>Pro(s):</label>
 			<select multiple class="form-control form-control-sm mr-2" name="pros[]" v-model="filters.pros">
-				<option value="">All Pros</option>
 				@foreach($allProsWithNotes as $notePro)
 				<option value="{{ $notePro->id }}">{{ $notePro->displayName() }}</option>
 				@endforeach
 			</select>
 		</div>
 	</div>
+	<div>
+		<div class="form-group">
+			<label>Ally Pro(s):</label>
+			<select multiple class="form-control form-control-sm mr-2" name="ally_pros[]" v-model="filters.ally_pros">
+				@foreach($allAllyPros as $noteAllyPro)
+				<option value="{{ $noteAllyPro->id }}">{{ $noteAllyPro->displayName() }}</option>
+				@endforeach
+			</select>
+		</div>
+	</div>
 	<div>
 		<div class="form-group">
 			<label>Patients(s):</label>
 			<select multiple class="form-control form-control-sm mr-2" name="patients[]" v-model="filters.patients">
-				<option value="">All Patients</option>
 				@foreach($allPatientsWithNotes as $notePatient)
 				<option value="{{ $notePatient->id }}">{{ $notePatient->displayName() }}</option>
 				@endforeach
@@ -99,9 +107,11 @@
 			<label>Status:</label>
 			<select class="form-control form-control-sm mr-2" name="status" v-model="filters.status">
 				<option value="">All Notes</option>
+				<option value="SIGNED">Notes signed</option>
 				<option value="CANCELLED">Cancelled</option>
 				<option value="NOT_YET_SIGNED">Notes not yet signed</option>
 				<option value="NOT_YET_SIGNED_BUT_ALLY_SIGNED">Notes not yet signed (but ally signed)</option>
+				<option value="WITH_BILLS">With Bills</option>
 				<option value="WITHOUT_BILLS">Without Bills</option>
 			</select>
 		</div>
@@ -128,6 +138,7 @@ $allFilterKeys = [
 	'effective_date_value_1',
 	'effective_date_value_2',
 	'pros',
+	'all_pros',
 	'patients',
 	'status'
 ];