|
@@ -5,6 +5,7 @@ namespace App\Http\Controllers;
|
|
|
use App\Lib\Backend;
|
|
|
use App\Models\Appointment;
|
|
|
use App\Models\AppSession;
|
|
|
+use App\Models\ClientMemo;
|
|
|
use App\Models\ClientProChange;
|
|
|
use App\Models\ClientSMS;
|
|
|
use App\Models\Facility;
|
|
@@ -238,6 +239,11 @@ class HomeController extends Controller
|
|
|
})->count();
|
|
|
$keyNumbers['pendingNotesToSign'] = $pendingNotesToSign;
|
|
|
|
|
|
+ $pendingNotesToSignAllySigned = Note::where(function ($query) use ($performerProID) {
|
|
|
+ $query->where('hcp_pro_id', $performerProID)->where('is_signed_by_hcp', false)->where('is_signed_by_ally', true)->where('is_cancelled', false);;
|
|
|
+ })->count();
|
|
|
+ $keyNumbers['pendingNotesToSignAllySigned'] = $pendingNotesToSignAllySigned;
|
|
|
+
|
|
|
|
|
|
$signedNotesWithoutBills = Note::where(function ($query) use ($performerProID) {
|
|
|
$query->where('hcp_pro_id', $performerProID)->where('is_signed_by_hcp', true)->where('is_cancelled', false);;
|
|
@@ -255,9 +261,6 @@ class HomeController extends Controller
|
|
|
})
|
|
|
->count();
|
|
|
|
|
|
- // num measurements that need stamping
|
|
|
- $keyNumbers['measurementsToBeStamped'] = ($this->performer()->pro->pro_type === 'ADMIN' ? '-' : count($this->performer()->pro->getMeasurements(true)));
|
|
|
-
|
|
|
// unacknowledged cancelled bills for authed pro
|
|
|
$keyNumbers['unacknowledgedCancelledBills'] = Bill::where('hcp_pro_id', $performerProID)
|
|
|
->where('is_cancelled', true)
|
|
@@ -390,6 +393,32 @@ class HomeController extends Controller
|
|
|
->whereNull('current_client_pro_change_decision_id')
|
|
|
->get();
|
|
|
|
|
|
+ // unstamped client memos
|
|
|
+ // for mcp
|
|
|
+ $mcpClientMemos = DB::select(
|
|
|
+ DB::raw("
|
|
|
+SELECT c.uid as client_uid, c.name_first, c.name_last,
|
|
|
+ cm.uid, cm.content, cm.created_at
|
|
|
+FROM client c join client_memo cm on c.id = cm.client_id
|
|
|
+WHERE
|
|
|
+ c.mcp_pro_id = {$performerProID} AND
|
|
|
+ cm.mcp_stamp_id IS NULL
|
|
|
+ORDER BY cm.created_at DESC
|
|
|
+ ")
|
|
|
+ );
|
|
|
+ // for na
|
|
|
+ $naClientMemos = DB::select(
|
|
|
+ DB::raw("
|
|
|
+SELECT c.uid as client_uid, c.name_first, c.name_last,
|
|
|
+ cm.uid, cm.content, cm.created_at
|
|
|
+FROM client c join client_memo cm on c.id = cm.client_id
|
|
|
+WHERE
|
|
|
+ c.default_na_pro_id = {$performerProID} AND
|
|
|
+ cm.default_na_stamp_id IS NULL
|
|
|
+ORDER BY cm.created_at DESC
|
|
|
+ ")
|
|
|
+ );
|
|
|
+
|
|
|
$naBillableSignedNotes = DB::select(DB::raw("
|
|
|
SELECT count(note.id) as na_billable_notes
|
|
|
FROM note
|
|
@@ -416,11 +445,91 @@ WHERE
|
|
|
|
|
|
$keyNumbers['naBillableSignedNotes'] = $naBillableSignedNotes;
|
|
|
|
|
|
+ $keyNumbers['rmBillsToSign'] = Bill
|
|
|
+ ::where('is_cancelled', false)
|
|
|
+ ->where('cm_or_rm', 'RM')
|
|
|
+ ->where(function ($q) use ($performerProID) {
|
|
|
+ $q
|
|
|
+ ->where(function ($q2) use ($performerProID) {
|
|
|
+ $q2->where('hcp_pro_id', $performerProID)->where('is_signed_by_hcp', false);
|
|
|
+ })
|
|
|
+ ->orWhere(function ($q2) use ($performerProID) {
|
|
|
+ $q2->where('rme_pro_id', $performerProID)->where('is_signed_by_rme', false);
|
|
|
+ })
|
|
|
+ ->orWhere(function ($q2) use ($performerProID) {
|
|
|
+ $q2->where('rmm_pro_id', $performerProID)->where('is_signed_by_rmm', false);
|
|
|
+ })
|
|
|
+ ->orWhere(function ($q2) use ($performerProID) {
|
|
|
+ $q2->where('generic_pro_id', $performerProID)->where('is_signed_by_generic_pro', false);
|
|
|
+ });
|
|
|
+ })
|
|
|
+ ->count();
|
|
|
+
|
|
|
+ $count = DB::select(
|
|
|
+ DB::raw(
|
|
|
+ "
|
|
|
+SELECT count(client.id) as cnt FROM client join care_month on care_month.client_id = client.id
|
|
|
+WHERE ((client.mcp_pro_id = {$performer->pro->id}) OR (client.rmm_pro_id = {$performer->pro->id})
|
|
|
+ OR (client.rme_pro_id = {$performer->pro->id}) OR (client.default_na_pro_id = {$performer->pro->id}))
|
|
|
+ AND EXTRACT(MONTH from care_month.start_date) = EXTRACT(MONTH from now())
|
|
|
+ AND EXTRACT(YEAR from care_month.start_date) = EXTRACT(YEAR from now())
|
|
|
+ AND (care_month.number_of_days_with_remote_measurements < 16 OR care_month.number_of_days_with_remote_measurements IS NULL)
|
|
|
+"
|
|
|
+ )
|
|
|
+ );
|
|
|
+ $keyNumbers['rmPatientsWithLT16MD'] = $count[0]->cnt;
|
|
|
+
|
|
|
+ $count = DB::select(
|
|
|
+ DB::raw(
|
|
|
+ "
|
|
|
+SELECT count(client.id) as cnt FROM client join care_month on care_month.client_id = client.id
|
|
|
+WHERE ((client.mcp_pro_id = {$performer->pro->id}) OR (client.rmm_pro_id = {$performer->pro->id})
|
|
|
+ OR (client.rme_pro_id = {$performer->pro->id}) OR (client.default_na_pro_id = {$performer->pro->id}))
|
|
|
+ AND EXTRACT(MONTH from care_month.start_date) = EXTRACT(MONTH from now())
|
|
|
+ AND EXTRACT(YEAR from care_month.start_date) = EXTRACT(YEAR from now())
|
|
|
+ AND (care_month.number_of_days_with_remote_measurements >= 16 AND care_month.number_of_days_with_remote_measurements IS NOT NULL)
|
|
|
+"
|
|
|
+ )
|
|
|
+ );
|
|
|
+ $keyNumbers['rmPatientsWithGTE16MD'] = $count[0]->cnt;
|
|
|
+
|
|
|
+ $count = DB::select(
|
|
|
+ DB::raw(
|
|
|
+ "
|
|
|
+SELECT count(client.id) as cnt FROM client join care_month on care_month.client_id = client.id
|
|
|
+WHERE ((client.mcp_pro_id = {$performer->pro->id}) OR (client.rmm_pro_id = {$performer->pro->id})
|
|
|
+ OR (client.rme_pro_id = {$performer->pro->id}) OR (client.default_na_pro_id = {$performer->pro->id}))
|
|
|
+ AND EXTRACT(MONTH from care_month.start_date) = EXTRACT(MONTH from now())
|
|
|
+ AND EXTRACT(YEAR from care_month.start_date) = EXTRACT(YEAR from now())
|
|
|
+ AND (care_month.has_non_hcp_communicated_to_patient_about_rm = TRUE AND care_month.has_non_hcp_communicated_to_patient_about_rm IS NOT NULL)
|
|
|
+"
|
|
|
+ )
|
|
|
+ );
|
|
|
+ $keyNumbers['rmPatientsWithWhomCommDone'] = $count[0]->cnt;
|
|
|
+
|
|
|
+ $count = DB::select(
|
|
|
+ DB::raw(
|
|
|
+ "
|
|
|
+SELECT count(client.id) as cnt FROM client join care_month on care_month.client_id = client.id
|
|
|
+WHERE ((client.mcp_pro_id = {$performer->pro->id}) OR (client.rmm_pro_id = {$performer->pro->id})
|
|
|
+ OR (client.rme_pro_id = {$performer->pro->id}) OR (client.default_na_pro_id = {$performer->pro->id}))
|
|
|
+ AND EXTRACT(MONTH from care_month.start_date) = EXTRACT(MONTH from now())
|
|
|
+ AND EXTRACT(YEAR from care_month.start_date) = EXTRACT(YEAR from now())
|
|
|
+ AND (care_month.has_non_hcp_communicated_to_patient_about_rm = FALSE OR care_month.has_non_hcp_communicated_to_patient_about_rm IS NULL)
|
|
|
+"
|
|
|
+ )
|
|
|
+ );
|
|
|
+ $keyNumbers['rmPatientsWithWhomCommNotDone'] = $count[0]->cnt;
|
|
|
+
|
|
|
+ // num measurements that need stamping
|
|
|
+ $keyNumbers['measurementsToBeStamped'] = $this->performer()->pro->getUnstampedMeasurementsFromCurrentMonth(true, null, null);
|
|
|
+
|
|
|
return view('app/dashboard', compact('keyNumbers', 'reimbursement', 'milliseconds',
|
|
|
'businessNumbers',
|
|
|
'incomingReports', 'tickets', 'supplyOrders',
|
|
|
'numERx', 'numLabs', 'numImaging', 'numSupplyOrders',
|
|
|
- 'newMCPAssociations', 'newNAAssociations'));
|
|
|
+ 'newMCPAssociations', 'newNAAssociations',
|
|
|
+ 'mcpClientMemos', 'naClientMemos'));
|
|
|
}
|
|
|
|
|
|
public function dashboardMeasurementsTab(Request $request, $page = 1) {
|
|
@@ -460,7 +569,7 @@ WHERE measurement.label NOT IN ('SBP', 'DBP')
|
|
|
" .
|
|
|
(
|
|
|
$performer->pro->pro_type != 'ADMIN' ? $ifNotAdmin : ''
|
|
|
- )
|
|
|
+ )
|
|
|
)
|
|
|
);
|
|
|
|
|
@@ -495,7 +604,7 @@ WHERE measurement.label NOT IN ('SBP', 'DBP')
|
|
|
" .
|
|
|
(
|
|
|
$performer->pro->pro_type != 'ADMIN' ? $ifNotAdmin : ''
|
|
|
- )
|
|
|
+ )
|
|
|
) .
|
|
|
" ORDER BY measurement.ts DESC LIMIT 20 OFFSET " . (($page - 1) * 20)
|
|
|
|
|
@@ -661,6 +770,15 @@ WHERE measurement.label NOT IN ('SBP', 'DBP')
|
|
|
$pro = $this->pro;
|
|
|
$term = $request->input('term') ? trim($request->input('term')) : '';
|
|
|
if (empty($term)) return '';
|
|
|
+
|
|
|
+ // if multiple words in query, check for all (max 2)
|
|
|
+ $term2 = '';
|
|
|
+ if(strpos($term, ' ') !== FALSE) {
|
|
|
+ $terms = explode(' ', $term);
|
|
|
+ $term = trim($terms[0]);
|
|
|
+ $term2 = trim($terms[1]);
|
|
|
+ }
|
|
|
+
|
|
|
$clientQuery= Client::whereNull('shadow_pro_id')
|
|
|
->where(function ($q) use ($term) {
|
|
|
$q->where('name_first', 'ILIKE', '%' . $term . '%')
|
|
@@ -669,6 +787,15 @@ WHERE measurement.label NOT IN ('SBP', 'DBP')
|
|
|
->orWhere('phone_home', 'ILIKE', '%' . $term . '%');
|
|
|
});
|
|
|
|
|
|
+ if(!empty($term2)) {
|
|
|
+ $clientQuery = $clientQuery->where(function ($q) use ($term2) {
|
|
|
+ $q->where('name_first', 'ILIKE', '%' . $term2 . '%')
|
|
|
+ ->orWhere('name_last', 'ILIKE', '%' . $term2 . '%')
|
|
|
+ ->orWhere('cell_number', 'ILIKE', '%' . $term2 . '%')
|
|
|
+ ->orWhere('phone_home', 'ILIKE', '%' . $term2 . '%');
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
if(!($pro->pro_type === 'ADMIN' && $pro->can_see_any_client_via_search)) {
|
|
|
$clientQuery->where(function ($q) use ($pro) {
|
|
|
$q->whereIn('id', $pro->getMyClientIds(true))
|
|
@@ -694,7 +821,17 @@ WHERE measurement.label NOT IN ('SBP', 'DBP')
|
|
|
->orWhereRaw('LOWER(address_state::text) LIKE ?', ['%' . $term . '%'])
|
|
|
->orWhereRaw('LOWER(phone::text) LIKE ?', ['%' . $term . '%'])
|
|
|
->orWhereRaw('LOWER(address_zip::text) LIKE ?', ['%' . $term . '%']);
|
|
|
- })
|
|
|
+ });
|
|
|
+ if($request->input('city')) {
|
|
|
+ $pharmacies = $pharmacies->whereRaw('LOWER(address_city::text) LIKE ?', ['%' . strtolower($request->input('city')) . '%']);
|
|
|
+ }
|
|
|
+ if($request->input('state')) {
|
|
|
+ $pharmacies = $pharmacies->whereRaw('LOWER(address_state::text) LIKE ?', ['%' . strtolower($request->input('state')) . '%']);
|
|
|
+ }
|
|
|
+ if($request->input('zip')) {
|
|
|
+ $pharmacies = $pharmacies->whereRaw('LOWER(address_zip::text) LIKE ?', ['%' . strtolower($request->input('zip')) . '%']);
|
|
|
+ }
|
|
|
+ $pharmacies = $pharmacies
|
|
|
->orderBy('name', 'asc')
|
|
|
->orderBy('address_line1', 'asc')
|
|
|
->orderBy('address_city', 'asc')
|