Selaa lähdekoodia

Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev

yeshijie 4 vuotta sitten
vanhempi
commit
8496b1406d

+ 103 - 27
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java

@ -15,8 +15,7 @@ import com.yihu.jw.entity.base.org.BaseDoctorPatientFollowDO;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.PatientMedicareCardDO;
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
import com.yihu.jw.entity.base.wx.WxWechatDO;
import com.yihu.jw.entity.base.wx.*;
import com.yihu.jw.entity.hospital.consult.WlyyDoctorClinicRoomDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalWaitingRoomDO;
@ -72,11 +71,15 @@ import com.yihu.jw.rm.iot.IotRequestMapping;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.common.LatitudeUtils;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.wechat.WeixinMessagePushUtils;
import com.yihu.jw.utils.StringUtil;
import com.yihu.jw.utils.WebserviceUtil;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.jw.wechat.dao.BasePatientWechatDao;
import com.yihu.jw.wechat.dao.WechatDao;
import com.yihu.jw.wechat.dao.WxPushLogDao;
import com.yihu.jw.wechat.dao.WxTemplateConfigDao;
import com.yihu.jw.wechat.service.WxAccessTokenService;
import com.yihu.mysql.query.BaseJpaService;
import com.yihu.utils.security.MD5;
import com.ylzinfo.ehc.EhcHandler;
@ -94,6 +97,7 @@ import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
@ -224,6 +228,16 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    private WechatDao wechatDao;
    @Autowired
    private BasePatientWechatDao patientWechatDao;
    @Autowired
    private WxTemplateConfigDao wxTemplateConfigDao;
    @Autowired
    private WxAccessTokenService wxAccessTokenService;
    @Autowired
    private WeixinMessagePushUtils weixinMessagePushUtils;
    @Autowired
    private BasePatientWechatDao basePatientWechatDao;
    @Autowired
    private WxPushLogDao wxPushLogDao;
    @Value("${demo.flag}")
@ -431,7 +445,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
     * @param outpatientId
     * @return
     */
    public com.alibaba.fastjson.JSONObject findReOutpatientInfo(String outpatientId,String prescriptionId) throws Exception {
    public com.alibaba.fastjson.JSONObject findReOutpatientInfo(String outpatientId,String prescriptionId,String wxId) throws Exception {
        com.alibaba.fastjson.JSONObject rs = new com.alibaba.fastjson.JSONObject();
        //复诊信息
@ -452,6 +466,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        rs.put("mobile",basePatientDO.getMobile());
        rs.put("birthday",DateUtil.dateToStr(basePatientDO.getBirthday(),"yyyy-MM-dd"));
        Long time = new Date().getTime()-outpatientDO.getCreateTime().getTime();
        rs.put("time",time);
        //获取处方信息
        List<WlyyPrescriptionDO> prescriptionDOs = null;
@ -476,9 +492,17 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                List<WlyyInspectionVO> inspectionVOs = new ArrayList<>();
                vo.setInspectionVOs(convertToModels(wlyyInspectionDao.findByPrescriptionId(vo.getId(),1),inspectionVOs,WlyyInspectionVO.class));
                WlyyPrescriptionEmrDO wlyyPrescriptionEmrDO = readOutPatientXml(outpatientDO.getOriginRegisterNo());
                //电子病历
                vo.setWlyyPrescriptionEmrDO(wlyyPrescriptionEmrDO);
                if (wxId.equalsIgnoreCase("xm_zsyy_wx")){
                    WlyyPrescriptionEmrDO wlyyPrescriptionEmrDO1 = prescriptionEmrDao.findEmrByPrescriptionId(vo.getId());
                    if (wlyyPrescriptionEmrDO1!=null){
                        vo.setWlyyPrescriptionEmrDO(wlyyPrescriptionEmrDO1);
                    }else {
                        WlyyPrescriptionEmrDO wlyyPrescriptionEmrDO = readOutPatientXml(outpatientDO.getOriginRegisterNo());
                        //电子病历
                        vo.setWlyyPrescriptionEmrDO(wlyyPrescriptionEmrDO);
                    }
                }
            }
        }
        rs.put("prescriptions",prescriptionVOs);
@ -3257,10 +3281,12 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                if ("1".equalsIgnoreCase(wlyyOutpatientDO.getType())){
                    data.put("type","9");
                   msg+=wlyyOutpatientDO.getPatientName()+",您好! 您有一个图文复诊已被医生取消,取消原因:"+cancelValue+"。取消说明:"+cancelRemark+"。";
//                   sendWxTemplateMsg(wechatId,wlyyOutpatientDO,"9");
                }
                if ("2".equalsIgnoreCase(wlyyOutpatientDO.getType())){
                    data.put("type","16");
                    msg+=wlyyOutpatientDO.getPatientName()+",您好! 您有一个视频复诊已被医生取消,取消原因:"+cancelValue+"。取消说明:"+cancelRemark+"。";
//                    sendWxTemplateMsg(wechatId,wlyyOutpatientDO,"16");
                }
                data.put("msg",msg);
                messageDO.setData(data.toString());
