| 
					
				 | 
			
			
				@ -1,28 +1,27 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				package com.yihu.wlyy.service.app.health; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.alibaba.fastjson.JSON; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				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.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.service.BaseService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.service.app.message.MessageService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.service.app.scheduling.DoctorWorkTimeService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.service.third.iot.IotDeviceService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.task.PushMsgTask; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.util.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.apache.commons.lang3.StringUtils; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -33,17 +32,12 @@ import org.json.JSONArray; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.json.JSONObject; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.beans.factory.annotation.Value; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.data.domain.Page; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				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.JdbcTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.stereotype.Component; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springframework.transaction.annotation.Transactional; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springside.modules.persistence.DynamicSpecifications; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springside.modules.persistence.SearchFilter; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springside.modules.persistence.SearchFilter.Operator; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import org.springside.modules.utils.Clock; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import java.text.DecimalFormat; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -96,6 +90,12 @@ public class PatientHealthIndexService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private ConsultTeamDao consultTeamDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private MessageService messageService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private DoctorSwitchDao doctorSwitchDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private TrackPatientDao trackPatientDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private IotDeviceService iotDeviceService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 获取居民标准预警值 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -169,7 +169,7 @@ public class PatientHealthIndexService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    //更改接口(包括手动记录的修改和所有的删除) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public void modify(long id, String recordDate, String value1, String value2, String value3, String value4) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        DevicePatientHealthIndex result = patientHealthIndexDao.findOne(id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        DevicePatientHealthIndex result = findOne(id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (result != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //字段值均为空为删除 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (StringUtils.isEmpty(value1) && StringUtils.isEmpty(value2) && StringUtils.isEmpty(value3) && StringUtils.isEmpty(value4)) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -196,7 +196,7 @@ public class PatientHealthIndexService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            patientHealthIndexDao.save(result); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            update(result); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if ("1".equals(result.getType()) || "2".equals(result.getType())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                verifyHealthIndex(result.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -266,143 +266,6 @@ public class PatientHealthIndexService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 保存患者健康指标  (旧) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public DevicePatientHealthIndex save(DevicePatientHealthIndex model, int index, double value, String patientCode) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        model.setCzrq(clock.getCurrentDate()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        model.setDel("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        PatientHealthStandard standard = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        // 当前值/收缩压,正数为高,负数为低 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        double value1 = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        // 上次值/舒张压,正数为高,负数为低 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        double value2 = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (model.getType() == 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            // 血糖记录,查询患者血糖预警值 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            standard = patientHealthStandardDao.findByPatientType(model.getUser(), 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (index % 2 == 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                // 餐后 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                value1 = CommonUtil.checkHealthIndex(value, standard != null && standard.getMaxValue2() > 0 ? standard.getMaxValue2() : SystemConf.HEALTH_STANDARD_ST_MAX_AFTER, standard != null && standard.getMinValue2() > 0 ? standard.getMinValue2() : SystemConf.HEALTH_STANDARD_ST_MIN_AFTER); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                // 餐前 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                value1 = CommonUtil.checkHealthIndex(value, standard != null && standard.getMaxValue1() > 0 ? standard.getMaxValue1() : SystemConf.HEALTH_STANDARD_ST_MAX_BEFORE, standard != null && standard.getMinValue1() > 0 ? standard.getMinValue1() : SystemConf.HEALTH_STANDARD_ST_MIN_BEFORE); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            // 查询上一次的血糖值 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (value1 != 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                value2 = NumberUtils.toDouble(findPreValue(model.getUser(), model.getType(), index, model.getRecordDate()), 0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } else if (model.getType() == 2) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            // 血压记录,查询患者血压预警值 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            standard = patientHealthStandardDao.findByPatientType(model.getUser(), 2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            // 收缩压 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            value1 = CommonUtil.checkHealthIndex(NumberUtils.toDouble(model.getValue1(), 0), standard != null && standard.getMaxValue1() > 0 ? standard.getMaxValue1() : SystemConf.HEALTH_STANDARD_SSY_MAX, standard != null && standard.getMinValue1() > 0 ? standard.getMinValue1() : SystemConf.HEALTH_STANDARD_SSY_MIN); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            // 舒张压 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            value2 = CommonUtil.checkHealthIndex(NumberUtils.toDouble(model.getValue2(), 0), standard != null && standard.getMaxValue2() > 0 ? standard.getMaxValue2() : SystemConf.HEALTH_STANDARD_SZY_MAX, standard != null && standard.getMinValue2() > 0 ? standard.getMinValue2() : SystemConf.HEALTH_STANDARD_SZY_MIN); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (value1 > 0 || value2 > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                value1 = NumberUtils.toDouble(model.getValue1(), 0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                value2 = NumberUtils.toDouble(model.getValue2(), 0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } else if (value1 < 0 || value2 < 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                value1 = -NumberUtils.toDouble(model.getValue1(), 0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                value2 = -NumberUtils.toDouble(model.getValue2(), 0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        // 保存到数据库 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        model = patientHealthIndexDao.save(model); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (value1 != 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            // 消息接收者 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<String> receivers = new ArrayList<String>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            // 查询患者信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Patient p = patientDao.findByCode(model.getUser()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            // 查询病人家庭签约的健康管理师 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            SignFamily signFamily = signFamilyDao.findByjiatingPatientYes(p.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String healthDoctorFamily = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (signFamily != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                healthDoctorFamily = signFamily.getDoctorHealth(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (StringUtils.isNotEmpty(healthDoctorFamily)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    // 添加到消息接收人列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    receivers.add(healthDoctorFamily); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            // 查询病人三师签约中的健康管理师 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            SignFamily signFamilySS = signFamilyDao.findBySanshiPatientYes(p.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (signFamilySS != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String healthDoctorTeam = signFamilySS.getDoctorHealth(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                // 判断是否是否是同一个健康管理师 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (StringUtils.isNotEmpty(healthDoctorTeam) && !StringUtils.equals(healthDoctorFamily, healthDoctorTeam)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    // 添加到消息接收人列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    receivers.add(healthDoctorTeam); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            List<Message> messages = new ArrayList<Message>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONArray array = new JSONArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for (String receiver : receivers) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (StringUtils.isEmpty(receiver)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Patient patient = patientDao.findByCode(patientCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                // 保存异常消息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Message message = new Message(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                message.setCzrq(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                message.setCreateTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                message.setRead(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                message.setOver("1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                message.setReceiver(receiver); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                message.setSender(p.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                message.setCode(getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                message.setSex(patient.getSex()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                message.setSenderName(p.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                message.setSenderPhoto(p.getPhoto()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                message.setTitle("预警值信息"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String typeName = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                switch (model.getType()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    case 1: { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        typeName = "血糖"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    case 2: { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        typeName = "血压"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    case 3: { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        typeName = "体重"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    case 4: { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        typeName = "腰围"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                message.setContent(patient.getName() + typeName + "超过预警值"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                message.setType(2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                message.setValue1(value1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                message.setValue2(value2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                message.setTzCode(model.getId() + "");//消息关联的体征id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                message.setTzType(model.getType() + "");//体征类别 (1血糖,2血压,3体重,4腰围) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                messages.add(message); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if(messageService.getMessageNoticeSettingByMessageType(receiver,"1",MessageNoticeSetting.MessageTypeEnum.healthSignSwitch.getValue())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    // 异常通知 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    JSONObject json = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    json.put("receiver", receiver); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    json.put("type", MessageType.MESSAGE_TYPE_DOCTOR_HEALTH_INDEX.D_HI_01.name()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    json.put("title", MessageType.MESSAGE_TYPE_DOCTOR_HEALTH_INDEX.体征指标.name()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    json.put("msg", p.getName() + "的体征指标出现异常,请及时处理!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    json.put("data", ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    JSONObject jsonObject = doctorWorkTimeService.isDoctorWorking(receiver); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (jsonObject.getString("status").equals("1")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        //如果在工作时间内就推送 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        array.put(json); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            // 批量保存消息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            messageDao.save(messages); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            // 推送消息给医生 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            pushMsgTask.put(array); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return model; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 判断当前值是否在区间内 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -526,61 +389,6 @@ public class PatientHealthIndexService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        pushMsgTask.put(array); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 获取患者某天血糖值 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private DevicePatientHealthIndex getPatientXT(String patient, String dateString) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        DevicePatientHealthIndex obj = new DevicePatientHealthIndex(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        obj.setUser(patient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        boolean hadData = false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Date date = DateUtil.strToDateShort(dateString); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        /***************** 按时间排序 ***************************/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<DevicePatientHealthIndex> list = patientHealthIndexDao.findByDate(patient, dateString); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (list != null && list.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            obj.setType(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            obj.setCzrq(date); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            obj.setRecordDate(date); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            obj.setSortDate(date); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for (DevicePatientHealthIndex item : list) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String data = item.getValue1(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String dataType = item.getValue2(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                Date recordDate = item.getRecordDate(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                obj.setId(item.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (data != null && dataType != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (dataType.equals("1")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        obj.setValue1(data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        hadData = true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } else if (dataType.equals("2")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        obj.setValue2(data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        hadData = true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } else if (dataType.equals("3")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        obj.setValue3(data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        hadData = true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } else if (dataType.equals("4")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        obj.setValue4(data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        hadData = true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } else if (dataType.equals("5")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        obj.setValue5(data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        hadData = true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } else if (dataType.equals("6")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        obj.setValue6(data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        hadData = true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } else if (dataType.equals("7")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        obj.setValue7(data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        hadData = true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (hadData) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return obj; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 获取患者某天血糖值 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -616,8 +424,6 @@ public class PatientHealthIndexService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " GROUP BY user,value1,value2,value3,value4,value5,value6,value7,type,record_date,sort_date " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " order by record_date,id desc "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        List<DevicePatientHealthIndex> list = patientHealthIndexDao.findByDateNative(patient, dateString); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (list != null && list.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            obj.put("type", 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            obj.put("czrq", date); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -691,7 +497,7 @@ public class PatientHealthIndexService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public void verifyHealthIndex(Long id) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //指标信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        DevicePatientHealthIndex data = patientHealthIndexDao.findOne(id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        DevicePatientHealthIndex data = findOne(id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String patientCode = data.getUser(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //患者信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Patient patient = patientDao.findByCode(patientCode); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -727,14 +533,12 @@ public class PatientHealthIndexService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (!checkHealthIndex(NumberUtils.toDouble(value1), maxValueAfter, minValueAfter)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    msgContent += patient.getName() + "血糖异常(" + value1 + "mmol/L)"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    //体征异常,更新体征数据状态 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    data.setStatus(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    patientHealthIndexDao.save(data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    updateStatus(data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } else { //餐前 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (!checkHealthIndex(NumberUtils.toDouble(value1), maxValueBefore, minValueBefore)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    msgContent += patient.getName() + "血糖异常(" + value1 + "mmol/L)"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    data.setStatus(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    patientHealthIndexDao.save(data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    updateStatus(data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -765,8 +569,7 @@ public class PatientHealthIndexService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            // 收缩压/舒张压校验 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (!checkHealthIndex(NumberUtils.toDouble(value1), maxValueSSY, minValueSSY) || !checkHealthIndex(NumberUtils.toDouble(value2), maxValueSZY, minValueSZY)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                msgContent = patient.getName() + "血压异常(舒张压 " + value2 + "mmHg、收缩压 " + value1 + "mmHg)"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                data.setStatus(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                patientHealthIndexDao.save(data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                updateStatus(data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -776,6 +579,63 @@ public class PatientHealthIndexService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /********************************************物联网 start***********************************************************/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 修改体征异常状态 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param data 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public void updateStatus(DevicePatientHealthIndex data){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(iotDeviceService.isUploadIot()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //物联网更新 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            iotDeviceService.updateStatus(data.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            data.setStatus(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            patientHealthIndexDao.save(data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 按id查找体征记录 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public DevicePatientHealthIndex findOne(Long id){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(iotDeviceService.isUploadIot()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return iotDeviceService.getById(id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return patientHealthIndexDao.findOne(id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 体征保存 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param data 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public DevicePatientHealthIndex save(DevicePatientHealthIndex data){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(iotDeviceService.isUploadIot()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return iotDeviceService.save(data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return patientHealthIndexDao.save(data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 体征修改 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param data 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public DevicePatientHealthIndex update(DevicePatientHealthIndex data){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(iotDeviceService.isUploadIot()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return iotDeviceService.update(data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return patientHealthIndexDao.save(data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /********************************************物联网 end***********************************************************/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 新增患者指标 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 【血糖】{"time":"2016-09-09 17:00:00","gi":"血糖值(mmol/L)"} 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -907,7 +767,7 @@ public class PatientHealthIndexService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            obj = patientHealthIndexDao.save(obj); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            obj = save(obj); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //判断是否有未结束的续方咨询,发送消息给对应的医生 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            sendPrescriptionHealthIndexMsgresult(obj,patient); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1000,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); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1007,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); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1015,24 +879,162 @@ 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; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 按录入时间和患者标识查询健康记录 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1053,32 +1055,32 @@ public class PatientHealthIndexService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @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; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//    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; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 按时间段查询患者健康指标 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1148,19 +1150,6 @@ public class PatientHealthIndexService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            re.put(json); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        if (gi_type != 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            Sort sort = new Sort(Direction.ASC, "recordDate"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            PageRequest pageRequest = new PageRequest(0, 1000, sort); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            re = patientHealthIndexDao.findIndexByPatientNative(patient, type, gi_type + "", startDate, endDate, pageRequest.getOffset(), pageRequest.getPageSize()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            // 排序 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            Sort sort = new Sort(Direction.ASC, "recordDate"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            PageRequest pageRequest = new PageRequest(0, 1000, sort); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            re = patientHealthIndexDao.findIndexByPatientNative(patient, type, startDate, endDate, pageRequest.getOffset(), pageRequest.getPageSize()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return re; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1180,22 +1169,9 @@ public class PatientHealthIndexService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (page > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            page = page - 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Date startDate = DateUtil.strToDate(start, DateUtil.YYYY_MM_DD_HH_MM_SS); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Date endDate = DateUtil.strToDate(end, DateUtil.YYYY_MM_DD_HH_MM_SS); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (type == 1)   //血糖特殊处理 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            PageRequest pageRequest = new PageRequest(page, pageSize); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            //根据时间过滤排序 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            List<String> dateList = patientHealthIndexDao.findDateList(patient, startDate, endDate, pageRequest.getOffset(), pageRequest.getPageSize()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            if (dateList != null && dateList.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                for (String dateString : dateList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    DevicePatientHealthIndex obj = getPatientXT(patient, dateString); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    if (obj != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                        re.add(obj); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            // 排序 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Sort sort = new Sort(Direction.DESC, "recordDate"); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1250,10 +1226,6 @@ public class PatientHealthIndexService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                re.put(json); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            List<DevicePatientHealthIndex> list = patientHealthIndexDao.findIndexByPatientNative(patient, type, startDate, endDate, pageRequest.getOffset(), pageRequest.getPageSize()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            re = list; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return re; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1298,39 +1270,6 @@ public class PatientHealthIndexService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return re; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 根据患者标志获取健康指标 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param patientCode 患者标志 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param pageSize    页数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 健康指标列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public Page<DevicePatientHealthIndex> findByPatien(String patientCode, int type, Date sortDate, Date begin, Date end, int pageSize) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (pageSize <= 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            pageSize = 10; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        // 排序 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Sort sort = new Sort(Direction.DESC, "sortDate"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        // 分页信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        PageRequest pageRequest = new PageRequest(0, pageSize, sort); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        // 设置查询条件 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Map<String, SearchFilter> filters = new HashMap<String, SearchFilter>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        // 患者标志 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        filters.put("user", new SearchFilter("user", Operator.EQ, patientCode)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (sortDate != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            filters.put("sortDate", new SearchFilter("sortDate", Operator.LT, sortDate)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        filters.put("recordDate1", new SearchFilter("recordDate", Operator.GTE, begin)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        filters.put("recordDate2", new SearchFilter("recordDate", Operator.LTE, end)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        filters.put("type", new SearchFilter("type", Operator.EQ, type)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        // 未作废 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        filters.put("del", new SearchFilter("del", Operator.EQ, "1")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Specification<DevicePatientHealthIndex> spec = DynamicSpecifications.bySearchFilter(filters.values(), DevicePatientHealthIndex.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return patientHealthIndexDao.findAll(spec, pageRequest); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 查询患者健康指标预警值 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1433,48 +1372,6 @@ public class PatientHealthIndexService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return array; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 查询上一次的值 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param patient 患者标识 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param type    类型:1血糖,2血压 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param index   第几个值,1~7 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private String findPreValue(String patient, int type, int index, Date recordDate) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        // 分页信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        PageRequest pageRequest = new PageRequest(0, 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        Page<String> page = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        switch (index) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            case 1: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                page = patientHealthIndexDao.findValue1ByPatient(patient, type, recordDate, pageRequest); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            case 2: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                page = patientHealthIndexDao.findValue2ByPatient(patient, type, recordDate, pageRequest); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            case 3: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                page = patientHealthIndexDao.findValue3ByPatient(patient, type, recordDate, pageRequest); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            case 4: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                page = patientHealthIndexDao.findValue4ByPatient(patient, type, recordDate, pageRequest); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            case 5: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                page = patientHealthIndexDao.findValue5ByPatient(patient, type, recordDate, pageRequest); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            case 6: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                page = patientHealthIndexDao.findValue6ByPatient(patient, type, recordDate, pageRequest); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            case 7: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                page = patientHealthIndexDao.findValue7ByPatient(patient, type, recordDate, pageRequest); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (page != null && page.getNumberOfElements() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return page.getContent().get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return "0"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 根据患者标志获取健康指标 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1485,12 +1382,6 @@ public class PatientHealthIndexService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //最新血糖指标 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (type == 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            DevicePatientHealthIndex obj = patientHealthIndexDao.findLastData(patientCode, 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            if (obj != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                String dateString = DateUtil.dateToStrShort(obj.getRecordDate()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                return getPatientXT(patientCode, dateString); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//                return null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return obj; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } else if (type == 2) {  //其他指标 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return patientHealthIndexDao.findLastData(patientCode, 2); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1499,25 +1390,6 @@ public class PatientHealthIndexService extends BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public com.alibaba.fastjson.JSONObject findLastBypatient(String patientCode, int type) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (type == 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            DevicePatientHealthIndex obj = patientHealthIndexDao.findLastData(patientCode, 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (obj != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                String dateString = DateUtil.dateToStrShort(obj.getRecordDate()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                return getPatientXT_Json(patientCode, dateString); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                return null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            DevicePatientHealthIndex obj = patientHealthIndexDao.findLastData(patientCode, type); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (obj != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                return JSON.parseObject(JSON.toJSONString(obj)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                return null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 获取患者健康指标历史记录 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 1血糖,2血压,3体重,4腰围 
			 |