BookingController.java 33 KB

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