@ -3299,6 +3325,48 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        return  rs;
    }
    public void sendWxTemplateMsg(String wxId,WlyyOutpatientDO outpatientDO,String type){
        List<BasePatientWechatDo> ps = basePatientWechatDao.findByWechatIdAndPatientId(wxId, outpatientDO.getPatient());
        if(ps.isEmpty()){
            logger.info("该用户"+outpatientDO.getPatientName()+"没有openid,无法推送模版消息,用户ID:"+outpatientDO.getPatient()+"wechatId:"+wxId);
            return;
        }
        if ("xm_ykyy_wx".equalsIgnoreCase(wxId)){
            ps.stream().forEach(one->{
                BaseDoctorDO doctorDO = baseDoctorDao.findById(outpatientDO.getDoctor());
                WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId,"template_doctor_notice","ysqxjz",1);
                WxTemplateConfigDO newConfig = new WxTemplateConfigDO();
                BeanUtils.copyProperties(config,newConfig);
                newConfig.setFirst(config.getFirst().replace("key1",outpatientDO.getPatientName()));
                if ("9".equals(type)){
                    newConfig.setFirst(newConfig.getFirst().replace("key2","图文复诊"));
                }
                if ("16".equals(type)){
                    newConfig.setFirst(newConfig.getFirst().replace("key2","视频复诊"));
                }
                newConfig.setUrl(config.getUrl()+""+outpatientDO.getId());
                newConfig.setKeyword1(config.getKeyword1()+outpatientDO.getHospitalName());
                newConfig.setKeyword2(config.getKeyword2()+outpatientDO.getDoctorName());
                newConfig.setKeyword3(config.getKeyword3()+doctorDO.getFee());
                WxAccessTokenDO wxAccessTokenDO = wxAccessTokenService.getWxAccessTokenById(wechatId);
                logger.info("=======setUrl========"+newConfig.getUrl());
                weixinMessagePushUtils.putWxMsg(wxAccessTokenDO.getAccessToken(),one.getOpenid(),newConfig);
                //保存发送模板记录,
                WxPushLogDO wxPushLogDO = new WxPushLogDO();
                wxPushLogDO.setCreateTime(new Date());
                wxPushLogDO.setOpenid(one.getOpenid());
                wxPushLogDO.setReceiver(outpatientDO.getPatient());
                wxPushLogDO.setWechatId(wechatId);
                wxPushLogDO.setReceiverName(outpatientDO.getPatientName());
                wxPushLogDO.setScene("ysqxjz");
                wxPushLogDao.save(wxPushLogDO);
            });
        }
    }
    public List<WlyyHospitalSysDictDO> findCancelReasonList(){
        return sysDictDao.findByDictName("PatientCancel");
    }
@ -4391,6 +4459,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        for (Map<String,Object> map:list){
            if (!map.get("id").toString().equalsIgnoreCase(outpatientId)){
                waitCount+=1;
            }else{
                break;
            }
        }
        return waitCount.toString();
@ -4799,6 +4869,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
     */
    public SystemMessageDO sendOutPatientMes(WlyyOutpatientDO outpatient){
        SystemMessageDO systemMessageDO = new SystemMessageDO();
        String msg="";
        JSONObject data = new JSONObject();
        try{
            //1.在线复诊2.协同门诊
            if("2".equals(outpatient.getOutpatientType())){
@ -4814,27 +4886,26 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                    systemMessageDO.setTitle("视频复诊预约成功");
                    systemMessageDO.setType("2");
                    saveInquirySystemMessage(outpatient);
                    msg="您的视频复诊已预约成功。\n" +
                            "预计"+outpatient.getDoctorName()+"医生将于"+outpatient.getRegisterDate()+" 与您进行视频咨询。请留意系统消息或微信公众号消息。咨询开始时,医生将邀请您进行视频通话,请您关注消息提醒,及时接受医生视频邀请。";
                    systemMessageDO.setReceiver(outpatient.getDoctor());
                    systemMessageDO.setReceiverName(outpatient.getDoctorName());
                    systemMessageDO.setRelationCode(outpatient.getId());
                    systemMessageDO.setSender(outpatient.getPatient());
                    systemMessageDO.setSenderName(outpatient.getPatientName());
                    systemMessageDO.setRelationCode(outpatient.getId());
                    data.put("name",outpatient.getPatientName());
                    data.put("age",IdCardUtil.getAgeForIdcard(outpatient.getIdcard()));
                    data.put("gender",IdCardUtil.getSexForIdcard_new(outpatient.getIdcard()));
                    data.put("question",outpatient.getDescription());
                    data.put("msg",msg);
                    systemMessageDO.setData(data.toString());
                    systemMessageService.saveMessage(systemMessageDO);
                }
            }
            systemMessageDO.setReceiver(outpatient.getDoctor());
            systemMessageDO.setReceiverName(outpatient.getDoctorName());
            systemMessageDO.setRelationCode(outpatient.getId());
            systemMessageDO.setSender(outpatient.getPatient());
            systemMessageDO.setSenderName(outpatient.getPatientName());
            systemMessageDO.setRelationCode(outpatient.getId());
            JSONObject data = new JSONObject();
            data.put("name",outpatient.getPatientName());
            data.put("age",IdCardUtil.getAgeForIdcard(outpatient.getIdcard()));
            data.put("gender",IdCardUtil.getSexForIdcard_new(outpatient.getIdcard()));
            data.put("question",outpatient.getDescription());
            String msg="您的视频复诊已预约成功。\n" +
                    "预计"+outpatient.getDoctorName()+"医生将于"+outpatient.getRegisterDate()+" 与您进行视频咨询。请留意系统消息或微信公众号消息。咨询开始时,医生将邀请您进行视频通话,请您关注消息提醒,及时接受医生视频邀请。";
            data.put("msg",msg);
            systemMessageDO.setData(data.toString());
            systemMessageService.saveMessage(systemMessageDO);
            BasePatientDO patient = basePatientDao.findById(outpatient.getPatient());
            if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
@ -5880,11 +5951,13 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            prescriptionLogService.addPrescriptionLog(prescriptionId,20,2,operate,operateName,reason,new Date());
            wlyyPrescriptionDO.setCheckStatus(2);
            wlyyPrescriptionDO.setCheckReason(reason);
            wlyyPrescriptionDO.setStatus(20);
            wlyyPrescriptionDO.setPrescribeTime(new Date());
            //发送系统消息 处方支付提醒
            SystemMessageDO messageDO = new SystemMessageDO();
@ -6527,8 +6600,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        String uid = userAgent.getUID();
        StringBuffer sql = new StringBuffer("select a.* from wlyy_prescription a,wlyy_prescription_info b where a.patient_code ='");
        StringBuffer countSql = new StringBuffer("select COUNT(a.id) count from wlyy_prescription a,wlyy_prescription_info b  where a.patient_code ='");
        sql.append(uid).append("' and a.status >= 0 AND a.id = b.prescription_id");
        countSql.append(uid).append("' and a.status >= 0 AND a.id = b.prescription_id ");
        sql.append(uid).append("' AND a.id = b.prescription_id");
        countSql.append(uid).append("' AND a.id = b.prescription_id ");
        if (StringUtils.isNotEmpty(keyName)){
            sql.append(" AND (" +
@ -6551,6 +6624,9 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            status= status.substring(1, status.length() - 1);
            sql.append(" AND a.status IN(").append(status).append(")");
            countSql.append(" AND a.status IN(").append(status).append(")");
        }else {
            sql.append("  and a.status IN(20,21,30,31,32,100,101)");
            countSql.append(" and a.status IN(20,21,30,31,32,100,101) ");
        }
        sql.append(" order by a.prescribe_time limit ").append((page-1)*size).append(",").append(size);
        List<WlyyPrescriptionDO> list = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(WlyyPrescriptionDO.class));

+ 2 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/XzzxEntranceService.java

@ -1256,6 +1256,7 @@ public class XzzxEntranceService{
                outpatientVO.setDiseaseImg(isEmty(object.getString("DISEASEIMG")));
                outpatientVO.setCreateTime(DateUtil.strToDate(object.getString("CREATETIME")));
                outpatientVO.setStatus(isEmty(object.getString("STATUS")));
                outpatientVO.setConNo(isEmty(object.getString("VISITNUM")));
                wlyyOutpatientVOList.add(outpatientVO);
            }
        }
@ -1306,6 +1307,7 @@ public class XzzxEntranceService{
                outpatientVO.setDiseaseImg(isEmty(object.getString("DISEASEIMG")));
                outpatientVO.setCreateTime(DateUtil.strToDate(object.getString("CREATETIME")));
                outpatientVO.setStatus(isEmty(object.getString("STATUS")));
                outpatientVO.setConNo(isEmty(object.getString("VISITNUM")));
            }
        }
        return outpatientVO;

+ 3 - 2
business/base-service/src/main/java/com/yihu/jw/order/pay/ylz/YlzPayService.java

