Browse Source

设备项目体征数据录入时判断居民预警状态

huangwenjie 7 years ago
parent
commit
a284abba0d

+ 5 - 2
patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/common/dao/PatientHealthIndexDao.java

@ -55,6 +55,9 @@ public interface PatientHealthIndexDao
	@Query("select a from PatientHealthIndex a where a.user = ?1 and a.type =?2  order by recordDate desc ")
    List<PatientHealthIndex> findByPatientAndType(String patientCode, int type, Pageable pageable);
	@Query("select count(a) from PatientHealthIndex a where a.recordDate >= ?1 and a.recordDate <= ?2 and a.type in (1,2) and a.status = ?3 and a.del = '1'")
	int getCountByTimeAndStatus(Date start, Date end,int status);
	@Query("select count(a) from DevicePatientHealthIndex a where a.recordDate >= ?1 and a.recordDate <= ?2 and a.type in (1,2) and a.status = ?3 and a.del = '1' and user = ?4")
	int getCountByTimeAndStatus(Date start, Date end, int status, String patientCode);
	@Query(value="select * from device.wlyy_patient_health_index where user = ?1 and type = ?2 ORDER BY record_date desc limit 0 ,5",nativeQuery = true)
	List<PatientHealthIndex> findByPatientAndTypeByPage(String patientCode, int type);
}

+ 24 - 19
patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/service/DeviceService.java

@ -403,33 +403,24 @@ public class DeviceService {
                String patientCode = result.getUser();
                //患者信息
                Patient patient = patientDao.findByCode(patientCode);
                int bloodPressureBbnormalCount = 0;//血压异常次数
                int bloodSuggurBbnormalCount = 0;//血糖异常次数
                // 排序
                Sort sort = new Sort(Sort.Direction.DESC, "recordDate");
                // 分页信息
                Pageable pageRequest = new PageRequest(0, 5, sort);
                Pageable pageable = new PageRequest(1, 5);
                List<PatientHealthIndex> bloodPressurepatientHealthIndices = new ArrayList<>();
                List<PatientHealthIndex> bloodSuggurpatientHealthIndices = new ArrayList<>();
                if( 1 == patient.getDisease()){
                    bloodPressurepatientHealthIndices = patientHealthIndexDao.findByPatientAndType(patientCode,2,pageable);
                } else if( 2 == patient.getDisease()){
                    bloodSuggurpatientHealthIndices = patientHealthIndexDao.findByPatientAndType(patientCode,1,pageable);
                } else {
                    bloodPressurepatientHealthIndices = patientHealthIndexDao.findByPatientAndType(patientCode,2,pageable);
                    bloodSuggurpatientHealthIndices = patientHealthIndexDao.findByPatientAndType(patientCode,1,pageable);
                }
                for (PatientHealthIndex patientHealthIndex : bloodPressurepatientHealthIndices) {
                    if(patientHealthIndex.getStatus() != null && 1 == patientHealthIndex.getStatus()){
                bloodPressurepatientHealthIndices = patientHealthIndexDao.findByPatientAndTypeByPage(patientCode,2);
                bloodSuggurpatientHealthIndices = patientHealthIndexDao.findByPatientAndTypeByPage(patientCode,1);
                for (PatientHealthIndex index1 : bloodPressurepatientHealthIndices) {
                    if(index1.getStatus() != null && 1 == index1.getStatus()){
                        bloodPressureBbnormalCount++;
                    }
                }
                for (PatientHealthIndex patientHealthIndex : bloodSuggurpatientHealthIndices) {
                    if(patientHealthIndex.getStatus() != null && 1 == patientHealthIndex.getStatus()){
                for (PatientHealthIndex index2 : bloodSuggurpatientHealthIndices) {
                    if(index2.getStatus() != null && 1 == index2.getStatus()){
                        bloodSuggurBbnormalCount++;
                    }
                }
@ -442,14 +433,28 @@ public class DeviceService {
                    Date end = new Date();
                    Date start = DateUtil.setDateTime(end,-7);
                    //计算血糖或者血压一周内的异常记录数量
                    int errorCount = patientHealthIndexDao.getCountByTimeAndStatus(start,end,1);
                    int errorCount = patientHealthIndexDao.getCountByTimeAndStatus(start,end,1,patientCode);
                    if(errorCount >= 5){//超过5次,记为预警状态
                        patient.setStandardStatus(1);
                    }
                }
                //连续5次正常,修改用户为非预警状态
                if((0 == bloodPressureBbnormalCount && 0 == bloodSuggurBbnormalCount) && 1 == patient.getStandardStatus()){
                if(patient.getDisease() != null){
                    if( 1 == patient.getDisease()){
                        if(0 == bloodPressureBbnormalCount && 1 == patient.getStandardStatus()){
                            patient.setStandardStatus(0);
                        }
                    }else if(2 == patient.getDisease()){
                        if(0 == bloodSuggurBbnormalCount && 1 == patient.getStandardStatus()){
                            patient.setStandardStatus(0);
                        }
                    }else if( 3 == patient.getDisease()){
                        if( (0 == bloodSuggurBbnormalCount|| 0 == bloodPressureBbnormalCount)&& 1 == patient.getStandardStatus()){
                            patient.setStandardStatus(0);
                        }
                    }
                }else{
                    patient.setStandardStatus(0);
                }