Beispiel #1
0
 public function getFoldersUsageHistory($benefiter_id)
 {
     $usageHistory = [];
     // find the benefiter from id
     $benefiter = Benefiter::find($benefiter_id);
     // fetch from basic folder history
     $basicFolderHistory = BasicFolderHistory::where('benefiter_id', '=', $benefiter_id)->get();
     // fetch from medical visit
     $medicalVisitsHistory = medical_visits::where('benefiter_id', '=', $benefiter_id)->get();
     // fetch from legal folder
     $legalFolderService = new LegalFolderService();
     $legalFolder = $legalFolderService->findLegalFolderFromBenefiterId($benefiter_id);
     $legalFolderHistory = null;
     if ($legalFolder != null) {
         $legalFolderHistory = LegalSession::where('legal_folder_id', '=', $legalFolder->id)->get();
     }
     // fetch from psychosocial folder
     $socialFolderService = new SocialFolderService();
     $psychosocialHistory = PsychosocialSession::where('social_folder_id', '=', $socialFolderService->getSocialFolderFromBenefiterId($benefiter_id)->id)->get();
     // fetch all users from DB
     $users = User::get()->toArray();
     // fetch all locations from DB
     $locations = medical_location_lookup::get()->toArray();
     // fetch all user roles and subroles
     $roles = Users_roles::get()->toArray();
     $subroles = Users_subroles::get()->toArray();
     // check if there are some users and locations in the DB, else return an empty array
     if (!empty($users) and !empty($locations) and $benefiter != null) {
         // push all basic folder history to the usageHistory array as AllFoldersUsageHistory objects
         if (!empty($basicFolderHistory)) {
             $this->pushAllBasicInfoFolderHistoryToUsageHistoryArray($basicFolderHistory, $benefiter, $roles, $users, $locations, $usageHistory);
         }
         // push all medical visits history to the usageHistory array as AllFoldersUsageHistory objects
         if (!empty($medicalVisitsHistory)) {
             $this->pushAllMedicalVisitsHistoryToUsageHistoryArray($medicalVisitsHistory, $benefiter, $roles, $subroles, $users, $locations, $usageHistory);
         }
         // push all legal folder history to the usageHistory array as AllFoldersUsageHistory objects
         if (!empty($legalFolderHistory)) {
             $this->pushAllLegalFolderHistoryToUsageHistoryArray($legalFolderHistory, $benefiter, $roles, $users, $locations, $usageHistory);
         }
         // push all psychosocial sessions history to the usageHistory array as AllFoldersUsageHistory objects
         if (!empty($psychosocialHistory)) {
             $this->pushAllPsychosocialFolderHistoryToUsageHistoryArray($psychosocialHistory, $benefiter, $roles, $users, $locations, $usageHistory);
         }
         // order usageHistory array by date
         usort($usageHistory, array($this, "orderUsageHistoryArrayByDate"));
     }
     return $usageHistory;
 }
Beispiel #2
0
 public function getReport_benefiters_vs_phycological_support()
 {
     $results = array();
     // get all phycological support types from lookup
     $phycological_support_types_lookup = Psychosocial_support_lookup::get();
     // get all phycological visits
     $phycological_visits = PsychosocialSession::select('social_folder_id', 'psychosocial_theme_id')->get();
     // foreach phycological support type count the benefiters avoiding duplicities
     foreach ($phycological_support_types_lookup as $phycological_type) {
         // benefiters with same psychosocial support type
         $benefiters_same_psychosocial_support_type = array();
         // here for each visit/session we create an array with all social folder ids registered for the current phycological support type
         foreach ($phycological_visits as $visit) {
             if ($phycological_type['id'] == $visit['psychosocial_theme_id']) {
                 array_push($benefiters_same_psychosocial_support_type, $visit['social_folder_id']);
             }
         }
         // then we count the duplicate result array
         $benefiters_count = count(array_count_values($benefiters_same_psychosocial_support_type));
         // we create the necessary pair of data, needed for the chart
         $phycological_support_result = ['$phycological_support_type' => $phycological_type['description'], 'type_count' => $benefiters_count];
         array_push($results, $phycological_support_result);
     }
     // return array with number of benefiters per phycological support type
     return $results;
 }
Beispiel #3
0
 private function savePsychosocialSessionToDB($request, $socialFolderId)
 {
     if (isset($request['session_date']) && isset($request['session_comments'])) {
         $psychosocialSession = new PsychosocialSession($this->getPsychosocialSessionArrayForDBInsert($request, $socialFolderId));
         $psychosocialSession->save();
     }
 }