|
@ -191,32 +191,31 @@ public class DeviceHealthIndexService extends BaseDeviceJpaService<DeviceHealthI
|
|
|
User loginUser = (User) request.getSession().getAttribute("userInfo");
|
|
|
|
|
|
StringBuilder filter = new StringBuilder();
|
|
|
String sql = "SELECT a.patient FROM wlyy.wlyy_sign_family a, wlyy.wlyy_patient b WHERE a.status > 0 AND a.patient = b.code ";
|
|
|
|
|
|
String sql =" SELECT i.* ,s.name userName FROM device.wlyy_patient_health_index i , wlyy.wlyy_sign_family s WHERE s. STATUS > 0 and i.user=s.patient ";
|
|
|
//1、管理员 2、医生 0、其他
|
|
|
if(loginUser.getType()==2){
|
|
|
Doctor doctor = doctorDao.findByCode(loginUser.getCode());
|
|
|
if(doctor!=null &&StringUtils.isNotEmpty(doctor.getHospital())){
|
|
|
|
|
|
sql += " AND a.hospital = '"+doctor.getHospital()+"' ";
|
|
|
filter.append(" AND s.hospital = '"+doctor.getHospital()+"' ");
|
|
|
}
|
|
|
}
|
|
|
//根据患者名称过滤
|
|
|
if(!StringUtils.isEmpty(userName)){
|
|
|
sql +=" AND b.NAME LIKE '%"+userName+"%'";
|
|
|
filter.append(" AND s.NAME LIKE '%"+userName+"%' ");
|
|
|
}
|
|
|
//根据健管师或医生名称过滤
|
|
|
if(!StringUtils.isEmpty(doctorName)){
|
|
|
sql += " and (a.doctor_name like '%"+doctorName+"%' or a.doctor_health_name like '%"+doctorName+"%') ";
|
|
|
filter.append(" and (s.doctor_name like '%"+doctorName+"%' or s.doctor_health_name like '%"+doctorName+"%') ");
|
|
|
}
|
|
|
List<String> patientList = jdbcTemplate.queryForList(sql,String.class);
|
|
|
|
|
|
if(!StringUtils.isEmpty(deviceSn)){
|
|
|
filter.append("deviceSn="+deviceSn+";");
|
|
|
filter.append(" and i.deviceSn="+deviceSn);
|
|
|
}
|
|
|
if(!StringUtils.isEmpty(idcard)){
|
|
|
filter.append("idcard="+idcard+";");
|
|
|
filter.append(" and i.idcard="+idcard);
|
|
|
}
|
|
|
//体征数据创建时间
|
|
|
if(!StringUtils.isEmpty(date)){
|
|
|
Date startTimeTemp = DateTimeUtil.simpleDateParse(date);
|
|
|
Calendar calendar = new GregorianCalendar();
|
|
@ -226,58 +225,72 @@ public class DeviceHealthIndexService extends BaseDeviceJpaService<DeviceHealthI
|
|
|
calendar.set(Calendar.SECOND,59);
|
|
|
calendar.set(Calendar.MILLISECOND,999);
|
|
|
Date endTimeTemp = calendar.getTime();
|
|
|
filter.append("czrq>=" + DateTimeUtil.utcDateTimeFormat(startTimeTemp)+ ";");
|
|
|
filter.append("czrq<=" + DateTimeUtil.utcDateTimeFormat(endTimeTemp)+ ";");
|
|
|
}
|
|
|
if(patientList != null && patientList.size() >0){
|
|
|
String temp = StringUtils.join(patientList, ",");
|
|
|
filter.append("user="+temp+";");
|
|
|
filter.append(" and i.czrq>=" + DateTimeUtil.utcDateTimeFormat(startTimeTemp));
|
|
|
filter.append(" and i.czrq<=" + DateTimeUtil.utcDateTimeFormat(endTimeTemp));
|
|
|
}
|
|
|
|
|
|
//指标类型
|
|
|
if(!StringUtils.isEmpty(indexType)){
|
|
|
filter.append("type="+indexType+";");
|
|
|
filter.append(" and i.type="+indexType);
|
|
|
}
|
|
|
//体征数据
|
|
|
if("1".equals(indexType)||"2".equals(indexType)||"4".equals(indexType)){
|
|
|
if(indexTypeMin1!=null){
|
|
|
filter.append("value1>="+indexTypeMin1+";");
|
|
|
filter.append(" and value1>="+indexTypeMin1);
|
|
|
}
|
|
|
if(indexTypeMax1!=null){
|
|
|
filter.append("value1<="+indexTypeMax1+";");
|
|
|
filter.append(" and value1<="+indexTypeMax1);
|
|
|
}
|
|
|
if(indexTypeMin2!=null){
|
|
|
filter.append("value2>="+indexTypeMin2+";");
|
|
|
filter.append(" and value2>="+indexTypeMin2);
|
|
|
}
|
|
|
if(indexTypeMax2!=null){
|
|
|
filter.append("value2<="+indexTypeMax2+";");
|
|
|
filter.append(" and value2<="+indexTypeMax2);
|
|
|
}
|
|
|
}else{
|
|
|
if(indexTypeMin1!=null){
|
|
|
filter.append("value3>="+indexTypeMin1+";");
|
|
|
filter.append(" and value3>="+indexTypeMin1);
|
|
|
}
|
|
|
if(indexTypeMax1!=null){
|
|
|
filter.append("value3<="+indexTypeMax1+";");
|
|
|
filter.append(" and value3<="+indexTypeMax1);
|
|
|
}
|
|
|
if(indexTypeMin2!=null){
|
|
|
filter.append("value4>="+indexTypeMin2+";");
|
|
|
filter.append(" and value4>="+indexTypeMin2);
|
|
|
}
|
|
|
if(indexTypeMax2!=null){
|
|
|
filter.append("value4<="+indexTypeMax2+";");
|
|
|
filter.append(" and value4<="+indexTypeMax2);
|
|
|
}
|
|
|
}
|
|
|
List<DeviceHealthIndex> list = (List<DeviceHealthIndex>)search(filter.toString());
|
|
|
String f = filter.toString();
|
|
|
List<Map<String, Object>> resultList = jdbcTemplate.queryForList(sql+f+" order by i.czrq desc ");
|
|
|
|
|
|
String regex = "(\\w{3})(\\w+)(\\w{3})";
|
|
|
List<DeviceHealthIndexVO> listTemp = new ArrayList<>();
|
|
|
if(list !=null && list.size()>0){
|
|
|
for (DeviceHealthIndex info : list){
|
|
|
if(resultList !=null && resultList.size()>0){
|
|
|
for (Map<String, Object> info : resultList){
|
|
|
DeviceHealthIndexVO bean = new DeviceHealthIndexVO();
|
|
|
BeanUtils.copyProperties(info, bean);
|
|
|
// BeanUtils.copyProperties(bean, info);
|
|
|
Patient patient = findPatient(bean.getUser());
|
|
|
bean.setUserName(patient== null?"":patient.getName());
|
|
|
bean.setId(Long.getLong(info.get("id")+""));
|
|
|
bean.setCzrq(info.get("czrq")!=null?(Date)info.get("czrq"):null);
|
|
|
bean.setDel(info.get("del")!=null?info.get("del")+"":null);
|
|
|
bean.setDeviceSn(info.get("device_sn")!=null?info.get("device_sn")+"":null);
|
|
|
bean.setIdcard(info.get("idcard")!=null?info.get("idcard")+"":null);
|
|
|
bean.setIntervene(info.get("intervene")!=null?info.get("intervene")+"":null);
|
|
|
bean.setRecordDate(info.get("record_date")!=null?(Date)info.get("record_date"):null);
|
|
|
bean.setSortDate(info.get("sort_date")!=null?(Date)info.get("sort_date"):null);
|
|
|
bean.setStatus(info.get("status")!=null?(Integer)info.get("status"):null);
|
|
|
bean.setType(info.get("type")!=null?(Integer)info.get("type"):0);
|
|
|
bean.setUser(info.get("user")!=null?info.get("user")+"":null);
|
|
|
bean.setUserName(info.get("userName")!=null?info.get("userName")+"":null);
|
|
|
bean.setValue1(info.get("value1")!=null?info.get("value1")+"":null);
|
|
|
bean.setValue2(info.get("value2")!=null?info.get("value2")+"":null);
|
|
|
bean.setValue3(info.get("value3")!=null?info.get("value3")+"":null);
|
|
|
bean.setValue4(info.get("value4")!=null?info.get("value4")+"":null);
|
|
|
bean.setValue5(info.get("value5")!=null?info.get("value5")+"":null);
|
|
|
bean.setValue6(info.get("value6")!=null?info.get("value6")+"":null);
|
|
|
bean.setValue7(info.get("value7")!=null?info.get("value7")+"":null);
|
|
|
if(StringUtils.isNotBlank(bean.getIdcard())){
|
|
|
bean.setIdcard(bean.getIdcard().replaceAll(regex, "$1****$3"));
|
|
|
}
|
|
|
bean.setHealthStandard(gethealthStandard(info.getType(),info.getUser()).toString());
|
|
|
bean.setHealthStandard(gethealthStandard(bean.getType(),bean.getUser()).toString());
|
|
|
listTemp.add(bean);
|
|
|
}
|
|
|
}
|