@ -8,6 +8,7 @@ import com.yihu.jw.hospital.prescription.dao.OauthYlzConfigDao;
import com.yihu.jw.order.pay.utils.PayLogService;
import com.yihu.jw.utils.StringUtil;
import com.ylzinfo.onepay.sdk.HisOnepayClient;
import com.ylzinfo.onepay.sdk.OnepayClient;
import com.ylzinfo.onepay.sdk.domain.ResponseParams;
import com.ylzinfo.onepay.sdk.domain.ext.*;
import com.ylzinfo.onepay.sdk.utils.DateUtil;
@ -320,7 +321,7 @@ public class YlzPayService {
        String onepayUrl = oauthYlzConfigDO.getUrl();
        String signType=oauthYlzConfigDO.getSignType();
        String encryptType = oauthYlzConfigDO.getEncType();
        HisOnepayClient onepayClient = new HisOnepayClient(onepayUrl, appId, appSecret, signType, encryptType);
        OnepayClient onepayClient = new OnepayClient(onepayUrl, appId, appSecret, signType, encryptType);
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("accId", accId);// 第三方应用原始ID微信公众号(支付宝)原始ID市民卡APP商户(医院)Id平安APP商户(医院)Id银联商户(医院)Id如:gh_54ec946bd3cd
@ -328,7 +329,7 @@ public class YlzPayService {
            jsonObject.put("cardNo",cardNo);//就诊卡或社保卡
            jsonObject.put("channel", channel);//WX: 微信 (默认)ALI: 支付宝PA: 平安SMK:市民卡APP
            //jsonObject.put("extra")
            ResponseParams<JSONObject> response = onepayClient.createSicardUrl(jsonObject);
            ResponseParams<JSONObject> response = onepayClient.createSicardPayUrl(jsonObject);
            if (response.getRespCode().equals("000000")){
                object = JSON.toJSONString(response);
            }else {

+ 2 - 0
business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java

@ -1495,6 +1495,8 @@ public class ImService {
			ykyyService.pushNotificationToYktPatient(patient.getYktId(),messageDO.getTitle(),data.get("msg").toString());
		}
	}
	
	/**
	 * 根据咨询CODE获取session_id

+ 11 - 1
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/service/channel/UnSettledHISPrescriptionService.java

@ -182,13 +182,23 @@ public class UnSettledHISPrescriptionService {
                    JSONObject json = jsonArray.getJSONObject(i);
                    String cfsb = json.getString("CFSB");
                    //查找对应的处方
                    String sql = "SELECT w.OUTPATIENT_ID,w.ID,w.DOCTOR_NAME from WLYY_PRESCRIPTION w WHERE REAL_ORDER = '"+cfsb+"' ORDER BY w.CREATE_TIME desc";
                    String sql = "SELECT w.OUTPATIENT_ID,w.ID,w.DOCTOR,w.DOCTOR_NAME from WLYY_PRESCRIPTION w WHERE REAL_ORDER = '"+cfsb+"' and status <> 11 ORDER BY w.CREATE_TIME desc";
                    List<Map<String, Object>> pre = hibenateUtils.createSQLQuery(sql);
                    if(pre!=null && pre.size()>0){
                        String prescriptionId = pre.get(0).get("ID").toString();
                        String outpatientId=pre.get(0).get("OUTPATIENT_ID").toString();
                        String doctor = pre.get(0).get("DOCTOR").toString();
                        String doctorName = pre.get(0).get("DOCTOR_NAME").toString();
                        //修改处方状态
                        String updateSql = "update WLYY_PRESCRIPTION set status = 11 where id = '"+prescriptionId+"'";
                        hibenateUtils.updateBySql(updateSql);
                        com.alibaba.fastjson.JSONObject msgObj = new com.alibaba.fastjson.JSONObject();
                        msgObj.put("outpatientid",outpatientId);
                        msgObj.put("prescriptionId",prescriptionId);
                        msgObj.put("reason","处方驳回");
                        WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(outpatientId);
                        String immsg = imService.pushPrescriptionBackMsg(msgObj,doctor,doctorName,outpatientId,wlyyOutpatientDO.getPatient(),wlyyOutpatientDO.getOutpatientType());
                        System.out.println("发送诊断消息成功:"+immsg);
                    }
                }
            }

+ 1 - 1
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java

@ -206,7 +206,7 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
                                           @RequestParam(value = "outpatientId", required = true) String outpatientId,
                                           @ApiParam(name = "prescriptionId", value = "处方ID")
                                           @RequestParam(value = "prescriptionId", required = false) String prescriptionId)throws Exception{
        com.alibaba.fastjson.JSONObject obj =  prescriptionService.findReOutpatientInfo(outpatientId,prescriptionId);
        com.alibaba.fastjson.JSONObject obj =  prescriptionService.findReOutpatientInfo(outpatientId,prescriptionId,wxId);
        return success(obj);
    }