Selaa lähdekoodia

居民标签接口

lyr 8 vuotta sitten
vanhempi
commit
b5a2a962d3

+ 3 - 0
src/main/java/com/yihu/wlyy/repository/patient/SignFamilyDao.java

@ -289,4 +289,7 @@ public interface SignFamilyDao extends PagingAndSortingRepository<SignFamily, Lo
	//找出没有健康管理师的签约数据
	@Query("select a from SignFamily a where a.type = 2 and a.status >= 1 and a.doctorHealth is null and a.doctor=?1 order by a.czrq desc")
	Page<SignFamily> findNoHealthSignFamilyHealth(String doctor, Pageable pageRequest);
	@Query("select a from SignFamily a where a.type = ?1 and a.signSource = ?2 and a.status > 0 order by a.id")
	Page<SignFamily> findByTypeAndSignSource(Integer type,String signSource,Pageable pageable);
}

+ 216 - 0
src/main/java/com/yihu/wlyy/service/common/util/ManageUtilService.java

@ -0,0 +1,216 @@
package com.yihu.wlyy.service.common.util;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorPatientGroupInfo;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeam;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeamInfo;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeamMember;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.doctor.DoctorPatientGroupInfoDao;
import com.yihu.wlyy.repository.doctor.DoctorTeamDao;
import com.yihu.wlyy.repository.doctor.DoctorTeamMemberDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.IdCardUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.DefaultTransactionDefinition;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * Created by lyr-pc on 2016/10/11.
 */
@Service
@Transactional
public class ManageUtilService extends BaseService {
    @Autowired
    SignFamilyDao signFamilyDao;
    @Autowired
    DoctorPatientGroupInfoDao groupInfoDao;
    @Autowired
    DoctorTeamDao teamDao;
    @Autowired
    DoctorTeamMemberDao teamMemberDao;
    @Autowired
    JpaTransactionManager transactionManager;
    static int page = 0;
    /**
     * 清洗头同步签约数据分组
     *
     * @return
     */
    public void signPatientSetGroup() {
        boolean flag = true;
        while (flag) {
            PageRequest pageRequest = new PageRequest(page, 1000);
            Page<SignFamily> signs = signFamilyDao.findByTypeAndSignSource(2, "1",pageRequest);
            if (signs != null && signs.getContent().size() == 1000) {
                page++;
            } else {
                flag = false;
            }
            DefaultTransactionDefinition def = new DefaultTransactionDefinition();
            def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); // 事物隔离级别,开启新事务
            TransactionStatus status = transactionManager.getTransaction(def); // 获得事务状态
            try {
                for (SignFamily sign : signs) {
                    if (StringUtils.isNotEmpty(sign.getTeamCode())) {
                        continue;
                    }
                    //建立团队
                    DoctorTeam doctorTeam = new DoctorTeam();
                    String doctorTeamCode = getCode();
                    doctorTeam.setCode(doctorTeamCode);
                    doctorTeam.setCzrq(new Date());
                    doctorTeam.setName("团队名称:" + sign.getName());
                    doctorTeam.setSignType("2");//家庭签约
                    doctorTeam.setDel("1");
                    teamDao.save(doctorTeam);
                    //添加团队成员
                    if (StringUtils.isNotEmpty(sign.getDoctor())) {
                        //添加全科
                        DoctorTeamMember wlyyDoctorTeamDoctor = new DoctorTeamMember();
                        wlyyDoctorTeamDoctor.setTeam(doctorTeamCode);
                        wlyyDoctorTeamDoctor.setMemberCode(sign.getDoctor());
                        wlyyDoctorTeamDoctor.setName(sign.getDoctorName());
                        wlyyDoctorTeamDoctor.setDel("1");
                        wlyyDoctorTeamDoctor.setType(2);
                        wlyyDoctorTeamDoctor.setSignType("2");//家庭签约
                        wlyyDoctorTeamDoctor.setCode(getCode());
                        wlyyDoctorTeamDoctor.setCzrq(new Date());
                        teamMemberDao.save(wlyyDoctorTeamDoctor);
                    }
                    if (StringUtils.isNotEmpty(sign.getDoctorHealth())) {
                        //添加健康管理师
                        DoctorTeamMember wlyyDoctorTeamDoctor = new DoctorTeamMember();
                        wlyyDoctorTeamDoctor.setTeam(doctorTeamCode);
                        wlyyDoctorTeamDoctor.setMemberCode(sign.getDoctorHealth());
                        wlyyDoctorTeamDoctor.setName(sign.getDoctorHealthName());
                        wlyyDoctorTeamDoctor.setDel("1");
                        wlyyDoctorTeamDoctor.setType(3);
                        wlyyDoctorTeamDoctor.setSignType("2");//家庭签约
                        wlyyDoctorTeamDoctor.setCode(getCode());
                        wlyyDoctorTeamDoctor.setCzrq(new Date());
                        teamMemberDao.save(wlyyDoctorTeamDoctor);
                    }
                    //添加患者和团队的关系
                    DoctorTeamMember wlyyDoctorTeamPatient = new DoctorTeamMember();
                    wlyyDoctorTeamPatient.setTeam(doctorTeamCode);
                    wlyyDoctorTeamPatient.setMemberCode(sign.getPatient());
                    wlyyDoctorTeamPatient.setName(sign.getName());
                    wlyyDoctorTeamPatient.setDel("1");
                    wlyyDoctorTeamPatient.setSignType("2");//家庭签约
                    wlyyDoctorTeamPatient.setType(5);
                    wlyyDoctorTeamPatient.setCode(getCode());
                    wlyyDoctorTeamPatient.setCzrq(new Date());
                    teamMemberDao.save(wlyyDoctorTeamPatient);
                    if (StringUtils.isEmpty(sign.getIdcard())) {
                        System.out.println("error:sign-family-set-group:no-idcard:" + sign.getId());
                        continue;
                    }
                    int age = IdCardUtil.getAgeForIdcard(sign.getIdcard());
                    String groupCode = "1";
                    if (age >= 65) {
                        groupCode = "3";
                    }
                    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");//家庭签约
                        groupInfoDao.save(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");//家庭签约
                        groupInfoDao.save(doctorPatientGroupInfo);
                    }
                    List<DoctorPatientGroupInfo> groups = groupInfoDao.findPatientGroups(sign.getPatient());
                    if (groups != null && groups.size() > 0) {
                        for (DoctorPatientGroupInfo group : groups) {
                            if (StringUtils.isNotEmpty(group.getSignType()) && group.getSignType().equals("2")) {
                                continue;
                            }
                            DoctorPatientGroupInfo patientGroup = new DoctorPatientGroupInfo();
                            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");//家庭签约
                            groupInfoDao.save(patientGroup);
                        }
                    }
                    sign.setTeamCode(doctorTeamCode);
                    signFamilyDao.save(sign);
                }
                //事物提交
                transactionManager.commit(status);
            } catch (Exception e) {
                transactionManager.rollback(status);
            }
        }
    }
}

