Bladeren bron

代码修改

yeshijie 8 jaren geleden
bovenliggende
commit
b584319bf0
1 gewijzigde bestanden met toevoegingen van 110 en 0 verwijderingen
  1. 110 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java

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

@ -1,5 +1,6 @@
package com.yihu.wlyy.service.app.sign;
import com.yihu.wlyy.entity.consult.Consult;
import com.yihu.wlyy.entity.dict.SystemDict;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
@ -7,6 +8,7 @@ import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeam;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeamMember;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.patient.*;
import com.yihu.wlyy.repository.consult.ConsultDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.DoctorTeamDao;
import com.yihu.wlyy.repository.doctor.DoctorTeamMemberDao;
@ -82,6 +84,8 @@ public class SignWebService extends BaseService {
    private DoctorTeamMemberDao doctorTeamMemberDao;
    @Autowired
    private WeiXinAccessTokenUtils weiXinAccessTokenUtils;
    @Autowired
    private ConsultDao consultDao;
    /**
     * 根据医生代码及签约状态编码 获取该医生签约患者的信息列表
@ -530,6 +534,112 @@ public class SignWebService extends BaseService {
        return jsonArray;
    }
    /**
     * 进行中的咨询获取服务团队信息
     * @param teamCode
     * @param code
     * @return
     */
    public JSONObject getConsultSignInfoOrRenewInfo(String teamCode, String code,String patient,String consultCode) {
        //签约或续签参数
        String patientCode = null;
        Long adminTeamId = null;
        String doctorHealth = null;
        String doctor = null;
        //先查找续签表有没有记录
        List<SignFamilyRenew> renews = signFamilyRenewDao.findByTeamCodeIsValid(teamCode, code);
        if (renews == null || renews.size() == 0) {
            //再查找签约表记录
            List<SignFamily> signFamilys = signFamilyDao.findByTeamCodeIsValid(teamCode, code);
            SignFamily signFamily = null;
            if (signFamilys == null || signFamilys.size() == 0) {
                signFamily = signFamilyDao.findByTeam(teamCode);
                if(signFamily==null){
                    signFamily = signFamilyDao.findOutTimeSigningByPatientAndTeamCode(patient,teamCode);
                    if(signFamily==null){
                        throw new RuntimeException("找不到签约关系!");
                    }
                }else {
                    Consult consult = consultDao.findByCode(consultCode);
                    if(signFamily.getApplyDate().getTime()-consult.getCzrq().getTime()<0){// 判断咨询是否在签约之后
                        signFamily = signFamilyDao.findOutTimeSigningByPatientAndTeamCode(patient,teamCode);
                        if(signFamily==null){
                            throw new RuntimeException("找不到签约关系!");
                        }
                    }
                }
            } else {
                signFamily = signFamilys.get(0);
            }
            patientCode = signFamily.getPatient();
            adminTeamId = signFamily.getAdminTeamId();
            doctorHealth = signFamily.getDoctorHealth();
            doctor = signFamily.getDoctor();
        } else {
            SignFamilyRenew renew = renews.get(0);
            patientCode = renew.getPatient();
            adminTeamId = renew.getAdminTeamId();
            doctorHealth = renew.getDoctorHealth();
            doctor = renew.getDoctor();
        }
        Patient p = patientService.findByCode(patientCode);
        JSONObject resultObject = new JSONObject();
        AdminTeam adminTeam = adminTeamService.getTeam(adminTeamId);
        //查找到团队领导
        Doctor leader = doctorService.findDoctorByCode(adminTeam.getLeaderCode());
        JSONObject leaderObj = this.doctorParse(leader);
        resultObject.put("leader", leaderObj);
        //签约团队的健管师
        if (StringUtils.isNotBlank(doctorHealth)) {
            Doctor health = doctorService.findDoctorByCode(doctorHealth);
            if (health != null) {
                JSONObject healthObj = this.doctorParse(health);
                resultObject.put("doctorHealth", healthObj);
            } else {
                resultObject.put("doctorHealth", "");
            }
        }
        //签约团队的全科医生
        if (StringUtils.isNotBlank(doctor)) {
            Doctor qk = doctorService.findDoctorByCode(doctor);
            if (qk != null) {
                JSONObject healthObj = this.doctorParse(qk);
                resultObject.put("doctor", healthObj);
            } else {
                resultObject.put("doctor", "");
            }
        }
        Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT+08:00"));
        int year = calendar.get(Calendar.YEAR);
        //统计当年咨询数量
        String consult_sql = "select count(1) as count from wlyy_consult_team  w where w.doctor = ? and w.patient =? and YEAR(w.czrq) = ? ";
        //统计随访数量
        String followup_sql = "select count(1) as count from wlyy_followup  w where (w.doctor_code = ? or w.doctor_code =?) and w.patient_code =? and YEAR(w.create_time) = ?  and w.followup_class is not null ";
        //统计待预约数量
        String reservation_sql = "select count(1) as count from wlyy_patient_reservation  w where (w.doctor = ? or w.doctor =?) and w.patient =? and YEAR(w.czrq) = ? ";
        //统计健康教育数量
        String article_sql = "select count(1) as count from wlyy_health_edu_article_patient  w where (w.doctor = ? or w.doctor =?) and w.patient =? and YEAR(w.czrq) = ? ";
        //统计健康指导数量
        String guidance_sql = "select count(1) as count from wlyy_patient_health_guidance  w where (w.doctor = ? or w.doctor =?) and w.patient =? and YEAR(w.czrq) = ? ";
        StringBuffer countSql = new StringBuffer();
        countSql.append(consult_sql).append(" union all ").append(followup_sql).append(" union all ").append(reservation_sql).append(" union all ").append(article_sql).append(" union all ").append(guidance_sql);
        List<Map<String, Object>> resultCount = jdbcTemplate.queryForList(countSql.toString(), new Object[]{doctorHealth, patient, year, doctorHealth, doctor, patient, year, doctorHealth, doctor, patient, year, doctorHealth, doctor, patient, year, doctorHealth, doctor, patient, year});
        resultObject.put("consultNum", resultCount.get(0).get("count"));
        resultObject.put("followupNum", resultCount.get(1).get("count"));
        resultObject.put("reservationNum", resultCount.get(2).get("count"));
        resultObject.put("articleNum", resultCount.get(3).get("count"));
        resultObject.put("guidanceNum", resultCount.get(4).get("count"));
        return resultObject;
    }
    /**
     * 已过时,启用getSignInfoOrRenewInfo
     *