|
@ -686,66 +686,68 @@ public class ConsultTeamService extends ConsultService {
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public int addTeamConsult(ConsultTeam ct, String patient,String agent) throws Exception {
|
|
|
JSONObject users = new JSONObject();
|
|
|
|
|
|
if(patient.equals(agent)){
|
|
|
agent = null;
|
|
|
}
|
|
|
synchronized (patient.intern()){//新增同步块,防止居民网络不好时多次点击,或者im服务器响应慢导致同时发起多个咨询
|
|
|
JSONObject users = new JSONObject();
|
|
|
|
|
|
// 咨询三师
|
|
|
if (ct.getType() == 1) {
|
|
|
// 查询三师签约信息
|
|
|
SignFamily sc = signFamilyDao.findBySanshiPatientYes(patient);
|
|
|
if (sc == null) {
|
|
|
// 不存在三师签约
|
|
|
return -2;
|
|
|
if(patient.equals(agent)){
|
|
|
agent = null;
|
|
|
}
|
|
|
ct.setTeam(sc.getTeamCode());
|
|
|
// 设置健康管理师,三师咨询默认给健康管理师处理
|
|
|
//查找病人所在的团队
|
|
|
DoctorTeam doctorTeam = doctorTeamDao.findBySanshiParientCode(patient);
|
|
|
//得到团队的健康管理师
|
|
|
DoctorTeamMember doctorTeamMemberHealthy = doctorTeamDoctor.findDoctorSanshi2ByTeam(doctorTeam.getCode(), 3);
|
|
|
DoctorTeamMember doctorTeamMember = doctorTeamDoctor.findDoctorSanshi2ByTeam(doctorTeam.getCode(), 2);
|
|
|
if (doctorTeamMemberHealthy == null) {
|
|
|
ct.setDoctor(doctorTeamMember.getMemberCode());
|
|
|
users.put(doctorTeamMember.getMemberCode(), 0);
|
|
|
} else {
|
|
|
users.put(doctorTeamMemberHealthy.getMemberCode(), 0);
|
|
|
if (doctorTeamMember != null) {
|
|
|
if (users.isNull(doctorTeamMember.getMemberCode())) {
|
|
|
users.put(doctorTeamMember.getMemberCode(), 1);
|
|
|
|
|
|
// 咨询三师
|
|
|
if (ct.getType() == 1) {
|
|
|
// 查询三师签约信息
|
|
|
SignFamily sc = signFamilyDao.findBySanshiPatientYes(patient);
|
|
|
if (sc == null) {
|
|
|
// 不存在三师签约
|
|
|
return -2;
|
|
|
}
|
|
|
ct.setTeam(sc.getTeamCode());
|
|
|
// 设置健康管理师,三师咨询默认给健康管理师处理
|
|
|
//查找病人所在的团队
|
|
|
DoctorTeam doctorTeam = doctorTeamDao.findBySanshiParientCode(patient);
|
|
|
//得到团队的健康管理师
|
|
|
DoctorTeamMember doctorTeamMemberHealthy = doctorTeamDoctor.findDoctorSanshi2ByTeam(doctorTeam.getCode(), 3);
|
|
|
DoctorTeamMember doctorTeamMember = doctorTeamDoctor.findDoctorSanshi2ByTeam(doctorTeam.getCode(), 2);
|
|
|
if (doctorTeamMemberHealthy == null) {
|
|
|
ct.setDoctor(doctorTeamMember.getMemberCode());
|
|
|
users.put(doctorTeamMember.getMemberCode(), 0);
|
|
|
} else {
|
|
|
users.put(doctorTeamMemberHealthy.getMemberCode(), 0);
|
|
|
if (doctorTeamMember != null) {
|
|
|
if (users.isNull(doctorTeamMember.getMemberCode())) {
|
|
|
users.put(doctorTeamMember.getMemberCode(), 1);
|
|
|
}
|
|
|
}
|
|
|
ct.setDoctor(doctorTeamMemberHealthy.getMemberCode());
|
|
|
}
|
|
|
ct.setDoctor(doctorTeamMemberHealthy.getMemberCode());
|
|
|
}
|
|
|
// 设置家庭医生
|
|
|
// 设置家庭医生
|
|
|
|
|
|
ct.setAdminTeamId(sc.getAdminTeamId());
|
|
|
} else if (ct.getType() == 2) {
|
|
|
// 咨询家庭医生
|
|
|
SignFamily sf = signFamilyDao.findByjiatingPatient(patient);
|
|
|
ct.setAdminTeamId(sc.getAdminTeamId());
|
|
|
} else if (ct.getType() == 2) {
|
|
|
// 咨询家庭医生
|
|
|
SignFamily sf = signFamilyDao.findByjiatingPatient(patient);
|
|
|
|
|
|
if (sf == null) {
|
|
|
// 不存在家庭签约
|
|
|
return -1;
|
|
|
}
|
|
|
ct.setTeam(sf.getTeamCode());
|
|
|
// 设置健康管理师,家庭医生咨询默认给健康管理师处理
|
|
|
//查找病人所在的团队
|
|
|
//1.3.3.2 更改从签约记录判断团队成员,分配建管师
|
|
|
if(StringUtils.isNotBlank(sf.getDoctorHealth())) {
|
|
|
users.put(sf.getDoctorHealth(), 0);
|
|
|
ct.setDoctor(sf.getDoctorHealth());
|
|
|
if (StringUtils.isNotBlank(sf.getDoctor())) {
|
|
|
if (users.isNull(sf.getDoctor())) {
|
|
|
users.put(sf.getDoctor(), 1);
|
|
|
}
|
|
|
if (sf == null) {
|
|
|
// 不存在家庭签约
|
|
|
return -1;
|
|
|
}
|
|
|
ct.setTeam(sf.getTeamCode());
|
|
|
// 设置健康管理师,家庭医生咨询默认给健康管理师处理
|
|
|
//查找病人所在的团队
|
|
|
//1.3.3.2 更改从签约记录判断团队成员,分配建管师
|
|
|
if(StringUtils.isNotBlank(sf.getDoctorHealth())) {
|
|
|
users.put(sf.getDoctorHealth(), 0);
|
|
|
ct.setDoctor(sf.getDoctorHealth());
|
|
|
if (StringUtils.isNotBlank(sf.getDoctor())) {
|
|
|
if (users.isNull(sf.getDoctor())) {
|
|
|
users.put(sf.getDoctor(), 1);
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
ct.setDoctor(sf.getDoctor());
|
|
|
users.put(sf.getDoctor(), 0);
|
|
|
}
|
|
|
} else {
|
|
|
ct.setDoctor(sf.getDoctor());
|
|
|
users.put(sf.getDoctor(), 0);
|
|
|
}
|
|
|
|
|
|
// DoctorTeam doctorTeam = doctorTeamDao.findByParientCode(patient);
|
|
|
// //得到团队的健康管理师
|
|
@ -765,64 +767,68 @@ public class ConsultTeamService extends ConsultService {
|
|
|
// ct.setDoctor(doctorTeamMemberHealthy.getMemberCode());
|
|
|
// }
|
|
|
|
|
|
// 设置家庭医生
|
|
|
ct.setAdminTeamId(sf.getAdminTeamId());
|
|
|
}
|
|
|
// 设置患者信息
|
|
|
ct.setPatient(patient);
|
|
|
// 查询患者信息
|
|
|
Patient tempPatient = patientDao.findByCode(patient);
|
|
|
// 设置患者姓名
|
|
|
ct.setName(tempPatient.getName());
|
|
|
// 设置患者生日
|
|
|
ct.setBirthday(tempPatient.getBirthday());
|
|
|
//新增性别
|
|
|
ct.setSex(tempPatient.getSex());
|
|
|
// 设置患者头像
|
|
|
ct.setPhoto(tempPatient.getPhoto());
|
|
|
// 设置操作日期
|
|
|
ct.setCzrq(new Date());
|
|
|
ct.setDel("1");
|
|
|
ct.setStatus(0);
|
|
|
// 医生未读数量为1
|
|
|
ct.setDoctorRead(1);
|
|
|
// 添加咨询记录
|
|
|
Consult consult = addConsult(ct.getPatient(), null, ct.getSymptoms(), ct.getImages(), ct.getType());
|
|
|
// 设置关联指导
|
|
|
consult.setGuidance(ct.getGuidance());
|
|
|
// 设置咨询标识
|
|
|
ct.setConsult(consult.getCode());
|
|
|
// 设置家庭医生
|
|
|
ct.setAdminTeamId(sf.getAdminTeamId());
|
|
|
}
|
|
|
// 设置患者信息
|
|
|
ct.setPatient(patient);
|
|
|
// 查询患者信息
|
|
|
Patient tempPatient = patientDao.findByCode(patient);
|
|
|
// 设置患者姓名
|
|
|
ct.setName(tempPatient.getName());
|
|
|
// 设置患者生日
|
|
|
ct.setBirthday(tempPatient.getBirthday());
|
|
|
//新增性别
|
|
|
ct.setSex(tempPatient.getSex());
|
|
|
// 设置患者头像
|
|
|
ct.setPhoto(tempPatient.getPhoto());
|
|
|
// 设置操作日期
|
|
|
ct.setCzrq(new Date());
|
|
|
ct.setDel("1");
|
|
|
ct.setStatus(0);
|
|
|
// 医生未读数量为1
|
|
|
ct.setDoctorRead(1);
|
|
|
// 添加咨询记录
|
|
|
Consult consult = addConsult(ct.getPatient(), null, ct.getSymptoms(), ct.getImages(), ct.getType());
|
|
|
// 设置关联指导
|
|
|
consult.setGuidance(ct.getGuidance());
|
|
|
// 设置咨询标识
|
|
|
ct.setConsult(consult.getCode());
|
|
|
|
|
|
//推送给IM去创建议题,取得成员消息
|
|
|
//推送给IM去创建议题,取得成员消息
|
|
|
// JSONObject messages = ImUtill.getCreateTopicMessage(patient, tempPatient.getName(), consult.getTitle(), "咨询问题:"+consult.getSymptoms(), consult.getImages());
|
|
|
JSONObject messages = ImUtill.getCreateTopicMessage(patient, tempPatient.getName(), consult.getTitle(), consult.getSymptoms(), consult.getImages(),agent);
|
|
|
users.put(patient, 0);//+ " "+(tempPatient.getSex()==1?"(男 ":"(女 ") + IdCardUtil.getAgeForIdcard(tempPatient.getIdcard())+")"
|
|
|
JSONObject obj = ImUtill.createTopics(patient + "_" + ct.getTeam() + "_" + ct.getType(), consult.getCode(), tempPatient.getName(), users, messages, ImUtill.SESSION_TYPE_MUC);
|
|
|
if (obj == null) {
|
|
|
throw new RuntimeException("IM消息发送异常!");
|
|
|
}
|
|
|
ct.setStartMsgId(obj.get("start_msg_id").toString());
|
|
|
consultTeamDao.save(ct);
|
|
|
consultDao.save(consult);
|
|
|
for (String key : users.keySet()) {
|
|
|
if (patient.equals(key)) {
|
|
|
continue;
|
|
|
JSONObject messages = ImUtill.getCreateTopicMessage(patient, tempPatient.getName(), consult.getTitle(), consult.getSymptoms(), consult.getImages(),agent);
|
|
|
users.put(patient, 0);//+ " "+(tempPatient.getSex()==1?"(男 ":"(女 ") + IdCardUtil.getAgeForIdcard(tempPatient.getIdcard())+")"
|
|
|
JSONObject obj = ImUtill.createTopics(patient + "_" + ct.getTeam() + "_" + ct.getType(), consult.getCode(), tempPatient.getName(), users, messages, ImUtill.SESSION_TYPE_MUC);
|
|
|
if (obj == null) {
|
|
|
throw new RuntimeException("IM消息发送异常!");
|
|
|
}
|
|
|
if(obj.getInt("status")==-1){//im议题创建失败
|
|
|
throw new RuntimeException(obj.getString("message"));
|
|
|
}
|
|
|
ct.setStartMsgId(obj.get("start_msg_id").toString());
|
|
|
consultTeamDao.save(ct);
|
|
|
consultDao.save(consult);
|
|
|
for (String key : users.keySet()) {
|
|
|
if (patient.equals(key)) {
|
|
|
continue;
|
|
|
}
|
|
|
//记录咨询的医生详情误删
|
|
|
ConsultTeamDoctor cd = new ConsultTeamDoctor();
|
|
|
cd.setConsult(consult.getCode());
|
|
|
cd.setDel("1");
|
|
|
cd.setCzrq(new Date());
|
|
|
cd.setTo(key);
|
|
|
consultTeamDoctorDao.save(cd);
|
|
|
}
|
|
|
//记录咨询的医生详情误删
|
|
|
ConsultTeamDoctor cd = new ConsultTeamDoctor();
|
|
|
cd.setConsult(consult.getCode());
|
|
|
cd.setDel("1");
|
|
|
cd.setCzrq(new Date());
|
|
|
cd.setTo(key);
|
|
|
consultTeamDoctorDao.save(cd);
|
|
|
}
|
|
|
|
|
|
// 保存医生咨询信息
|
|
|
// 添加咨询转发记录
|
|
|
// 添加医生咨询日志
|
|
|
String content = addLogs(ct);
|
|
|
// 保存医生咨询信息
|
|
|
// 添加咨询转发记录
|
|
|
// 添加医生咨询日志
|
|
|
String content = addLogs(ct);
|
|
|
|
|
|
return 1;
|
|
|
return 1;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|