Advertisement
Guest User

Untitled

a guest
May 27th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.33 KB | None | 0 0
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3. error_reporting(0);
  4. class Android_api extends CI_Controller {
  5.  
  6. public function index()
  7. {
  8. $this->load->view('login');
  9.  
  10. }
  11.  
  12. public function login_check()
  13. {
  14. //echo "id is";
  15. $username=$_POST['user_name'];
  16. $password=$_POST['password'];
  17. $table='tbl_employee_master';
  18. $where=array('is_deleted'=>'N','employee_contact'=>$username,'employee_password'=>$password);
  19.  
  20. $result = $this->Select_model->select_table_data($table,$where);
  21. //echo $result;
  22.  
  23. if($result!=0)
  24. {
  25. echo json_encode($result);
  26. //echo "pass";
  27. }
  28. else if($result==0)
  29. {
  30. echo "fail";
  31. }
  32. }
  33.  
  34.  
  35.  
  36.  
  37. public function change_password()
  38. {
  39.  
  40. $user_name=$_POST['user_name'];
  41. $otp=$_POST['otp'];
  42. $change_password=$_POST['change_password'];
  43. $confirm_password=$_POST['confirm_password'];
  44.  
  45. $table='tbl_employee_master';
  46. $where=array('employee_contact'=>$user_name,'is_deleted'=>'N');
  47. $result=$this->Select_model->select_table_data($table,$where);
  48. //$data['res'] = $this->Master_model->select_register($table,$where);
  49. //echo $this->db->last_query();
  50. //print_r($result);
  51.  
  52.  
  53. foreach($result as $userdata)
  54. {
  55. $employee_email=$userdata->employee_email;
  56. $employee_id=$userdata->employee_id;
  57. $employee_contact=$userdata->employee_contact;
  58. $employee_password=$userdata->employee_password;
  59.  
  60. }
  61.  
  62.  
  63. if($employee_password == $otp)//$password is from db and $otp is from form
  64. {
  65. //echo "inside if";
  66.  
  67. if($change_password == $confirm_password)//$change_password and $confirm_password is from form
  68. {
  69. $result1 = $this->Select_model->update_password($table,$change_password,$employee_contact);
  70. //echo $this->db->last_query();
  71.  
  72. //print_r($result1);
  73.  
  74. if($result1=='Updatetrue')
  75. {
  76. echo "pass";
  77. }
  78.  
  79. if($result1=='Updatefalse')
  80. {
  81. echo "fail";
  82. }
  83. }
  84.  
  85.  
  86.  
  87. }
  88. else{
  89. echo "fail";
  90. }
  91. }
  92.  
  93. public function forgotpassword()
  94. {
  95. $Username=$_POST['user_name'];
  96. if($Username=='')
  97. {
  98.  
  99. }
  100. else{
  101. $mailresult=$this->Login_model->recovery_mail($Username);
  102.  
  103. if($mailresult==1)
  104. {
  105. echo "Pass";
  106. }
  107. else
  108. {
  109. echo "fail";
  110. }
  111. }
  112. }
  113.  
  114.  
  115. public function patient_details($id)
  116. {
  117.  
  118. $query = $this->db->query("SELECT * from tbl_patient_details where is_deleted='N' ");
  119. if($query->num_rows()>0)
  120. {
  121. //echo "Pass";
  122. echo json_encode($query->result());
  123. }
  124. else
  125. {
  126. echo "fail";
  127. }
  128.  
  129. }
  130.  
  131.  
  132.  
  133. // reception side appointment details list
  134.  
  135. public function appointment_details()
  136. {
  137.  
  138. /* $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
  139. 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"); */
  140.  
  141.  
  142. $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");
  143.  
  144. /* $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
  145. 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"); */
  146.  
  147.  
  148. //echo $this->db->last_query();
  149.  
  150. if($query->num_rows()>0)
  151. {
  152. //echo "Pass";
  153. echo json_encode($query->result());
  154. }
  155. else
  156. {
  157. echo "fail";
  158. }
  159.  
  160. }
  161.  
  162.  
  163.  
  164. public function update_consultation($appointment_id,$patient_id)
  165. {
  166. /* $updatetoken=array(
  167. 'status'=>'Billing');
  168. $this->db->where('appointment_id',$this->input->post('appointment_id'));
  169. $this->db->where('patient_id',$this->input->post('patient_id'));
  170. $this->db->update('tbl_appointment_details',$updatetoken); */
  171.  
  172. $this->db->query("Update tbl_appointment_details set status='Billing' where id ='".$appointment_id."'");
  173.  
  174. $query=$this->db->affected_rows();
  175. }
  176.  
  177.  
  178.  
  179. // print doctor report of all appointment patient after giving doctor id and from date and to date
  180.  
  181. public function print_report()
  182. {
  183. date_default_timezone_set('Asia/Kolkata');
  184. /* $doctor_id=$_POST['doctor_id']='2';
  185. $_POST['from_date']='25-04-2017';
  186. $_POST['to_date']='3-05-2017'; */
  187.  
  188. $doctor_id=$_POST['doctor_id'];
  189. $_POST['from_date'];
  190. $_POST['to_date'];
  191.  
  192. $from_date=date("Y-m-d", strtotime($_POST['from_date']));
  193. $to_date=date("Y-m-d", strtotime($_POST['to_date']));
  194.  
  195. $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
  196. inner join tbl_appointment_details as TAD on TPD.patient_id = TAD.patient_id
  197. inner join appointment as A on TAD.patient_id = A.patient_id
  198. inner join tbl_opd_details as TOD on TAD.patient_id=TOD.patient_id
  199. 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'
  200. group by TAD.patient_name");
  201.  
  202.  
  203. //echo $this->db->last_query();
  204.  
  205. if($query->num_rows()>0)
  206. {
  207. //echo "Pass";
  208. echo json_encode($query->result());
  209. }
  210. else
  211. {
  212. echo "fail";
  213. }
  214.  
  215. }
  216.  
  217. // only for showing above api hard coaded
  218. public function print_report_reception()
  219. {
  220. date_default_timezone_set('Asia/Kolkata');
  221. $doctor_name=$_POST['doctor_name'];
  222. $_POST['from_date'];
  223. $_POST['to_date'];
  224.  
  225. $this->db->select('employee_id');
  226. $this->db->from('tbl_employee_master');
  227. $this->db->where('employee_name',$doctor_name);
  228. $doctor_id= $this->db->get()->row()->employee_id;
  229. //echo $doctor_id = $this->db->query("select employee_id from tbl_employee_master where employee_name='".$doctor_name."'")->get()->row()->employee_id;
  230. //echo $this->db->last_query();
  231.  
  232. $from_date=date("Y-m-d", strtotime($_POST['from_date']));
  233. $to_date=date("Y-m-d", strtotime($_POST['to_date']));
  234.  
  235. $query = $this->db->query("select TAD.patient_name, TAD.consulting_name as doctor_name, A.doctor_id, TOD.opd_charges, TOD.created_time from
  236. tbl_patient_details as TPD
  237. inner join tbl_appointment_details as TAD on TPD.patient_id = TAD.patient_id
  238. inner join appointment as A on TAD.patient_id = A.patient_id
  239. inner join tbl_opd_details as TOD on TAD.patient_id=TOD.patient_id
  240. 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'");
  241.  
  242.  
  243. //echo $this->db->last_query();
  244.  
  245. if($query->num_rows()>0)
  246. {
  247. //echo "Pass";
  248. echo json_encode($query->result());
  249. }
  250. else
  251. {
  252. echo "fail";
  253. }
  254.  
  255. }
  256.  
  257.  
  258. // disply patient list under doctor login
  259.  
  260. public function doctor_appoint($doctor_id)
  261. {
  262. //$doctor_id='2';
  263. if($doctor_id!='')
  264. {
  265. //$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");
  266.  
  267.  
  268. /* $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"); */
  269.  
  270.  
  271. $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");
  272.  
  273.  
  274.  
  275.  
  276. //echo $this->db->last_query();
  277.  
  278. if($query->num_rows()>0)
  279. {
  280. //echo "Pass";
  281. echo json_encode($query->result());
  282. }
  283. else
  284. {
  285. echo "fail";
  286. }
  287. }
  288. else
  289. {
  290. echo "fail";
  291. }
  292. }
  293.  
  294. public function patient_quick_search_doctor($doctor_id)
  295. {
  296.  
  297.  
  298. if($doctor_id!='')
  299. {
  300. $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."'");
  301. if($query->num_rows()>0)
  302. {
  303. //echo "Pass";
  304. echo json_encode($query->result());
  305. }
  306. else
  307. {
  308. echo "fail";
  309. }
  310. }
  311. else{
  312. echo "fail";
  313. }
  314. }
  315.  
  316. //appointment_detail_search
  317.  
  318. public function patient_quick_search()
  319. {
  320.  
  321. $appointment_search=$_POST['appointment_search']/* ='Ram narsing ghodke' */;
  322.  
  323. $appointment_search1=explode(" ",$appointment_search);
  324.  
  325. if($appointment_search!='')
  326. {
  327.  
  328. /* $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
  329. 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"); */
  330.  
  331. $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
  332. 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");
  333.  
  334. //echo $this->db->last_query();
  335.  
  336. if($query->num_rows()>0)
  337. {
  338. //echo "Pass";
  339. echo json_encode($query->result());
  340. }
  341. else
  342. {
  343. echo "fail";
  344. }
  345. }
  346. else
  347. {
  348. echo "fail";
  349. }
  350.  
  351. }
  352.  
  353.  
  354. public function opd_details($id)
  355. {
  356. //$id=$_POST['patient_id']='5';
  357. if($id!='')
  358. {
  359. $query = $this->db->query("SELECT * from tbl_opd_details
  360. where patient_id ='".$id."' and is_deleted='N'");
  361.  
  362. // echo $this->db->last_query();
  363.  
  364. if($query->num_rows()>0)
  365. {
  366. //echo "Pass";
  367. echo json_encode($query->result());
  368. }
  369. else
  370. {
  371. echo "fail";
  372. }
  373. }
  374.  
  375. else
  376. {
  377. echo "fail";
  378. }
  379.  
  380. }
  381.  
  382. // 3 tables joins api
  383.  
  384. public function instruction_details()
  385. {
  386.  
  387. // $instruction_id=$_POST['instruction_id'];
  388.  
  389. // echo "sdss";
  390.  
  391. /* $query = $this->db->query("
  392. SELECT medicine.*,dosage.*,instruction.*,prescription.*
  393. from tbl_prescription_details as prescription join tbl_master_medicine as medicine on prescription.medicine_name=medicine.medicine_name
  394. join tbl_master_dosage as dosage on prescription.prescription_dosage=dosage.dosage
  395. join tbl_master_instructions as instruction on prescription.prescription_insructions=instruction.instructions
  396. where prescription.is_deleted='N'"); */
  397.  
  398. $query_medicine = $this->db->query("SELECT * from tbl_master_medicine where is_deleted='N'");
  399. $dosage = $this->db->query("SELECT * from tbl_master_dosage where is_deleted='N'");
  400. $instruction = $this->db->query("SELECT * from tbl_master_instructions where is_deleted='N'");
  401.  
  402.  
  403. $lab_test_query = $this->db->query("SELECT * from tbl_master_lab_test where is_deleted='N'");
  404.  
  405. //echo $this->db->last_query();
  406.  
  407.  
  408. //echo "Pass";
  409. echo json_encode(array("medicine details"=>$query_medicine->result(),
  410. "dosage details"=>$dosage->result(),
  411. "instruction details"=>$instruction->result(),
  412. "lab_test_query details"=>$lab_test_query->result()
  413. ));
  414.  
  415.  
  416.  
  417. }
  418.  
  419.  
  420.  
  421. // API for showing all doctors list
  422.  
  423. public function doctors_list()
  424. {
  425. $query = $this->db->query("SELECT * from tbl_employee_master where is_deleted='N' ");
  426.  
  427. //echo $this->db->last_query();
  428.  
  429. if($query->num_rows()>0)
  430. {
  431. //echo "Pass";
  432. echo json_encode($query->result());
  433. }
  434. else
  435. {
  436. echo "fail";
  437. }
  438.  
  439. }
  440.  
  441. // check doctor type and print all doctors
  442.  
  443. public function doctors_list_detail()
  444. {
  445. $query = $this->db->query("SELECT * from tbl_employee_master where is_deleted='N' and Type='D'");
  446.  
  447. //echo $this->db->last_query();
  448.  
  449. if($query->num_rows()>0)
  450. {
  451. //echo "Pass";
  452. echo json_encode($query->result());
  453. }
  454. else
  455. {
  456. echo "fail";
  457. }
  458.  
  459. }
  460.  
  461.  
  462.  
  463. // API for showing all doctors slot time
  464.  
  465. public function doctors_slot($id)
  466. {
  467. $id=$_POST['id'];
  468. if($id!='')
  469. {
  470.  
  471. $query = $this->db->query("SELECT * from tbl_doctor_schedule
  472. where doctor_id ='".$id."' and is_deleted='N' and is_work!='1'" );
  473.  
  474. $query2 = $this->db->query("SELECT * from appointment
  475. where doctor_id ='".$id."' and is_deleted='N'");
  476.  
  477. $query3 = $this->db->query("SELECT * from tbl_doctor_schedule
  478. where doctor_id ='".$id."' and is_deleted='N' and is_work='1'" );
  479.  
  480. // echo $this->db->last_query();
  481. //echo $id;
  482.  
  483. if($query->num_rows()>0)
  484. {
  485. //echo "Pass";
  486. echo json_encode(array("doctor"=>$query->result(),"doctor_booked_slot"=>$query2->result(),"Vacation"=>$query3->result()));
  487.  
  488. //echo json_encode(array("doctor_booked_slot"=>$query2->result()));
  489.  
  490.  
  491. }
  492. else
  493. {
  494. echo "fail";
  495. }
  496. }
  497.  
  498. else
  499. {
  500. echo "fail";
  501. }
  502.  
  503. }
  504.  
  505. // API for display slot time as under the doctor as day wise..
  506.  
  507. public function doctors__dayslot($id,$day)
  508. {
  509. $id=$_POST['id'];
  510. $day=$_POST['day'];
  511. if($id!='')
  512. {
  513. $query = $this->db->query("SELECT * from tbl_doctor_schedule
  514. where doctor_id ='".$id."' and day ='".$day."' and is_deleted='N'");
  515.  
  516. // echo $this->db->last_query();
  517. //echo $id;
  518.  
  519. if($query->num_rows()>0)
  520. {
  521. //echo "Pass";
  522. echo json_encode($query->result());
  523.  
  524. }
  525. else
  526. {
  527. echo "fail";
  528. }
  529. }
  530.  
  531. else
  532. {
  533. echo "fail";
  534. }
  535.  
  536. }
  537.  
  538. // update query
  539.  
  540. public function appointment_booked_status($appointment_id,$appointment_id1)
  541. {
  542. //$appointment_id=$_POST['appointment_id'];
  543. // $Cancel="Cancel";
  544. $yes="Y";
  545.  
  546.  
  547. if($appointment_id1!='')
  548. {
  549.  
  550. $this->db->query("Update appointment set status ='Cancel',is_deleted='Y' where id ='".$appointment_id1."'");
  551. $query2=$this->db->affected_rows();
  552. //echo $this->db->last_query();
  553. }
  554.  
  555. if($appointment_id!='')
  556. {
  557.  
  558. $this->db->query("Update tbl_appointment_details set appointment_cancel='Y' where id ='".$appointment_id."'");
  559. $query3=$this->db->affected_rows();
  560. //echo $this->db->last_query();
  561. }
  562.  
  563. if($query2 > 0 || $query3 > 0)
  564. {
  565. echo "Success";
  566. //echo json_encode($query->result());
  567.  
  568. }
  569. else
  570. {
  571. echo "fail";
  572. }
  573.  
  574.  
  575. }
  576.  
  577.  
  578.  
  579. }
  580.  
  581.  
  582.  
  583. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement