BookingController.java 25 KB

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