|
@ -29,16 +29,19 @@ import com.yihu.jw.entity.care.securitymonitoring.SecurityMonitoringOrderDO;
|
|
import com.yihu.jw.entity.care.sign.CapacityAssessmentRecordDO;
|
|
import com.yihu.jw.entity.care.sign.CapacityAssessmentRecordDO;
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
import com.yihu.jw.restmodel.ResponseContant;
|
|
import com.yihu.jw.restmodel.ResponseContant;
|
|
|
|
import com.yihu.jw.restmodel.web.ObjEnvelop;
|
|
import com.yihu.jw.restmodel.web.PageEnvelop;
|
|
import com.yihu.jw.restmodel.web.PageEnvelop;
|
|
import com.yihu.jw.util.common.GpsUtil;
|
|
import com.yihu.jw.util.common.GpsUtil;
|
|
import com.yihu.jw.util.common.IdCardUtil;
|
|
import com.yihu.jw.util.common.IdCardUtil;
|
|
import com.yihu.jw.util.common.LatitudeUtils;
|
|
import com.yihu.jw.util.common.LatitudeUtils;
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
|
import com.yihu.jw.util.healthIndex.HealthIndexUtil;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.json.JSONArray;
|
|
import org.json.JSONArray;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
@ -87,6 +90,8 @@ public class PatientInfoPlatFormService {
|
|
private YsDeviceService ysDeviceService;
|
|
private YsDeviceService ysDeviceService;
|
|
@Autowired
|
|
@Autowired
|
|
private GpsUtil gpsUtil;
|
|
private GpsUtil gpsUtil;
|
|
|
|
@Autowired
|
|
|
|
private HealthIndexUtil healthIndexUtil;
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@ -477,7 +482,7 @@ public class PatientInfoPlatFormService {
|
|
return PageEnvelop.getSuccessListWithPage("查询成功",list,page,pageSize,count);
|
|
return PageEnvelop.getSuccessListWithPage("查询成功",list,page,pageSize,count);
|
|
}
|
|
}
|
|
|
|
|
|
public PageEnvelop getEmergencyWarnOrderListNew(Integer page,Integer pageSize,String patient){
|
|
|
|
|
|
public PageEnvelop getEmergencyWarnOrderListNew(Integer page,Integer pageSize,String patient,String beginTime,String endTime){
|
|
page = page>0?page-1:0;
|
|
page = page>0?page-1:0;
|
|
String filter =" ";
|
|
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' ";
|
|
String sqltmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_child' or dict_name = 'jkzl_older' ";
|
|
@ -490,10 +495,13 @@ public class PatientInfoPlatFormService {
|
|
|
|
|
|
String sql = " select '22' as 'OrderType',p.archive_type archiveType,p.residential_area residentialArea,ord.id,ord.patient,p.name,ord.serve_desc,DATE_FORMAT(ord.create_time,'%Y-%m-%d %H:%i:%S') create_time," +
|
|
String sql = " select '22' as 'OrderType',p.archive_type archiveType,p.residential_area residentialArea,ord.id,ord.patient,p.name,ord.serve_desc,DATE_FORMAT(ord.create_time,'%Y-%m-%d %H:%i:%S') create_time," +
|
|
"ord.`status`,case p.sex when 1 then '男' when 2 then '女' else p.sex end as sex,TIMESTAMPDIFF(YEAR,p.birthday,now()) as age \n" +
|
|
"ord.`status`,case p.sex when 1 then '男' when 2 then '女' else p.sex end as sex,TIMESTAMPDIFF(YEAR,p.birthday,now()) as age \n" +
|
|
"from base_security_monitoring_order ord INNER JOIN base_patient p on ord.patient = p.id " ;
|
|
|
|
|
|
"from base_security_monitoring_order ord INNER JOIN base_patient p on ord.patient = p.id where 1=1 " ;
|
|
if (StringUtils.isNotBlank(patient)){
|
|
if (StringUtils.isNotBlank(patient)){
|
|
sql +=" and ord.patient='"+patient+"' ";
|
|
sql +=" and ord.patient='"+patient+"' ";
|
|
}
|
|
}
|
|
|
|
if(StringUtils.isNotBlank(beginTime) && StringUtils.isNotBlank(endTime)){
|
|
|
|
sql +=" and ord.create_time>='"+beginTime+"' and ord.create_time<='"+endTime+"' ";
|
|
|
|
}
|
|
sql+= filter +" order by create_time desc ";
|
|
sql+= filter +" order by create_time desc ";
|
|
String countSql = "select count(id) from ("+sql+")A ";
|
|
String countSql = "select count(id) from ("+sql+")A ";
|
|
long count = jdbcTemplate.queryForObject(countSql,long.class);
|
|
long count = jdbcTemplate.queryForObject(countSql,long.class);
|
|
@ -639,7 +647,7 @@ public class PatientInfoPlatFormService {
|
|
return PageEnvelop.getSuccessListWithPage("查询成功",list,page,pageSize,count);
|
|
return PageEnvelop.getSuccessListWithPage("查询成功",list,page,pageSize,count);
|
|
}
|
|
}
|
|
|
|
|
|
public PageEnvelop getEmergencyWarningListNew(Integer page,Integer pageSize,String patient){
|
|
|
|
|
|
public PageEnvelop getEmergencyWarningListNew(Integer page,Integer pageSize,String patient,String beginTime,String endTime){
|
|
page = page>0?page-1:0;
|
|
page = page>0?page-1:0;
|
|
String filter=" ";
|
|
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' ";
|
|
String sqltmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_child' or dict_name = 'jkzl_older' ";
|
|
@ -657,6 +665,9 @@ public class PatientInfoPlatFormService {
|
|
if (StringUtils.isNotBlank(patient)){
|
|
if (StringUtils.isNotBlank(patient)){
|
|
filter +=" and ord.patient='"+patient+"' ";
|
|
filter +=" and ord.patient='"+patient+"' ";
|
|
}
|
|
}
|
|
|
|
if(StringUtils.isNotBlank(beginTime) && StringUtils.isNotBlank(endTime)){
|
|
|
|
filter += " and ord.create_time>='"+beginTime+"' and ord.create_time<='"+endTime+"' ";
|
|
|
|
}
|
|
|
|
|
|
sql += filter + " order by create_time desc";
|
|
sql += filter + " order by create_time desc";
|
|
sqlCount +=filter;
|
|
sqlCount +=filter;
|
|
@ -666,7 +677,7 @@ public class PatientInfoPlatFormService {
|
|
return PageEnvelop.getSuccessListWithPage("查询成功",list,page,pageSize,count);
|
|
return PageEnvelop.getSuccessListWithPage("查询成功",list,page,pageSize,count);
|
|
}
|
|
}
|
|
|
|
|
|
public PageEnvelop getHealthMonitoringListNew(Integer page,Integer pageSize){
|
|
|
|
|
|
public PageEnvelop getHealthMonitoringListNew(Integer page,Integer pageSize,String beginTime,String endTime){
|
|
page = page>0?page-1:0;
|
|
page = page>0?page-1:0;
|
|
|
|
|
|
String filter=" ";
|
|
String filter=" ";
|
|
@ -677,9 +688,12 @@ public class PatientInfoPlatFormService {
|
|
orgCodes = orgCodes.replaceAll(",","','");
|
|
orgCodes = orgCodes.replaceAll(",","','");
|
|
filter = " and idx.user not in ('"+orgCodes+"') ";
|
|
filter = " and idx.user not in ('"+orgCodes+"') ";
|
|
}
|
|
}
|
|
|
|
if(StringUtils.isNotBlank(beginTime) && StringUtils.isNotBlank(endTime)){
|
|
|
|
filter+=" and idx.czrq>='"+beginTime+"' and idx.czrq<='"+endTime+"' ";
|
|
|
|
}
|
|
|
|
|
|
String sql = " SELECT idx.id,idx.user,idx.`name`,p.archive_type archiveType,p.residential_area residentialArea,'健康监测' as serve_desc, " +
|
|
String sql = " SELECT idx.id,idx.user,idx.`name`,p.archive_type archiveType,p.residential_area residentialArea,'健康监测' as serve_desc, " +
|
|
"idx.czrq,value1,value2,value3,value4,value5,value6,value7,type FROM wlyy_patient_health_index idx " +
|
|
|
|
|
|
"idx.czrq,value1,value2,value3,value4,value5,value6,value7,type,DATE_FORMAT(idx.czrq,'%Y-%m-%d %H:%i:%S') createTime FROM wlyy_patient_health_index idx " +
|
|
" INNER JOIN base_patient p on idx.user = p.id and p.del=1\n" +
|
|
" INNER JOIN base_patient p on idx.user = p.id and p.del=1\n" +
|
|
" WHERE idx.del = 1 AND idx.type < 3 "+filter+" ORDER BY idx.czrq desc ";
|
|
" WHERE idx.del = 1 AND idx.type < 3 "+filter+" ORDER BY idx.czrq desc ";
|
|
String countSql = "select count(id) from ("+sql+")A ";
|
|
String countSql = "select count(id) from ("+sql+")A ";
|
|
@ -1039,4 +1053,222 @@ public class PatientInfoPlatFormService {
|
|
return detailInfo;
|
|
return detailInfo;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取紧急预警和一般预警中的总数
|
|
|
|
* @param patient
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public ObjEnvelop getWarningCount(String patient){
|
|
|
|
String filter1=" ";
|
|
|
|
String filter2=" ";
|
|
|
|
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&&StringUtils.isBlank(patient)){
|
|
|
|
String orgCodes = String.valueOf(listtmp.get(0).get("orgCodes"));
|
|
|
|
orgCodes = orgCodes.replaceAll(",","','");
|
|
|
|
filter1 = " and ord.patient not in ('"+orgCodes+"') ";
|
|
|
|
filter2 = " and idx.user not in ('"+orgCodes+"') ";
|
|
|
|
}
|
|
|
|
//查紧急预警
|
|
|
|
Long warningCount = this.getWarningCountByEmergencyAndSecurity(filter1);
|
|
|
|
Map<String,Object> map = new HashMap<String,Object>();
|
|
|
|
map.put("warningCount",warningCount);
|
|
|
|
|
|
|
|
//查一般预警(体征预警)
|
|
|
|
Long healthCount = this.getWarningCountByHealth(filter2);
|
|
|
|
map.put("healthCount",healthCount);
|
|
|
|
map.put("total",warningCount+healthCount);
|
|
|
|
return ObjEnvelop.getSuccess("获取成功",map);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取紧急预警中的列表
|
|
|
|
* @param page
|
|
|
|
* @param pageSize
|
|
|
|
* @param patient
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public PageEnvelop getWarningList(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&&StringUtils.isBlank(patient)){
|
|
|
|
String orgCodes = String.valueOf(listtmp.get(0).get("orgCodes"));
|
|
|
|
orgCodes = orgCodes.replaceAll(",","','");
|
|
|
|
filter = " and ord.patient not in ('"+orgCodes+"') ";
|
|
|
|
}
|
|
|
|
|
|
|
|
String sql1 = "SELECT\n" +
|
|
|
|
"\t'20' AS OrderType,\n" +
|
|
|
|
"\tp.archive_type archiveType,\n" +
|
|
|
|
"\tp.residential_area residentialArea,\n" +
|
|
|
|
"\tord.id,\n" +
|
|
|
|
"\tord.patient,\n" +
|
|
|
|
"\tp.NAME,\n" +
|
|
|
|
"\t'紧急呼叫' AS serve_desc,\n" +
|
|
|
|
"\tDATE_FORMAT( ord.create_time, '%Y-%m-%d %H:%i:%S' ) createTime,\n" +
|
|
|
|
"\tord.`status`,\n" +
|
|
|
|
"CASE\n" +
|
|
|
|
"\t\tp.sex \n" +
|
|
|
|
"\t\tWHEN 1 THEN\n" +
|
|
|
|
"\t\t'男' \n" +
|
|
|
|
"\t\tWHEN 2 THEN\n" +
|
|
|
|
"\t\t'女' ELSE p.sex \n" +
|
|
|
|
"\tEND AS sex,\n" +
|
|
|
|
"\tTIMESTAMPDIFF(YEAR,p.birthday,now()) AS age \n" +
|
|
|
|
"FROM\n" +
|
|
|
|
"\tbase_emergency_assistance_order ord\n" +
|
|
|
|
"\tINNER JOIN base_patient p ON ord.patient = p.id \n" +
|
|
|
|
"\tAND p.del = 1 \n" +
|
|
|
|
"WHERE\n" +
|
|
|
|
"\tord.STATUS = 1 "+filter;
|
|
|
|
String sql2 = "SELECT\n" +
|
|
|
|
"\t\t'22' AS 'OrderType',\n" +
|
|
|
|
"\t\tp.archive_type archiveType,\n" +
|
|
|
|
"\t\tp.residential_area residentialArea,\n" +
|
|
|
|
"\t\tord.id,\n" +
|
|
|
|
"\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' ) createTime,\n" +
|
|
|
|
"\t\tord.`status`,\n" +
|
|
|
|
"\tCASE\n" +
|
|
|
|
"\t\t\tp.sex \n" +
|
|
|
|
"\t\t\tWHEN 1 THEN\n" +
|
|
|
|
"\t\t\t'男' \n" +
|
|
|
|
"\t\t\tWHEN 2 THEN\n" +
|
|
|
|
"\t\t\t'女' ELSE p.sex \n" +
|
|
|
|
"\t\tEND AS sex,\n" +
|
|
|
|
"\t\tTIMESTAMPDIFF(YEAR,p.birthday,now()) AS age \n" +
|
|
|
|
"\tFROM\n" +
|
|
|
|
"\t\tbase_security_monitoring_order ord\n" +
|
|
|
|
"\t\tINNER JOIN base_patient p ON ord.patient = p.id \n" +
|
|
|
|
"\t\twhere ord.status = 1"+filter;
|
|
|
|
|
|
|
|
String sql = "select * FROM (" +
|
|
|
|
"\t"+sql1+" UNION "+sql2 +
|
|
|
|
"\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" +
|
|
|
|
"\tCASE\n" +
|
|
|
|
"\t\t\tp.sex \n" +
|
|
|
|
"\t\t\tWHEN 1 THEN\n" +
|
|
|
|
"\t\t\t'男' \n" +
|
|
|
|
"\t\t\tWHEN 2 THEN\n" +
|
|
|
|
"\t\t\t'女' ELSE p.sex \n" +
|
|
|
|
"\t\tEND AS sex\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 filter
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
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"+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"+filter;
|
|
|
|
String sqlCount = "SELECT\n" +
|
|
|
|
"\tsum( warningCount ) warningCount\n" +
|
|
|
|
"FROM\n" +
|
|
|
|
"\t( " + emergencySql + " UNION ALL " + securitySql +
|
|
|
|
") 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);
|
|
|
|
}
|
|
}
|
|
}
|