Pārlūkot izejas kodu

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

trick9191 8 gadi atpakaļ
vecāks
revīzija
2f50f76017

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

@ -76,6 +76,12 @@ public interface SignFamilyDao extends PagingAndSortingRepository<SignFamily, Lo
    @Query(value = "select a from SignFamily a where a.doctorHealth =?1 and a.patient = ?2 and a.status =0 and a.signYear =?3")
    List<SignFamily> findByDoctorHealthAndPatient(String doctorHealth,String patient,String signYear);
    @Query(value = "select a from SignFamily a where a.doctor =?1 and a.patient = ?2 and a.signYear =?3 and a.status = 1 and a.expensesStatus ='1'")
    List<SignFamily> findByDoctorAndPatientIsValid(String doctor,String patient,String signYear);
    @Query(value = "select a from SignFamily a where a.doctorHealth =?1 and a.patient = ?2 and a.signYear =?3 and a.status = 1 and a.expensesStatus ='1'")
    List<SignFamily> findByDoctorHealthAndPatientIsValid(String doctorHealth,String patient,String signYear);
    @Query("select a from SignFamily a where a.doctor = ?1 and a.patient = ?2 and a.status = 1 and a.type = 2")
    SignFamily findByFamilyDoctorAndPatient(String doctor, String patient);

+ 6 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/SignFamilyRenewDao.java

@ -30,6 +30,12 @@ public interface SignFamilyRenewDao extends PagingAndSortingRepository<SignFamil
    @Query(value = "select a from SignFamilyRenew a where a.doctor =?1 and a.patient = ?2 and a.signYear =?3")
    List<SignFamilyRenew> findByDoctorAndPatient(String doctor,String patient,String signYear);
    @Query(value = "select a from SignFamilyRenew a where a.doctor =?1 and a.patient = ?2 and a.signYear =?3 and a.status = 1 and a.expensesStatus ='1'")
    List<SignFamilyRenew> findByDoctorAndPatientIsValid(String doctor,String patient,String signYear);
    @Query(value = "select a from SignFamilyRenew a where a.doctorHealth =?1 and a.patient = ?2 and a.signYear =?3 and a.status = 1 and a.expensesStatus ='1'")
    List<SignFamilyRenew> findByDoctorHealthAndPatientIsValid(String doctorHealth,String patient,String signYear);
    @Query(value = "select a from SignFamilyRenew a where a.doctorHealth =?1 and a.patient = ?2 and a.signYear =?3")
    List<SignFamilyRenew> findByDoctorHealthAndPatient(String doctorHealth,String patient,String signYear);

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

