Ver código fonte

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

trick9191 7 anos atrás
pai
commit
8e59222b38

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

@ -384,24 +384,24 @@ 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推送
	
	            //患者信息
	            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);
                }
		
		            //判断是否有未结束的续方咨询,发送消息给对应的医生----huangwenjie--2017.11.06
		            sendPrescriptionHealthIndexMsgresult(result,patient);
	            }
                //指标数据上传基卫
                uploadHealthIndex(result);
@ -447,16 +447,16 @@ public class DeviceService {
                }
                //连续5次正常,修改用户为非预警状态
                if(StringUtils.isNotBlank(patientdisease)){
                    if("1".equals(patientdisease)){
                if(patient.getDisease() != null){
                    if( 1 == patient.getDisease()){
                        if(0 == bloodPressureBbnormalCount && (patient.getStandardStatus() == null || 1 == patient.getStandardStatus())){
                            patient.setStandardStatus(0);
                        }
                    }else if("2".equals(patientdisease)){
                    }else if(2 == patient.getDisease()){
                        if(0 == bloodSuggurBbnormalCount && (patient.getStandardStatus() == null || 1 == patient.getStandardStatus())){
                            patient.setStandardStatus(0);
                        }
                    }else if( "1,2".equals(patientdisease) || "2,1".equals(patientdisease)){
                    }else if( 3 == patient.getDisease()){
                        if( 0 == bloodSuggurBbnormalCount && 0 == bloodPressureBbnormalCount && (patient.getStandardStatus() == null || 1 == patient.getStandardStatus())){
                            patient.setStandardStatus(0);
                        }
@ -475,7 +475,7 @@ public class DeviceService {
        return Result.success("Device data incoming success");
    }
    
    /**
     * 保存设备数据
     */
@ -901,7 +901,7 @@ public class DeviceService {
            ex.printStackTrace();
        }
    }
    
    /**
     * 判断是否有未结束的续方咨询,发送消息给对应的医生
     * @param result
@ -909,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();
@ -922,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);
            }

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

@ -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
    }

+ 2 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/scheme/DoctorSchemeService.java

@ -396,11 +396,10 @@ public class DoctorSchemeService {
//        List<Patient> patients = patientDao.findAllSignPatientTeamcode(teamCode,doctorcode);
        List<PatientVO> patients = new ArrayList<>();
        String patientsql = "select p.*,b.deviceType as deviceType,group_concat(sp.label) as disease from wlyy_patient p " +
        String patientsql = "select p.code,p.standard_status,p.disease_condition,group_concat(sp.label) as disease from wlyy_patient p " +
                "  LEFT JOIN wlyy_sign_family s on s.patient = p.code " +
                "  RIGHT JOIN wlyy_sign_patient_label_info sp on sp.patient = p.code and sp.label_type = 3 and (sp.label = 1 or sp.label = 2) and sp.status =1" +
                "  LEFT JOIN (select user,sum(category_code) deviceType FROM wlyy_patient_device GROUP BY user) b on p.code = b.user " +
                "WHERE s.status > 0 and s.admin_team_code ='"+teamCode+"' and (s.doctor = '"+doctorcode+"' or s.doctor_health ='"+doctorcode+"') GROUP BY p.code";
                " WHERE s.status > 0 and s.admin_team_code ='"+teamCode+"' and (s.doctor = '"+doctorcode+"' or s.doctor_health ='"+doctorcode+"') GROUP BY p.code";
        patients= jdbcTemplate.query(patientsql,new BeanPropertyRowMapper(PatientVO.class));

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelInfoController.java

@ -845,7 +845,7 @@ public class SignPatientLabelInfoController extends BaseController {
            @ApiParam(name="startdate", value="体征数据开始时间yyyy-mm-dd hh:mm:ss") @RequestParam(value = "startdate",required = false,defaultValue = "2017-9-10 00:00:00")  String startdate,
            @ApiParam(name="enddate", value="体征数据结束时间yyyy-mm-dd hh:mm:ss") @RequestParam(value = "enddate",required = false,defaultValue = "2017-9-16 23:59:59")  String enddate){
        try {
            com.alibaba.fastjson.JSONObject result = doctorSchemeService.getSlowDiseaseTeaminfos(teamCode,getcolor,getstands,gethealthindex,startdate,enddate,"zbqD201703150226");
            com.alibaba.fastjson.JSONObject result = doctorSchemeService.getSlowDiseaseTeaminfos(teamCode,getcolor,getstands,gethealthindex,startdate,enddate,getUID());
            return write(200, "查询成功", "data", result);
        }catch (Exception e){
            //日志文件中记录异常信息