load->database(); } function insertNurse($data) { $this->db->insert('caregiver', $data); return $this->db->insert_id(); } function getNurseByEmail($email) { $this->db->where('email', $email); $query = $this->db->get('caregiver')->row(); return $query; } function getNurse() { $query = $this->db->get('caregiver'); return $query->result(); } function getSendApprovalList() { $this->db->where('submited_for_verification', 'yes'); $query = $this->db->get('caregiver'); return $query->result(); } function getNurseBysearch($search) { $this->db->order_by('id', 'desc'); $this->db->like('id', $search); $this->db->or_like('fname', $search); $this->db->or_like('phone', $search); $this->db->or_like('email', $search); $query = $this->db->get('caregiver'); return $query->result(); } function getNurseByLimit($limit, $start, $orderColumn, $orderType) { if($orderColumn==0) $this->db->order_by('id', $orderType); else if($orderColumn==1) $this->db->order_by('fname', $orderType); else if($orderColumn==2) $this->db->order_by('email', $orderType); else if($orderColumn==3) $this->db->order_by('phone', $orderType); $this->db->limit($limit, $start); $query = $this->db->get('caregiver'); return $query->result(); } function getNurseByLimitBySearch($limit, $start, $search, $orderColumn, $orderType) { if($orderColumn==0) $this->db->order_by('id', $orderType); else if($orderColumn==1) $this->db->order_by('fname', $orderType); else if($orderColumn==2) $this->db->order_by('email', $orderType); else if($orderColumn==3) $this->db->order_by('phone', $orderType); $this->db->like('id', $search); $this->db->or_like('fname', $search); $this->db->or_like('phone', $search); $this->db->or_like('email', $search); $this->db->limit($limit, $start); $query = $this->db->get('caregiver'); return $query->result(); } function getNurseById($id) { $this->db->where('id', $id); $query = $this->db->get('caregiver')->row(); // pre($query);die(); $pref_time=$this->db->get_where('master_timeslot_type',array('id' => $query->availability_time_slot))->row(); $query->preferred_time=$pref_time->name; $query->preferred_start=date("H:i", strtotime($pref_time->startTime)); $query->preferred_end=date("H:i", strtotime($pref_time->endTime)); // pre($query->preferred_end);die(); return $query; //echo '
'; print_r($query); echo '
';die; } function getTimeSlotById($id){ $this->db->where('id', $id); $this->db->where('status!=', 0); return $query=$this->db->get('master_timeslot_type')->row(); } function getNurseByIonId($id) { $this->db->where('ion_user_id', $id); $query = $this->db->get('caregiver'); return $query->row(); } function email_check($email) { //echo $email;die; $this->db->where('email', $email); $query = $this->db->get('caregiver')->row(); if($query) return 1; else return 0; } function update_email_check($email,$ionid) { //echo $email;die; $this->db->where('email', $email)->where('id!=',$ionid); $query = $this->db->get('users')->row(); //echo $this->db->last_query(); // print_r($query); //die; if($query) return 1; else return 0; } function updateIonUser($email,$password,$id,$ionid){ $update_ion_user = array( 'email' => $email, 'password' => $password ); $this->db->where('id', $ionid); $this->db->update('users', $update_ion_user); $update_caregiver = array( 'email' => $email ); $this->db->where('id', $id); $this->db->update('caregiver', $update_caregiver); } function updateNurse($id, $data) { $this->db->where('id', $id); $this->db->update('caregiver', $data); return $this->db->affected_rows(); // echo $this->db->last_query(); // die; } function updateService($id, $data) { $this->db->where('caregiver_id', $id); $this->db->delete('caregiver_service_mapping'); foreach($data as $ser){ $serarr=array( 'caregiver_id'=>$id, 'service_id'=>$ser, ); $this->db->insert('caregiver_service_mapping', $serarr); } return true; } function CheckAvailability($data){ $start=$data['scheduleDate'].' '.$data['startTime']; $end=$data['scheduleDate'].' '.$data['endTime']; $caregiver_id=$data['caregiver_id']; $sql="SELECT * FROM caregiver_availability"; $sql.=" where status='1' and caregiver_id='".$caregiver_id."'"; $sql.=" and ( ('".$start."' between start and end) and ('".$end."' between start and end) )"; $result=$this->db->query($sql)->result(); $output=''; if(!empty($result)){ $output='Already in Availability List.'; } //echo $this->db->last_query(); //return json_encode($result); return $output; //print_r($data); } function get_state_nameByid($id){ $query=$this->db->get_where('master_statelist', array('id' => $id))->row(); return $query->name; } function get_state_list(){ $query=$this->db->get_where('master_statelist', array('status' => '1')); return $query->result(); } function get_language_list(){ $query=$this->db->get_where('master_language', array('status' => '1')); return $query->result(); } function get_country_list(){ $query=$this->db->get_where('master_country', array('status' => '1')); return $query->result(); } function get_time_slot_list(){ $query=$this->db->get_where('master_timeslot_type', array('status' => '1')); return $query->result(); } function get_time_slot_Byid($id){ $query=$this->db->get_where('master_timeslot_type', array('id' => $id))->row(); return $query->name; } function get_ref_src_list(){ $query=$this->db->get_where('master_cg_referal_source', array('status' => '1')); return $query->result(); } function get_ref_src_Byid($id){ $query=$this->db->get_where('master_cg_referal_source', array('id' => $id))->row(); return $query->name; } function get_service_list(){ $query=$this->db->get_where('master_service_activity', array('status' => '1')); return $query->result(); } function get_CaregiverService_listById($id){ $query=$this->db->get_where('caregiver_service_mapping', array('caregiver_id' => $id)); return $query->result(); } function caregiver_skill_list(){ $query=$this->db->get_where('master_cg_skills', array('status' => '1')); return $query->result(); } function get_ethnicity_list(){ $query=$this->db->get_where('master_ethnicity', array('status' => '1')); return $query->result(); } function get_eyeColors(){ $query=$this->db->get_where('master_eye_color', array('status' => '1')); return $query->result(); } function get_hairColors(){ $query=$this->db->get_where('master_hair_color', array('status' => '1')); return $query->result(); } function caregiver_skill_NameByid($id){ $query=$this->db->get_where('master_cg_skills', array('id' => $id))->row(); return $query->name; } function getProgress(){ $id = $this->session->userdata('user_id'); $query=$this->db->get_where('caregiver', array('ion_user_id' => $id))->row(); return $query->progress; // print_r($query->progress); // die; } function addVerificationHistory($data){ $this->db->insert('caregiver_verification_history', $data); return $this->db->insert_id(); } function addVerificationHistoryDetails($data){ $this->db->insert('caregiver_verification_history_details', $data); return $this->db->insert_id(); } function delete($id) { $this->db->where('id', $id); $this->db->delete('caregiver'); } function addNurseDocuments($data){ $this->db->insert('users_documents', $data); return $this->db->insert_id(); } function updateNurseDocuments($data,$id){ $this->db->where('id', $id); $this->db->update('users_documents', $data); } function checkDocumentsExsist($ionid,$doc_type){ $this->db->where('ion_user_id', $ionid)->where('user_type', 'Caregiver')->where('documents_type', $doc_type)->where('status', 1); $query = $this->db->get('users_documents')->row(); if($query) return 1; else return 0; } function getNurseDocuments($ionid){ $this->db->where('ion_user_id', $ionid)->where('user_type', 'Caregiver')->where('status', 1); $query = $this->db->get('users_documents'); // print_r($query);die; return $query->result(); } function deleteNursePreDocuments($doc_id){ $this->db->where('id', $doc_id); $this->db->update('users_documents', array('status'=>0)); } function getCaregiverPatient($id){ $this->db->distinct('a.patient_id'); $this->db->select('a.*,b.*'); $this->db->from('caregiver_schedule a'); $this->db->join('patient_details b', 'b.id = a.patient_id', 'left'); $this->db->group_by('a.patient_id'); $this->db->where('a.caregiver_id',$id); $query = $this->db->get()->result(); return $query; } function getPreviousCaregiverPatientSchedule($id){ $now=date("Y-m-d 00:00:00"); $this->db->select('a.id as scheduleId,a.patient_id as patient_row_id,a.*,b.*'); $this->db->from('caregiver_schedule a'); $this->db->join('patient_details b', 'b.id = a.patient_id', 'left'); $this->db->where('a.start<',$now); $this->db->where("`a`.`caregiver_id`=$id AND `a`.`acceptance_status`!='Declined' ORDER BY FIELD(a.acceptance_status, 'Unconfirmed','Accepted','Declined') ASC"); $query = $this->db->get()->result(); return $query; } function getUpcommingCaregiverPatientSchedule($id){ $now=date("Y-m-d 00:00:00"); $this->db->select('a.id as scheduleId,a.patient_id as patient_row_id,a.*,b.*'); $this->db->from('caregiver_schedule a'); $this->db->join('patient_details b', 'b.id = a.patient_id', 'left'); $this->db->where('a.start>',$now); $this->db->where("`a`.`caregiver_id`=$id AND `a`.`acceptance_status`!='Declined' ORDER BY FIELD(a.acceptance_status, 'Unconfirmed','Accepted','Declined') ASC"); $query = $this->db->get()->result(); return $query; } function masterScheduleList(){ $this->db->where('status','1'); $query = $this->db->get('master_schedule')->result(); return $query; } function masterScheduleWeekdayList(){ $this->db->where('status','1'); $this->db->group_by('week_day'); $query = $this->db->get('master_schedule')->result(); return $query; } function getTimeByDay($day){ $this->db->where('week_day', $day)->where('status','1'); $query = $this->db->get('master_schedule')->result(); return $query; } function saveCaregiverSchedule($data){ $this->db->insert('caregiver_schedule', $data); return $this->db->insert_id(); } function getCaregiverSchedule($id){ $this->db->where('caregiver_id', $id)->where('status','1'); $query = $this->db->get('caregiver_schedule')->result(); return $query; } function getCaregiverEventSchedule($id){ $this->db->where('status','1'); $this->db->where('caregiver_id',$id); $query = $this->db->get('caregiver_schedule')->result(); return $query; } function updateCaregiverEventSchedule($data,$id){ $this->db->where('id', $id); $query=$this->db->update('caregiver_schedule', $data); return $this->db->affected_rows(); } function deleteCaregiverEventSchedule($id){ $this->db->where('id', $id); $query=$this->db->update('caregiver_schedule', array('status'=>'0')); return $this->db->affected_rows(); } function deleteSchedule($scheduleId,$caregiverId,$update_by){ $update_on=date ('Y-m-d H:i:s', now()); $data=array( 'update_by'=>$update_by, 'update_on'=>$update_on, 'status'=>'0', ); $this->db->where('caregiver_id', $caregiverId)->where('schedule_master_id', $scheduleId)->where('status', '1'); $query=$this->db->update('caregiver_schedule', $data); return $this->db->affected_rows(); } function updateAcceptance($post) { $scheduleId = $post["scheduleId"]; $decision = $post["decision"]; $rejection_reason = $post["rejectionReason"]; $this->db->where('id', $scheduleId); $query=$this->db->update('caregiver_schedule', array( 'acceptance_status'=>$decision, 'rejection_reason' =>$rejection_reason ) ); return $this->db->affected_rows(); } public function getServices(){ $skillId=$_GET['skillId']; $this->db->select('b.*'); $this->db->where('a.skill_id',$skillId); $this->db->from('skill_to_service_mapping a'); $this->db->join('master_service_activity b', 'b.id = a.service_id', 'left'); $query = $this->db->get()->result(); //echo $this->db->last_query(); $service_count=count($query); // echo '
'; print_r($query); echo '
'; // die; $output=''; if($service_count>0){ $output.='
'; } return $output; } function getScheduleByLimitBySearch($limit, $start, $search, $orderColumn, $orderType, $caregiverId) { if($orderColumn==0) $this->db->order_by('patient_id', $orderType); else if($orderColumn==1) $this->db->order_by('start', $orderType); else if($orderColumn==2) $this->db->order_by('start', $orderType); else if($orderColumn==3) $this->db->order_by('end', $orderType); $this->db->like('patient_id', $search); $this->db->or_like('start', $search); $this->db->or_like('end', $search); $this->db->where('caregiver_id',$caregiverId); $this->db->where('status','1'); $this->db->limit($limit, $start); $query = $this->db->get('caregiver_schedule'); return $query->result(); } function getScheduleByLimit($limit, $start, $orderColumn, $orderType, $caregiverId) { if($orderColumn==0) $this->db->order_by('patient_id', $orderType); else if($orderColumn==1) $this->db->order_by('start', $orderType); else if($orderColumn==2) $this->db->order_by('start', $orderType); else if($orderColumn==3) $this->db->order_by('end', $orderType); $this->db->where('caregiver_id',$caregiverId); $this->db->where('status','1'); $this->db->limit($limit, $start); $query = $this->db->get('caregiver_schedule')->result(); return $query; } function saveAvailability($data){ $created_by=$this->session->userdata('user_id'); $created_on=date ('Y-m-d H:i:s', now()); $data['color']='#2D95BF'; $data['start']=$data['Sdate'].' '.$data['startTime']; $data['end']=$data['Sdate'].' '.$data['endTime']; $data['caregiver_id']=$data['caregiver_id']; $data['created_by']=$created_by; $data['created_on']=$created_on; $data['status']=1; unset($data['startTime']); unset($data['endTime']); unset($data['Sdate']); //print_r($data);die; $this->db->insert('caregiver_availability', $data); $insertId=$this->db->insert_id(); if($insertId>0){ return true; }else{ return false; } } function caregiverScheduleById($caregiverId){ //echo 'test';die; $now=date("Y-m-d 00:00:00"); $this->db->select('a.*,b.first_name,b.last_name'); $this->db->from('caregiver_schedule a'); $this->db->join('patient_details b', 'b.id = a.patient_id', 'left'); $this->db->where('a.caregiver_id',$caregiverId); $this->db->where('a.start>',$now); $this->db->where('a.status','1'); $this->db->order_by('a.start', 'asc'); $query = $this->db->get()->result(); //echo $this->db->last_query();die; return $query; } function availableScheduleById($caregiverId){ $now=date("Y-m-d H:i:s"); $this->db->where('caregiver_id',$caregiverId); $this->db->where('start>',$now); $this->db->where('status','1'); $this->db->order_by('start', 'asc'); $query = $this->db->get('caregiver_availability')->result(); //echo $this->db->last_query();die; return $query; } function previousScheduleById($caregiverId){ $now=date("Y-m-d 00:00:00"); $this->db->select('a.*,b.first_name,b.last_name'); $this->db->from('caregiver_schedule a'); $this->db->join('patient_details b', 'b.id = a.patient_id', 'left'); $this->db->where('a.caregiver_id',$caregiverId); $this->db->where('a.start<',$now); $this->db->where('a.status','1'); $this->db->order_by('a.start', 'asc'); $query = $this->db->get()->result(); return $query; } function deleteAvailability($data){ $id=$data['id']; $this->db->where('id', $id); $this->db->update('caregiver_availability', array("status"=>0)); $result=$this->db->affected_rows(); if($result>0){ $output="Deleted Successfully."; }else{ $output="Delete Error."; } return $output; //print_r($result); } function schedulePreferenceById($data){ // $caregiverId = $data['caregiver_id']; $caregiverId=$data; $this->db->select('a.*,b.name'); $this->db->from('schedule_preferences a'); $this->db->join('master_timeslot_type b', 'b.id = a.session', 'left'); $this->db->where('a.nurse_id',$caregiverId); $query = $this->db->get()->result_array(); return $query; } function getCaregiverPreferenceDate($data){ $caregiverId = $data['caregiver_id']; $day = $data['day']; $this->db->select('a.*,b.name'); $this->db->from('schedule_preferences a'); $this->db->join('master_timeslot_type b', 'b.id = a.session', 'left'); $this->db->where('a.nurse_id',$caregiverId); $this->db->where('a.day',$day); $query = $this->db->get()->row(); return $query; } function getFcmToken($caregiver_id){ $this->db->select("b.fcm_token,a.id"); $this->db->from('caregiver a'); $this->db->join('users b', 'b.id = a.ion_user_id', 'left'); $this->db->where('a.id',$caregiver_id); $query = $this->db->get()->row(); return $query; } function getFcmTokenByAvailabilityId($availabilityId){ $this->db->select("b.fcm_token,a.id as availability_id, c.ion_user_id"); $this->db->from('caregiver_availability a'); $this->db->join('caregiver c', 'c.id = a.caregiver_id', 'left'); $this->db->join('users b', 'b.id = c.ion_user_id', 'left'); $this->db->where('a.id',$availabilityId); $query = $this->db->get()->row(); return $query; } }