@ -1102,34 +1102,36 @@ public class FamilyContractService extends BaseService {
        }
        String doctorTeamCode = null;//服务团队的CODE;
        if (type == 1) {
            //2017-5-27 屏蔽三师签约判断
            //判断是否有三师签约 并且判断全科医生一致
            SignFamily sssignFamily = signFamilyDao.findSSByIdcard(p.getIdcard());
            if (sssignFamily != null) {
                if (StringUtils.isNotEmpty(doctor)) {
                    if (!doctor.equals(sssignFamily.getDoctor())) {
                        result.put("status", -2);
                        result.put("msg", "居民已签约三师,故全科医生只可为" + sssignFamily.getDoctorName() + "医生,请重新选择全科医生");
                        return result;
                    }
                    List<AdminTeam> teams = adminTeamService.findDoctorsTeams(sf.getDoctorHealth(), sssignFamily.getDoctor());
                    if (teams == null || teams.size() < 1) {
                        result.put("status", -4);
                        result.put("msg", "居民已签约三师,三师签约的全科医生" + sssignFamily.getDoctorName() + "与该签约申请的健管师" + sf.getDoctorHealthName() + "不在同一个团队,该签约申请已失效");
                        messageService.readHealth(msgid);
                        updateSignStatus(p.getIdcard());
                        return result;
                    }
                }
                if (StringUtils.isNotEmpty(healthDoctor) && !sf.getDoctor().equals(sssignFamily.getDoctor())) {
                    result.put("status", -3);
                    result.put("msg", "对不起,居民已签约三师,故只可与" + sssignFamily.getDoctorName() + "医生签约,该签约申请已失效");
                    messageService.readHealth(msgid);
                    updateSignStatus(p.getIdcard());
                    return result;
                }
            }
//            SignFamily sssignFamily = signFamilyDao.findSSByIdcard(p.getIdcard());
//
//            if (sssignFamily != null) {
//                if (StringUtils.isNotEmpty(doctor)) {
//                    if (!doctor.equals(sssignFamily.getDoctor())) {
//                        result.put("status", -2);
//                        result.put("msg", "居民已签约三师,故全科医生只可为" + sssignFamily.getDoctorName() + "医生,请重新选择全科医生");
//                        return result;
//                    }
//                    List<AdminTeam> teams = adminTeamService.findDoctorsTeams(sf.getDoctorHealth(), sssignFamily.getDoctor());
//
//                    if (teams == null || teams.size() < 1) {
//                        result.put("status", -4);
//                        result.put("msg", "居民已签约三师,三师签约的全科医生" + sssignFamily.getDoctorName() + "与该签约申请的健管师" + sf.getDoctorHealthName() + "不在同一个团队,该签约申请已失效");
//                        messageService.readHealth(msgid);
//                        updateSignStatus(p.getIdcard());
//                        return result;
//                    }
//                }
//                if (StringUtils.isNotEmpty(healthDoctor) && !sf.getDoctor().equals(sssignFamily.getDoctor())) {
//                    result.put("status", -3);
//                    result.put("msg", "对不起,居民已签约三师,故只可与" + sssignFamily.getDoctorName() + "医生签约,该签约申请已失效");
//                    messageService.readHealth(msgid);
//                    updateSignStatus(p.getIdcard());
//                    return result;
//                }
//            }
            //List<SystemDict> systemDicts = systemDictDao.findByDictName("SIGN_YEAR");
            Calendar cal = Calendar.getInstance();
@ -1175,7 +1177,7 @@ public class FamilyContractService extends BaseService {
            sf.setBegin(begin.getTime());
            sf.setEnd(end.getTime());
            //签约类型:1三师签约,2家庭签约
            // 改为签约生效
            sf.setStatus(1);
            sf.setSignType("1");//患者发起签约
@ -1209,7 +1211,7 @@ public class FamilyContractService extends BaseService {
            //建立团队
            DoctorTeam doctorTeam = new DoctorTeam();
            doctorTeamCode = getCode();
            doctorTeam.setName("三师签约团队患者:" + p.getName());
            doctorTeam.setName("签约团队患者:" + p.getName());
            doctorTeam.setCode(doctorTeamCode);
            doctorTeam.setCzrq(new Date());
            doctorTeam.setSignType("2");

+ 22 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java

@ -1231,4 +1231,26 @@ public class SignWebService extends BaseService {
        String dateKey = DateUtil.dateToStr(new Date(),"yyyyMMdd");
        redisTemplate.opsForValue().set("renew:"+dateKey+":"+patient,"1");
    }
    //判断用户当前年度是否有已经付费的签约记录
    public int checkNowYearSign(String doctor,String patient){
        List<SignFamilyRenew> renews1 = signFamilyRenewDao.findByDoctorAndPatientIsValid(doctor,patient,DateUtil.getNowYear()+"");
        if(renews1!=null&&renews1.size()>0){
            return 0;
        }
        List<SignFamilyRenew> renews2 = signFamilyRenewDao.findByDoctorHealthAndPatientIsValid(doctor,patient,DateUtil.getNowYear()+"");
        if(renews2!=null&&renews2.size()>0){
            return 0;
        }
        List<SignFamily> sign1 = signFamilyDao.findByDoctorAndPatientIsValid(doctor,patient,DateUtil.getNowYear()+"");
        if(sign1!=null&&sign1.size()>0){
            return 0;
        }
        List<SignFamily> sign2 = signFamilyDao.findByDoctorHealthAndPatientIsValid(doctor,patient,DateUtil.getNowYear()+"");
        if(sign2!=null&&sign2.size()>0){
            return 0;
        }
        return 1;
    }
}

+ 21 - 7
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/PatientService.java

@ -383,11 +383,11 @@ public class PatientService extends TokenService {
        //判断是否有生效记录SQL
        String sql = "SELECT t.id,t.sign_year signYear FROM wlyy_sign_family t WHERE t.patient ='" + patient + "' AND t.status>=0 AND t.expenses_status='1'";
        //用于判断续签表是否有记录QL,有记录则不允许续签
        String sqlRenew = "SELECT t.id,t.sign_year signYear FROM wlyy_sign_family_renew t WHERE t.patient ='" + patient + "' AND t.status>=0 ";
        String sqlRenew = "SELECT t.id,t.sign_year signYear,t.status FROM wlyy_sign_family_renew t WHERE t.patient ='" + patient + "' AND t.status>=0 ";
        //判读是否有当前年度的记录SQL
        String signSql = "SELECT t.id,t.sign_year signYear FROM wlyy_sign_family t WHERE t.patient ='" + patient + "' AND t.status>=0  AND t.sign_year ='" + year + "'";
        String signSql = "SELECT t.id,t.sign_year signYear ,t.status  FROM wlyy_sign_family t WHERE t.patient ='" + patient + "' AND t.status>=0  AND t.sign_year ='" + year + "'";
        //判读是否有旧的已到期记录SQL
        String oldSignSql = "SELECT t.id,t.sign_year signYear FROM wlyy_sign_family t WHERE t.patient ='" + patient + "' AND t.status=-4 AND  t.expenses_status='1' AND t.sign_year ='" + (year - 1) + "'";
        String oldSignSql = "SELECT t.id,t.sign_year signYear,t.status FROM wlyy_sign_family t WHERE t.patient ='" + patient + "' AND t.status=-4 AND  t.expenses_status='1' AND t.sign_year ='" + (year - 1) + "'";
        //判断时间是否在6月30之前
        if (month < 7) {
            //判断是否有签约记录
@ -421,8 +421,15 @@ public class PatientService extends TokenService {
            //如果在签约七月份之后判断是否已经生效,判断是否有旧数据
            List<Map<String,Object>> signFamilys1 = jdbcTemplate.queryForList(signSql);
            if (signFamilys1 != null && signFamilys1.size() > 0) {
                rs.put("mes", "当前年度已经签约");
                rs.put("code", "-2");
                Map<String,Object> map = signFamilys1.get(0);
                int state = (int)map.get("status");
                if(state==1){
                    rs.put("mes", "医生已经同意续签");
                    rs.put("code", "-5");
                }else {
                    rs.put("mes", "当前年度已经签约");
                    rs.put("code", "-2");
                }
                return rs;
            }
            List<Map<String,Object>> signFamilys2 = jdbcTemplate.queryForList(oldSignSql);
@ -442,8 +449,15 @@ public class PatientService extends TokenService {
        List<Map<String,Object>> renews = jdbcTemplate.queryForList(sqlRenew);
        //如果续签表没有数据,则可以续签,有数据提示已经续签
        if (renews != null && renews.size() > 0) {
            rs.put("mes", "已经提交续签");
            rs.put("code", "-3");
            Map<String,Object> remew = renews.get(0);
            int state = (int)remew.get("status");
            if(state==1){
                rs.put("mes", "医生已经同意续签");
                rs.put("code", "-5");
            }else{
                rs.put("mes", "已经提交续签");
                rs.put("code", "-3");
            }
            return rs;
        } else {
            rs.put("mes", "可以续签(未到期)");

+ 6 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorSignController.java

@ -447,6 +447,12 @@ public class DoctorSignController extends WeixinBaseController {
                             @RequestParam(required = true)String patient,
                             @RequestParam(required = false) Long mesId ){
        try{
            int isNowYearSign = signWebService.checkNowYearSign(getUID(),patient);
            if(isNowYearSign==0){
                return  write(200, "已经存在下个年度的签约关系", "data", -1);
            }
            Calendar cal = Calendar.getInstance();
            int year = cal.get(Calendar.YEAR);
            int month = cal.get(Calendar.MONTH)+1;