BookingController.java 33 KB

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