Browse Source

数据清洗修改

lyr 8 years ago
parent
commit
a706ee79e9

+ 1 - 1
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/dao/DoctorPatientGroupInfoDao.java

@ -106,6 +106,6 @@ public interface DoctorPatientGroupInfoDao extends PagingAndSortingRepository<Do
	List<DoctorPatientGroupInfo> findByGroupAndStatus(String group, Integer status);
	@Query("select a from DoctorPatientGroupInfo a where a.status = 1 and a.id >= ?1 and a.id < ?2 ")
	@Query("select a from DoctorPatientGroupInfo a where a.id between ?1 and ?2 and a.status = 1")
	Page<DoctorPatientGroupInfo> findByIdRange(Long start, Long end, Pageable pageRequest);
}

+ 1 - 1
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/dao/SignFamilyDao.java

@ -42,6 +42,6 @@ public interface SignFamilyDao extends PagingAndSortingRepository<SignFamily, Lo
	List<SignFamily> findByJiatingChaangeSignYesterdayExpensesStatus(String yesterday, String now);
	// 查询同步数据
	@Query("select a from SignFamily a where a.type = ?1 and a.signSource = ?2 and a.status > 0 and a.id >= ?3 and a.id <= ?4 order by a.id")
	@Query("select a from SignFamily a where a.id between ?3 and ?4 and a.type = ?1 and a.signSource = ?2 and a.status > 0 order by a.id")
	Page<SignFamily> findByTypeAndSignSourceAndId(Integer type,String signSource,Long start,Long end,Pageable pageable);
}

+ 5 - 0
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/task/PatientDiseaseToLabel.java

