Browse Source

健康咨询接口提交

huangwenjie 5 years ago
parent
commit
dfb9c77f60

+ 130 - 2
business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java

@ -943,8 +943,6 @@ public class ImService {
			// 查询患者信息
			BasePatientDO p = basePatientDao.findById(patient);
			
			
			
			if(!"0".equals(wlyyOutpatientDO.getStatus())){
				throw new RuntimeException("该就诊记录已被取消,无法接单!");
			}
@ -1691,4 +1689,134 @@ public class ImService {
	public String patientGuaidenceAppend(String sender_id, String sender_name, String session_id,String content_type, String content, String business_type)throws Exception  {
		return imUtil.sendImMsg(sender_id, sender_name,session_id, content_type, content, "1");
	}
	
	/**
	 * 全科医生发起求助专科医生的专家咨询
	 * @param patient_code
	 * @param general_doctor
	 * @param special_doctor
	 * @param when
	 * @param symptoms
	 * @param images
	 * @param consult
	 * @return
	 */
	public JSONObject generalAddExpertConsult(String patient_code, String general_doctor, String special_doctor, String when, String symptoms, String images, ConsultTeamDo ct) throws Exception {
		// 设置咨询类型:15
		ct.setType(15);
		// 设置发病时间
		ct.setWhen(when);
		// 设置主要症状
		ct.setSymptoms(symptoms);
		// 设置咨询图片URL
		ct.setImages(images);
		// 设置咨询语音URL
		ct.setVoice(null);
		
		BaseDoctorDO generalDoctor = baseDoctorDao.findById(general_doctor);
		BaseDoctorDO specialDoctor = baseDoctorDao.findById(special_doctor);
//			doctorCode = doctor.getCode();
		// 查询患者信息
		BasePatientDO p = basePatientDao.findById(patient_code);
		
		String consultTitle = "居民:"+p.getName() +"(医生:)-"+specialDoctor.getName()+"发起咨询!";
		
		JSONObject jsonObject = new JSONObject();
		jsonObject.put("title", consultTitle);
		jsonObject.put("content",symptoms);
		jsonObject.put("age",DateUtil.getAgeForIdcard(p.getIdcard()));
		jsonObject.put("sex",p.getSex());
		jsonObject.put("name",p.getName());
		
		String content = jsonObject.toString();
		
		//4、创建咨询
		JSONObject users = new JSONObject();//咨询参与者
		users.put(general_doctor,0);//全科医生
		users.put(special_doctor,0);//专科医生
		
		//关联业务code
//		ct.setRelationCode(outpatientCode);
		//医生信息
		ct.setDoctor(special_doctor);
		ct.setDoctorName(specialDoctor.getName());
		// 设置患者信息
		ct.setPatient(p.getId());
		ct.setSymptoms(symptoms);
		
		// 设置患者姓名
		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);
		// 添加咨询记录
		ConsultDo consult = addConsult(ct.getPatient(), consultTitle, ct.getSymptoms(), ct.getImages(), ct.getType());
		// 设置关联指导
//		consult.setGuidance(ct.getGuidance());
		//关联业务code
//		consult.setRelationCode(outpatientCode);
		// 设置咨询标识
		ct.setConsult(consult.getId());
		
		//推送给IM去创建议题,取得成员消息
		
		JSONObject messages =  new JSONObject();
		JSONObject obj = new JSONObject();
		String sessionId = "";
		messages = imUtil.getCreateTopicMessage(generalDoctor.getId(),generalDoctor.getName(), consult.getTitle(), content, consult.getImages(), special_doctor);
		//5、(im创建咨询) 续方咨询的sessionid为居民code+就诊code+12(图文,视频,图文+视频)
		sessionId = general_doctor + "_" + special_doctor + "_" + ct.getType();
		obj = imUtil.createTopics(sessionId, consult.getId(), p.getName(), users, messages, imUtil.SESSION_TYPE_GENERAL_EXPERT);
		
		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(special_doctor);
		consultTeamDoctorDao.save(cd);
		
		//7、发送系统消息提示团队长有未审核的消息
//			addCheckMessage(prescription, sessionId, p);
		
		//8、 保存医生咨询信息
		// 添加咨询转发记录
		// 添加医生咨询日志
		addLogs(ct);
		
		JSONObject result = imUtil.getSingleSessionInfo(sessionId,special_doctor);
		//外层消息-通知
		System.out.println("发送外层SOCKET消息:全科求助专科医生");
		JSONObject object = new JSONObject();
		object.put("socket_sms_type",5);
		imUtil.sendMessage(special_doctor,general_doctor,"1",object.toString());
		
		return result;
	}
}

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

@ -156,13 +156,16 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
			return success("操作成功",result);
	}
	
	@PostMapping(value = BaseHospitalRequestMapping.PatientIM.add)
	@ApiOperation(value = "居民添加咨询接口", notes = "居民添加咨询接口")
	public Envelop add(
			@ApiParam(name = "patient", value = "居民CODE")
			@RequestParam(value = "patient",required = false) String patient,
			@ApiParam(name = "doctor", value = "医生CODE")
			@RequestParam(value = "doctor",required = true) String doctor,
	
	@PostMapping(value = BaseHospitalRequestMapping.DodtorIM.generalAddExpertConsult)
	@ApiOperation(value = "全科医生发起求助专科医生的专家咨询", notes = "全科医生发起求助专科医生的专家咨询")
	public Envelop generalAddExpertConsult(
			@ApiParam(name = "patient_code", value = "居民CODE")
			@RequestParam(value = "patient_code",required = true) String patient_code,
			@ApiParam(name = "general_doctor", value = "全科医生")
			@RequestParam(value = "general_doctor",required = true) String general_doctor,
			@ApiParam(name = "special_doctor", value = "专科医生")
			@RequestParam(value = "special_doctor",required = true) String special_doctor,
			@ApiParam(name = "when", value = "发病时间")
			@RequestParam(value = "when",required = false) String when,
			@ApiParam(name = "symptoms", value = "主述")
@ -170,41 +173,16 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
			@ApiParam(name = "images", value = "图片")
			@RequestParam(value = "images",required = false) String images,
			@ApiParam(name = "voice", value = "语音")
			@RequestParam(value = "voice",required = false) String voice,
			@ApiParam(name = "type", value = "咨询类型:1专家咨询 14导诊助手")
			@RequestParam(value = "type",required = false) Integer type)throws Exception{
		
		System.out.println("symptoms="+symptoms);
		
		if (type == null) {
			type = 1;
		}
//		if (type != 1 && type != 2) {
//			return error(-1, "无效请求!");
//		}
			@RequestParam(value = "voice",required = false) String voice)throws Exception{
		
		ConsultTeamDo consult = new ConsultTeamDo();
		// 设置咨询类型:1专家咨询  14导诊助手
		consult.setType(type);
		// 设置发病时间
		consult.setWhen(when);
		// 设置主要症状
		consult.setSymptoms(symptoms);
		// 设置咨询图片URL
		consult.setImages(images);
		// 设置咨询语音URL
		consult.setVoice(voice);
		consult.setType(15);//家医咨询求助互联网医院专科医生:全科医生-专科医生-咨询聊天
		
		// 保存到数据库
//		int res = 0;
//		JSONArray dts = null;
		synchronized (patient.intern()){//新增同步方法。设备保存写在service层但是不生效,写在controller层才生效
			JSONObject re = null;
			re = imService.addTeamConsult(consult, patient,doctor);
//			res = re.getInteger("status");
//			dts = re.containsKey("doctor")?re.getJSONArray("doctor"):null;
		JSONObject result = new JSONObject();
		synchronized (patient_code.intern()){
			result = imService.generalAddExpertConsult(patient_code, general_doctor,special_doctor,when,symptoms,images,consult);
		}
		return success("操作成功", consult);
		return success("操作成功",result);
	}
	
	@PostMapping(value = BaseHospitalRequestMapping.DodtorIM.finish)