Browse Source

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

trick9191 7 years ago
parent
commit
d7f5e6529f

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

@ -4,18 +4,17 @@ 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.*;
@ -92,6 +91,10 @@ public class PatientHealthIndexService extends BaseService {
    @Autowired
    private MessageService messageService;
    @Autowired
    private DoctorSwitchDao doctorSwitchDao;
    @Autowired
    private TrackPatientDao trackPatientDao;
    @Autowired
    private IotDeviceService iotDeviceService;
    /**
@ -857,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);
@ -864,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);
		    }
	    }
	
@ -872,24 +879,209 @@ 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;
    }
    /**
     * 按录入时间和患者标识查询健康记录
     *
     * @param patientCode
     * @param date
     * @return
     */
    public Iterable<DevicePatientHealthIndex> findByPatienDate(String patientCode, int type, Date date) {
        return patientHealthIndexDao.findByPatienDate(patientCode, type, date);
    }
    /**
     * 按时间段查询患者健康指标
     *
     * @param type  健康指标类型(1血糖,2血压,3体重,4腰围)
     * @param begin 开始时间
     * @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;
    }
    /**
     * 按时间段查询患者健康指标
     *

+ 14 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java

@ -1210,8 +1210,10 @@ public class SignPatientLabelInfoService extends BaseService {
                                "     AND t2.status = 1 " +
                                "     AND (t1.doctor = ? or t1.doctor_health = ?)" +
                                "     AND t1.status > 0 " +
                                (teamCode > 0 ? "    AND t1.admin_team_code = ? " : "")+
                                "     AND t3.disease_condition = ? ";
                                (teamCode > 0 ? "    AND t1.admin_team_code = ? " : "");
                                if(StringUtils.isNotBlank(diseaseCondition)){
                                   sql+=" AND t3.disease_condition = ? ";
                                }
                                //1.4.2新增重点居民跟踪过滤
                                if(StringUtils.isNotBlank(trackFlag)&&"1".equals(trackFlag)){
                                    sql = sql + " AND tp.del='1' AND tp.doctor_code='"+doctor+"' AND tp.team_code ="+teamCode;
@ -1221,9 +1223,17 @@ public class SignPatientLabelInfoService extends BaseService {
                                }
                        if (teamCode > 0) {
                            args = new Object[]{label.getLabelCode(), labelType, doctor, doctor, teamCode,diseaseCondition};
                            if(StringUtils.isNotBlank(diseaseCondition)){
                                args = new Object[]{label.getLabelCode(), labelType, doctor, doctor, teamCode,diseaseCondition};
                            }else {
                                args = new Object[]{label.getLabelCode(), labelType, doctor, doctor, teamCode};
                            }
                        } else {
                            args = new Object[]{label.getLabelCode(), labelType, doctor, doctor,diseaseCondition};
                            if(StringUtils.isNotBlank(diseaseCondition)){
                                args = new Object[]{label.getLabelCode(), labelType, doctor, doctor,diseaseCondition};
                            }else{
                                args = new Object[]{label.getLabelCode(), labelType, doctor, doctor};
                            }
                        }
                    }else{
                        continue;

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

@ -443,9 +443,7 @@ public class SignPatientLabelInfoController extends BaseController {
            if (StringUtils.isEmpty(health)) {
                return error(-1, "健康情况标签不能为空");
            }
            //xh1D201703150222
            int result = labelInfoService.setPatientLabels(patient, "", "", health, disease, custom, getUID(), getUID());
//            int result = labelInfoService.setPatientLabels(patient, "", "", health, disease, custom, "xh1D201703150222", "xh1D201703150222");
            if (result == 0) {
                return error(-1, "查不到患者信息");
@ -490,9 +488,7 @@ public class SignPatientLabelInfoController extends BaseController {
            if (StringUtils.isEmpty(patient)) {
                return error(-1, "患者不能为空");
            }
            //D2016008240002
            JSONArray labels = labelInfoService.getPatientLabelByLabelTypeAndTeamCode(patient, labelType, teamCode, getUID());
            //JSONArray labels = labelInfoService.getPatientLabelByLabelTypeAndTeamCode(patient, labelType, teamCode, "xh1D201703150222");
            return write(200, "查询成功", "data", labels);
        } catch (Exception e) {
            e.printStackTrace();
@ -884,7 +880,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,"xh1D2017031503333");
            com.alibaba.fastjson.JSONObject result = doctorSchemeService.getSlowDiseaseTeaminfos(teamCode,getcolor,getstands,gethealthindex,startdate,enddate,getUID());
            return write(200, "查询成功", "data", result);
        }catch (Exception e){
            //日志文件中记录异常信息

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

@ -241,7 +241,7 @@ public class DoctroSchemeController extends BaseController {
                                            @ApiParam(name="startDate", value="开始时间") @RequestParam(value = "startDate",required = true)String startDate,
                                            @ApiParam(name="endDate", value="结束时间") @RequestParam(value = "endDate",required = true)String endDate){
        try {
            return write(200, "查询成功", "data",doctorSchemeService.getTrackPatientCountTitle(teamCode,"xh1D2017031503333",startDate,endDate));
            return write(200, "查询成功", "data",doctorSchemeService.getTrackPatientCountTitle(teamCode,getUID(),startDate,endDate));
        }catch (Exception e){
            error(e);
            //返回接口异常信息处理结果