|
@ -35,11 +35,13 @@ import com.yihu.jw.util.common.GpsUtil;
|
|
|
import com.yihu.jw.util.common.IdCardUtil;
|
|
|
import com.yihu.jw.util.common.LatitudeUtils;
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
import com.yihu.jw.util.healthIndex.HealthIndexUtil;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.json.JSONArray;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
@ -88,6 +90,8 @@ public class PatientInfoPlatFormService {
|
|
|
private YsDeviceService ysDeviceService;
|
|
|
@Autowired
|
|
|
private GpsUtil gpsUtil;
|
|
|
@Autowired
|
|
|
private HealthIndexUtil healthIndexUtil;
|
|
|
|
|
|
|
|
|
/**
|
|
@ -1063,16 +1067,7 @@ public class PatientInfoPlatFormService {
|
|
|
map.put("warningCount",warningCount);
|
|
|
|
|
|
//查一般预警(体征预警)
|
|
|
String healthSql = "SELECT\n" +
|
|
|
"\tcount( idx.id ) \n" +
|
|
|
"FROM\n" +
|
|
|
"\twlyy_patient_health_index idx\n" +
|
|
|
"\tINNER JOIN base_patient p ON idx.USER = p.id AND p.del = 1 \n" +
|
|
|
"WHERE\n" +
|
|
|
"\tidx.status = 1 \n" +
|
|
|
"\tAND idx.del = 1 \n" +
|
|
|
"\tAND idx.type < 3 \n" + filter2;
|
|
|
Long healthCount = jdbcTemplate.queryForObject(healthSql, Long.class);
|
|
|
Long healthCount = this.getWarningCountByHealth(filter2);
|
|
|
map.put("healthCount",healthCount);
|
|
|
map.put("total",warningCount+healthCount);
|
|
|
return ObjEnvelop.getSuccess("获取成功",map);
|
|
@ -1105,7 +1100,7 @@ public class PatientInfoPlatFormService {
|
|
|
"\tord.patient,\n" +
|
|
|
"\tp.NAME,\n" +
|
|
|
"\t'紧急呼叫' AS serve_desc,\n" +
|
|
|
"\tDATE_FORMAT( ord.create_time, '%Y-%m-%d %H:%i:%S' ) create_time,\n" +
|
|
|
"\tDATE_FORMAT( ord.create_time, '%Y-%m-%d %H:%i:%S' ) createTime,\n" +
|
|
|
"\tord.`status`,\n" +
|
|
|
"CASE\n" +
|
|
|
"\t\tp.sex \n" +
|
|
@ -1129,7 +1124,7 @@ public class PatientInfoPlatFormService {
|
|
|
"\t\tord.patient,\n" +
|
|
|
"\t\tp.NAME,\n" +
|
|
|
"\t\tord.serve_desc,\n" +
|
|
|
"\t\tDATE_FORMAT( ord.create_time, '%Y-%m-%d %H:%i:%S' ) create_time,\n" +
|
|
|
"\t\tDATE_FORMAT( ord.create_time, '%Y-%m-%d %H:%i:%S' ) createTime,\n" +
|
|
|
"\t\tord.`status`,\n" +
|
|
|
"\tCASE\n" +
|
|
|
"\t\t\tp.sex \n" +
|
|
@ -1146,30 +1141,95 @@ public class PatientInfoPlatFormService {
|
|
|
|
|
|
String sql = "select * FROM (" +
|
|
|
"\t"+sql1+" UNION "+sql2 +
|
|
|
"\t) t order by t.create_time desc limit "+page*pageSize+","+pageSize;
|
|
|
"\t) t order by t.createTime desc limit "+page*pageSize+","+pageSize;
|
|
|
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
return PageEnvelop.getSuccessListWithPage("获取成功",list,page,pageSize,this.getWarningCountByEmergencyAndSecurity(filter));
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 获取体征预警中的列表
|
|
|
* @param page
|
|
|
* @param pageSize
|
|
|
* @param patient
|
|
|
* @return
|
|
|
*/
|
|
|
public PageEnvelop getHealthWarningList(Integer page,Integer pageSize,String patient){
|
|
|
page = page>0?page-1:0;
|
|
|
|
|
|
String filter=" ";
|
|
|
String sqltmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_child' or dict_name = 'jkzl_older' ";
|
|
|
List<Map<String,Object>> listtmp = jdbcTemplate.queryForList(sqltmp);
|
|
|
if(listtmp.size()>0){
|
|
|
String orgCodes = String.valueOf(listtmp.get(0).get("orgCodes"));
|
|
|
orgCodes = orgCodes.replaceAll(",","','");
|
|
|
filter = " and idx.user not in ('"+orgCodes+"') ";
|
|
|
}
|
|
|
String sql = "SELECT\n" +
|
|
|
"\t\tidx.id,\n" +
|
|
|
"\t\tidx.USER,\n" +
|
|
|
"\t\tidx.`name`,idx.type,\n" +
|
|
|
"\t\tp.archive_type archiveType,\n" +
|
|
|
"\t\tp.residential_area residentialArea,\n" +
|
|
|
"\t\t'健康监测' AS serve_desc,\n" +
|
|
|
"\tTIMESTAMPDIFF(YEAR,p.birthday,now()) AS age, \n" +
|
|
|
"\t\tidx.czrq,\n" +
|
|
|
"\t\tvalue1,\n" +
|
|
|
"\t\tvalue2,\n" +
|
|
|
"\t\tvalue3,\n" +
|
|
|
"\t\tvalue4,\n" +
|
|
|
"\t\tvalue5,\n" +
|
|
|
"\t\tvalue6,\n" +
|
|
|
"\t\tvalue7,\n" +
|
|
|
"\t\ttype,DATE_FORMAT( idx.czrq, '%Y-%m-%d %H:%i:%S' ) createTime \n" +
|
|
|
"\tFROM\n" +
|
|
|
"\t\twlyy_patient_health_index idx\n" +
|
|
|
"\t\tINNER JOIN base_patient p ON idx.USER = p.id AND p.del = 1 \n" +
|
|
|
"\tWHERE\n" +
|
|
|
"\t\tidx.del = 1 \n" +
|
|
|
"\t\tand idx.status=1 \n" +
|
|
|
"\t\tAND idx.type < 3 "+filter+" ORDER By idx.czrq DESC limit "+page*pageSize+","+pageSize;
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
if(!ObjectUtils.isEmpty(list)){
|
|
|
//查体征预警信息,偏高偏低
|
|
|
for (Map<String, Object> map : list) {
|
|
|
com.alibaba.fastjson.JSONArray info = healthIndexUtil.verifyHealthIndex(
|
|
|
Integer.parseInt(map.get("type").toString()),
|
|
|
null==map.get("value1")?"":map.get("value1").toString(),
|
|
|
null==map.get("value2")?"":map.get("value2").toString(),
|
|
|
null==map.get("value3")?"":map.get("value3").toString());
|
|
|
//去除正常的值
|
|
|
Iterator it = info.iterator();
|
|
|
while (it.hasNext()){
|
|
|
JSONObject next = (JSONObject)it.next();
|
|
|
if("0".equals(next.getString("error"))){
|
|
|
it.remove();
|
|
|
}
|
|
|
}
|
|
|
map.put("info",info);
|
|
|
}
|
|
|
}
|
|
|
return PageEnvelop.getSuccessListWithPage("获取成功",list,page,pageSize,this.getWarningCountByHealth(filter));
|
|
|
}
|
|
|
/**
|
|
|
* 获取紧急呼救和安防工单正在预警中的总数
|
|
|
* @param filter1
|
|
|
* @param filter
|
|
|
* @return
|
|
|
*/
|
|
|
Long getWarningCountByEmergencyAndSecurity(String filter1){
|
|
|
Long getWarningCountByEmergencyAndSecurity(String filter){
|
|
|
//紧急呼救
|
|
|
String emergencySql = "SELECT count( ord.id ) warningCount \n" +
|
|
|
"\tFROM\n" +
|
|
|
"\t\tbase_emergency_assistance_order ord\n" +
|
|
|
"\t\tINNER JOIN base_patient p ON ord.patient = p.id and p.del=1 \n" +
|
|
|
"\tWHERE\n" +
|
|
|
"\t\t ord.STATUS = 1"+filter1;
|
|
|
"\t\t ord.STATUS = 1"+filter;
|
|
|
//安防监护
|
|
|
String securitySql = "SELECT count( ord.id ) warningCount \n" +
|
|
|
"\tFROM\n" +
|
|
|
"\t\tbase_security_monitoring_order ord\n" +
|
|
|
"\t\tINNER JOIN base_patient p ON ord.patient = p.id and p.del=1 \n" +
|
|
|
"\t\tAND ord.STATUS = 1"+filter1;
|
|
|
"\t\tAND ord.STATUS = 1"+filter;
|
|
|
String sqlCount = "SELECT\n" +
|
|
|
"\tsum( warningCount ) warningCount\n" +
|
|
|
"FROM\n" +
|
|
@ -1177,4 +1237,22 @@ public class PatientInfoPlatFormService {
|
|
|
") t";
|
|
|
return jdbcTemplate.queryForObject(sqlCount, Long.class);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取一般体征预警中的总数
|
|
|
* @param filter
|
|
|
* @return
|
|
|
*/
|
|
|
Long getWarningCountByHealth(String filter){
|
|
|
String healthSql = "SELECT\n" +
|
|
|
"\tcount( idx.id ) \n" +
|
|
|
"FROM\n" +
|
|
|
"\twlyy_patient_health_index idx\n" +
|
|
|
"\tINNER JOIN base_patient p ON idx.USER = p.id AND p.del = 1 \n" +
|
|
|
"WHERE\n" +
|
|
|
"\tidx.status = 1 \n" +
|
|
|
"\tAND idx.del = 1 \n" +
|
|
|
"\tAND idx.type < 3 \n" + filter;
|
|
|
return jdbcTemplate.queryForObject(healthSql, Long.class);
|
|
|
}
|
|
|
}
|