PageRenderTime 57ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 1ms

/firebaseclass.php

https://bitbucket.org/devpronitzz/healthcase
PHP | 2823 lines | 2224 code | 357 blank | 242 comment | 103 complexity | 48ac0966e9d8fc21f852cbcc5ad85f0d MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, BSD-3-Clause, Apache-2.0, MIT
  1. <?php
  2. $root = $_SERVER['DOCUMENT_ROOT'];
  3. /*
  4. include_once $root.'/services/connection/db.php';
  5. include_once $root.'/services/classes/publicClass/commanClass.php';
  6. include_once $root.'/services/classes/publicClass/responseClass.php';
  7. */
  8. //include_once 'connection/db.php';
  9. include_once 'publicClass/responseClass.php';
  10. require './firebase/vendor/autoload.php';
  11. use Kreait\Firebase\Factory;
  12. use Kreait\Firebase\ServiceAccount;
  13. error_reporting(E_ALL ^ E_DEPRECATED);
  14. //Create Connection Class
  15. class UserClass
  16. {
  17. var $conn;
  18. //constructor to eastablishment connection with database
  19. public function __construct()
  20. {
  21. $serviceAccount = ServiceAccount::fromJsonFile('./firebase/firebase_credentials.json');
  22. $firebase = (new Factory)
  23. ->withServiceAccount($serviceAccount)
  24. ->withDatabaseUri('https://projects-a6962.firebaseio.com')
  25. ->create();
  26. $this->conn = $firebase->getDatabase();
  27. }
  28. /*********Query start Following Block 1********/
  29. /*public function imageupload()
  30. {
  31. $image_name = $_FILES["fileUpload1"]["name"];
  32. $tmp_arr = explode(".",$image_name);
  33. $img_extn = end($tmp_arr);
  34. $new_image_name = 'image_'. uniqid() . date('YmdHis').'.'.$img_extn;
  35. $flag=0;
  36. if (file_exists("uploads/".$new_image_name))
  37. {
  38. return false;
  39. }
  40. else
  41. {
  42. move_uploaded_file($_FILES["fileUpload1"]["tmp_name"],"uploads/". $new_image_name);
  43. $flag = 1;
  44. $static_url = "http://bytesnmaterials.com/healthcare/uploads/".$new_image_name;
  45. return $static_url;
  46. }
  47. }*/
  48. //$imagePath = 'http://bytesnmaterials.com/healthcare/profile/profile.png';
  49. public function signup_doctor($doctorName,$address,$mobileNo,$emailID,$passwordD,$deviceID,$register_image,$latID,$logID,$file_url_name,$imagePath,$unionID1,$feeID,$specialID,$callstatus)
  50. {
  51. /*mysql_query("set character_set_server='utf8'");
  52. mysql_query("set names 'utf8'");
  53. */
  54. if(isset($_FILES['imageData']['name']))
  55. {
  56. if((($_FILES['imageData']['type'] == "image/jpeg")|| ($_FILES['imageData']['type'] == "image/gif")|| ($_FILES['imageData']['type'] == "image/jpg")|| ($_FILES['imageData']['type'] == "image/png")&& ($_FILES['imageData']['size'] < 1000000000000000))){
  57. if ($_FILES["imageData"]["error"] > 0) echo "Return Code: " . $_FILES["imageData"]["error"] . "<br />"; else {
  58. $Ex = end(explode(".",$_FILES['imageData']['name']));
  59. $array = explode(".",$_FILES['imageData']['name']);
  60. $file_url_name = $array[0].time().".".$Ex;
  61. move_uploaded_file($_FILES["imageData"]["tmp_name"], "uploads/col_certificate/".$file_url_name);
  62. }
  63. }
  64. }
  65. $file_url_name1 = "http://bytesnmaterials.com/healthcare/uploads/col_certificate/".$file_url_name;
  66. $register_image1 = "http://bytesnmaterials.com/healthcare/uploads/register_image/".$register_image;
  67. /*$sql = "INSERT INTO `doctor_signup` (`device_id`,`register_image`, `doctor_name`, `address`, `mobile_no`, `email_id`, `password`, `lat`, `log`,`col_certificate`, `union_id`, `status`, `type`, `profile_pic`, `specialization`,`payment_id`, `fee`, `chat_status`,`call_status`) VALUES ('$deviceID','$register_image1', '$doctorName', '$address', '$mobileNo', '$emailID', '$passwordD', '$latID', '$logID' ,'$file_url_name1', '$unionID1', '0', 'D','http://bytesnmaterials.com/healthcare/profile/profile.png','$specialID','0','$feeID','0','$callstatus')";
  68. $result=mysql_query($sql);
  69. return $result;*/
  70. $postData = [
  71. 'device_id' => $deviceID,
  72. 'register_image' => $register_image1,
  73. 'doctor_name' => $doctorName,
  74. 'address' => $address,
  75. 'mobile_no' => $mobileNo,
  76. 'email_id' => $emailID,
  77. 'password' => $passwordD,
  78. 'lat' => $latID,
  79. 'log' => $logID,
  80. 'col_certificate' =>$file_url_name1,
  81. 'union_id' => $unionID1,
  82. 'status' => '0',
  83. 'type' => 'D',
  84. 'profile_pic' => 'http://bytesnmaterials.com/healthcare/profile/profile.png',
  85. 'specialization' => $specialID,
  86. 'payment_id' => '0',
  87. 'fee' => $feeID,
  88. 'chat_status' => '0',
  89. 'call_status' => $callstatus,
  90. 'union_id' => '',
  91. 'doctor_id' => '',
  92. 'register_image' => ''
  93. ];
  94. $postRef = $this->conn->getReference('doctor_signup')->push($postData);
  95. return $postRef;
  96. }
  97. public function insert_notification_details($tokenID,$patientID,$doctorID,$name,$message,$caseD,$date,$type,$status)
  98. {
  99. mysql_query("set character_set_server='utf8'");
  100. mysql_query("set names 'utf8'");
  101. $sql = "INSERT INTO `push_notification`(`doctor_id`, `patient_id`, `name`, `message`, `token`, `case_description`,`date`, `type`, `status`) VALUES ('$doctorID', '$patientID','$name','$message','$tokenID','$caseD','$date','P','$status')";
  102. $result=mysql_query($sql);
  103. return $result;
  104. }
  105. public function insert_push_notification_details($tokenID,$patientID,$patientname,$getresult,$caseD,$date,$type,$status)
  106. {
  107. mysql_query("set character_set_server='utf8'");
  108. mysql_query("set names 'utf8'");
  109. //$sql = "INSERT INTO `push_notification`(`doctor_id`, `patient_id`, `name`, `message`, `token`, `case_description`,`date`, `type`, `status`) VALUES ('$getresult', '$patientID','$name','Request To Chat','$tokenID','$caseD','$date','$type','$status')";
  110. $sql = "INSERT INTO `chat_message`(`from_id`, `to_id`, `message`, `status`, `type`, `message_type`, `read_status`) VALUES ('$patientID','$getresult','$caseD','0','P','p_text','0')";
  111. //echo $sql;
  112. $result=mysql_query($sql);
  113. return $result;
  114. }
  115. public function insert_patient_notification($patientID,$doctorID,$message,$date,$status)
  116. {
  117. mysql_query("set character_set_server='utf8'");
  118. mysql_query("set names 'utf8'");
  119. $sql = "INSERT INTO `push_notification_details`(`patient_id`, `doctor_id`, `message`, `status`, `date`) VALUES ('$patientID','$doctorID','$message','$status','$date')";
  120. $result=mysql_query($sql);
  121. return $result;
  122. }
  123. public function update_pushnotification($id,$status)
  124. {
  125. mysql_query("set character_set_server='utf8'");
  126. mysql_query("set names 'utf8'");
  127. $sql = "UPDATE `push_notification` SET `status`='$status' WHERE `id`='$id'";
  128. $result=mysql_query($sql);
  129. return $result;
  130. }
  131. public function insert_patient_details($patientName,$emailID,$phoneNo,$address,$case_desc,$password,$age,$latitude,$logitude,$type,$tokenID)
  132. {
  133. /*mysql_query("set character_set_server='utf8'");
  134. mysql_query("set names 'utf8'");
  135. $sql = "INSERT INTO `patient` (`patient_name`, `email_id`, `mobile_no`, `address`,`case_desc`, `profile_pic`, `password`, `age`, `lat`, `log`, `type`, `token`, `took`,`status`,`call_status`) VALUES ('$patientName', '$emailID', '$phoneNo', '$address','$case_desc', 'http://bytesnmaterials.com/healthcare/profile/profile.png', '$password', '$age', '$latitude', '$logitude', '$type', '$tokenID','0','0','1')";
  136. $result=mysql_query($sql);
  137. return $result;*/
  138. $postData = [
  139. 'patient_name' => $patientName,
  140. 'email_id' => $emailID,
  141. 'mobile_no' => $phoneNo,
  142. 'address' => $address,
  143. 'case_desc' => $case_desc,
  144. 'profile_pic' => "http://bytesnmaterials.com/healthcare/profile/profile.png",
  145. 'password' => $password,
  146. 'age'=> $age,
  147. 'type' => $type,
  148. 'lat' => $latitude,
  149. 'log' => $logitude,
  150. 'token' => $tokenID,
  151. 'took' => '0',
  152. 'status' => '0',
  153. 'call_status' => '1'
  154. ];
  155. $postRef = $this->conn->getReference('patient')->push($postData);
  156. // print_r($postRef);
  157. // exit;
  158. return $postRef;
  159. }
  160. public function insert_pharmacy_details($pharmacyName,$emailID,$phoneNo,$address,$password,$age,$latitude,$logitude,$type,$tokenID,$hour_status,$working_hour)
  161. {
  162. if($is_24_hours_support == ""){
  163. $is_24_hours_support1 = "false";
  164. }else{
  165. $is_24_hours_support1 = $is_24_hours_support;
  166. }
  167. /*mysql_query("set character_set_server='utf8'");
  168. mysql_query("set names 'utf8'");
  169. $sql = "INSERT INTO `pharmacy`(`pharmacy_name`, `email_id`, `mobile_no`, `address`, `profile_pic`, `password`, `age`, `lat`, `log`, `type`, `token`, `call_status`, `hour_status`, `home_delivery`, `working_hour`, `injection_provider`, `status`) VALUES ('$pharmacyName', '$emailID', '$phoneNo', '$address', 'http://bytesnmaterials.com/healthcare/profile/profile.png', '$password', '$age', '$latitude', '$logitude', '$type', '$tokenID','1','$hour_status','0','$working_hour','0','0')";
  170. $result=mysql_query($sql);
  171. return $result;*/
  172. $postData = [
  173. 'pharmacy_name' => $pharmacyName,
  174. 'email_id' => $emailID,
  175. 'mobile_no' => $phoneNo,
  176. 'address' => $address,
  177. 'profile_pic' => "http://bytesnmaterials.com/healthcare/profile/profile.png",
  178. 'password' => $password,
  179. 'age'=> $age,
  180. 'type' => $type,
  181. 'lat' => $latitude,
  182. 'log' => $logitude,
  183. 'token' => $tokenID,
  184. 'status' => '0',
  185. 'call_status' => '1',
  186. 'hour_status' => $hour_status,
  187. 'home_delivery' => '0',
  188. 'working_hour' => $working_hour,
  189. 'injection_provider' => '0'
  190. ];
  191. $postRef = $this->conn->getReference('pharmacy')->push($postData);
  192. return $postRef;
  193. }
  194. public function check_patient_mobile_details($mobile,$email_id)
  195. {
  196. // mysql_query("set names 'utf8'");
  197. // $sql = "SELECT * FROM `patient` WHERE mobile_no = '".$mobile."'";
  198. // //echo $sql;
  199. // $result=mysql_query($sql);
  200. // return $result;
  201. $check_mobile = $this->conn->getReference('patient')
  202. ->orderByChild('mobile_no')
  203. ->equalTo($mobile);
  204. $snapshot_mobile = $check_mobile->getSnapshot();
  205. $k1 = $snapshot_mobile->getValue();
  206. $check_email = $this->conn->getReference('patient')
  207. ->orderByChild('email_id')
  208. ->equalTo($email_id);
  209. $snapshot_email = $check_email->getSnapshot();
  210. $k2 = $snapshot_email->getValue();
  211. if(!empty($k1) || !empty($k2)){
  212. $k = empty($k1)?$k2:$k1;
  213. }
  214. else{
  215. $k = [] ;
  216. }
  217. return $k;
  218. }
  219. public function insert_quick_registration($mobile_no,$emailId,$password,$latitude,$logitude,$tokenID)
  220. {
  221. // mysql_query("set character_set_server='utf8'");
  222. // mysql_query("set names 'utf8'");
  223. // $sql = "INSERT INTO `patient` (`mobile_no`, `password`, `type`, `lat`, `log`, `token`) VALUES ('$mobile_no', '$password', 'P', '$latitude', '$logitude','$tokenID')";
  224. // //echo $sql;
  225. // $result=mysql_query($sql);
  226. // return $result;
  227. $postData = [
  228. 'address' => "",
  229. 'age' => "",
  230. 'call_status' => "",
  231. 'case_desc' => "",
  232. 'patient_name' => "",
  233. 'profile_pic' => "",
  234. 'took' => "",
  235. 'email_id' => $emailId,
  236. 'age' => "",
  237. 'status' =>"",
  238. 'password' => $password,
  239. 'type' => 'P',
  240. 'lat' => $latitude,
  241. 'log' => $logitude,
  242. 'token' => $tokenID,
  243. 'patient_id' => "",
  244. 'mobile_no' => $mobile_no
  245. ];
  246. $postRef = $this->conn->getReference('patient')->push($postData);
  247. return $postRef;
  248. }
  249. public function get_doctor_details($doctorName,$emailID)
  250. {
  251. /*mysql_query("set character_set_server='utf8'");
  252. mysql_query("set names 'utf8'");
  253. $sql = "select * from doctor_signup where doctor_name = '$doctorName' and email_id = '$emailID'";
  254. $result=mysql_query($sql);
  255. return $result;*/
  256. $newPost = $this->conn->getReference('doctor_signup')
  257. ->orderByChild('email_id')
  258. ->equalTo($emailID);
  259. $snapshot_unionid = $newPost->getSnapshot();
  260. $refID = $snapshot_unionid->getValue();
  261. $getRefKey = array_keys($refID)[0];
  262. if(count($refID) == 1){
  263. $data_arr = array_values($refID);
  264. $data_arr[0]['doctor_id'] = $getRefKey;
  265. return $data_arr;
  266. }else{
  267. return [];
  268. }
  269. }
  270. public function get_patient_notification_id($patientID,$doctorID,$date,$tokenID)
  271. {
  272. mysql_query("set character_set_server='utf8'");
  273. mysql_query("set names 'utf8'");
  274. $sql = "select * from push_notification where doctor_id = '$doctorID' and patient_id = '$patientID' AND date = '$date' AND token = '$tokenID'";
  275. $result=mysql_query($sql);
  276. return $result;
  277. }
  278. public function update_patient_lat_log_api($doctorID,$lat,$log)
  279. {
  280. mysql_query("set character_set_server='utf8'");
  281. mysql_query("set names 'utf8'");
  282. $sql = "UPDATE doctor_signup SET lat = '$lat', log = '$log' WHERE doctor_id='$doctorID'";
  283. $result=mysql_query($sql);
  284. return $result;
  285. }
  286. public function get_detail_doctor($toID)
  287. {
  288. mysql_query("set character_set_server='utf8'");
  289. mysql_query("set names 'utf8'");
  290. $sql = "select * from doctor_signup where doctor_id = '$toID'";
  291. $result=mysql_query($sql);
  292. return $result;
  293. }
  294. public function check_union_id($unionID)
  295. {
  296. /*mysql_query("set character_set_server='utf8'");
  297. mysql_query("set names 'utf8'");
  298. $sql = "select * from doctor_signup where union_id = '$unionID'";
  299. $result=mysql_query($sql);
  300. return $result;*/
  301. $newPost = $this->conn->getReference('doctor_signup')
  302. ->orderByChild('union_id')
  303. ->equalTo($unionID);
  304. $snapshot_unionid = $newPost->getSnapshot();
  305. $refID = $snapshot_unionid->getValue();
  306. if(count($refID) == 1){
  307. return $refID;
  308. }else{
  309. return [];
  310. }
  311. }
  312. public function check_patient_notification($patientID,$doctorID,$status)
  313. {
  314. mysql_query("set character_set_server='utf8'");
  315. mysql_query("set names 'utf8'");
  316. $sql = "select * from push_notification_details where doctor_id = '$patientID' and patient_id = '$doctorID' and status = '$status'";
  317. $result=mysql_query($sql);
  318. return $result;
  319. }
  320. public function get_all_patient_details_app($doctorID)
  321. {
  322. mysql_query("set character_set_server='utf8'");
  323. mysql_query("set names 'utf8'");
  324. $sql = "SELECT p.* FROM `patient` as p,push_notification_details as ps WHERE ps.doctor_id = '$doctorID'";
  325. $result=mysql_query($sql);
  326. return $result;
  327. }
  328. public function get_patients_notification_details($patientID,$typeID)
  329. {
  330. mysql_query("set character_set_server='utf8'");
  331. mysql_query("set names 'utf8'");
  332. $sql = "SELECT p.*, pn.status,pn.date,pn.message,pn.id
  333. FROM push_notification AS pn, patient AS p
  334. WHERE pn.doctor_id = '$patientID'
  335. AND pn.type != '$typeID'
  336. AND pn.patient_id = p.patient_id ORDER BY pn.id DESC";
  337. $result=mysql_query($sql);
  338. return $result;
  339. }
  340. public function get_doctor_notification_details($patientID,$typeID)
  341. {
  342. mysql_query("set character_set_server='utf8'");
  343. mysql_query("set names 'utf8'");
  344. $sql = "SELECT pn.status,pn.date,pn.message,pn.id , d . *
  345. FROM `push_notification` AS pn, `doctor_signup` AS d
  346. WHERE pn.patient_id = '$patientID'
  347. AND pn.type != '$typeID'
  348. AND d.doctor_id = pn.doctor_id ORDER BY pn.id DESC";
  349. $result=mysql_query($sql);
  350. return $result;
  351. }
  352. /*-----------------------------------------NOTIFICATION---------------------------------------------------*/
  353. public function insert_token($tokenID)
  354. {
  355. mysql_query("set character_set_server='utf8'");
  356. mysql_query("set names 'utf8'");
  357. $sql = "INSERT INTO `push_notification`(`token`) VALUES ('$tokenID')";
  358. $result=mysql_query($sql);
  359. return $result;
  360. }
  361. public function gettokendetails($tokenID)
  362. {
  363. mysql_query("set character_set_server='utf8'");
  364. mysql_query("set names 'utf8'");
  365. $sql = "select * from push_notification where token = '$tokenID'";
  366. $result=mysql_query($sql);
  367. return $result;
  368. }
  369. public function get_patient_name($patientID)
  370. {
  371. mysql_query("set character_set_server='utf8'");
  372. mysql_query("set names 'utf8'");
  373. $sql = "select * from patient where patient_id = '$patientID'";
  374. $result=mysql_query($sql);
  375. return $result;
  376. }
  377. public function get_patient_name_det($patientID)
  378. {
  379. mysql_query("set character_set_server='utf8'");
  380. mysql_query("set names 'utf8'");
  381. $sql = "select patient_id as id,patient_name as name,profile_pic,type from patient where patient_id = '$patientID'";
  382. $result=mysql_query($sql);
  383. return $result;
  384. }
  385. /*--------------------------------------------------------------------------------------------------------*/
  386. public function update_doctor_profile_details($doctorID,$doctorName,$emailID,$address,$mobileNO,$file_url)
  387. {
  388. mysql_query("set character_set_server='utf8'");
  389. mysql_query("set names 'utf8'");
  390. $sql = "UPDATE `doctor_signup` SET `doctor_name`='$doctorName',`address`='$address',`mobile_no`='$mobileNO',email_id = '$emailID',`profile_pic`='$file_url' WHERE `doctor_id`='$doctorID'";
  391. $result=mysql_query($sql);
  392. return $result;
  393. }
  394. public function update_patient_profile_details($patientID,$patientName,$emailID,$mobileNO,$addressID,$file_url)
  395. {
  396. mysql_query("set character_set_server='utf8'");
  397. mysql_query("set names 'utf8'");
  398. $sql = "UPDATE `patient` SET `patient_name`='$patientName',`profile_pic`='$file_url',`email_id`='$emailID',`mobile_no`='$mobileNO',`address`='$addressID' WHERE patient_id = '$patientID'";
  399. $result=mysql_query($sql);
  400. return $result;
  401. }
  402. public function update_patient_profile($patientID,$patientName,$emailID,$mobileNO,$addressID,$array_full)
  403. {
  404. mysql_query("set character_set_server='utf8'");
  405. mysql_query("set names 'utf8'");
  406. $array_full1 = "http://bytesnmaterials.com/healthcare/profile/".$array_full;
  407. $sql = "UPDATE `patient` SET `patient_name`='$patientName',`email_id`='$emailID',`mobile_no`='$mobileNO',`address`='$addressID',`profile_pic`='$array_full1' WHERE patient_id = '$patientID'";
  408. $result=mysql_query($sql);
  409. return $result;
  410. }
  411. public function update_pharmacyd_profile($patientID,$patientName,$emailID,$mobileNO,$addressID,$array_full,$lat,$log)
  412. {
  413. if($is_24_hours_support == ""){
  414. $is_24_hours_support1 = "false";
  415. }else{
  416. $is_24_hours_support1 = $is_24_hours_support;
  417. }
  418. mysql_query("set character_set_server='utf8'");
  419. mysql_query("set names 'utf8'");
  420. $array_full1 = "http://bytesnmaterials.com/healthcare/profile/".$array_full;
  421. $sql = "UPDATE `pharmacy` SET `pharmacy_name`='$patientName',`email_id`='$emailID',`mobile_no`='$mobileNO',`address`='$addressID',`profile_pic`='$array_full1',`lat`='$lat',`log`='$log' WHERE pharmacy_id = '$patientID'";
  422. $result=mysql_query($sql);
  423. return $result;
  424. }
  425. public function update_phar_profile($patientID,$patientName,$emailID,$mobileNO,$addressID)
  426. {
  427. mysql_query("set character_set_server='utf8'");
  428. mysql_query("set names 'utf8'");
  429. $sql = "UPDATE `pharmacy` SET `pharmacy_name`='$patientName',`email_id`='$emailID',`mobile_no`='$mobileNO',`address`='$addressID' WHERE pharmacy_id = '$patientID'";
  430. $result=mysql_query($sql);
  431. return $result;
  432. }
  433. public function update_pharmacy_profile($pharmacyID,$pharmacyName,$emailID,$mobileNO,$addressID)
  434. {
  435. mysql_query("set character_set_server='utf8'");
  436. mysql_query("set names 'utf8'");
  437. $sql = "UPDATE `pharmacy` SET `pharmacy_name`='$pharmacyName',`email_id`='$emailID',`mobile_no`='$mobileNO',`address`='$addressID' WHERE pharmacy_id = '$pharmacyID'" or die(mysql_error());
  438. $result=mysql_query($sql);
  439. return $result;
  440. }
  441. public function update_doctor_profile($doctorID,$doctorName,$emailID,$feeID,$address,$mobileNO,$array_full)
  442. {
  443. mysql_query("set character_set_server='utf8'");
  444. mysql_query("set names 'utf8'");
  445. $array_full1 = "http://bytesnmaterials.com/healthcare/profile/".$array_full;
  446. $sql = "UPDATE `doctor_signup` SET `doctor_name`='$doctorName',`address`='$address',`mobile_no`='$mobileNO',`email_id`='$emailID',`profile_pic`='$array_full1',`fee`='$feeID' WHERE `doctor_id`='$doctorID'";
  447. $result=mysql_query($sql);
  448. return $result;
  449. }
  450. public function updatedoctortoken($emailID,$password,$token,$latitude,$logitude,$refID)
  451. {
  452. // mysql_query("set character_set_server='utf8'");
  453. // mysql_query("set names 'utf8'");
  454. // $sql = "UPDATE `doctor_signup` SET `device_id`='$token', lat = '$latitude', log = '$logitude', status = '1' WHERE (`email_id` = '$emailID' OR `mobile_no` = '$emailID') and password = '$password'";
  455. // $result=mysql_query($sql);
  456. // return $result;
  457. $newPost = $this->conn->getReference('doctor_signup')
  458. ->orderByChild('email_id')
  459. ->equalTo($emailID);
  460. $mobileCheck = $this->conn->getReference('doctor_signup')
  461. ->orderByChild('mobile_no')
  462. ->equalTo($emailID);
  463. $snapshot_email = $newPost->getSnapshot();
  464. $refID_email = $snapshot_email->getValue();
  465. $snapshot_mobile = $mobileCheck->getSnapshot();
  466. $refID_mobile = $snapshot_mobile->getValue();
  467. if(count($refID_email) == 1 || count($refID_mobile)==1 ){
  468. $refIDKey = empty($refID_email) ? $refID_mobile : $refID_email;
  469. $refUpdateKey = empty($refID_email) ? array_keys($refID_mobile)[0] : array_keys($refID_email)[0];
  470. $resetArray = array_values($refIDKey);
  471. if($resetArray[0]['password'] == $password){
  472. if(isset($refUpdateKey)) {
  473. $updates = [
  474. //'doctor_signup/'.$newPostKey => $postData
  475. 'doctor_signup/'.$refUpdateKey.'/device_id' => $token,
  476. 'doctor_signup/'.$refUpdateKey.'/lat' => $latitude,
  477. 'doctor_signup/'.$refUpdateKey.'/log' => $logitude,
  478. 'doctor_signup/'.$refUpdateKey.'/status' => '1',
  479. ];
  480. $res = $this->conn->getReference() // this is the root reference
  481. ->update($updates);
  482. }
  483. else{
  484. die("update key not found");
  485. }
  486. }
  487. else{
  488. die("password validation failed");
  489. }
  490. }
  491. else{
  492. die("no match");
  493. }
  494. return true;
  495. }
  496. public function updatepatienttoken($emailID,$password,$token,$latitude,$logitude)
  497. {
  498. // mysql_query("set character_set_server='utf8'");
  499. // mysql_query("set names 'utf8'");
  500. // $sql = "UPDATE `patient` SET `token`='$token', lat = '$latitude', log = '$logitude', status = '1' WHERE (`email_id` = '$emailID' OR `mobile_no` = '$emailID') and `password` = '$password'";
  501. // $result=mysql_query($sql);
  502. // return $result;
  503. $newPost = $this->conn->getReference('patient')
  504. ->orderByChild('email_id')
  505. ->equalTo($emailID);
  506. $mobileCheck = $this->conn->getReference('patient')
  507. ->orderByChild('mobile_no')
  508. ->equalTo($emailID);
  509. $snapshot_email = $newPost->getSnapshot();
  510. $refID_email = $snapshot_email->getValue();
  511. $snapshot_mobile = $mobileCheck->getSnapshot();
  512. $refID_mobile = $snapshot_mobile->getValue();
  513. if(count($refID_email) == 1 || count($refID_mobile)==1 ){
  514. $refIDKey = empty($refID_email) ? $refID_mobile : $refID_email;
  515. $refUpdateKey = empty($refID_email) ? array_keys($refID_mobile)[0] : array_keys($refID_email)[0];
  516. $resetArray = array_values($refIDKey);
  517. if($resetArray[0]['password'] == $password){
  518. if(isset($refUpdateKey)){
  519. $updates = [
  520. //'doctor_signup/'.$newPostKey => $postData
  521. 'patient/'.$refUpdateKey.'/token' => $token,
  522. 'patient/'.$refUpdateKey.'/lat' => $latitude,
  523. 'patient/'.$refUpdateKey.'/log' => $logitude,
  524. 'patient/'.$refUpdateKey.'/status' => '1'
  525. ];
  526. $res = $this->conn->getReference() // this is the root reference
  527. ->update($updates);
  528. }
  529. else{
  530. die("update key not found : updatepatienttoken ");
  531. }
  532. }
  533. else{
  534. die("password validation failed");
  535. }
  536. }
  537. else{
  538. die("no match");
  539. }
  540. return true;
  541. }
  542. public function updatepharmacytoken($emailID,$password,$token,$latitude,$logitude)
  543. {
  544. // mysql_query("set character_set_server='utf8'");
  545. // mysql_query("set names 'utf8'");
  546. // $sql = "UPDATE `pharmacy` SET `token`='$token', status = '1' WHERE (`email_id` = '$emailID' OR `mobile_no` = '$emailID') and `password` = '$password'";
  547. // $result=mysql_query($sql);
  548. // return $result;
  549. $newPost = $this->conn->getReference('pharmacy')
  550. ->orderByChild('email_id')
  551. ->equalTo($emailID);
  552. $mobileCheck = $this->conn->getReference('pharmacy')
  553. ->orderByChild('mobile_no')
  554. ->equalTo($emailID);
  555. $snapshot_email = $newPost->getSnapshot();
  556. $refID_email = $snapshot_email->getValue();
  557. $snapshot_mobile = $mobileCheck->getSnapshot();
  558. $refID_mobile = $snapshot_mobile->getValue();
  559. if(count($refID_email) == 1 || count($refID_mobile)==1 ){
  560. $refIDKey = empty($refID_email) ? $refID_mobile : $refID_email;
  561. $refUpdateKey = empty($refID_email) ? array_keys($refID_mobile)[0] : array_keys($refID_email)[0];
  562. $resetArray = array_values($refIDKey);
  563. if($resetArray[0]['password'] == $password){
  564. if(isset($refUpdateKey)) {
  565. $updates = [
  566. //'doctor_signup/'.$newPostKey => $postData
  567. 'pharmacy/'.$refUpdateKey.'/token' => $token,
  568. 'pharmacy/'.$refUpdateKey.'/lat' => $latitude,
  569. 'pharmacy/'.$refUpdateKey.'/log' => $logitude,
  570. 'pharmacy/'.$refUpdateKey.'/status' => '1'
  571. ];
  572. $res = $this->conn->getReference() // this is the root reference
  573. ->update($updates);
  574. }
  575. else{
  576. die("update key not found");
  577. }
  578. }
  579. else{
  580. die("password validation failed");
  581. }
  582. }
  583. else{
  584. die("no match");
  585. }
  586. return true;
  587. }
  588. public function getalldoctordetails()
  589. {
  590. mysql_query("set character_set_server='utf8'");
  591. mysql_query("set names 'utf8'");
  592. $sql = "select * from doctor_signup";
  593. $result=mysql_query($sql);
  594. return $result;
  595. }
  596. public function get_patient_profile_details($patientID)
  597. {
  598. mysql_query("set character_set_server='utf8'");
  599. mysql_query("set names 'utf8'");
  600. $sql = "select * from patient where patient_id = '$patientID'";
  601. $result=mysql_query($sql);
  602. return $result;
  603. }
  604. public function get_pharmacy_profile_details($pharmacyID)
  605. {
  606. mysql_query("set character_set_server='utf8'");
  607. mysql_query("set names 'utf8'");
  608. $sql = "select * from pharmacy where pharmacy_id = '$pharmacyID'";
  609. $result=mysql_query($sql);
  610. return $result;
  611. }
  612. public function getalldoctor_details()
  613. {
  614. mysql_query("set character_set_server='utf8'");
  615. mysql_query("set names 'utf8'");
  616. $sql = "select device_id from doctor_signup";
  617. $result=mysql_query($sql);
  618. return $result;
  619. }
  620. public function checknotificationdetails($patientID,$doctorID)
  621. {
  622. mysql_query("set character_set_server='utf8'");
  623. mysql_query("set names 'utf8'");
  624. $sql = "select * from push_notification where patient_id = '$patientID' and doctor_id = '$doctorID'";
  625. $result=mysql_query($sql);
  626. return $result;
  627. }
  628. public function get_doctor_profile_details($doctorID)
  629. {
  630. mysql_query("set character_set_server='utf8'");
  631. mysql_query("set names 'utf8'");
  632. $sql = "select * from doctor_signup where doctor_id = '$doctorID'";
  633. $result=mysql_query($sql);
  634. //$result3 = mysql_fetch_array($sql);
  635. // $image_old = $result3['profile_pic'];
  636. return $result;
  637. }
  638. public function patientdetail($emailID,$phoneNo,$patientName)
  639. {
  640. //mysql_query("set character_set_server='utf8'");
  641. //mysql_query("set names 'utf8'");
  642. //$sql = "select patient_id,patient_name,email_id,mobile_no,address,case_description,age,lat,log,type,token from patient where patient_name = '$patientName' and email_id = '$emailID' and mobile_no = '$phoneNo'";
  643. //$sql = "select * from patient where patient_name = '$patientName' and email_id = '$emailID' and mobile_no = '$phoneNo'";
  644. //$result=mysql_query($sql);
  645. //return $result;
  646. $mobileCheck = $this->conn->getReference('patient')
  647. ->orderByChild('email_id')
  648. ->equalTo($emailID);
  649. $snapshot_mobile = $mobileCheck->getSnapshot();
  650. $refID_mobile = $snapshot_mobile->getValue();
  651. $data_arr = array_values($refID_mobile);
  652. if(count($refID_mobile)==1 ){
  653. if($data_arr[0]['mobile_no']==$phoneNo ){
  654. $extractKey = array_keys($refID_mobile)[0];
  655. $data_arr[0]['patient_id'] = $extractKey;
  656. return $data_arr;
  657. }else{
  658. return [];
  659. }
  660. }
  661. else{
  662. return [];
  663. }
  664. }
  665. public function get_pharmacy_detail($emailID,$phoneNo,$pharmacyName)
  666. {
  667. // mysql_query("set character_set_server='utf8'");
  668. // mysql_query("set names 'utf8'");
  669. // //$sql = "select patient_id,patient_name,email_id,mobile_no,address,case_description,age,lat,log,type,token from patient where patient_name = '$patientName' and email_id = '$emailID' and mobile_no = '$phoneNo'";
  670. // $sql = "select * from pharmacy where pharmacy_name = '$pharmacyName' and email_id = '$emailID' and mobile_no = '$phoneNo'";
  671. // $result=mysql_query($sql);
  672. // return $result;
  673. $mobileCheck = $this->conn->getReference('pharmacy')
  674. ->orderByChild('email_id')
  675. ->equalTo($emailID);
  676. $snapshot_mobile = $mobileCheck->getSnapshot();
  677. $refID_mobile = $snapshot_mobile->getValue();
  678. $data_arr = array_values($refID_mobile);
  679. if(count($refID_mobile)==1 ){
  680. if($data_arr[0]['mobile_no']==$phoneNo){
  681. $extractKey = array_keys($refID_mobile)[0];
  682. $data_arr[0]['pharmacy_id'] = $extractKey;
  683. return $data_arr;
  684. }
  685. else{
  686. return [];
  687. }
  688. }
  689. else{
  690. return [];
  691. }
  692. }
  693. public function getdoctordetaildetails($emailID,$password)
  694. {
  695. // mysql_query("set character_set_server='utf8'");
  696. // mysql_query("set names 'utf8'");
  697. // $sql = "select * from doctor_signup where (email_id = '$emailID' OR mobile_no = '$emailID') and password = '$password'";
  698. // $result=mysql_query($sql);
  699. // return $result;
  700. $newPost = $this->conn->getReference('doctor_signup')
  701. ->orderByChild('email_id')
  702. ->equalTo($emailID);
  703. $mobileCheck = $this->conn->getReference('doctor_signup')
  704. ->orderByChild('mobile_no')
  705. ->equalTo($emailID);
  706. $snapshot_email = $newPost->getSnapshot();
  707. $refID_email = $snapshot_email->getValue();
  708. $snapshot_mobile = $mobileCheck->getSnapshot();
  709. $refID_mobile = $snapshot_mobile->getValue();
  710. if(count($refID_email) == 1 || count($refID_mobile)==1 ){
  711. $refIDKey = empty($refID_email) ? $refID_mobile : $refID_email;
  712. $refKeyU = array_keys($refIDKey)[0];
  713. $resetArray = array_values($refIDKey);
  714. if($resetArray[0]['password'] == $password){
  715. $resetArray[0]['doctor_id'] = $refKeyU;
  716. return $resetArray[0];
  717. }
  718. else{
  719. die("password validation failed : getdoctordetaildetails");
  720. }
  721. }
  722. else{
  723. die("no match: getdoctordetaildetails");
  724. }
  725. }
  726. public function getquickregistrationdetail($mobile_no,$password)
  727. {
  728. // mysql_query("set character_set_server='utf8'");
  729. // mysql_query("set names 'utf8'");
  730. // $sql = "select * from patient where mobile_no = '$mobile_no' and password = '$password'";
  731. // $result=mysql_query($sql);
  732. // return $result;
  733. $mobileCheck = $this->conn->getReference('patient')
  734. ->orderByChild('mobile_no')
  735. ->equalTo($mobile_no);
  736. $snapshot_mobile = $mobileCheck->getSnapshot();
  737. $refID_mobile = $snapshot_mobile->getValue();
  738. if(count($refID_mobile)==1 ){
  739. $refIDKey =$refID_mobile;
  740. $resetArray = array_values($refIDKey);
  741. if($resetArray[0]['password'] == $password){
  742. return $refIDKey;
  743. }
  744. else{
  745. die("password validation failed : getquickregistrationdetail");
  746. }
  747. }
  748. else{
  749. die("no match: getquickregistrationdetail");
  750. }
  751. }
  752. public function getpatient_details($emailID,$password)
  753. {
  754. // mysql_query("set character_set_server='utf8'");
  755. // mysql_query("set names 'utf8'");
  756. // $sql = "select * from patient where (email_id = '$emailID' OR mobile_no = '$emailID') and password = '$password'";
  757. // $result=mysql_query($sql);
  758. // return $result;
  759. $newPost = $this->conn->getReference('patient')
  760. ->orderByChild('email_id')
  761. ->equalTo($emailID);
  762. $mobileCheck = $this->conn->getReference('patient')
  763. ->orderByChild('mobile_no')
  764. ->equalTo($emailID);
  765. $snapshot_email = $newPost->getSnapshot();
  766. $refID_email = $snapshot_email->getValue();
  767. $snapshot_mobile = $mobileCheck->getSnapshot();
  768. $refID_mobile = $snapshot_mobile->getValue();
  769. if(count($refID_email) == 1 || count($refID_mobile)==1 ){
  770. $refIDKey = empty($refID_email) ? $refID_mobile : $refID_email;
  771. $refKeyU = array_keys($refIDKey)[0];
  772. $resetArray = array_values($refIDKey);
  773. if($resetArray[0]['password'] == $password){
  774. $resetArray[0]['patient_id'] = $refKeyU;
  775. return $resetArray[0];
  776. }
  777. else{
  778. die("password validation failed : getpatient_details");
  779. }
  780. }
  781. else{
  782. die("no match: getpatient_details");
  783. }
  784. }
  785. public function getpharmacy_details($emailID,$password)
  786. {
  787. // mysql_query("set character_set_server='utf8'");
  788. // mysql_query("set names 'utf8'");
  789. // $sql = "select * from pharmacy where (email_id = '$emailID' OR mobile_no = '$emailID') and password = '$password'";
  790. // $result=mysql_query($sql);
  791. // return $result;
  792. $newPost = $this->conn->getReference('pharmacy')
  793. ->orderByChild('email_id')
  794. ->equalTo($emailID);
  795. $mobileCheck = $this->conn->getReference('pharmacy')
  796. ->orderByChild('mobile_no')
  797. ->equalTo($emailID);
  798. $snapshot_email = $newPost->getSnapshot();
  799. $refID_email = $snapshot_email->getValue();
  800. $snapshot_mobile = $mobileCheck->getSnapshot();
  801. $refID_mobile = $snapshot_mobile->getValue();
  802. if(count($refID_email) == 1 || count($refID_mobile)==1 ){
  803. $refIDKey = empty($refID_email) ? $refID_mobile : $refID_email;
  804. $refKeyU = array_keys($refIDKey)[0];
  805. $resetArray = array_values($refIDKey);
  806. if($resetArray[0]['password'] == $password){
  807. $resetArray[0]['pharmacy_id'] = $refKeyU;
  808. return $resetArray[0];
  809. }
  810. else{
  811. die("password validation failed : getpharmacy_details");
  812. }
  813. }
  814. else{
  815. die("no match: getpharmacy_details");
  816. }
  817. }
  818. public function get_patient_details($doctorID)
  819. {
  820. mysql_query("set character_set_server='utf8'");
  821. mysql_query("set names 'utf8'");
  822. $sql = "select pa.*,p.*, pa.status as TookStatus from patient_took as pa,patient as p where pa.doctor_id = '$doctorID' and p.patient_id=pa.patient_id and pa.status != 0";
  823. $result=mysql_query($sql);
  824. return $result;
  825. }
  826. public function getMyHistory($doctorID)
  827. {
  828. mysql_query("set character_set_server='utf8'");
  829. mysql_query("set names 'utf8'");
  830. $sql = "select pa.*,p.*, pa.status as TookStatus from patient_took as pa,doctor_signup as p where pa.time >= DATE_SUB(CURDATE(), INTERVAL 7 DAY) AND pa.patient_id = '$doctorID' and p.doctor_id=pa.doctor_id";
  831. $result=mysql_query($sql);
  832. return $result;
  833. }
  834. public function getpatientdetailsa($patientID)
  835. {
  836. mysql_query("set character_set_server='utf8'");
  837. mysql_query("set names 'utf8'");
  838. $sql = "select * from patient where patient_id = '$patientID'";
  839. $result=mysql_query($sql);
  840. return $result;
  841. }
  842. public function check_login_details($email,$password,$type)
  843. {
  844. $newPost = $this->conn->getReference('healthcare_login')
  845. ->orderByChild('email_id')
  846. ->equalTo($email);
  847. $mobileCheck = $this->conn->getReference('healthcare_login')
  848. ->orderByChild('mobile_no')
  849. ->equalTo($email);
  850. $snapshot_email = $newPost->getSnapshot();
  851. $refID_email = $snapshot_email->getValue();
  852. $snapshot_mobile = $mobileCheck->getSnapshot();
  853. $refID_mobile = $snapshot_mobile->getValue();
  854. if(count($refID_email) > 0 || count($refID_mobile) > 0 ){
  855. $refIDKey = empty($refID_email) ? $refID_mobile : $refID_email;
  856. $filteredItems = array_filter( $refIDKey, function($item) use($password,$type){
  857. return $item['password']==$password && $item['type']==$type;
  858. });
  859. if(!empty($filteredItems) && count($filteredItems)==1){
  860. //login true
  861. return $filteredItems;
  862. }
  863. else{
  864. return [];
  865. }
  866. }
  867. else{
  868. return [];
  869. }
  870. }
  871. public function checkemaildetails($email)
  872. {
  873. /*mysql_query("set character_set_server='utf8'");
  874. mysql_query("set names 'utf8'");
  875. $sql = "select * from healthcare_login where email_id = '$emailID'";
  876. $result=mysql_query($sql);
  877. return $result;*/
  878. $newPost = $this->conn->getReference('healthcare_login')
  879. ->orderByChild('email_id')
  880. ->equalTo($email);
  881. $snapshot_email = $newPost->getSnapshot();
  882. $refID_email = $snapshot_email->getValue();
  883. if(count($refID_email) == 1){
  884. return $refID_email;
  885. }
  886. else{
  887. return [];
  888. }
  889. }
  890. public function check_mobile_no_s($mobileNo)
  891. {
  892. /*mysql_query("set character_set_server='utf8'");
  893. mysql_query("set names 'utf8'");
  894. $sql = "select * from healthcare_login where mobile_no = '$mobileNo'";
  895. $result=mysql_query($sql);
  896. return $result;*/
  897. $mobileCheck = $this->conn->getReference('healthcare_login')
  898. ->orderByChild('mobile_no')
  899. ->equalTo($mobileNo);
  900. $snapshot_mobile = $mobileCheck->getSnapshot();
  901. $refID_mobile = $snapshot_mobile->getValue();
  902. if(count($refID_mobile) == 1){
  903. return $refID_mobile;
  904. }
  905. else{
  906. return [];
  907. }
  908. }
  909. public function insert_login($dID,$emailID,$mobileNo,$passwordD,$type)
  910. {
  911. /*mysql_query("set character_set_server='utf8'");
  912. mysql_query("set names 'utf8'");
  913. $sql = "INSERT INTO `healthcare_login`(`id`,`email_id`, `mobile_no`, `password`, `type`) VALUES
  914. ('$dID','$emailID','$mobileNo','$passwordD','D')";
  915. $result=mysql_query($sql);
  916. return $result;*/
  917. $postData = [
  918. 'id' => $dID,
  919. 'email_id' => $emailID,
  920. 'mobile_no' => $mobileNo,
  921. 'password' => $passwordD,
  922. 'type' => 'D'
  923. ];
  924. $postRef = $this->conn->getReference('healthcare_login')->push($postData);
  925. return $postRef;
  926. }
  927. public function quick_health_registration($mobileNo,$emailId,$password,$id)
  928. {
  929. // mysql_query("set character_set_server='utf8'");
  930. // mysql_query("set names 'utf8'");
  931. // $sql = "INSERT INTO `healthcare_login`(`mobile_no`, `password`, `type`) VALUES ('$mobileNo','$passwordD','P')";
  932. // $result=mysql_query($sql);
  933. // return $result;
  934. $postData = [
  935. 'password' => $password,
  936. 'type' => 'P',
  937. 'mobile_no' => $mobileNo,
  938. 'login_id' => "",
  939. 'id' => $id,
  940. 'email_id' => $emailId
  941. ];
  942. $postRef = $this->conn->getReference('healthcare_login')->push($postData);
  943. return $postRef;
  944. }
  945. public function insert_p_login($pID,$emailID,$mobile_no,$passwordD)
  946. {
  947. /*mysql_query("set character_set_server='utf8'");
  948. mysql_query("set names 'utf8'");
  949. $sql = "INSERT INTO `healthcare_login`(`id`,`email_id`,`mobile_no`, `password`, `type`) VALUES ('$pID','$emailID','$mobile_no','$passwordD','P')";
  950. $result=mysql_query($sql);
  951. return $result;*/
  952. $postData = [
  953. 'id' => $pID,
  954. 'email_id' => $emailID,
  955. 'mobile_no' => $mobile_no,
  956. 'password' => $passwordD,
  957. 'type' => 'p'
  958. ];
  959. $postRef = $this->conn->getReference('healthcare_login')->push($postData);
  960. return $postRef;
  961. }
  962. public function insert_pharmacy_login($p_ID,$emailID,$mobile_no,$passwordD)
  963. {
  964. /*mysql_query("set character_set_server='utf8'");
  965. mysql_query("set names 'utf8'");
  966. $sql = "INSERT INTO `healthcare_login`(`id`,`email_id`,`mobile_no`, `password`, `type`) VALUES ('$p_ID','$emailID','$mobile_no','$passwordD','F')";
  967. $result=mysql_query($sql);
  968. return $result;*/
  969. $postData = [
  970. 'id' => $p_ID,
  971. 'email_id' => $emailID,
  972. 'mobile_no' => $mobile_no,
  973. 'password' => $passwordD,
  974. 'type' => 'F'
  975. ];
  976. $postRef = $this->conn->getReference('healthcare_login')->push($postData);
  977. return $postRef;
  978. }
  979. public function update_status_detail($doctorID,$paymentID)
  980. {
  981. mysql_query("set character_set_server='utf8'");
  982. mysql_query("set names 'utf8'");
  983. $sql = "UPDATE `doctor_signup` SET `payment_id`= '$paymentID',`status`= 1 WHERE `doctor_id`='$doctorID'";
  984. $result=mysql_query($sql);
  985. return $result;
  986. }
  987. public function checkemailid($emailID)
  988. {
  989. /*mysql_query("set character_set_server='utf8'");
  990. mysql_query("set names 'utf8'");
  991. $sql = "select * from doctor_signup where email_id = '$emailID'";
  992. $result=mysql_query($sql);
  993. return $result;*/
  994. $newPost = $this->conn->getReference('doctor_signup')
  995. ->orderByChild('email_id')
  996. ->equalTo($emailID);
  997. $snapshot_emailID = $newPost->getSnapshot();
  998. $refID = $snapshot_emailID->getValue();
  999. if(count($refID) == 1){
  1000. return $refID;
  1001. }else{
  1002. return [];
  1003. }
  1004. }
  1005. public function check_patient_mobile_no($emailID,$phoneNo)
  1006. {
  1007. mysql_query("set character_set_server='utf8'");
  1008. mysql_query("set names 'utf8'");
  1009. $sql = "select * from patient where email_id = '$emailID' OR mobile_no = '$phoneNo'";
  1010. $result=mysql_query($sql);
  1011. return $result;
  1012. }
  1013. public function check_doctor_ID($doctorID)
  1014. {
  1015. mysql_query("set character_set_server='utf8'");
  1016. mysql_query("set names 'utf8'");
  1017. $sql = "select * from doctor_signup where doctor_id = '$doctorID'";
  1018. $result=mysql_query($sql);
  1019. return $result;
  1020. }
  1021. /*------------------------------------------Chat-------------------------------------------------*/
  1022. public function get_type_details($id)
  1023. {
  1024. mysql_query("set character_set_server='utf8'");
  1025. mysql_query("set names 'utf8'");
  1026. //$sql = "select * from push_notification_details where doctor_id = '$id' and status = '1'";
  1027. $sql = "select * from chat_message where from_id = '$id' OR to_id = '$id' and type = 'D' Group By to_id";
  1028. $result=mysql_query($sql);
  1029. return $result;
  1030. }
  1031. public function get_last_message_date($fromID,$toID,$type)
  1032. {
  1033. mysql_query("set character_set_server='utf8'");
  1034. mysql_query("set names 'utf8'");
  1035. $sql = "select * from chat_message where to_id = '$toID' and from_id = '$fromID' and type = '$type' ORDER BY chatmsg_id DESC LIMIT 1";
  1036. $result=mysql_query($sql);
  1037. return $result;
  1038. }
  1039. public function get_farmacy_last_message_date($fromID,$toid,$type)
  1040. {
  1041. mysql_query("set character_set_server='utf8'");
  1042. mysql_query("set names 'utf8'");
  1043. $sql = "select * from chat_message where to_id = '$toid' and from_id = '$fromID' and type = '$type' ORDER BY chatmsg_id DESC LIMIT 1";
  1044. $result=mysql_query($sql);
  1045. return $result;
  1046. }
  1047. public function get_farmacy_p_last_message_date($fromID,$toid,$type)
  1048. {
  1049. mysql_query("set character_set_server='utf8'");
  1050. mysql_query("set names 'utf8'");
  1051. $sql = "select * from chat_message where to_id = '$toid' and from_id = '$fromID' and type = '$type' ORDER BY chatmsg_id DESC LIMIT 1";
  1052. $result=mysql_query($sql);
  1053. return $result;
  1054. }
  1055. public function get_chat_patient_details($id,$type)
  1056. {
  1057. mysql_query("set character_set_server='utf8'");
  1058. mysql_query("set names 'utf8'");
  1059. $sql = "select from_id,to_id from chat_message where (from_id = '$id' AND type = 'D') OR (to_id = '$id' AND type = 'P') GROUP BY from_id";
  1060. $result=mysql_query($sql);
  1061. $PatToID = array();
  1062. $PatFromID = array();
  1063. $sqlT = "select DISTINCT to_id from chat_message where (from_id = '$id' AND type = 'D')";
  1064. $qryT=mysql_query($sqlT);
  1065. while($resultT=mysql_fetch_assoc($qryT)) {
  1066. $PatToID[] = $resultT['to_id'];
  1067. }
  1068. $sqlF = "select DISTINCT from_id from chat_message where (to_id = '$id' AND type = 'P')";
  1069. $qryF=mysql_query($sqlF);
  1070. while($resultF=mysql_fetch_assoc($qryF)) {
  1071. $PatFromID[] = $resultF['from_id'];
  1072. }
  1073. $array_merge_patients = array_merge($PatToID, $PatFromID);
  1074. $Newpatients = array_unique($array_merge_patients);
  1075. $all_chat_patients = array_values($Newpatients);
  1076. /*echo "<pre>";
  1077. print_r($all_chat_patients);
  1078. echo "</pre>";*/
  1079. return $all_chat_patients;
  1080. }
  1081. public function get_chat_pharmacy_details($id,$type)
  1082. {
  1083. mysql_query("set character_set_server='utf8'");
  1084. mysql_query("set names 'utf8'");
  1085. $sql = "select from_id,to_id from chat_message where to_id = '$id' AND (type = 'DF' OR type = 'FD') GROUP BY from_id";
  1086. $result=mysql_query($sql);
  1087. $PhRToID = array();
  1088. $PhRFromID = array();
  1089. $sqlT = "select DISTINCT to_id from chat_message where (from_id = '$id' AND type = 'DF')";
  1090. $qryT=mysql_query($sqlT);
  1091. while($resultT=mysql_fetch_assoc($qryT)) {
  1092. $PhRToID[] = $resultT['to_id'];
  1093. }
  1094. $sqlF = "select DISTINCT from_id from chat_message where (to_id = '$id' AND type = 'FD')";
  1095. $qryF=mysql_query($sqlF);
  1096. while($resultF=mysql_fetch_assoc($qryF)) {
  1097. $PhRFromID[] = $resultF['from_id'];
  1098. }
  1099. $array_merge_pharmcy = array_merge($PhRToID, $PhRFromID);
  1100. $Newpharmcy = array_unique($array_merge_pharmcy);
  1101. $all_chat_pharmcy = array_values($Newpharmcy);
  1102. return $all_chat_pharmcy;
  1103. //return $all_chat_pharmcy;
  1104. }
  1105. public function get_chat_pharmacy_patient_details($id,$type)
  1106. {
  1107. mysql_query("set character_set_server='utf8'");
  1108. mysql_query("set names 'utf8'");
  1109. /*$sql = "select from_id,to_id from chat_message where from_id = '$id' AND (type = 'FP' OR type = 'PF') GROUP BY to_id";
  1110. $result=mysql_query($sql);*/
  1111. $PhRToID = array();
  1112. $PhRFromID = array();
  1113. $sqlT = "select DISTINCT to_id from chat_message where (from_id = '$id' AND type = 'PF')";
  1114. $qryT=mysql_query($sqlT);
  1115. while($resultT=mysql_fetch_assoc($qryT)) {
  1116. $PhRToID[] = $resultT['to_id'];
  1117. }
  1118. $sqlF = "select DISTINCT from_id from chat_message where (to_id = '$id' AND type = 'FP')";
  1119. $qryF=mysql_query($sqlF);
  1120. while($resultF=mysql_fetch_assoc($qryF)) {
  1121. $PhRFromID[] = $resultF['from_id'];
  1122. }
  1123. $array_merge_pharmcy = array_merge($PhRToID, $PhRFromID);
  1124. $Newpharmcy = array_unique($array_merge_pharmcy);
  1125. $all_chat_pharmcy = array_values($Newpharmcy);
  1126. return $all_chat_pharmcy;
  1127. }
  1128. public function get_patient_id_chat($id,$type)
  1129. {
  1130. mysql_query("set character_set_server='utf8'");
  1131. mysql_query("set names 'utf8'");
  1132. /*$sql = "select from_id,to_id from chat_message where (from_id = '$id' AND type = 'FP') OR (to_id = '$id' AND type = 'PF') GROUP BY from_id";
  1133. $result=mysql_query($sql);*/
  1134. $PatToID = array();
  1135. $PatFromID = array();
  1136. $sqlT = "select DISTINCT to_id from chat_message where (from_id = '$id' AND type = 'FP')";
  1137. $qryT=mysql_query($sqlT);
  1138. while($resultT=mysql_fetch_assoc($qryT)) {
  1139. $PatToID[] = $resultT['to_id'];
  1140. }
  1141. $sqlF = "select DISTINCT from_id from chat_message where (to_id = '$id' AND type = 'PF')";
  1142. $qryF=mysql_query($sqlF);
  1143. while($resultF=mysql_fetch_assoc($qryF)) {
  1144. $PatFromID[] = $resultF['from_id'];
  1145. }
  1146. $array_merge_patients = array_merge($PatToID, $PatFromID);
  1147. $Newpatients = array_unique($array_merge_patients);
  1148. $all_chat_patients = array_values($Newpatients);
  1149. return $all_chat_patients;
  1150. }
  1151. public function get_doctor_id_chat($id,$type)
  1152. {
  1153. mysql_query("set character_set_server='utf8'");
  1154. mysql_query("set names 'utf8'");
  1155. /*$sql = "select from_id,to_id from chat_message where (from_id = '$id' AND type = 'FD') OR (to_id = '$id' AND type = 'DF') GROUP BY to_id";
  1156. $result=mysql_query($sql);*/
  1157. $DcoToID = array();
  1158. $DocFromID = array();
  1159. $sqlT = "select DISTINCT to_id from chat_message where (from_id = '$id' AND type = 'FD')";
  1160. $qryT=mysql_query($sqlT);
  1161. while($resultT=mysql_fetch_assoc($qryT)) {
  1162. $DcoToID[] = $resultT['to_id'];
  1163. }
  1164. $sqlF = "select DISTINCT from_id from chat_message where (to_id = '$id' AND type = 'DF')";
  1165. $qryF=mysql_query($sqlF);
  1166. while($resultF=mysql_fetch_assoc($qryF)) {
  1167. $DocFromID[] = $resultF['from_id'];
  1168. }
  1169. $array_merge_doctors = array_merge($DcoToID, $DocFromID);
  1170. $Newdoctors= array_unique($array_merge_doctors);
  1171. $all_chat_doctors = array_values($Newdoctors);
  1172. return $all_chat_doctors;
  1173. }
  1174. public function get_pharmacy_det_id()
  1175. {
  1176. mysql_query("set character_set_server='utf8'");
  1177. mysql_query("set names 'utf8'");
  1178. $sql = "select * from pharmacy";
  1179. $result=mysql_query($sql);
  1180. return $result;
  1181. }
  1182. public function get_chat_doctor_chatlist($id)
  1183. {
  1184. mysql_query("set character_set_server='utf8'");
  1185. mysql_query("set names 'utf8'");
  1186. $sql = "SELECT from_id,to_id
  1187. FROM `chat_message`
  1188. WHERE (from_id = '$id'
  1189. OR to_id = '$id') AND type='DD'
  1190. GROUP BY (
  1191. to_id
  1192. AND from_id
  1193. )";
  1194. $result=mysql_query($sql);
  1195. return $result;
  1196. }
  1197. public function get_chat_doctor_details($id,$type)
  1198. {
  1199. mysql_query("set character_set_server='utf8'");
  1200. mysql_query("set names 'utf8'");
  1201. /*$sql = "select * from chat_message where from_id = '$id' AND type = '$type' GROUP BY to_id";
  1202. $result=mysql_query($sql);*/
  1203. $DocToID = array();
  1204. $DocFromID = array();
  1205. $sqlT = "select DISTINCT to_id from chat_message where (from_id = '$id' AND type = 'P')";
  1206. $qryT=mysql_query($sqlT);
  1207. while($resultT=mysql_fetch_assoc($qryT)) {
  1208. $DocToID[] = $resultT['to_id'];
  1209. }
  1210. $sqlF = "select DISTINCT from_id from chat_message where (to_id = '$id' AND type = 'D')";
  1211. $qryF=mysql_query($sqlF);
  1212. while($resultF=mysql_fetch_assoc($qryF)) {
  1213. $DocFromID[] = $resultF['from_id'];
  1214. }
  1215. $array_merge_doctor = array_merge($DocToID, $DocFromID);
  1216. $Newdoctor = array_unique($array_merge_doctor);
  1217. $all_chat_doctor = array_values($Newdoctor);
  1218. return $all_chat_doctor;
  1219. }
  1220. public function get_doctor_requst_details($id)
  1221. {
  1222. mysql_query("set character_set_server='utf8'");
  1223. mysql_query("set names 'utf8'");
  1224. $sql = "select * from push_notification_details where patient_id = '$id'";
  1225. //echo $sql;
  1226. //$sql = "select * from chat_message where from_id = '$id' OR to_id = '$id' and type = 'D' GROUP BY from_id OR to_id";
  1227. //echo $sql;
  1228. $result=mysql_query($sql);
  1229. return $result;
  1230. }
  1231. public function getpatientdetails($pID)
  1232. {
  1233. mysql_query("set character_set_server='utf8'");
  1234. mysql_query("set names 'utf8'");
  1235. $sql = "select patient_id as id,patient_name as name,profile_pic,type from patient where patient_id = '$pID'";
  1236. //echo $sql;
  1237. //$sql = "select patient_id as id,patient_name as name,profile_pic,type from patient";
  1238. $result=mysql_query($sql);
  1239. return $result;
  1240. }
  1241. public function getdoctor_details($pID)
  1242. {
  1243. mysql_query("set character_set_server='utf8'");
  1244. mysql_query("set names 'utf8'");
  1245. $sql = "select doctor_id as id,doctor_name as name,profile_pic,type from doctor_signup where doctor_id = '$pID'";
  1246. $result=mysql_query($sql);
  1247. return $result;
  1248. }
  1249. public function get_doctor_detailrow($doctorID)
  1250. {
  1251. mysql_query("set character_set_server='utf8'");
  1252. mysql_query("set names 'utf8'");
  1253. $sql = "select doctor_id as id,doctor_name as name,profile_pic,type from doctor_signup where doctor_id = '$doctorID'";
  1254. $result=mysql_query($sql);
  1255. return $result;
  1256. }
  1257. public function get_detail_patient($fromID)
  1258. {
  1259. mysql_query("set character_set_server='utf8'");
  1260. mysql_query("set names 'utf8'");
  1261. $sql = "select * from patient where patient_id = '$fromID'";
  1262. $result=mysql_query($sql);
  1263. return $result;
  1264. }
  1265. public function getmessaged($id,$pID)
  1266. {
  1267. mysql_query("set character_set_server='utf8'");
  1268. mysql_query("set names 'utf8'");
  1269. //$sql = "SELECT chatmsg_id,message,status,date,message_type FROM chat_message WHERE (from_id = '$id' AND to_id = '$pID') OR (from_id = '$pID' AND to_id = '$id') ORDER BY chatmsg_id DESC LIMIT 1";
  1270. $sql = "SELECT * FROM chat_message WHERE (from_id = '$id' AND to_id = '$pID' AND type = 'D') OR (from_id = '$pID' AND to_id = '$id' AND type = 'P') ORDER BY chatmsg_id DESC LIMIT 1";
  1271. //echo $sql;
  1272. $result=mysql_query($sql);
  1273. return $result;
  1274. }
  1275. public function getDmessaged($id,$pID)
  1276. {
  1277. mysql_query("set character_set_server='utf8'");
  1278. mysql_query("set names 'utf8'");
  1279. //$sql = "SELECT chatmsg_id,message,status,date,message_type FROM chat_message WHERE (from_id = '$id' AND to_id = '$pID') OR (from_id = '$pID' AND to_id = '$id') ORDER BY chatmsg_id DESC LIMIT 1";
  1280. $sql = "SELECT * FROM chat_message WHERE (from_id = '$id' AND to_id = '$pID' AND type = 'P') OR (from_id = '$pID' AND to_id = '$id' AND type = 'D') ORDER BY chatmsg_id DESC LIMIT 1";
  1281. $result=mysql_query($sql);
  1282. return $result;
  1283. }
  1284. public function getpharmacymessaged($id,$fID)
  1285. {
  1286. mysql_query("set character_set_server='utf8'");
  1287. mysql_query("set names 'utf8'");
  1288. //$sql = "SELECT chatmsg_id,message,status,date,message_type FROM chat_message WHERE (from_id = '$id' AND to_id = '$pID') OR (from_id = '$pID' AND to_id = '$id') ORDER BY chatmsg_id DESC LIMIT 1";
  1289. $sql = "SELECT * FROM chat_message WHERE (from_id = '$id' AND to_id = '$fID' AND type = 'DF') OR (from_id = '$fID' AND to_id = '$id' AND type = 'FD') ORDER BY chatmsg_id DESC LIMIT 1";
  1290. $result=mysql_query($sql);
  1291. return $result;
  1292. }
  1293. public function getpharmacypatientmessaged($id,$fID)
  1294. {
  1295. mysql_query("set character_set_server='utf8'");
  1296. mysql_query("set names 'utf8'");
  1297. $sql = "SELECT * FROM chat_message WHERE (from_id = '$id' AND to_id = '$fID' AND type = 'PF') OR (from_id = '$fID' AND to_id = '$id' AND type = 'FP') ORDER BY chatmsg_id DESC LIMIT 1";
  1298. $result=mysql_query($sql);
  1299. return $result;
  1300. }
  1301. public function getpharmacypatientmessaged1($id,$fID)
  1302. {
  1303. mysql_query("set character_set_server='utf8'");
  1304. mysql_query("set names 'utf8'");
  1305. $sql = "SELECT * FROM chat_message WHERE (from_id = '$id' AND to_id = '$fID' AND type = 'FP') OR (from_id = '$fID' AND to_id = '$id' AND type = 'PF') ORDER BY chatmsg_id DESC LIMIT 1";
  1306. $result=mysql_query($sql);
  1307. return $result;
  1308. }
  1309. public function getpharmacydoctormessaged($id,$fID)
  1310. {
  1311. mysql_query("set character_set_server='utf8'");
  1312. mysql_query("set names 'utf8'");
  1313. $sql = "SELECT * FROM chat_message WHERE (from_id = '$id' AND to_id = '$fID' AND type = 'FD') OR (from_id = '$fID' AND to_id = '$id' AND type = 'DF') ORDER BY chatmsg_id DESC LIMIT 1";
  1314. $result=mysql_query($sql);
  1315. return $result;
  1316. }
  1317. public function getpharmacydmessaged($id,$fID)
  1318. {
  1319. mysql_query("set character_set_server='utf8'");
  1320. mysql_query("set names 'utf8'");
  1321. $sql = "SELECT * FROM chat_message WHERE (from_id = '$id' AND to_id = '$fID' AND type = 'FF') OR (from_id = '$fID' AND to_id = '$id' AND type = 'FF') ORDER BY chatmsg_id DESC LIMIT 1";
  1322. $result=mysql_query($sql);
  1323. return $result;
  1324. }
  1325. public function insert_message($fromID,$toID,$message,$type,$mtype)
  1326. {
  1327. mysql_query("set character_set_server='utf8'");
  1328. mysql_query("set names 'utf8'");
  1329. $sql = "INSERT INTO `chat_message`(`from_id`, `to_id`, `message`, `status`, `type`, `message_type`,`read_status`) VALUES ('$fromID','$toID','$message','0','$type','$mtype','0')";
  1330. $result=mysql_query($sql);
  1331. return $result;
  1332. }
  1333. public function insert_invite_doctor_chat($doctorID,$member_ID,$messageID)
  1334. {
  1335. mysql_query("set character_set_server='utf8'");
  1336. mysql_query("set names 'utf8'");
  1337. $sql = "INSERT INTO `chat_message`(`from_id`, `to_id`, `message`, `status`, `type`, `message_type`,`read_status`) VALUES ('$doctorID','$member_ID','$messageID','0','DD','text','0')";
  1338. $result=mysql_query($sql);
  1339. return $result;
  1340. }public function insert_case_description($patientID,$doctorID,$caseD,$date,$type,$status, $FirstLat = '', $FirstLan = '')
  1341. {
  1342. mysql_query("set character_set_server='utf8'");
  1343. mysql_query("set names 'utf8'");
  1344. $sql = "INSERT INTO `chat_message`(`from_id`, `to_id`, `message`, `status`, `type`, `message_type`,`read_status`, `first_lat`, `first_lang`) VALUES ('$patientID','$doctorID','$caseD','0','P','p_text','0', '$FirstLat', '$FirstLan')";
  1345. $result=mysql_query($sql);
  1346. return $result;
  1347. }
  1348. public function upload_image($fromID,$toID,$file_url,$type,$mtype)
  1349. {
  1350. mysql_query("set character_set_server='utf8'");
  1351. mysql_query("set names 'utf8'");
  1352. $sql = "INSERT INTO `chat_message`(`from_id`, `to_id`, `message`, `status`, `type`,`read_status`, `message_type`) VALUES ('$fromID','$toID','$file_url','0','$type','0','$mtype')"; //echo $sql;
  1353. $result=mysql_query($sql);
  1354. return $result;
  1355. }
  1356. public function upload_image_group($fromID,$toID,$file_url,$type,$mtype)
  1357. {
  1358. mysql_query("set character_set_server='utf8'");
  1359. mysql_query("set names 'utf8'");
  1360. $sql = "INSERT INTO `group_chat`(`member_id`, `group_id`, `message`, `message_type`, `read_status`, `type`) VALUES ('$fromID','$toID','$file_url','$mtype','0','$type')"; //echo $sql;
  1361. $result=mysql_query($sql);
  1362. return $result;
  1363. }
  1364. public function update_read_message_status($fromID,$toID)
  1365. {
  1366. mysql_query("set character_set_server='utf8'");
  1367. mysql_query("set names 'utf8'");
  1368. $sql = "UPDATE `chat_message` SET `read_status`='1' WHERE ((`from_id` = '$fromID' AND `to_id` = '$toID') OR (`from_id` = '$toID' AND `to_id` = '$fromID')) AND (type = 'P' OR type = 'D')";
  1369. $result=mysql_query($sql);
  1370. return $result;
  1371. }
  1372. public function update_read_message_from_pharmacy($fromID,$toID)
  1373. {
  1374. mysql_query("set character_set_server='utf8'");
  1375. mysql_query("set names 'utf8'");
  1376. $sql = "UPDATE `chat_message` SET `read_status`='1' WHERE ((`from_id` = '$fromID' AND `to_id` = '$toID') OR (`from_id` = '$toID' AND `to_id` = '$fromID')) AND type = 'FP'";
  1377. $result=mysql_query($sql);
  1378. return $result;
  1379. }
  1380. public function update_read_message_far_patient_from_pharmacy($fromID,$toID)
  1381. {
  1382. mysql_query("set character_set_server='utf8'");
  1383. mysql_query("set names 'utf8'");
  1384. $sql = "UPDATE `chat_message` SET `read_status`='1' WHERE ((`from_id` = '$fromID' AND `to_id` = '$toID') OR (`from_id` = '$toID' AND `to_id` = '$fromID')) AND type = 'PF'";
  1385. $result=mysql_query($sql);
  1386. return $result;
  1387. }
  1388. public function update_read_message_far_doc_from_pharmacy($fromID,$toID)
  1389. {
  1390. mysql_query("set character_set_server='utf8'");
  1391. mysql_query("set names 'utf8'");
  1392. $sql = "UPDATE `chat_message` SET `read_status`='1' WHERE ((`from_id` = '$fromID' AND `to_id` = '$toID') OR (`from_id` = '$toID' AND `to_id` = '$fromID')) AND type = 'DF'";
  1393. $result=mysql_query($sql);
  1394. return $result;
  1395. }
  1396. public function update_read_message_phar_to_phar($fromID,$toID)
  1397. {
  1398. mysql_query("set character_set_server='utf8'");
  1399. mysql_query("set names 'utf8'");
  1400. $sql = "UPDATE `chat_message` SET `read_status`='1' WHERE (`from_id` = '$toID' AND `to_id` = '$fromID') AND type = 'FF'";
  1401. $result=mysql_query($sql);
  1402. return $result;
  1403. }
  1404. public function update_read_message_from_doc_pharmacy($fromID,$toID)
  1405. {
  1406. mysql_query("set character_set_server='utf8'");
  1407. mysql_query("set names 'utf8'");
  1408. $sql = "UPDATE `chat_message` SET `read_status`='1' WHERE ((`from_id` = '$fromID' AND `to_id` = '$toID') OR (`from_id` = '$toID' AND `to_id` = '$fromID')) AND type = 'FD'";
  1409. $result=mysql_query($sql);
  1410. return $result;
  1411. }
  1412. public function update_read_patientd_message_from_pharmacy($fromID,$toID)
  1413. {
  1414. mysql_query("set character_set_server='utf8'");
  1415. mysql_query("set names 'utf8'");
  1416. $sql = "UPDATE `chat_message` SET `read_status`='1' WHERE ((`from_id` = '$fromID' AND `to_id` = '$toID') OR (`from_id` = '$toID' AND `to_id` = '$fromID')) AND type = 'PF'";
  1417. $result=mysql_query($sql);
  1418. return $result;
  1419. }
  1420. public function update_read_docmessage_from_pharmacy($fromID,$toID)
  1421. {
  1422. mysql_query("set character_set_server='utf8'");
  1423. mysql_query("set names 'utf8'");
  1424. $sql = "UPDATE `chat_message` SET `read_status`='1' WHERE ((`from_id` = '$fromID' AND `to_id` = '$toID') OR (`from_id` = '$toID' AND `to_id` = '$fromID')) AND type = 'DF'";
  1425. $result=mysql_query($sql);
  1426. return $result;
  1427. }
  1428. public function update_read_messageFF_from_pharmacy($fromID,$toID)
  1429. {
  1430. mysql_query("set character_set_server='utf8'");
  1431. mysql_query("set names 'utf8'");
  1432. $sql = "UPDATE `chat_message` SET `read_status`='1' WHERE ((`from_id` = '$fromID' AND `to_id` = '$toID') OR (`from_id` = '$toID' AND `to_id` = '$fromID')) AND type = 'FD'";
  1433. $result=mysql_query($sql);
  1434. return $result;
  1435. }
  1436. public function update_read_messagefp_from_pharmacy($fromID,$toID)
  1437. {
  1438. mysql_query("set character_set_server='utf8'");
  1439. mysql_query("set names 'utf8'");
  1440. $sql = "UPDATE `chat_message` SET `read_status`='1' WHERE ((`from_id` = '$fromID' AND `to_id` = '$toID') OR (`from_id` = '$toID' AND `to_id` = '$fromID')) AND type = 'FP'";
  1441. $result=mysql_query($sql);
  1442. return $result;
  1443. }
  1444. public function update_read_message_from_group($toID,$fromID)
  1445. {
  1446. mysql_query("set character_set_server='utf8'");
  1447. mysql_query("set names 'utf8'");
  1448. $sql = "UPDATE `readchatmessage` SET `status`='1' WHERE group_id = '$toID' AND member_id = '$fromID'";
  1449. $result=mysql_query($sql);
  1450. return $result;
  1451. }
  1452. public function get_chat_image($fromID,$toID,$type,$mtype)
  1453. {
  1454. mysql_query("set character_set_server='utf8'");
  1455. mysql_query("set names 'utf8'");
  1456. $sql = "SELECT * FROM chat_message WHERE patient_id = '$pid'";
  1457. $result=mysql_query($sql);
  1458. return $result;
  1459. }
  1460. public function getmessagedetail($fid,$tid,$type,$to_type)
  1461. {
  1462. mysql_query("set character_set_server='utf8'");
  1463. mysql_query("set names 'utf8'");
  1464. $sql = "SELECT chatmsg_id,from_id,to_id,message,status,date,type,message_type from `chat_message` where (from_id = '$fid' AND to_id = '$tid' AND type = 'D') OR (from_id = '$tid' and to_id = '$fid' AND type = 'P')";
  1465. $result=mysql_query($sql);
  1466. return $result;
  1467. }
  1468. public function getfmessagedetail($fid,$tid,$type,$to_type)
  1469. {
  1470. mysql_query("set character_set_server='utf8'");
  1471. mysql_query("set names 'utf8'");
  1472. $sql = "SELECT chatmsg_id,from_id,to_id,message,status,date,type,message_type from `chat_message` where (from_id = '$fid' AND to_id = '$tid' AND type = 'DF') OR (from_id = '$tid' AND to_id = '$fid' AND type = 'FD')";
  1473. $result=mysql_query($sql);
  1474. return $result;
  1475. }
  1476. public function getpatientmessagedetail($fid,$tid,$type,$to_type)
  1477. {
  1478. mysql_query("set character_set_server='utf8'");
  1479. mysql_query("set names 'utf8'");
  1480. $sql = "SELECT from_id,to_id,message,status,date,type,message_type from `chat_message` where (from_id = '$fid' AND to_id = '$tid' AND type = 'PF') OR (from_id = '$tid' AND to_id = '$fid' AND type = 'FP')";
  1481. $result=mysql_query($sql);
  1482. return $result;
  1483. }
  1484. public function getmessagedetaildetails($fid,$tid,$type)
  1485. {
  1486. mysql_query("set character_set_server='utf8'");
  1487. mysql_query("set names 'utf8'");
  1488. $sql = "SELECT from_id,to_id,message,status,date,type,message_type from `chat_message` where ((from_id = '$fid' and to_id = '$tid') OR (from_id = '$tid' and to_id = '$fid')) AND type='DD'";
  1489. $result=mysql_query($sql);
  1490. return $result;
  1491. }
  1492. public function getpmessagedetail($fid,$tid,$type,$to_type)
  1493. {
  1494. mysql_query("set character_set_server='utf8'");
  1495. mysql_query("set names 'utf8'");
  1496. $sql = "SELECT from_id,to_id,message,status,date,type,message_type from `chat_message` where (from_id = '$fid' AND to_id = '$tid' AND type = 'P') OR (from_id = '$tid' AND to_id = '$fid' AND type = 'D')";
  1497. //$sql = "SELECT from_id as toid,to_id as fromid,message,status,date,type,message_type from `chat_message` where (from_id = '$fid' and to_id = '$tid') OR (from_id = '$tid' and to_id = '$fid')";
  1498. $result=mysql_query($sql);
  1499. return $result;
  1500. }
  1501. public function get_pharmacy_chat_message($fid,$tid,$type,$to_type)
  1502. {
  1503. mysql_query("set character_set_server='utf8'");
  1504. mysql_query("set names 'utf8'");
  1505. $sql = "SELECT chatmsg_id,from_id,to_id,message,status,date,type,message_type from `chat_message` where ((from_id = '$fid' and to_id = '$tid') OR (from_id = '$tid' and to_id = '$fid')) AND (type = 'DF' OR type = 'PF' OR type = 'FD' OR type = 'FP' OR type = 'FF')";
  1506. //$sql = "SELECT from_id as toid,to_id as fromid,message,status,date,type,message_type from `chat_message` where (from_id = '$fid' and to_id = '$tid') OR (from_id = '$tid' and to_id = '$fid')";
  1507. $result=mysql_query($sql);
  1508. return $result;
  1509. }
  1510. public function get_pharmacy_doctor_chat_message($fid,$tid,$type,$to_type)
  1511. {
  1512. mysql_query("set character_set_server='utf8'");
  1513. mysql_query("set names 'utf8'");
  1514. $sql = "SELECT chatmsg_id,from_id,to_id,message,status,date,type,message_type from `chat_message` where (from_id = '$fid' AND to_id = '$tid' AND type = 'FD') OR (from_id = '$tid' AND to_id = '$fid' AND type = 'DF')";
  1515. //$sql = "SELECT from_id as toid,to_id as fromid,message,status,date,type,message_type from `chat_message` where (from_id = '$fid' and to_id = '$tid') OR (from_id = '$tid' and to_id = '$fid')";
  1516. $result=mysql_query($sql);
  1517. return $result;
  1518. }
  1519. public function get_pharmacy_patient_chat_message($fid,$tid,$type,$to_type)
  1520. {
  1521. mysql_query("set character_set_server='utf8'");
  1522. mysql_query("set names 'utf8'");
  1523. $sql = "SELECT chatmsg_id,from_id,to_id,message,status,date,type,message_type from `chat_message` where (from_id = '$fid' and to_id = '$tid' AND type = 'FP') OR (from_id = '$tid' and to_id = '$fid' AND type = 'PF')";
  1524. //$sql = "SELECT from_id as toid,to_id as fromid,message,status,date,type,message_type from `chat_message` where (from_id = '$fid' and to_id = '$tid') OR (from_id = '$tid' and to_id = '$fid')";
  1525. $result=mysql_query($sql);
  1526. return $result;
  1527. }
  1528. public function get_pharmacy_pharmacy_chat_message($fid,$tid,$type,$to_type)
  1529. {
  1530. mysql_query("set character_set_server='utf8'");
  1531. mysql_query("set names 'utf8'");
  1532. $sql = "SELECT chatmsg_id,from_id,to_id,message,status,date,type,message_type from `chat_message` where (from_id = '$fid' and to_id = '$tid' AND type = 'FF') OR (from_id = '$tid' and to_id = '$fid' AND type = 'FF')";
  1533. //$sql = "SELECT from_id as toid,to_id as fromid,message,status,date,type,message_type from `chat_message` where (from_id = '$fid' and to_id = '$tid') OR (from_id = '$tid' and to_id = '$fid')";
  1534. $result=mysql_query($sql);
  1535. return $result;
  1536. }
  1537. public function count_unread_message($id,$res,$type)
  1538. {
  1539. mysql_query("set character_set_server='utf8'");
  1540. mysql_query("set names 'utf8'");
  1541. $sql = "SELECT * FROM `chat_message` WHERE (`from_id` = '$res' AND `to_id` = '$id') and `read_status` = '0' AND type != '$type'";
  1542. $result=mysql_query($sql);
  1543. return $result;
  1544. }
  1545. public function count_unread_pharmacyd_message($id,$res,$type)
  1546. {
  1547. mysql_query("set character_set_server='utf8'");
  1548. mysql_query("set names 'utf8'");
  1549. $sql = "SELECT * FROM `chat_message` WHERE (`from_id` = '$id' AND `to_id` = '$res') and `read_status` = '0' AND type = 'FP'";
  1550. $result=mysql_query($sql);
  1551. return $result;
  1552. }
  1553. public function count_unread_far_message($id,$res,$type)
  1554. {
  1555. mysql_query("set character_set_server='utf8'");
  1556. mysql_query("set names 'utf8'");
  1557. $sql = "SELECT * FROM `chat_message` WHERE (`from_id` = '$res' AND `to_id` = '$id') and `read_status` = '0' AND type = 'FD'";
  1558. $result=mysql_query($sql);
  1559. return $result;
  1560. }
  1561. public function count_unread_DS_message($id,$res,$type)
  1562. {
  1563. mysql_query("set character_set_server='utf8'");
  1564. mysql_query("set names 'utf8'");
  1565. $sql = "SELECT * FROM `chat_message` WHERE (`from_id` = '$res' AND `to_id` = '$id') and `read_status` = '0' AND type = 'D'";
  1566. $result=mysql_query($sql);
  1567. return $result;
  1568. }
  1569. public function count_pharmacyunread_message($id,$res,$type)
  1570. {
  1571. mysql_query("set character_set_server='utf8'");
  1572. mysql_query("set names 'utf8'");
  1573. $sql = "SELECT * FROM `chat_message` WHERE (`from_id` = '$res' AND `to_id` = '$id') and `read_status` = '0' AND type = 'FP'";
  1574. $result=mysql_query($sql);
  1575. return $result;
  1576. }
  1577. public function count_pharunread_message($id,$res,$type)
  1578. {
  1579. mysql_query("set character_set_server='utf8'");
  1580. mysql_query("set names 'utf8'");
  1581. $sql = "SELECT * FROM `chat_message` WHERE (`from_id` = '$res' AND `to_id` = '$id') and `read_status` = '0' AND type = '$type'";
  1582. $result=mysql_query($sql);
  1583. return $result;
  1584. }
  1585. public function count_unread_pat_message($id,$res,$type)
  1586. {
  1587. mysql_query("set character_set_server='utf8'");
  1588. mysql_query("set names 'utf8'");
  1589. $sql = "SELECT * FROM `chat_message` WHERE (`from_id` = '$res' AND `to_id` = '$id') AND `read_status` = '0' AND type = 'P'";
  1590. $result=mysql_query($sql);
  1591. return $result;
  1592. }
  1593. public function count_unread_message_doctor($id,$doctor_Id,$type)
  1594. {
  1595. mysql_query("set character_set_server='utf8'");
  1596. mysql_query("set names 'utf8'");
  1597. $sql = "SELECT * FROM `chat_message` WHERE (`from_id` = '$doctor_Id' AND `to_id` = '$id') OR (`from_id` = '$id' AND `to_id` = '$doctor_Id') AND `read_status` = '0'";
  1598. $result=mysql_query($sql);
  1599. return $result;
  1600. }
  1601. public function get_member_det($fromID,$toID)
  1602. {
  1603. mysql_query("set character_set_server='utf8'");
  1604. mysql_query("set names 'utf8'");
  1605. $sql = "SELECT * FROM chatgroup_details WHERE group_id = '$toID' AND doctor_id != '$fromID'";
  1606. $result=mysql_query($sql);
  1607. return $result;
  1608. }
  1609. public function count_unread_group_message($group_id,$memberID)
  1610. {
  1611. mysql_query("set character_set_server='utf8'");
  1612. mysql_query("set names 'utf8'");
  1613. $sql = "SELECT * FROM `readchatmessage` WHERE group_id = '$group_id' AND member_id = '$memberID' AND `status` = '0'";
  1614. $result=mysql_query($sql);
  1615. return $result;
  1616. }
  1617. public function insert_unread_message($fromID,$toID,$groupchatID)
  1618. {
  1619. mysql_query("set character_set_server='utf8'");
  1620. mysql_query("set names 'utf8'");
  1621. $sql = "INSERT INTO `readchatmessage`( `groupchat_id`, `group_id`, `member_id`, `status`) VALUES ('$groupchatID','$toID','$fromID','0')";
  1622. $result=mysql_query($sql);
  1623. return $result;
  1624. }
  1625. public function update_patient_took($patientID)
  1626. {
  1627. mysql_query("set character_set_server='utf8'");
  1628. mysql_query("set names 'utf8'");
  1629. $sql = "UPDATE patient set took = '1' where patient_id = '$patientID'";
  1630. $result=mysql_query($sql);
  1631. return $result;
  1632. }
  1633. public function get_patient_attended($doctorID)
  1634. {
  1635. mysql_query("set character_set_server='utf8'");
  1636. mysql_query("set names 'utf8'");
  1637. $sql = "SELECT *
  1638. FROM `patient`
  1639. WHERE patient_id NOT
  1640. IN (
  1641. SELECT patient_id
  1642. FROM push_notification_details
  1643. WHERE doctor_id = '$doctorID'
  1644. AND STATUS = '1'
  1645. )";
  1646. $result=mysql_query($sql);
  1647. return $result;
  1648. }
  1649. public function get_doctor_token_details($getresult,$categoryID)
  1650. {
  1651. mysql_query("set character_set_server='utf8'");
  1652. mysql_query("set names 'utf8'");
  1653. $sql = "SELECT device_id
  1654. FROM `doctor_signup`
  1655. WHERE doctor_id = '$getresult'";
  1656. $result=mysql_query($sql);
  1657. return $result;
  1658. }
  1659. public function get_patient_token_details($PatientId)
  1660. {
  1661. mysql_query("set character_set_server='utf8'");
  1662. mysql_query("set names 'utf8'");
  1663. $sql = "SELECT token FROM `patient` WHERE patient_id = '$PatientId'";
  1664. $result=mysql_fetch_assoc(mysql_query($sql));
  1665. return $result;
  1666. }
  1667. public function getDoctorTokenDevice($PatientId)
  1668. {
  1669. mysql_query("set character_set_server='utf8'");
  1670. mysql_query("set names 'utf8'");
  1671. $sql = "SELECT device_id FROM `doctor_signup` WHERE doctor_id = '$PatientId'";
  1672. $result=mysql_fetch_assoc(mysql_query($sql));
  1673. return $result;
  1674. }
  1675. public function get_pharmacydetail()
  1676. {
  1677. mysql_query("set character_set_server='utf8'");
  1678. mysql_query("set names 'utf8'");
  1679. $sql = "SELECT * from pharmacy";
  1680. $result=mysql_query($sql);
  1681. return $result;
  1682. }
  1683. public function get_pharmacy_details_api($fromID)
  1684. {
  1685. mysql_query("set character_set_server='utf8'");
  1686. mysql_query("set names 'utf8'");
  1687. $sql = "SELECT * from pharmacy";
  1688. $result=mysql_query($sql);
  1689. return $result;
  1690. }
  1691. public function get_pharmacy_details_api_d($fromID)
  1692. {
  1693. mysql_query("set character_set_server='utf8'");
  1694. mysql_query("set names 'utf8'");
  1695. $sql = "SELECT * from pharmacy where pharmacy_id = '$fromID'";
  1696. $result=mysql_query($sql);
  1697. return $result;
  1698. }
  1699. public function get_patient_f($patientID)
  1700. {
  1701. mysql_query("set character_set_server='utf8'");
  1702. mysql_query("set names 'utf8'");
  1703. $sql = "SELECT `patient_id` as id, `patient_name` as name, `profile_pic`, `type` FROM `patient` where patient_id = '$patientID'";
  1704. $result=mysql_query($sql);
  1705. return $result;
  1706. }
  1707. public function get_doctor_f($dID)
  1708. {
  1709. mysql_query("set character_set_server='utf8'");
  1710. mysql_query("set names 'utf8'");
  1711. $sql = "SELECT `doctor_id` as id, `doctor_name` as name, `profile_pic`, `type` FROM `doctor_signup` where doctor_id = '$dID'";
  1712. $result=mysql_query($sql);
  1713. return $result;
  1714. }
  1715. /*------------------------------------------End Chat-------------------------------------------------*/
  1716. /*------------------------------------------Group Chat-------------------------------------------------*/
  1717. public function create_group($groupName,$doctorID,$groupImg)
  1718. {
  1719. mysql_query("set character_set_server='utf8'");
  1720. mysql_query("set names 'utf8'");
  1721. $sql = "INSERT INTO `create_group`(`group_name`, `doctor_id`,`group_image`,`type`) VALUES ('$groupName',$doctorID,'$groupImg','G')";
  1722. $result=mysql_query($sql);
  1723. return $result;
  1724. }
  1725. public function get_group_records($groupName,$doctorID)
  1726. {
  1727. mysql_query("set character_set_server='utf8'");
  1728. mysql_query("set names 'utf8'");
  1729. $sql = "SELECT * from `create_group` where group_name = '$groupName' AND doctor_id = '$doctorID'";
  1730. //echo $sql;
  1731. $result=mysql_query($sql);
  1732. return $result;
  1733. }
  1734. public function get_patient_help($patient_id,$speciallize_doctor,$description)
  1735. {
  1736. mysql_query("set character_set_server='utf8'");
  1737. mysql_query("set names 'utf8'");
  1738. $sql = "SELECT * from `patient_help`";
  1739. //echo $sql;
  1740. $result=mysql_query($sql);
  1741. return $result;
  1742. }
  1743. public function create_group_without_url($groupName,$doctorID,$file_url_name)
  1744. {
  1745. mysql_query("set character_set_server='utf8'");
  1746. mysql_query("set names 'utf8'");
  1747. if(isset($_FILES['imageData']['name']))
  1748. {
  1749. if((($_FILES['imageData']['type'] == "image/jpeg")|| ($_FILES['imageData']['type'] == "image/gif")|| ($_FILES['imageData']['type'] == "image/jpg")|| ($_FILES['imageData']['type'] == "image/png")&& ($_FILES['imageData']['size'] < 1000000000000000))){
  1750. if ($_FILES["imageData"]["error"] > 0) echo "Return Code: " . $_FILES["imageData"]["error"] . "<br />"; else {
  1751. $Ex = end(explode(".",$_FILES['imageData']['name']));
  1752. $array = explode(".",$_FILES['imageData']['name']);
  1753. $file_url_name = $array[0].time().".".$Ex;
  1754. move_uploaded_file($_FILES["imageData"]["tmp_name"], "uploads/group_image/".$file_url_name);
  1755. }
  1756. }
  1757. }
  1758. $file_url_name1 = "http://bytesnmaterials.com/healthcare/uploads/group_image/".$file_url_name;
  1759. $sql = "INSERT INTO `create_group`(`group_name`, `doctor_id`,`group_image`,`type`) VALUES ('$groupName','$doctorID','$file_url_name1','G')";
  1760. $result=mysql_query($sql);
  1761. return $result;
  1762. }
  1763. public function add_doctor_from_group($groupName,$doctorID,$member_id)
  1764. {
  1765. mysql_query("set character_set_server='utf8'");
  1766. mysql_query("set names 'utf8'");
  1767. $sql = "INSERT INTO `chatgroup_details`(`group_id`, `doctor_id`,`member_id`) VALUES ('$groupName','$doctorID','$member_id')";
  1768. //echo $sql;
  1769. $result=mysql_query($sql);
  1770. return $result;
  1771. }
  1772. public function add_patient_help($patient_id,$speciallize_doctor,$description)
  1773. {
  1774. mysql_query("set character_set_server='utf8'");
  1775. mysql_query("set names 'utf8'");
  1776. $sql = "INSERT INTO `patient_help`(`patient_id`, `speciallize_doctor`, `description`) VALUES ('$patient_id','$speciallize_doctor','$description')";
  1777. //echo $sql;
  1778. $result=mysql_query($sql);
  1779. return $result;
  1780. }
  1781. public function get_group_all_doctor($groupID,$doctorID)
  1782. {
  1783. mysql_query("set character_set_server='utf8'");
  1784. mysql_query("set names 'utf8'");
  1785. $sql = "SELECT * FROM `chatgroup_details` where group_id = '$groupID' AND doctor_id = '$doctorID'";
  1786. $result=mysql_query($sql);
  1787. return $result;
  1788. }
  1789. public function get_all_group_doctor($doctor_iD)
  1790. {
  1791. mysql_query("set character_set_server='utf8'");
  1792. mysql_query("set names 'utf8'");
  1793. $sql = "SELECT * FROM doctor_signup where doctor_id != '$doctor_iD'";
  1794. $result=mysql_query($sql);
  1795. return $result;
  1796. }
  1797. public function get_group_list($id)
  1798. {
  1799. mysql_query("set character_set_server='utf8'");
  1800. mysql_query("set names 'utf8'");
  1801. $sql = "SELECT g.group_id AS id, g.group_name AS name, g.group_image AS profile_pic, g.type
  1802. FROM `create_group` AS g, chatgroup_details AS cg
  1803. WHERE cg.group_id
  1804. IN (
  1805. SELECT group_id
  1806. FROM chatgroup_details
  1807. WHERE cg.doctor_id = '$id'
  1808. ) AND g.group_id = cg.group_id";
  1809. $result=mysql_query($sql);
  1810. return $result;
  1811. }
  1812. public function get_group_name($groupName)
  1813. {
  1814. mysql_query("set character_set_server='utf8'");
  1815. mysql_query("set names 'utf8'");
  1816. $sql = "SELECT * FROM `create_group` where group_id = '$groupName'";
  1817. $result=mysql_query($sql);
  1818. return $result;
  1819. }
  1820. public function insert_group_admin_details($groupId,$doctorID)
  1821. {
  1822. mysql_query("set character_set_server='utf8'");
  1823. mysql_query("set names 'utf8'");
  1824. $sql = "INSERT INTO `chatgroup_details`(`group_id`, `doctor_id`, `member_id`) VALUES ('$groupId','$doctorID','$doctorID')";
  1825. //echo $sql;
  1826. $result=mysql_query($sql);
  1827. return $result;
  1828. }
  1829. public function get_group_admin_id($groupID)
  1830. {
  1831. mysql_query("set character_set_server='utf8'");
  1832. mysql_query("set names 'utf8'");
  1833. $sql = "SELECT * FROM `create_group` where group_id = '$groupID'";
  1834. $result=mysql_query($sql);
  1835. return $result;
  1836. }
  1837. public function getlastmessagegroup($group_id)
  1838. {
  1839. mysql_query("set character_set_server='utf8'");
  1840. mysql_query("set names 'utf8'");
  1841. $sql = "SELECT * FROM `group_chat` where group_id = '$group_id' ORDER BY groupchat_id DESC LIMIT 1";
  1842. $result=mysql_query($sql);
  1843. return $result;
  1844. }
  1845. public function getgroupmessagedetail($tid,$type)
  1846. {
  1847. mysql_query("set character_set_server='utf8'");
  1848. mysql_query("set names 'utf8'");
  1849. $sql = "SELECT groupchat_id,member_id as fromid,group_id,message,message_type,read_status,type,date FROM `group_chat` where group_id = '$tid' AND type = '$type'";
  1850. $result=mysql_query($sql);
  1851. return $result;
  1852. }
  1853. public function get_doctor_profile_pic($doctorID)
  1854. {
  1855. mysql_query("set character_set_server='utf8'");
  1856. mysql_query("set names 'utf8'");
  1857. $sql = "SELECT profile_pic FROM `doctor_signup` where doctor_id = '$doctorID'";
  1858. //echo $sql;
  1859. $result=mysql_query($sql);
  1860. return $result;
  1861. }
  1862. public function getgroup_doc_IDet($id)
  1863. {
  1864. mysql_query("set character_set_server='utf8'");
  1865. mysql_query("set names 'utf8'");
  1866. $sql = "SELECT * FROM `chatgroup_details` where doctor_id = '$id'";
  1867. //echo $sql;
  1868. $result=mysql_query($sql);
  1869. return $result;
  1870. }
  1871. public function insert_group_message($fromID,$toID,$message,$type,$mtype)
  1872. {
  1873. mysql_query("set character_set_server='utf8'");
  1874. mysql_query("set names 'utf8'");
  1875. $sql = "INSERT INTO `group_chat`(`member_id`, `group_id`, `message`, `message_type`, `read_status`, `type`) VALUES ('$fromID','$toID','$message','$mtype',0,'$type')";
  1876. $result=mysql_query($sql);
  1877. return $result;
  1878. }
  1879. public function get_all_doctor_group_details($groupID)
  1880. {
  1881. mysql_query("set character_set_server='utf8'");
  1882. mysql_query("set names 'utf8'");
  1883. $sql = "SELECT * FROM `chatgroup_details` where group_id = '$groupID'";
  1884. $result=mysql_query($sql);
  1885. return $result;
  1886. }
  1887. public function get_group_doctor_token_detail($docID)
  1888. {
  1889. mysql_query("set character_set_server='utf8'");
  1890. mysql_query("set names 'utf8'");
  1891. $sql = "SELECT device_id FROM `doctor_signup` where doctor_id = '$docID'";
  1892. //echo $sql;
  1893. $result=mysql_query($sql);
  1894. return $result;
  1895. }
  1896. public function get_last_group_message_date($toID,$type)
  1897. {
  1898. mysql_query("set character_set_server='utf8'");
  1899. mysql_query("set names 'utf8'");
  1900. $sql = "SELECT * FROM `group_chat` where group_id = '$toID' ORDER BY groupchat_id DESC LIMIT 1";
  1901. $result=mysql_query($sql);
  1902. return $result;
  1903. }
  1904. public function check_pstient_took($patientID,$doctorID)
  1905. {
  1906. mysql_query("set character_set_server='utf8'");
  1907. mysql_query("set names 'utf8'");
  1908. $sql = "SELECT * FROM `patient_took` where doctor_id = '$doctorID' AND patient_id = '$patientID'";
  1909. $result=mysql_query($sql);
  1910. return $result;
  1911. }
  1912. public function check_patienttook($patientID,$doctorID)
  1913. {
  1914. mysql_query("set character_set_server='utf8'");
  1915. mysql_query("set names 'utf8'");
  1916. $sql = "SELECT * FROM `patient_took` where doctor_id = '$doctorID' AND patient_id = '$patientID' AND status = '1'";
  1917. $result=mysql_query($sql);
  1918. return $result;
  1919. }
  1920. public function insert_patient_took($patientID,$doctorID,$status,$duration, $lat, $lang)
  1921. {
  1922. mysql_query("set character_set_server='utf8'");
  1923. mysql_query("set names 'utf8'");
  1924. //$sql = "SELECT * FROM `patient_took` where patient_id = '$patientID' AND doctor_id = '$doctorID' AND doctor_id = '$status'";
  1925. $sql = "INSERT INTO `patient_took`(`patient_id`, `doctor_id`, `status`,`duration`, `lat`, `lang`) VALUES ('$patientID','$doctorID','$status','$duration', '$lat', '$lang')";
  1926. $result=mysql_query($sql);
  1927. return $result;
  1928. }
  1929. public function update_took_patientd($patientID,$doctorID,$status)
  1930. {
  1931. mysql_query("set character_set_server='utf8'");
  1932. mysql_query("set names 'utf8'");
  1933. //$sql = "SELECT * FROM `patient_took` where patient_id = '$patientID' AND doctor_id = '$doctorID' AND doctor_id = '$status'";
  1934. $sql = "UPDATE `patient_took` set `status` = '$status' Where patient_id = '$patientID' AND doctor_id = '$doctorID'";
  1935. $result=mysql_query($sql);
  1936. return $result;
  1937. }
  1938. public function update_took_patientdAndTime($patientID,$doctorID,$status, $Duration)
  1939. {
  1940. mysql_query("set character_set_server='utf8'");
  1941. mysql_query("set names 'utf8'");
  1942. //$sql = "SELECT * FROM `patient_took` where patient_id = '$patientID' AND doctor_id = '$doctorID' AND doctor_id = '$status'";
  1943. $sql = "UPDATE `patient_took` set `status` = '$status', `duration` = '$Duration' Where patient_id = '$patientID' AND doctor_id = '$doctorID'";
  1944. $result=mysql_query($sql);
  1945. return $result;
  1946. }
  1947. public function get_doctor_name_notification($doctorID)
  1948. {
  1949. mysql_query("set character_set_server='utf8'");
  1950. mysql_query("set names 'utf8'");
  1951. //$sql = "SELECT * FROM `patient_took` where patient_id = '$patientID' AND doctor_id = '$doctorID' AND doctor_id = '$status'";
  1952. $sql = "SELECT * from doctor_signup where doctor_id = '$doctorID'";
  1953. $result=mysql_query($sql);
  1954. return $result;
  1955. }
  1956. public function get_doctor_deviceId_D($getresult)
  1957. {
  1958. mysql_query("set character_set_server='utf8'");
  1959. mysql_query("set names 'utf8'");
  1960. $sql = "SELECT * from doctor_signup where doctor_id = '$getresult'";
  1961. $result=mysql_query($sql);
  1962. return $result;
  1963. }
  1964. public function get_patient_ID($doctorID)
  1965. {
  1966. mysql_query("set character_set_server='utf8'");
  1967. mysql_query("set names 'utf8'");
  1968. $sql = "SELECT * from patient_took where doctor_id = '$doctorID' AND status = '1'";
  1969. $result=mysql_query($sql);
  1970. return $result;
  1971. }
  1972. public function get_doctorID($id)
  1973. {
  1974. mysql_query("set character_set_server='utf8'");
  1975. mysql_query("set names 'utf8'");
  1976. $sql = "SELECT * from patient_took where patient_id = '$id' AND status = '1'";
  1977. //echo $sql;
  1978. $result=mysql_query($sql);
  1979. return $result;
  1980. }
  1981. public function check_mail_id($email)
  1982. {
  1983. $newPost = $this->conn->getReference('healthcare_login')
  1984. ->orderByChild('email_id')
  1985. ->equalTo($email);
  1986. $mobileCheck = $this->conn->getReference('healthcare_login')
  1987. ->orderByChild('mobile_no')
  1988. ->equalTo($email);
  1989. $snapshot_email = $newPost->getSnapshot();
  1990. $refID_email = $snapshot_email->getValue();
  1991. $snapshot_mobile = $mobileCheck->getSnapshot();
  1992. $refID_mobile = $snapshot_mobile->getValue();
  1993. if(count($refID_email) == 1 || count($refID_mobile) == 1 ){
  1994. $refIDKey = empty($refID_email) ? $refID_mobile : $refID_email;
  1995. $resetArray = array_values($refIDKey);
  1996. return $refIDKey;
  1997. }
  1998. else{
  1999. return [];
  2000. }
  2001. }
  2002. public function update_healthcare_login($id,$npassword)
  2003. {
  2004. mysql_query("set character_set_server='utf8'");
  2005. mysql_query("set names 'utf8'");
  2006. $sql = "Update healthcare_login SET password = '$npassword' where (email_id = '$id' OR mobile_no = '$id')";
  2007. $result=mysql_query($sql);
  2008. return $result;
  2009. }
  2010. public function update_patient_password_details($id,$npassword)
  2011. {
  2012. mysql_query("set character_set_server='utf8'");
  2013. mysql_query("set names 'utf8'");
  2014. $sql = "UPDATE `patient` SET `password`='$npassword' WHERE email_id = '$id'";
  2015. $result=mysql_query($sql);
  2016. return $result;
  2017. }
  2018. public function update_doctor_password_details($id,$npassword)
  2019. {
  2020. mysql_query("set character_set_server='utf8'");
  2021. mysql_query("set names 'utf8'");
  2022. $sql = "UPDATE `doctor_signup` SET `password`='$npassword' WHERE email_id = '$id'";
  2023. //echo $sql;
  2024. $result=mysql_query($sql);
  2025. return $result;
  2026. }
  2027. public function update_patient_mpassword_details($id,$npassword)
  2028. {
  2029. mysql_query("set character_set_server='utf8'");
  2030. mysql_query("set names 'utf8'");
  2031. $sql = "UPDATE `patient` SET `password`='$npassword' WHERE mobile_no = '$id'";
  2032. $result=mysql_query($sql);
  2033. return $result;
  2034. }
  2035. public function update_doctor_mpassword_details($id,$npassword)
  2036. {
  2037. mysql_query("set character_set_server='utf8'");
  2038. mysql_query("set names 'utf8'");
  2039. $sql = "UPDATE `doctor_signup` SET `password`='$npassword' WHERE mobile_no = '$id'";
  2040. //echo $sql;
  2041. $result=mysql_query($sql);
  2042. return $result;
  2043. }
  2044. public function update_doctor_call_status($id,$type,$status)
  2045. {
  2046. mysql_query("set character_set_server='utf8'");
  2047. mysql_query("set names 'utf8'");
  2048. $sql = "UPDATE `doctor_signup` SET call_status = '$status' WHERE `doctor_id`='$id'";
  2049. //echo $sql;
  2050. $result=mysql_query($sql);
  2051. return $result;
  2052. }
  2053. public function update_patient_call_status($id,$type,$status)
  2054. {
  2055. mysql_query("set character_set_server='utf8'");
  2056. mysql_query("set names 'utf8'");
  2057. $sql = "UPDATE `patient` SET call_status = '$status' WHERE patient_id = '$id'";
  2058. $result=mysql_query($sql);
  2059. return $result;
  2060. }
  2061. public function get_doctor_call_status($doctorID)
  2062. {
  2063. mysql_query("set character_set_server='utf8'");
  2064. mysql_query("set names 'utf8'");
  2065. $sql = "SELECT * from doctor_signup where doctor_id = '$doctorID'";
  2066. $result=mysql_query($sql);
  2067. return $result;
  2068. }
  2069. public function update_patient_logout_status($id,$type)
  2070. {
  2071. mysql_query("set character_set_server='utf8'");
  2072. mysql_query("set names 'utf8'");
  2073. $sql = "UPDATE patient SET token = '', status = '2' where patient_id = '$id'";
  2074. $result=mysql_query($sql);
  2075. return $result;
  2076. }
  2077. public function update_doctor_logout_status($id,$type)
  2078. {
  2079. mysql_query("set character_set_server='utf8'");
  2080. mysql_query("set names 'utf8'");
  2081. $sql = "UPDATE doctor_signup SET device_id = '', status = '2' where doctor_id = '$id'";
  2082. //$sql = "UPDATE doctor_signup SET status = '2' where doctor_id = '$id'";
  2083. $result=mysql_query($sql);
  2084. return $result;
  2085. }
  2086. public function update_pharmacy_logout_status($id,$type)
  2087. {
  2088. mysql_query("set character_set_server='utf8'");
  2089. mysql_query("set names 'utf8'");
  2090. $sql = "UPDATE pharmacy SET token = '', status = '2' where pharmacy_id = '$id'";
  2091. $result=mysql_query($sql);
  2092. return $result;
  2093. }
  2094. public function update_doctor_status($id,$status)
  2095. {
  2096. mysql_query("set character_set_server='utf8'");
  2097. mysql_query("set names 'utf8'");
  2098. $sql = "UPDATE doctor_signup SET status = '$status' where doctor_id = '$id'";
  2099. //$sql = "UPDATE doctor_signup SET status = '2' where doctor_id = '$id'";
  2100. $result=mysql_query($sql);
  2101. return $result;
  2102. }
  2103. public function update_doctor_lat_long($id,$lat,$long)
  2104. {
  2105. mysql_query("set character_set_server='utf8'");
  2106. mysql_query("set names 'utf8'");
  2107. $sql = "UPDATE doctor_signup SET lat = '$lat', log = '$long' where doctor_id = '$id'";
  2108. //$sql = "UPDATE doctor_signup SET status = '2' where doctor_id = '$id'";
  2109. $result=mysql_query($sql);
  2110. return $result;
  2111. }
  2112. public function check_doctor_logout_status($id,$type)
  2113. {
  2114. mysql_query("set character_set_server='utf8'");
  2115. mysql_query("set names 'utf8'");
  2116. $sql = "SELECT status FROM doctor_signup where doctor_id = '$id'";
  2117. $result=mysql_fetch_assoc(mysql_query($sql));
  2118. return $result['status'];
  2119. }
  2120. public function update_doctor_took_status($did,$status)
  2121. {
  2122. mysql_query("set character_set_server='utf8'");
  2123. mysql_query("set names 'utf8'");
  2124. $sql = "UPDATE doctor_signup SET status = '$status' where doctor_id = '$did'";
  2125. $result=mysql_query($sql);
  2126. return $result;
  2127. }
  2128. public function update_patient_took_status($pid,$status)
  2129. {
  2130. mysql_query("set character_set_server='utf8'");
  2131. mysql_query("set names 'utf8'");
  2132. $sql = "UPDATE patient SET status = '$status' where patient_id = '$pid'";
  2133. $result=mysql_query($sql);
  2134. return $result;
  2135. }
  2136. public function compress_image($source_url, $destination_url, $quality) {
  2137. $info = getimagesize($source_url);
  2138. //echo $destination_url;
  2139. //echo $destination_url;
  2140. if ($info['mime'] == 'image/jpeg')
  2141. $image = imagecreatefromjpeg($source_url);
  2142. elseif ($info['mime'] == 'image/gif')
  2143. $image = imagecreatefromgif($source_url);
  2144. elseif ($info['mime'] == 'image/png')
  2145. $image = imagecreatefrompng($source_url);
  2146. //echo $image;
  2147. imagejpeg($image, $destination_url, $quality);
  2148. return $destination_url;
  2149. }
  2150. /*-----------------------Map All Person API--------------------------------*/
  2151. public function get_all_patient_api()
  2152. {
  2153. mysql_query("set character_set_server='utf8'");
  2154. mysql_query("set names 'utf8'");
  2155. $sql = "SELECT * from `patient`";
  2156. $result=mysql_query($sql);
  2157. return $result;
  2158. }
  2159. public function get_all_doctor_api($id = "")
  2160. {
  2161. mysql_query("set character_set_server='utf8'");
  2162. mysql_query("set names 'utf8'");
  2163. if($id != "")
  2164. {
  2165. //$sql = "SELECT * from doctor_signup where doctor_id != '".$id."' AND `lat` != '' AND `lat` != '0.0' AND `log` != '' AND `log` != '0.0'";
  2166. $sql = "SELECT * from doctor_signup where `lat` != '' AND `lat` != '0.0' AND `log` != '' AND `log` != '0.0'";
  2167. }
  2168. else{
  2169. $sql = "SELECT * FROM `doctor_signup` WHERE `lat` != '' AND `lat` != '0.0' AND `log` != '' AND `log` != '0.0'";
  2170. }
  2171. $result=mysql_query($sql);
  2172. return $result;
  2173. }
  2174. public function get_all_pharmacy_api()
  2175. {
  2176. mysql_query("set character_set_server='utf8'");
  2177. mysql_query("set names 'utf8'");
  2178. $sql = "SELECT * from pharmacy";
  2179. $result=mysql_query($sql);
  2180. return $result;
  2181. }
  2182. public function get_patient_api($PatientId)
  2183. {
  2184. mysql_query("set character_set_server='utf8'");
  2185. mysql_query("set names 'utf8'");
  2186. $sql = "SELECT * from patient where patient_id='$PatientId'";
  2187. $result=mysql_query($sql);
  2188. return $result;
  2189. }
  2190. public function update_pharmacy_details($pharmacyID,$hourID,$workinghourID,$home_deliveryID,$inject)
  2191. {
  2192. mysql_query("set character_set_server='utf8'");
  2193. mysql_query("set names 'utf8'");
  2194. $sql = "UPDATE pharmacy SET hour_status = '$hourID',home_delivery = '$home_deliveryID',working_hour = '$workinghourID',injection_provider = '$inject' where pharmacy_id = '$pharmacyID'";
  2195. $result=mysql_query($sql);
  2196. return $result;
  2197. }
  2198. public function get_pharmacy_details($pID)
  2199. {
  2200. mysql_query("set character_set_server='utf8'");
  2201. mysql_query("set names 'utf8'");
  2202. $sql = "SELECT * FROM pharmacy where pharmacy_id = '$pID'";
  2203. $result=mysql_query($sql);
  2204. return $result;
  2205. }
  2206. public function update_healthcare_logindetails($ID,$emailID,$mobileNo,$type)
  2207. {
  2208. mysql_query("set character_set_server='utf8'");
  2209. mysql_query("set names 'utf8'");
  2210. $sql = "UPDATE `healthcare_login` SET `email_id` = '$emailID' , `mobile_no` = '$mobileNo' where `id` = '$ID' AND type = '$type'";
  2211. $result=mysql_query($sql);
  2212. return $result;
  2213. }
  2214. public function update_healthcare_pharmacy_logindetails($pharmacyID,$emailID,$mobileNO)
  2215. {
  2216. mysql_query("set character_set_server='utf8'");
  2217. mysql_query("set names 'utf8'");
  2218. $sql = "UPDATE `healthcare_login` SET `email_id` = '$emailID' , `mobile_no` = '$mobileNO' where `id` = '$pharmacyID'";
  2219. $result=mysql_query($sql);
  2220. return $result;
  2221. }
  2222. public function get_lastmessage_groupchat($fromID,$toID,$message)
  2223. {
  2224. mysql_query("set character_set_server='utf8'");
  2225. mysql_query("set names 'utf8'");
  2226. $sql = "SELECT * FROM `group_chat`where `member_id` = '$fromID' AND `group_id` = '$toID' AND `message` = '$message' ORDER BY groupchat_id DESC LIMIT 1";
  2227. $result=mysql_query($sql);
  2228. return $result;
  2229. }
  2230. public function get_doctordetailsD($doctorID)
  2231. {
  2232. mysql_query("set character_set_server='utf8'");
  2233. mysql_query("set names 'utf8'");
  2234. $sql = "SELECT * FROM `doctor_signup`where doctor_id = '$doctorID'";
  2235. $result=mysql_query($sql);
  2236. return $result;
  2237. }
  2238. public function insert_rating_details($patientID,$doctorID,$rate)
  2239. {
  2240. mysql_query("set character_set_server='utf8'");
  2241. mysql_query("set names 'utf8'");
  2242. $sql = "INSERT INTO `rating`(`patient_id`, `doctor_id`, `rate`) VALUES ('$patientID','$doctorID','$rate')";
  2243. $result=mysql_query($sql);
  2244. return $result;
  2245. }
  2246. public function check_rating_status($patientID,$doctorID)
  2247. {
  2248. mysql_query("set character_set_server='utf8'");
  2249. mysql_query("set names 'utf8'");
  2250. $sql = "SELECT * FROM rating where patient_id = '$patientID' AND doctor_id = '$doctorID'";
  2251. $result=mysql_query($sql);
  2252. return $result;
  2253. }
  2254. public function update_rating_details($patientID,$doctorID,$rate)
  2255. {
  2256. mysql_query("set character_set_server='utf8'");
  2257. mysql_query("set names 'utf8'");
  2258. $sql = "UPDATE rating SET rate = '$rate' where patient_id = '$patientID' AND doctor_id = '$doctorID'";
  2259. $result=mysql_query($sql);
  2260. return $result;
  2261. }
  2262. public function get_patient_token_id($id,$type)
  2263. {
  2264. mysql_query("set character_set_server='utf8'");
  2265. mysql_query("set names 'utf8'");
  2266. $sql = "SELECT token as ud_id,patient_id FROM patient where patient_id = '$id'";
  2267. $result=mysql_query($sql);
  2268. return $result;
  2269. }
  2270. public function get_doctor_token_id($id,$type)
  2271. {
  2272. mysql_query("set character_set_server='utf8'");
  2273. mysql_query("set names 'utf8'");
  2274. $sql = "SELECT device_id as ud_id,doctor_id FROM doctor_signup where doctor_id = '$id'";
  2275. $result=mysql_query($sql);
  2276. return $result;
  2277. }
  2278. public function get_pharmacy_token_id($id,$type)
  2279. {
  2280. mysql_query("set character_set_server='utf8'");
  2281. mysql_query("set names 'utf8'");
  2282. $sql = "SELECT pharmacy_id,token as ud_id FROM pharmacy where pharmacy_id = '$id'";
  2283. $result=mysql_query($sql);
  2284. return $result;
  2285. }
  2286. public function insert_casedescription_chat_message($getresult,$patientID,$caseD)
  2287. {
  2288. mysql_query("set character_set_server='utf8'");
  2289. mysql_query("set names 'utf8'");
  2290. $sql = "SELECT pharmacy_id,token as ud_id FROM pharmacy where pharmacy_id = '$id'";
  2291. $result=mysql_query($sql);
  2292. return $result;
  2293. }
  2294. public function get_doctor_history($doctorID)
  2295. {
  2296. mysql_query("set character_set_server='utf8'");
  2297. mysql_query("set names 'utf8'");
  2298. $sql = "select * from doctor_signup where doctor_id = '$doctorID'";
  2299. $result=mysql_query($sql);
  2300. return $result;
  2301. }
  2302. public function get_doctor_rating($doctorID)
  2303. {
  2304. mysql_query("set character_set_server='utf8'");
  2305. mysql_query("set names 'utf8'");
  2306. $sql = "select * from rating where doctor_id = '$doctorID'";
  2307. $result=mysql_query($sql);
  2308. return $result;
  2309. }
  2310. public function get_sum_of_rating($doctorID)
  2311. {
  2312. mysql_query("set character_set_server='utf8'");
  2313. mysql_query("set names 'utf8'");
  2314. $sql = "select sum(rate) as rate from rating where doctor_id = '$doctorID'";
  2315. $result=mysql_query($sql);
  2316. return $result;
  2317. }
  2318. public function check_h_took_status($fromID,$toID)
  2319. {
  2320. mysql_query("set character_set_server='utf8'");
  2321. mysql_query("set names 'utf8'");
  2322. $sql = "select * FROM patient_took where patient_id = '$fromID' AND doctor_id = '$toID' AND status = 1";
  2323. $result=mysql_query($sql);
  2324. return $result;
  2325. }
  2326. public function insert_duration_chat($patientID,$doctorID,$messg,$status,$mytype)
  2327. {
  2328. mysql_query("set character_set_server='utf8'");
  2329. mysql_query("set names 'utf8'");
  2330. $sql = "INSERT INTO `chat_message`(`from_id`, `to_id`, `message`, `status`, `type`, `message_type`, `read_status`) VALUES ('$doctorID','$patientID','$messg','$status','$mytype','text','0')";
  2331. $result=mysql_query($sql);
  2332. return $result;
  2333. }
  2334. public function getDoctorTookStatus($DocId)
  2335. {
  2336. mysql_query("set character_set_server='utf8'");
  2337. mysql_query("set names 'utf8'");
  2338. $sql = "SELECT * FROM `patient_took` WHERE `doctor_id` = '$DocId' and `status` = '1'";
  2339. $result=mysql_fetch_assoc(mysql_query($sql));
  2340. return $result;
  2341. }
  2342. public function getPatientTookStatus($PTId, $DocId)
  2343. {
  2344. mysql_query("set character_set_server='utf8'");
  2345. mysql_query("set names 'utf8'");
  2346. $sql = "SELECT * FROM `patient_took` WHERE `patient_id` = '$PTId' and `doctor_id` = '$DocId' and `status` = '1'";
  2347. $result=mysql_fetch_assoc(mysql_query($sql));
  2348. return $result;
  2349. }
  2350. public function GetTookDetail($id)
  2351. {
  2352. mysql_query("set character_set_server='utf8'");
  2353. mysql_query("set names 'utf8'");
  2354. $sql = "SELECT * FROM `patient_took` WHERE `id` = '$id'";
  2355. $result=mysql_fetch_assoc(mysql_query($sql));
  2356. return $result;
  2357. }
  2358. public function UpdateDoneStatus($id)
  2359. {
  2360. mysql_query("set character_set_server='utf8'");
  2361. mysql_query("set names 'utf8'");
  2362. $sql = "UPDATE `patient_took` SET status = '2' WHERE `id` = '$id'";
  2363. $result=mysql_query($sql);
  2364. return $result;
  2365. }
  2366. public function UpdatePaitentReview($id, $Rating, $Review)
  2367. {
  2368. mysql_query("set character_set_server='utf8'");
  2369. mysql_query("set names 'utf8'");
  2370. $sql = "UPDATE `patient_took` SET pt_rating = '$Rating', pt_review = '$Review' where `id` = '$id'";
  2371. mysql_query($sql);
  2372. }
  2373. public function UpdateDoctorReview($id, $Rating, $Review)
  2374. {
  2375. mysql_query("set character_set_server='utf8'");
  2376. mysql_query("set names 'utf8'");
  2377. $sql = "UPDATE `patient_took` SET doctor_rate = '$Rating', doctor_review = '$Review' where `id` = '$id'";
  2378. mysql_query($sql);
  2379. }
  2380. public function GetDoctorAvgRating($id)
  2381. {
  2382. mysql_query("set character_set_server='utf8'");
  2383. mysql_query("set names 'utf8'");
  2384. $sql = "SELECT AVG(`doctor_rate`) as AvgRate from patient_took where `doctor_id` = '$id'";
  2385. return mysql_fetch_assoc(mysql_query($sql));
  2386. }
  2387. public function get_patient_cancel_details($doctorID)
  2388. {
  2389. mysql_query("set character_set_server='utf8'");
  2390. mysql_query("set names 'utf8'");
  2391. $sql = "select pa.*,p.*, pa.status as TookStatus from patient_took as pa,patient as p where pa.time >= DATE_SUB(CURDATE(), INTERVAL 7 DAY) AND pa.doctor_id = '$doctorID' and p.patient_id=pa.patient_id and pa.status = 0";
  2392. $result=mysql_query($sql);
  2393. return $result;
  2394. }
  2395. public function get_doctor_cancel_details($doctorID)
  2396. {
  2397. mysql_query("set character_set_server='utf8'");
  2398. mysql_query("set names 'utf8'");
  2399. $sql = "select pa.*,p.*, pa.status as TookStatus from patient_took as pa,doctor_signup as p where pa.time >= DATE_SUB(CURDATE(), INTERVAL 7 DAY) AND pa.patient_id = '$doctorID' and p.doctor_id=pa.doctor_id and pa.status = 4";
  2400. $result=mysql_query($sql);
  2401. return $result;
  2402. }
  2403. public function AcceptTimeExt($TookId)
  2404. {
  2405. mysql_query("set character_set_server='utf8'");
  2406. mysql_query("set names 'utf8'");
  2407. $sql = "UPDATE `patient_took` SET status = '1' WHERE `id` = '$TookId'";
  2408. $result=mysql_query($sql);
  2409. return $result;
  2410. }
  2411. public function InsertCancelTook($TookId)
  2412. {
  2413. mysql_query("set character_set_server='utf8'");
  2414. mysql_query("set names 'utf8'");
  2415. $sql = "SELECT * FROM `patient_took` WHERE `id` = '$TookId'";
  2416. $result=mysql_fetch_assoc(mysql_query($sql));
  2417. $PTID = $result['patient_id'];
  2418. $DocId = $result['doctor_id'];
  2419. $sql = "INSERT INTO `cancel_took`(`cancel_took_patient`, `cancel_took_doctor`) VALUES ('$PTID','$DocId')";
  2420. mysql_query($sql);
  2421. $sql = "DELETE FROM `patient_took` WHERE `id` = '$TookId'";
  2422. mysql_query($sql);
  2423. }
  2424. public function GetAllPatientRating($id)
  2425. {
  2426. mysql_query("set character_set_server='utf8'");
  2427. mysql_query("set names 'utf8'");
  2428. $sql = "SELECT * from patient_took as ptt LEFT JOIN doctor_signup as DS on ptt.doctor_id=DS.doctor_id where `patient_id` = '$id' and pt_rating != '0'";
  2429. return mysql_query($sql);
  2430. }
  2431. public function GetAllDoctorRating($id)
  2432. {
  2433. mysql_query("set character_set_server='utf8'");
  2434. mysql_query("set names 'utf8'");
  2435. $sql = "SELECT * from patient_took as ptt LEFT JOIN patient as DS on ptt.patient_id=DS.patient_id where `doctor_id` = '$id' and doctor_rate != '0'";
  2436. return mysql_query($sql);
  2437. }
  2438. /*public function get_doctor_history($doctor_id,$hist_date)
  2439. {
  2440. mysql_query("set character_set_server='utf8'");
  2441. mysql_query("set names 'utf8'");
  2442. echo $sql = "SELECT patient_id FROM patient_took where doctor_id = '$doctor_id' AND status = '2' AND time >= '$hist_date'";
  2443. $result=mysql_query($sql);
  2444. return $result;
  2445. }
  2446. */
  2447. /*public function get_doctor_history($doctor_id,$hist_date)
  2448. {
  2449. mysql_query("set character_set_server='utf8'");
  2450. mysql_query("set names 'utf8'");
  2451. $sql = "SELECT patient_id FROM patient_took where doctor_id = '$doctor_id' AND status = '2' AND time >= '$hist_date'";
  2452. $result=mysql_query($sql);
  2453. return $result;
  2454. }*/
  2455. }
  2456. ?>