|  | @ -0,0 +1,318 @@
 | 
												
													
														
															|  | 
 |  | package com.yihu.jw.care.endpoint.device;
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | import com.yihu.jw.care.endpoint.BaseController;
 | 
												
													
														
															|  | 
 |  | import com.yihu.jw.care.service.device.PatientHealthIndexService;
 | 
												
													
														
															|  | 
 |  | import com.yihu.jw.entity.care.device.DevicePatientHealthIndex;
 | 
												
													
														
															|  | 
 |  | import io.swagger.annotations.Api;
 | 
												
													
														
															|  | 
 |  | import io.swagger.annotations.ApiOperation;
 | 
												
													
														
															|  | 
 |  | import io.swagger.annotations.ApiParam;
 | 
												
													
														
															|  | 
 |  | import org.apache.commons.lang3.StringUtils;
 | 
												
													
														
															|  | 
 |  | import org.json.JSONArray;
 | 
												
													
														
															|  | 
 |  | import org.json.JSONObject;
 | 
												
													
														
															|  | 
 |  | import org.springframework.beans.factory.annotation.Autowired;
 | 
												
													
														
															|  | 
 |  | import org.springframework.http.MediaType;
 | 
												
													
														
															|  | 
 |  | import org.springframework.jdbc.core.JdbcTemplate;
 | 
												
													
														
															|  | 
 |  | import org.springframework.web.bind.annotation.*;
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | import java.util.ArrayList;
 | 
												
													
														
															|  | 
 |  | import java.util.HashMap;
 | 
												
													
														
															|  | 
 |  | import java.util.List;
 | 
												
													
														
															|  | 
 |  | import java.util.Map;
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | @RestController
 | 
												
													
														
															|  | 
 |  | @RequestMapping(value = "/doctor/health_index", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
 | 
												
													
														
															|  | 
 |  | @Api(description = "医生端-患者指标")
 | 
												
													
														
															|  | 
 |  | public class DoctorHealthController extends BaseController {
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 	@Autowired
 | 
												
													
														
															|  | 
 |  | 	private PatientHealthIndexService healthIndexService;
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 	@Autowired
 | 
												
													
														
															|  | 
 |  | 	private JdbcTemplate jdbcTemplate;
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 	@RequestMapping(value = "recent",method = RequestMethod.GET)
 | 
												
													
														
															|  | 
 |  | 	@ApiOperation("患者最近填写的健康指标")
 | 
												
													
														
															|  | 
 |  | 	public String recent(@ApiParam("患者代码")
 | 
												
													
														
															|  | 
 |  | 						  @RequestParam String patient) {
 | 
												
													
														
															|  | 
 |  | 		try {
 | 
												
													
														
															|  | 
 |  | 			JSONArray array = healthIndexService.findRecentByPatient(patient);
 | 
												
													
														
															|  | 
 |  | 			if (array != null) {
 | 
												
													
														
															|  | 
 |  | 				return write(200, "查询成功", "list", array);
 | 
												
													
														
															|  | 
 |  | 			} else {
 | 
												
													
														
															|  | 
 |  | 				return error(-1, "查询失败");
 | 
												
													
														
															|  | 
 |  | 			}
 | 
												
													
														
															|  | 
 |  | 		} catch (Exception e) {
 | 
												
													
														
															|  | 
 |  | 			error(e);
 | 
												
													
														
															|  | 
 |  | 			return error(-1, "查询失败");
 | 
												
													
														
															|  | 
 |  | 		}
 | 
												
													
														
															|  | 
 |  | 	}
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 	/**
 | 
												
													
														
															|  | 
 |  | 	 * 根据患者标志获取健康指标
 | 
												
													
														
															|  | 
 |  | 	 * @param patient 患者标识
 | 
												
													
														
															|  | 
 |  | 	 * @param type 健康指标类型(1血糖,2血压,3体重,4腰围)
 | 
												
													
														
															|  | 
 |  | 	 * @return 操作结果
 | 
												
													
														
															|  | 
 |  | 	 */
 | 
												
													
														
															|  | 
 |  | 	@RequestMapping(value = "chart",method = RequestMethod.POST)
 | 
												
													
														
															|  | 
 |  | 	@ApiOperation("根据患者标志获取健康指标(图表)")
 | 
												
													
														
															|  | 
 |  | 	public String getHealthIndexChartByPatient(@ApiParam(name="patient",value="患者代码",defaultValue = "eb0b478fbe9245428ecf63cd7517206f")
 | 
												
													
														
															|  | 
 |  | 												   @RequestParam(value="patient",required = true) String patient,
 | 
												
													
														
															|  | 
 |  | 											   @ApiParam(name="type",value="指标类型",defaultValue = "1")
 | 
												
													
														
															|  | 
 |  | 											   @RequestParam(value="type",required = true) int type,
 | 
												
													
														
															|  | 
 |  | 											   @ApiParam(name="gi_type",value="就餐类型",defaultValue = "1")
 | 
												
													
														
															|  | 
 |  | 												   @RequestParam(value = "gi_type",required = false) int gi_type,
 | 
												
													
														
															|  | 
 |  | 											   @ApiParam(name="begin",value="开始时间",defaultValue = "2017-05-22 00:00:00")
 | 
												
													
														
															|  | 
 |  | 											   @RequestParam(value="begin",required = true) String begin,
 | 
												
													
														
															|  | 
 |  | 											   @ApiParam(name="end",value="结束时间",defaultValue = "2017-06-02 00:00:00")
 | 
												
													
														
															|  | 
 |  | 												   @RequestParam(value="end",required = true) String end) {
 | 
												
													
														
															|  | 
 |  | 		try {
 | 
												
													
														
															|  | 
 |  | 			JSONArray jsonArray = healthIndexService.findChartByPatient(patient,type,gi_type,begin,end);
 | 
												
													
														
															|  | 
 |  | 			if (jsonArray.length()==0) {
 | 
												
													
														
															|  | 
 |  | 				return success("查询成功!");
 | 
												
													
														
															|  | 
 |  | 			}
 | 
												
													
														
															|  | 
 |  | 			return write(200, "查询成功", "list", jsonArray);
 | 
												
													
														
															|  | 
 |  | 		} catch (Exception ex) {
 | 
												
													
														
															|  | 
 |  | 			error(ex);
 | 
												
													
														
															|  | 
 |  | 			return invalidUserException(ex, -1, "查询失败!");
 | 
												
													
														
															|  | 
 |  | 		}
 | 
												
													
														
															|  | 
 |  | 	}
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 	/**
 | 
												
													
														
															|  | 
 |  | 	 * 根据患者标志获取健康指标
 | 
												
													
														
															|  | 
 |  | 	 * @param patient 患者指标
 | 
												
													
														
															|  | 
 |  | 	 * @param type 健康指标类型(1血糖,2血压,3体重,4腰围)
 | 
												
													
														
															|  | 
 |  | 	 * @return 操作结果
 | 
												
													
														
															|  | 
 |  | 	 */
 | 
												
													
														
															|  | 
 |  | 	@RequestMapping(value = "list",method = RequestMethod.POST)
 | 
												
													
														
															|  | 
 |  | 	@ApiOperation("根据患者标志获取健康指标")
 | 
												
													
														
															|  | 
 |  | 	public String getHealthIndexByPatient(@ApiParam(name="patient",value="患者代码",defaultValue = "P20160901001")
 | 
												
													
														
															|  | 
 |  | 											  @RequestParam(value="patient",required = true) String patient,
 | 
												
													
														
															|  | 
 |  | 										  @ApiParam(name="type",value="指标类型",defaultValue = "1")
 | 
												
													
														
															|  | 
 |  | 										  @RequestParam(value="type",required = true) int type,
 | 
												
													
														
															|  | 
 |  | 										  @ApiParam(name="begin",value="开始时间",defaultValue = "2016-07-23 00:00:00")
 | 
												
													
														
															|  | 
 |  | 											  @RequestParam(value="begin",required = true) String begin,
 | 
												
													
														
															|  | 
 |  | 										  @ApiParam(name="end",value="开始时间",defaultValue = "2016-08-23 00:00:00")
 | 
												
													
														
															|  | 
 |  | 											  @RequestParam(value="end",required = true) String end,
 | 
												
													
														
															|  | 
 |  | 										  @ApiParam(name="page",value="第几页",defaultValue = "1")
 | 
												
													
														
															|  | 
 |  | 											  @RequestParam(value="page",required = true) int page,
 | 
												
													
														
															|  | 
 |  | 										  @ApiParam(name="pagesize",value="每页几行",defaultValue = "10")
 | 
												
													
														
															|  | 
 |  | 											  @RequestParam(value="pagesize",required = true) int pagesize) {
 | 
												
													
														
															|  | 
 |  | 		try {
 | 
												
													
														
															|  | 
 |  | 			JSONObject jsonObject = new JSONObject();
 | 
												
													
														
															|  | 
 |  | 			if (type == 1) {
 | 
												
													
														
															|  | 
 |  | 				List<Object> list = healthIndexService.findIndexByPatient2(patient, type, begin, end, page, pagesize);
 | 
												
													
														
															|  | 
 |  | 				jsonObject.put("data",list);
 | 
												
													
														
															|  | 
 |  | 			}else{
 | 
												
													
														
															|  | 
 |  | 				JSONArray jsonArray = healthIndexService.findIndexByPatient(patient, type, begin, end, page, pagesize);
 | 
												
													
														
															|  | 
 |  | 				jsonObject.put("data",jsonArray);
 | 
												
													
														
															|  | 
 |  | 			}
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 			return write(200, "查询成功", "list", jsonObject);
 | 
												
													
														
															|  | 
 |  | 		} catch (Exception ex) {
 | 
												
													
														
															|  | 
 |  | 			error(ex);
 | 
												
													
														
															|  | 
 |  | 			return invalidUserException(ex, -1, "查询失败!");
 | 
												
													
														
															|  | 
 |  | 		}
 | 
												
													
														
															|  | 
 |  | 	}
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 	/**
 | 
												
													
														
															|  | 
 |  | 	 * 根据患者标志获取健康指标
 | 
												
													
														
															|  | 
 |  | 	 * @param patient 患者指标
 | 
												
													
														
															|  | 
 |  | 	 * @param type 健康指标类型(1血糖,2血压,3体重,4腰围)
 | 
												
													
														
															|  | 
 |  | 	 * @return 操作结果
 | 
												
													
														
															|  | 
 |  | 	 */
 | 
												
													
														
															|  | 
 |  | 	@RequestMapping(value = "list1",method = RequestMethod.POST)
 | 
												
													
														
															|  | 
 |  | 	@ApiOperation("根据患者标志获取健康指标")
 | 
												
													
														
															|  | 
 |  | 	public String getHealthIndexByPatient1(@ApiParam(name="patient",value="患者代码",defaultValue = "P20160901001")
 | 
												
													
														
															|  | 
 |  | 										  @RequestParam(value="patient",required = true) String patient,
 | 
												
													
														
															|  | 
 |  | 										  @ApiParam(name="type",value="指标类型",defaultValue = "1")
 | 
												
													
														
															|  | 
 |  | 										  @RequestParam(value="type",required = true) int type,
 | 
												
													
														
															|  | 
 |  | 										  @ApiParam(name="page",value="第几页",defaultValue = "1")
 | 
												
													
														
															|  | 
 |  | 										  @RequestParam(value="page",required = true) int page,
 | 
												
													
														
															|  | 
 |  | 										  @ApiParam(name="pagesize",value="每页几行",defaultValue = "10")
 | 
												
													
														
															|  | 
 |  | 										  @RequestParam(value="pagesize",required = true) int pagesize) {
 | 
												
													
														
															|  | 
 |  | 		try {
 | 
												
													
														
															|  | 
 |  | 			JSONObject jsonObject = new JSONObject();
 | 
												
													
														
															|  | 
 |  | 			if (type == 1) {
 | 
												
													
														
															|  | 
 |  | 				jsonObject = healthIndexService.findIndexByPatient3(patient, type, page, pagesize);
 | 
												
													
														
															|  | 
 |  | 			}else{
 | 
												
													
														
															|  | 
 |  | 				jsonObject = healthIndexService.findIndexByPatient1(patient, type, page, pagesize);
 | 
												
													
														
															|  | 
 |  | 			}
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 			return write(200, "查询成功", "list", jsonObject);
 | 
												
													
														
															|  | 
 |  | 		} catch (Exception ex) {
 | 
												
													
														
															|  | 
 |  | 			error(ex);
 | 
												
													
														
															|  | 
 |  | 			return invalidUserException(ex, -1, "查询失败!");
 | 
												
													
														
															|  | 
 |  | 		}
 | 
												
													
														
															|  | 
 |  | 	}
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 	/**
 | 
												
													
														
															|  | 
 |  | 	 *
 | 
												
													
														
															|  | 
 |  | 	 * @param patient 患者标识
 | 
												
													
														
															|  | 
 |  | 	 * @return
 | 
												
													
														
															|  | 
 |  | 	 */
 | 
												
													
														
															|  | 
 |  | 	@RequestMapping(value = "standard",method = RequestMethod.GET)
 | 
												
													
														
															|  | 
 |  | 	@ApiOperation("患者健康指标预警值查询")
 | 
												
													
														
															|  | 
 |  | 	public String standard(@ApiParam("患者代码") @RequestParam String patient) {
 | 
												
													
														
															|  | 
 |  | 		try {
 | 
												
													
														
															|  | 
 |  | 			JSONArray standardArray = new JSONArray();
 | 
												
													
														
															|  | 
 |  | 			JSONArray userArray = new JSONArray();
 | 
												
													
														
															|  | 
 |  | 			// 预警值未设置,返回默认值
 | 
												
													
														
															|  | 
 |  | 			StringBuffer sb = new StringBuffer();
 | 
												
													
														
															|  | 
 |  | 			sb.append("[");
 | 
												
													
														
															|  | 
 |  | 			// 默认血糖(餐前,餐后二小时)
 | 
												
													
														
															|  | 
 |  | 			sb.append("{min_value_1:"+ PatientHealthIndexService.HEALTH_STANDARD_ST_MIN_BEFORE +", max_value_1: "+ PatientHealthIndexService.HEALTH_STANDARD_ST_MAX_BEFORE +", " +
 | 
												
													
														
															|  | 
 |  | 					"min_value_2:"+ PatientHealthIndexService.HEALTH_STANDARD_ST_MIN_AFTER +", max_value_2:"+ PatientHealthIndexService.HEALTH_STANDARD_ST_MAX_AFTER +", type:1},");
 | 
												
													
														
															|  | 
 |  | 			// 默认血压(收缩压,舒张压)
 | 
												
													
														
															|  | 
 |  | 			sb.append("{min_value_1:"+ PatientHealthIndexService.HEALTH_STANDARD_SSY_MIN +", max_value_1:"+ PatientHealthIndexService.HEALTH_STANDARD_SSY_MAX +", " +
 | 
												
													
														
															|  | 
 |  | 					"min_value_2:"+ PatientHealthIndexService.HEALTH_STANDARD_SZY_MIN +", max_value_2:"+ PatientHealthIndexService.HEALTH_STANDARD_SZY_MAX +", type:2}");
 | 
												
													
														
															|  | 
 |  | 			sb.append("]");
 | 
												
													
														
															|  | 
 |  | 			standardArray = new JSONArray(sb.toString());
 | 
												
													
														
															|  | 
 |  | 			JSONObject json = new JSONObject();
 | 
												
													
														
															|  | 
 |  | 			json.put("standard", standardArray);
 | 
												
													
														
															|  | 
 |  | 			json.put("custom", userArray);
 | 
												
													
														
															|  | 
 |  | 			return write(200, "查询成功", "data", json);
 | 
												
													
														
															|  | 
 |  | 		} catch (Exception e) {
 | 
												
													
														
															|  | 
 |  | 			error(e);
 | 
												
													
														
															|  | 
 |  | 			return invalidUserException(e, -1, "查询失败!");
 | 
												
													
														
															|  | 
 |  | 		}
 | 
												
													
														
															|  | 
 |  | 	}
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 	@RequestMapping(value = "last",method = RequestMethod.GET)
 | 
												
													
														
															|  | 
 |  | 	@ApiOperation("患者最新健康指标信息")
 | 
												
													
														
															|  | 
 |  | 	public String getHealthIndexByPatient(@ApiParam(name="patient",value="患者代码",defaultValue = "")
 | 
												
													
														
															|  | 
 |  | 										   @RequestParam(value="patient",required = true) String patient) {
 | 
												
													
														
															|  | 
 |  | 		try {
 | 
												
													
														
															|  | 
 |  | 			Map<String,Object> map = new HashMap<>();
 | 
												
													
														
															|  | 
 |  | 			DevicePatientHealthIndex xt = healthIndexService.findLastByPatienIot(patient, 1);
 | 
												
													
														
															|  | 
 |  | 			if (xt != null) {
 | 
												
													
														
															|  | 
 |  | 				map.put("xt", xt);
 | 
												
													
														
															|  | 
 |  | 			}
 | 
												
													
														
															|  | 
 |  | 			DevicePatientHealthIndex xy = healthIndexService.findLastByPatienIot(patient, 2);
 | 
												
													
														
															|  | 
 |  | 			if (xy != null) {
 | 
												
													
														
															|  | 
 |  | 				map.put("xy", xy);
 | 
												
													
														
															|  | 
 |  | 			}
 | 
												
													
														
															|  | 
 |  | 			DevicePatientHealthIndex tz = healthIndexService.findLastByPatienIot(patient, 3);
 | 
												
													
														
															|  | 
 |  | 			if (tz != null) {
 | 
												
													
														
															|  | 
 |  | 				map.put("tz", tz);
 | 
												
													
														
															|  | 
 |  | 			}
 | 
												
													
														
															|  | 
 |  | 			DevicePatientHealthIndex sg = healthIndexService.findLastByPatienIot(patient, 4);
 | 
												
													
														
															|  | 
 |  | 			if (sg != null) {
 | 
												
													
														
															|  | 
 |  | 				map.put("sg", sg);
 | 
												
													
														
															|  | 
 |  | 			}
 | 
												
													
														
															|  | 
 |  | 			DevicePatientHealthIndex xl = healthIndexService.findLastByPatienIot(patient, 5);
 | 
												
													
														
															|  | 
 |  | 			if (xl != null) {
 | 
												
													
														
															|  | 
 |  | 				map.put("xl", xl);
 | 
												
													
														
															|  | 
 |  | 			}
 | 
												
													
														
															|  | 
 |  | 			return write(200, "查询成功", "data", map);
 | 
												
													
														
															|  | 
 |  | 		} catch (Exception ex) {
 | 
												
													
														
															|  | 
 |  | 			error(ex);
 | 
												
													
														
															|  | 
 |  | 			return invalidUserException(ex, -1, ex.getMessage());
 | 
												
													
														
															|  | 
 |  | 		}
 | 
												
													
														
															|  | 
 |  | 	}
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 	@RequestMapping(value = "getHealthIndexHistory",method = RequestMethod.GET)
 | 
												
													
														
															|  | 
 |  | 	@ApiOperation("获取患者健康指标历史记录")
 | 
												
													
														
															|  | 
 |  | 	public String getHealthIndexHistory(@ApiParam(name="patient",value="患者代码",defaultValue = "P20161008001")
 | 
												
													
														
															|  | 
 |  | 										 @RequestParam(value="patient",required = true) String patient,
 | 
												
													
														
															|  | 
 |  | 										 @ApiParam(name="type",value="指标类型1血糖,2血压,3体重,4腰围",defaultValue = "1")
 | 
												
													
														
															|  | 
 |  | 										 @RequestParam(value="type",required = true) int type,
 | 
												
													
														
															|  | 
 |  | 										 @ApiParam(name="page",value="第几页",defaultValue = "0")
 | 
												
													
														
															|  | 
 |  | 										 @RequestParam(value="page",required = true) int page,
 | 
												
													
														
															|  | 
 |  | 										 @ApiParam(name="pagesize",value="每页几行",defaultValue = "10")
 | 
												
													
														
															|  | 
 |  | 										 @RequestParam(value="pagesize",required = true) int pagesize) {
 | 
												
													
														
															|  | 
 |  | 		try {
 | 
												
													
														
															|  | 
 |  | 			List<Map<String,String>> list = healthIndexService.getHealthIndexHistory(patient, type, page, pagesize);
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 			return write(200, "获取患者健康指标历史记录成功", "data", list);
 | 
												
													
														
															|  | 
 |  | 		} catch (Exception ex) {
 | 
												
													
														
															|  | 
 |  | 			return invalidUserException(ex, -1, ex.getMessage());
 | 
												
													
														
															|  | 
 |  | 		}
 | 
												
													
														
															|  | 
 |  | 	}
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 	@RequestMapping(value = "doctorstandard",method = RequestMethod.GET)
 | 
												
													
														
															|  | 
 |  | 	@ApiOperation("医生健康指标预警值方案查询")
 | 
												
													
														
															|  | 
 |  | 	public String doctorstandard(@ApiParam("医生") @RequestParam String doctor) {
 | 
												
													
														
															|  | 
 |  | 		try {
 | 
												
													
														
															|  | 
 |  | 			JSONArray standardArray = new JSONArray();
 | 
												
													
														
															|  | 
 |  | 			JSONArray userArray = new JSONArray();
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 			if(StringUtils.isBlank(doctor)){
 | 
												
													
														
															|  | 
 |  | 				doctor = getUID();
 | 
												
													
														
															|  | 
 |  | 			}
 | 
												
													
														
															|  | 
 |  | 			// 预警值未设置,返回默认值
 | 
												
													
														
															|  | 
 |  | 			StringBuffer sb = new StringBuffer();
 | 
												
													
														
															|  | 
 |  | 			sb.append("[");
 | 
												
													
														
															|  | 
 |  | 			// 默认血糖(餐前,餐后二小时)
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 			sb.append("{min_value_1:"+ PatientHealthIndexService.HEALTH_STANDARD_ST_MIN_BEFORE +", max_value_1: "+ PatientHealthIndexService.HEALTH_STANDARD_ST_MAX_BEFORE +", " +
 | 
												
													
														
															|  | 
 |  | 					"min_value_2:"+ PatientHealthIndexService.HEALTH_STANDARD_ST_MIN_AFTER +", max_value_2:"+ PatientHealthIndexService.HEALTH_STANDARD_ST_MAX_AFTER +", type:1},");
 | 
												
													
														
															|  | 
 |  | 			// 默认血压(收缩压,舒张压)
 | 
												
													
														
															|  | 
 |  | 			sb.append("{min_value_1:"+ PatientHealthIndexService.HEALTH_STANDARD_SSY_MIN +", max_value_1:"+ PatientHealthIndexService.HEALTH_STANDARD_SSY_MAX +", " +
 | 
												
													
														
															|  | 
 |  | 					"min_value_2:"+ PatientHealthIndexService.HEALTH_STANDARD_SZY_MIN +", max_value_2:"+ PatientHealthIndexService.HEALTH_STANDARD_SZY_MAX +", type:2}");
 | 
												
													
														
															|  | 
 |  | 			sb.append("]");
 | 
												
													
														
															|  | 
 |  | 			standardArray = new JSONArray(sb.toString());
 | 
												
													
														
															|  | 
 |  | 			JSONObject json = new JSONObject();
 | 
												
													
														
															|  | 
 |  | 			json.put("standard", standardArray);
 | 
												
													
														
															|  | 
 |  | 			json.put("custom", userArray);
 | 
												
													
														
															|  | 
 |  | 			return write(200, "查询成功", "data", json);
 | 
												
													
														
															|  | 
 |  | 		} catch (Exception e) {
 | 
												
													
														
															|  | 
 |  | 			error(e);
 | 
												
													
														
															|  | 
 |  | 			return invalidUserException(e, -1, "查询失败!");
 | 
												
													
														
															|  | 
 |  | 		}
 | 
												
													
														
															|  | 
 |  | 	}
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 	@RequestMapping(value = "/getHealthDateAll",method = RequestMethod.GET)
 | 
												
													
														
															|  | 
 |  | 	@ApiOperation("医生端--查询所有有数据的日期")
 | 
												
													
														
															|  | 
 |  | 	public String getHealthDateAll(@ApiParam(value = "居民code)", name = "patientCode") @RequestParam(value = "patientCode",required = true)String patientCode,
 | 
												
													
														
															|  | 
 |  | 								   @ApiParam(value = "设备sn码", name = "deviceSn") @RequestParam(value = "deviceSn",required = true)String deviceSn,
 | 
												
													
														
															|  | 
 |  | 								   @ApiParam(value = "时间(month:yyyy-MM)", name = "choseMonth") @RequestParam(value = "choseMonth",required = true)String choseMonth,
 | 
												
													
														
															|  | 
 |  | 								   @ApiParam(value = "健康指标类型(1血糖,2血压,3体重,4腰围)",name = "type")@RequestParam(value = "type",required = true)int type){
 | 
												
													
														
															|  | 
 |  | 		try{
 | 
												
													
														
															|  | 
 |  | 			String sql = "select DISTINCT(DATE_FORMAT(a.record_date,'%Y-%m-%d')) result from wlyy_patient_health_index a where a.type="+type+" and a.`user` = '"+patientCode+"' and DATE_FORMAT(a.record_date,'%Y-%m') = '"+choseMonth+"' and a.device_sn = '"+deviceSn+"' and a.del = '1' order by a.record_date,a.id";
 | 
												
													
														
															|  | 
 |  | 			List<Map<String,Object>> reusltList = jdbcTemplate.queryForList(sql);
 | 
												
													
														
															|  | 
 |  | 			List<String> list = new ArrayList<>();
 | 
												
													
														
															|  | 
 |  | 			for (Map<String,Object> map : reusltList){
 | 
												
													
														
															|  | 
 |  | 				list.add(String.valueOf(map.get("result")));
 | 
												
													
														
															|  | 
 |  | 			}
 | 
												
													
														
															|  | 
 |  | 			return write(200, "获取健康指标记录日期成功", "data", list);
 | 
												
													
														
															|  | 
 |  | 		}catch (Exception e){
 | 
												
													
														
															|  | 
 |  | 			return invalidUserException(e, -1, e.getMessage());
 | 
												
													
														
															|  | 
 |  | 		}
 | 
												
													
														
															|  | 
 |  | 	}
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 	@RequestMapping(value = "/patientHealthIndexByDateAndDeviceSn",method = RequestMethod.GET)
 | 
												
													
														
															|  | 
 |  | 	@ApiOperation("医生端--根据时间和设备sn码查询某个居民的体征记录")
 | 
												
													
														
															|  | 
 |  | 	public String patientHealthIndexByDateAndDeviceSn(@ApiParam(value = "居民code)", name = "patientCode") @RequestParam(value = "patientCode",required = true)String patientCode,
 | 
												
													
														
															|  | 
 |  | 													  @ApiParam(value = "设备sn码", name = "deviceSn") @RequestParam(value = "deviceSn",required = true)String deviceSn,
 | 
												
													
														
															|  | 
 |  | 													  @ApiParam(value = "日期", name = "choseDay") @RequestParam(value = "choseDay",required = true)String choseDay,
 | 
												
													
														
															|  | 
 |  | 													  @ApiParam(value = "健康指标类型(1血糖,2血压,3体重,4腰围)",name = "type")@RequestParam(value = "type",required = true)int type){
 | 
												
													
														
															|  | 
 |  | 		try {
 | 
												
													
														
															|  | 
 |  | 			List<Map<String,String>> list = healthIndexService.getHealthIndexByPatientAndDate(patientCode,deviceSn,choseDay,type);
 | 
												
													
														
															|  | 
 |  | 			return write(200, "获取健康指标历史记录成功", "data", list);
 | 
												
													
														
															|  | 
 |  | 		} catch (Exception ex) {
 | 
												
													
														
															|  | 
 |  | 			return invalidUserException(ex, -1, ex.getMessage());
 | 
												
													
														
															|  | 
 |  | 		}
 | 
												
													
														
															|  | 
 |  | 	}
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 	@RequestMapping(value = "getHealthIndexById",method = RequestMethod.GET)
 | 
												
													
														
															|  | 
 |  | 	@ApiOperation("根据体征记录id获取体征记录详情")
 | 
												
													
														
															|  | 
 |  | 	public String getHealthIndexById(@ApiParam("体征记录id")
 | 
												
													
														
															|  | 
 |  | 						 @RequestParam Long id) {
 | 
												
													
														
															|  | 
 |  | 		try {
 | 
												
													
														
															|  | 
 |  | 			DevicePatientHealthIndex patientHealthIndex = healthIndexService.getHealthIndexById(id);
 | 
												
													
														
															|  | 
 |  | 			return write(200, "查询成功", "data", patientHealthIndex);
 | 
												
													
														
															|  | 
 |  | 		} catch (Exception e) {
 | 
												
													
														
															|  | 
 |  | 			error(e);
 | 
												
													
														
															|  | 
 |  | 			return error(-1, "查询失败");
 | 
												
													
														
															|  | 
 |  | 		}
 | 
												
													
														
															|  | 
 |  | 	}
 | 
												
													
														
															|  | 
 |  | }
 |