浏览代码

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

lyr 8 年之前
父节点
当前提交
758361a878

+ 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()));
    }
}

+ 25 - 92
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java

@ -796,8 +796,8 @@ public class FamilyContractService extends BaseService {
        doctorTeamDoctor.save(wlyyDoctorTeamPatient);
        // 患者标签设置
        if(!(labelInfoService.setPatientLabels(patient.getCode(),patient.getIdcard(),
                patient.getName(),healthLabel,disease,customLabel) == 1)){
        if (!(labelInfoService.setPatientLabels(patient.getCode(), patient.getIdcard(),
                patient.getName(), healthLabel, disease, customLabel) == 1)) {
            throw new Exception("patient sign label settting error:" + patient.getIdcard());
        }
@ -967,8 +967,8 @@ public class FamilyContractService extends BaseService {
        }
        // 患者标签设置
        if(!(labelInfoService.setPatientLabels(p.getCode(),p.getIdcard(),
                p.getName(),healthLabel,disease,customLabel) == 1)){
        if (!(labelInfoService.setPatientLabels(p.getCode(), p.getIdcard(),
                p.getName(), healthLabel, disease, customLabel) == 1)) {
            throw new Exception("patient sign label settting error:" + p.getIdcard());
        }
@ -1475,96 +1475,29 @@ public class FamilyContractService extends BaseService {
                result.put("msg", "医生不存在");
            }
            if (StringUtils.isNotEmpty(signFamily.getDoctorHealth())) {
                // 取消原有健康管理师的家庭签约分组,并新增分组
                List<DoctorPatientGroupInfo> groups = doctorPatientGroupInfoDao.findGroupInfoByPatientAndDoctor(signFamily.getDoctorHealth(), patient);
                if (groups != null) {
                    List<DoctorPatientGroupInfo> newGroups = new ArrayList<>();
                    for (DoctorPatientGroupInfo group : groups) {
                        if (group.getGroup().equals("1") || group.getGroup().equals("2") || group.getGroup().equals("3")) {
                            DoctorPatientGroupInfo newGroup = new DoctorPatientGroupInfo();
                            newGroup.setDoctor(doctor.getCode());
                            newGroup.setCzrq(new Date());
                            newGroup.setGroup(group.getGroup());
                            newGroup.setPatient(patient);
                            newGroup.setSignType("2");
                            newGroup.setStatus(1);
                            newGroup.setPname(group.getPname());
                            newGroups.add(newGroup);
                        }
                        group.setStatus(0);
                        group.setCzrq(new Date());
                    }
                    if (newGroups.size() > 0) {
                        doctorPatientGroupInfoDao.save(newGroups);
                    }
                    // 更新团队信息
                    if (StringUtils.isNotEmpty(signFamily.getTeamCode())) {
                        DoctorTeamMember teamMember = doctorTeamDoctor.findMemberByTeamAndCode(signFamily.getTeamCode(), signFamily.getDoctorHealth());
                        if (teamMember != null) {
                            teamMember.setDel("0");
                            teamMember.setCzrq(new Date());
                        }
                        DoctorTeamMember newTeamMember = new DoctorTeamMember();
                        newTeamMember.setCode(getCode());
                        newTeamMember.setMemberCode(doctor.getCode());
                        newTeamMember.setName(doctor.getName());
                        newTeamMember.setTeam(signFamily.getTeamCode());
                        newTeamMember.setDel("1");
                        newTeamMember.setSignType("2");
                        newTeamMember.setType(3);
                        newTeamMember.setCzrq(new Date());
                        doctorTeamDoctor.save(newTeamMember);
                    }
                }
            } else {
                // 新增分组
                List<DoctorPatientGroupInfo> groups = doctorPatientGroupInfoDao.findGroupInfoByPatientAndDoctor(signFamily.getDoctor(), patient);
                if (groups != null) {
                    List<DoctorPatientGroupInfo> newGroups = new ArrayList<>();
                    for (DoctorPatientGroupInfo group : groups) {
                        if (group.getGroup().equals("1") || group.getGroup().equals("2") || group.getGroup().equals("3")) {
                            DoctorPatientGroupInfo newGroup = new DoctorPatientGroupInfo();
                            newGroup.setDoctor(doctor.getCode());
                            newGroup.setCzrq(new Date());
                            newGroup.setGroup(group.getGroup());
                            newGroup.setPatient(patient);
                            newGroup.setSignType("2");
                            newGroup.setStatus(1);
                            newGroup.setPname(group.getPname());
                            newGroups.add(newGroup);
                        }
                    }
                    if (newGroups.size() > 0) {
                        doctorPatientGroupInfoDao.save(newGroups);
                    }
                    // 新增团队信息
                    if (StringUtils.isNotEmpty(signFamily.getTeamCode())) {
                        DoctorTeamMember newTeamMember = new DoctorTeamMember();
                        newTeamMember.setCode(getCode());
                        newTeamMember.setMemberCode(doctor.getCode());
                        newTeamMember.setName(doctor.getName());
                        newTeamMember.setTeam(signFamily.getTeamCode());
                        newTeamMember.setDel("1");
                        newTeamMember.setSignType("2");
                        newTeamMember.setType(3);
                        newTeamMember.setCzrq(new Date());
                        doctorTeamDoctor.save(newTeamMember);
                    }
                DoctorTeamMember teamMember = doctorTeamDoctor.findMemberByTeamAndCode(signFamily.getTeamCode(), signFamily.getDoctorHealth());
                if (teamMember != null) {
                    teamMember.setDel("0");
                    teamMember.setCzrq(new Date());
                    doctorTeamDoctor.save(teamMember);
                }
            }
            // 新增团队信息
            if (StringUtils.isNotEmpty(signFamily.getTeamCode())) {
                DoctorTeamMember newTeamMember = new DoctorTeamMember();
                newTeamMember.setCode(getCode());
                newTeamMember.setMemberCode(doctor.getCode());
                newTeamMember.setName(doctor.getName());
                newTeamMember.setTeam(signFamily.getTeamCode());
                newTeamMember.setDel("1");
                newTeamMember.setSignType("2");
                newTeamMember.setType(3);
                newTeamMember.setCzrq(new Date());
                doctorTeamDoctor.save(newTeamMember);
            }
            signFamily.setDoctorHealth(doctor.getCode());
            signFamily.setDoctorHealthName(doctor.getName());