+ 19 - 0
src/main/java/com/yihu/wlyy/web/common/util/ManagerUtilController.java

@ -5,6 +5,7 @@ import com.yihu.wlyy.job.consult.FamousConsultTimesJob;
import com.yihu.wlyy.service.app.disease.PatientDiseaseService;
import com.yihu.wlyy.service.app.scheduling.DoctorWorkTimeService;
import com.yihu.wlyy.service.app.statistics.StatisticsService;
import com.yihu.wlyy.service.common.util.ManageUtilService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
@ -37,6 +38,8 @@ public class ManagerUtilController extends BaseController {
    DoctorWorkTimeService workTimeService;
    @Autowired
    StatisticsService statisticsService;
    @Autowired
    ManageUtilService manageUtilService;
    /*********************************************患者疾病相关******************************************/
    /**
@ -139,4 +142,20 @@ public class ManagerUtilController extends BaseController {
            return error(-1, "更新失败");
        }
    }
    /**
     * 签约同步数据设置团队和分组
     *
     * @return
     */
    @RequestMapping(value = "/sign_set_group_team")
    public String signSetGroupAndTeam(){
        try {
            manageUtilService.signPatientSetGroup();
            return write(200, "更新成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "更新失败");
        }
    }
}

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

@ -48,7 +48,7 @@ public class SignPatientLabelInfoController extends BaseController {
            }
            page = page - 1;
            JSONArray result = labelInfoService.getPatientByLabel("fa4dd8565f0f11e68344fa163e8aee56", labelCode, labelType, teamCode, page, pagesize);
            JSONArray result = labelInfoService.getPatientByLabel(getUID(), labelCode, labelType, teamCode, page, pagesize);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
@ -74,7 +74,7 @@ public class SignPatientLabelInfoController extends BaseController {
                teamCode = 0L;
            }
            JSONArray result = labelInfoService.getPatientAmountByLabelType("fa4dd8565f0f11e68344fa163e8aee56", labelType, teamCode);
            JSONArray result = labelInfoService.getPatientAmountByLabelType(getUID(), labelType, teamCode);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
@ -163,7 +163,7 @@ public class SignPatientLabelInfoController extends BaseController {
                return error(-1, "标签参数不为空时标签类型不能为空");
            }
            JSONArray result = labelInfoService.searchPatientByNameOrLabel("fa4dd8565f0f11e68344fa163e8aee56", filter, labelCode, labelType);
            JSONArray result = labelInfoService.searchPatientByNameOrLabel(getUID(), filter, labelCode, labelType);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {