liubing пре 3 година
родитељ
комит
05dfe88a78

+ 25 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/third/platForm/PatientInfoPlatFormEndpoint.java

@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.care.endpoint.BaseController;
import com.yihu.jw.care.service.assistance.EmergencyAssistanceService;
import com.yihu.jw.care.service.common.DictService;
import com.yihu.jw.care.service.device.PatientHealthIndexService;
import com.yihu.jw.care.service.doorCoach.DoctorDoorCoachOrderService;
import com.yihu.jw.care.service.doorCoach.PatientDoorCoachOrderService;
import com.yihu.jw.care.service.lifeCare.LifeCareOrderService;
@ -58,6 +59,8 @@ public class PatientInfoPlatFormEndpoint extends EnvelopRestEndpoint {
    private BaseServiceNewsService baseServiceNewsService;
    @Autowired
    private DictService dictService;
    @Autowired
    private PatientHealthIndexService healthIndexService;
    private BaseController baseController = new BaseController();
@ -162,6 +165,28 @@ public class PatientInfoPlatFormEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "getHealthIndexInfoWithAvg")
    @ApiOperation("获取居民体征信息--带体征平均值")
    public String getHealthIndexInfoWithAvg(@ApiParam(name="patient",value="患者代码",defaultValue = "eb0b478fbe9245428ecf63cd7517206f")
                                     @RequestParam(value="patient",required = false) String patient,
                                     @ApiParam(name="type",value="指标类型",defaultValue = "1")
                                     @RequestParam(value="type",required = true) Integer type,
                                     @ApiParam(name="gi_type",value="就餐类型",defaultValue = "0")
                                     @RequestParam(value = "gi_type",required = false) Integer 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,
                                     @ApiParam(name = "deviceSn",required = false)
                                     @RequestParam(value = "deviceSn",required = false) String deviceSn){
        try {
            return baseController.write(200,"查询成功","data",healthIndexService.findChartByPatientWithAvg(patient,type,gi_type,begin,end,deviceSn));
        }catch (Exception e){
            return baseController.errorResult(e);
        }
    }
    @GetMapping(value = "getHealthIndexInfo")
    @ApiOperation("获取居民体征信息")
    public String getHealthIndexInfo(@ApiParam(name="patient",value="患者代码",defaultValue = "eb0b478fbe9245428ecf63cd7517206f")

+ 1 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/assistance/EmergencyAssistanceService.java

@ -126,7 +126,7 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
    private BaseDoctorHospitalDao baseDoctorHospitalDao;
    @Autowired
    private BaseOrgDao orgDao;
    @Autowired
    private DeviceDetailDao deviceDetailDao;
    /**

+ 76 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/PatientHealthIndexService.java

@ -863,7 +863,82 @@ public class PatientHealthIndexService extends BaseJpaService<DevicePatientHealt
        }
        return re;
    }
    
    public JSONObject findChartByPatientWithAvg(String patient, int type, int gi_type, String begin, String end,String deviceSn) {
        JSONObject result = new JSONObject();
        JSONArray re = new JSONArray();
        String sql = "SELECT " +
                "MIN(id) id" +
                ", user" +
                ",value1" +
                ",value2" +
                ",value3" +
                ",value4" +
                ",value5" +
                ",value6" +
                ",value7" +
                ",device_sn" +
                ",type" +
                ",record_date" +
                ",sort_date" +
                ",min(czrq) czrq " +
                " from wlyy_patient_health_index " +
                " WHERE 1=1 "+
                " and type =" + type +
                " and record_date >= '" + begin + "'" +
                " and record_date <= '" + end + "' " +
                " and del = '1' ";
        if (StringUtils.isNotBlank(patient)){
            sql+=" and user = '" + patient + "' ";
        }
        if (StringUtils.isNotBlank(deviceSn)){
            sql += " and device_sn='"+deviceSn+"' ";
        }
        String conditionApp = "";
        if (gi_type != 0) {
            conditionApp = " and value2 = '" + gi_type + "' ";
        }
        sql = sql + conditionApp +
                " GROUP BY user,value1,value2,value3,value4,value5,value6,value7,type,record_date,sort_date " +
                " order by record_date desc ,sort_date desc limit " + 0 + " ," + 1000 + " ";
//        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        List<Map<String, Object>> list = findByPatientAndTime(sql,patient,type,1000,gi_type,begin,end);
        for (Map<String, Object> map : list) {
            JSONObject json = new JSONObject();
            json.put("id", map.get("id"));
            json.put("patient", map.get("user"));
            json.put("value1", map.get("value1"));
            json.put("value2", map.get("value2"));
            json.put("value3", map.get("value3"));
            json.put("value4", map.get("value4"));
            json.put("value5", map.get("value5"));
            json.put("value6", map.get("value6"));
            json.put("value7", map.get("value7"));
            json.put("deviceSn", map.get("device_sn") == null ? "" : map.get("device_sn"));
            json.put("type", map.get("type"));
            Date date = (Date) map.get("record_date");
            if (type == 2) {
                json.put("date", DateUtil.dateToStr(date, DateUtil.YYYY_MM_DD_HH_MM_SS));
            } else {
                json.put("date", DateUtil.dateToStr(date, DateUtil.YYYY_MM_DD));
            }
            json.put("sortDate", map.get("sort_date"));
            json.put("czrq", map.get("czrq"));
            re.put(json);
        }
        result.put("list",re);
        OptionalDouble avg =  list.stream().mapToDouble(t -> t.get("value1") == null ? 0.0 :Double.parseDouble(t.get("value1").toString())).average();
        result.put("avg",0.0);
        try {
            result.put("avg",avg.getAsDouble());
        }catch (Exception e){}
        return result;
    }
    /**
     * 按时间段查询患者健康指标
     *