@ -14,6 +14,7 @@ import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.DefaultTransactionDefinition;
import java.text.SimpleDateFormat;
import java.util.*;
/**
@ -63,6 +64,8 @@ public class PatientDiseaseToLabel implements Runnable {
    }
    void diseasesToLabel(Page<PatientDisease> diseases) {
        System.out.println("sign-patient-group-team:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
        Map<String, SignPatientLabelInfo> labelInfos = new HashMap<>();
        for (PatientDisease disease : diseases.getContent()) {
@ -86,5 +89,7 @@ public class PatientDiseaseToLabel implements Runnable {
        }
        labelInfoDao.save(labelInfos.values());
        System.out.println("sign-patient-group-team:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
    }
}

+ 6 - 0
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/task/PatientGroupToLabelRunnable.java

@ -12,6 +12,7 @@ import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.DefaultTransactionDefinition;
import java.text.SimpleDateFormat;
import java.util.*;
/**
@ -63,6 +64,8 @@ public class PatientGroupToLabelRunnable implements Runnable {
    }
    void groupToLabel(Page<DoctorPatientGroupInfo> groups) {
        System.out.println("sign-patient-group-team:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
        Map<String, SignPatientLabelInfo> normalLabel = new HashMap<>();
        Map<String, SignPatientLabelInfo> manbingLabel = new HashMap<>();
        Map<String, SignPatientLabelInfo> sixFiveLabel = new HashMap<>();
@ -111,6 +114,9 @@ public class PatientGroupToLabelRunnable implements Runnable {
        if (sixFiveLabel.size() > 0) {
            labelInfoDao.save(sixFiveLabel.values());
        }
        groupInfoDao.save(groups);
        System.out.println("sign-patient-group-team:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
    }
}

+ 24 - 59
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/task/SignTeamAndGroupRunnable.java

@ -1,11 +1,9 @@
package com.yihu.wlyy.statistics.task;
import com.yihu.wlyy.statistics.Application;
import com.yihu.wlyy.statistics.dao.DoctorPatientGroupInfoDao;
import com.yihu.wlyy.statistics.dao.DoctorTeamDao;
import com.yihu.wlyy.statistics.dao.DoctorTeamMemberDao;
import com.yihu.wlyy.statistics.dao.SignFamilyDao;
import com.yihu.wlyy.statistics.dao.*;
import com.yihu.wlyy.statistics.model.doctor.DoctorPatientGroupInfo;
import com.yihu.wlyy.statistics.model.label.SignPatientLabelInfo;
import com.yihu.wlyy.statistics.model.signfamily.SignFamily;
import com.yihu.wlyy.statistics.model.team.DoctorTeam;
import com.yihu.wlyy.statistics.model.team.DoctorTeamMember;
@ -34,19 +32,19 @@ public class SignTeamAndGroupRunnable implements Runnable {
    long end = 0;
    SignFamilyDao signFamilyDao;
    DoctorPatientGroupInfoDao groupInfoDao;
    DoctorTeamDao teamDao;
    DoctorTeamMemberDao teamMemberDao;
    JpaTransactionManager transactionManager;
    SignPatientLabelInfoDao labelInfoDao;
    public SignTeamAndGroupRunnable(Long start, Long end){
        this.start = start;
        this.end = end;
        this.signFamilyDao = Application.ctx.getBean(SignFamilyDao.class);
        this.groupInfoDao = Application.ctx.getBean(DoctorPatientGroupInfoDao.class);
        this.teamDao = Application.ctx.getBean(DoctorTeamDao.class);
        this.teamMemberDao = Application.ctx.getBean(DoctorTeamMemberDao.class);
        this.transactionManager = Application.ctx.getBean(JpaTransactionManager.class);
        this.labelInfoDao = Application.ctx.getBean(SignPatientLabelInfoDao.class);
    }
    public String getCode() {
@ -85,6 +83,7 @@ public class SignTeamAndGroupRunnable implements Runnable {
        List<DoctorTeam> teams = new ArrayList<>();
        List<DoctorTeamMember> teamMembers = new ArrayList<>();
        List<DoctorPatientGroupInfo> groupList = new ArrayList<>();
        Map<String,SignPatientLabelInfo> labels =  new HashMap<>();
        List<SignFamily> signList = signs.getContent();
        for (SignFamily sign : signList) {
@ -158,77 +157,43 @@ public class SignTeamAndGroupRunnable implements Runnable {
                int age = IdCardUtil.getAgeForIdcard(sign.getIdcard());
                String groupCode = "1";
                String groupName = "普通人群";
                if (age >= 65) {
                    groupCode = "3";
                    groupName = "65岁以上人群";
                }
                if (StringUtils.isNotEmpty(sign.getDoctorHealth())) {
                    //把病人添加到健康管理师的健康分组里
                    DoctorPatientGroupInfo doctorPatientGroupInfo = new DoctorPatientGroupInfo();
                    doctorPatientGroupInfo.setCzrq(new Date());
                    doctorPatientGroupInfo.setDoctor(sign.getDoctorHealth());
                    doctorPatientGroupInfo.setStatus(1);
                    doctorPatientGroupInfo.setPatient(sign.getPatient());
                    doctorPatientGroupInfo.setPname(sign.getName());
                    doctorPatientGroupInfo.setPartAmount(0);
                    doctorPatientGroupInfo.setGroup(groupCode);//默认健康分组
                    doctorPatientGroupInfo.setQyrq(sign.getApplyDate());
                    doctorPatientGroupInfo.setSignType("2");//家庭签约
                    groupList.add(doctorPatientGroupInfo);
                }
                if (StringUtils.isNotEmpty(sign.getDoctor())) {
                    //把病人添加到全科医生的健康分组里
                    DoctorPatientGroupInfo doctorPatientGroupInfo = new DoctorPatientGroupInfo();
                    doctorPatientGroupInfo.setCzrq(new Date());
                    doctorPatientGroupInfo.setDoctor(sign.getDoctor());
                    doctorPatientGroupInfo.setStatus(1);
                    doctorPatientGroupInfo.setPatient(sign.getPatient());
                    doctorPatientGroupInfo.setPname(sign.getName());
                    doctorPatientGroupInfo.setPartAmount(0);
                    doctorPatientGroupInfo.setGroup(groupCode);//默认健康分组
                    doctorPatientGroupInfo.setQyrq(sign.getApplyDate());
                    doctorPatientGroupInfo.setSignType("2");//家庭签约
                    groupList.add(doctorPatientGroupInfo);
                }
                SignPatientLabelInfo label =  new SignPatientLabelInfo();
                List<DoctorPatientGroupInfo> groups = groupInfoDao.findPatientGroups(sign.getPatient());
                SignPatientLabelInfo exLabelInfo = labelInfoDao.findByPatientAndLabelAndLabelTypeAndStatus(
                        sign.getPatient(), groupCode, "1", 1);
                if (groups != null && groups.size() > 0) {
                    for (DoctorPatientGroupInfo group : groups) {
                        if (StringUtils.isNotEmpty(group.getSignType()) && group.getSignType().equals("2")) {
                            continue;
                        }
                if (exLabelInfo != null) {
                    continue;
                }
                        DoctorPatientGroupInfo patientGroup = new DoctorPatientGroupInfo();
                label.setPatient(sign.getPatient());
                label.setPatient(sign.getName());
                label.setLabel(groupCode);
                label.setLabelName(groupName);
                label.setLabelType("1");
                label.setStatus(1);
                label.setCzrq(new Date());
                        patientGroup.setCzrq(new Date());
                        patientGroup.setDoctor(group.getDoctor());
                        patientGroup.setStatus(1);
                        patientGroup.setPatient(sign.getPatient());
                        patientGroup.setPname(sign.getName());
                        patientGroup.setPartAmount(0);
                        patientGroup.setGroup(group.getGroup());
                        patientGroup.setQyrq(sign.getApplyDate());
                        patientGroup.setSignType("2");//家庭签约
                labels.put(sign.getPatient(),label);
                        groupList.add(patientGroup);
                    }
                }
                sign.setTeamCode(doctorTeamCode);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        teamDao.save(teams);
        teamMemberDao.save(teamMembers);
        groupInfoDao.save(groupList);
        labelInfoDao.save(labels.values());
        signFamilyDao.save(signList);
        System.out.println("sign-patient-group-team:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
    }
}