|
@ -4,9 +4,10 @@ package com.yihu.jw.hospital.module.rehabilitation.service;
|
|
|
import com.yihu.jw.doctor.dao.BaseDoctorDao;
|
|
|
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
|
|
|
import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
|
import com.yihu.jw.entity.base.servicePackage.ServiceItemPlanDO;
|
|
|
import com.yihu.jw.entity.rehabilitation.RehabilitationguidanceDO;
|
|
|
import com.yihu.jw.entity.rehabilitation.RehabilitationguidancePatientDO;
|
|
|
import com.yihu.jw.entity.util.TransforSqlUtl;
|
|
|
import com.yihu.jw.hospital.module.door.dao.ServiceItemPlanDao;
|
|
|
import com.yihu.jw.hospital.module.rehabilitation.dao.RehabilitationGuidanceDao;
|
|
|
import com.yihu.jw.hospital.module.rehabilitation.dao.RehabilitationGuidancePatientDao;
|
|
|
import com.yihu.jw.hospital.task.PushMsgTask;
|
|
@ -15,6 +16,7 @@ import com.yihu.jw.hospital.utils.WeiXinOpenIdUtils;
|
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
|
import com.yihu.jw.restmodel.web.PageEnvelop;
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
import com.yihu.jw.util.entity.ServiceException;
|
|
|
import org.apache.commons.lang3.StringEscapeUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
@ -35,6 +37,7 @@ import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
/**
|
|
@ -57,11 +60,14 @@ public class RehabilitationGuidanceService {
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
@Autowired
|
|
|
private PushMsgTask pushMsgTask;
|
|
|
|
|
|
@Autowired
|
|
|
private ServiceItemPlanDao serviceItemPlanDao;
|
|
|
@Autowired
|
|
|
private WeiXinAccessTokenUtils weiXinAccessTokenUtils;
|
|
|
@Autowired
|
|
|
private WeiXinOpenIdUtils weiXinOpenIdUtils;
|
|
|
@Autowired
|
|
|
private RehabilitationManageService rehabilitationManageService;
|
|
|
|
|
|
//按类型查找
|
|
|
public RehabilitationguidanceDO findByType(String type){
|
|
@ -101,7 +107,6 @@ public class RehabilitationGuidanceService {
|
|
|
String disease = "";
|
|
|
if (StringUtils.isNoneBlank(planId)) {
|
|
|
String sql = "select * from wlyy_patient_rehabilitation_plan where id='" + planId + "' ";
|
|
|
sql = TransforSqlUtl.wlyy_patient_rehabilitation_planAll(sql);
|
|
|
Map<String, Object> map = jdbcTemplate.queryForMap(sql);
|
|
|
if (map.get("disease") != null && StringUtils.isNoneBlank(map.get("disease").toString())) {
|
|
|
disease = map.get("disease").toString();
|
|
@ -119,18 +124,16 @@ public class RehabilitationGuidanceService {
|
|
|
|
|
|
/**
|
|
|
* 查询康复指导列表
|
|
|
*
|
|
|
* @param type
|
|
|
* @param code
|
|
|
* @param page
|
|
|
* @param pagesize
|
|
|
* @return
|
|
|
*/
|
|
|
public PageEnvelop select(String title, Integer type, String code, String planId, Integer page, Integer pagesize) {
|
|
|
public PageEnvelop select(String title, String type, String code, String planId, Integer page, Integer pagesize) {
|
|
|
String disease = "";
|
|
|
if (StringUtils.isNoneBlank(planId)) {
|
|
|
String sql = "select * from wlyy_patient_rehabilitation_plan where id='" + planId + "' ";
|
|
|
sql = TransforSqlUtl.wlyy_patient_rehabilitation_planAll(sql);
|
|
|
Map<String, Object> map = jdbcTemplate.queryForMap(sql);
|
|
|
if (map.get("disease") != null && StringUtils.isNoneBlank(map.get("disease").toString())) {
|
|
|
disease = map.get("disease").toString();
|
|
@ -173,7 +176,7 @@ public class RehabilitationGuidanceService {
|
|
|
}
|
|
|
|
|
|
|
|
|
public PageEnvelop selectPatientGuidances(String patient, String doctor, String code, Integer page, Integer pagesize) {
|
|
|
public PageEnvelop selectPatientGuidances(String patient, String doctor, String article, Integer page, Integer pagesize) {
|
|
|
if (page >= 1) {
|
|
|
page--;
|
|
|
}
|
|
@ -190,9 +193,10 @@ public class RehabilitationGuidanceService {
|
|
|
// 设置查询条件
|
|
|
Map<String, SearchFilter> filters = new HashMap<String, SearchFilter>();
|
|
|
// 指定患者
|
|
|
if (StringUtils.isNoneBlank(code)) {
|
|
|
filters.put("code", new SearchFilter("code", SearchFilter.Operator.EQ, code));
|
|
|
if (StringUtils.isNoneBlank(article)) {
|
|
|
filters.put("article", new SearchFilter("article", SearchFilter.Operator.EQ, article));
|
|
|
}
|
|
|
// 指定患者
|
|
|
if (StringUtils.isNoneBlank(patient)) {
|
|
|
filters.put("patient", new SearchFilter("patient", SearchFilter.Operator.EQ, patient));
|
|
|
}
|
|
@ -216,7 +220,21 @@ public class RehabilitationGuidanceService {
|
|
|
* @return
|
|
|
*/
|
|
|
public List<RehabilitationguidancePatientDO> sendGuidanceToPatient(List<RehabilitationguidancePatientDO> rehabilitationguidancePatientDOS, String planId) throws Exception {
|
|
|
List<ServiceItemPlanDO> itemPlanDOList = serviceItemPlanDao.findByPlanIdAndStatus(planId,"5","0");
|
|
|
if(itemPlanDOList.size()==0){
|
|
|
throw new ServiceException("该康复计划没有未发送的康复指导");
|
|
|
}
|
|
|
Map<String,ServiceItemPlanDO> itemPlanDOMap = itemPlanDOList.stream().collect(Collectors.toMap(ServiceItemPlanDO::getId, (p) -> p));
|
|
|
for (RehabilitationguidancePatientDO rehabilitationguidancePatientDO : rehabilitationguidancePatientDOS) {
|
|
|
//查询计划id
|
|
|
ServiceItemPlanDO itemPlanDO = itemPlanDOMap.get(rehabilitationguidancePatientDO.getRelationCode());
|
|
|
if(itemPlanDO==null){
|
|
|
throw new ServiceException("请勿重复发送");
|
|
|
}
|
|
|
if(!itemPlanDO.getDoctor().equals(rehabilitationguidancePatientDO.getDoctor())){
|
|
|
throw new ServiceException("不是您的任务,无法完成");
|
|
|
}
|
|
|
|
|
|
RehabilitationguidanceDO rehabilitationguidanceDO = rehabilitationGuidanceDao.findByCode(rehabilitationguidancePatientDO.getArticle());
|
|
|
rehabilitationguidanceDO.setUseCount(rehabilitationguidanceDO.getUseCount() + 1);
|
|
|
rehabilitationGuidanceDao.save(rehabilitationguidanceDO);
|
|
@ -234,6 +252,8 @@ public class RehabilitationGuidanceService {
|
|
|
rehabilitationguidancePatientDO.setIsRead(0);
|
|
|
rehabilitationguidancePatientDO.setSendStatus(0);
|
|
|
rehabilitationguidancePatientDO = rehabilitationGuidancePatientDao.save(rehabilitationguidancePatientDO);
|
|
|
itemPlanDO.setRelationCode(rehabilitationguidancePatientDO.getId()+"");
|
|
|
rehabilitationManageService.completePlan(itemPlanDO);
|
|
|
this.sendSpecialistWeixinMessage(rehabilitationguidancePatientDO.getPatient(), rehabilitationguidancePatientDO.getDoctor(), 1, rehabilitationguidancePatientDO.getArticle(), planId, null);
|
|
|
}
|
|
|
return rehabilitationguidancePatientDOS;
|
|
@ -288,7 +308,7 @@ public class RehabilitationGuidanceService {
|
|
|
if (type == 1) {
|
|
|
RehabilitationguidanceDO rehabilitationguidanceDO = rehabilitationGuidanceDao.findByCode(relationCode);
|
|
|
json.put("toUser", patientCode);
|
|
|
json.put("first", patient.getName() + ",您好!您的家庭医生发来一篇健康文章!");
|
|
|
json.put("first", patient.getName() + ",您好!您的医生发来一篇健康文章!");
|
|
|
json.put("represented", patientCode);//被代理人
|
|
|
json.put("id", planId);
|
|
|
json.put("date", DateUtil.getStringDate());
|
|
@ -367,42 +387,10 @@ public class RehabilitationGuidanceService {
|
|
|
json.put("keyword2", DateUtil.getStringDate());
|
|
|
json.put("remark", "请及时阅读");
|
|
|
json.put("url", "smfw/html/toAppointment.html?relationCode=" + relationCode + "");
|
|
|
} else if (type == 5) {
|
|
|
//家签提醒 5
|
|
|
sendType = 11;//待办事项
|
|
|
String sql = "select pd.id,pd.execute_time as executeTime from wlyy_rehabilitation_plan_detail pd " +
|
|
|
"where pd.plan_id ='" + planId + "' and pd.hospital_service_item_id='4' and pd.status <>1 order by pd.execute_time desc ";
|
|
|
List<Map<String, Object>> mapList = jdbcTemplate.queryForList(sql);
|
|
|
String excuteTime = "";
|
|
|
if (mapList != null && mapList.size() != 0) {
|
|
|
excuteTime = DateUtil.dateToStrLong((Date) mapList.get(0).get("executeTime"));
|
|
|
}
|
|
|
json.put("first", patient.getName() + ",您好!为方便为您提供康复管理服务,请先选择合适的社区和家庭医生进行签约");
|
|
|
json.put("toUser", patientCode);
|
|
|
json.put("represented", patientCode);//被代理人
|
|
|
json.put("keyword1", "家庭医生签约");
|
|
|
json.put("keyword2", DateUtil.getStringDate());
|
|
|
json.put("remark", "请及时阅读");
|
|
|
json.put("url", "qygl/html/signing-welcome.html");
|
|
|
}
|
|
|
logger.info("微信模板入参:" + sendType + "==" + json.toString());
|
|
|
if (StringUtils.isNotBlank(patient.getOpenid())) {
|
|
|
pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), sendType, patient.getOpenid(), patient.getName(), json);
|
|
|
} else {
|
|
|
//发送代理人
|
|
|
org.json.JSONArray jsonArray = weiXinOpenIdUtils.getAgentOpenId(patient.getId(), patient.getOpenid());
|
|
|
if (jsonArray != null && jsonArray.length() > 0) {
|
|
|
for (int i = 0; i < jsonArray.length(); i++) {
|
|
|
org.json.JSONObject j = jsonArray.getJSONObject(i);
|
|
|
BasePatientDO member = (BasePatientDO) j.get("member");
|
|
|
org.json.JSONObject data = json;
|
|
|
data.remove("toUser");
|
|
|
data.put("toUser", member.getId());
|
|
|
data.remove("first");
|
|
|
data.put("first", weiXinOpenIdUtils.getTitleMes(patient, j.getInt("relation"), patient.getName()));
|
|
|
pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), sendType, member.getOpenid(), patient.getName(), data);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|