| 
					
				 | 
			
			
				@ -867,33 +867,24 @@ public class PatientHealthIndexService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String patientCode = obj.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<DevicePatientHealthIndex> bloodPressurepatientHealthIndices = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<DevicePatientHealthIndex> bloodSuggurpatientHealthIndices = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if( 1 == patient.getDisease()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            bloodPressurepatientHealthIndices = patientHealthIndexDao.findByPatientAndTypeByPage(patientCode,2,pageable); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } else if( 2 == patient.getDisease()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            bloodSuggurpatientHealthIndices = patientHealthIndexDao.findByPatientAndTypeByPage(patientCode,1,pageable); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            bloodPressurepatientHealthIndices = patientHealthIndexDao.findByPatientAndTypeByPage(patientCode,2,pageable); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            bloodSuggurpatientHealthIndices = patientHealthIndexDao.findByPatientAndTypeByPage(patientCode,1,pageable); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (DevicePatientHealthIndex patientHealthIndex : bloodPressurepatientHealthIndices) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(patientHealthIndex.getStatus() != null && 1 == patientHealthIndex.getStatus()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        bloodPressurepatientHealthIndices = patientHealthIndexDao.findByPatientAndTypeByPage(patientCode,2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        bloodSuggurpatientHealthIndices = patientHealthIndexDao.findByPatientAndTypeByPage(patientCode,1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (DevicePatientHealthIndex index1 : bloodPressurepatientHealthIndices) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(index1.getStatus() != null && 1 == index1.getStatus()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                bloodPressureBbnormalCount++; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (DevicePatientHealthIndex patientHealthIndex : bloodSuggurpatientHealthIndices) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(patientHealthIndex.getStatus() != null && 1 == patientHealthIndex.getStatus()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        for (DevicePatientHealthIndex index2 : bloodSuggurpatientHealthIndices) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(index2.getStatus() != null && 1 == index2.getStatus()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                bloodSuggurBbnormalCount++; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -906,14 +897,28 @@ public class PatientHealthIndexService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 |