浏览代码

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

trick9191 8 年之前
父节点
当前提交
48b3aedadf

+ 4 - 4
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/consult/ConsultDao.java

@ -13,19 +13,19 @@ public interface ConsultDao extends PagingAndSortingRepository<Consult, Long>, J
    Consult findByCode(String code);
    // 查询患者咨询记录
    @Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.team,b.evaluate from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.del = '1' and a.symptoms like ?2 order by a.czrq desc")
    @Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.team,b.evaluate,a.signCode  from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.del = '1' and a.symptoms like ?2 order by a.czrq desc")
    Page<Object> findByPatient(String patient, String title, Pageable pageRequest);
    // 查询患者咨询记录
    @Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.team,b.evaluate from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.id < ?3 and a.del = '1'and a.symptoms like ?2 order by a.czrq desc")
    @Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.team,b.evaluate,a.signCode from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.id < ?3 and a.del = '1'and a.symptoms like ?2 order by a.czrq desc")
    Page<Object> findByPatient(String patient, String title, long id, Pageable pageRequest);
    // 查询患者咨询记录
    @Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.team,b.evaluate from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.del = '1' order by a.czrq desc")
    @Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.team,b.evaluate,a.signCode  from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.del = '1' order by a.czrq desc")
    Page<Object> findByPatient(String patient, Pageable pageRequest);
    // 查询患者咨询记录
    @Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.team,b.evaluate from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.id < ?2 and a.del = '1'order by a.czrq desc")
    @Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.team,b.evaluate,a.signCode  from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.id < ?2 and a.del = '1'order by a.czrq desc")
    Page<Object> findByPatient(String patient, long id, Pageable pageRequest);
    @Query("select count(a) from Consult a,ConsultTeamDoctor b  where a.code = b.consult and a.patient=?1 and b.to=?2 and b.from is null")

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

@ -305,6 +305,9 @@ public interface SignFamilyDao extends PagingAndSortingRepository<SignFamily, Lo
    @Query("select a from SignFamily a where a.patient = ?1 and a.type =2 and a.status >= 0")
    SignFamily findByPatient(String patient);
    @Query("select a from SignFamily a where a.teamCode = ?1 and a.type =2 and a.status >= 0")
    SignFamily findByTeam(String teamCode);
    @Query("select a from SignFamily a where a.patient = ?1 and a.type =2 and a.status >= 0")
    List<SignFamily> findByPatients(String patient);
@ -395,4 +398,7 @@ public interface SignFamilyDao extends PagingAndSortingRepository<SignFamily, Lo
    @Query(value = " select a.*  from wlyy_sign_family a where a.patient = ?1  and a.status = -4 order by a.apply_date desc limit 0,1", nativeQuery = true)
    SignFamily findOutTimeSigningByPatient(String patient);
    @Query(value = " select a.*  from wlyy_sign_family a where a.patient = ?1  and a.status = -4 and a.team_code = ?2 order by a.apply_date desc limit 0,1", nativeQuery = true)
    SignFamily findOutTimeSigningByPatientAndTeamCode(String patient,String teamCode);
}

+ 1 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/DoctorInfoService.java

@ -843,6 +843,7 @@ public class DoctorInfoService extends BaseService {
        JSONObject data = new JSONObject();
        if (StringUtils.isNotEmpty(oldDoctorCode)) {
            data.put("toUser", patient);
            data.put("represented",patient);//被代理人
            data.put("doctor", newD.getCode());
            data.put("doctorName", newD.getName());
            data.put("first", p.getName() + ",您好!因签约团队内分工调整,您的责任医生有变动," + oldDoctorHealthName +

+ 12 - 16
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultService.java

@ -1,12 +1,14 @@
package com.yihu.wlyy.service.app.consult;
import java.util.Date;
import java.util.List;
import com.yihu.wlyy.entity.consult.Consult;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.consult.*;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.util.SendPatientUtil;
import org.springframework.beans.factory.annotation.Autowired;
@ -14,22 +16,13 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import com.yihu.wlyy.entity.consult.Consult;
import com.yihu.wlyy.repository.consult.ConsultCommunicationDao;
import com.yihu.wlyy.repository.consult.ConsultCommunicationReplyDao;
import com.yihu.wlyy.repository.consult.ConsultDao;
import com.yihu.wlyy.repository.consult.ConsultMoViDao;
import com.yihu.wlyy.repository.consult.ConsultPublicDao;
import com.yihu.wlyy.repository.consult.ConsultPublicReplyDao;
import com.yihu.wlyy.repository.consult.ConsultTeamDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.service.BaseService;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.util.Date;
import java.util.List;
@Component
@Transactional
public class ConsultService extends BaseService {
@ -76,7 +69,10 @@ public class ConsultService extends BaseService {
		consult.setSymptoms(symptoms);
		consult.setImages(images);
		consult.setType(type);
		consult.setSignCode(patientService.getSignCodeByPatient(patient));
		SignFamily signFamily = signFamilyDao.findByPatient(patient);
		if(signFamily!=null){
			consult.setSignCode(signFamily.getCode());
		}
		return consultDao.save(consult);
	}

+ 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;
    /**
     * 根据医生代码及签约状态编码 获取该医生签约患者的信息列表
@ -534,6 +538,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
     *

+ 3 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/consult/ConsultController.java

@ -103,6 +103,9 @@ public class ConsultController extends WeixinBaseController {
                    json.put("evaluate", result[9]);
                    //签约code
                    json.put("signCode", result[10]);
                    array.put(json);
                }
            }

+ 16 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/sign/PatientSignController.java

@ -4,6 +4,7 @@ import com.yihu.wlyy.entity.patient.SignWeb;
import com.yihu.wlyy.service.app.sign.SignWebService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
@ -261,6 +262,21 @@ public class PatientSignController extends BaseController {
		}
	}
	@RequestMapping(value = "/consult_sign_doctor_info")
	@ResponseBody
	@ApiOperation(value = "获取咨询的服务团队")
	public String consult_sign_doctor(@RequestParam(required = true,value = "team")String teamCode,
									  @RequestParam(required = true)String code,@RequestParam(required = true)String consultCode){
		try{
			JSONObject resultObj =  signWebService.getConsultSignInfoOrRenewInfo(teamCode,code,getRepUID(),consultCode);
			return write(200, "查询成功!", "data", resultObj);
		}catch (Exception e){
			error(e);
			return error(-1, "签约状态查询失败!");
		}
	}
	@RequestMapping("/sign_service_info")
	public String getSignServiceInfo(@RequestParam(required = true,value = "team")String teamCode) {
		try {