|  | @ -37,7 +37,6 @@ import org.springframework.data.domain.PageRequest;
 | 
	
		
			
				|  |  | import org.springframework.data.domain.Sort;
 | 
	
		
			
				|  |  | import org.springframework.data.domain.Sort.Direction;
 | 
	
		
			
				|  |  | import org.springframework.data.jpa.domain.Specification;
 | 
	
		
			
				|  |  | import org.springframework.jdbc.core.BeanPropertyRowMapper;
 | 
	
		
			
				|  |  | import org.springframework.jdbc.core.JdbcTemplate;
 | 
	
		
			
				|  |  | import org.springframework.stereotype.Component;
 | 
	
		
			
				|  |  | import org.springframework.transaction.annotation.Transactional;
 | 
	
	
		
			
				|  | @ -899,12 +898,12 @@ public class PatientHealthIndexService extends BaseService {
 | 
	
		
			
				|  |  |                     throw new Exception("暂不支持该指标!");
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     
 | 
	
		
			
				|  |  |             obj = patientHealthIndexDao.save(obj);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     
 | 
	
		
			
				|  |  |             //判断是否有未结束的续方咨询,发送消息给对应的医生
 | 
	
		
			
				|  |  |             sendPrescriptionHealthIndexMsgresult(obj,patient);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     
 | 
	
		
			
				|  |  |             //保存完后上传基卫
 | 
	
		
			
				|  |  | //            new Thread(new HealthIndexUploadTask(String.valueOf(obj.getId()))).start();
 | 
	
		
			
				|  |  |         } else {
 | 
	
	
		
			
				|  | @ -914,16 +913,16 @@ public class PatientHealthIndexService extends BaseService {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return obj;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 判断是否有未结束的续方咨询,发送消息给对应的医生
 | 
	
		
			
				|  |  |      * @param result
 | 
	
		
			
				|  |  |      * @param patient
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     private void sendPrescriptionHealthIndexMsgresult(DevicePatientHealthIndex result, Patient patient) {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         
 | 
	
		
			
				|  |  |         List<ConsultTeam> consultTeams = consultTeamDao.findUnfinishedConsultPrescription(patient.getCode());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     
 | 
	
		
			
				|  |  |         for (ConsultTeam consultTeam:consultTeams) {
 | 
	
		
			
				|  |  |             if(consultTeam.getHealthindexType() != null){
 | 
	
		
			
				|  |  |                 org.json.JSONObject contentPatient = new org.json.JSONObject();
 | 
	
	
		
			
				|  | @ -936,12 +935,12 @@ public class PatientHealthIndexService extends BaseService {
 | 
	
		
			
				|  |  |                     contentPatient.put("tzMsg", "体征记录:血压 "+result.getValue1()+"/"+result.getValue2()+" mmHg");
 | 
	
		
			
				|  |  |                     contentPatient.put("type",1);
 | 
	
		
			
				|  |  |                 }else{}
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 
 | 
	
		
			
				|  |  |                 contentPatient.put("tzTime", "检测时间:"+DateUtil.dateToStrLong(result.getRecordDate()));
 | 
	
		
			
				|  |  |                 contentPatient.put("tzAlert","温馨提示:本条体征为居民上传的健康体征数据,您可以");
 | 
	
		
			
				|  |  |                 contentPatient.put("needUpload","false");
 | 
	
		
			
				|  |  |                 contentPatient.put("healthindexid",result.getId());//体征记录 ID
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 
 | 
	
		
			
				|  |  |                 //患者发送Im消息
 | 
	
		
			
				|  |  |                 ImUtill.sendTopicIM(patient.getCode(), patient.getName(), consultTeam.getConsult(), "16", contentPatient.toString(), null);
 | 
	
		
			
				|  |  |             }
 | 
	
	
		
			
				|  | @ -956,13 +955,13 @@ public class PatientHealthIndexService extends BaseService {
 | 
	
		
			
				|  |  |     public void handlePatientStandarStatus(DevicePatientHealthIndex obj) {
 | 
	
		
			
				|  |  |         //连续5次体征值正常,则修改为非预警状态;连续5次异常,修改为预警状态-----START
 | 
	
		
			
				|  |  |         String patientCode = obj.getUser();
 | 
	
		
			
				|  |  |         //患者信息
 | 
	
		
			
				|  |  |         Patient p = patientDao.findByCode(patientCode);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         PatientVO patient = new PatientVO();
 | 
	
		
			
				|  |  |         String patientsql = "select group_concat(label) disease from wlyy_sign_patient_label_info where label_type = 3 and status=1 and (label = 1 or label = 2) and patient = '"+p.getCode()+"' GROUP BY patient";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String patientdisease = jdbcTemplate.queryForObject(patientsql,String.class);
 | 
	
		
			
				|  |  | 	    //患者信息
 | 
	
		
			
				|  |  | 	    Patient p = patientDao.findByCode(patientCode);
 | 
	
		
			
				|  |  | 	
 | 
	
		
			
				|  |  | 	    PatientVO patient = new PatientVO();
 | 
	
		
			
				|  |  | 	    String patientsql = "select group_concat(label) disease from wlyy_sign_patient_label_info where label_type = 3 and status=1 and (label = 1 or label = 2) and patient = '"+p.getCode()+"' GROUP BY patient";
 | 
	
		
			
				|  |  | 	
 | 
	
		
			
				|  |  | 	    String patientdisease = jdbcTemplate.queryForObject(patientsql,String.class);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         int bloodPressureBbnormalCount = 0;//血压异常次数
 | 
	
		
			
				|  |  |         int bloodSuggurBbnormalCount = 0;//血糖异常次数
 | 
	
	
		
			
				|  | @ -984,42 +983,42 @@ public class PatientHealthIndexService extends BaseService {
 | 
	
		
			
				|  |  |                 bloodSuggurBbnormalCount++;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //连续3次异常,修改用户为预警状态
 | 
	
		
			
				|  |  |         if ((bloodPressureBbnormalCount >= 3 || bloodSuggurBbnormalCount >= 3) && (patient.getStandardStatus() == null || 0 == patient.getStandardStatus())) {
 | 
	
		
			
				|  |  |             p.setStandardStatus(1);
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  |             Date end = new Date();
 | 
	
		
			
				|  |  |             Date start = DateUtil.setDateTime(end, -7);
 | 
	
		
			
				|  |  |             //计算血糖或者血压一周内的异常记录数量
 | 
	
		
			
				|  |  |             int errorCount = patientHealthIndexDao.getCountByTimeAndStatus(start, end, 1, patientCode);
 | 
	
		
			
				|  |  |             if (errorCount >= 5) {//超过5次,记为预警状态
 | 
	
		
			
				|  |  |                 p.setStandardStatus(1);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //连续5次正常,修改用户为非预警状态
 | 
	
		
			
				|  |  |         if (StringUtils.isNotBlank(patientdisease)) {
 | 
	
		
			
				|  |  |             if ("1".equals(patientdisease)) {
 | 
	
		
			
				|  |  |                 if (0 == bloodPressureBbnormalCount && (patient.getStandardStatus() == null || 1 == patient.getStandardStatus())) {
 | 
	
		
			
				|  |  |                     p.setStandardStatus(0);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             } else if ("2".equals(patientdisease)) {
 | 
	
		
			
				|  |  |                 if (0 == bloodSuggurBbnormalCount && (patient.getStandardStatus() == null || 1 == patient.getStandardStatus())) {
 | 
	
		
			
				|  |  |                     p.setStandardStatus(0);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             } else if ("1,2".equals(patientdisease) || "2,1".equals(patientdisease)) {
 | 
	
		
			
				|  |  |                 if (0 == bloodSuggurBbnormalCount && 0 == bloodPressureBbnormalCount && (patient.getStandardStatus() == null || 1 == patient.getStandardStatus())) {
 | 
	
		
			
				|  |  |                     p.setStandardStatus(0);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  |             p.setStandardStatus(0);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         patientDao.save(p);
 | 
	
		
			
				|  |  |         //连续5次体征值正常,则修改为非预警状态;连续5次异常,修改为预警状态-----END
 | 
	
		
			
				|  |  | 	
 | 
	
		
			
				|  |  | 	
 | 
	
		
			
				|  |  | 	    //连续3次异常,修改用户为预警状态
 | 
	
		
			
				|  |  | 	    if ((bloodPressureBbnormalCount >= 3 || bloodSuggurBbnormalCount >= 3) && (patient.getStandardStatus() == null || 0 == patient.getStandardStatus())) {
 | 
	
		
			
				|  |  | 		    p.setStandardStatus(1);
 | 
	
		
			
				|  |  | 	    } else {
 | 
	
		
			
				|  |  | 		    Date end = new Date();
 | 
	
		
			
				|  |  | 		    Date start = DateUtil.setDateTime(end, -7);
 | 
	
		
			
				|  |  | 		    //计算血糖或者血压一周内的异常记录数量
 | 
	
		
			
				|  |  | 		    int errorCount = patientHealthIndexDao.getCountByTimeAndStatus(start, end, 1, patientCode);
 | 
	
		
			
				|  |  | 		    if (errorCount >= 5) {//超过5次,记为预警状态
 | 
	
		
			
				|  |  | 			    p.setStandardStatus(1);
 | 
	
		
			
				|  |  | 		    }
 | 
	
		
			
				|  |  | 	    }
 | 
	
		
			
				|  |  | 	
 | 
	
		
			
				|  |  | 	    //连续5次正常,修改用户为非预警状态
 | 
	
		
			
				|  |  | 	    if (StringUtils.isNotBlank(patientdisease)) {
 | 
	
		
			
				|  |  | 		    if ("1".equals(patientdisease)) {
 | 
	
		
			
				|  |  | 			    if (0 == bloodPressureBbnormalCount && (patient.getStandardStatus() == null || 1 == patient.getStandardStatus())) {
 | 
	
		
			
				|  |  | 				    p.setStandardStatus(0);
 | 
	
		
			
				|  |  | 			    }
 | 
	
		
			
				|  |  | 		    } else if ("2".equals(patientdisease)) {
 | 
	
		
			
				|  |  | 			    if (0 == bloodSuggurBbnormalCount && (patient.getStandardStatus() == null || 1 == patient.getStandardStatus())) {
 | 
	
		
			
				|  |  | 				    p.setStandardStatus(0);
 | 
	
		
			
				|  |  | 			    }
 | 
	
		
			
				|  |  | 		    } else if ("1,2".equals(patientdisease) || "2,1".equals(patientdisease)) {
 | 
	
		
			
				|  |  | 			    if (0 == bloodSuggurBbnormalCount && 0 == bloodPressureBbnormalCount && (patient.getStandardStatus() == null || 1 == patient.getStandardStatus())) {
 | 
	
		
			
				|  |  | 				    p.setStandardStatus(0);
 | 
	
		
			
				|  |  | 			    }
 | 
	
		
			
				|  |  | 		    }
 | 
	
		
			
				|  |  | 	    } else {
 | 
	
		
			
				|  |  | 		    p.setStandardStatus(0);
 | 
	
		
			
				|  |  | 	    }
 | 
	
		
			
				|  |  | 	
 | 
	
		
			
				|  |  | 	    patientDao.save(p);
 | 
	
		
			
				|  |  | 	    //连续5次体征值正常,则修改为非预警状态;连续5次异常,修改为预警状态-----END
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 |