OtherService.class.php 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820
  1. <?php
  2. if (!defined('IS_INITPHP')) exit('Access Denied!');
  3. class OtherService extends BaseService{
  4. //定义每次请求全局变量,返回请求
  5. private $jsonData = array();
  6. //返回sqlData的数据
  7. private $sqlData = null;
  8. //返回sql执行后,返回boolean,默认为true
  9. private $xmlData = array();
  10. private $tempData = array();
  11. //infoString的提示语
  12. private $infoString = null;
  13. //检测请求方法,默认是要检测的
  14. private $boolCheckFun = true;
  15. //检测用户是否合法性,默认是不合法的
  16. private $boolCheckUser = false;
  17. //返回结果,如果是LIST 返回DATA不用加入[]
  18. private $resultType = null;
  19. /**
  20. * 用于在Api引擎中解析数组列表方式
  21. * @param string $funName 方式名
  22. * @param array $funOjb 数组列表
  23. * @return json
  24. */
  25. public function medicineAdd($funName,$funObj) {
  26. //不用检测的方法列表
  27. $boolCheckFun = $this->checkFun($funName);
  28. if($boolCheckFun){
  29. //统一验证方式
  30. $boolCheckUser = $this->checkUser();
  31. }else{
  32. //检测方法过滤通过后进入下一步
  33. $boolCheckFun = true;
  34. $boolCheckUser = true;
  35. }
  36. //用于生成返回前台验证时间戳和用户token
  37. $jsonData = $this->getDataToken($boolCheckUser);
  38. $stepData1 = null;
  39. $stepData2 = null;
  40. $stepData3 = null;
  41. $stepData4 = null;
  42. $stepData5 = null;
  43. //进入流程处理
  44. if($boolCheckFun && $boolCheckUser){
  45. foreach ($funObj as $key => $json) {
  46. $json = json_decode($json);
  47. $nodeType = $json->nodeType;
  48. $sqlType = $json->sqlType;
  49. $parameter = $json->parameter;
  50. $sqlString = $json->sqlString;
  51. $resultType = $json->resultType;
  52. $infoString = $json->infoString;
  53. if($nodeType=="step1"){
  54. $sqlString= $this->getReplace($parameter,$sqlString,$sqlData,$nodeType,$boolCheckUser);
  55. $sqlData = call_user_func(array($_ENV["dbDao"],$sqlType),$sqlString,$resultType);
  56. $stepData1 =$sqlData;
  57. }else if($nodeType=="step2"){
  58. //添加处方
  59. if(!$stepData1){
  60. $sqlString= $this->getReplace($parameter,$sqlString,$sqlData,$nodeType,$boolCheckUser);
  61. $sqlData = call_user_func(array($_ENV["dbDao"],$sqlType),$sqlString,$resultType);
  62. $stepData2 =$sqlData;
  63. }
  64. }else if($nodeType=="step3"){
  65. //添加药品组
  66. if($stepData1){
  67. $sqlString= $this->getReplace($parameter,$sqlString,$stepData1,$nodeType,$boolCheckUser);
  68. $sqlData = call_user_func(array($_ENV["dbDao"],$sqlType),$sqlString,$resultType);
  69. $stepData3 =$sqlData;
  70. }else{
  71. if($stepData2){
  72. $sqlString= $this->getReplace($parameter,$sqlString,$stepData2,$nodeType,$boolCheckUser);
  73. $sqlData = call_user_func(array($_ENV["dbDao"],$sqlType),$sqlString,$resultType);
  74. $stepData3 =$sqlData;
  75. }
  76. }
  77. }else if($nodeType=="step4"){
  78. //添加计划组
  79. if($stepData3){
  80. $sqlString= $this->getReplace($parameter,$sqlString,$stepData3,$nodeType,$boolCheckUser);
  81. $sqlData = call_user_func(array($_ENV["dbDao"],$sqlType),$sqlString,$resultType);
  82. $stepData4 =$sqlData;
  83. }
  84. }else if($nodeType=="step5"){
  85. //添加计划
  86. if($stepData4){
  87. $consumptionHoursString = explode(',', $this->getParameter("I_consumptionHoursString"));
  88. $quantityString = explode(',', $this->getParameter("I_quantityString"));
  89. $startTime = $this->getParameter("I_startDate");
  90. $doseType = $this->getParameter("I_doseType");
  91. $drugName = $this->getParameter("I_drugName");
  92. $customerUserId = $this->getParameter("M_id","",$boolCheckUser);
  93. $customerFamilyId = $this->getParameter("I_customerFamilyId");
  94. $data_values=null;
  95. $data_values1=null;
  96. for ($x=0; $x<=count($consumptionHoursString)-1; $x++) {
  97. $data_values .= "('".$stepData4['autoid']."','".$startTime." ".$consumptionHoursString[$x]."','".$startTime." ".$consumptionHoursString[$x]."','pending','".$stepData3['autoid']."','".$consumptionHoursString[$x]."','".$quantityString[$x]."','".$doseType."'),";
  98. $data_values1 .="('".$stepData4['autoid']."','服用','".$drugName.$quantityString[$x].$doseType."','".$customerUserId."','".$customerFamilyId."','2','".$startTime." ".$consumptionHoursString[$x].":00','".date("Y-m-d H:i:s", time())."'),";
  99. }
  100. $data_values = substr($data_values,0,-1); //去掉最后一个逗号
  101. $data_values1 = substr($data_values1,0,-1); //去掉最后一个逗号
  102. $sqlString= $sqlString . $data_values;
  103. $sqlString1= "INSERT INTO hz_pushtask (parameter,title,content,customerUserId,customerFamilyId,eventType,pushTime,createTime) VALUES" . $data_values1;
  104. $sqlData = call_user_func(array($_ENV["dbDao"],$sqlType),$sqlString,$resultType);
  105. call_user_func(array($_ENV["dbDao"],"insert"),$sqlString1,"return");
  106. $stepData5 =$sqlData;
  107. }
  108. }
  109. }
  110. }
  111. //最终生成数据
  112. $jsonData= $this->getJson($jsonData,$sqlData,$infoString,$rows,$resultType);
  113. //封装后,返回前台json包
  114. $this->codeJson($jsonData);
  115. }
  116. /**
  117. * 用于在Api引擎中解析数组列表方式
  118. * @param string $funName 方式名
  119. * @param array $funOjb 数组列表
  120. * @return json
  121. */
  122. public function registerVerifyCode($funName,$funObj) {
  123. //不用检测的方法列表
  124. $boolCheckFun = $this->checkFun($funName);
  125. if($boolCheckFun){
  126. //统一验证方式
  127. $boolCheckUser = $this->checkUser();
  128. }else{
  129. //检测方法过滤通过后进入下一步
  130. $boolCheckFun = true;
  131. $boolCheckUser = true;
  132. }
  133. //用于生成返回前台验证时间戳和用户token
  134. $jsonData = $this->getDataToken($boolCheckUser);
  135. $sqlString = "SELECT COUNT(1) as rows FROM hz_verifysmscode t WHERE t.phone='{I_phone}' and type=0 AND DATE(t.createtime)=DATE(SYSDATE())";
  136. $sqlString= $this->getReplace("I_phone",$sqlString,$sqlData,$nodeType,$boolCheckUser);
  137. $rows = call_user_func(array($_ENV["dbDao"],"select"),$sqlString,"entity");
  138. if(intval($rows['rows'])<5){
  139. //进入流程处理
  140. if($boolCheckFun && $boolCheckUser){
  141. foreach ($funObj as $key => $json) {
  142. $json = json_decode($json);
  143. $nodeType = $json->nodeType;
  144. $sqlType = $json->sqlType;
  145. $parameter = $json->parameter;
  146. $sqlString = $json->sqlString;
  147. $resultType = $json->resultType;
  148. $infoString = $json->infoString;
  149. $sqlString= $this->getReplace($parameter,$sqlString,$sqlData,$nodeType,$boolCheckUser);
  150. $sqlData = call_user_func(array($_ENV["dbDao"],$sqlType),$sqlString,$resultType);
  151. if(!$sqlData){break;}
  152. }
  153. //发送短信
  154. if($sqlData)
  155. {
  156. $smsApi =C('SmsApi');
  157. $smsStr ="【南方医院】".$sqlData['code']."(注册验证码),请在20分钟内完成注册。如非本人操作,请忽略。";
  158. $url =$smsApi."&mobile=".$sqlData['phone']."&content=".$smsStr."&ext=1";
  159. $result = call_user_func(array($_ENV["commonClass"],"send_get"),$url);
  160. $sqlString = "update hz_verifysmscode set status='$result' where id='".$sqlData['id']."'";
  161. call_user_func(array($_ENV["dbDao"],"update"),$sqlString,"exesql");
  162. $sqlData = array("return"=>"true");
  163. }
  164. }
  165. }else{
  166. $infoString = "注册验证码一天只能发5条,请明天再试。";
  167. }
  168. //最终生成数据
  169. $jsonData= $this->getJson($jsonData,$sqlData,$infoString,$rows,$resultType);
  170. //封装后,返回前台json包
  171. $this->codeJson($jsonData);
  172. }
  173. /**
  174. * 用于在Api引擎中解析数组列表方式
  175. * @param string $funName 方式名
  176. * @param array $funOjb 数组列表
  177. * @return json
  178. */
  179. public function resetPwdVerifyCode($funName,$funObj) {
  180. //不用检测的方法列表
  181. $boolCheckFun = $this->checkFun($funName);
  182. if($boolCheckFun){
  183. //统一验证方式
  184. $boolCheckUser = $this->checkUser();
  185. }else{
  186. //检测方法过滤通过后进入下一步
  187. $boolCheckFun = true;
  188. $boolCheckUser = true;
  189. }
  190. //用于生成返回前台验证时间戳和用户token
  191. $jsonData = $this->getDataToken($boolCheckUser);
  192. $sqlString = "SELECT COUNT(1) as rows FROM hz_verifysmscode t WHERE t.phone='{I_phone}' and type=1 AND DATE(t.createtime)=DATE(SYSDATE())";
  193. $sqlString= $this->getReplace("I_phone",$sqlString,$sqlData,$nodeType,$boolCheckUser);
  194. $rows = call_user_func(array($_ENV["dbDao"],"select"),$sqlString,"entity");
  195. if(intval($rows['rows'])<5){
  196. //进入流程处理
  197. if($boolCheckFun && $boolCheckUser){
  198. foreach ($funObj as $key => $json) {
  199. $json = json_decode($json);
  200. $nodeType = $json->nodeType;
  201. $sqlType = $json->sqlType;
  202. $parameter = $json->parameter;
  203. $sqlString = $json->sqlString;
  204. $resultType = $json->resultType;
  205. $infoString = $json->infoString;
  206. $sqlString= $this->getReplace($parameter,$sqlString,$sqlData,$nodeType,$boolCheckUser);
  207. $sqlData = call_user_func(array($_ENV["dbDao"],$sqlType),$sqlString,$resultType);
  208. if(!$sqlData){break;}
  209. }
  210. //发送短信
  211. if($sqlData)
  212. {
  213. $smsApi =C('SmsApi');
  214. $smsStr ="【南方医院】".$sqlData['code']."(重置密码验证码),请在20分钟内完成重置密码。如非本人操作,请忽略。";
  215. $url =$smsApi."&mobile=".$sqlData['phone']."&content=".$smsStr."&ext=1";
  216. $result = call_user_func(array($_ENV["commonClass"],"send_get"),$url);
  217. $sqlString = "update hz_verifysmscode set status='$result' where id='".$sqlData['id']."'";
  218. call_user_func(array($_ENV["dbDao"],"update"),$sqlString,"exesql");
  219. $sqlData = array("return"=>"true");
  220. }
  221. }
  222. }else{
  223. $infoString = "重置密码验证码一天只能发5条,请明天再试。";
  224. }
  225. //最终生成数据
  226. $jsonData= $this->getJson($jsonData,$sqlData,$infoString,$rows,$resultType);
  227. //封装后,返回前台json包
  228. $this->codeJson($jsonData);
  229. }
  230. /**
  231. * 用于在Api引擎中解析数组列表方式
  232. * @param string $funName 方式名
  233. * @param array $funOjb 数组列表
  234. * @return json
  235. */
  236. public function appointsOrder($funName,$funObj) {
  237. //不用检测的方法列表
  238. $boolCheckFun = $this->checkFun($funName);
  239. if($boolCheckFun){
  240. //统一验证方式
  241. $boolCheckUser = $this->checkUser();
  242. }else{
  243. //检测方法过滤通过后进入下一步
  244. $boolCheckFun = true;
  245. $boolCheckUser = true;
  246. }
  247. //用于生成返回前台验证时间戳和用户token
  248. $jsonData = $this->getDataToken($boolCheckUser);
  249. //用于生成返回医院HisUrl和Appkey
  250. $hisApi = $this->checkHisApi();
  251. //进入流程处理
  252. if($boolCheckFun && $boolCheckUser && $hisApi){
  253. //检测本地有没有卡
  254. $sqlString = "SELECT COUNT(1) as rows FROM hz_customercard WHERE hospitalId='{I_hospitalId}' AND customerFamilyId ='{I_customerFamilyId}'";
  255. $sqlString= $this->getReplace("I_hospitalId,I_customerFamilyId",$sqlString,$sqlData,$nodeType,$boolCheckUser);
  256. $rows = call_user_func(array($_ENV["dbDao"],"select"),$sqlString,"entity");
  257. if(intval($rows['rows'])>=1)
  258. {
  259. //一天一个医院只能挂号两条
  260. $sqlString = "SELECT COUNT(1) as rows FROM hz_appointsorder t WHERE t.hospitalId='{I_hospitalId}' and t.regDate='{I_regDate}' AND t.customerFamilyId='{I_customerFamilyId}' AND t.resultCode='0' AND t.cancelFlag='1' ";
  261. $sqlString= $this->getReplace("I_hospitalId,I_regDate,I_customerFamilyId",$sqlString,$sqlData,$nodeType,$boolCheckUser);
  262. $rows = call_user_func(array($_ENV["dbDao"],"select"),$sqlString,"entity");
  263. if(intval($rows['rows'])<2){
  264. //一天一个医院只能挂号两条
  265. $sqlString = "SELECT COUNT(1) as rows FROM hz_appointsorder t WHERE t.hospitalId='{I_hospitalId}' and t.deptId='{I_deptId}' and t.doctorId='{I_doctorId}' and t.regDate='{I_regDate}' AND t.customerFamilyId='{I_customerFamilyId}' AND t.resultCode='0' AND t.cancelFlag='1' ";
  266. $sqlString= $this->getReplace("I_hospitalId,I_deptId,I_doctorId,I_regDate,I_customerFamilyId",$sqlString,$sqlData,$nodeType,$boolCheckUser);
  267. $rows = call_user_func(array($_ENV["dbDao"],"select"),$sqlString,"entity");
  268. if(intval($rows['rows'])<1){
  269. foreach ($funObj as $key => $json) {
  270. $json = json_decode($json);
  271. $nodeType = $json->nodeType;
  272. $parameter = $json->parameter;
  273. $sqlType = $json->sqlType;
  274. $xmlString = $json->xmlString;
  275. $resultType = $json->resultType;
  276. $dataType = $json->dataType;
  277. $sqlString = $json->sqlString;
  278. $funcName = $json->funcName;
  279. $replaceXmlData = $json->replaceXmlData;
  280. $returnXmlData = $json->returnXmlData;
  281. $infoString =$json->infoString;
  282. $isPass = $json->isPass;
  283. if($nodeType=="sql"){
  284. $sqlString= $this->getReplace($parameter,$sqlString,$sqlData,$nodeType,$boolCheckUser);
  285. $sqlData = call_user_func(array($_ENV["dbDao"],$sqlType),$sqlString,$resultType);
  286. if($isPass=="pass"){
  287. if($sqlData){
  288. $sqlData="";
  289. break;
  290. }
  291. }else{
  292. if(!$sqlData){break;}
  293. }
  294. if($dataType=="add"){
  295. $tempData[] =$sqlData;
  296. $sqlData = $tempData =array_merge($tempData, $sqlData);
  297. }
  298. }else if($nodeType=="xml"){
  299. //先生成xml,把变量转入
  300. $postData= $this->getReplace($parameter,$xmlString,$sqlData,$nodeType,$boolCheckUser);
  301. $postUrl = $this->hisApiReplace($hisApi['hisUrl'],$hisApi['appKey'],$funcName);
  302. $returnXml = call_user_func(array($_ENV["commonClass"],"sendDataByCurl"),$postUrl,$postData);
  303. //如果为空,则返回HIS的报错
  304. if(empty($returnXml)){
  305. $sqlData = "";
  306. $infoString ="服务器连接返回内容出错";
  307. }else if(strval($returnXml ->resultCode)=="1"){
  308. $sqlData = "";
  309. $infoString = strval($returnXml ->resultDesc);
  310. }else {
  311. $sqlData = $this->xmlDataReplace($returnXml,$replaceXmlData,$returnXmlData);
  312. if($dataType=="add"){
  313. $tempData[] =$sqlData;
  314. $sqlData = $tempData =array_merge($tempData, $sqlData);
  315. }
  316. }
  317. if(!$sqlData){break;}
  318. }
  319. }
  320. }else{
  321. $infoString = "同个医生当天只能挂1个号";
  322. }
  323. }else{
  324. $infoString = "同个医院当天只能挂2个号";
  325. }
  326. }else{
  327. //检测本地预约次数1次
  328. $sqlString = "SELECT COUNT(1) as rows FROM hz_appointsorder WHERE hospitalId='{I_hospitalId}' AND customerFamilyId ='{I_customerFamilyId}' and resultCode='0'";
  329. $sqlString= $this->getReplace("I_hospitalId,I_customerFamilyId",$sqlString,$sqlData,$nodeType,$boolCheckUser);
  330. $rows = call_user_func(array($_ENV["dbDao"],"select"),$sqlString,"entity");
  331. if(intval($rows['rows'])<1){
  332. //HIS验证用户名
  333. $sqlString = "SELECT trueName,idNo,address,sex,phone,birthDay,nation FROM hz_customerfamily WHERE id ='{I_customerFamilyId}'";
  334. $sqlString= $this->getReplace("I_customerFamilyId",$sqlString,$sqlData,$nodeType,$boolCheckUser);
  335. $data = call_user_func(array($_ENV["dbDao"],"select"),$sqlString,"entity");
  336. $xmlString ="<?xml version=\"1.0\" encoding=\"UTF-8\" ?><req><hospitalId>{I_hospitalId}</hospitalId><userIdCard>{D_idNo}</userIdCard><username>{D_trueName}</username></req>";
  337. $postData= $this->getReplace("I_hospitalId,D_idNo,D_trueName",$xmlString,$data,$nodeType,$boolCheckUser);
  338. $postUrl = $this->hisApiReplace($hisApi['hisUrl'],$hisApi['appKey'],"confirmPatient");
  339. $returnXml = call_user_func(array($_ENV["commonClass"],"sendDataByCurl"),$postUrl,$postData);
  340. //如果为空,则返回HIS的报错
  341. if(empty($returnXml)){
  342. $infoString ="服务器连接返回内容出错";
  343. }else{
  344. $xmlData = $this->xmlDataReplace($returnXml,"cardId,patientId","one");
  345. if(!empty($xmlData["cardId"]))
  346. {
  347. //HIS验证用户名绑定
  348. $sqlString = "insert into hz_customercard (customerFamilyId,hospitalId,cardType,cardId,patientId,createTime) VALUES ('{I_customerFamilyId}','{I_hospitalId}','1','{D_cardId}','{D_patientId}','{F_timenow}')";
  349. $sqlString= $this->getReplace("I_customerFamilyId,I_hospitalId,D_cardId,D_patientId,F_timenow",$sqlString,$xmlData,$nodeType,$boolCheckUser);
  350. $data = call_user_func(array($_ENV["dbDao"],"insert"),$sqlString,"entity");
  351. foreach ($funObj as $key => $json) {
  352. $json = json_decode($json);
  353. $nodeType = $json->nodeType;
  354. $parameter = $json->parameter;
  355. $sqlType = $json->sqlType;
  356. $xmlString = $json->xmlString;
  357. $resultType = $json->resultType;
  358. $dataType = $json->dataType;
  359. $sqlString = $json->sqlString;
  360. $funcName = $json->funcName;
  361. $replaceXmlData = $json->replaceXmlData;
  362. $returnXmlData = $json->returnXmlData;
  363. $infoString =$json->infoString;
  364. $isPass = $json->isPass;
  365. if($nodeType=="sql"){
  366. $sqlString= $this->getReplace($parameter,$sqlString,$sqlData,$nodeType,$boolCheckUser);
  367. $sqlData = call_user_func(array($_ENV["dbDao"],$sqlType),$sqlString,$resultType);
  368. if($isPass=="pass"){
  369. if($sqlData){
  370. $sqlData="";
  371. break;
  372. }
  373. }else{
  374. if(!$sqlData){break;}
  375. }
  376. if($dataType=="add"){
  377. $tempData[] =$sqlData;
  378. $sqlData = $tempData =array_merge($tempData, $sqlData);
  379. }
  380. }else if($nodeType=="xml"){
  381. //先生成xml,把变量转入
  382. $postData= $this->getReplace($parameter,$xmlString,$sqlData,$nodeType,$boolCheckUser);
  383. $postUrl = $this->hisApiReplace($hisApi['hisUrl'],$hisApi['appKey'],$funcName);
  384. $returnXml = call_user_func(array($_ENV["commonClass"],"sendDataByCurl"),$postUrl,$postData);
  385. //如果为空,则返回HIS的报错
  386. if(empty($returnXml)){
  387. $sqlData = "";
  388. $infoString ="服务器连接返回内容出错";
  389. }else if(strval($returnXml ->resultCode)=="1"){
  390. $sqlData = "";
  391. $infoString = strval($returnXml ->resultDesc);
  392. }else {
  393. $sqlData = $this->xmlDataReplace($returnXml,$replaceXmlData,$returnXmlData);
  394. if($dataType=="add"){
  395. $tempData[] =$sqlData;
  396. $sqlData = $tempData =array_merge($tempData, $sqlData);
  397. }
  398. }
  399. if(!$sqlData){break;}
  400. }
  401. }
  402. }else{
  403. //发送HIS挂号
  404. $funObj = C("appointsOrderNew");
  405. foreach ($funObj as $key => $json) {
  406. $json = json_decode($json);
  407. $nodeType = $json->nodeType;
  408. $parameter = $json->parameter;
  409. $sqlType = $json->sqlType;
  410. $xmlString = $json->xmlString;
  411. $resultType = $json->resultType;
  412. $dataType = $json->dataType;
  413. $sqlString = $json->sqlString;
  414. $funcName = $json->funcName;
  415. $replaceXmlData = $json->replaceXmlData;
  416. $returnXmlData = $json->returnXmlData;
  417. $infoString =$json->infoString;
  418. $isPass = $json->isPass;
  419. if($nodeType=="sql"){
  420. $sqlString= $this->getReplace($parameter,$sqlString,$sqlData,$nodeType,$boolCheckUser);
  421. $sqlData = call_user_func(array($_ENV["dbDao"],$sqlType),$sqlString,$resultType);
  422. if($isPass=="pass"){
  423. if($sqlData){
  424. $sqlData="";
  425. break;
  426. }
  427. }else{
  428. if(!$sqlData){break;}
  429. }
  430. if($dataType=="add"){
  431. $tempData[] =$sqlData;
  432. $sqlData = $tempData =array_merge($tempData, $sqlData);
  433. }
  434. }else if($nodeType=="xml"){
  435. //如果病人不为空
  436. if(empty($xmlData["patientId"])){
  437. //2016年10月31日10:31:12
  438. //如果卡为空,则进建档方式
  439. //建档成功后,用户病人ID接口
  440. //Log::posthis("QuerySchedule:req2\r\n"."*c".call_user_func(array($_ENV["commonClass"],"timestamp")));
  441. $xmlPatString ="<?xml version=\"1.0\" encoding=\"UTF-8\" ?><req><hospitalId>{I_hospitalId}</hospitalId><userIdCard>{D_idNo}</userIdCard><username>{D_trueName}</username><sex>{D_sex}</sex><birthDay>{D_birthDay}</birthDay><phone>{D_phone}</phone><nation>{D_nation}</nation><address>{D_address}</address></req>";
  442. $postData= $this->getReplace("I_hospitalId,D_idNo,D_trueName,D_sex,D_birthDay,D_phone,D_nation,D_address",$xmlPatString,$data,$nodeType,$boolCheckUser);
  443. $postUrl = $this->hisApiReplace($hisApi['hisUrl'],$hisApi['appKey'],"createPatient");
  444. $returnXml = call_user_func(array($_ENV["commonClass"],"sendDataByCurl"),$postUrl,$postData);
  445. if(empty($returnXml)){
  446. $sqlData = "";
  447. $infoString ="服务器连接返回内容出错";
  448. }else if(strval($returnXml ->resultCode)=="1"){
  449. $sqlData = "";
  450. $infoString = strval($returnXml ->resultDesc);
  451. }else {
  452. //把病人ID加入
  453. $tempPatData= array("patientId" => $returnXml ->patientId );
  454. $tempData[] =$sqlData;
  455. $sqlData = $tempData =array_merge($tempData, $tempPatData);
  456. }
  457. }else{
  458. //把病人ID加入
  459. $tempPatData = array("patientId" => $xmlData["patientId"]);
  460. $tempData[] =$sqlData;
  461. $sqlData = $tempData =array_merge($tempData, $tempPatData);
  462. }
  463. //先生成xml,把变量转入
  464. $postData= $this->getReplace($parameter,$xmlString,$sqlData,$nodeType,$boolCheckUser);
  465. $postUrl = $this->hisApiReplace($hisApi['hisUrl'],$hisApi['appKey'],$funcName);
  466. $returnXml = call_user_func(array($_ENV["commonClass"],"sendDataByCurl"),$postUrl,$postData);
  467. //如果为空,则返回HIS的报错
  468. if(empty($returnXml)){
  469. $sqlData = "";
  470. $infoString ="服务器连接返回内容出错";
  471. }else if(strval($returnXml ->resultCode)=="1"){
  472. $sqlData = "";
  473. $infoString = strval($returnXml ->resultDesc);
  474. }else {
  475. $tempPatData = $this->xmlDataReplace($returnXml,$replaceXmlData,$returnXmlData);
  476. if($dataType=="add"){
  477. $tempData[] =$sqlData;
  478. $sqlData = $tempData =array_merge($tempData, $tempPatData);
  479. }
  480. }
  481. if(!$sqlData){break;}
  482. }
  483. }
  484. }
  485. }
  486. }else{
  487. $infoString = "非首诊须绑定诊疗卡";
  488. }
  489. }
  490. }
  491. //最终生成数据
  492. $jsonData= $this->getJson($jsonData,$sqlData,$infoString,0,$resultType);
  493. //封装后,返回前台json包
  494. $this->codeJson($jsonData);
  495. }
  496. /**
  497. * 用于在Api引擎中解析数组列表方式
  498. * @param string $funName 方式名
  499. * @param array $funOjb 数组列表
  500. * @return json
  501. */
  502. public function getDoctorBookingScheduleSyn($funName,$funObj) {
  503. //不用检测的方法列表
  504. $boolCheckFun = $this->checkFun($funName);
  505. if($boolCheckFun){
  506. //统一验证方式
  507. $boolCheckUser = $this->checkUser();
  508. }else{
  509. //检测方法过滤通过后进入下一步
  510. $boolCheckFun = true;
  511. $boolCheckUser = true;
  512. }
  513. //用于生成返回前台验证时间戳和用户token
  514. $jsonData = $this->getDataToken($boolCheckUser);
  515. //用于生成返回医院HisUrl和Appkey
  516. $hisApi = $this->checkHisApi();
  517. //进入流程处理
  518. if($boolCheckFun && $boolCheckUser && $hisApi){
  519. foreach ($funObj as $key => $json) {
  520. //$json = json_decode(iconv("GB2312","UTF-8//IGNORE",$json));
  521. $json = json_decode($json);
  522. $nodeType = $json->nodeType;
  523. $parameter = $json->parameter;
  524. $sqlType = $json->sqlType;
  525. $xmlString = $json->xmlString;
  526. $resultType = $json->resultType;
  527. $dataType = $json->dataType;
  528. $sqlString = $json->sqlString;
  529. $funcName = $json->funcName;
  530. $replaceXmlData = $json->replaceXmlData;
  531. $returnXmlData = $json->returnXmlData;
  532. $infoString =$json->infoString;
  533. $isPass = $json->isPass;
  534. if($nodeType=="sql"){
  535. $sqlString= $this->getReplace($parameter,$sqlString,$sqlData,$nodeType,$boolCheckUser);
  536. $sqlData = call_user_func(array($_ENV["dbDao"],$sqlType),$sqlString,$resultType);
  537. if($isPass=="pass"){
  538. if($sqlData){
  539. $sqlData="";
  540. break;
  541. }
  542. }else{
  543. if(!$sqlData){break;}
  544. }
  545. if($dataType=="add"){
  546. $tempData[] =$sqlData;
  547. $sqlData = $tempData =array_merge($tempData, $sqlData);
  548. }
  549. }else if($nodeType=="xml"){
  550. $postData= $this->getReplace($parameter,$xmlString,$sqlData,$nodeType,$boolCheckUser);
  551. $postUrl = $this->hisApiReplace($hisApi['hisUrl'],$hisApi['appKey'],$funcName);
  552. $returnXml = call_user_func(array($_ENV["commonClass"],"sendDataByCurl"),$postUrl,$postData);
  553. //如果为空,则返回HIS的报错
  554. if(empty($returnXml)){
  555. $sqlData = "";
  556. $infoString ="服务器连接返回内容出错";
  557. }else if(strval($returnXml ->resultCode)=="1"){
  558. $sqlData = "";
  559. $infoString = strval($returnXml ->resultDesc);
  560. }else {
  561. /* 原来的
  562. foreach($returnXml as $key=>$ri){
  563. $TimeRegInfoList = $ri->TimeRegInfoList;
  564. foreach($TimeRegInfoList as $key=>$tril){
  565. $timeRegInfo = $tril->timeRegInfo;
  566. $replaceXmlDataTemp = null;
  567. foreach($timeRegInfo as $key=>$tri){
  568. $sqlData[] = array(
  569. 'hospitalId' => I("hospitalId"),
  570. 'deptId' => I("deptId"),
  571. 'doctorId' => strval($ri->doctorId),
  572. 'regDate' => strval($tril->regDate),
  573. 'regWeekDay' => strval($tril->regWeekDay),
  574. 'timeFlag' => strval($tri->timeFlag),
  575. 'regTotalCount' => strval($tri->regTotalCount),
  576. 'regLeaveCount' => strval($tri->regleaveCount),
  577. 'regFee' => strval($tri->regFee),
  578. 'treatFee' => strval($tri->treatFee)
  579. );
  580. }
  581. }
  582. }
  583. */
  584. $Schedule = $returnXml->Schedules->Schedule;
  585. foreach($Schedule as $key=>$v){
  586. if(strval($v->ScheduleStatus)=="N" || strval($v->ScheduleStatus)=="A"){
  587. $timeFlag = "";
  588. if(strval($v->SessionCode)=="S")
  589. {
  590. $timeFlag ="1";
  591. }else if(strval($v->SessionCode)=="X"){
  592. $timeFlag ="2";
  593. }else if(strval($v->SessionCode)=="W"){
  594. $timeFlag ="3";
  595. }
  596. $sqlData[] = array(
  597. 'hospitalId' => I("hospitalId"),
  598. 'deptId' => I("deptId"),
  599. 'doctorId' => strval($v->DoctorCode),
  600. 'regDate' => strval($v->ServiceDate),
  601. 'regWeekDay' => strval($v->WeekDay),
  602. 'timeFlag' => $timeFlag,
  603. 'regTotalCount' => strval($v->AvailableTotalNum),
  604. 'regLeaveCount' => strval($v->AvailableLeftNum),
  605. 'regFee' => (float)(strval($v->RegFee))*100,
  606. 'treatFee' => (float)(strval($v->CheckupFee))*100
  607. );
  608. }
  609. }
  610. if($dataType=="add"){
  611. $tempData[] =$sqlData;
  612. $sqlData = $tempData =array_merge($tempData, $sqlData);
  613. }
  614. }
  615. if(!$sqlData){break;}
  616. }
  617. }
  618. }
  619. //最终生成数据
  620. $jsonData= $this->getJson($jsonData,$sqlData,$infoString,0,$resultType);
  621. //封装后,返回前台json包
  622. $this->codeJson($jsonData);
  623. }
  624. /**
  625. * 用于在Api引擎中解析数组列表方式
  626. * @param string $funName 方式名
  627. * @param array $funOjb 数组列表
  628. * @return json
  629. */
  630. public function getGuideList($funName,$funObj) {
  631. //不用检测的方法列表
  632. $boolCheckFun = $this->checkFun($funName);
  633. if($boolCheckFun){
  634. //统一验证方式
  635. $boolCheckUser = $this->checkUser();
  636. }else{
  637. //检测方法过滤通过后进入下一步
  638. $boolCheckFun = true;
  639. $boolCheckUser = true;
  640. }
  641. //用于生成返回前台验证时间戳和用户token
  642. $jsonData = $this->getDataToken($boolCheckUser);
  643. //用于生成返回医院HisUrl和Appkey
  644. $hisApi = $this->checkHisApi();
  645. //进入流程处理
  646. if($boolCheckFun && $boolCheckUser && $hisApi){
  647. //print_r($funObj);
  648. foreach ($funObj as $key => $json) {
  649. //$json = json_decode(iconv("GB2312","UTF-8//IGNORE",$json));
  650. $json = json_decode($json);
  651. $nodeType = $json->nodeType;
  652. $parameter = $json->parameter;
  653. $sqlType = $json->sqlType;
  654. $xmlString = $json->xmlString;
  655. $resultType = $json->resultType;
  656. $dataType = $json->dataType;
  657. $sqlString = $json->sqlString;
  658. $funcName = $json->funcName;
  659. $replaceXmlData = $json->replaceXmlData;
  660. $returnXmlData = $json->returnXmlData;
  661. $infoString =$json->infoString;
  662. $isPass = $json->isPass;
  663. if($nodeType=="sql"){
  664. $sqlString= $this->getReplace($parameter,$sqlString,$sqlData,$nodeType,$boolCheckUser);
  665. $sqlData = call_user_func(array($_ENV["dbDao"],$sqlType),$sqlString,$resultType);
  666. if($isPass=="pass"){
  667. if($sqlData){
  668. $sqlData="";
  669. break;
  670. }
  671. }else{
  672. if(!$sqlData){break;}
  673. }
  674. if($dataType=="add"){
  675. $tempData[] =$sqlData;
  676. $sqlData = $tempData =array_merge($tempData, $sqlData);
  677. }
  678. }else if($nodeType=="xml"){
  679. $postData= $this->getReplace($parameter,$xmlString,$sqlData,$nodeType,$boolCheckUser);
  680. $postUrl = $this->hisApiReplace($hisApi['hisUrl'],$hisApi['appKey'],$funcName);
  681. $returnXml = call_user_func(array($_ENV["commonClass"],"sendDataByCurl"),$postUrl,$postData);
  682. //如果为空,则返回HIS的报错
  683. if(empty($returnXml)){
  684. $sqlData = "";
  685. $infoString ="服务器连接返回内容出错";
  686. }else if(strval($returnXml ->resultCode)=="1"){
  687. $sqlData = "";
  688. $infoString = strval($returnXml ->resultDesc);
  689. }else {
  690. $sqlData = "";
  691. $returnXml = $returnXml->invoiceList->invoice;
  692. foreach($returnXml as $key=>$v){
  693. $sqlData[] = array(
  694. 'invoice' => $v
  695. );
  696. }
  697. if($dataType=="add"){
  698. $tempData[] =$sqlData;
  699. $sqlData = $tempData =array_merge($tempData, $sqlData);
  700. }
  701. }
  702. if(!$sqlData){break;}
  703. }
  704. }
  705. }
  706. //最终生成数据
  707. $jsonData= $this->getJson($jsonData,$sqlData,$infoString,0,$resultType);
  708. //封装后,返回前台json包
  709. $this->codeJson($jsonData);
  710. }
  711. }
  712. ?>