BookingController.java 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. package com.yihu.wlyy.web.third;
  2. import com.yihu.wlyy.entity.patient.Patient;
  3. import com.yihu.wlyy.entity.patient.PatientReservation;
  4. import com.yihu.wlyy.logs.BusinessLogs;
  5. import com.yihu.wlyy.service.app.reservation.PatientReservationService;
  6. import com.yihu.wlyy.service.common.account.DoctorService;
  7. import com.yihu.wlyy.service.common.account.PatientService;
  8. import com.yihu.wlyy.service.third.guahao.GuahaoDoctor;
  9. import com.yihu.wlyy.service.third.guahao.GuahaoXMService;
  10. import com.yihu.wlyy.service.third.guahao.GuahaoYihuService;
  11. import com.yihu.wlyy.service.third.guahao.IGuahaoService;
  12. import com.yihu.wlyy.task.PushMsgTask;
  13. import com.yihu.wlyy.util.HttpClientUtil;
  14. import com.yihu.wlyy.util.SystemConf;
  15. import com.yihu.wlyy.web.WeixinBaseController;
  16. import io.swagger.annotations.Api;
  17. import io.swagger.annotations.ApiOperation;
  18. import io.swagger.annotations.ApiParam;
  19. import org.apache.commons.lang3.StringUtils;
  20. import org.apache.http.NameValuePair;
  21. import org.apache.http.message.BasicNameValuePair;
  22. import org.json.JSONArray;
  23. import org.json.JSONObject;
  24. import org.springframework.beans.factory.annotation.Autowired;
  25. import org.springframework.stereotype.Controller;
  26. import org.springframework.web.bind.annotation.RequestMapping;
  27. import org.springframework.web.bind.annotation.RequestMethod;
  28. import org.springframework.web.bind.annotation.RequestParam;
  29. import org.springframework.web.bind.annotation.ResponseBody;
  30. import java.text.SimpleDateFormat;
  31. import java.util.*;
  32. /**
  33. * 预约挂号
  34. *
  35. * @author hzp at 2016-08-30
  36. */
  37. @Controller
  38. @RequestMapping(value = "/third/guahao")
  39. @Api(description = "预约挂号接口")
  40. public class BookingController extends WeixinBaseController {
  41. @Autowired
  42. private GuahaoXMService guahaoXM;
  43. @Autowired
  44. private GuahaoYihuService guahaoYihu;
  45. @Autowired
  46. private PatientReservationService patientReservationService;
  47. @Autowired
  48. private PatientService patientService;
  49. @Autowired
  50. private DoctorService doctorService;
  51. /**
  52. * 根据城市编码获取相应挂号服务
  53. *
  54. * @return
  55. */
  56. private IGuahaoService getService(String city) {
  57. IGuahaoService re = guahaoYihu;
  58. if (city != null && city.equals("350200")) {
  59. re = guahaoXM;
  60. }
  61. return re;
  62. }
  63. /**
  64. * 发送短信参数
  65. */
  66. private List<NameValuePair> buildSmsParams(String content, String mobile) {
  67. List<NameValuePair> params = new ArrayList<NameValuePair>();
  68. params.add(new BasicNameValuePair("SpCode", SystemConf.getInstance().getSmsCode()));
  69. params.add(new BasicNameValuePair("LoginName", SystemConf.getInstance().getSmsName()));
  70. params.add(new BasicNameValuePair("Password", SystemConf.getInstance().getSmsPassword()));
  71. params.add(new BasicNameValuePair("MessageContent", content));
  72. params.add(new BasicNameValuePair("UserNumber", mobile));
  73. params.add(new BasicNameValuePair("SerialNumber", String.valueOf(System.currentTimeMillis())));
  74. params.add(new BasicNameValuePair("ScheduleTime", ""));
  75. params.add(new BasicNameValuePair("f", "1"));
  76. return params;
  77. }
  78. private JSONObject toJson(String result) {
  79. JSONObject json = new JSONObject();
  80. try {
  81. String[] temps = result.split("&");
  82. for (String temp : temps) {
  83. if (temp.split("=").length != 2) {
  84. continue;
  85. }
  86. String key = temp.split("=")[0];
  87. String value = temp.split("=")[1];
  88. json.put(key, value);
  89. }
  90. } catch (Exception e) {
  91. e.printStackTrace();
  92. }
  93. return json;
  94. }
  95. /**
  96. * 获取时间
  97. */
  98. private static Date getMonthBefore(Date d, int month) {
  99. Calendar now = Calendar.getInstance();
  100. now.setTime(d);
  101. now.set(Calendar.MONTH, now.get(Calendar.MONTH) - month);
  102. return now.getTime();
  103. }
  104. @RequestMapping(value = "GetOrgList", method = RequestMethod.POST)
  105. @ResponseBody
  106. @ApiOperation("获取机构列表")
  107. public String GetOrgList(@ApiParam(name = "city", value = "城市编码", defaultValue = "350200")
  108. @RequestParam(value = "city", required = true) String city,
  109. @ApiParam(name = "filter", value = "过滤条件", defaultValue = "")
  110. @RequestParam(value = "filter", required = false) String filter,
  111. @ApiParam(name = "type", value = "类型", defaultValue = "1")
  112. @RequestParam(value = "type", required = false) String type,
  113. @ApiParam(name = "pageIndex", value = "第几页", defaultValue = "")
  114. @RequestParam(value = "pageIndex", required = false) Integer pageIndex,
  115. @ApiParam(name = "pageSize", value = "每页记录数", defaultValue = "")
  116. @RequestParam(value = "pageSize", required = false) Integer pageSize) {
  117. try {
  118. List<Map<String, String>> list = getService(city).GetOrgList(city, filter, type, pageIndex, pageSize);
  119. return write(200, "获取机构列表成功!", "data", list);
  120. } catch (Exception e) {
  121. return error(-1, e.getMessage());
  122. }
  123. }
  124. @RequestMapping(value = "GetOrgDepList", method = RequestMethod.POST)
  125. @ResponseBody
  126. @ApiOperation("获取科室接口")
  127. public String GetOrgDepList(@ApiParam(name = "city", value = "城市编码", defaultValue = "350200")
  128. @RequestParam(value = "city", required = true) String city,
  129. @ApiParam(name = "hospitalId", value = "医院ID", defaultValue = "350211A1001")
  130. @RequestParam(value = "hospitalId", required = true) String hospitalId,
  131. @ApiParam(name = "filter", value = "过滤条件", defaultValue = "")
  132. @RequestParam(value = "filter", required = false) String filter,
  133. @ApiParam(name = "pageIndex", value = "第几页", defaultValue = "")
  134. @RequestParam(value = "pageIndex", required = false) Integer pageIndex,
  135. @ApiParam(name = "pageSize", value = "每页记录数", defaultValue = "")
  136. @RequestParam(value = "pageSize", required = false) Integer pageSize) {
  137. try {
  138. List<Map<String, String>> list = getService(city).GetOrgDepList(hospitalId, filter, pageIndex, pageSize);
  139. return write(200, "获取科室列表成功!", "data", list);
  140. } catch (Exception e) {
  141. return error(-1, e.getMessage());
  142. }
  143. }
  144. @RequestMapping(value = "GetDoctorList", method = RequestMethod.POST)
  145. @ResponseBody
  146. @ApiOperation("获取医生接口")
  147. public String GetDoctorList(@ApiParam(name = "city", value = "城市编码", defaultValue = "350200")
  148. @RequestParam(value = "city", required = true) String city,
  149. @ApiParam(name = "hospitalId", value = "医院ID", defaultValue = "350211A1001")
  150. @RequestParam(value = "hospitalId", required = true) String hospitalId,
  151. @ApiParam(name = "hosDeptId", value = "科室ID", defaultValue = "1040610")
  152. @RequestParam(value = "hosDeptId", required = true) String hosDeptId,
  153. @ApiParam(name = "filter", value = "过滤条件", defaultValue = "")
  154. @RequestParam(value = "filter", required = false) String filter,
  155. @ApiParam(name = "pageIndex", value = "第几页", defaultValue = "")
  156. @RequestParam(value = "pageIndex", required = false) Integer pageIndex,
  157. @ApiParam(name = "pageSize", value = "每页记录数", defaultValue = "")
  158. @RequestParam(value = "pageSize", required = false) Integer pageSize) {
  159. try {
  160. List<GuahaoDoctor> list = getService(city).GetDoctorList(hospitalId, hosDeptId, filter, pageIndex, pageSize);
  161. return write(200, "获取医生列表成功!", "data", list);
  162. } catch (Exception e) {
  163. return error(-1, e.getMessage());
  164. }
  165. }
  166. @RequestMapping(value = "GetDoctorArrange", method = RequestMethod.POST)
  167. @ResponseBody
  168. @ApiOperation("获取医生排班接口(包含排班详细)")
  169. public String GetDoctorArrange(@ApiParam(name = "city", value = "城市编码", defaultValue = "350200")
  170. @RequestParam(value = "city", required = true) String city,
  171. @ApiParam(name = "hospitalId", value = "医院ID", defaultValue = "350211G1102")
  172. @RequestParam(value = "hospitalId", required = true) String hospitalId,
  173. @ApiParam(name = "hosDeptId", value = "科室ID", defaultValue = "3020001")
  174. @RequestParam(value = "hosDeptId", required = true) String hosDeptId,
  175. @ApiParam(name = "doctorId", value = "医生ID", defaultValue = "AA2")
  176. @RequestParam(value = "doctorId", required = true) String doctorId) {
  177. try {
  178. List<Map<String, Object>> list = getService(city).GetDoctorArrange(hospitalId, hosDeptId, doctorId);
  179. return write(200, "获取医生排班成功!", "data", list);
  180. } catch (Exception e) {
  181. return error(-1, e.getMessage());
  182. }
  183. }
  184. @RequestMapping(value = "GetDoctorArrangeSimple", method = RequestMethod.POST)
  185. @ResponseBody
  186. @ApiOperation("获取医生排班接口(一级)")
  187. public String GetDoctorArrangeSimple(@ApiParam(name = "city", value = "城市编码", defaultValue = "350200")
  188. @RequestParam(value = "city", required = true) String city,
  189. @ApiParam(name = "hospitalId", value = "医院ID", defaultValue = "350211A1001")
  190. @RequestParam(value = "hospitalId", required = true) String hospitalId,
  191. @ApiParam(name = "hosDeptId", value = "科室ID", defaultValue = "1010210")
  192. @RequestParam(value = "hosDeptId", required = true) String hosDeptId,
  193. @ApiParam(name = "doctorId", value = "医生ID", defaultValue = "03101")
  194. @RequestParam(value = "doctorId", required = true) String doctorId) {
  195. try {
  196. List<Map<String, String>> list = getService(city).GetDoctorArrangeSimple(hospitalId, hosDeptId, doctorId);
  197. return write(200, "获取医生排班成功!", "data", list);
  198. } catch (Exception e) {
  199. return error(-1, e.getMessage());
  200. }
  201. }
  202. @RequestMapping(value = "GetDoctorInfo", method = RequestMethod.POST)
  203. @ResponseBody
  204. @ApiOperation("根据医生编码获取医生详细信息")
  205. public String GetDoctorInfo(@ApiParam(name = "city", value = "城市编码", defaultValue = "350200")
  206. @RequestParam(value = "city", required = true) String city,
  207. @ApiParam(name = "doctorId", value = "医生id", defaultValue = "07101")
  208. @RequestParam(value = "doctorId", required = true) String doctorId,
  209. @ApiParam(name = "hospitalId", value = "医院id", defaultValue = "350211A1001")
  210. @RequestParam(value = "hospitalId", required = true) String hospitalId,
  211. @ApiParam(name = "hosDeptId", value = "科室id", defaultValue = "1040610")
  212. @RequestParam(value = "hosDeptId", required = true) String hosDeptId) {
  213. try {
  214. GuahaoDoctor doctor = getService(city).GetDoctorInfo(doctorId, hospitalId, hosDeptId);
  215. return write(200, "获取医生信息成功!", "data", doctor);
  216. } catch (Exception e) {
  217. return error(-1, e.getMessage());
  218. }
  219. }
  220. @RequestMapping(value = "CreateOrder", method = RequestMethod.POST)
  221. @ResponseBody
  222. @ApiOperation("创建挂号单")
  223. public String CreateOrder(@ApiParam(name = "city", value = "城市编码", defaultValue = "350200")
  224. @RequestParam(value = "city", required = true) String city,
  225. @ApiParam(name = "hospitalId", value = "医院ID", defaultValue = "350211A1001")
  226. @RequestParam(value = "hospitalId", required = true) String hospitalId,
  227. @ApiParam(name = "hospitalName", value = "医院名称", defaultValue = "厦门大学附属第一医院")
  228. @RequestParam(value = "hospitalName", required = true) String hospitalName,
  229. @ApiParam(name = "hosDeptId", value = "科室ID", defaultValue = "1040610")
  230. @RequestParam(value = "hosDeptId", required = true) String hosDeptId,
  231. @ApiParam(name = "hosDeptName", value = "医院科室名称", defaultValue = "儿二科")
  232. @RequestParam(value = "hosDeptName", required = true) String hosDeptName,
  233. @ApiParam(name = "doctorId", value = "医生ID", defaultValue = "07101")
  234. @RequestParam(value = "doctorId", required = true) String doctorId,
  235. @ApiParam(name = "doctorName", value = "医生姓名", defaultValue = "林素莲")
  236. @RequestParam(value = "doctorName", required = true) String doctorName,
  237. @ApiParam(name = "arrangeDate", value = "排班信息", defaultValue = "{\"sectionType\":\"a\",\"startTime\":\"2016-09-02 08:20:00\",\"endTime\":\"2016-09-02 08:30:00\"}")
  238. @RequestParam(value = "arrangeDate", required = true) String arrangeDate,
  239. @ApiParam(name = "patient", value = "患者代码", defaultValue = "01954b2ebbb24a40a05da9d2f5c94795")
  240. @RequestParam(value = "patient", required = true) String patient,
  241. @ApiParam(name = "patientName", value = "患者姓名", defaultValue = "张锦川")
  242. @RequestParam(value = "patientName", required = true) String patientName,
  243. @ApiParam(name = "cardNo", value = "身份证号码", defaultValue = "35052419880511553X")
  244. @RequestParam(value = "cardNo", required = true) String cardNo,
  245. @ApiParam(name = "clinicCard", value = "市民卡号", defaultValue = "D57117706")
  246. @RequestParam(value = "clinicCard", required = true) String clinicCard,
  247. @ApiParam(name = "patientPhone", value = "患者手机", defaultValue = "13950116510")
  248. @RequestParam(value = "patientPhone", required = true) String patientPhone) {
  249. try {
  250. if (StringUtils.isEmpty(patientName)) {
  251. return error(-1, "未设置姓名!");
  252. }
  253. if (StringUtils.isEmpty(cardNo)) {
  254. return error(-1, "未设置身份证号!");
  255. }
  256. if (StringUtils.isEmpty(clinicCard)) {
  257. return error(-1, "未设置社保卡号!");
  258. }
  259. if (StringUtils.isEmpty(patientPhone)) {
  260. return error(-1, "未设置手机号码!");
  261. }
  262. String orderCode = getService(city).CreateOrder(hospitalId, hospitalName, hosDeptId, hosDeptName, doctorId, doctorName, arrangeDate, patient, patientName, cardNo, clinicCard, patientPhone);
  263. //预约发送微信消息
  264. PatientReservation obj = patientReservationService.findByCode(orderCode);
  265. if (obj != null) {
  266. Patient p = patientService.findByCode(obj.getPatient());
  267. String msg = "您成功预约了 " + obj.getOrgName() + " " + obj.getDoctorName() + " " + obj.getStartTime() + " 的号源!";
  268. if (StringUtils.isNotEmpty(p.getOpenid())) {
  269. // 推送消息给微信端
  270. JSONObject json = new JSONObject();
  271. json.put("first", "");
  272. json.put("toUser", p.getCode());
  273. json.put("id", obj.getCode());
  274. json.put("date", obj.getStartTime());
  275. json.put("orgCode", obj.getOrgCode());
  276. json.put("orgName", obj.getOrgName());
  277. json.put("doctorName", obj.getDoctorName());
  278. json.put("deptName", obj.getDeptName());
  279. json.put("remark", p.getName() + ",您好!" + msg);
  280. PushMsgTask.getInstance().putWxMsg(getAccessToken(), 6, p.getOpenid(), p.getName(), json);
  281. }
  282. //发送短信小时
  283. // 调用总部发送信息的接口
  284. //String result = HttpClientUtil.post(SystemConf.getInstance().getSmsUrl(), buildSmsParams(msg, p.getMobile()), "GBK");
  285. //JSONObject json = toJson(result);
  286. // if (json == null) {
  287. // // 发送失败
  288. // throw new Exception("短信发送失败!");
  289. // } else if (json.getInt("result") != 0) {
  290. // return json.getString("description");
  291. // } else {
  292. // //发送成功,保存到数据库
  293. // }
  294. BusinessLogs.info(BusinessLogs.BusinessType.appointment, getUID(), p.getCode(), new JSONObject(obj));
  295. return write(200, "创建挂号单成功!");
  296. } else {
  297. return error(-1, "创建挂号单失败!");
  298. }
  299. } catch (Exception e) {
  300. return error(-1, e.getMessage());
  301. }
  302. }
  303. @RequestMapping(value = "CancelOrder", method = RequestMethod.POST)
  304. @ResponseBody
  305. @ApiOperation("取消挂号单")
  306. public String CancelOrder(@ApiParam(name = "orderId", value = "订单id", defaultValue = "9")
  307. @RequestParam(value = "orderId", required = true) Long orderId) {
  308. try {
  309. //获取订单信息
  310. PatientReservation obj = patientReservationService.findById(orderId);
  311. boolean re = false;
  312. if (obj != null) {
  313. String type = obj.getType();
  314. String code = obj.getCode();
  315. if (type.equals("0")) { //医护网接口
  316. re = guahaoYihu.CancelOrder(code);
  317. } else if (type.equals("1")) //厦门市民健康预约接口
  318. {
  319. re = guahaoXM.CancelOrder(code, obj.getSsc());
  320. }
  321. }
  322. if (re) {
  323. //更新状态
  324. patientReservationService.updateStatus(orderId, 0);
  325. //微信消息
  326. Patient p = patientService.findByCode(obj.getPatient());
  327. if (StringUtils.isNotEmpty(p.getOpenid())) {
  328. JSONObject json = new JSONObject();
  329. json.put("first", "");
  330. json.put("toUser", p.getCode());
  331. json.put("name", obj.getName());
  332. json.put("date", obj.getStartTime());
  333. json.put("doctorName", obj.getDoctorName());
  334. json.put("orgName", obj.getOrgName());
  335. json.put("remark", obj.getName() + ",您好!\n您已取消了" + obj.getStartTime() + "的挂号!");
  336. PushMsgTask.getInstance().putWxMsg(getAccessToken(), 7, p.getOpenid(), obj.getName(), json);
  337. }
  338. return write(200, "取消挂号单成功!");
  339. } else {
  340. return error(-1, "取消挂号单失败!");
  341. }
  342. } catch (Exception e) {
  343. return error(-1, e.getMessage());
  344. }
  345. }
  346. /****************************************** 内网预约 ***************************************************************/
  347. /* @RequestMapping(value = "sendMessage", method = RequestMethod.POST)
  348. @ResponseBody
  349. @ApiOperation("发送短信测试")
  350. public String sendMessage()
  351. {
  352. try {
  353. //发送短信消息,调用总部发送信息的接口
  354. String result = HttpClientUtil.post(SystemConf.getInstance().getSmsUrl(), buildSmsParams("测试", "13559207522"), "GBK");
  355. System.out.print(result);
  356. *//*JSONObject json = toJson(result);
  357. JSONObject result = smsService.sendMsg("13559207522", "测试");
  358. if (result != null && result.getInt("result") != 0) {
  359. System.out.print("短信提醒失败!(原因:" + result.getString("description") + ")");
  360. }*//*
  361. return error(-1, "创建挂号单失败!"+result);
  362. }
  363. catch (Exception e) {
  364. return error(-1, e.getMessage());
  365. }
  366. }*/
  367. @RequestMapping(value = "CreateOrderByDoctor", method = RequestMethod.POST)
  368. @ResponseBody
  369. @ApiOperation("(内网)转诊预约挂号")
  370. public String CreateOrderByDoctor(@ApiParam(name = "hospitalId", value = "医院ID", defaultValue = "350211A1001")
  371. @RequestParam(value = "hospitalId", required = true) String hospitalId,
  372. @ApiParam(name = "hospitalName", value = "医院名称", defaultValue = "厦门大学附属第一医院")
  373. @RequestParam(value = "hospitalName", required = true) String hospitalName,
  374. @ApiParam(name = "hosDeptId", value = "科室ID", defaultValue = "1011610")
  375. @RequestParam(value = "hosDeptId", required = true) String hosDeptId,
  376. @ApiParam(name = "hosDeptName", value = "医院科室名称", defaultValue = "内分泌糖尿病科门诊")
  377. @RequestParam(value = "hosDeptName", required = true) String hosDeptName,
  378. @ApiParam(name = "doctorId", value = "医生ID", defaultValue = "50108")
  379. @RequestParam(value = "doctorId", required = true) String doctorId,
  380. @ApiParam(name = "doctorName", value = "医生姓名", defaultValue = "杨叔禹")
  381. @RequestParam(value = "doctorName", required = true) String doctorName,
  382. @ApiParam(name = "arrangeDate", value = "排班信息", defaultValue = "{\"sectionType\":\"p\",\"startTime\":\"2016-12-29 14:00:00\",\"endTime\":\"2016-12-29 14:08:00\"}")
  383. @RequestParam(value = "arrangeDate", required = true) String arrangeDate,
  384. @ApiParam(name = "patient", value = "患者代码", defaultValue = "01954b2ebbb24a40a05da9d2f5c94795")
  385. @RequestParam(value = "patient", required = true) String patient,
  386. @ApiParam(name = "patientName", value = "患者姓名", defaultValue = "张锦川")
  387. @RequestParam(value = "patientName", required = true) String patientName,
  388. @ApiParam(name = "cardNo", value = "身份证号码", defaultValue = "35052419880511553X")
  389. @RequestParam(value = "cardNo", required = true) String cardNo,
  390. @ApiParam(name = "clinicCard", value = "市民卡号", defaultValue = "A0601003595X")
  391. @RequestParam(value = "clinicCard", required = true) String clinicCard,
  392. @ApiParam(name = "patientPhone", value = "患者手机", defaultValue = "13559207522")
  393. @RequestParam(value = "patientPhone", required = true) String patientPhone,
  394. @ApiParam(name = "dcode", value = "代预约医生编号", defaultValue = "test00000000005")
  395. @RequestParam(value = "dcode", required = true) String dcode,
  396. @ApiParam(name = "dname", value = "代预约医生名称", defaultValue = "组2全科医生")
  397. @RequestParam(value = "dname", required = true) String dname) {
  398. try {
  399. String orderCode = guahaoXM.CreateOrderByDoctor(hospitalId, hospitalName, hosDeptId, hosDeptName, doctorId, doctorName, arrangeDate, patient, patientName, cardNo, clinicCard, patientPhone, dname, dcode);
  400. //获取预约信息查询是否挂号成功
  401. PatientReservation obj = patientReservationService.findByCode(orderCode);
  402. if (obj != null) {
  403. String des = "";
  404. try {
  405. String msg = obj.getDname() + "医生已成功为您预约:" + obj.getStartTime() + "," + obj.getOrgName() +
  406. obj.getDeptName() + obj.getDeptName() + "医生的号源。您可直接前往医院就诊。";
  407. //发送短信消息,调用总部发送信息的接口
  408. String result = HttpClientUtil.post(SystemConf.getInstance().getSmsUrl(), buildSmsParams(msg, patientPhone), "GBK");
  409. System.out.print(result);
  410. JSONObject resultJson = toJson(result);
  411. if (resultJson != null && resultJson.getInt("result") != 0) {
  412. des = "短信提醒失败!(原因:"+resultJson.getString("description")+")";
  413. }
  414. // 推送消息给微信端
  415. Patient p = patientService.findByCode(patient);
  416. if (StringUtils.isNotEmpty(p.getOpenid())) {
  417. JSONObject json = new JSONObject();
  418. json.put("first", "");
  419. json.put("toUser", patient);
  420. json.put("id", orderCode);
  421. json.put("date", obj.getStartTime());
  422. json.put("orgName", obj.getOrgName());
  423. json.put("orgCode", obj.getOrgCode());
  424. json.put("doctorName", obj.getDeptName());
  425. json.put("deptName", obj.getDeptName());
  426. json.put("remark", patientName + ",您好!\n" + msg);
  427. PushMsgTask.getInstance().putWxMsg(getAccessToken(), 6, p.getOpenid(), patientName, json);
  428. }
  429. else{
  430. des +=" 微信提醒失败,患者无绑定微信!";
  431. }
  432. BusinessLogs.info(BusinessLogs.BusinessType.appointment, getUID(), p.getCode(), new JSONObject(obj));
  433. }
  434. catch (Exception ex)
  435. {
  436. ex.printStackTrace();
  437. }
  438. return write(200, "创建挂号单成功!"+des,"data",obj.getId());
  439. } else {
  440. return error(-1, "创建挂号单失败!");
  441. }
  442. } catch (Exception e) {
  443. return error(-1, e.getMessage());
  444. }
  445. }
  446. @RequestMapping(value = "GetDoctorArrangeTenDay", method = RequestMethod.POST)
  447. @ResponseBody
  448. @ApiOperation("(内网)获取医生排班接口")
  449. public String GetDoctorArrangeTenDay(
  450. @ApiParam(name = "hospitalId", value = "医院ID", defaultValue = "350211A1001")
  451. @RequestParam(value = "hospitalId", required = true) String hospitalId,
  452. @ApiParam(name = "hosDeptId", value = "科室ID", defaultValue = "1011610")
  453. @RequestParam(value = "hosDeptId", required = true) String hosDeptId,
  454. @ApiParam(name = "doctorId", value = "医生ID", defaultValue = "50108")
  455. @RequestParam(value = "doctorId", required = true) String doctorId) {
  456. try {
  457. List<Map<String, Object>> list = guahaoXM.GetDoctorArrangeTenDay(hospitalId, hosDeptId, doctorId);
  458. return write(200, "获取医生排班成功!", "data", list);
  459. } catch (Exception e) {
  460. return error(-1, e.getMessage());
  461. }
  462. }
  463. /********************************************* 医生端查询 **************************************************************************/
  464. @RequestMapping(value = "GetPatientReservationList", method = {RequestMethod.POST,RequestMethod.GET})
  465. @ResponseBody
  466. @ApiOperation("获取患者预约信息列表接口-医生端")
  467. public String GetPatientReservation(@ApiParam(name = "pageIndex", value = "第几页", defaultValue = "1")
  468. @RequestParam(value = "pageIndex", required = false) Integer pageIndex,
  469. @ApiParam(name = "pageSize", value = "每页记录数", defaultValue = "10")
  470. @RequestParam(value = "pageSize", required = false) Integer pageSize,
  471. @ApiParam(name = "patient", value = "患者编号", defaultValue = "4afdbce6194e412fbc770eb4dfbe7b00")
  472. @RequestParam(value = "patient", required = false) String patient,
  473. @ApiParam(name = "teamCode", value = "行政团队")
  474. @RequestParam(value = "teamCode", required = false) Long teamCode) {
  475. try {
  476. JSONArray list = patientReservationService.getReservationByPatient(patient, teamCode, pageIndex, pageSize);
  477. return write(200, "获取患者预约信息列表成功!", "data", list);
  478. } catch (Exception e) {
  479. return error(-1, e.getMessage());
  480. }
  481. }
  482. @RequestMapping(value = "GetDoctorReservationList", method = RequestMethod.POST)
  483. @ResponseBody
  484. @ApiOperation("获取医生代预约信息列表接口-医生端")
  485. public String GetDoctorReservation(@ApiParam(name = "pageIndex", value = "第几页", defaultValue = "1")
  486. @RequestParam(value = "pageIndex", required = false) Integer pageIndex,
  487. @ApiParam(name = "pageSize", value = "每页记录数", defaultValue = "10")
  488. @RequestParam(value = "pageSize", required = false) Integer pageSize,
  489. @ApiParam(name = "doctor", value = "医生编号", defaultValue = "shiliuD20160926005")
  490. @RequestParam(value = "doctor", required = false) String doctor) {
  491. try {
  492. List<Map<String,String>> list = patientReservationService.getReservationByDoctor(doctor, pageIndex, pageSize);
  493. return write(200, "获取患者预约信息列表成功!", "data", list);
  494. } catch (Exception e) {
  495. return error(-1, e.getMessage());
  496. }
  497. }
  498. @RequestMapping(value = "GetPatientReservation", method = RequestMethod.POST)
  499. @ResponseBody
  500. @ApiOperation("获取患者预约信息单条-医生端")
  501. public String GetPatientReservation(@ApiParam(name = "orderId", value = "订单id", defaultValue = "9")
  502. @RequestParam(value = "orderId", required = true) Long orderId) {
  503. try {
  504. PatientReservation obj = patientReservationService.findById(orderId);
  505. return write(200, "获取患者预约信息成功!", "data", obj);
  506. }
  507. catch (Exception e) {
  508. return error(-1, e.getMessage());
  509. }
  510. }
  511. @RequestMapping(value = "CountReservationByDoctorForPatient", method = RequestMethod.POST)
  512. @ResponseBody
  513. @ApiOperation("获取医生为患者预约的总数")
  514. public String CountReservationByDoctorForPatient(@ApiParam(name = "doctor", value = "医生编号")
  515. @RequestParam(value = "doctor", required = true) String doctor,
  516. @ApiParam(name = "patient", value = "患者编号")
  517. @RequestParam(value = "patient", required = true) String patient) {
  518. try {
  519. Long obj = patientReservationService.countReservationByDoctorForPatient(doctor, patient);
  520. return write(200, "获取患者预约信息成功!", "data", obj);
  521. } catch (Exception e) {
  522. return error(-1, e.getMessage());
  523. }
  524. }
  525. /*************************************** 患者端查询 ******************************************************************/
  526. @RequestMapping(value = "GetRegList", method = RequestMethod.POST)
  527. @ResponseBody
  528. @ApiOperation("获取患者预约信息列表接口--患者端")
  529. public String GetRegList(@ApiParam(name = "patient", value = "患者编号", defaultValue = "0cc6e4562de2437ab2dbbf51a9fc3b49")
  530. @RequestParam(value = "patient", required = false) String patient) {
  531. try {
  532. SimpleDateFormat sm = new SimpleDateFormat("yyyy-MM-dd");
  533. Date nowDate = new Date();
  534. Date oneMonthAfter = getMonthBefore(nowDate, -1);
  535. Date threeMonthBefore = getMonthBefore(nowDate, 3); //三个月历史记录
  536. List<PatientReservation> list = guahaoXM.GetRegList(patient, sm.format(threeMonthBefore), sm.format(oneMonthAfter), threeMonthBefore, oneMonthAfter);
  537. return write(200, "获取患者预约信息列表成功!", "data", list);
  538. } catch (Exception e) {
  539. return error(-1, e.getMessage());
  540. }
  541. }
  542. @RequestMapping(value = "GetPatientReservationXm", method = RequestMethod.POST)
  543. @ResponseBody
  544. @ApiOperation("获取患者预约信息单条-患者端")
  545. public String GetPatientReservationXm(@ApiParam(name = "patientCode", value = "患者编号",defaultValue = "0cc6e4562de2437ab2dbbf51a9fc3b49")
  546. @RequestParam(value = "patientCode", required = true) String patientCode,
  547. @ApiParam(name = "orgCode", value = "机构编码",defaultValue = "350211A1002")
  548. @RequestParam(value = "orgCode", required = true) String orgCode,
  549. @ApiParam(name = "regCode", value = "挂号单号",defaultValue = "9c34e255-5984-43f0-8ecf-3bbf160e3c58")
  550. @RequestParam(value = "regCode", required = true) String regCode) {
  551. try {
  552. PatientReservation obj = guahaoXM.getRegDetail(patientCode, orgCode, regCode);
  553. return write(200, "获取患者预约信息成功!", "data", obj);
  554. } catch (Exception e) {
  555. return error(-1, e.getMessage());
  556. }
  557. }
  558. }