Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- defined('BASEPATH') OR exit('No direct script access allowed');
- error_reporting(0);
- class Android_api extends CI_Controller {
- public function index()
- {
- $this->load->view('login');
- }
- public function login_check()
- {
- //echo "id is";
- $username=$_POST['user_name'];
- $password=$_POST['password'];
- $table='tbl_employee_master';
- $where=array('is_deleted'=>'N','employee_contact'=>$username,'employee_password'=>$password);
- $result = $this->Select_model->select_table_data($table,$where);
- //echo $result;
- if($result!=0)
- {
- echo json_encode($result);
- //echo "pass";
- }
- else if($result==0)
- {
- echo "fail";
- }
- }
- public function change_password()
- {
- $user_name=$_POST['user_name'];
- $otp=$_POST['otp'];
- $change_password=$_POST['change_password'];
- $confirm_password=$_POST['confirm_password'];
- $table='tbl_employee_master';
- $where=array('employee_contact'=>$user_name,'is_deleted'=>'N');
- $result=$this->Select_model->select_table_data($table,$where);
- //$data['res'] = $this->Master_model->select_register($table,$where);
- //echo $this->db->last_query();
- //print_r($result);
- foreach($result as $userdata)
- {
- $employee_email=$userdata->employee_email;
- $employee_id=$userdata->employee_id;
- $employee_contact=$userdata->employee_contact;
- $employee_password=$userdata->employee_password;
- }
- if($employee_password == $otp)//$password is from db and $otp is from form
- {
- //echo "inside if";
- if($change_password == $confirm_password)//$change_password and $confirm_password is from form
- {
- $result1 = $this->Select_model->update_password($table,$change_password,$employee_contact);
- //echo $this->db->last_query();
- //print_r($result1);
- if($result1=='Updatetrue')
- {
- echo "pass";
- }
- if($result1=='Updatefalse')
- {
- echo "fail";
- }
- }
- }
- else{
- echo "fail";
- }
- }
- public function forgotpassword()
- {
- $Username=$_POST['user_name'];
- if($Username=='')
- {
- }
- else{
- $mailresult=$this->Login_model->recovery_mail($Username);
- if($mailresult==1)
- {
- echo "Pass";
- }
- else
- {
- echo "fail";
- }
- }
- }
- public function patient_details($id)
- {
- $query = $this->db->query("SELECT * from tbl_patient_details where is_deleted='N' ");
- if($query->num_rows()>0)
- {
- //echo "Pass";
- echo json_encode($query->result());
- }
- else
- {
- echo "fail";
- }
- }
- // reception side appointment details list
- public function appointment_details()
- {
- /* $query = $this->db->query("SELECT appoint.*,patient.*,appoint.patient_id as patient_id,appoint.id as appointment_id,patient.id as patient_id, opd.followup_date,appnt.id as
- appntid from tbl_appointment_details as appoint, tbl_patient_details as patient,tbl_opd_details as opd, appointment as appnt where appoint.status!='Billing' and appoint.is_deleted='N' and patient.is_deleted='N' and appoint.patient_id=patient.patient_id and appnt.patient_id=patient.patient_id and opd.patient_id=patient.patient_id and appoint.appointment_date between '".date('Y-m-d')."' and '".date('Y-m-d')." 23:59:59' group by appoint.appointment_date"); */
- $query = $this->db->query("SELECT appoint.*,patient.*,appoint.patient_id as patient_id,appoint.id as appointment_id, opd.followup_date,appnt.id as appntid ,IF(appoint.appointment_date != '0000-00-00 00:00:00', 'AP', 'WK') as type,appoint.created_time as created_time from tbl_appointment_details as appoint join tbl_patient_details as patient on appoint.patient_id=patient.patient_id and appoint.status!='Billing' and appoint.is_deleted='N' join appointment as appnt ON appnt.patient_id=patient.patient_id left join tbl_opd_details as opd on opd.patient_id=patient.patient_id and appoint.appointment_date between '".date('Y-m-d')."' and '".date('Y-m-d')." 23:59:59' group by appoint.appointment_date,appoint.created_time");
- /* $query = $this->db->query("SELECT appoint.*,patient.*,appoint.patient_id as patient_id,appoint.id as appointment_id,patient.id as patient_id,appnt.id as
- appntid,'0000-00-00' as followup_date from tbl_appointment_details as appoint, tbl_patient_details as patient, appointment as appnt where appoint.is_deleted='N' and patient.is_deleted='N' and appoint.patient_id=patient.patient_id and appnt.patient_id=patient.patient_id and appoint.appointment_date between '".date('Y-m-d')."' and '".date('Y-m-d')." 23:59:59' group by appoint.appointment_date"); */
- //echo $this->db->last_query();
- if($query->num_rows()>0)
- {
- //echo "Pass";
- echo json_encode($query->result());
- }
- else
- {
- echo "fail";
- }
- }
- public function update_consultation($appointment_id,$patient_id)
- {
- /* $updatetoken=array(
- 'status'=>'Billing');
- $this->db->where('appointment_id',$this->input->post('appointment_id'));
- $this->db->where('patient_id',$this->input->post('patient_id'));
- $this->db->update('tbl_appointment_details',$updatetoken); */
- $this->db->query("Update tbl_appointment_details set status='Billing' where id ='".$appointment_id."'");
- $query=$this->db->affected_rows();
- }
- // print doctor report of all appointment patient after giving doctor id and from date and to date
- public function print_report()
- {
- date_default_timezone_set('Asia/Kolkata');
- /* $doctor_id=$_POST['doctor_id']='2';
- $_POST['from_date']='25-04-2017';
- $_POST['to_date']='3-05-2017'; */
- $doctor_id=$_POST['doctor_id'];
- $_POST['from_date'];
- $_POST['to_date'];
- $from_date=date("Y-m-d", strtotime($_POST['from_date']));
- $to_date=date("Y-m-d", strtotime($_POST['to_date']));
- $query = $this->db->query("select TAD.patient_name, TAD.consulting_name, A.doctor_id, TOD.opd_charges, TOD.created_time from tbl_patient_details as TPD
- inner join tbl_appointment_details as TAD on TPD.patient_id = TAD.patient_id
- inner join appointment as A on TAD.patient_id = A.patient_id
- inner join tbl_opd_details as TOD on TAD.patient_id=TOD.patient_id
- where TOD.status='Billing' and A.doctor_id='".$doctor_id."' and TOD.created_time >='".$from_date."' and TOD.created_time<='".$to_date." 59:59:59'
- group by TAD.patient_name");
- //echo $this->db->last_query();
- if($query->num_rows()>0)
- {
- //echo "Pass";
- echo json_encode($query->result());
- }
- else
- {
- echo "fail";
- }
- }
- // only for showing above api hard coaded
- public function print_report_reception()
- {
- date_default_timezone_set('Asia/Kolkata');
- $doctor_name=$_POST['doctor_name'];
- $_POST['from_date'];
- $_POST['to_date'];
- $this->db->select('employee_id');
- $this->db->from('tbl_employee_master');
- $this->db->where('employee_name',$doctor_name);
- $doctor_id= $this->db->get()->row()->employee_id;
- //echo $doctor_id = $this->db->query("select employee_id from tbl_employee_master where employee_name='".$doctor_name."'")->get()->row()->employee_id;
- //echo $this->db->last_query();
- $from_date=date("Y-m-d", strtotime($_POST['from_date']));
- $to_date=date("Y-m-d", strtotime($_POST['to_date']));
- $query = $this->db->query("select TAD.patient_name, TAD.consulting_name as doctor_name, A.doctor_id, TOD.opd_charges, TOD.created_time from
- tbl_patient_details as TPD
- inner join tbl_appointment_details as TAD on TPD.patient_id = TAD.patient_id
- inner join appointment as A on TAD.patient_id = A.patient_id
- inner join tbl_opd_details as TOD on TAD.patient_id=TOD.patient_id
- where TOD.status='Billing' and A.doctor_id='".$doctor_id."' and TOD.created_time >='".$from_date."' and TOD.created_time<='".$to_date." 59:59:59'");
- //echo $this->db->last_query();
- if($query->num_rows()>0)
- {
- //echo "Pass";
- echo json_encode($query->result());
- }
- else
- {
- echo "fail";
- }
- }
- // disply patient list under doctor login
- public function doctor_appoint($doctor_id)
- {
- //$doctor_id='2';
- if($doctor_id!='')
- {
- //$query = $this->db->query("SELECT app.*,appoint.*,patient.*,appoint.patient_id as patient_id ,appnt.id as appntid, IF(appoint.appointment_date != '0000-00-00 00:00:00', 'AP', 'WK') as type,appoint.created_time as created_time from tbl_appointment_details as appoint join tbl_patient_details as patient on appoint.patient_id= patient.patient_id join appointment as app on app.patient_id= patient.patient_id where appoint.status!='Billing' and appoint.is_deleted='N' and patient.is_deleted='N' and app.is_deleted='N' and app.doctor_id='".$doctor_id."' and appoint.appointment_date between '".date('Y-m-d')."' and '".date('Y-m-d')." 23:59:59' group by appoint.appointment_date,appoint.created_time");
- /* $query = $this->db->query("SELECT appoint.*,patient.*,appoint.patient_id as patient_id,appoint.id as appointment_id, opd.followup_date,appnt.id as appntid ,IF(appoint.appointment_date != '0000-00-00 00:00:00', 'AP', 'WK') as type,appoint.created_time as created_time from tbl_appointment_details as appoint join tbl_patient_details as patient on appoint.patient_id=patient.patient_id and appoint.status!='Billing' and appoint.is_deleted='N' join appointment as appnt ON appnt.patient_id=patient.patient_id left join tbl_opd_details as opd on opd.patient_id=patient.patient_id where appnt.doctor_id='".$doctor_id."' group by appoint.appointment_date,appoint.created_time"); */
- $query = $this->db->query("SELECT appoint.*,patient.*,appoint.patient_id as patient_id,appoint.id as appointment_id, opd.followup_date,appnt.id as appntid, md.new_patient_charges,md.followup_charges,IF(appoint.appointment_date != '0000-00-00 00:00:00', 'AP', 'WK') as type,appoint.created_time as created_time from tbl_appointment_details as appoint join tbl_patient_details as patient on appoint.patient_id=patient.patient_id and appoint.status!='Billing' and appoint.is_deleted='N' join appointment as appnt ON appnt.patient_id=patient.patient_id left join tbl_opd_details as opd on opd.patient_id=patient.patient_id join tbl_master_doctor as md ON appnt.doctor_id=md.id and md.id='".$doctor_id."' group by appoint.appointment_date,appoint.created_time");
- //echo $this->db->last_query();
- if($query->num_rows()>0)
- {
- //echo "Pass";
- echo json_encode($query->result());
- }
- else
- {
- echo "fail";
- }
- }
- else
- {
- echo "fail";
- }
- }
- public function patient_quick_search_doctor($doctor_id)
- {
- if($doctor_id!='')
- {
- $query = $this->db->query("SELECT * FROM `appointment` as app join tbl_appointment_details as tad on app.`patient_id`=tad.`patient_id` where `doctor_id`='".$doctor_id."'");
- if($query->num_rows()>0)
- {
- //echo "Pass";
- echo json_encode($query->result());
- }
- else
- {
- echo "fail";
- }
- }
- else{
- echo "fail";
- }
- }
- //appointment_detail_search
- public function patient_quick_search()
- {
- $appointment_search=$_POST['appointment_search']/* ='Ram narsing ghodke' */;
- $appointment_search1=explode(" ",$appointment_search);
- if($appointment_search!='')
- {
- /* $query = $this->db->query("SELECT appoint.*,patient.*,appoint.patient_id as patient_id,'0000-00-00' as followup_date from tbl_appointment_details as appoint, tbl_patient_details as patient
- where appoint.patient_id like('".$appointment_search."%') or appoint.patient_name like('".$appointment_search."%') or appoint.referral_contact like('".$appointment_search."%') and appoint.patient_id=patient.patient_id group by appoint.patient_id"); */
- $query = $this->db->query("SELECT appoint.*,patient.*,appoint.patient_id as patient_id,'0000-00-00' as followup_date from tbl_patient_details as patient left join tbl_appointment_details as appoint
- on appoint.patient_id=patient.patient_id where patient.patient_id like('".$appointment_search."%') or patient.first_name like('".$appointment_search1[0]."%') or appoint.referral_contact like('".$appointment_search."%')group by appoint.patient_id");
- //echo $this->db->last_query();
- if($query->num_rows()>0)
- {
- //echo "Pass";
- echo json_encode($query->result());
- }
- else
- {
- echo "fail";
- }
- }
- else
- {
- echo "fail";
- }
- }
- public function opd_details($id)
- {
- //$id=$_POST['patient_id']='5';
- if($id!='')
- {
- $query = $this->db->query("SELECT * from tbl_opd_details
- where patient_id ='".$id."' and is_deleted='N'");
- // echo $this->db->last_query();
- if($query->num_rows()>0)
- {
- //echo "Pass";
- echo json_encode($query->result());
- }
- else
- {
- echo "fail";
- }
- }
- else
- {
- echo "fail";
- }
- }
- // 3 tables joins api
- public function instruction_details()
- {
- // $instruction_id=$_POST['instruction_id'];
- // echo "sdss";
- /* $query = $this->db->query("
- SELECT medicine.*,dosage.*,instruction.*,prescription.*
- from tbl_prescription_details as prescription join tbl_master_medicine as medicine on prescription.medicine_name=medicine.medicine_name
- join tbl_master_dosage as dosage on prescription.prescription_dosage=dosage.dosage
- join tbl_master_instructions as instruction on prescription.prescription_insructions=instruction.instructions
- where prescription.is_deleted='N'"); */
- $query_medicine = $this->db->query("SELECT * from tbl_master_medicine where is_deleted='N'");
- $dosage = $this->db->query("SELECT * from tbl_master_dosage where is_deleted='N'");
- $instruction = $this->db->query("SELECT * from tbl_master_instructions where is_deleted='N'");
- $lab_test_query = $this->db->query("SELECT * from tbl_master_lab_test where is_deleted='N'");
- //echo $this->db->last_query();
- //echo "Pass";
- echo json_encode(array("medicine details"=>$query_medicine->result(),
- "dosage details"=>$dosage->result(),
- "instruction details"=>$instruction->result(),
- "lab_test_query details"=>$lab_test_query->result()
- ));
- }
- // API for showing all doctors list
- public function doctors_list()
- {
- $query = $this->db->query("SELECT * from tbl_employee_master where is_deleted='N' ");
- //echo $this->db->last_query();
- if($query->num_rows()>0)
- {
- //echo "Pass";
- echo json_encode($query->result());
- }
- else
- {
- echo "fail";
- }
- }
- // check doctor type and print all doctors
- public function doctors_list_detail()
- {
- $query = $this->db->query("SELECT * from tbl_employee_master where is_deleted='N' and Type='D'");
- //echo $this->db->last_query();
- if($query->num_rows()>0)
- {
- //echo "Pass";
- echo json_encode($query->result());
- }
- else
- {
- echo "fail";
- }
- }
- // API for showing all doctors slot time
- public function doctors_slot($id)
- {
- $id=$_POST['id'];
- if($id!='')
- {
- $query = $this->db->query("SELECT * from tbl_doctor_schedule
- where doctor_id ='".$id."' and is_deleted='N' and is_work!='1'" );
- $query2 = $this->db->query("SELECT * from appointment
- where doctor_id ='".$id."' and is_deleted='N'");
- $query3 = $this->db->query("SELECT * from tbl_doctor_schedule
- where doctor_id ='".$id."' and is_deleted='N' and is_work='1'" );
- // echo $this->db->last_query();
- //echo $id;
- if($query->num_rows()>0)
- {
- //echo "Pass";
- echo json_encode(array("doctor"=>$query->result(),"doctor_booked_slot"=>$query2->result(),"Vacation"=>$query3->result()));
- //echo json_encode(array("doctor_booked_slot"=>$query2->result()));
- }
- else
- {
- echo "fail";
- }
- }
- else
- {
- echo "fail";
- }
- }
- // API for display slot time as under the doctor as day wise..
- public function doctors__dayslot($id,$day)
- {
- $id=$_POST['id'];
- $day=$_POST['day'];
- if($id!='')
- {
- $query = $this->db->query("SELECT * from tbl_doctor_schedule
- where doctor_id ='".$id."' and day ='".$day."' and is_deleted='N'");
- // echo $this->db->last_query();
- //echo $id;
- if($query->num_rows()>0)
- {
- //echo "Pass";
- echo json_encode($query->result());
- }
- else
- {
- echo "fail";
- }
- }
- else
- {
- echo "fail";
- }
- }
- // update query
- public function appointment_booked_status($appointment_id,$appointment_id1)
- {
- //$appointment_id=$_POST['appointment_id'];
- // $Cancel="Cancel";
- $yes="Y";
- if($appointment_id1!='')
- {
- $this->db->query("Update appointment set status ='Cancel',is_deleted='Y' where id ='".$appointment_id1."'");
- $query2=$this->db->affected_rows();
- //echo $this->db->last_query();
- }
- if($appointment_id!='')
- {
- $this->db->query("Update tbl_appointment_details set appointment_cancel='Y' where id ='".$appointment_id."'");
- $query3=$this->db->affected_rows();
- //echo $this->db->last_query();
- }
- if($query2 > 0 || $query3 > 0)
- {
- echo "Success";
- //echo json_encode($query->result());
- }
- else
- {
- echo "fail";
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement