Browse Source

Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev

# Conflicts:
#	svr/svr-iot/src/main/java/com/yihu/iot/service/monitorPlatform/MonitorPlatformService.java
wangzhinan 4 năm trước cách đây
mục cha
commit
360cb217f7

+ 5 - 2
business/im-service/src/main/java/com/yihu/jw/im/dao/ConsultDao.java

@ -2,6 +2,7 @@ package com.yihu.jw.im.dao;
import com.yihu.jw.entity.base.im.ConsultDo;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
@ -11,8 +12,8 @@ import org.springframework.data.repository.PagingAndSortingRepository;
 */
public interface ConsultDao extends PagingAndSortingRepository<ConsultDo, String>, JpaSpecificationExecutor<ConsultDo> {
	
//	@Query("from ConsultDo a where a.relationCode = ?1")
//	ConsultDo findByRelationCode(String outpatientid);
	@Query("from ConsultDo a where a.relationCode = ?1")
	ConsultDo findByRelationCode(String outpatientid);
//	// 查询患者咨询记录
//	Page<Object> findByPatient(String patient, String title, String id, PageRequest pageRequest);
@ -27,4 +28,6 @@ public interface ConsultDao extends PagingAndSortingRepository<ConsultDo, String
//	// 查询患者咨询记录
//	@Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status,b.doctor,b.team,b.evaluate,a.signCode  from ConsultDo a,ConsultTeamDo b where a.code = b.consult and a.patient = ?1 and a.del = '1' and a.type<>8 order by a.czrq desc")
//	Page<Object> findByPatient(String patient, Pageable pageRequest);
}

+ 258 - 118
business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java

@ -1153,129 +1153,131 @@ public class ImService {
			jsonObject.put("age",DateUtil.getAgeForIdcard(p.getIdcard()));
			jsonObject.put("sex",p.getSex());
			jsonObject.put("name",p.getName());
			
			//4、创建咨询
			JSONObject users = new JSONObject();//咨询参与者
			
			String consultTitle = "";
			//协同门诊
			if("2".equals(wlyyOutpatientDO.getOutpatientType())){
				users.put(wlyyOutpatientDO.getGeneralDoctor(),0);
				ct.setType(12);
				consultTitle = "申请协同门诊";
				
				JSONObject consultName = new JSONObject();
				consultName.put("patientName",p.getName());
				consultName.put("doctorName",doctor.getName());
				jsonObject.put("name",consultName.toJSONString());
			}else{
				users.put(patient, 0);
				consultTitle = "申请复诊";
			}
			
			String content = jsonObject.toString();
			
			users.put(doctorCode, 0);
			//关联业务code
			ct.setRelationCode(outpatientCode);
			//医生信息
			ct.setDoctor(doctorCode);
			ct.setDoctorName(doctor.getName());
			// 设置患者信息
			ct.setPatient(patient);
			ct.setSymptoms(wlyyOutpatientDO.getDescription());
			
			// 设置患者姓名
			ct.setName(p.getName());
			// 设置患者生日
			ct.setBirthday(p.getBirthday());
			//新增性别
			ct.setSex(p.getSex());
			// 设置患者头像
			ct.setPhoto(p.getPhoto());
			// 设置操作日期
			ct.setCzrq(new Date());
			ct.setDel("1");
			ct.setStatus(0);
			ct.setEvaluate(0);
			// 医生未读数量为1
			ct.setDoctorRead(1);
			//添加就诊图片
			ct.setImages(wlyyOutpatientDO.getDiseaseImg());
			// 添加咨询记录
			ConsultDo consult = addConsult(ct.getPatient(), consultTitle, ct.getSymptoms(), ct.getImages(), ct.getType());
			// 设置关联指导
			consult.setGuidance(ct.getGuidance());
			//关联业务code
			consult.setRelationCode(outpatientCode);
			//支付状态为1
			consult.setPayStatus(1);
			// 设置咨询标识
			ct.setConsult(consult.getId());
			
			//推送给IM去创建议题,取得成员消息
			
			JSONObject messages =  new JSONObject();
			JSONObject obj = new JSONObject();
			String sessionId = "";
			//协同门诊
			if("2".equals(wlyyOutpatientDO.getOutpatientType())){
				BaseDoctorDO generalDoctor = baseDoctorDao.findById(wlyyOutpatientDO.getGeneralDoctor());
				messages = imUtil.getCreateTopicMessage(generalDoctor.getId(),generalDoctor.getName(), consult.getTitle(), content, consult.getImages(), doctorCode);
				//5、(im创建咨询) 续方咨询的sessionid为居民code+就诊code+12(图文,视频,图文+视频)
				sessionId = patient + "_" + outpatientCode + "_" + ct.getType();
				obj = imUtil.createTopics(sessionId, consult.getId(), p.getName(), users, messages, imUtil.SESSION_TYPE_COLLABORATION_HOSPITAL);
				
			}else{
				messages = imUtil.getCreateTopicMessage(patient, p.getName(), consult.getTitle(), content, consult.getImages(), doctorCode);
				//5、(im创建咨询) 续方咨询的sessionid为居民code+就诊code+9(图文,视频,图文+视频)
				sessionId = patient + "_" + outpatientCode + "_" + ct.getType();
				
				if(1== type){
					//图文复诊
					obj = imUtil.createTopics(sessionId, consult.getId(), p.getName(), users, messages, imUtil.SESSION_TYPE_EXAMINATION);
			ConsultDo consultDo = consultDao.findByRelationCode(outpatientCode);
			if (consultDo==null){
				//4、创建咨询
				JSONObject users = new JSONObject();//咨询参与者
				String consultTitle = "";
				//协同门诊
				if("2".equals(wlyyOutpatientDO.getOutpatientType())){
					users.put(wlyyOutpatientDO.getGeneralDoctor(),0);
					ct.setType(12);
					consultTitle = "申请协同门诊";
					JSONObject consultName = new JSONObject();
					consultName.put("patientName",p.getName());
					consultName.put("doctorName",doctor.getName());
					jsonObject.put("name",consultName.toJSONString());
				}else{
					//视频复诊+图文复诊
					obj = imUtil.createTopics(sessionId, consult.getId(), p.getName(), users, messages, imUtil.SESSION_TYPE_EXAMINATION_VIDEO);
					users.put(patient, 0);
					consultTitle = "申请复诊";
				}
				
			}
			
			
				String content = jsonObject.toString();
			if (obj == null) {
				throw new RuntimeException("IM消息发送异常!");
			}
			if (obj.getInteger("status") == -1) {//im议题创建失败
				throw new RuntimeException(obj.getString("message"));
			}
			ct.setStartMsgId(obj.get("start_msg_id").toString());
			consultTeamDao.save(ct);
			consultDao.save(consult);
			
			//设置咨询code
				users.put(doctorCode, 0);
				//关联业务code
				ct.setRelationCode(outpatientCode);
				//医生信息
				ct.setDoctor(doctorCode);
				ct.setDoctorName(doctor.getName());
				// 设置患者信息
				ct.setPatient(patient);
				ct.setSymptoms(wlyyOutpatientDO.getDescription());
				// 设置患者姓名
				ct.setName(p.getName());
				// 设置患者生日
				ct.setBirthday(p.getBirthday());
				//新增性别
				ct.setSex(p.getSex());
				// 设置患者头像
				ct.setPhoto(p.getPhoto());
				// 设置操作日期
				ct.setCzrq(new Date());
				ct.setDel("1");
				ct.setStatus(0);
				ct.setEvaluate(0);
				// 医生未读数量为1
				ct.setDoctorRead(1);
				//添加就诊图片
				ct.setImages(wlyyOutpatientDO.getDiseaseImg());
				// 添加咨询记录
				ConsultDo consult = addConsult(ct.getPatient(), consultTitle, ct.getSymptoms(), ct.getImages(), ct.getType());
				// 设置关联指导
				consult.setGuidance(ct.getGuidance());
				//关联业务code
				consult.setRelationCode(outpatientCode);
				//支付状态为1
				consult.setPayStatus(1);
				// 设置咨询标识
				ct.setConsult(consult.getId());
				//推送给IM去创建议题,取得成员消息
				JSONObject messages =  new JSONObject();
				JSONObject obj = new JSONObject();
				String sessionId = "";
				//协同门诊
				if("2".equals(wlyyOutpatientDO.getOutpatientType())){
					BaseDoctorDO generalDoctor = baseDoctorDao.findById(wlyyOutpatientDO.getGeneralDoctor());
					messages = imUtil.getCreateTopicMessage(generalDoctor.getId(),generalDoctor.getName(), consult.getTitle(), content, consult.getImages(), doctorCode);
					//5、(im创建咨询) 续方咨询的sessionid为居民code+就诊code+12(图文,视频,图文+视频)
					sessionId = patient + "_" + outpatientCode + "_" + ct.getType();
					obj = imUtil.createTopics(sessionId, consult.getId(), p.getName(), users, messages, imUtil.SESSION_TYPE_COLLABORATION_HOSPITAL);
				}else{
					messages = imUtil.getCreateTopicMessage(patient, p.getName(), consult.getTitle(), content, consult.getImages(), doctorCode);
					//5、(im创建咨询) 续方咨询的sessionid为居民code+就诊code+9(图文,视频,图文+视频)
					sessionId = patient + "_" + outpatientCode + "_" + ct.getType();
					if(1== type){
						//图文复诊
						obj = imUtil.createTopics(sessionId, consult.getId(), p.getName(), users, messages, imUtil.SESSION_TYPE_EXAMINATION);
					}else{
						//视频复诊+图文复诊
						obj = imUtil.createTopics(sessionId, consult.getId(), p.getName(), users, messages, imUtil.SESSION_TYPE_EXAMINATION_VIDEO);
					}
				}
				if (obj == null) {
					throw new RuntimeException("IM消息发送异常!");
				}
				if (obj.getInteger("status") == -1) {//im议题创建失败
					throw new RuntimeException(obj.getString("message"));
				}
				ct.setStartMsgId(obj.get("start_msg_id").toString());
				consultTeamDao.save(ct);
				consultDao.save(consult);
				//设置咨询code
//			wlyyOutpatientDO.setConsult(consult.getCode());
//			prescriptionDao.save(prescription);
			
			//6、记录咨询的医生详情
			ConsultTeamDoctorDo cd = new ConsultTeamDoctorDo();
			cd.setConsult(consult.getId());
			cd.setDel("1");
			cd.setCzrq(new Date());
			cd.setTo(doctorCode);
			consultTeamDoctorDao.save(cd);
			
			//7、发送系统消息提示团队长有未审核的消息
				//6、记录咨询的医生详情
				ConsultTeamDoctorDo cd = new ConsultTeamDoctorDo();
				cd.setConsult(consult.getId());
				cd.setDel("1");
				cd.setCzrq(new Date());
				cd.setTo(doctorCode);
				consultTeamDoctorDao.save(cd);
				//7、发送系统消息提示团队长有未审核的消息
//			addCheckMessage(prescription, sessionId, p);
			
			//8、 保存医生咨询信息
			// 添加咨询转发记录
			// 添加医生咨询日志
			addLogs(ct);
			
			JSONObject result = imUtil.getSingleSessionInfo(sessionId,doctorCode);
			
				//8、 保存医生咨询信息
				// 添加咨询转发记录
				// 添加医生咨询日志
				addLogs(ct);
			}
			String sessionIds = patient + "_" + outpatientCode + "_" + ct.getType();
			JSONObject result = imUtil.getSingleSessionInfo(sessionIds,doctorCode);
			wlyyOutpatientDO.setStatus("1");//修改就诊记录为就诊中
			wlyyOutpatientDO.setConDate(new Date());
			wlyyOutpatientDO.setDoctor(doctorCode);
@ -1312,11 +1314,149 @@ public class ImService {
				//医生接诊发送导诊护士外层消息
				this.sendOutpatientGuaidanceMessage(wlyyOutpatientDO);
			}
			
			return result;
		}
	}
	
	/**
	 * 添加复诊咨询
	 * @return
	 */
	public JSONObject addConsult(String outpatientCode, String patient,String doctorCode, ConsultTeamDo ct, String reason, Integer type,String wxId) throws Exception {
		//1、获取his就诊记录详情(保存续方表、药品续方信息表、续方疾病类型表)
		WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findOne(outpatientCode);
		BaseDoctorDO doctor = baseDoctorDao.findById(doctorCode);
//			doctorCode = doctor.getCode();
		// 查询患者信息
		BasePatientDO p = basePatientDao.findById(patient);
		JSONObject jsonObject = new JSONObject();
		jsonObject.put("title", p.getName() + "申请复诊");
		jsonObject.put("content",wlyyOutpatientDO.getDescription());
		jsonObject.put("age",DateUtil.getAgeForIdcard(p.getIdcard()));
		jsonObject.put("sex",p.getSex());
		jsonObject.put("name",p.getName());
		//4、创建咨询
		JSONObject users = new JSONObject();//咨询参与者
		String consultTitle = "";
		//协同门诊
		if("2".equals(wlyyOutpatientDO.getOutpatientType())){
			users.put(wlyyOutpatientDO.getGeneralDoctor(),0);
			ct.setType(12);
			consultTitle = "申请协同门诊";
			JSONObject consultName = new JSONObject();
			consultName.put("patientName",p.getName());
			consultName.put("doctorName",doctor.getName());
			jsonObject.put("name",consultName.toJSONString());
		}else{
			users.put(patient, 0);
			consultTitle = "申请复诊";
		}
		String content = jsonObject.toString();
		users.put(doctorCode, 0);
		//关联业务code
		ct.setRelationCode(outpatientCode);
		//医生信息
		ct.setDoctor(doctorCode);
		ct.setDoctorName(doctor.getName());
		// 设置患者信息
		ct.setPatient(patient);
		ct.setSymptoms(wlyyOutpatientDO.getDescription());
		// 设置患者姓名
		ct.setName(p.getName());
		// 设置患者生日
		ct.setBirthday(p.getBirthday());
		//新增性别
		ct.setSex(p.getSex());
		// 设置患者头像
		ct.setPhoto(p.getPhoto());
		// 设置操作日期
		ct.setCzrq(new Date());
		ct.setDel("1");
		ct.setStatus(0);
		ct.setEvaluate(0);
		// 医生未读数量为1
		ct.setDoctorRead(1);
		//添加就诊图片
		ct.setImages(wlyyOutpatientDO.getDiseaseImg());
		// 添加咨询记录
		ConsultDo consult = addConsult(ct.getPatient(), consultTitle, ct.getSymptoms(), ct.getImages(), ct.getType());
		// 设置关联指导
		consult.setGuidance(ct.getGuidance());
		//关联业务code
		consult.setRelationCode(outpatientCode);
		//支付状态为1
		consult.setPayStatus(1);
		// 设置咨询标识
		ct.setConsult(consult.getId());
		//推送给IM去创建议题,取得成员消息
		JSONObject messages =  new JSONObject();
		JSONObject obj = new JSONObject();
		String sessionId = "";
		//协同门诊
		if("2".equals(wlyyOutpatientDO.getOutpatientType())){
			BaseDoctorDO generalDoctor = baseDoctorDao.findById(wlyyOutpatientDO.getGeneralDoctor());
			messages = imUtil.getCreateTopicMessage(generalDoctor.getId(),generalDoctor.getName(), consult.getTitle(), content, consult.getImages(), doctorCode);
			//5、(im创建咨询) 续方咨询的sessionid为居民code+就诊code+12(图文,视频,图文+视频)
			sessionId = patient + "_" + outpatientCode + "_" + ct.getType();
			obj = imUtil.createTopics(sessionId, consult.getId(), p.getName(), users, messages, imUtil.SESSION_TYPE_COLLABORATION_HOSPITAL);
		}else{
			messages = imUtil.getCreateTopicMessage(patient, p.getName(), consult.getTitle(), content, consult.getImages(), doctorCode);
			//5、(im创建咨询) 续方咨询的sessionid为居民code+就诊code+9(图文,视频,图文+视频)
			sessionId = patient + "_" + outpatientCode + "_" + ct.getType();
			if(1== type){
				//图文复诊
				obj = imUtil.createTopics(sessionId, consult.getId(), p.getName(), users, messages, imUtil.SESSION_TYPE_EXAMINATION);
			}else{
				//视频复诊+图文复诊
				obj = imUtil.createTopics(sessionId, consult.getId(), p.getName(), users, messages, imUtil.SESSION_TYPE_EXAMINATION_VIDEO);
			}
		}
		if (obj == null) {
			throw new RuntimeException("IM消息发送异常!");
		}
		if (obj.getInteger("status") == -1) {//im议题创建失败
			throw new RuntimeException(obj.getString("message"));
		}
		ct.setStartMsgId(obj.get("start_msg_id").toString());
		consultTeamDao.save(ct);
		consultDao.save(consult);
		//设置咨询code
//			wlyyOutpatientDO.setConsult(consult.getCode());
//			prescriptionDao.save(prescription);
		//6、记录咨询的医生详情
		ConsultTeamDoctorDo cd = new ConsultTeamDoctorDo();
		cd.setConsult(consult.getId());
		cd.setDel("1");
		cd.setCzrq(new Date());
		cd.setTo(doctorCode);
		consultTeamDoctorDao.save(cd);
		//7、发送系统消息提示团队长有未审核的消息
//			addCheckMessage(prescription, sessionId, p);
		//8、 保存医生咨询信息
		// 添加咨询转发记录
		// 添加医生咨询日志
		addLogs(ct);
		JSONObject result = imUtil.getSingleSessionInfo(sessionId,doctorCode);
		return result;
	}
	/**
	 * 医生接诊发送导诊护士外层消息
	 * @param wlyyOutpatientDO

+ 2 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java

@ -901,6 +901,8 @@ public class BaseHospitalRequestMapping {
        
        //添加(复诊咨询,协同门诊)
        public static final String addPrescriptionConsult ="/addPrescriptionConsult";
        public static final String addConsult= "addConsult";
    
        //全科医生发起求助专科医生的专家咨询
        public static final String generalAddExpertConsult = "/generalAddExpertConsult";

+ 69 - 4
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/DoctorConsultEndpoint.java

@ -1,8 +1,6 @@
package com.yihu.jw.hospital.endpoint.consult;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.thoughtworks.xstream.mapper.Mapper;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
@ -11,14 +9,12 @@ import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDiagnosisDO;
import com.yihu.jw.hospital.prescription.dao.OutpatientDao;
import com.yihu.jw.hospital.prescription.service.PrescriptionService;
import com.yihu.jw.hospital.prescription.service.XzyyPrescriptionService;
import com.yihu.jw.hospital.service.SystemMessage.HospitalSystemMessageService;
import com.yihu.jw.im.service.ImService;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.im.ConsultVO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
@ -227,6 +223,75 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
			}
			return success("操作成功",result);
	}
	@PostMapping(value = BaseHospitalRequestMapping.DodtorIM.addConsult)
	@ApiOperation(value = "添加(复诊咨询,协同门诊)", notes = "添加(复诊咨询,协同门诊)")
	public Envelop addConsult(@ApiParam(name = "outpatientCode", value = "HIS就诊记录CODE", defaultValue = "1")
										  @RequestParam(value = "outpatientCode", required = true) String outpatientCode,
										  @ApiParam(name = "patientCode", value = "复诊居民", defaultValue = "9638fa184ad14a71ba7e4bf931670778")
										  @RequestParam(value = "patientCode", required = true) String patientCode,
										  @ApiParam(name = "doctorCode", value = "当前医生", defaultValue = "1cd15ffe6b3a11e69f7c005056850d66")
										  @RequestParam(value = "doctorCode", required = true) String doctorCode,
										  @ApiParam(name = "type", value = "咨询类型(1、图文;2、视频,3、图文+视频)", defaultValue = "1")
										  @RequestParam(value = "type", required = true) Integer type,
										  @ApiParam(name = "reason", value = "复诊说明", defaultValue = "复诊说明")
										  @RequestParam(value = "reason", required = false) String reason)throws Exception{
		ConsultTeamDo consult = new ConsultTeamDo();
		/*if(2 == type){
			consult.setType(16);//视频复诊
			if ("xm_ykyy_wx".equalsIgnoreCase(wxId)){
				prescriptionService.sendWxTemplateMsg(wxId,outpatientCode,null,"16","outpatientMsgRemind","");
			}
		}else{
			consult.setType(9);//图文复诊
		}*/
		//咨询类型(1、图文;2、视频,3、图文+视频)
		consult.setHealthindexType(type);
//			int res = 0;
		JSONObject result = new JSONObject();
		synchronized (outpatientCode.intern()){
			/*if(!"xm_ykyy_wx".equals(wxId)){//中山医院-心脏中心需要挂号
				//1.调用挂号接口
				logger.info("调用挂号接口====START");
				String rsCode = "";
				String mes = "";
				if("xm_xzzx_wx".equals(wxId)){ //心脏中心挂号
					JSONObject res = xzyyPrescriptionService.registerOutPatient(outpatientCode,doctorCode);
					rsCode = res.getString("@RESULT");
					mes = res.getString("@MSG");
					if (type==2){
						prescriptionService.sendWxTemplateMsg(wxId,outpatientCode,null,"16","outpatientMsgRemind","");
					}
				}else {
					if (demoFlag.equalsIgnoreCase("true")){
						rsCode="0";
						mes="已挂号";
					}else {
						net.sf.json.JSONObject res = prescriptionService.registerOutPatient(outpatientCode,doctorCode);
						rsCode = (String)res.get("@RESULT");
						mes = (String)res.get("@MSG");
					}
				}
				if("0".equals(rsCode)||"-2".equals(rsCode)){
					//挂号成功,已经挂号
				}else{
					failed(mes);
				}
				logger.info("调用挂号接口====END");
			}
*/
			//2.
			result = imService.addConsult(outpatientCode, patientCode,doctorCode,consult,reason,type,wxId);
		}
		return success("操作成功",result);
	}
	
	
	@PostMapping(value = BaseHospitalRequestMapping.DodtorIM.generalAddExpertConsult)