|
@ -10,6 +10,7 @@ import com.yihu.wlyy.entity.patient.SignFamily;
|
|
|
import com.yihu.wlyy.entity.specialist.PatientDiseaseServer;
|
|
|
import com.yihu.wlyy.entity.specialist.SpecialDisease;
|
|
|
import com.yihu.wlyy.entity.specialist.TeamDiseaseRelation;
|
|
|
import com.yihu.wlyy.entity.wechat.WechatTemplateConfig;
|
|
|
import com.yihu.wlyy.repository.doctor.DoctorAdminTeamDao;
|
|
|
import com.yihu.wlyy.repository.doctor.DoctorDao;
|
|
|
import com.yihu.wlyy.repository.doctor.SignPatientLabelDao;
|
|
@ -20,7 +21,10 @@ import com.yihu.wlyy.repository.patient.SignFamilyDao;
|
|
|
import com.yihu.wlyy.repository.specialist.PatientDiseaseServerDao;
|
|
|
import com.yihu.wlyy.repository.specialist.SpecialDiseaseDao;
|
|
|
import com.yihu.wlyy.repository.specialist.TeamDiseaseRelationDao;
|
|
|
import com.yihu.wlyy.repository.wechat.WechatTemplateConfigDao;
|
|
|
import com.yihu.wlyy.service.BaseService;
|
|
|
import com.yihu.wlyy.task.PushMsgTask;
|
|
|
import com.yihu.wlyy.util.DateUtil;
|
|
|
import com.yihu.wlyy.util.http.HttpResponse;
|
|
|
import com.yihu.wlyy.util.http.HttpUtils;
|
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
@ -76,6 +80,10 @@ public class SpecialistService extends BaseService {
|
|
|
private MessageDao messageDao;
|
|
|
@Autowired
|
|
|
private SignFamilyDao signFamilyDao;
|
|
|
@Autowired
|
|
|
private PushMsgTask pushMsgTask;
|
|
|
@Autowired
|
|
|
private WechatTemplateConfigDao templateConfigDao;
|
|
|
|
|
|
public String setPatientLabelInfo(List<SignPatientLabelInfo> list) {
|
|
|
if (list != null && list.size() > 0) {
|
|
@ -528,7 +536,7 @@ public class SpecialistService extends BaseService {
|
|
|
return mes;
|
|
|
}
|
|
|
|
|
|
public String agreeSpecialistTeam(String state, String relationCode, String remark, Long mesId) throws Exception {
|
|
|
public String agreeSpecialistTeam(String token, String state, String relationCode, String remark, Long mesId) throws Exception {
|
|
|
Map<String, Object> param = new HashedMap();
|
|
|
param.put("state", state);
|
|
|
param.put("relationCode", relationCode);
|
|
@ -545,50 +553,57 @@ public class SpecialistService extends BaseService {
|
|
|
messageDao.save(m);
|
|
|
}
|
|
|
|
|
|
JSONObject josn = rs.getJSONObject("obj");
|
|
|
Patient p = patientDao.findByCode(josn.getString("patient"));
|
|
|
Doctor d = doctorDao.findByCode(josn.getString("doctor"));
|
|
|
|
|
|
//如果医生拒绝,置空疾病服务类型
|
|
|
if("0".equals(state)){
|
|
|
List<PatientDiseaseServer> servers = patientDiseaseServerDao.findBySpecialistRelationCodeAndDel(relationCode,"1");
|
|
|
for (PatientDiseaseServer server:servers){
|
|
|
server.setDel("0");
|
|
|
}
|
|
|
if ("0".equals(state)) {
|
|
|
List<PatientDiseaseServer> servers = patientDiseaseServerDao.findBySpecialistRelationCodeAndDel(relationCode, "1");
|
|
|
for (PatientDiseaseServer server : servers) {
|
|
|
server.setDel("0");
|
|
|
}
|
|
|
patientDiseaseServerDao.save(servers);
|
|
|
}
|
|
|
|
|
|
JSONObject josn = rs.getJSONObject("obj");
|
|
|
SignFamily sign = signFamilyDao.findByPatient(josn.getString("patient"));
|
|
|
//判断是否有家庭医生,有家庭医生则通知家庭医生
|
|
|
if(sign!=null){
|
|
|
Patient p = patientDao.findByCode(josn.getString("patient"));
|
|
|
Doctor d = doctorDao.findByCode(josn.getString("doctor"));
|
|
|
// 添加签约申请消息
|
|
|
Message message = new Message();
|
|
|
message.setCzrq(new Date());
|
|
|
message.setCreateTime(new Date());
|
|
|
message.setContent("您有一个居民开通共管服务!");
|
|
|
message.setRead(1);//设置未读
|
|
|
message.setReceiver(sign.getDoctor());//设置接受医生的code
|
|
|
message.setSender(p.getCode());//设置发送的用户
|
|
|
message.setSenderName(p.getName());
|
|
|
message.setCode(getCode());
|
|
|
message.setTitle("专科医生共管通知");
|
|
|
message.setType(18);//家庭签约取消信息
|
|
|
message.setReadonly(0);//是否只读消息
|
|
|
message.setSex(p.getSex());
|
|
|
message.setOver("1");//未处理
|
|
|
message.setRelationCode(relationCode);
|
|
|
message.setDel("1");
|
|
|
message.setState(1);
|
|
|
|
|
|
JSONObject dataJson = new JSONObject();
|
|
|
dataJson.put("doctor",d.getCode());
|
|
|
dataJson.put("doctorName",d.getName());
|
|
|
dataJson.put("hospital",d.getHospital());
|
|
|
dataJson.put("hospitalName",d.getHospitalName());
|
|
|
dataJson.put("dept",d.getDept());
|
|
|
dataJson.put("deptName",d.getDeptName());
|
|
|
message.setReason(dataJson.toString());
|
|
|
|
|
|
messageDao.save(message);
|
|
|
//推送给居民模板消息
|
|
|
pushWeiTemp(token, "0", remark, p, d);
|
|
|
} else {
|
|
|
//医生同意,推送全科医生消息
|
|
|
SignFamily sign = signFamilyDao.findByPatient(josn.getString("patient"));
|
|
|
//判断是否有家庭医生,有家庭医生则通知家庭医生
|
|
|
if (sign != null) {
|
|
|
// 添加签约申请消息
|
|
|
Message message = new Message();
|
|
|
message.setCzrq(new Date());
|
|
|
message.setCreateTime(new Date());
|
|
|
message.setContent("您有一个居民开通共管服务!");
|
|
|
message.setRead(1);//设置未读
|
|
|
message.setReceiver(sign.getDoctor());//设置接受医生的code
|
|
|
message.setSender(p.getCode());//设置发送的用户
|
|
|
message.setSenderName(p.getName());
|
|
|
message.setCode(getCode());
|
|
|
message.setTitle("专科医生共管通知");
|
|
|
message.setType(18);//家庭签约取消信息
|
|
|
message.setReadonly(0);//是否只读消息
|
|
|
message.setSex(p.getSex());
|
|
|
message.setOver("1");//未处理
|
|
|
message.setRelationCode(relationCode);
|
|
|
message.setDel("1");
|
|
|
message.setState(1);
|
|
|
|
|
|
JSONObject dataJson = new JSONObject();
|
|
|
dataJson.put("doctor", d.getCode());
|
|
|
dataJson.put("doctorName", d.getName());
|
|
|
dataJson.put("hospital", d.getHospital());
|
|
|
dataJson.put("hospitalName", d.getHospitalName());
|
|
|
dataJson.put("dept", d.getDept());
|
|
|
dataJson.put("deptName", d.getDeptName());
|
|
|
message.setReason(dataJson.toString());
|
|
|
|
|
|
messageDao.save(message);
|
|
|
|
|
|
//推送给居民模板消息
|
|
|
pushWeiTemp(token, "1", "", p, d);
|
|
|
}
|
|
|
}
|
|
|
return "1";
|
|
|
}
|
|
@ -637,5 +652,34 @@ public class SpecialistService extends BaseService {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
public void pushWeiTemp(String token, String state, String remark, Patient patient, Doctor doctor) {
|
|
|
logger.info("pushWeiTemp:"+patient.getCode()+"__openid:"+patient.getOpenid());
|
|
|
if (StringUtils.isNotBlank(patient.getOpenid())) {
|
|
|
WechatTemplateConfig temp;
|
|
|
JSONObject json = new JSONObject();
|
|
|
if ("0".equals(state)) {
|
|
|
//拒绝
|
|
|
temp = templateConfigDao.findByScene("template_deal_with", "tdwspref");
|
|
|
json.put("toUser", patient.getCode());
|
|
|
json.put("keyword1", DateUtil.dateToStr(new Date(), "yyyy-MM-dd"));
|
|
|
json.put("keyword2", temp.getKeyword2().replace("key1", doctor.getName()));
|
|
|
json.put("remark", temp.getRemark().replace("key1", remark));
|
|
|
json.put("first", temp.getFirst().replace("key1", patient.getName()));
|
|
|
} else {
|
|
|
//同意
|
|
|
temp = templateConfigDao.findByScene("template_deal_with", "tdwspref");
|
|
|
json.put("toUser", patient.getCode());
|
|
|
json.put("keyword1", DateUtil.dateToStr(new Date(), "yyyy-MM-dd"));
|
|
|
json.put("keyword2", temp.getKeyword2().replace("key1", doctor.getName()));
|
|
|
json.put("remark", temp.getRemark());
|
|
|
json.put("first", temp.getFirst().replace("key1", patient.getName()));
|
|
|
}
|
|
|
|
|
|
logger.info("pushWeiTempJOSN:"+json.toString());
|
|
|
|
|
|
pushMsgTask.putWxMsg(token, 24, patient.getOpenid(), patient.getName(), json);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|