public function getAllMedicalLocations()
 {
     return medical_location_lookup::get()->all();
 }
Example #2
0
 public function saveNewLocationToDB($request)
 {
     $location = new medical_location_lookup();
     $location->description = $request['new_location'];
     $location->save();
 }
Example #3
0
 public function getLegalSessionsHistoryForSingleBenefiter($benefiterId)
 {
     $history = array();
     $legal_folder = $this->findLegalFolderFromBenefiterId($benefiterId);
     if ($legal_folder != null) {
         $legalSessions = $this->findLegalSessionsFromLegalFolderIdOrderedByDateDesc($legal_folder->id);
         if ($legalSessions != null) {
             // fetch all users from DB
             $users = User::get()->toArray();
             // fetch all locations from DB
             $locations = medical_location_lookup::get()->toArray();
             // fetch all lawyer actions from DB
             $lawyerActions = \DB::table('lawyer_action_lookup')->get();
             if ($users != null and $locations != null and $lawyerActions != null) {
                 $this->pushLegalSessionsToHistoryArray($legalSessions, $users, $locations, $lawyerActions, $history);
             }
         }
     }
     return $history;
 }
Example #4
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;
 }