|
@@ -34,7 +34,6 @@ use Illuminate\Support\Facades\Http;
|
|
use PDF;
|
|
use PDF;
|
|
use Illuminate\Support\Facades\Schema;
|
|
use Illuminate\Support\Facades\Schema;
|
|
use App\Models\AdminPatient;
|
|
use App\Models\AdminPatient;
|
|
-use App\Models\Survey;
|
|
|
|
use App\Models\SupplyOrderView;
|
|
use App\Models\SupplyOrderView;
|
|
use Illuminate\Pagination\LengthAwarePaginator;
|
|
use Illuminate\Pagination\LengthAwarePaginator;
|
|
|
|
|
|
@@ -779,9 +778,9 @@ class AdminController extends Controller
|
|
$s = "'" . '%'.strtolower(trim($string)).'%'. "'";
|
|
$s = "'" . '%'.strtolower(trim($string)).'%'. "'";
|
|
array_push($searchArray, $s);
|
|
array_push($searchArray, $s);
|
|
}
|
|
}
|
|
- $searchArrayStrings = implode(',', $searchArray);
|
|
|
|
|
|
+ $searchArrayStrings = implode(',', $searchArray);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
|
|
|
|
$qry = "
|
|
$qry = "
|
|
SELECT
|
|
SELECT
|
|
@@ -801,7 +800,7 @@ class AdminController extends Controller
|
|
c.most_recent_completed_mcp_note_date as last_visit_date,
|
|
c.most_recent_completed_mcp_note_date as last_visit_date,
|
|
(cover.plan_type) as cover
|
|
(cover.plan_type) as cover
|
|
|
|
|
|
- FROM
|
|
|
|
|
|
+ FROM
|
|
point p
|
|
point p
|
|
LEFT JOIN client c on c.id = p.client_id
|
|
LEFT JOIN client c on c.id = p.client_id
|
|
LEFT JOIN pro mcp on mcp.id = c.mcp_pro_id
|
|
LEFT JOIN pro mcp on mcp.id = c.mcp_pro_id
|
|
@@ -811,7 +810,7 @@ class AdminController extends Controller
|
|
if($searchArrayStrings){
|
|
if($searchArrayStrings){
|
|
$qry = $qry . "WHERE lower(p.data) ILIKE any (array[".$searchArrayStrings."])";
|
|
$qry = $qry . "WHERE lower(p.data) ILIKE any (array[".$searchArrayStrings."])";
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
|
|
|
|
$records = DB::select($qry);
|
|
$records = DB::select($qry);
|
|
|
|
|
|
@@ -821,8 +820,8 @@ class AdminController extends Controller
|
|
|
|
|
|
$records = new LengthAwarePaginator(
|
|
$records = new LengthAwarePaginator(
|
|
$collect->forPage($page, $size),
|
|
$collect->forPage($page, $size),
|
|
- $collect->count(),
|
|
|
|
- $size,
|
|
|
|
|
|
+ $collect->count(),
|
|
|
|
+ $size,
|
|
$page
|
|
$page
|
|
);
|
|
);
|
|
|
|
|
|
@@ -830,74 +829,4 @@ class AdminController extends Controller
|
|
|
|
|
|
return view('app.admin.patients-notes-points-filter', compact('records', 'filters'));
|
|
return view('app.admin.patients-notes-points-filter', compact('records', 'filters'));
|
|
}
|
|
}
|
|
-
|
|
|
|
- public function surveys(Request $request)
|
|
|
|
- {
|
|
|
|
- $filters = $request->all();
|
|
|
|
- $entityTypes = Survey::ALLOWED_ENTITIES;
|
|
|
|
- $surveyFormsPath = resource_path(Survey::FORM_PATH);
|
|
|
|
- $filesInFolder = File::allFiles($surveyFormsPath);
|
|
|
|
- $forms = [];
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- foreach ($filesInFolder as $path) {
|
|
|
|
- $file = pathinfo($path);
|
|
|
|
- $fileName = $file['filename'];
|
|
|
|
- $internalName = explode('.', $fileName)[0];
|
|
|
|
- $forms[] = $internalName;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- $records = Survey::query();
|
|
|
|
- $searchString = $request->get('string');
|
|
|
|
- if($searchString){
|
|
|
|
- $searchString = strtolower($searchString);
|
|
|
|
- $records = $records->where(function ($q) use ($searchString) {
|
|
|
|
- return $q->orWhereRaw('LOWER(title::text) ILIKE ?', ['%' . $searchString . '%'])
|
|
|
|
- ->orWhereRaw('LOWER(internal_name::text) ILIKE ?', ['%' . $searchString . '%'])
|
|
|
|
- ->orWhereRaw('survey_data ILIKE ?', ['%' . $searchString . '%']);
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- $entityType = $request->get('entity_type');
|
|
|
|
- if($entityType){
|
|
|
|
- $records = $records->where('entity_type', $entityType);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- $records = $records->orderBy('created_at', 'DESC')->paginate(5);
|
|
|
|
- return view('app.admin.surveys.list', compact('forms', 'records', 'entityTypes', 'filters'));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public function getEntityRecords(Request $request)
|
|
|
|
- {
|
|
|
|
- $term = $request->get('term');
|
|
|
|
- $type = $request->get('type');
|
|
|
|
- if(!in_array($type, Survey::ALLOWED_ENTITIES)){
|
|
|
|
- return $this->fail('Invalid entity type');
|
|
|
|
- }
|
|
|
|
- $records = [];
|
|
|
|
- if($type === 'Client'){
|
|
|
|
- $clients = Client::query();
|
|
|
|
- $clients = $clients->where('is_active', true);
|
|
|
|
-
|
|
|
|
- $clients = $clients->where(function ($q) use ($term) {
|
|
|
|
- return $q->orWhereRaw('LOWER(name_first::text) ILIKE ?', ['%' . $term . '%'])
|
|
|
|
- ->orWhereRaw('LOWER(name_last::text) ILIKE ?', ['%' . $term . '%'])
|
|
|
|
- ->orWhereRaw('LOWER(email_address::text) ILIKE ?', ['%' . $term . '%'])
|
|
|
|
- ->orWhereRaw('cell_number ILIKE ?', ['%' . $term . '%']);
|
|
|
|
- });
|
|
|
|
- $clients = $clients->orderBy('name_first', 'ASC')->limit(10)->get();
|
|
|
|
- $clientsData = $clients->map(function($client) {
|
|
|
|
- return [
|
|
|
|
- "uid" => $client->uid,
|
|
|
|
- "id" => $client->id,
|
|
|
|
- "text" => $client->displayName(),
|
|
|
|
- ];
|
|
|
|
- });
|
|
|
|
- return json_encode([
|
|
|
|
- "results" => $clientsData
|
|
|
|
- ]);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return $this->pass($records);
|
|
|
|
- }
|
|
|
|
}
|
|
}
|