浏览代码

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

trick9191 7 年之前
父节点
当前提交
25ceefc359

+ 4 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/health/repository/DevicePatientHealthIndexDao.java

@ -101,9 +101,9 @@ public interface DevicePatientHealthIndexDao
	@Query(value= " select * from device.wlyy_patient_health_index where type in (1,2) and record_date BETWEEN ?1 AND ?2  AND user in (select p.code from wlyy.wlyy_patient p INNER JOIN wlyy.wlyy_sign_family s on s.patient = p.code and s.status > 0 AND s.admin_team_code = ?3 and p.disease >0 and (s.doctor = ?4 or s.doctor_health =?4))",nativeQuery = true)
	List<DevicePatientHealthIndex> findByTeamcodeAndRecordDate(Date start, Date end,String teamcode,String doctorcode);
	@Query("select a from DevicePatientHealthIndex a where a.user = ?1 and a.type =?2  order by recordDate desc ")
	List<DevicePatientHealthIndex> findByPatientAndTypeByPage(String patientCode, int type, Pageable pageable);
	@Query(value="select * from device.wlyy_patient_health_index where user = ?1 and type = ?2 ORDER BY record_date desc limit 0 ,5",nativeQuery = true)
	List<DevicePatientHealthIndex> findByPatientAndTypeByPage(String patientCode, int type);
	@Query("select count(a) from DevicePatientHealthIndex a where a.recordDate >= ?1 and a.recordDate <= ?2 and a.type in (1,2) and a.status = ?3 and a.del = '1'")
	int getCountByTimeAndStatus(Date start, Date end,int status);
	@Query("select count(a) from DevicePatientHealthIndex a where a.recordDate >= ?1 and a.recordDate <= ?2 and a.type in (1,2) and a.status = ?3 and a.del = '1' and user = ?4")
	int getCountByTimeAndStatus(Date start, Date end, int status, String patientCode);
}

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

@ -867,33 +867,24 @@ public class PatientHealthIndexService extends BaseService {
        String patientCode = obj.getUser();
        //患者信息
        Patient patient = patientDao.findByCode(patientCode);
        int bloodPressureBbnormalCount = 0;//血压异常次数
        int bloodSuggurBbnormalCount = 0;//血糖异常次数
        // 排序
        Sort sort = new Sort(Sort.Direction.DESC, "recordDate");
        // 分页信息
        Pageable pageRequest = new PageRequest(0, 5, sort);
        Pageable pageable = new PageRequest(1, 5);
        List<DevicePatientHealthIndex> bloodPressurepatientHealthIndices = new ArrayList<>();
        List<DevicePatientHealthIndex> bloodSuggurpatientHealthIndices = new ArrayList<>();
        if( 1 == patient.getDisease()){
            bloodPressurepatientHealthIndices = patientHealthIndexDao.findByPatientAndTypeByPage(patientCode,2,pageable);
        } else if( 2 == patient.getDisease()){
            bloodSuggurpatientHealthIndices = patientHealthIndexDao.findByPatientAndTypeByPage(patientCode,1,pageable);
        } else {
            bloodPressurepatientHealthIndices = patientHealthIndexDao.findByPatientAndTypeByPage(patientCode,2,pageable);
            bloodSuggurpatientHealthIndices = patientHealthIndexDao.findByPatientAndTypeByPage(patientCode,1,pageable);
        }
        for (DevicePatientHealthIndex patientHealthIndex : bloodPressurepatientHealthIndices) {
            if(patientHealthIndex.getStatus() != null && 1 == patientHealthIndex.getStatus()){
        bloodPressurepatientHealthIndices = patientHealthIndexDao.findByPatientAndTypeByPage(patientCode,2);
        bloodSuggurpatientHealthIndices = patientHealthIndexDao.findByPatientAndTypeByPage(patientCode,1);
        for (DevicePatientHealthIndex index1 : bloodPressurepatientHealthIndices) {
            if(index1.getStatus() != null && 1 == index1.getStatus()){
                bloodPressureBbnormalCount++;
            }
        }
        for (DevicePatientHealthIndex patientHealthIndex : bloodSuggurpatientHealthIndices) {
            if(patientHealthIndex.getStatus() != null && 1 == patientHealthIndex.getStatus()){
        for (DevicePatientHealthIndex index2 : bloodSuggurpatientHealthIndices) {
            if(index2.getStatus() != null && 1 == index2.getStatus()){
                bloodSuggurBbnormalCount++;
            }
        }
@ -906,14 +897,28 @@ public class PatientHealthIndexService extends BaseService {
            Date end = new Date();
            Date start = DateUtil.setDateTime(end,-7);
            //计算血糖或者血压一周内的异常记录数量
            int errorCount = patientHealthIndexDao.getCountByTimeAndStatus(start,end,1);
            int errorCount = patientHealthIndexDao.getCountByTimeAndStatus(start,end,1,patientCode);
            if(errorCount >= 5){//超过5次,记为预警状态
                patient.setStandardStatus(1);
            }
        }
        //连续5次正常,修改用户为非预警状态
        if((0 == bloodPressureBbnormalCount && 0 == bloodSuggurBbnormalCount) && 1 == patient.getStandardStatus()){
        if(patient.getDisease() != null){
            if( 1 == patient.getDisease()){
                if(0 == bloodPressureBbnormalCount && 1 == patient.getStandardStatus()){
                    patient.setStandardStatus(0);
                }
            }else if(2 == patient.getDisease()){
                if(0 == bloodSuggurBbnormalCount && 1 == patient.getStandardStatus()){
                    patient.setStandardStatus(0);
                }
            }else if( 3 == patient.getDisease()){
                if( (0 == bloodSuggurBbnormalCount|| 0 == bloodPressureBbnormalCount)&& 1 == patient.getStandardStatus()){
                    patient.setStandardStatus(0);
                }
            }
        }else{
            patient.setStandardStatus(0);
        }