package com.yihu.wlyy.web.third; import com.yihu.wlyy.service.app.archives.PatientEventService; import com.yihu.wlyy.service.app.archives.PatientRecordService; import com.yihu.wlyy.web.BaseController; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.json.JSONObject; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import java.util.*; /** * 市民健康档案接口 * @author hzp at 2016-12-19 */ @Controller @RequestMapping(value = "/third/smjk") @Api(description = "市民健康档案接口") public class OpenApiSmjkController extends BaseController { @Autowired private PatientRecordService patientRecordService; @Autowired private PatientEventService patientEventService; @ApiOperation("获取门诊记录/住院记录(基卫+APP)") @RequestMapping(value = "/event", produces = "application/json;charset=UTF-8", method = RequestMethod.GET) @ResponseBody public String getAllEvent(@ApiParam(name="patient",value="患者代码",defaultValue = "14531c1f0c09442e8017853fd1a0c8b7") @RequestParam(value="patient",required = false) String patient, @ApiParam(name="type",value="类型",defaultValue = "") @RequestParam(value="type",required = false) String type, @ApiParam(name="page",value="第几页",defaultValue = "1") @RequestParam(value="page",required = true) String page, @ApiParam(name="pageSize",value="每页几行",defaultValue = "10") @RequestParam(value="pageSize",required = true) String pageSize, @ApiParam(name="lastTime",value="最后一条时间",defaultValue = "") @RequestParam(value="lastTime",required = false) String lastTime) { try { List> result = patientRecordService.getAllEvent(patient,type,page,pageSize,lastTime); return write(200, "获取就诊记录成功!", "data", result); } catch (Exception e) { return invalidUserException(e, -1, "获取门/急诊数据失败!"); } } @RequestMapping(value = "/event/healthData", produces = "application/json;charset=UTF-8", method = RequestMethod.GET) @ResponseBody @ApiOperation("获取健康档案详情(基卫)") public String getHealthData(@ApiParam(name="patient",value="患者代码",defaultValue = "14531c1f0c09442e8017853fd1a0c8b7") @RequestParam(value="patient",required = false) String patient, @ApiParam(name="event",value="事件ID",defaultValue = "30d1eb16-bca2-4b39-b413-672b4361e7a7") @RequestParam(value="event",required = true) String event, @ApiParam(name="catalog",value="档案类型",defaultValue = "0101") @RequestParam(value="catalog",required = true) String catalog, @ApiParam(name="serial",value="该类别顺序号,默认填1",defaultValue = "1") @RequestParam(value="serial",required = true) String serial) { try { String result = patientRecordService.getHealthData(patient, event, catalog, serial); return write(200, "获取健康档案详情成功!", "data", result); } catch (Exception e) { return invalidUserException(e, -1, "获取健康档案详情失败!"); } } @RequestMapping(value = "/event/catalog", produces = "application/json;charset=UTF-8", method = RequestMethod.GET) @ResponseBody @ApiOperation("通过事件号获取档案类型列表(基卫)") public String getEventCatalog(@ApiParam(name="patient",value="患者代码",defaultValue = "14531c1f0c09442e8017853fd1a0c8b7") @RequestParam(value="patient",required = false) String patient, @ApiParam(name="event",value="事件ID",defaultValue = "30d1eb16-bca2-4b39-b413-672b4361e7a7") @RequestParam(value="event",required = true) String event) { try { List> result = patientRecordService.getEventCatalog(patient,event); return write(200, "通过事件号获取档案类型列表成功!", "data", result); } catch (Exception e) { return invalidUserException(e, -1, e.getMessage()); } } @RequestMapping(value = "/event/drug", produces = "application/json;charset=UTF-8", method = RequestMethod.GET) @ResponseBody @ApiOperation("获取用药记录(基卫)") public String getDrugsList(@ApiParam(name="patient",value="患者代码",defaultValue = "14531c1f0c09442e8017853fd1a0c8b7") @RequestParam(value="patient",required = false) String patient, @ApiParam(name="page",value="第几页",defaultValue = "1") @RequestParam(value="page",required = true) String page, @ApiParam(name="pageSize",value="每页几行",defaultValue = "10") @RequestParam(value="pageSize",required = true) String pageSize) { try { String result = patientRecordService.getDrugsListPage(patient, page, pageSize); return write(200, "获取用药记录成功!", "data", result); } catch (Exception e) { return invalidUserException(e, -1, "获取用药记录失败!"); } } @ApiOperation("获取检查检验报告(基卫+APP)") @RequestMapping(value = "/event/report", produces = "application/json;charset=UTF-8", method = RequestMethod.GET) @ResponseBody public String getReportList(@ApiParam(name="patient",value="患者代码",defaultValue = "14531c1f0c09442e8017853fd1a0c8b7") @RequestParam(value="patient",required = false) String patient, @ApiParam(name="page",value="第几页",defaultValue = "1") @RequestParam(value="page",required = true) String page, @ApiParam(name="pageSize",value="每页几行",defaultValue = "10") @RequestParam(value="pageSize",required = true) String pageSize, @ApiParam(name="lastTime",value="最后一条时间",defaultValue = "2010-10-10 00:00:00") @RequestParam(value="lastTime",required = false) String lastTime) { try { List> result = patientRecordService.getExamAndLabReport(patient, page, pageSize,lastTime); return write(200, "获取检查检验报告成功!", "data", result); } catch (Exception e) { return invalidUserException(e, -1, "获取检查检验报告失败!"); } } /******************************************* 就诊事件管理 **********************************************************/ @RequestMapping(value = "/event/detail", produces = "application/json;charset=UTF-8", method = RequestMethod.GET) @ResponseBody @ApiOperation("获取就诊事件详情") public String getEventDetail(@ApiParam(name="event",value="事件ID",defaultValue = "") @RequestParam(value="event",required = true) String event) { try { JSONObject result = patientEventService.getEventDetail(event); return write(200, "获取就诊事件详情成功!", "data", result); } catch (Exception e) { return invalidUserException(e, -1, "获取就诊事件详情失败!"); } } }