|
@ -4,18 +4,17 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.yihu.device.entity.DevicePatientHealthIndex;
|
|
|
import com.yihu.wlyy.entity.consult.ConsultTeam;
|
|
|
import com.yihu.wlyy.entity.device.PatientDevice;
|
|
|
import com.yihu.wlyy.entity.doctor.DoctorSwitch;
|
|
|
import com.yihu.wlyy.entity.doctor.health.DoctorHealthStandard;
|
|
|
import com.yihu.wlyy.entity.doctor.profile.Doctor;
|
|
|
import com.yihu.wlyy.entity.message.Message;
|
|
|
import com.yihu.wlyy.entity.message.MessageNoticeSetting;
|
|
|
import com.yihu.wlyy.entity.patient.Patient;
|
|
|
import com.yihu.wlyy.entity.patient.PatientAimSports;
|
|
|
import com.yihu.wlyy.entity.patient.PatientHealthStandard;
|
|
|
import com.yihu.wlyy.entity.patient.SignFamily;
|
|
|
import com.yihu.wlyy.entity.patient.*;
|
|
|
import com.yihu.wlyy.entity.patient.vo.PatientVO;
|
|
|
import com.yihu.wlyy.health.repository.DevicePatientHealthIndexDao;
|
|
|
import com.yihu.wlyy.repository.consult.ConsultTeamDao;
|
|
|
import com.yihu.wlyy.repository.doctor.DoctorDao;
|
|
|
import com.yihu.wlyy.repository.doctor.DoctorSwitchDao;
|
|
|
import com.yihu.wlyy.repository.doctor.health.DoctorHealthStandardDao;
|
|
|
import com.yihu.wlyy.repository.message.MessageDao;
|
|
|
import com.yihu.wlyy.repository.patient.*;
|
|
@ -92,6 +91,10 @@ public class PatientHealthIndexService extends BaseService {
|
|
|
@Autowired
|
|
|
private MessageService messageService;
|
|
|
@Autowired
|
|
|
private DoctorSwitchDao doctorSwitchDao;
|
|
|
@Autowired
|
|
|
private TrackPatientDao trackPatientDao;
|
|
|
@Autowired
|
|
|
private IotDeviceService iotDeviceService;
|
|
|
|
|
|
/**
|
|
@ -857,6 +860,8 @@ public class PatientHealthIndexService extends BaseService {
|
|
|
//连续3次异常,修改用户为预警状态
|
|
|
if ((bloodPressureBbnormalCount >= 3 || bloodSuggurBbnormalCount >= 3) && (patient.getStandardStatus() == null || 0 == patient.getStandardStatus())) {
|
|
|
p.setStandardStatus(1);
|
|
|
//1.4.2加入重点关注逻辑
|
|
|
setTrackPatientByDoctor(patientCode);
|
|
|
} else {
|
|
|
Date end = new Date();
|
|
|
Date start = DateUtil.setDateTime(end, -7);
|
|
@ -864,6 +869,8 @@ public class PatientHealthIndexService extends BaseService {
|
|
|
int errorCount = patientHealthIndexDao.getCountByTimeAndStatus(start, end, 1, patientCode);
|
|
|
if (errorCount >= 5) {//超过5次,记为预警状态
|
|
|
p.setStandardStatus(1);
|
|
|
//1.4.2加入重点关注逻辑
|
|
|
setTrackPatientByDoctor(patientCode);
|
|
|
}
|
|
|
}
|
|
|
|
|
@ -872,24 +879,209 @@ public class PatientHealthIndexService extends BaseService {
|
|
|
if ("1".equals(patientdisease)) {
|
|
|
if (0 == bloodPressureBbnormalCount && (patient.getStandardStatus() == null || 1 == patient.getStandardStatus())) {
|
|
|
p.setStandardStatus(0);
|
|
|
//1.4.2加入重点关注逻辑
|
|
|
cancalTrackPatientByDoctor(patientCode);
|
|
|
}
|
|
|
} else if ("2".equals(patientdisease)) {
|
|
|
if (0 == bloodSuggurBbnormalCount && (patient.getStandardStatus() == null || 1 == patient.getStandardStatus())) {
|
|
|
p.setStandardStatus(0);
|
|
|
//1.4.2加入重点关注逻辑
|
|
|
cancalTrackPatientByDoctor(patientCode);
|
|
|
}
|
|
|
} else if ("1,2".equals(patientdisease) || "2,1".equals(patientdisease)) {
|
|
|
if (0 == bloodSuggurBbnormalCount && 0 == bloodPressureBbnormalCount && (patient.getStandardStatus() == null || 1 == patient.getStandardStatus())) {
|
|
|
p.setStandardStatus(0);
|
|
|
//1.4.2加入重点关注逻辑
|
|
|
cancalTrackPatientByDoctor(patientCode);
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
p.setStandardStatus(0);
|
|
|
//1.4.2加入重点关注逻辑
|
|
|
cancalTrackPatientByDoctor(patientCode);
|
|
|
}
|
|
|
|
|
|
patientDao.save(p);
|
|
|
//连续5次体征值正常,则修改为非预警状态;连续5次异常,修改为预警状态-----END
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 设置
|
|
|
* @param patient
|
|
|
* @return
|
|
|
*/
|
|
|
public int setTrackPatientByDoctor(String patient){
|
|
|
SignFamily signFamily = signFamilyDao.findByjiatingPatientYes(patient);
|
|
|
if(signFamily==null){
|
|
|
return -1;
|
|
|
}
|
|
|
Patient p = patientDao.findByCode(patient);
|
|
|
if(p==null){
|
|
|
return -1;
|
|
|
}
|
|
|
//医生是否自动追踪居民
|
|
|
DoctorSwitch sw = doctorSwitchDao.findByDoctor(signFamily.getDoctor());
|
|
|
DoctorSwitch swh = doctorSwitchDao.findByDoctor(signFamily.getDoctorHealth());
|
|
|
|
|
|
if(sw!=null){
|
|
|
if("1".equals(sw.getAlertPatientSwitch())){
|
|
|
//查询是否与医生建立重点跟踪关系,诺无关系则建立
|
|
|
TrackPatient trackPatient = trackPatientDao.findByDoctorCodeAndPatientCode(signFamily.getDoctor(),patient);
|
|
|
|
|
|
if(trackPatient == null){
|
|
|
TrackPatient t = new TrackPatient();
|
|
|
t.setCreateTime(new Date());
|
|
|
t.setDoctorCode(signFamily.getDoctor());
|
|
|
t.setDoctorName(signFamily.getDoctorName());
|
|
|
t.setIdcard(signFamily.getIdcard());
|
|
|
t.setSsc(signFamily.getSsc());
|
|
|
t.setTeamCode(signFamily.getAdminTeamId().intValue());
|
|
|
t.setPatientCode(patient);
|
|
|
t.setPatientName(p.getName());
|
|
|
t.setDel("1");
|
|
|
trackPatientDao.save(t);
|
|
|
}else{
|
|
|
trackPatient.setDel("1");
|
|
|
trackPatientDao.save(trackPatient);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if(swh!=null){
|
|
|
if("1".equals(sw.getAlertPatientSwitch())){
|
|
|
//查询是否与医生建立重点跟踪关系,诺无关系则建立
|
|
|
TrackPatient trackPatient = trackPatientDao.findByDoctorCodeAndPatientCode(signFamily.getDoctorHealth(),patient);
|
|
|
if(trackPatient == null){
|
|
|
TrackPatient t = new TrackPatient();
|
|
|
t.setCreateTime(new Date());
|
|
|
t.setDoctorCode(signFamily.getDoctorHealth());
|
|
|
t.setDoctorName(signFamily.getDoctorHealthName());
|
|
|
t.setIdcard(signFamily.getIdcard());
|
|
|
t.setSsc(signFamily.getSsc());
|
|
|
t.setTeamCode(signFamily.getAdminTeamId().intValue());
|
|
|
t.setPatientCode(patient);
|
|
|
t.setPatientName(p.getName());
|
|
|
t.setDel("1");
|
|
|
trackPatientDao.save(t);
|
|
|
}else{
|
|
|
trackPatient.setDel("1");
|
|
|
trackPatientDao.save(trackPatient);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
public int cancalTrackPatientByDoctor(String patient){
|
|
|
SignFamily signFamily = signFamilyDao.findByjiatingPatientYes(patient);
|
|
|
if(signFamily==null){
|
|
|
return -1;
|
|
|
}
|
|
|
Patient p = patientDao.findByCode(patient);
|
|
|
if(p==null){
|
|
|
return -1;
|
|
|
}
|
|
|
//医生是否自动追踪居民
|
|
|
|
|
|
DoctorSwitch sw = doctorSwitchDao.findByDoctor(signFamily.getDoctor());
|
|
|
DoctorSwitch swh = doctorSwitchDao.findByDoctor(signFamily.getDoctorHealth());
|
|
|
|
|
|
if(sw!=null){
|
|
|
if("1".equals(sw.getAlertPatientSwitch())){
|
|
|
//查询是否与医生建立重点跟踪关系,诺无关系则建立
|
|
|
TrackPatient trackPatient = trackPatientDao.findByDoctorCodeAndPatientCode(signFamily.getDoctor(),patient);
|
|
|
|
|
|
if(trackPatient == null){
|
|
|
TrackPatient t = new TrackPatient();
|
|
|
t.setCreateTime(new Date());
|
|
|
t.setDoctorCode(signFamily.getDoctor());
|
|
|
t.setDoctorName(signFamily.getDoctorName());
|
|
|
t.setIdcard(signFamily.getIdcard());
|
|
|
t.setSsc(signFamily.getSsc());
|
|
|
t.setTeamCode(signFamily.getAdminTeamId().intValue());
|
|
|
t.setPatientCode(patient);
|
|
|
t.setPatientName(p.getName());
|
|
|
t.setDel("0");
|
|
|
trackPatientDao.save(t);
|
|
|
}else{
|
|
|
trackPatient.setDel("0");
|
|
|
trackPatientDao.save(trackPatient);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if(swh!=null){
|
|
|
if("1".equals(sw.getAlertPatientSwitch())){
|
|
|
//查询是否与医生建立重点跟踪关系,诺无关系则建立
|
|
|
TrackPatient trackPatient = trackPatientDao.findByDoctorCodeAndPatientCode(signFamily.getDoctorHealth(),patient);
|
|
|
if(trackPatient == null){
|
|
|
TrackPatient t = new TrackPatient();
|
|
|
t.setCreateTime(new Date());
|
|
|
t.setDoctorCode(signFamily.getDoctorHealth());
|
|
|
t.setDoctorName(signFamily.getDoctorHealthName());
|
|
|
t.setIdcard(signFamily.getIdcard());
|
|
|
t.setSsc(signFamily.getSsc());
|
|
|
t.setTeamCode(signFamily.getAdminTeamId().intValue());
|
|
|
t.setPatientCode(patient);
|
|
|
t.setPatientName(p.getName());
|
|
|
t.setDel("0");
|
|
|
trackPatientDao.save(t);
|
|
|
}else{
|
|
|
trackPatient.setDel("0");
|
|
|
trackPatientDao.save(trackPatient);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 按录入时间和患者标识查询健康记录
|
|
|
*
|
|
|
* @param patientCode
|
|
|
* @param date
|
|
|
* @return
|
|
|
*/
|
|
|
public Iterable<DevicePatientHealthIndex> findByPatienDate(String patientCode, int type, Date date) {
|
|
|
return patientHealthIndexDao.findByPatienDate(patientCode, type, date);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 按时间段查询患者健康指标
|
|
|
*
|
|
|
* @param type 健康指标类型(1血糖,2血压,3体重,4腰围)
|
|
|
* @param begin 开始时间
|
|
|
* @param end 结束时间
|
|
|
* @return
|
|
|
*/
|
|
|
public List<DevicePatientHealthIndex> findChartByPatien(String patient, int type, String begin, String end) {
|
|
|
List<DevicePatientHealthIndex> re = new ArrayList<>();
|
|
|
|
|
|
Date startDate = DateUtil.strToDate(begin, DateUtil.YYYY_MM_DD_HH_MM_SS);
|
|
|
Date endDate = DateUtil.strToDate(end, DateUtil.YYYY_MM_DD_HH_MM_SS);
|
|
|
if (type == 1) //血糖特殊处理
|
|
|
{
|
|
|
//根据时间过滤排序
|
|
|
List<String> dateList = patientHealthIndexDao.findDateList(patient, startDate, endDate, null);
|
|
|
if (dateList != null && dateList.size() > 0) {
|
|
|
for (int i = dateList.size() - 1; i >= 0; i--) {
|
|
|
String dateString = dateList.get(i);
|
|
|
DevicePatientHealthIndex obj = getPatientXT(patient, dateString);
|
|
|
if (obj != null) {
|
|
|
re.add(obj);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
// 排序
|
|
|
Sort sort = new Sort(Direction.ASC, "recordDate");
|
|
|
PageRequest pageRequest = new PageRequest(0, 1000, sort);
|
|
|
re = patientHealthIndexDao.findIndexByPatient(patient, type, startDate, endDate, pageRequest).getContent();
|
|
|
}
|
|
|
return re;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 按时间段查询患者健康指标
|
|
|
*
|