getEnableTime.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. function SoapToXml($xml)
  3. {
  4. //api测试先关闭
  5. $startStr=strrpos($xml,"<![CDATA[");
  6. $endStr=strpos($xml,"]]>");
  7. $xml=substr($xml,$startStr,$endStr-$startStr);
  8. $xml = str_replace("<![CDATA[>","",$xml);
  9. $xml = str_replace("<![CDATA[","",$xml);
  10. $xml = str_replace("]]]]>","",$xml);
  11. $xml = str_replace("]]>","",$xml);
  12. $xml = str_replace("<ILLEGAL VALUE>","",$xml);
  13. return $xml;
  14. }
  15. date_default_timezone_set('PRC');
  16. $callback = isset($_GET['callback']) ? trim($_GET['callback']) : '';
  17. //==============获得前台请求==============
  18. $req['HospitalId'] = $_GET['hospitalId'];
  19. $req['startDate'] = $_GET['startDate'];
  20. $req['endDate'] = $_GET['endDate'];
  21. $req['deptId'] = $_GET['deptId'];
  22. if (isset($_GET['doctorId'])) {
  23. $req['doctorId'] = $_GET['doctorId'];
  24. }
  25. $day = $_GET['day']?$_GET['day']:1;
  26. $arr = array();
  27. $TradeCode = "1004";
  28. $ExtOrgCode = "南方医务通";
  29. $ExtUserID = "NFYWT";
  30. $ClientType ="";
  31. $HospitalId =$req['HospitalId'];
  32. $DeptType = "";
  33. $SessType = "";
  34. $StartDate = $req['startDate'];
  35. $EndDate = date('Y-m-d',(strtotime($req['startDate'])+$day*3600*24));
  36. $RBASSessionCode = "";
  37. $ServiceCode = "";
  38. $StopScheduleFlag = "";
  39. $DepartmentCode = $req['deptId'];
  40. $DoctorCode= empty($req['doctorId'])?'':$req['doctorId'];
  41. $callback = isset($_GET['callback']) ? trim($_GET['callback']) : '';
  42. $SearchCode = "";
  43. $postData = "<Request><HospitalId>$HospitalId</HospitalId><ExtOrgCode>$ExtOrgCode</ExtOrgCode><ExtUserID>NFYWT</ExtUserID><ClientType></ClientType><TradeCode>1004</TradeCode><DeptType></DeptType><DoctorCode></DoctorCode><SessType></SessType><StartDate>$StartDate</StartDate><EndDate>$EndDate</EndDate><RBASSessionCode></RBASSessionCode><ServiceCode></ServiceCode><DoctorCode></DoctorCode><StopScheduleFlag></StopScheduleFlag><DepartmentCode>$DepartmentCode</DepartmentCode><SearchCode></SearchCode></Request>";
  44. $postData = str_replace(' ','%20',$postData);
  45. libxml_disable_entity_loader(false);
  46. $wsdl = "yygh1.wsdl";
  47. try{
  48. $client = new SoapClient($wsdl);
  49. $param = array(array("Input" => $postData));
  50. $result = $client->__soapCall('QuerySchedule',$param);
  51. $res = reset($result);
  52. } catch (SoapFault $e) {
  53. var_dump($e);exit;
  54. }
  55. //$res = SoapToXml($result);
  56. $res = simplexml_load_string($res);
  57. $res = json_encode($res);
  58. $res = json_decode($res,true);
  59. $times = array();
  60. for($i = $day-1; $i >=0;$i--) {
  61. $time = date('Y-m-d',strtotime($req['startDate'])+$i*3600*24);
  62. $times[$i]['time'] = $time;
  63. $times[$i]['count'] = 0;
  64. }
  65. if (isset($res['Schedules']['Schedule'])) {
  66. foreach ($res['Schedules']['Schedule'] as $k => $v ) {
  67. foreach ($times as $index => $time) {
  68. if ($time['time'] == $v ['ServiceDate']) {
  69. $times[$index]['count'] = intval($times[$index]['count']) + 1;
  70. break;
  71. }
  72. }
  73. }
  74. } else {
  75. $arr[0]['msg'] = '请求出错';
  76. $arr[0]['time'] = $StartDate;
  77. echo $callback . '(' . json_encode($arr) .')';exit;
  78. }
  79. foreach ($times as $k => $v) {
  80. if (intval($v['count']) == 0) {
  81. $arr[$k][$v['time']]= false;
  82. } else {
  83. $arr[$k][$v['time']]= true;
  84. }
  85. }
  86. echo $callback . '(' . json_encode($arr) .')';exit;
  87. ?>