| 
					
				 | 
			
			
				@ -243,7 +243,7 @@ public class ImService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * 查询居民与某个医生未结束的咨询 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * 查询居民与某个医生未结束的专家咨询 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param patient 居民 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param doctor  医生 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -257,7 +257,34 @@ public class ImService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								"AND a.patient= '" +patient+"' "+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								"AND b.to_doctor='" +doctor+"' "+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								"AND a.del='1' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								"AND a.type<> 9 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								"AND (a.type<> 9 or a.type<> 16)" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								"AND a.`status`=0"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						String consultCode = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						if (rstotal != null && rstotal.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							consultCode = rstotal.get(0).get("consultCode").toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						return consultCode; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * 查询全科医生与某个医生未结束的专家咨询 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param patient 居民 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param doctor  医生 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					public String  getUnfinishedConsultByActualSender(String actualSender, String doctor) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						String totalSql = "SELECT a.consult as consultCode " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								"FROM wlyy_consult_team a,wlyy_consult_team_doctor b " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								"WHERE a.consult=b.consult " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								"AND b.to_doctor='" +doctor+"' "+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								"AND b.actual_sender='" +actualSender+"' "+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								"AND a.del='1' " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								"AND a.type<> 12 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								"AND a.`status`=0"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1016,6 +1043,7 @@ public class ImService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								//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(图文,视频,图文+视频) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1285,8 +1313,13 @@ public class ImService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					public JSONObject getConsultInfoAndPatientInfo(String consult,String patientCode) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						BasePatientDO basePatientDO = basePatientDao.findById(patientCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						ConsultDo consultDo = consultDao.findOne(consult); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						BasePatientDO basePatientDO = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						if(StringUtils.isEmpty(patientCode)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							patientCode = consultDo.getPatient(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						basePatientDO = basePatientDao.findById(patientCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						JSONObject result = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						JSONObject patientinfoObj = new JSONObject(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1793,6 +1826,8 @@ public class ImService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							throw new RuntimeException(obj.getString("message")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						ct.setStartMsgId(obj.get("start_msg_id").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						ct.setActualSender(generalDoctor.getId());//实际发起人-全科医生 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						ct.setActualSenderName(generalDoctor.getName());//实际发起人-全科医生 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						consultTeamDao.save(ct); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						consultDao.save(consult); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1843,4 +1878,160 @@ public class ImService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							return null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * (健康咨询)医生咨询记录查询 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param doctor 医生标识 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param id 会话ID(等同IM表topicId) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param type 咨询会话类型 : 0 全部 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param status 咨询状态:0全部,1候诊中,2就诊中,3结束 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param pagesize 分页大小 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param title 标题关键字 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param start_time 开始时间 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param end_time 结束时间 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param patient 居民CODE 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					public List<ConsultVO>  findexpertConsultRecordByDoctor(String doctor, String id, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					                                                  Integer type, Integer status, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					                                                  int page,int pagesize, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					                                                  String title,String start_time,String end_time,String patinet) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						if(page >=1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							page --; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						if (pagesize <= 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							pagesize = 10; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						String  sql = "SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								"a.id AS id," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								"a.type AS type," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								"a.title AS title," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								"a.symptoms AS symptoms," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								"a.czrq AS czrq," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								"b.status AS status," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								"b.evaluate AS evaluate," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								"d.name AS patientName," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								"d.id as patientId," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								"d.idcard as patientIdcard," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								"d.sex as patientsex," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								"d.photo AS patientphoto " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								"FROM wlyy_consult a," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								"wlyy_consult_team b," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								"base_patient d " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								"WHERE a.id=b.consult " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								"AND b.patient=d.id AND b.patient='"+patinet+"' "+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								"AND b.actual_sender='"+doctor+"' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						List<ConsultVO> result = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						if(!StringUtils.isEmpty(title)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							title="%"+title+"%"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							sql +=" and a.title like '"+title+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						if(!StringUtils.isEmpty(start_time)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							sql +=" and a.czrq >= '"+start_time+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						if(!StringUtils.isEmpty(end_time)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							sql +=" and a.czrq <= '"+end_time+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						//咨询状态 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						if(status != 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							if(status ==2 ){//就诊中 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								sql +=" and b.status = 0 "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							}else if(status ==3 ){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								sql +=" and b.status = 1 "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							}else{} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						//咨询状态 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						if(type != 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							sql +=" AND a.type="+type; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						if (!StringUtils.isEmpty(id)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							sql += " and a.id = '" + id + "'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						sql += " ORDER BY a.czrq desc limit "+page * pagesize+","+pagesize+""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						result = jdbcTemplate.query(sql, new BeanPropertyRowMapper(ConsultVO.class)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * (健康咨询)查询患者所有的咨询记录总数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param doctor 患者标识 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param id 会话ID(等同IM表topicId) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param type 咨询会话类型 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param status 咨询状态:0全部,1候诊中,2就诊中,3结束 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param pagesize 分页大小 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param title 标题关键字 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param start_time 开始时间 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param end_time 结束时间 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @param patient 居民CODE 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					public Long findexpertConsultRecordByDoctor(String doctor, String id,Integer type, Integer status,String title,String start_time,String end_time,String patient) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						String  sql = "SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								" COUNT(1) AS total " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								"FROM wlyy_consult a," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								"wlyy_consult_team b," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								"base_patient d " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								"WHERE a.id=b.consult " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								"AND b.patient=d.id AND b.patient='"+patient+"' "+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								"AND b.actual_sender='"+doctor+"' "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						List<ConsultVO> result = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						if(!StringUtils.isEmpty(title)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							title="%"+title+"%"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							sql +=" and a.title like '"+title+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						if(!StringUtils.isEmpty(start_time)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							sql +=" and a.czrq >= '"+start_time+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						if(!StringUtils.isEmpty(end_time)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							sql +=" and a.czrq <= '"+end_time+"'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						//咨询状态 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						if(status != 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							if(status ==2 ){//就诊中 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								sql +=" and b.status = 0 "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							}else if(status ==3 ){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								sql +=" and b.status = 1 "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							}else{} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						//咨询状态 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						if(type != 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							sql +=" AND a.type="+type; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						if (!StringUtils.isEmpty(id)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							sql += " and a.id = '" + id + "'"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(sql); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						Long count = 0L; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						if (rstotal != null && rstotal.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							count = (Long) rstotal.get(0).get("total"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						return count; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				} 
			 |