BookingController.java 26 KB

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