|
@ -5,8 +5,7 @@ import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.yihu.jw.care.dao.device.BasePatientOutBedDao;
|
|
|
import com.yihu.jw.care.dao.device.PatientDeviceDao;
|
|
|
import com.yihu.jw.care.dao.device.*;
|
|
|
import com.yihu.jw.care.dao.security.*;
|
|
|
import com.yihu.jw.care.dao.team.BaseTeamMemberDao;
|
|
|
import com.yihu.jw.care.service.common.DictService;
|
|
@ -26,8 +25,7 @@ import com.yihu.jw.entity.base.im.ConsultDo;
|
|
|
import com.yihu.jw.entity.base.im.ConsultTeamDo;
|
|
|
import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
|
import com.yihu.jw.entity.care.contacts.PatientSosContactsDO;
|
|
|
import com.yihu.jw.entity.care.device.BasePatientOutBed;
|
|
|
import com.yihu.jw.entity.care.device.DevicePatientDevice;
|
|
|
import com.yihu.jw.entity.care.device.*;
|
|
|
import com.yihu.jw.entity.care.securitymonitoring.*;
|
|
|
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
|
|
|
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
|
|
@ -47,6 +45,8 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@ -117,6 +117,12 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
private ObjectMapper objectMapper;
|
|
|
@Autowired
|
|
|
private BasePatientOutBedDao outBedDao;
|
|
|
@Autowired
|
|
|
private BaseSleepPlanDao sleepPlanDao;
|
|
|
@Autowired
|
|
|
private BaseSleepPlanDetailDao sleepPlanDetailDao;
|
|
|
@Autowired
|
|
|
private BaseSleepNightRecordDao nightRecordDao;
|
|
|
|
|
|
private Logger logger = LoggerFactory.getLogger(SecurityMonitoringOrderService.class);
|
|
|
|
|
@ -351,6 +357,19 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
if (5==orderDO.getOrderSource()){//睡眠带工单
|
|
|
try {
|
|
|
JSONObject monitorInfo = JSONObject.parseObject(orderDO.getWarnInfo());
|
|
|
List<BaseSleepPlan> sleepPlans = sleepPlanDao.findByPatient(patientDO.getId());
|
|
|
if (sleepPlans.size()>0){
|
|
|
BaseSleepPlan sleepPlan = sleepPlans.get(0);
|
|
|
String endTime = DateUtil.getNextMin(sleepPlan.getGetUpTime(),-1);
|
|
|
monitorInfo.put("sleepPlan",true);
|
|
|
monitorInfo.put("getUpTime",sleepPlan.getGetUpTime());
|
|
|
monitorInfo.put("siestaTime",sleepPlan.getNapTime());
|
|
|
monitorInfo.put("nightRestTime",sleepPlan.getNightRestTime());
|
|
|
monitorInfo.put("nightRecordTime",sleepPlan.getNightRestTime()+"-隔日"+endTime);
|
|
|
|
|
|
}else {
|
|
|
monitorInfo.put("sleepPlan",false);
|
|
|
}
|
|
|
monitorInfo = patientSignTopicInfo(monitorInfo,orderDO.getPatient(),"preventFall");
|
|
|
emergencyOrderVO.setInformation(monitorInfo);
|
|
|
}catch (Exception e){
|
|
@ -1297,6 +1316,25 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
result.put("sleepStatus",true);
|
|
|
JSONObject tmp = objInfo.getJSONObject(0);
|
|
|
JSONObject sleepInfo = new JSONObject();
|
|
|
List<BaseSleepPlanDetail> planDetails = sleepPlanDetailDao.findByPatientAndDay(patient,getSleepMonitoringDay(new Date(),patient));
|
|
|
if (planDetails.size()>0){
|
|
|
BaseSleepPlanDetail planDetail = planDetails.get(0);
|
|
|
String jsonStr = JSON.toJSONStringWithDateFormat(planDetail, "yyyy-MM-dd HH:mm:ss", SerializerFeature.WriteMapNullValue);
|
|
|
sleepInfo = JSONObject.parseObject(jsonStr);
|
|
|
}
|
|
|
List<BaseSleepPlan> sleepPlans = sleepPlanDao.findByPatient(patient);
|
|
|
if (sleepPlans.size()>0){
|
|
|
BaseSleepPlan sleepPlan = sleepPlans.get(0);
|
|
|
String endTime = DateUtil.getNextMin(sleepPlan.getGetUpTime(),-1);
|
|
|
sleepInfo.put("sleepPlan",true);
|
|
|
sleepInfo.put("getUpTime",sleepPlan.getGetUpTime());
|
|
|
sleepInfo.put("siestaTime",sleepPlan.getNapTime());
|
|
|
sleepInfo.put("nightRestTime",sleepPlan.getNightRestTime());
|
|
|
sleepInfo.put("nightRecordTime",sleepPlan.getNightRestTime()+"-隔日"+endTime);
|
|
|
|
|
|
}else {
|
|
|
sleepInfo.put("sleepPlan",false);
|
|
|
}
|
|
|
sleepInfo.put("online",tmp.getBooleanValue("online"));
|
|
|
sleepInfo.put("onbed",tmp.getBooleanValue("onbed"));
|
|
|
sleepInfo.put("heartrate",tmp.getString("heartrate"));
|
|
@ -1476,6 +1514,44 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
*获取居民睡眠计划
|
|
|
*/
|
|
|
public BaseSleepPlan getPatientSleepPlan(String patient){
|
|
|
List<BaseSleepPlan> list = sleepPlanDao.findByPatient(patient);
|
|
|
if (list.size()>0){
|
|
|
return list.get(0);
|
|
|
}else {
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
*获取居民睡眠监护列表
|
|
|
*/
|
|
|
public Page<BaseSleepPlanDetail> getPatientSleepDetainList(String patient,String begin,String end,Integer page,Integer pageSize){
|
|
|
page=page>0?page-1:0;
|
|
|
PageRequest pageRequest = new PageRequest(page, pageSize);
|
|
|
begin = begin.substring(0,begin.indexOf(" "));
|
|
|
end = end.substring(0,end.indexOf(" "));
|
|
|
Page<BaseSleepPlanDetail> list = sleepPlanDetailDao.findByListByPage(patient,begin,end,pageRequest);
|
|
|
for (BaseSleepPlanDetail tmp:list){
|
|
|
List<BaseSleepNightRecord> records = nightRecordDao.findByPatientAndDayOrderByCreateTimeDesc(patient,tmp.getDay());
|
|
|
tmp.setSleepNightRecordList(records);
|
|
|
}
|
|
|
return list;
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
*获取居民起夜记录
|
|
|
*/
|
|
|
public List<BaseSleepNightRecord> getPatientSleepNightRecord(String patient, String day){
|
|
|
|
|
|
List<BaseSleepNightRecord> records = nightRecordDao.findByPatientAndDayOrderByCreateTimeDesc(patient,day);
|
|
|
return records;
|
|
|
}
|
|
|
|
|
|
private String getRandomIntStr(){
|
|
|
Random rand = new Random();
|
|
|
int i = rand.nextInt(); //int范围类的随机数
|
|
@ -1490,4 +1566,19 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
one.setUpdateUserName(one.getDoctorName());
|
|
|
}
|
|
|
|
|
|
private String getSleepMonitoringDay(Date date,String patient){
|
|
|
List<BaseSleepPlan> sleepPlans = sleepPlanDao.findByPatient(patient);
|
|
|
if (sleepPlans.size()>0){
|
|
|
String bedUpStr = sleepPlans.get(0).getGetUpTime();
|
|
|
Date bedUp = DateUtil.strToDate(DateUtil.getStringDateShort()+" "+bedUpStr+":00");// 起床时间 起床前一小时内算为起床
|
|
|
if (date.before(bedUp)&&bedUp.getTime()-date.getTime()>1000*1*3600){
|
|
|
bedUp = DateUtil.getNextDay1(bedUp,-1);
|
|
|
}
|
|
|
String dayTime = DateUtil.dateToStr(bedUp,DateUtil.YYYY_MM_DD);//监测日期
|
|
|
return dayTime;
|
|
|
}else {
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|