DiseaseController.java 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. package com.yihu.figure.controller;
  2. import com.yihu.figure.model.disease.Inspection;
  3. import com.yihu.figure.model.disease.Visit;
  4. import com.yihu.figure.service.DiseaseService;
  5. import com.yihu.figure.util.DateUtil;
  6. import io.swagger.annotations.Api;
  7. import io.swagger.annotations.ApiOperation;
  8. import io.swagger.annotations.ApiParam;
  9. import org.json.JSONArray;
  10. import org.json.JSONObject;
  11. import org.springframework.beans.factory.annotation.Autowired;
  12. import org.springframework.http.MediaType;
  13. import org.springframework.web.bind.annotation.RequestMapping;
  14. import org.springframework.web.bind.annotation.RequestMethod;
  15. import org.springframework.web.bind.annotation.RequestParam;
  16. import org.springframework.web.bind.annotation.RestController;
  17. import java.util.List;
  18. /**
  19. * Created by chenweida on 2017/3/6.
  20. * 近期疾病
  21. */
  22. @RestController
  23. @RequestMapping(value = "/disease", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
  24. @Api(description = "近期疾病")
  25. public class DiseaseController extends BaseController {
  26. @Autowired
  27. private DiseaseService diseaseService;
  28. /**
  29. * 根据健康卡号抓取数据某个病人的全部就诊事件列表接口
  30. * /smjk/GetResidentEventListJson
  31. *
  32. * @param strSSID 健康卡号
  33. * @return
  34. */
  35. @ApiOperation(value = "根据健康卡号生成数据某个病人的全部就诊事件")
  36. @RequestMapping(value = "GetResidentEventListJson", method = RequestMethod.GET)
  37. public String getResidentEventListJson(
  38. @ApiParam(name = "strSSID", value = "健康卡号", required = true) @RequestParam(value = "strSSID", required = true) String strSSID,
  39. @ApiParam(name = "patientCode", value = "患者code", required = true) @RequestParam(value = "patientCode", required = true) String patientCode) {
  40. try {
  41. diseaseService.getResidentEventListJson(strSSID,patientCode);
  42. return success("成功");
  43. } catch (Exception e) {
  44. error(e);
  45. return invalidUserException(e, -1, "启动失败:" + e.getMessage());
  46. }
  47. }
  48. /**
  49. * 根据健康卡号抓取数据某个病人的全部检查检验事件
  50. * /smjk/GetResidentEventListJson
  51. *
  52. * @param strSSID 健康卡号
  53. * @return
  54. */
  55. @ApiOperation(value = "根据健康卡号抓取数据某个病人的全部检查检验事件")
  56. @RequestMapping(value = "GetRecordListByCatalogcodesJson", method = RequestMethod.GET)
  57. public String GetRecordListByCatalogcodesJson(
  58. @ApiParam(name = "strSSID", value = "健康卡号", required = true) @RequestParam(value = "strSSID", required = true) String strSSID,
  59. @ApiParam(name = "patientCode", value = "患者code", required = true) @RequestParam(value = "patientCode", required = true) String patientCode) {
  60. try {
  61. diseaseService.GetRecordListByCatalogcodesJson(strSSID,patientCode);
  62. return success("成功");
  63. } catch (Exception e) {
  64. error(e);
  65. return invalidUserException(e, -1, "启动失败:" + e.getMessage());
  66. }
  67. }
  68. @ApiOperation(value = "根据code查询患者的就诊事件")
  69. @RequestMapping(value = "getVisits", method = RequestMethod.GET)
  70. public String getVisits(
  71. @ApiParam(name = "patientCode", value = "患者code", required = true) @RequestParam(value = "patientCode", required = true) String patientCode,
  72. @ApiParam(name = "time", value = "时间", required = false) @RequestParam(value = "time", required = false) String time) {
  73. try {
  74. List<Visit> visitList = diseaseService.getVisits(patientCode,time);
  75. JSONArray ja=new JSONArray();
  76. visitList.stream().forEach( v->{
  77. JSONObject jo=new JSONObject();
  78. jo.put("orgName",v.getOrgName());
  79. jo.put("typeName",v.getTypeName());
  80. jo.put("time", DateUtil.dateToStr(v.getEndTime(),"yyyy-MM-dd"));
  81. ja.put(jo);
  82. });
  83. return write(200, "获取列表成功!", "list", ja);
  84. } catch (Exception e) {
  85. error(e);
  86. return invalidUserException(e, -1, "启动失败:" + e.getMessage());
  87. }
  88. }
  89. @ApiOperation(value = "根据code查询患者的检查检验")
  90. @RequestMapping(value = "getInspections", method = RequestMethod.GET)
  91. public String getInspections(
  92. @ApiParam(name = "patientCode", value = "患者code", required = true) @RequestParam(value = "patientCode", required = true) String patientCode,
  93. @ApiParam(name = "time", value = "时间", required = false) @RequestParam(value = "time", required = false) String time) {
  94. try {
  95. List<Inspection> inspections = diseaseService.getInspections(patientCode,time);
  96. JSONArray ja=new JSONArray();
  97. inspections.stream().forEach( v->{
  98. JSONObject jo=new JSONObject();
  99. jo.put("orgName",v.getOrgName());
  100. jo.put("cataLogCodeName",v.getCataLogCodeName());
  101. jo.put("time", DateUtil.dateToStr(v.getEndTime(),"yyyy-MM-dd"));
  102. ja.put(jo);
  103. });
  104. return write(200, "获取列表成功!", "list", ja);
  105. } catch (Exception e) {
  106. error(e);
  107. return invalidUserException(e, -1, "启动失败:" + e.getMessage());
  108. }
  109. }
  110. }