|
@ -677,11 +677,11 @@ public class ConsultTeamService extends ConsultService {
|
|
|
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){
|
|
|
users.put(doctorTeamMember.getMemberCode(),1);
|
|
|
users.put(doctorTeamMember.getMemberCode(), 0);
|
|
|
} else {
|
|
|
users.put(doctorTeamMemberHealthy.getMemberCode(), 0);
|
|
|
if (doctorTeamMember != null) {
|
|
|
users.put(doctorTeamMember.getMemberCode(), 1);
|
|
|
}
|
|
|
ct.setDoctor(doctorTeamMemberHealthy.getMemberCode());
|
|
|
}
|
|
@ -703,11 +703,11 @@ public class ConsultTeamService extends ConsultService {
|
|
|
DoctorTeamMember doctorTeamMember = doctorTeamDoctor.findDoctorJiating2ByTeam(doctorTeam.getCode(), 2);
|
|
|
if (doctorTeamMemberHealthy == null) {
|
|
|
ct.setDoctor(doctorTeamMember.getMemberCode());
|
|
|
users.put(doctorTeamMember.getMemberCode(),0);
|
|
|
}else{
|
|
|
users.put(doctorTeamMemberHealthy.getMemberCode(),0);
|
|
|
if(doctorTeamMember!=null){
|
|
|
users.put(doctorTeamMember.getMemberCode(),1);
|
|
|
users.put(doctorTeamMember.getMemberCode(), 0);
|
|
|
} else {
|
|
|
users.put(doctorTeamMemberHealthy.getMemberCode(), 0);
|
|
|
if (doctorTeamMember != null) {
|
|
|
users.put(doctorTeamMember.getMemberCode(), 1);
|
|
|
}
|
|
|
ct.setDoctor(doctorTeamMemberHealthy.getMemberCode());
|
|
|
}
|
|
@ -748,10 +748,10 @@ public class ConsultTeamService extends ConsultService {
|
|
|
// 添加医生咨询日志
|
|
|
String content = addLogs(ct);
|
|
|
//推送给IM去创建议题,取得成员消息
|
|
|
JSONObject messages = ImUtill.getCreateTopicMessage(patient,tempPatient.getName(),consult.getTitle(),consult.getSymptoms(),consult.getImages());
|
|
|
users.put(patient,0);
|
|
|
JSONObject obj = ImUtill.createTopics(patient+"_consult_"+ct.getType(),consult.getCode(),tempPatient.getName()+" "+IdCardUtil.getAgeForIdcard(tempPatient.getIdcard()),users,messages,"1");
|
|
|
if(obj==null){
|
|
|
JSONObject messages = ImUtill.getCreateTopicMessage(patient, tempPatient.getName(), consult.getTitle(), consult.getSymptoms(), consult.getImages());
|
|
|
users.put(patient, 0);
|
|
|
JSONObject obj = ImUtill.createTopics(patient + "_consult_" + ct.getType(), consult.getCode(), tempPatient.getName() + " " + IdCardUtil.getAgeForIdcard(tempPatient.getIdcard()), users, messages, "1");
|
|
|
if (obj == null) {
|
|
|
throw new RuntimeException("IM消息结束异常!");
|
|
|
}
|
|
|
ct.setStartMsgId(obj.get("start_msg_id").toString());
|
|
@ -954,7 +954,7 @@ public class ConsultTeamService extends ConsultService {
|
|
|
throw new Exception("send consult finished IM message failed");
|
|
|
} else {
|
|
|
JSONObject jo = new JSONObject(returnJson); //设置消息ID
|
|
|
consultTeam.setEndMsgId(jo.getInt("startId")+"");
|
|
|
consultTeam.setEndMsgId(jo.getInt("startId") + "");
|
|
|
consultTeam.setEndOperator(endOperator);
|
|
|
consultTeam.setEndType(endType);
|
|
|
}
|
|
@ -1217,7 +1217,7 @@ public class ConsultTeamService extends ConsultService {
|
|
|
;
|
|
|
JSONObject jo = new JSONObject(returnJson);
|
|
|
//设置消息ID
|
|
|
ct.setStartMsgId(jo.getInt("startId")+"");
|
|
|
ct.setStartMsgId(jo.getInt("startId") + "");
|
|
|
//推送给IM图片
|
|
|
if (StringUtils.isNotEmpty(ct.getImages())) {
|
|
|
String[] images = ct.getImages().split(",");
|
|
@ -1289,6 +1289,7 @@ public class ConsultTeamService extends ConsultService {
|
|
|
public List<ConsultTeamLog> getConsultLog(String consultCode) {
|
|
|
return consultTeamLogDao.getConsultLogByConsultLog(consultCode);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @param ct
|
|
|
* @param uid
|
|
@ -1329,10 +1330,10 @@ public class ConsultTeamService extends ConsultService {
|
|
|
//推送给IM文字消息
|
|
|
String returnJson = null;
|
|
|
JSONObject jo;
|
|
|
if(StringUtils.isNotEmpty(oldConsultCode)){
|
|
|
ConsultTeam oldConsult = consultTeamDao.findByConsult(oldConsultCode);
|
|
|
if(oldConsult!=null){
|
|
|
returnJson = sendIM(ct.getPatient(), ct.getDoctor(), "6", "居民问题:" +oldConsult.getSymptoms());
|
|
|
if (StringUtils.isNotEmpty(oldConsultCode)) {
|
|
|
ConsultTeam oldConsult = consultTeamDao.findByConsult(oldConsultCode);
|
|
|
if (oldConsult != null) {
|
|
|
returnJson = sendIM(ct.getPatient(), ct.getDoctor(), "6", "居民问题:" + oldConsult.getSymptoms());
|
|
|
//推送给IM图片
|
|
|
if (StringUtils.isNotEmpty(oldConsult.getImages())) {
|
|
|
String[] images = oldConsult.getImages().split(",");
|
|
@ -1344,13 +1345,13 @@ public class ConsultTeamService extends ConsultService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if(StringUtils.isEmpty(returnJson))
|
|
|
if (StringUtils.isEmpty(returnJson))
|
|
|
returnJson = sendIM(ct.getPatient(), ct.getDoctor(), "6", content);
|
|
|
else
|
|
|
sendIM(ct.getPatient(), ct.getDoctor(), "6", content);
|
|
|
jo = new JSONObject(returnJson);
|
|
|
//设置消息ID
|
|
|
ct.setStartMsgId(jo.getInt("startId")+"");
|
|
|
ct.setStartMsgId(jo.getInt("startId") + "");
|
|
|
//推送给IM图片
|
|
|
if (StringUtils.isNotEmpty(ct.getImages())) {
|
|
|
String[] images = ct.getImages().split(",");
|
|
@ -1373,10 +1374,10 @@ public class ConsultTeamService extends ConsultService {
|
|
|
public void sendForHelpMsg(ConsultTeam ct, String uid, String oldConsultCode) throws Exception {
|
|
|
ct.setPatient(uid);
|
|
|
//推送给IM文字消息
|
|
|
if(StringUtils.isNotEmpty(oldConsultCode)){
|
|
|
ConsultTeam oldConsult = consultTeamDao.findByConsult(oldConsultCode);
|
|
|
if(oldConsult!=null){
|
|
|
sendIM(ct.getPatient(), ct.getDoctor(), "6", "居民问题:" +oldConsult.getSymptoms());
|
|
|
if (StringUtils.isNotEmpty(oldConsultCode)) {
|
|
|
ConsultTeam oldConsult = consultTeamDao.findByConsult(oldConsultCode);
|
|
|
if (oldConsult != null) {
|
|
|
sendIM(ct.getPatient(), ct.getDoctor(), "6", "居民问题:" + oldConsult.getSymptoms());
|
|
|
//推送给IM图片
|
|
|
if (StringUtils.isNotEmpty(oldConsult.getImages())) {
|
|
|
String[] images = oldConsult.getImages().split(",");
|
|
@ -1388,7 +1389,7 @@ public class ConsultTeamService extends ConsultService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
sendIM(ct.getPatient(), ct.getDoctor(), "6", "咨询问题:"+ ct.getSymptoms());
|
|
|
sendIM(ct.getPatient(), ct.getDoctor(), "6", "咨询问题:" + ct.getSymptoms());
|
|
|
//推送给IM图片
|
|
|
if (StringUtils.isNotEmpty(ct.getImages())) {
|
|
|
String[] images = ct.getImages().split(",");
|
|
@ -1410,73 +1411,76 @@ public class ConsultTeamService extends ConsultService {
|
|
|
|
|
|
/**
|
|
|
* 判断两医生是否在同一团队内
|
|
|
*
|
|
|
* @param docCode1
|
|
|
* @param docCode2
|
|
|
* @return
|
|
|
*/
|
|
|
public boolean isCommonTeam(String docCode1, String docCode2){
|
|
|
public boolean isCommonTeam(String docCode1, String docCode2) {
|
|
|
String sqlQuSum =
|
|
|
"SELECT c.team_id FROM " +
|
|
|
"(SELECT a.* FROM wlyy_admin_team_member a where a.doctor_code='"+ docCode1 +"' ) c " +
|
|
|
"(SELECT a.* FROM wlyy_admin_team_member a where a.doctor_code='" + docCode1 + "' ) c " +
|
|
|
"LEFT JOIN " +
|
|
|
"(SELECT b.* FROM wlyy_admin_team_member b where b.doctor_code='"+ docCode2 +"' ) d " +
|
|
|
"(SELECT b.* FROM wlyy_admin_team_member b where b.doctor_code='" + docCode2 + "' ) d " +
|
|
|
"on c.team_id=d.team_id " +
|
|
|
"WHERE d.team_id IS NOT NULL";
|
|
|
List ls = jdbcTemplate.queryForList(sqlQuSum);
|
|
|
return ls!=null && ls.size()>0;
|
|
|
return ls != null && ls.size() > 0;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 通过team获取医生code
|
|
|
*
|
|
|
* @param consult 关联的上一个咨询
|
|
|
* @return
|
|
|
*/
|
|
|
public List findByTeam(String consult){
|
|
|
public List findByTeam(String consult) {
|
|
|
return consultTeamDao.findByTeamAndType(consult, 10);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 全科医生求助专科医生(同团队)
|
|
|
*
|
|
|
* @param ct
|
|
|
* @param uid
|
|
|
* @param oldConsultCode
|
|
|
* @param isSend 是否转发患者咨询内容
|
|
|
* @param isSend 是否转发患者咨询内容
|
|
|
*/
|
|
|
public void addSeekHelpTeam(ConsultTeam ct, String uid,String oldConsultCode,int isSend){
|
|
|
public void addSeekHelpTeam(ConsultTeam ct, String uid, String oldConsultCode, int isSend) {
|
|
|
ct.setPatient(uid);
|
|
|
//推送给IM文字消息
|
|
|
JSONObject participants = new JSONObject();
|
|
|
participants.put(ct.getPatient(),0);
|
|
|
participants.put(ct.getDoctor(),0);
|
|
|
participants.put(ct.getPatient(), 0);
|
|
|
participants.put(ct.getDoctor(), 0);
|
|
|
Doctor doctor = doctorService.findDoctorByCode(uid);
|
|
|
JSONObject sessionJson = ImUtill.createSession(participants,"2",doctor.getName()+"发起求助!","");
|
|
|
if(sessionJson.getInt("status")==-1){
|
|
|
throw new RuntimeException(sessionJson.getString("message"));
|
|
|
JSONObject sessionJson = ImUtill.createSession(participants, "2", doctor.getName() + "发起求助!", "");
|
|
|
if (sessionJson.getInt("status") == -1) {
|
|
|
throw new RuntimeException(sessionJson.getString("message"));
|
|
|
}
|
|
|
JSONObject session = sessionJson.getJSONObject("data");
|
|
|
if(StringUtils.isNotEmpty(oldConsultCode)){
|
|
|
if (StringUtils.isNotEmpty(oldConsultCode)) {
|
|
|
ct.setTeam(oldConsultCode);
|
|
|
ConsultTeam oldConsult = consultTeamDao.findByConsult(oldConsultCode);
|
|
|
if(oldConsult!=null&&isSend==1){
|
|
|
ImUtill.sendImMsg(ct.getPatient(), ct.getDoctor(), session.getString("id"),"1","居民问题:" +oldConsult.getSymptoms(),"1");
|
|
|
ConsultTeam oldConsult = consultTeamDao.findByConsult(oldConsultCode);
|
|
|
if (oldConsult != null && isSend == 1) {
|
|
|
ImUtill.sendImMsg(ct.getPatient(), ct.getDoctor(), session.getString("id"), "1", "居民问题:" + oldConsult.getSymptoms(), "1");
|
|
|
//推送给IM图片
|
|
|
if (StringUtils.isNotEmpty(oldConsult.getImages())) {
|
|
|
String[] images = oldConsult.getImages().split(",");
|
|
|
for (String image : images) {
|
|
|
if (StringUtils.isNoneEmpty(image)) {
|
|
|
ImUtill.sendImMsg(ct.getPatient(), ct.getDoctor(), session.getString("id"), "2",image,"1");
|
|
|
ImUtill.sendImMsg(ct.getPatient(), ct.getDoctor(), session.getString("id"), "2", image, "1");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
ImUtill.sendImMsg(ct.getPatient(), ct.getDoctor(), session.getString("id"),"1","咨询问题:"+ ct.getSymptoms(),"1");
|
|
|
ImUtill.sendImMsg(ct.getPatient(), ct.getDoctor(), session.getString("id"), "1", "咨询问题:" + ct.getSymptoms(), "1");
|
|
|
//推送给IM图片
|
|
|
if (StringUtils.isNotEmpty(ct.getImages())) {
|
|
|
String[] images = ct.getImages().split(",");
|
|
|
for (String image : images) {
|
|
|
if (StringUtils.isNoneEmpty(image)) {
|
|
|
ImUtill.sendImMsg(ct.getPatient(), ct.getDoctor(), session.getString("id"), "2",image,"1");
|
|
|
ImUtill.sendImMsg(ct.getPatient(), ct.getDoctor(), session.getString("id"), "2", image, "1");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@ -1484,11 +1488,12 @@ public class ConsultTeamService extends ConsultService {
|
|
|
|
|
|
/**
|
|
|
* 全科医生求助专科医生(不同团队)
|
|
|
*
|
|
|
* @param ct
|
|
|
* @param uid
|
|
|
* @param oldConsultCode
|
|
|
*/
|
|
|
public void addSeekHelpOtherTeam(ConsultTeam ct, String uid,String oldConsultCode,int isSend) throws Exception{
|
|
|
public void addSeekHelpOtherTeam(ConsultTeam ct, String uid, String oldConsultCode, int isSend) throws Exception {
|
|
|
// 设置患者信息
|
|
|
ct.setPatient(uid);
|
|
|
Doctor doctorTemp = doctorDao.findByCode(uid);
|
|
@ -1521,7 +1526,7 @@ public class ConsultTeamService extends ConsultService {
|
|
|
cd.setTo(ct.getDoctor());
|
|
|
// 添加医生咨询日志
|
|
|
String content = addLogs(ct);
|
|
|
if(StringUtils.isBlank(oldConsultCode)) {
|
|
|
if (StringUtils.isBlank(oldConsultCode)) {
|
|
|
JSONObject messages = ImUtill.getCreateTopicMessage(doctorTemp.getCode(), doctorTemp.getName(), consult.getTitle(), content, consult.getImages());
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put(ct.getPatient(), 0);
|
|
@ -1532,11 +1537,11 @@ public class ConsultTeamService extends ConsultService {
|
|
|
throw new RuntimeException("im消息创建异常!" + obj == null ? "" : obj.getString("message"));
|
|
|
}
|
|
|
ct.setStartMsgId(obj.get("start_msg_id").toString());
|
|
|
}else{
|
|
|
} else {
|
|
|
//转发咨询问题
|
|
|
Consult oldConsult = consultDao.findByCode(oldConsultCode);
|
|
|
ct.setTeam(oldConsultCode);
|
|
|
if(oldConsult!=null&&isSend==1){
|
|
|
if (oldConsult != null && isSend == 1) {
|
|
|
JSONObject messages = ImUtill.getCreateTopicMessage(doctorTemp.getCode(), doctorTemp.getName(), consult.getTitle(), oldConsult.getSymptoms(), oldConsult.getImages());
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put(ct.getPatient(), 0);
|
|
@ -1546,27 +1551,27 @@ public class ConsultTeamService extends ConsultService {
|
|
|
throw new RuntimeException("im消息创建异常!" + obj == null ? "" : obj.getString("message"));
|
|
|
}
|
|
|
ct.setStartMsgId(obj.get("start_msg_id").toString());
|
|
|
ImUtill.sendTopicIM(doctorTemp.getCode(),doctorTemp.getName(),consult.getCode(),"6",content);
|
|
|
if(StringUtils.isNotBlank(consult.getImages())){
|
|
|
ImUtill.sendTopicIM(doctorTemp.getCode(), doctorTemp.getName(), consult.getCode(), "6", content);
|
|
|
if (StringUtils.isNotBlank(consult.getImages())) {
|
|
|
String imgs[] = consult.getImages().split(",");
|
|
|
for(String url :imgs)
|
|
|
ImUtill.sendTopicIM(doctorTemp.getCode(),doctorTemp.getName(),consult.getCode(),"2",url);
|
|
|
for (String url : imgs)
|
|
|
ImUtill.sendTopicIM(doctorTemp.getCode(), doctorTemp.getName(), consult.getCode(), "2", url);
|
|
|
}
|
|
|
}
|
|
|
JSONObject qiuzuObj = new JSONObject();
|
|
|
qiuzuObj.put("session_id",oldConsult.getPatient()+"_consult_"+consult.getType());
|
|
|
qiuzuObj.put("patient",ct.getPatient());
|
|
|
qiuzuObj.put("old_consult_code",oldConsultCode);
|
|
|
qiuzuObj.put("doctor",ct.getDoctor());
|
|
|
qiuzuObj.put("doctor_name",doctor.getName());
|
|
|
ImUtill.sendTopicIM(doctorTemp.getCode(),doctorTemp.getName(),oldConsultCode,"5",qiuzuObj.toString());
|
|
|
qiuzuObj.put("session_id", oldConsult.getPatient() + "_consult_" + consult.getType());
|
|
|
qiuzuObj.put("patient", ct.getPatient());
|
|
|
qiuzuObj.put("old_consult_code", oldConsultCode);
|
|
|
qiuzuObj.put("doctor", ct.getDoctor());
|
|
|
qiuzuObj.put("doctor_name", doctor.getName());
|
|
|
ImUtill.sendTopicIM(doctorTemp.getCode(), doctorTemp.getName(), oldConsultCode, "5", qiuzuObj.toString());
|
|
|
}
|
|
|
consultTeamDao.save(ct); // 保存医生咨询信息
|
|
|
consultTeamDoctorDao.save(cd);
|
|
|
consultDao.save(consult);
|
|
|
}
|
|
|
|
|
|
public int finishConsult(String consult, String endOperator, int endType){
|
|
|
public int finishConsult(String consult, String endOperator, int endType) {
|
|
|
ConsultTeam consultTeam = consultTeamDao.findByConsult(consult);
|
|
|
String endName = "";
|
|
|
String endId = "";
|
|
@ -1576,15 +1581,20 @@ public class ConsultTeamService extends ConsultService {
|
|
|
endName = p.getName();
|
|
|
endId = p.getCode();
|
|
|
} else {
|
|
|
Doctor d = doctorDao.findByCode(endOperator);
|
|
|
endId = d.getCode();
|
|
|
endName = d.getName();
|
|
|
if (endOperator.equals("admin")) {
|
|
|
endId = "system";
|
|
|
endName = "system";
|
|
|
} else {
|
|
|
Doctor d = doctorDao.findByCode(endOperator);
|
|
|
endId = d.getCode();
|
|
|
endName = d.getName();
|
|
|
}
|
|
|
}
|
|
|
JSONObject obj = ImUtill.endTopics(consultTeam.getPatient(),endId,endName,consultTeam.getConsult());
|
|
|
if(obj==null){
|
|
|
JSONObject obj = ImUtill.endTopics(consultTeam.getPatient(), endId, endName, consultTeam.getConsult());
|
|
|
if (obj == null) {
|
|
|
throw new RuntimeException("IM消息结束异常!");
|
|
|
}
|
|
|
if(obj.getInt("status")==-1){
|
|
|
if (obj.getInt("status") == -1) {
|
|
|
throw new RuntimeException(String.valueOf(obj.get("message")));
|
|
|
}
|
|
|
consultTeam.setType(endType);
|
|
@ -1595,6 +1605,7 @@ public class ConsultTeamService extends ConsultService {
|
|
|
|
|
|
/**
|
|
|
* 新增名医咨询
|
|
|
*
|
|
|
* @param ct
|
|
|
* @param uid
|
|
|
* @param type 1患者 2医生
|
|
@ -1603,8 +1614,8 @@ public class ConsultTeamService extends ConsultService {
|
|
|
public void famousConsult(ConsultTeam ct, String uid, String type) throws Exception {
|
|
|
// 设置患者信息
|
|
|
ct.setPatient(uid);
|
|
|
String senderId="";
|
|
|
String senderName="";
|
|
|
String senderId = "";
|
|
|
String senderName = "";
|
|
|
if ("1".equals(type)) {
|
|
|
// 查询患者信息
|
|
|
Patient tempPatient = patientDao.findByCode(uid);
|
|
@ -1658,16 +1669,16 @@ public class ConsultTeamService extends ConsultService {
|
|
|
String content = addLogs(ct);
|
|
|
//推送给IM文字消息
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put(ct.getPatient(),0);
|
|
|
jsonObject.put(ct.getDoctor(),0);
|
|
|
jsonObject.put(ct.getPatient(), 0);
|
|
|
jsonObject.put(ct.getDoctor(), 0);
|
|
|
|
|
|
JSONObject messages = ImUtill.getCreateTopicMessage(senderId,senderName,senderName+"发起咨询",content,ct.getImages());
|
|
|
JSONObject messages = ImUtill.getCreateTopicMessage(senderId, senderName, senderName + "发起咨询", content, ct.getImages());
|
|
|
|
|
|
JSONObject obj = ImUtill.createTopics(null,consult.getCode(),consult.getSymptoms(),jsonObject,messages,"2");
|
|
|
if(obj==null){
|
|
|
JSONObject obj = ImUtill.createTopics(null, consult.getCode(), consult.getSymptoms(), jsonObject, messages, "2");
|
|
|
if (obj == null) {
|
|
|
throw new RuntimeException("im消息创建异常!");
|
|
|
}
|
|
|
if(obj.getInt("status")==-1){
|
|
|
if (obj.getInt("status") == -1) {
|
|
|
throw new RuntimeException(obj.getString("message"));
|
|
|
}
|
|
|
//设置消息ID
|