load->database(); } function insertPatient($data) { $this->db->insert('patient_details', $data); return $this->db->insert_id(); } function updatePatient($data,$pid){ $this->db->where('id', $pid); $this->db->update('patient_details', $data); return 'phs2'; } function getPatientByid($id){ $this->db->where('id', $id); $query = $this->db->get('patient_details')->row(); $caregiver_type=$this->db->get_where('master_cg_skills',array('id'=>$query->level_of_service))->row(); $query->service_name=$caregiver_type->name; // echo '
'; print_r($query); echo '
';die; return $query; } function approvePatient($pid){ $data = array('approve_status' => 1); $this->db->where('id', $pid); $this->db->update('patient_details', $data); return 'approved'; } function activatePatient($pid){ $data = array('active_status' => 1); $this->db->where('id', $pid); $this->db->update('patient_details', $data); return 'approved'; } function addPatientDocuments($data){ $this->db->insert('patient_documents', $data); return $this->db->insert_id(); } function mdOrdersInsert($data) { $this->db->insert('md_orders', $data); return $this->db->insert_id(); } function mdOrdersUpdate($data,$pid) { $this->db->where('patient_id', $pid); $this->db->update('md_orders', $data); return $pid; } function insertPatientInsurance($data,$pid) { $this->db->where('patient_id',$pid); $query = $this->db->get('patient_insurance_info'); if ($query->num_rows() > 0){ $this->db->where('patient_id', $pid); $this->db->update('patient_insurance_info', $data); return $this->db->insert_id(); } else{ $this->db->insert('patient_insurance_info', $data); return $this->db->insert_id(); } } function insuranceInfoCheck($pid){ $this->db->where('patient_id',$pid); $query = $this->db->get('patient_insurance_info'); return $query->num_rows(); } /*get necessesary dropdown details*/ function getPatientDoc($id,$type){ $this->db->where('patient_id', $id); $this->db->where('documents_type', $type); $query = $this->db->get('patient_documents'); return $query->result(); } function getDocDetails($id){ $this->db->where('id', $id); $query = $this->db->get('patient_documents'); return $query->result(); } function getLanguages() { $this->db->where('status', 1); $query = $this->db->get('master_language'); return $query->result(); } function getReferalSource() { $this->db->where('status', 1); $query = $this->db->get('master_patient_ref'); return $query->result(); } function getEleDep(){ $this->db->where('status', 1); $query = $this->db->get('master_ele_dependency'); return $query->result(); } function getallergy(){ $this->db->where('status', 1); $query = $this->db->get('master_allergy'); return $query->result(); } function getICD(){ $this->db->where('status', 1); $query = $this->db->get('master_icd'); return $query->result(); } function getLevelService() { $this->db->where('status', 1); $query = $this->db->get('master_cg_skills'); return $query->result(); } function getServiceActivity() { $this->db->where('status', 1); $query = $this->db->get('master_service_activity'); return $query->result(); } function getTherapyType() { $this->db->where('status', 1); $query = $this->db->get('master_therapytype'); return $query->result(); } function getAccessType() { $query = $this->db->get('master_access_type'); return $query->result(); } function getTubeType() { $this->db->where('status', 1); $query = $this->db->get('master_tubetype'); return $query->result(); } function getPayertype() { $this->db->where('status', 1); $query = $this->db->get('master_payertype'); return $query->result(); } function getvendorLists() { $query = $this->db->get('master_vendor'); return $query->result(); } /*get necessesary dropdown details end*/ function getValueFrom($tableName,$fieldName,$fieldValue){ $this->db->where($fieldName, $fieldValue); $query = $this->db->get($tableName); return $query->result(); } /* for data table */ function status_change($post){ $id = $post['id']; $stat = $post['val']; $this->db->set('status', $stat); $this->db->where('id', $id); $this->db->update('patient_details'); if($stat == '1') { return 'Status set active'; } else{ return 'Status set deactive'; } } function getWherevalueInsInfo($id){ $this->db->where('patient_id', $id); $query = $this->db->get('patient_insurance_info'); return $query->result(); } function getWherevalue($id){ $this->db->where('id', $id); $query = $this->db->get('patient_details'); return $query->result(); } function getWhereMdOrders($id){ $this->db->where('patient_id', $id); $query = $this->db->get('md_orders'); return $query->result(); } function name_list(){ $this->db->where(array('active_status' => 1)); $query = $this->db->get('patient_details'); $this->db->order_by('id', 'DESC'); return $query->result(); } function patientLists(){ $this->db->where(array('active_status' => 1)); $query = $this->db->get('patient_details'); $this->db->order_by('id', 'DESC'); return $query->result(); } function getNameBysearch($search) { $this->db->order_by('id', 'desc'); $this->db->like('id', $search); $this->db->or_like('first_name', $search); $this->db->or_like('last_name', $search); $this->db->or_like('gender', $search); $this->db->where(array('active_status' => 1)); $query = $this->db->get('patient_details'); return $query->result(); } function getNameByLimit($limit, $start) { $this->db->order_by('id', 'desc'); $this->db->limit($limit, $start); $this->db->where(array('active_status' => 1)); $query = $this->db->get('patient_details'); return $query->result(); } function getNameByLimitBySearch($limit, $start, $search) { $this->db->like('id', $search); $this->db->order_by('id', 'desc'); $this->db->or_like('first_name', $search); $this->db->or_like('last_name', $search); $this->db->or_like('gender', $search); $this->db->where(array('active_status' => 1)); $this->db->limit($limit, $start); $query = $this->db->get('patient_details'); return $query->result(); } function name_listPending(){ $query = $this->db->get('patient_details'); $this->db->order_by('id', 'DESC'); return $query->result(); } function getNameBysearchPending($search) { $this->db->order_by('id', 'desc'); $this->db->like('id', $search); $this->db->or_like('first_name', $search); $this->db->or_like('last_name', $search); $this->db->or_like('gender', $search); $query = $this->db->get('patient_details'); return $query->result(); } function getNameByLimitPending($limit, $start) { $this->db->order_by('id', 'desc'); $this->db->limit($limit, $start); $query = $this->db->get('patient_details'); return $query->result(); } function getNameByLimitBySearchPending($limit, $start, $search) { $this->db->like('id', $search); $this->db->order_by('id', 'desc'); $this->db->or_like('first_name', $search); $this->db->or_like('last_name', $search); $this->db->or_like('gender', $search); $this->db->limit($limit, $start); $query = $this->db->get('patient_details'); return $query->result(); } function delete_patient($id) { $this->db->where('id', $id); $this->db->delete('patient_details'); } function getWhereAssessment($id){ $this->db->select('*'); $this->db->from('assessment a1'); $this->db->join('assessment_step2 a2', 'a1.id = a2.main_id', 'left'); $this->db->join('assessment_step3 a3', 'a1.id = a3.main_id', 'left'); $this->db->join('assessment_step4 a4', 'a1.id = a4.main_id', 'left'); $this->db->join('assessment_step5 a5', 'a1.id = a5.main_id', 'left'); $this->db->join('assessment_step6 a6', 'a1.id = a6.main_id', 'left'); $this->db->where('a1.patient_id',$id); $query = $this->db->get(); return $query->result(); } function getInitialAssessmentStatus($id) { $this->db->where('patient_id', $id); $query = $this->db->get('assessment'); return $query->num_rows(); } function getProgress($id){ $query=$this->db->get_where('patient_details', array('id' => $id))->row(); return $query->progress; } // scheduled visits function getScheduledVisitsList($filter){ $currentDate = time(); $start_date=''; $end_date=''; if ($filter=='week') { $start_date = date('Y-m-d', strtotime('this week', $currentDate)); $end_date = date('Y-m-d', strtotime('this week +6 days', $currentDate)); } elseif ($filter=='month') { $start_date = date('Y-m-01'); $end_date = date('Y-m-t'); } elseif ($filter=='year') { $currentYear = date('Y'); $start_date = date('Y-01-01', strtotime($currentYear)); $end_date = date('Y-12-31', strtotime($currentYear)); } $this->db->select('*'); $this->db->from('caregiver_patient_clock_in_out'); $this->db->where(array('status' => 1)); if ($start_date!='' && $end_date!='') { $this->db->where('DATE(created_on) >=', $start_date); $this->db->where('DATE(created_on) <=', $end_date); } $query = $this->db->get(); return $query->num_rows(); } function getScheduledVisitsListPage($limit, $start, $orderColumn, $orderType, $filter) { $currentDate = time(); $start_date=''; $end_date=''; if ($filter=='week') { $start_date = date('Y-m-d', strtotime('this week', $currentDate)); $end_date = date('Y-m-d', strtotime('this week +6 days', $currentDate)); } elseif ($filter=='month') { $start_date = date('Y-m-01'); $end_date = date('Y-m-t'); } elseif ($filter=='year') { $currentYear = date('Y'); $start_date = date('Y-01-01', strtotime($currentYear)); $end_date = date('Y-12-31', strtotime($currentYear)); } $this->db->select('CONCAT(ca.fname, " ", ca.lname) as caregiver_name, CONCAT(pd.first_name, " ", pd.last_name) as patient_name, pcio.clock_in_time, pcio.clock_out_time, cs.name as service_type, pd.address'); $this->db->from('caregiver_patient_clock_in_out pcio'); $this->db->join('patient_details pd', 'pcio.patient_id = pd.id', 'left'); $this->db->join('caregiver ca', 'ca.id = pcio.caregiver_id', 'left'); $this->db->join('master_cg_skills cs', 'cs.id = pd.level_of_service', 'left'); if($orderColumn==0){ $this->db->order_by('pcio.id', $orderType); } else if($orderColumn==1){ $this->db->order_by('pcio.clock_in_time', $orderType); } else if($orderColumn==2){ $this->db->order_by('CONCAT(pd.first_name, " ", pd.last_name)', $orderType); } else if($orderColumn==3){ $this->db->order_by('pd.address', $orderType); } else if($orderColumn==4){ $this->db->order_by('cs.name', $orderType); } else if($orderColumn==5){ $this->db->order_by('CONCAT(ca.fname, " ", ca.lname)', $orderType); } else if($orderColumn==6){ $this->db->order_by('pcio.clock_in_time', $orderType); } else if($orderColumn==7){ $this->db->order_by('pcio.clock_out_time', $orderType); } $this->db->where(array('pcio.status' => 1)); if ($start_date!='' && $end_date!='') { $this->db->where('DATE(pcio.created_on) >=', $start_date); $this->db->where('DATE(pcio.created_on) <=', $end_date); } $this->db->limit($limit, $start); $query = $this->db->get(); return $query->result(); } function getScheduledVisitsBySearchListPage($limit, $start, $search,$orderColumn, $orderType, $filter) { $currentDate = time(); $start_date=''; $end_date=''; if ($filter=='week') { $start_date = date('Y-m-d', strtotime('this week', $currentDate)); $end_date = date('Y-m-d', strtotime('this week +6 days', $currentDate)); } elseif ($filter=='month') { $start_date = date('Y-m-01'); $end_date = date('Y-m-t'); } elseif ($filter=='year') { $currentYear = date('Y'); $start_date = date('Y-01-01', strtotime($currentYear)); $end_date = date('Y-12-31', strtotime($currentYear)); } $this->db->select('CONCAT(ca.fname, " ", ca.lname) as caregiver_name, CONCAT(pd.first_name, " ", pd.last_name) as patient_name, pcio.clock_in_time, pcio.clock_out_time, cs.name as service_type, pd.address'); $this->db->from('caregiver_patient_clock_in_out pcio'); $this->db->join('patient_details pd', 'pcio.patient_id = pd.id', 'left'); $this->db->join('caregiver ca', 'ca.id = pcio.caregiver_id', 'left'); $this->db->join('master_cg_skills cs', 'cs.id = pd.level_of_service', 'left'); if($orderColumn==0){ $this->db->order_by('pcio.id', $orderType); } else if($orderColumn==1){ $this->db->order_by('pcio.clock_in_time', $orderType); } else if($orderColumn==2){ $this->db->order_by('pd.first_name', $orderType); } else if($orderColumn==3){ $this->db->order_by('pd.address', $orderType); } else if($orderColumn==4){ $this->db->order_by('cs.name', $orderType); } else if($orderColumn==5){ $this->db->order_by('ca.fname', $orderType); } else if($orderColumn==6){ $this->db->order_by('pcio.clock_in_time', $orderType); } else if($orderColumn==7){ $this->db->order_by('pcio.clock_out_time', $orderType); } $this->db->where(array('pcio.status' => 1)); if ($start_date!='' && $end_date!='') { $this->db->where('DATE(pcio.created_on) >=', $start_date); $this->db->where('DATE(pcio.created_on) <=', $end_date); } $this->db->group_start(); $this->db->like('pcio.id', $search); $this->db->or_like("CONCAT(ca.fname, '', ca.lname)", $search); $this->db->or_like("CONCAT(pd.first_name, '', pd.last_name)", $search); $this->db->or_like('pcio.clock_in_time', $search); $this->db->or_like('pcio.clock_out_time', $search); $this->db->or_like('cs.name', $search); $this->db->or_like('pd.address', $search); $this->db->group_end(); $this->db->limit($limit, $start); $query = $this->db->get(); return $query->result(); } function model_get_open_cases($data){ try{ /* | 1. New patients who didn't get any schedule yet. | 2. Unconfirmed schedules [by caregiver]. (If current time crosses the scheduled end time). | 3. Declined schedules [by caregiver]. | 4. Accepted schedules [by caregiver]. (If there is no clocked-in time between that scheduled start & end time). */ $from_api=isset($data['from_api'])&&$data['from_api']!=""?trim($data['from_api']):''; $start=isset($data['start'])?(0+(int)($data['start'])):0; $limit=isset($data['limit'])?(0+(int)($data['limit'])):10; $search=isset($data['search'])&&$data['search']!=""?trim($data['search']):''; $order_column=isset($data['order_column'])?(0+(int)($data['order_column'])):0; $order_type=isset($data['order_type'])&&$data['order_type']!=""?trim($data['order_type']):'DESC'; $filter=isset($data['filter'])&&$data['filter']!=""?trim($data['filter']):'week'; $this->db->distinct(); $this->db->select( 'SQL_CALC_FOUND_ROWS p.id, p.reference_information, p.reference_id, p.referral_type, p.patient_id, p.first_name, p.last_name, CONCAT(p.first_name, " ", p.last_name) as name, p.gender, p.patient_email as email, p.telephone, p.primary_language, p.level_of_service, mcs.name AS service_type, p.address, JSON_UNQUOTE(JSON_EXTRACT(p.address, "$.City")) AS main_city, JSON_UNQUOTE(JSON_EXTRACT(p.address, "$.Zipcode")) AS main_zipcode,',false ); $this->db->from('patient_details p'); $this->db->join('master_cg_skills mcs', 'p.level_of_service = mcs.id', 'left'); $this->db->join('caregiver_schedule cs', 'p.id = cs.patient_id', 'left'); $this->db->join('caregiver_patient_clock_in_out cio', 'cs.id = cio.schedule_id', 'left'); $this->db->where('p.active_status', 1); $this->db->group_start(); $this->db->where('(p.referral_type = "New" AND cs.patient_id IS NULL)'); $this->db->or_where('(cs.status = 1 AND cs.acceptance_status = "Unconfirmed" AND NOW() > cs.end)'); $this->db->or_where('(cs.status = 1 AND cs.acceptance_status = "Accepted" AND NOW() > cs.end AND cio.schedule_id IS NULL)'); $this->db->or_where('(cs.status = 1 AND cs.acceptance_status = "Declined")'); $this->db->group_end(); if($order_column==0){ $this->db->order_by('p.id', $order_type); }elseif($order_column==1) { $this->db->order_by('mcs.name', $order_type); }elseif($order_column==2){ $this->db->order_by('p.first_name', $order_type); }elseif($order_column==3){ $this->db->order_by('p.patient_email', $order_type); }elseif($order_column==4){ $this->db->order_by('p.telephone', $order_type); }elseif($order_column==5){ $this->db->order_by('p.address', $order_type); } if(isset($search) && $search!=''){ $this->db->group_start(); $this->db->like('p.id', $search); $this->db->or_like('mcs.name', $search); $this->db->or_like("CONCAT(p.first_name,' ',p.last_name)", $search); $this->db->or_like('p.patient_email', $search); $this->db->or_like('p.telephone', $search); $this->db->or_like('p.address', $search); $this->db->group_end(); } if($from_api==''){ $this->db->limit($limit,$start); } $query=$this->db->get(); $openCases=$query->result_array(); $openCasesCount=$query->num_rows(); $main_query=$this->db->last_query(); $total_count=($this->db->query("SELECT FOUND_ROWS() AS total_rows"))->row()->total_rows; $response=(object)[ 'status'=>200, 'msg'=>'fetched successfully', 'data'=>(object)[ 'total_count'=>$total_count, 'count'=>$openCasesCount, 'open_cases'=>$openCases, 'query'=>$main_query ] ]; return $response; }catch(Exception $e){ $getMsg="Patient_model - model_get_open_cases: ".$e->getMessage(); echo $getMsg; } } function model_get_patients($data){ try{ $from_api=isset($data['from_api'])&&$data['from_api']!=""?trim($data['from_api']):''; $start=isset($data['start'])?(0+(int)($data['start'])):0; $limit=isset($data['limit'])?(0+(int)($data['limit'])):10; $search=isset($data['search'])&&$data['search']!=""?trim($data['search']):''; $order_column=isset($data['order_column'])?(0+(int)($data['order_column'])):0; $order_type=isset($data['order_type'])&&$data['order_type']!=""?trim($data['order_type']):'DESC'; $filter=isset($data['filter'])&&$data['filter']!=""?trim($data['filter']):'year'; $startDate=isset($data['start_date'])&&$data['start_date']!=""?trim($data['start_date']):null; $endDate=isset($data['end_date'])&&$data['end_date']!=""?trim($data['end_date']):null; $this->db->distinct(); $this->db->select( 'SQL_CALC_FOUND_ROWS FROM_UNIXTIME(u.created_on) AS registered_on, p.id, p.reference_information, p.reference_id, p.referral_type, p.patient_id, p.first_name, p.last_name, CONCAT(p.first_name, " ", p.last_name) as name, p.gender, p.patient_email as email, p.telephone, p.primary_language, p.level_of_service, mcs.name AS service_type, p.address, JSON_UNQUOTE(JSON_EXTRACT(p.address, "$.City")) AS main_city, JSON_UNQUOTE(JSON_EXTRACT(p.address, "$.Zipcode")) AS main_zipcode',false ); $this->db->from('patient_details p'); $this->db->join('users u','p.ion_user_id=u.id'); $this->db->join('master_cg_skills mcs','p.level_of_service=mcs.id','left'); $this->db->where('p.active_status', 1); $this->db->where('u.active', 1); if($startDate!=null && $startDate!='' && $endDate!=null && $endDate!=''){ $this->db->where('DATE(FROM_UNIXTIME(u.created_on)) BETWEEN "'.$startDate.'" AND "'.$endDate.'"'); } if($order_column==0){ $this->db->order_by('p.id', $order_type); }elseif($order_column==1) { $this->db->order_by('mcs.name', $order_type); }elseif($order_column==2){ $this->db->order_by('p.first_name', $order_type); }elseif($order_column==3){ $this->db->order_by('p.patient_email', $order_type); }elseif($order_column==4){ $this->db->order_by('p.telephone', $order_type); }elseif($order_column==5){ $this->db->order_by('p.address', $order_type); } if(isset($search) && $search!=''){ $this->db->group_start(); $this->db->like('p.id', $search); $this->db->or_like('mcs.name', $search); $this->db->or_like("CONCAT(p.first_name,' ',p.last_name)", $search); $this->db->or_like('p.patient_email', $search); $this->db->or_like('p.telephone', $search); $this->db->or_like('p.address', $search); $this->db->group_end(); } if($from_api==''){ $this->db->limit($limit,$start); } $query=$this->db->get(); $activePatients=$query->result_array(); $activePatientsCount=$query->num_rows(); $main_query=$this->db->last_query(); $total_count=($this->db->query("SELECT FOUND_ROWS() AS total_rows"))->row()->total_rows; $response=(object)[ 'status'=>200, 'msg'=>'fetched successfully', 'data'=>(object)[ 'total_count'=>$total_count, 'count'=>$activePatientsCount, 'patients'=>$activePatients, 'query'=>$main_query ] ]; return $response; }catch(Exception $e){ $getMsg="Patient_model - model_get_patients: ".$e->getMessage(); echo $getMsg; } } function model_get_schedules($data){ try{ $from_api=isset($data['from_api'])&&$data['from_api']!=""?trim($data['from_api']):''; $start=isset($data['start'])?(0+(int)($data['start'])):0; $limit=isset($data['limit'])?(0+(int)($data['limit'])):10; $search=isset($data['search'])&&$data['search']!=""?trim($data['search']):''; $order_column=isset($data['order_column'])?(0+(int)($data['order_column'])):0; $order_type=isset($data['order_type'])&&$data['order_type']!=""?trim($data['order_type']):'DESC'; $filter=isset($data['filter'])&&$data['filter']!=""?trim($data['filter']):'year'; $startDate=isset($data['start_date'])&&$data['start_date']!=""?trim($data['start_date']):null; $endDate=isset($data['end_date'])&&$data['end_date']!=""?trim($data['end_date']):null; $this->db->distinct(); $this->db->select( "SQL_CALC_FOUND_ROWS (CASE WHEN (cio.clock_in_time IS NULL AND cio.clock_out_time IS NULL AND cs.acceptance_status='Unconfirmed' AND CURRENT_TIMESTAMP() < cs.end ) THEN 'unconfirmed' WHEN (cio.clock_in_time IS NULL AND cio.clock_out_time IS NULL AND cs.acceptance_status='Accepted' AND CURRENT_TIMESTAMP() < cs.end ) THEN 'upcoming' WHEN (cio.clock_in_time IS NOT NULL AND ( ((cio.clock_out_time IS NULL OR cio.clock_out_time IS NOT NULL) AND cs.acceptance_status='Accepted') OR (cio.clock_out_time IS NULL AND cs.acceptance_status='Reported') ) ) THEN 'ongoing' WHEN (cio.clock_in_time IS NOT NULL AND cio.clock_out_time IS NOT NULL AND cs.acceptance_status='Reported' ) THEN 'completed' WHEN (cio.clock_in_time IS NULL AND cio.clock_out_time IS NULL AND cs.acceptance_status IN('Unconfirmed','Accepted') AND CURRENT_TIMESTAMP() > cs.end ) THEN 'missed' WHEN (cio.clock_in_time IS NULL AND cio.clock_out_time IS NULL AND cs.acceptance_status='Declined' ) THEN 'declined' ELSE 'undefined' END) AS visit_status, cs.acceptance_status, (CASE WHEN (cs.acceptance_status='Reported' AND cio.clock_out_time IS NOT NULL AND a.reporting_approval='0' ) THEN 'pending' WHEN (cs.acceptance_status='Reported' AND cio.clock_out_time IS NOT NULL AND a.reporting_approval='1' ) THEN 'approved' ELSE '' END) AS approval_status, cs.id AS schedule_id, c.id AS caregiver_id, p.id AS patient_id, cs.start AS schedule_start, cs.end AS schedule_end, cio.clock_in_time, cio.clock_out_time, mcs.name AS service_type, CONCAT(c.fname, ' ', c.lname) AS caregiver_name, CONCAT(p.first_name, ' ', p.last_name) AS patient_name, JSON_UNQUOTE(JSON_EXTRACT(p.address, '$.City')) AS patient_main_city, JSON_UNQUOTE(JSON_EXTRACT(p.address, '$.Zipcode')) AS patient_main_zipcode",false ); $this->db->from('caregiver_schedule cs'); $this->db->join('caregiver c', 'cs.caregiver_id=c.id', 'left'); $this->db->join('patient_details p', 'cs.patient_id=p.id', 'left'); $this->db->join('master_cg_skills mcs', 'p.level_of_service=mcs.id', 'left'); $this->db->join('caregiver_patient_clock_in_out cio', 'cs.id=cio.schedule_id', 'left'); $this->db->join('assessment a', 'cs.id=a.schedule_id', 'left'); $this->db->where('cs.status', '1'); if($startDate!=null && $startDate!='' && $endDate!=null && $endDate!=''){ $this->db->where('cs.start BETWEEN "'.$startDate.'" AND "'.$endDate.'"'); } if($order_column==0){ $this->db->order_by('cs.id', $order_type); // $this->db->order_by('cs.start', 'DESC'); }elseif($order_column==1) { $this->db->order_by('cs.start', $order_type); }elseif($order_column==2){ $this->db->order_by('p.first_name', $order_type); }elseif($order_column==3){ $this->db->order_by('p.address', $order_type); }elseif($order_column==4){ $this->db->order_by('mcs.name', $order_type); }elseif($order_column==5){ $this->db->order_by('c.fname', $order_type); }elseif($order_column==6){ $this->db->order_by('cs.acceptance_status', $order_type); } if(isset($search) && $search!=''){ if(in_array(strtolower($search),[ 'unconfirmed', 'upcoming', 'ongoing', 'completed', 'missed', 'declined' ])){ $this->db->having('visit_status',$search); }else if(in_array(strtolower($search),[ 'approval pending', 'approved' ])){ $search=strtolower($search)=='approval pending'?'pending':$search; $this->db->having('approval_status',$search); }else{ $this->db->group_start(); $this->db->like('cs.id', $search); $this->db->or_like('cs.start', $search); $this->db->or_like("CONCAT(p.first_name,' ',p.last_name)", $search); $this->db->or_like('p.address', $search); $this->db->or_like('mcs.name', $search); $this->db->or_like("CONCAT(c.fname,' ',c.lname)", $search); $this->db->or_like('cs.acceptance_status', $search); $this->db->group_end(); } // if(preg_match('/['.preg_quote('unconfirmed','/').']/i', $search)){ // }if(preg_match('/['.preg_quote('upcoming','/').']/i', $search)){ // }if(preg_match('/['.preg_quote('ongoing','/').']/i', $search)){ // }if(preg_match('/['.preg_quote('completed','/').']/i', $search)){ // }if(preg_match('/['.preg_quote('missed','/').']/i', $search)){ // }if(preg_match('/['.preg_quote('declined','/').']/i', $search)){ // } } if($from_api==''){ $this->db->limit($limit,$start); } $query=$this->db->get(); $schedules=$query->result(); $schedulesCount=$query->num_rows(); $main_query=$this->db->last_query(); $total_count=($this->db->query("SELECT FOUND_ROWS() AS total_rows"))->row()->total_rows; $response=(object)[ 'status'=>200, 'msg'=>'fetched successfully', 'data'=>(object)[ 'total_count'=>$total_count, 'count'=>$schedulesCount, 'schedules'=>$schedules, 'query'=>$main_query ] ]; return $response; }catch(Exception $e){ $getMsg="CaregiverSchedule_model - model_get_schedules: ".$e->getMessage(); echo $getMsg; } } } /* for data table end */