package com.yihu.figure.controller; import com.yihu.figure.model.disease.Inspection; import com.yihu.figure.model.disease.Visit; import com.yihu.figure.service.DiseaseService; import com.yihu.figure.util.DateUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.json.JSONArray; import org.json.JSONObject; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; 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.RestController; import java.util.List; /** * Created by chenweida on 2017/3/6. * 近期疾病 */ @RestController @RequestMapping(value = "/disease", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @Api(description = "近期疾病") public class DiseaseController extends BaseController { @Autowired private DiseaseService diseaseService; /** * 根据健康卡号抓取数据某个病人的全部就诊事件列表接口 * /smjk/GetResidentEventListJson * * @param strSSID 健康卡号 * @return */ @ApiOperation(value = "根据健康卡号生成数据某个病人的全部就诊事件") @RequestMapping(value = "GetResidentEventListJson", method = RequestMethod.GET) public String getResidentEventListJson( @ApiParam(name = "strSSID", value = "健康卡号", required = true) @RequestParam(value = "strSSID", required = true) String strSSID, @ApiParam(name = "patientCode", value = "患者code", required = true) @RequestParam(value = "patientCode", required = true) String patientCode) { try { diseaseService.getResidentEventListJson(strSSID,patientCode); return success("成功"); } catch (Exception e) { error(e); return invalidUserException(e, -1, "启动失败:" + e.getMessage()); } } /** * 根据健康卡号抓取数据某个病人的全部检查检验事件 * /smjk/GetResidentEventListJson * * @param strSSID 健康卡号 * @return */ @ApiOperation(value = "根据健康卡号抓取数据某个病人的全部检查检验事件") @RequestMapping(value = "GetRecordListByCatalogcodesJson", method = RequestMethod.GET) public String GetRecordListByCatalogcodesJson( @ApiParam(name = "strSSID", value = "健康卡号", required = true) @RequestParam(value = "strSSID", required = true) String strSSID, @ApiParam(name = "patientCode", value = "患者code", required = true) @RequestParam(value = "patientCode", required = true) String patientCode) { try { diseaseService.GetRecordListByCatalogcodesJson(strSSID,patientCode); return success("成功"); } catch (Exception e) { error(e); return invalidUserException(e, -1, "启动失败:" + e.getMessage()); } } @ApiOperation(value = "根据code查询患者的就诊事件") @RequestMapping(value = "getVisits", method = RequestMethod.GET) public String getVisits( @ApiParam(name = "patientCode", value = "患者code", required = true) @RequestParam(value = "patientCode", required = true) String patientCode, @ApiParam(name = "time", value = "时间", required = false) @RequestParam(value = "time", required = false) String time) { try { List visitList = diseaseService.getVisits(patientCode,time); JSONArray ja=new JSONArray(); visitList.stream().forEach( v->{ JSONObject jo=new JSONObject(); jo.put("orgName",v.getOrgName()); jo.put("typeName",v.getTypeName()); jo.put("time", DateUtil.dateToStr(v.getEndTime(),"yyyy-MM-dd")); ja.put(jo); }); return write(200, "获取列表成功!", "list", ja); } catch (Exception e) { error(e); return invalidUserException(e, -1, "启动失败:" + e.getMessage()); } } @ApiOperation(value = "根据code查询患者的检查检验") @RequestMapping(value = "getInspections", method = RequestMethod.GET) public String getInspections( @ApiParam(name = "patientCode", value = "患者code", required = true) @RequestParam(value = "patientCode", required = true) String patientCode, @ApiParam(name = "time", value = "时间", required = false) @RequestParam(value = "time", required = false) String time) { try { List inspections = diseaseService.getInspections(patientCode,time); JSONArray ja=new JSONArray(); inspections.stream().forEach( v->{ JSONObject jo=new JSONObject(); jo.put("orgName",v.getOrgName()); jo.put("cataLogCodeName",v.getCataLogCodeName()); jo.put("time", DateUtil.dateToStr(v.getEndTime(),"yyyy-MM-dd")); ja.put(jo); }); return write(200, "获取列表成功!", "list", ja); } catch (Exception e) { error(e); return invalidUserException(e, -1, "启动失败:" + e.getMessage()); } } }