瀏覽代碼

Merge branch 'dev' of trick9191/patient-co-management into dev

trick9191 7 年之前
父節點
當前提交
fe7e107f1f

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

@ -384,17 +384,21 @@ public class DeviceService {
            if (result == null) {
                throw new Exception("This device is not relate patient!");
            } else {
    
                //患者信息
                String patientCode = result.getUser();
                Patient patient = patientDao.findByCode(patientCode);
                
                String patientsql = "select group_concat(label) disease from wlyy.wlyy_sign_patient_label_info where label_type = 3 and status=1 and (label = 1 or label = 2) and patient = '"+patient.getCode()+"' GROUP BY patient";
                String patientdisease = jdbcTemplate.queryForObject(patientsql,String.class);
                //血糖、血压数据需校验,如果超标,需要发送消息给医生
                if (1 == deviceType || 2 == deviceType) {
                    verifyHealthIndex(result);
                    //发送华三demo推送
//                    messagePush(result);
                    
                    //判断是否有未结束的续方咨询,发送消息给对应的医生----huangwenjie--2017.11.06
                    sendPrescriptionHealthIndexMsgresult(result,patient);
                }
@ -443,16 +447,16 @@ public class DeviceService {
                }
                //连续5次正常,修改用户为非预警状态
                if(patient.getDisease() != null){
                    if( 1 == patient.getDisease()){
                if(StringUtils.isNotBlank(patientdisease)){
                    if("1".equals(patientdisease)){
                        if(0 == bloodPressureBbnormalCount && (patient.getStandardStatus() == null || 1 == patient.getStandardStatus())){
                            patient.setStandardStatus(0);
                        }
                    }else if(2 == patient.getDisease()){
                    }else if("2".equals(patientdisease)){
                        if(0 == bloodSuggurBbnormalCount && (patient.getStandardStatus() == null || 1 == patient.getStandardStatus())){
                            patient.setStandardStatus(0);
                        }
                    }else if( 3 == patient.getDisease()){
                    }else if( "1,2".equals(patientdisease) || "2,1".equals(patientdisease)){
                        if( 0 == bloodSuggurBbnormalCount && 0 == bloodPressureBbnormalCount && (patient.getStandardStatus() == null || 1 == patient.getStandardStatus())){
                            patient.setStandardStatus(0);
                        }
@ -471,7 +475,7 @@ public class DeviceService {
        return Result.success("Device data incoming success");
    }
    
    /**
     * 保存设备数据
     */
@ -897,7 +901,7 @@ public class DeviceService {
            ex.printStackTrace();
        }
    }
    
    /**
     * 判断是否有未结束的续方咨询,发送消息给对应的医生
     * @param result
@ -905,7 +909,7 @@ public class DeviceService {
     */
    private void sendPrescriptionHealthIndexMsgresult(PatientHealthIndex result, Patient patient) {
        List<ConsultTeam> consultTeams = consultTeamDao.findUnfinishedConsult(patient.getCode());
    
        for (ConsultTeam consultTeam:consultTeams) {
            if(consultTeam.getHealthindexType() != null){
                org.json.JSONObject contentPatient = new org.json.JSONObject();
@ -918,12 +922,12 @@ public class DeviceService {
                    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);
            }

+ 27 - 20
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthIndexService.java

@ -12,6 +12,7 @@ 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.vo.PatientVO;
import com.yihu.wlyy.health.repository.DevicePatientHealthIndexDao;
import com.yihu.wlyy.repository.consult.ConsultTeamDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
@ -36,6 +37,7 @@ 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;
@ -897,12 +899,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 {
@ -912,16 +914,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();
@ -934,12 +936,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);
            }
@ -955,7 +957,12 @@ public class PatientHealthIndexService extends BaseService {
        //连续5次体征值正常,则修改为非预警状态;连续5次异常,修改为预警状态-----START
        String patientCode = obj.getUser();
        //患者信息
        Patient patient = patientDao.findByCode(patientCode);
        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;//血糖异常次数
@ -981,37 +988,37 @@ public class PatientHealthIndexService extends BaseService {
        //连续3次异常,修改用户为预警状态
        if ((bloodPressureBbnormalCount >= 3 || bloodSuggurBbnormalCount >= 3) && (patient.getStandardStatus() == null || 0 == patient.getStandardStatus())) {
            patient.setStandardStatus(1);
            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次,记为预警状态
                patient.setStandardStatus(1);
                p.setStandardStatus(1);
            }
        }
        //连续5次正常,修改用户为非预警状态
        if (patient.getDisease() != null) {
            if (1 == patient.getDisease()) {
        if (StringUtils.isNotBlank(patientdisease)) {
            if ("1".equals(patientdisease)) {
                if (0 == bloodPressureBbnormalCount && (patient.getStandardStatus() == null || 1 == patient.getStandardStatus())) {
                    patient.setStandardStatus(0);
                    p.setStandardStatus(0);
                }
            } else if (2 == patient.getDisease()) {
            } else if ("2".equals(patientdisease)) {
                if (0 == bloodSuggurBbnormalCount && (patient.getStandardStatus() == null || 1 == patient.getStandardStatus())) {
                    patient.setStandardStatus(0);
                    p.setStandardStatus(0);
                }
            } else if (3 == patient.getDisease()) {
            } else if ("1,2".equals(patientdisease) || "2,1".equals(patientdisease)) {
                if (0 == bloodSuggurBbnormalCount && 0 == bloodPressureBbnormalCount && (patient.getStandardStatus() == null || 1 == patient.getStandardStatus())) {
                    patient.setStandardStatus(0);
                    p.setStandardStatus(0);
                }
            }
        } else {
            patient.setStandardStatus(0);
            p.setStandardStatus(0);
        }
        patientDao.save(patient);
        patientDao.save(p);
        //连续5次体征值正常,则修改为非预警状态;连续5次异常,修改为预警状态-----END
    }

+ 2 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/call/CustomerService.java

@ -9,6 +9,7 @@ import com.yihu.wlyy.repository.call.CallServiceDao;
import com.yihu.wlyy.repository.message.MessageDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.DateUtil;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -176,7 +177,7 @@ public class CustomerService extends BaseService{
			cs.setOrderHospitalName(orderHospitalName);
			cs.setOrderTime(orderTime);
			cs.setDealTime(new Date());
			cs.setRegisterTime(new Date());
			cs.setRegisterTime(DateUtil.stringToDate(registerTime,"yyyy-MM-dd HH:mm:ss"));
			cs.setDealState(1);
		//预约失败
		}else{