|
@ -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}")
|
|
@ -3257,10 +3271,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 +3315,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");
|
|
|
}
|
|
@ -4799,6 +4857,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 +4874,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)){
|
|
@ -6527,8 +6586,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 +6610,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));
|