Browse Source

Merge branch 'dev' of http://192.168.1.220:10080/Amoy/patient-co-management into dev

chenweida 8 năm trước cách đây
mục cha
commit
45492513d6

+ 2 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/message/MessageDao.java

@ -38,10 +38,10 @@ public interface MessageDao extends PagingAndSortingRepository<Message, Long>, J
    List<Message> findUnreadSign(String sender, String receiver, String signStatus);
    @Query(" from Message a where a.read = 1 and over ='1' and a.sender = ?1 and a.receiver=?2 and a.signStatus='1'")
    Message findByPatient(String patient,String doctor);
    List<Message> findByPatient(String patient,String doctor);
    @Query(" from Message a where a.read = 1 and over ='1' and a.sender = ?1 and a.receiver=?2 ")
    Message findByPatientRenew(String patient,String doctor);
    List<Message> findByPatientRenew(String patient,String doctor);
    @Query("select a from Message a where a.receiver = ?1 and a.sender=?2 and a.tzType=?3 order by a.createTime desc")
    List<Message> getHealthIndexMessageByPatient(String doctor,String patient,String type,Pageable pageRequest);

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

@ -1,5 +1,6 @@
package com.yihu.wlyy.service.app.sign;
import com.yihu.wlyy.entity.consult.Consult;
import com.yihu.wlyy.entity.consult.ConsultTeam;
import com.yihu.wlyy.entity.doctor.OperatorLog;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
@ -13,6 +14,7 @@ import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.organization.Hospital;
import com.yihu.wlyy.entity.patient.*;
import com.yihu.wlyy.logs.BusinessLogs;
import com.yihu.wlyy.repository.consult.ConsultDao;
import com.yihu.wlyy.repository.consult.ConsultTeamDao;
import com.yihu.wlyy.repository.dict.SystemDictDao;
import com.yihu.wlyy.repository.doctor.*;
@ -117,7 +119,8 @@ public class FamilyContractService extends BaseService {
    private OperatorLogDao operatorLogDao;
    @Autowired
    private WeiXinOpenIdUtils weiXinOpenIdUtils;
    @Autowired
    private ConsultDao consultDao;
    @Autowired
    private SignFamilyRenewDao signFamilyRenewDao;
@ -648,7 +651,6 @@ public class FamilyContractService extends BaseService {
        } else if (doc.getLevel() == 3) {
            sf = signFamilyDao.findByDoctorHealthPatient(doctor, patient);
        }
        Message message = messageDao.findByPatient(patient, doctor);
        if (sf.getStatus() != 0 && sf.getStatus() != 2) {
            return -2;
        }
@ -657,10 +659,16 @@ public class FamilyContractService extends BaseService {
        } else {
            return -2;
        }
        //修改信息为无效
        if (message != null) {
            message.setRead(0);
            message.setOver("0");
        //结束与医生所有消息
        List<Message> messages = messageDao.findByPatient(patient, doctor);
        if(messages!=null&&messages.size()>0){
            for(Message message:messages){
                //修改信息为无效
                if (message != null) {
                    message.setRead(0);
                    message.setOver("0");
                }
            }
        }
        return 200;
    }
@ -688,12 +696,20 @@ public class FamilyContractService extends BaseService {
            sf.setStatus(-1);
        }
        Message message = messageDao.findByPatientRenew(patient, doctor);
        //修改信息为无效
        if (message != null) {
            message.setRead(0);
            message.setOver("0");
        //结束与医生所有消息
        List<Message> messages = messageDao.findByPatientRenew(patient, doctor);
        if(messages!=null&messages.size()>0){
            for(Message message:messages){
                //修改信息为无效
                if (message != null) {
                    message.setRead(0);
                    message.setOver("0");
                    messageDao.save(message);
                }
            }
        }
        return 200;
    }
@ -2602,7 +2618,8 @@ public class FamilyContractService extends BaseService {
        JSONObject result = new JSONObject();
        Map<String, JSONObject> docMap = new HashMap<>();
        SignFamily ssSign = signFamilyDao.findSignByPatient(patient, 1);
        SignFamily jtSign = signFamilyDao.findByTeamCode(infos[1]);
//        SignFamily jtSign = signFamilyDao.findByTeamCode(infos[1]);
        SignFamily jtSign = getSignFamilyBySessionId(sessionId,infos[0]);
        if (ssSign != null) {
            DoctorTeamMember member = doctorTeamDoctor.findSanshiByTeamAndType(ssSign.getTeamCode(), 1);
            if (member != null) {
@ -2669,7 +2686,8 @@ public class FamilyContractService extends BaseService {
        JSONObject result = new JSONObject();
        Map<String, JSONObject> docMap = new HashMap<>();
        SignFamily ssSign = signFamilyDao.findSignByPatient(infos[0], 1);
        SignFamily jtSign = signFamilyDao.findByTeamCode(infos[1]);
//        SignFamily jtSign = signFamilyDao.findByTeamCode(infos[1]);
        SignFamily jtSign = getSignFamilyBySessionId(sessionId,infos[0]);
        JSONObject ssArray = new JSONObject();
        JSONObject jtArray = new JSONObject();
        if (ssSign != null) {
@ -2697,6 +2715,27 @@ public class FamilyContractService extends BaseService {
        return result;
    }
    /**
     * 根据会话id查询 家庭签约信息
     * @param sessionId
     * @param patient
     * @return
     */
    public SignFamily getSignFamilyBySessionId(String sessionId,String patient){
        SignFamily signFamily = null;
        String sql = "select id from " + SystemConf.getInstance().getImDataBaseName() + ".topics where  session_id = '"+sessionId+"' order by create_time desc limit 0, 1";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        if(list!=null&&list.size()>0){
            String consultCode = list.get(0).get("id").toString();
            signFamily = signFamilyDao.findByPatient(patient);
            Consult consult = consultDao.findByCode(consultCode);
            if(signFamily==null||signFamily.getApplyDate().getTime()-consult.getCzrq().getTime()>0){
                signFamily = signFamilyDao.findOutTimeSigningByPatient(patient);
            }
        }
        return signFamily;
    }
    /**
     * 查询患者对应医生

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

@ -9,6 +9,7 @@ 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.consult.ConsultTeamDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.DoctorTeamDao;
import com.yihu.wlyy.repository.doctor.DoctorTeamMemberDao;
@ -86,6 +87,8 @@ public class SignWebService extends BaseService {
    private WeiXinAccessTokenUtils weiXinAccessTokenUtils;
    @Autowired
    private ConsultDao consultDao;
    @Autowired
    private ConsultTeamDao consultTeamDao;
    /**
     * 根据医生代码及签约状态编码 获取该医生签约患者的信息列表
@ -544,7 +547,7 @@ public class SignWebService extends BaseService {
     * @param code
     * @return
     */
    public JSONObject getConsultSignInfoOrRenewInfo(String teamCode, String code,String patient,String consultCode) {
    public JSONObject getConsultSignInfoOrRenewInfo(String teamCode, String code,String patient,String consultCode,Integer status) {
        //签约或续签参数
        String patientCode = null;
@ -556,26 +559,22 @@ public class SignWebService extends BaseService {
        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("找不到签约关系!");
                    }
            if(consultCode==null){
                if(status==1){
                    signFamily = signFamilyDao.findByPatientCodeStatus(patient,status);
                }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("找不到签约关系!");
                        }
                    }
                    signFamily = signFamilyDao.findOutTimeSigningByPatient(patient);
                }
            }else {
                signFamily = signFamilyDao.findByPatient(patient);
                Consult consult = consultDao.findByCode(consultCode);
                if(signFamily==null||signFamily.getApplyDate().getTime()-consult.getCzrq().getTime()>0){
                    signFamily = signFamilyDao.findOutTimeSigningByPatient(patient);
                }
            } else {
                signFamily = signFamilys.get(0);
            }
            if(signFamily==null){
                throw new RuntimeException("找不到签约关系!");
            }
            patientCode = signFamily.getPatient();
            adminTeamId = signFamily.getAdminTeamId();
@ -591,7 +590,7 @@ public class SignWebService extends BaseService {
        }
        Patient p = patientService.findByCode(patientCode);
//        Patient p = patientService.findByCode(patientCode);
        JSONObject resultObject = new JSONObject();
        AdminTeam adminTeam = adminTeamService.getTeam(adminTeamId);

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

@ -284,6 +284,7 @@ public class ConsultController extends WeixinBaseController {
                    return error(-1, "还有咨询未结束,不允许再次提交咨询!");
                }
            } catch (Exception e) {
                error(e);
                return error(-1, e.getMessage());
            }
            if (StringUtils.isEmpty(images)) {

+ 4 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/sign/PatientSignController.java

@ -267,9 +267,11 @@ public class PatientSignController extends BaseController {
	@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){
									  @RequestParam(required = true)String code,
                                      @RequestParam(required = false)String consult,
                                      @RequestParam(required = false)Integer status){
		try{
			JSONObject resultObj =  signWebService.getConsultSignInfoOrRenewInfo(teamCode,code,getRepUID(),consultCode);
			JSONObject resultObj =  signWebService.getConsultSignInfoOrRenewInfo(teamCode,code,getRepUID(),consult,status);
			return write(200, "查询成功!", "data", resultObj);
		}catch (Exception e){
			error(e);