Commit 36ff7771 by Jemsheer K D

Merge branch 'master' into client

parents 5a36263c 17b7a32a
......@@ -42,8 +42,10 @@ class Webservice extends CI_Controller {
$ress = $this->cpf_valid($data['cpf']);
if((isset($ress)) && ($ress == 1)){
$is_cpf = $this->Webservice_model->is_cpf_exist($data['cpf']);
$is_cpf = $this->Webservice_model->is_cpf_exist($data['cpf'],0);
if($is_cpf['status'] == 'success'){
$res = $this->registration_processing_user($data,$type);
}else{
$res = array(
......@@ -117,6 +119,7 @@ class Webservice extends CI_Controller {
if($result['status'] == 'success'){
$this->Webservice_model->insert_cpf($data['cpf'],$result['userdata']['id'],0);
$fileName = $result['userdata']['id'].'_'.$_FILES['profile_photo']['name'];
$config = set_upload_options('../assets/uploads/profilepic/patient/');
$config['file_name'] = $fileName;
......@@ -2068,14 +2071,14 @@ class Webservice extends CI_Controller {
// $data['dob'] = strtotime($dob);
$ress = $this->cpf_valid($data['dependent_cpf']);
if($ress == '1'){
$is_cpf = $this->Webservice_model->is_cpf_exist($data['dependent_cpf']);
/*$is_cpf = $this->Webservice_model->is_cpf_exist($data['dependent_cpf']);
if($is_cpf['status'] == 'error'){
$res = array(
"status"=> "error",
"error"=> "CPF Exist",
"message"=> "CPF Already Exist"
);
}else{
}else{*/
$auth_result = $this->Webservice_model->get_userid_frm_authtoken($headers['Auth']);
$fileName =$auth_result->userid.'_'.$_FILES['dependent_image']['name'];
$fileName = str_replace('%','a',$fileName);
......@@ -2116,7 +2119,7 @@ class Webservice extends CI_Controller {
'data' =>array('dependent_list'=>$new_data)
);
}
}
// }
}else{
$res = array(
"status"=> "error",
......@@ -2196,14 +2199,14 @@ class Webservice extends CI_Controller {
if((isset($data['dependent_name'])) && strlen(trim($data['dependent_name']," ")) > 0 && isset($data['dependent_relation']) && strlen(trim($data['dependent_relation']," ")) > 0 && isset($data['dependent_dob']) && strlen(trim($data['dependent_dob']," ")) > 0 && (isset($_FILES['dependent_image']) && isset($data['dependent_id']) && strlen(trim($data['dependent_id']," ")) > 0) && isset($data['dependent_cpf']) && strlen(trim($data['dependent_cpf']," ")) > 0){
$ress = $this->cpf_valid($data['dependent_cpf']);
if($ress == '1'){
$is_cpf = $this->Webservice_model->is_cpf_exist($data['dependent_cpf']);
/*$is_cpf = $this->Webservice_model->is_cpf_exist($data['dependent_cpf']);
if($is_cpf['status'] == 'error'){
$res = array(
"status"=> "error",
"error"=> "CPF Exist",
"message"=> "CPF Already Exist"
);
}else{
}else{*/
$auth_result = $this->Webservice_model->get_userid_frm_authtoken($headers['Auth']);
$fileName = $auth_result->userid.'_'.$_FILES['dependent_image']['name'];
$config = set_upload_options('../assets/uploads/profilepic/patient_dependent/');
......@@ -2244,7 +2247,7 @@ class Webservice extends CI_Controller {
'data' =>array('dependent_list'=>$new_data)
);
}
}
// }
}else{
$res = array(
"status"=> "error",
......@@ -3400,6 +3403,8 @@ class Webservice extends CI_Controller {
$data['specialization'] = $data['specialization_id'];
$data['gender'] = strtoupper($data['gender']);
$ch = curl_init();
$area = $data['zip_code'];
$url = "https://maps.googleapis.com/maps/api/geocode/json?address=${area}&key=AIzaSyDMcP8sMKFPmLROvIf3g1U86_Vg5ur41nQ";
......@@ -3419,6 +3424,7 @@ class Webservice extends CI_Controller {
$result = $this->Webservice_model->registration($data,$type);
if($result['status'] == 'success'){
$this->Webservice_model->insert_cpf($data['cpf'],$result['userdata']['id'],1);
$fileName = $result['userdata']['id'].'_'.$_FILES['profile_photo']['name'];
$config = set_upload_options('../assets/uploads/profilepic/doctors/');
$config['file_name'] = $fileName;
......@@ -3520,6 +3526,62 @@ class Webservice extends CI_Controller {
print json_encode($res);
}
public function cpf_availability(){
header('Content-type: application/json');
$headers = apache_request_headers();
$cpf = $_GET['cpf'];
if(isset($cpf) && strlen(trim($cpf," ")) > 0 ){
$is_cpf = $this->Webservice_model->is_cpf_exist($cpf,0);
if($is_cpf['status'] == 'success'){
$res = array(
"status"=> "success",
"data"=>array("is_available"=>true)
);
}else{
$res = array(
"status"=> "success",
"data"=>array("is_available"=>false)
);
}
}else{
$res = array(
"status"=> "error",
"error"=> "required",
"message"=> "CPF is required"
);
}
print json_encode($res);
}
public function cpf_availability_doctor(){
header('Content-type: application/json');
$headers = apache_request_headers();
$cpf = $_GET['cpf'];
if(isset($cpf) && strlen(trim($cpf," ")) > 0 ){
$is_cpf = $this->Webservice_model->is_cpf_exist($cpf,1);
if($is_cpf['status'] == 'success'){
$res = array(
"status"=> "success",
"data"=>array("is_available"=>true)
);
}else{
$res = array(
"status"=> "success",
"data"=>array("is_available"=>false)
);
}
}else{
$res = array(
"status"=> "error",
"error"=> "required",
"message"=> "CPF is required"
);
}
print json_encode($res);
}
public function cpf_valid($cpf){
$cpf = preg_replace('/[^0-9]/', '', (string) $cpf);
......
......@@ -1454,8 +1454,14 @@ CASE when tbl_registration.gender='0' then 'MALE' when tbl_registration.gender='
//............................ get clinic specialisation
function is_cpf_exist($cpf){
function is_cpf_exist($cpf,$type=''){
if($type == 0){
$res = $this->db->get_where('tbl_cpf_number',array('cpf'=>$cpf,'user_type'=>0))->row();
}else if($type == 1){
$res = $this->db->get_where('tbl_cpf_number',array('cpf'=>$cpf,'user_type'=>1))->row();
}else{
$res = $this->db->get_where('tbl_cpf_number',array('cpf'=>$cpf))->row();
}
if($res){
$query = array('status'=>'error');
}else{
......@@ -1464,6 +1470,14 @@ CASE when tbl_registration.gender='0' then 'MALE' when tbl_registration.gender='
return $query;
}
function insert_cpf($cpf,$id,$type){
if($this->db->insert('tbl_cpf_number',array('cpf'=>$cpf,'user_type'=>$type,'user_id'=>$id))){
return true;
}else{
return false;
}
}
function get_clinic_specialisation(){
$this->db->select("DISTINCT(tbl_specialization.specialization_name),tbl_clinic_specialization.clinic_id,tbl_specialization.id");
$this->db->join('tbl_specialization','tbl_specialization.id = tbl_clinic_specialization.specialization_id');
......@@ -2322,17 +2336,17 @@ CASE when tbl_doctors.gender='0' then 'MALE' when tbl_doctors.gender='1' then 'F
}else{
$nextday = strtotime(date('Y-m-d', strtotime('+1 day', $query['date'])));
$next_day_consult = $this->db->get_where('tbl_booking',array('doctor_id'=>$query['doctor_id'],'clinic_id'=>$query['clinic_id'],'date'=>$nextday,'booking_status'=>'0','time'=>$query['time']))->row_array();
$next_day_consult = $this->db->get_where('tbl_booking',array('doctor_id'=>$query['doctor_id'],'clinic_id'=>$query['clinic_id'],'date'=>$nextday,'booking_status'=>'0','time'=>$query['time'],'payment_status'=>'1'))->row_array();
if($next_day_consult){
$msg3 = "Your Wait Listed Appointment on ".date('d.m.Y h:i a',$next_day_consult['time_start'])." can be changed to ".date('d.m.Y h:i a',$query['time_start'])." as the Time Slot is Available Now. Would you like to change the Appointment on Available Slot ?";
$this->db->insert('tbl_patient_notification',array('patient_id'=>$next_day_consult['patient_id'],'type'=>'0','message'=>$msg3,'time'=>$conslt_time,'booking_id'=>$query['id'],'read_status'=>'0'));
$this->db->insert('tbl_patient_notification',array('patient_id'=>$next_day_consult['patient_id'],'type'=>'4','message'=>$msg3,'time'=>$conslt_time,'booking_id'=>$next_day_consult['id'],'read_status'=>'0'));
$new_patient_insert_id = $this->db->insert_id();
$fcm_user_new = $this->db->get_where('tbl_authtoken',array('userid'=>$next_day_consult['patient_id']))->row();
$new['id'] = $new_patient_insert_id;
$new['type'] = "Consultation Confirmation";
$new['type'] = "Consultation Updates";
$new['booking_id'] = $next_day_consult['id'];
$new['booking_date'] = $query['date'];
$new['doctor_id'] = $query['doctor_id'];
......@@ -3458,6 +3472,63 @@ CASE when tbl_doctors.gender='0' then 'MALE' when tbl_doctors.gender='1' then 'F
$this->db->update('tbl_wallet_details',array('future_earn'=>encrypt_data($future_earn),'total_earn'=>encrypt_data($total)),array('doctor_id'=>$id));
}
}
$todays_consult = $this->db->get_where('tbl_booking',array('doctor_id'=>$query->doctor_id,'clinic_id'=>$query->clinic_id,'date'=>$query->date,'booking_status'=>'0','time'=>$query->book_time,'payment_status'=>'1'))->row_array();
if($todays_consult){
$text = "Your Wait Listed Appointment on ".date('d.m.Y h:i a',$todays_consult['time_start'])." can be changed to ".date('d.m.Y h:i a',$query->time_start)." as the Time Slot is Available Now. Would you like to change the Appointment on Available Slot ?";
$this->db->insert('tbl_patient_notification',array('patient_id'=>$todays_consult['patient_id'],'type'=>'4','message'=>$text,'time'=>$conslt_time,'booking_id'=>$todays_consult['id'],'read_status'=>'0'));
$cancel_patient_insert_id = $this->db->insert_id();
$fcm_user_new = $this->db->get_where('tbl_authtoken',array('userid'=>$todays_consult['patient_id']))->row();
$news['id'] = $cancel_patient_insert_id;
$news['type'] = "Consultation Updates";
$news['booking_id'] = $todays_consult['id'];
$news['booking_date'] = $query->date;
$news['doctor_id'] = $query->doctor_id;
$news['doctor_name'] = $doctr_data['name'];
$news['doctor_specialization'] = $special->specialization_name;
$news['message'] = $text;
$news['time'] = $conslt_time;
$news['to'] =$fcm_user_new->fcm_token;
$user_type = '1';
$push_status =$this->push_sent($news,$user_type);
}else{
$nextday = strtotime(date('Y-m-d', strtotime('+1 day', $query->date)));
$next_day_consult = $this->db->get_where('tbl_booking',array('doctor_id'=>$query->doctor_id,'clinic_id'=>$query->clinic_id,'date'=>$nextday,'booking_status'=>'0','time'=>$query->time,'payment_status'=>'1'))->row_array();
if($next_day_consult){
$text = "Your Wait Listed Appointment on ".date('d.m.Y h:i a',$next_day_consult['time_start'])." can be changed to ".date('d.m.Y h:i a',$query->time_start)." as the Time Slot is Available Now. Would you like to change the Appointment on Available Slot ?";
$this->db->insert('tbl_patient_notification',array('patient_id'=>$next_day_consult['patient_id'],'type'=>'4','message'=>$text,'time'=>$conslt_time,'booking_id'=>$next_day_consult['id'],'read_status'=>'0'));
$cancel_patient_insert_id = $this->db->insert_id();
$fcm_user_new = $this->db->get_where('tbl_authtoken',array('userid'=>$next_day_consult['patient_id']))->row();
$new['id'] = $cancel_patient_insert_id;
$new['type'] = "Consultation Updates";
$new['booking_id'] = $next_day_consult['id'];
$new['booking_date'] = $next_day_consult['date'];
$new['doctor_id'] = $next_day_consult['doctor_id'];
$new['doctor_name'] =$doctr_data['name'];
$new['doctor_specialization'] =$special->specialization_name;
$new['message'] = $text;
$new['time'] = $conslt_time;
$new['to'] =$fcm_user_new->fcm_token;
$user_type = '1';
$push_status =push_sent($new,$user_type);
}
}
$result = array('status'=>'success');
}else{
$result = array('status'=>'failed','message'=>'Invalid Doctor ');
......
......@@ -225,6 +225,61 @@ public function cancelBooking()
$this->Patient_model->change_waitinglist_to_confirmed($check_waiting_list['booking_id']);
}
*/
$todays_consult = $this->db->get_where('tbl_booking',array('doctor_id'=>$booking_details['doc_id'],'clinic_id'=>$booking_details['clinic_id'],'date'=>$booking_details['book_date'],'booking_status'=>'0','time'=>$booking_details['book_time'],'payment_status'=>'1'))->row_array();
if($todays_consult){
$doctor_data = $this->Doctor_model->get_single_doctor($userdata['id']);
$text = "Your Wait Listed Appointment on ".date('d.m.Y h:i a',$todays_consult['time_start'])." can be changed to ".date('d.m.Y h:i a',$booking_details['time_start'])." as the Time Slot is Available Now. Would you like to change the Appointment on Available Slot ?";
$this->db->insert('tbl_patient_notification',array('patient_id'=>$todays_consult['patient_id'],'type'=>'4','message'=>$text,'time'=>strtotime($nowin_server),'booking_id'=>$todays_consult['id'],'read_status'=>'0'));
$new_patient_insert_id = $this->db->insert_id();
$fcm_user_new = $this->Home_model->get_patient_fcm($todays_consult['patient_id']);
$new['id'] = $new_patient_insert_id;
$new['type'] = "Consultation Updates";
$new['booking_id'] = $todays_consult['id'];
$new['booking_date'] = $booking_details['book_date'];
$new['doctor_id'] = $booking_details['doc_id'];
$new['doctor_name'] = $userdata['name'];
$new['doctor_specialization'] = $doctor_data['dr_specialization'];
$new['message'] = $text;
$new['time'] = strtotime($nowin_server);
$new['to'] =$fcm_user_new['fcm_token'];
$user_type = '1';
$push_status =push_sent($new,$user_type);
}else{
$nextday = strtotime(date('Y-m-d', strtotime('+1 day', $booking_details['book_date'])));
$next_day_consult = $this->db->get_where('tbl_booking',array('doctor_id'=>$booking_details['doc_id'],'clinic_id'=>$booking_details['clinic_id'],'date'=>$nextday,'booking_status'=>'0','time'=>$booking_details['book_time'],'payment_status'=>'1'))->row_array();
$fcm_user_new = $this->Home_model->get_patient_fcm($next_day_consult['patient_id']);
if($next_day_consult){
$text = "Your Wait Listed Appointment on ".date('d.m.Y h:i a',$next_day_consult['time_start'])." can be changed to ".date('d.m.Y h:i a',$booking_details['time_start'])." as the Time Slot is Available Now. Would you like to change the Appointment on Available Slot ?";
$this->db->insert('tbl_patient_notification',array('patient_id'=>$next_day_consult['patient_id'],'type'=>'4','message'=>$text,'time'=>strtotime($nowin_server),'booking_id'=>$next_day_consult['id'],'read_status'=>'0'));
$new_patient_insert_id = $this->db->insert_id();
$fcm_user_new = $this->db->get_where('tbl_authtoken',array('userid'=>$next_day_consult['patient_id']))->row();
$new['id'] = $new_patient_insert_id;
$new['type'] = "Consultation Updates";
$new['booking_id'] = $next_day_consult['id'];
$new['booking_date'] = $todays_consult['book_date'];
$new['doctor_id'] = $result['doc_id'];
$new['doctor_name'] = $userdata['name'];
$new['doctor_specialization'] = $doctor_data['dr_specialization'];
$new['message'] = $text;
$new['time'] = strtotime($nowin_server);
$new['to'] =$fcm_user_new['fcm_token'];
$user_type = '1';
$push_status =push_sent($new,$user_type);
}
}
$day_appointment = $this->Doctor_model->get_doctor_appointments_day($userdata['id'],$_POST['selectedDate']);
foreach ($day_appointment as $key => $value)
{
......
......@@ -137,7 +137,7 @@ public function cancelBooking()
/*------------------------------------------------*/
$check_waiting_list = $this->Patient_model->check_waiting_list($result);
//print_r($check_waiting_list);die();
//check any user Exist in waiting List on that date if true ;
if($check_waiting_list['count']>0)
{
$this->Patient_model->change_waitinglist_to_confirmed($check_waiting_list['booking_id']);
......@@ -194,6 +194,35 @@ public function cancelBooking()
}
/*------------------------------------------------*/
}//if no user exist in waiting list on that particular date. check on next date.
else{
$nextday = strtotime(date('Y-m-d', strtotime('+1 day', $booking_details['book_date'])));
$next_day_consult = $this->db->get_where('tbl_booking',array('doctor_id'=>$booking_details['doc_id'],'clinic_id'=>$booking_details['clinic_id'],'date'=>$nextday,'booking_status'=>'0','time'=>$booking_details['book_time'],'payment_status'=>'1'))->row_array();
$doctor_data_waiting = $this->Doctor_model->get_single_doctor($next_day_consult['doctor_id']);
$fcm_user = $this->Home_model->get_patient_fcm($next_day_consult['patient_id']);
if($next_day_consult){
$text = "Your Wait Listed Appointment on ".date('d.m.Y h:i a',$next_day_consult['time_start'])." can be changed to ".date('d.m.Y h:i a',$result['time_start'])." as the Time Slot is Available Now. Would you like to change the Appointment on Available Slot ?";
$this->db->insert('tbl_patient_notification',array('patient_id'=>$next_day_consult['patient_id'],'type'=>'4','message'=>$text,'time'=>strtotime($nowin_server),'booking_id'=>$next_day_consult['id'],'read_status'=>'0'));
$new_patient_insert_id = $this->db->insert_id();
$fcm_user = $this->Home_model->get_patient_fcm($next_day_consult['patient_id']);
$new['id'] = $new_patient_insert_id;
$new['type'] = "Consultation Updates";
$new['booking_id'] = $next_day_consult['id'];
$new['booking_date'] = $booking_details['book_date'];
$new['doctor_id'] = $booking_details['doc_id'];
$new['doctor_name'] = $doctor_data_waiting['dr_name'];
$new['doctor_specialization'] = $doctor_data_waiting['dr_specialization'];
$new['message'] = $text;
$new['time'] = strtotime($nowin_server);
$new['to'] =$fcm_user['fcm_token'];
$user_type = '1';
$push_status =push_sent($new,$user_type);
}
}
$confirmed_consultation = $this->Patient_model->get_patient_confirmed_consultation($userdata['id']);
$template['confirmed_consultation'] = $confirmed_consultation;
......
......@@ -1143,9 +1143,11 @@ else
if(empty($patient_data['pt_customer_id']))
{
$create_customer = array('email'=>$patient_data['pt_email'],'name'=>$patient_data['pt_name'],'cpf_cnpj'=>$patient_data['pt_cpf'],'zip_code' => $patient_data['pt_zip_code'],'street'=>$patient_data['pt_street_add'],'number'=>$patient_data['pt_number'],'complement'=>$patient_data['pt_complement']);
$create_customer = array('email'=>$patient_data['pt_email'],'name'=>decrypt_data($patient_data['pt_name']),/*'cpf_cnpj'=>$patient_data['pt_cpf'],*/'zip_code' => decrypt_data($patient_data['pt_zip_code']),'street'=>decrypt_data($patient_data['pt_street_add']),'number'=>decrypt_data($patient_data['pt_number']),'complement'=>decrypt_data($patient_data['pt_complement']));
$request = load_curl('https://api.iugu.com/v1/customers',$create_customer);
$customer = json_decode($request);
$this->Patient_model->update_profile($patient_data['patientid'],array('customer_id' => $customer->id ));
$patient_data['pt_customer_id'] = $customer->id;
}
......
......@@ -382,6 +382,7 @@ public function get_booking_details($book_id)
{
$this->db->select("tbl_booking.id as book_id,
tbl_booking.date as book_date,
tbl_booking.clinic_id,
tbl_booking.time as book_time,
tbl_booking.total_sum as book_price,
tbl_booking.visit_type as visit_type,
......
......@@ -511,9 +511,9 @@ function insertVacation($request)
function update_profile($id,$data)
{
$date_of_birth = $data['dob'];
unset($data['dob']);
//$date_of_birth = $data['dob'];
//unset($data['dob']);
//print_r($data);exit();
$this->db->where('tbl_registration.id',$id);
if($this->db->update('tbl_registration',$data))
......@@ -522,7 +522,7 @@ function update_profile($id,$data)
$this->db->query("update tbl_registration set dob = AES_ENCRYPT(".$date_of_birth.",'Ptf/PWNWrULQT72syxfaaBRTS9JbiKrj9dfuVEvT3rA')where id = ".$id);
//$this->db->query("update tbl_registration set dob = AES_ENCRYPT(".$date_of_birth.",'Ptf/PWNWrULQT72syxfaaBRTS9JbiKrj9dfuVEvT3rA')where id = ".$id);
$result = array('status' => 'success');
......@@ -535,7 +535,8 @@ function update_profile($id,$data)
$result = array('status' => 'error');
}
//echo $this->db->last_query();
//print_r($result);exit();
return $result;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment