Parcourir la source

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

chenweida il y a 8 ans
Parent
commit
750ec9a6c0

+ 1 - 1
src/main/java/com/yihu/wlyy/entity/doctor/team/sign/DoctorPatientGroupInfo.java

@ -37,7 +37,7 @@ public class DoctorPatientGroupInfo extends IdEntity {
	private Date czrq;
	// 状态,1正常,0作废
	private Integer status;
	//签约类型(1表示三师签约,2表示家庭签约,3表示三师和家庭签约都存在)
	//签约类型(1表示三师签约,2表示家庭签约)
	private String signType;
	@Column(name = "sign_type")

+ 2 - 0
src/main/java/com/yihu/wlyy/repository/consult/ConsultTeamDao.java

@ -170,4 +170,6 @@ public interface ConsultTeamDao extends PagingAndSortingRepository<ConsultTeam,
	//名医咨询 -根据status 带symptoms
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and a.type=6 and b.to = ?1 and a.symptoms like ?2 and a.status = ?3 and a.del = '1' and b.del = '1'")
	Page<ConsultTeam> findFamousDoctorDoingList(String uid,String title,Integer type, Pageable pageRequest);
	@Query("select a from ConsultTeam a where  a.type=?3  and a.del = '1' and a.patient=?1 and a.doctor=?2 and  a.status=0 ")
	ConsultTeam findByParientCodeAndSignTypeAndDoctor(String patientCode, String doctor, String s);
}

+ 3 - 0
src/main/java/com/yihu/wlyy/repository/doctor/DoctorPatientGroupInfoDao.java

@ -95,4 +95,7 @@ public interface DoctorPatientGroupInfoDao extends PagingAndSortingRepository<Do
	@Modifying
	@Query("update DoctorPatientGroupInfo set status = ?4 where doctor = ?1 and patient = ?2 and group = ?3 and status = 1")
	int updateDoctorPatientGroup(String doctor,String patient,String group,int status);
	@Query("select a from DoctorPatientGroupInfo a where  a.status = 1 and a.doctor = ?2 and a.patient = ?1 and a.signType =2")
	List<DoctorPatientGroupInfo> findByPatientAndDoctor(String patient, String oldDoctorCode);
}

+ 4 - 0
src/main/java/com/yihu/wlyy/repository/doctor/DoctorTeamMemberDao.java

@ -43,4 +43,8 @@ public interface DoctorTeamMemberDao extends PagingAndSortingRepository<DoctorTe
    DoctorTeamMember findSanshiByTeamAndType(String teamCode, int i);
    List<DoctorTeamMember> findByTeamAndDel(String team, String del);
    @Query(" FROM DoctorTeamMember a WHERE a.team =?1 and  a.del='1' and  a.signType='2' and  a.memberCode=?2 ")
    DoctorTeamMember findMemberByTeamAndCode(String teamCode, String oldDoctorCode);
}

+ 64 - 0
src/main/java/com/yihu/wlyy/service/app/account/DoctorInfoService.java

@ -6,6 +6,7 @@ import com.yihu.wlyy.entity.address.City;
import com.yihu.wlyy.entity.address.Province;
import com.yihu.wlyy.entity.address.Town;
import com.yihu.wlyy.entity.consult.Consult;
import com.yihu.wlyy.entity.consult.ConsultTeam;
import com.yihu.wlyy.entity.consult.ConsultTeamDoctor;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorPatientGroup;
@ -13,11 +14,13 @@ 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.DoctorTeamMember;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.patient.WlyyPatientSick;
import com.yihu.wlyy.repository.address.CityDao;
import com.yihu.wlyy.repository.address.ProvinceDao;
import com.yihu.wlyy.repository.address.TownDao;
import com.yihu.wlyy.repository.consult.ConsultDao;
import com.yihu.wlyy.repository.consult.ConsultTeamDao;
import com.yihu.wlyy.repository.consult.ConsultTeamDoctorDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.DoctorPatientGroupInfoDao;
@ -81,6 +84,8 @@ public class DoctorInfoService extends BaseService {
    @Autowired
    private SignFamilyDao signFamilyDao;
    private ConsultTeamDao consultTeamDao;
    /**
     * 获取医生的签约病人
     *
@ -625,4 +630,63 @@ public class DoctorInfoService extends BaseService {
        return doctorDao.findAll(spec, pageRequest);
    }
    public void updateTeamHealthDoctor(String newDoctorCode, String oldDoctorCode, String patient)throws Exception {
        ConsultTeam consultTeam= consultTeamDao.findByParientCodeAndSignTypeAndDoctor(patient,oldDoctorCode,"2");
        if(consultTeam!=null){
            throw new Exception("存在没有关闭的健康咨询");
        }
        Patient patientObj=patientDao.findByCode(patient);
        Doctor newD=doctorDao.findByCode(newDoctorCode);
        //得到患者的签约信息
        SignFamily signFamily= signFamilyDao.findByPatient(patient);
        //修改签约中的健康管理师
        signFamily.setDoctorHealth(newD.getCode());
        signFamily.setDoctorHealthName(newD.getName());
        //修改医生服务团队 删除旧的健康管理师
        DoctorTeamMember doctorTeamMember=  doctorTeamDoctor.findMemberByTeamAndCode(signFamily.getTeamCode(),oldDoctorCode);
        doctorTeamMember.setDel("0");
        //添加新的健康管理师到服务团队里
        DoctorTeamMember  newDoctorTeamMember=new DoctorTeamMember();
        newDoctorTeamMember.setTeam(signFamily.getTeamCode());
        newDoctorTeamMember.setCzrq(new Date());
        newDoctorTeamMember.setName(newD.getName());
        newDoctorTeamMember.setMemberCode(newD.getCode());
        newDoctorTeamMember.setType(3);
        newDoctorTeamMember.setSignType("2");
        newDoctorTeamMember.setDel("1");
        newDoctorTeamMember.setCode(UUID.randomUUID().toString().replace("-",""));
        doctorTeamDoctor.save(newDoctorTeamMember);
        String groupCode="";
        //把患者移除旧的健康管理师的患者表
        List<DoctorPatientGroupInfo>  oldDoctorPatientGroupInfos=doctorPatientGroupInfoDao.findByPatientAndDoctor(patient,oldDoctorCode);
        for(DoctorPatientGroupInfo doctorPatientGroupInfo:oldDoctorPatientGroupInfos){
            doctorPatientGroupInfo.setCzrq(new Date());
            doctorPatientGroupInfo.setStatus(0);//设置为无效
            //保存原来旧的分组
            if(Integer.valueOf(doctorPatientGroupInfo.getGroup())<4){
                groupCode=doctorPatientGroupInfo.getGroup()+"";
            }
        }
        //把患者加到新的健康管理师的患者表
        DoctorPatientGroupInfo doctorPatientGroupInfo = new DoctorPatientGroupInfo();
        doctorPatientGroupInfo.setCzrq(new Date());
        doctorPatientGroupInfo.setDoctor(newDoctorCode);
        doctorPatientGroupInfo.setStatus(1);
        doctorPatientGroupInfo.setPatient(patientObj.getCode());
        doctorPatientGroupInfo.setPname(patientObj.getName());
        doctorPatientGroupInfo.setPartAmount(0);
        doctorPatientGroupInfo.setGroup(groupCode);//默认健康分组
        doctorPatientGroupInfo.setQyrq(new Date());
        doctorPatientGroupInfo.setSignType("2");//家庭签约
        doctorPatientGroupInfoDao.save(doctorPatientGroupInfo);
    }
    public void updateTeamHealthDoctors(String newDoctorCode, String oldDoctorCode, String patients)throws Exception {
        String [] patiensString=patients.split(",");
        for (int i=0;i<patiensString.length;i++){
            updateTeamHealthDoctor(newDoctorCode,oldDoctorCode,patiensString[i]);
        }
    }
}

+ 10 - 0
src/main/java/com/yihu/wlyy/service/app/consult/ConsultTeamService.java

@ -756,4 +756,14 @@ public class ConsultTeamService extends ConsultService {
		// 添加医生咨询日志
		addLogs(ct);
	}
	/**
	 * 根据健康管理师和患者 找到正在进行中的咨询
	 * @param patientCode
	 * @param doctor
     */
	public ConsultTeam getConsultByPatientAndDoctor(String patientCode, String doctor) {
		ConsultTeam consultTeam= consultTeamDao.findByParientCodeAndSignTypeAndDoctor(patientCode,doctor,"2");
		return consultTeam;
	}
}

+ 21 - 1
src/main/java/com/yihu/wlyy/web/doctor/account/DoctorController.java

@ -3,6 +3,7 @@ package com.yihu.wlyy.web.doctor.account;
import java.util.List;
import java.util.Map;
import com.yihu.wlyy.entity.consult.ConsultTeam;
import com.yihu.wlyy.entity.organization.Hospital;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.profile.DoctorComment;
@ -1407,7 +1408,26 @@ public class DoctorController extends BaseController {
    @ResponseBody
    public String setFamous(String doctorCode, Integer status) {
        try {
            doctorInfoService.setFamous(doctorCode,status);
           doctorInfoService.setFamous(doctorCode,status);
            return write(200, "更新成功");
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "更新失败");
        }
    }
    /**
     * 转换团队中的健康管理师
     * @param  newDoctorCode 新的健康管理师的code
     * @param oldDoctorCode 旧的健康管理师的code
     * @param patients 患者code 多个逗号分隔
     * @return
     */
    @RequestMapping(value = "/updateTeamHealthDoctors")
    @ResponseBody
    public String updateTeamHealthDoctors(String newDoctorCode,String oldDoctorCode,String patients) {
        try {
            doctorInfoService.updateTeamHealthDoctors(newDoctorCode,oldDoctorCode,patients);
            return write(200, "更新成功");
        } catch (Exception e) {
            e.printStackTrace();

+ 24 - 0
src/main/java/com/yihu/wlyy/web/doctor/consult/DoctorConsultController.java

@ -374,4 +374,28 @@ public class DoctorConsultController extends WeixinBaseController {
		}
	}
	/**
	 * 根据医生code和和患者code判断是否有存在进行中的咨询
	 * @param patientCode
	 * @param doctor
	 * @return
     */
	@RequestMapping(value = "getConsultByPatientAndDoctor")
	@ResponseBody
	public String getConsultByPatientAndDoctor(String patientCode,String doctor) {
		try {
			JSONObject json = new JSONObject();
			ConsultTeam consultTeam= consultTeamService.getConsultByPatientAndDoctor(patientCode,doctor);
			if(consultTeam==null){
				json.put("hasConsult","0");
			}else{
				json.put("hasConsult","1");
			}
			return json.toString();
		} catch (Exception e) {
			error(e);
			return error(-1, "回复失败!");
		}
	}
}