소스 검색

医生咨询代码提交

esb 8 년 전
부모
커밋
a98d481084

+ 1 - 1
src/main/java/com/yihu/wlyy/entity/consult/ConsultTeam.java

@ -30,7 +30,7 @@ public class ConsultTeam extends IdEntity {
	private String doctor;
	// 三师团队标识
	private String team;
	//三师咨询,2家庭医生咨询 3.名医咨询
	//1 三师咨询,2家庭医生咨询 6.名医咨询
	private Integer type;
	// 提问者标识
	private String patient;

+ 9 - 1
src/main/java/com/yihu/wlyy/repository/ConsultDao.java

@ -12,12 +12,20 @@ public interface ConsultDao extends PagingAndSortingRepository<Consult, Long>, J
	
	Consult findByCode(String code);
	// 查询患者咨询记录
	@Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.del = '1' and a.symptoms like ?2 order by a.czrq desc")
	Page<Object> findByPatient(String patient,String title, Pageable pageRequest);
	// 查询患者咨询记录
	@Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.id < ?3 and a.del = '1'and a.symptoms like ?2 order by a.czrq desc")
	Page<Object> findByPatient(String patient,String title, long id, Pageable pageRequest);
	// 查询患者咨询记录
	@Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.del = '1' order by a.czrq desc")
	Page<Object> findByPatient(String patient, Pageable pageRequest);
	// 查询患者咨询记录
	@Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.id < ?2 and a.del = '1' order by a.czrq desc")
	@Query("select a.id,a.type,a.code,a.title,a.symptoms,a.czrq,b.status from Consult a,ConsultTeam b where a.code = b.consult and a.patient = ?1 and a.id < ?2 and a.del = '1'order by a.czrq desc")
	Page<Object> findByPatient(String patient, long id, Pageable pageRequest);
	@Query("select count(a) from Consult a,ConsultTeamDoctor b  where a.code = b.consult and a.patient=?1 and b.to=?2 ")

+ 25 - 0
src/main/java/com/yihu/wlyy/repository/ConsultTeamDao.java

@ -6,6 +6,7 @@
package com.yihu.wlyy.repository;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
@ -144,4 +145,28 @@ public interface ConsultTeamDao extends PagingAndSortingRepository<ConsultTeam,
	//查找
	@Query("SELECT a FROM ConsultTeam a WHERE a.patient=?1 and a.status=0 and a.del=1")
	ConsultTeam findFamousConsultByPatient(String uid);
	//名医咨询 -全部
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and a.type=6 and b.to = ?1 and a.id < ?2 and a.del = '1' and b.del = '1'")
	Page<ConsultTeam> findFamousDoctorAllList(String uid, long id, Pageable pageRequest);
	//名医咨询 -全部
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and a.type=6 and b.to = ?1  and a.del = '1' and b.del = '1'")
	Page<ConsultTeam> findFamousDoctorAllList(String uid, Pageable pageRequest);
	//名医咨询 -全部 带symptoms
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and a.type=6 and b.to = ?1 and a.id < ?2 and a.symptoms like ?3 and a.del = '1' and b.del = '1'")
	Page<ConsultTeam> findFamousDoctorAllList(String uid, long id,String title, Pageable pageRequest);
	//名医咨询 -全部 带symptoms
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and a.type=6 and b.to = ?1 and a.symptoms like ?2  and a.del = '1' and b.del = '1'")
	Page<ConsultTeam> findFamousDoctorAllList(String uid,String title, Pageable pageRequest);
	//名医咨询 -根据status
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and a.type=6 and b.to = ?1 and a.id < ?2 and a.status = ?3 and a.del = '1' and b.del = '1'")
	Page<ConsultTeam> findFamousDoctorDoingList(String uid, long id,Integer type, Pageable pageRequest);
	//名医咨询 -根据status
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and a.type=6 and b.to = ?1 and a.status = ?2  and a.del = '1' and b.del = '1'")
	Page<ConsultTeam> findFamousDoctorDoingList(String uid,Integer type, Pageable pageRequest);
	//名医咨询 -根据status 带symptoms
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and a.type=6 and b.to = ?1 and a.id < ?2 and a.symptoms like ?3 and a.status = ?4 and a.del = '1' and b.del = '1'")
	Page<ConsultTeam> findFamousDoctorDoingList(String uid, long id,String title,Integer type, Pageable pageRequest);
	//名医咨询 -根据status 带symptoms
	@Query("select a from ConsultTeam a, ConsultTeamDoctor b where a.consult = b.consult and a.type=6 and b.to = ?1 and a.symptoms like ?2 and a.status = ?3 and a.del = '1' and b.del = '1'")
	Page<ConsultTeam> findFamousDoctorDoingList(String uid,String title,Integer type, Pageable pageRequest);
}

+ 15 - 5
src/main/java/com/yihu/wlyy/service/app/consult/ConsultService.java

@ -19,6 +19,7 @@ import com.yihu.wlyy.repository.ConsultTeamDao;
import com.yihu.wlyy.repository.DoctorDao;
import com.yihu.wlyy.repository.PatientDao;
import com.yihu.wlyy.service.BaseService;
import org.springframework.util.StringUtils;
public class ConsultService extends BaseService {
@ -68,7 +69,7 @@ public class ConsultService extends BaseService {
	 * @param pagesize 分页大小
	 * @return
	 */
	public Page<Object> findConsultRecordByPatient(String patient, long id, int pagesize) {
	public Page<Object> findConsultRecordByPatient(String patient, long id, int pagesize,String title) {
		if (id < 0) {
			id = 0;
		}
@ -79,10 +80,19 @@ public class ConsultService extends BaseService {
		Sort sort = new Sort(Direction.DESC, "id");
		// 分页信息
		PageRequest pageRequest = new PageRequest(0, pagesize, sort);
		if (id > 0) {
			return consultDao.findByPatient(patient, id, pageRequest);
		} else {
			return consultDao.findByPatient(patient, pageRequest);
		if(!StringUtils.isEmpty(title)){
			title="%"+title+"%";
			if (id > 0) {
				return consultDao.findByPatient(patient,title, id, pageRequest);
			} else {
				return consultDao.findByPatient(patient,title, pageRequest);
			}
		}else{
			if (id > 0) {
				return consultDao.findByPatient(patient, id, pageRequest);
			} else {
				return consultDao.findByPatient(patient, pageRequest);
			}
		}
	}

+ 59 - 13
src/main/java/com/yihu/wlyy/service/app/consult/ConsultTeamService.java

@ -76,12 +76,12 @@ public class ConsultTeamService extends ConsultService {
	/**
	 * 查詢醫生網絡諮詢列表
	 * @param type 咨询类型:1、咨询我的,2、公共的, 3、参与过的,4、已结束的
	 * @param type 咨询类型:1、咨询我的,2、公共的, 3、参与过的,4、已结束的 5 名医咨询 全部  6 名医咨询 进行中 7 名医咨询 已结束
	 * @param id
	 * @param pagesize 每页显示数,默认为10
	 * @return
	 */
	public Page<ConsultTeam> findByDoctor(String uid, int type, long id, int pagesize) {
	public Page<ConsultTeam> findByDoctor(String uid, int type, long id, int pagesize,String title) {
		if (id < 0) {
			id = 0;
		}
@ -105,12 +105,58 @@ public class ConsultTeamService extends ConsultService {
			// 已完成的
			return findByDoctorType4(uid, id, pagesize);
		case 5:
			// 名医咨询
			return findByDoctorType1(uid, type, id, pagesize);
			// 5 名医咨询 全部
			return findByDoctorType5(uid, id, pagesize,title);
		case 6:
			//6 名医咨询 进行中
			return findByDoctorType6(uid, 0, id, pagesize,title);
		case 7:
			//7 名医咨询 已结束
			return findByDoctorType6(uid, 1, id, pagesize,title);
		}
		return null;
	}
	private Page<ConsultTeam> findByDoctorType5(String uid,  long id, int pagesize,String title) {
		Sort sort = new Sort(Direction.DESC, "id");
		// 分页信息
		PageRequest pageRequest = new PageRequest(0, pagesize, sort);
		if(StringUtils.isNoneEmpty(title)){
			title="%"+title+"%";
			if (id > 0) {
				return consultTeamDao.findFamousDoctorAllList(uid, id,title, pageRequest);
			} else {
				return consultTeamDao.findFamousDoctorAllList(uid,title, pageRequest);
			}
		}else{
			if (id > 0) {
				return consultTeamDao.findFamousDoctorAllList(uid, id, pageRequest);
			} else {
				return consultTeamDao.findFamousDoctorAllList(uid, pageRequest);
			}
		}
	}
	private Page<ConsultTeam> findByDoctorType6(String uid, int type, long id, int pagesize,String title) {
		// 排序
		Sort sort = new Sort(Direction.DESC, "id");
		// 分页信息
		PageRequest pageRequest = new PageRequest(0, pagesize, sort);
		if(StringUtils.isNoneEmpty(title)){
			title="%"+title+"%";
			if (id > 0) {
				return consultTeamDao.findFamousDoctorDoingList(uid, id,title,type, pageRequest);
			} else {
				return consultTeamDao.findFamousDoctorDoingList(uid, title,type,pageRequest);
			}
		}else{
			if (id > 0) {
				return consultTeamDao.findFamousDoctorDoingList(uid, id,type, pageRequest);
			} else {
				return consultTeamDao.findFamousDoctorDoingList(uid,type, pageRequest);
			}
		}
	}
	/**
	 * 查询全部咨询记录
	 * @param uid
@ -655,6 +701,15 @@ public class ConsultTeamService extends ConsultService {
		return consultTeamLogDao.findOne(logId);
	}
	public boolean isExistFamousConsult(String uid) {
		ConsultTeam consultTeam= consultTeamDao.findFamousConsultByPatient(uid);
		if(consultTeam!=null){
			return true;
		}else{
			return false;
		}
	}
	public void addFamousTeamConsult(ConsultTeam ct, String uid) throws Exception{
		// 设置患者信息
		ct.setPatient(uid);
@ -694,13 +749,4 @@ public class ConsultTeamService extends ConsultService {
		// 添加医生咨询日志
		addLogs(ct);
	}
	public boolean isExistFamousConsult(String uid) {
		ConsultTeam consultTeam= consultTeamDao.findFamousConsultByPatient(uid);
		if(consultTeam!=null){
			return true;
		}else{
			return false;
		}
	}
}

+ 37 - 0
src/main/java/com/yihu/wlyy/service/common/account/DoctorService.java

@ -5,10 +5,17 @@
 *******************************************************************************/
package com.yihu.wlyy.service.common.account;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springside.modules.persistence.DynamicSpecifications;
import org.springside.modules.persistence.SearchFilter;
import org.springside.modules.utils.Clock;
import com.yihu.wlyy.entity.doctor.Doctor;
@ -16,6 +23,10 @@ import com.yihu.wlyy.entity.Token;
import com.yihu.wlyy.repository.DoctorDao;
import com.yihu.wlyy.util.EncodesUtil;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * 医生基本信息类.
 *
@ -66,5 +77,31 @@ public class DoctorService extends TokenService {
	}
	public Page<Doctor> famousDoctorList(String name, long id, int pagesize) {
		if (pagesize <= 0) {
			pagesize = 10;
		}
		// 排序
		Sort sort = new Sort(Sort.Direction.ASC, "id");
		// 分页信息
		PageRequest pageRequest = new PageRequest(0, pagesize, sort);
		// 设置查询条件
		Map<String, SearchFilter> filters = new HashMap<String, SearchFilter>();
		if (StringUtils.isNoneEmpty(name)) {
			filters.put("name", new SearchFilter("name", SearchFilter.Operator.LIKE, "%"+name+"%"));
		}
		if (id > 0) {
			filters.put("id", new SearchFilter("id", SearchFilter.Operator.GT, id));
		}
		//设置过滤条件是名医
		//filters.put("level", new SearchFilter("level", SearchFilter.Operator.EQ, level));
		//设置过滤条件是次数大于零
		//filters.put("level", new SearchFilter("level", SearchFilter.Operator.EQ, level));
		// 未作废
		filters.put("status", new SearchFilter("status", SearchFilter.Operator.EQ, 1));
		Specification<Doctor> spec = DynamicSpecifications.bySearchFilter(filters.values(), Doctor.class);
		return doctorDao.findAll(spec, pageRequest);
	}
}

+ 2 - 2
src/main/java/com/yihu/wlyy/web/doctor/consult/DoctorConsultController.java

@ -53,9 +53,9 @@ public class DoctorConsultController extends WeixinBaseController {
	 */
	@RequestMapping(value = "list")
	@ResponseBody
	public String list(int type, int id, int pagesize, @RequestParam(required = false) String patient) {
	public String list(int type, int id, int pagesize, @RequestParam(required = false) String patient, @RequestParam(required = false) String title) {
		try {
			Page<ConsultTeam> list = consultTeamService.findByDoctor(getUID(), type, id, pagesize);
			Page<ConsultTeam> list = consultTeamService.findByDoctor(getUID(), type, id, pagesize,title);
			JSONArray jsonArray = new JSONArray();
			for (ConsultTeam consult : list) {
				if (consult == null) {

+ 115 - 7
src/main/java/com/yihu/wlyy/web/patient/consult/ConsultController.java

@ -53,16 +53,20 @@ public class ConsultController extends WeixinBaseController {
	/**
	 * 患者咨询记录查询
	 * @param title 咨询标题
	 * @param id
	 * @param pagesize 分页大小
	 * @return
	 */
	@RequestMapping(value = "records")
	@ResponseBody
	public String consultRecords(long id, int pagesize) {
	public String consultRecords(
			@RequestParam(required = false) String  title,
			long id,
			int pagesize) {
		try {
			JSONArray array = new JSONArray();
			Page<Object> data = consultTeamService.findConsultRecordByPatient(getUID(), id, pagesize);
			Page<Object> data = consultTeamService.findConsultRecordByPatient(getUID(), id, pagesize,title);
			if (data != null) {
				for (Object consult : data.getContent()) {
					if (consult == null) {
@ -291,7 +295,7 @@ public class ConsultController extends WeixinBaseController {
				voice = CommonUtil.copyTempVoice(voice);
			}
			ConsultTeam consult = new ConsultTeam();
			// 设置咨询类型:1三师咨询,2家庭医生咨询
			// 设置咨询类型:1三师咨询,2家庭医生咨询  6.名医咨询
			consult.setType(type);
			// 设置发病时间
			consult.setWhen(when);
@ -319,7 +323,12 @@ public class ConsultController extends WeixinBaseController {
				DoctorStatisticsTask.getInstance(doctorStatisticsService).put(consult.getDoctor(), 1, 1, 0);
			}
			// 推送消息给医生
			PushMsgTask.getInstance().put(consult.getDoctor(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_CONSULT_TEAM.D_CT_01.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_CONSULT_TEAM.指定咨询.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_CONSULT_TEAM.您有新的指定咨询.name(), consult.getConsult());
			if(type==6){
				// 推送消息给医生
				PushMsgTask.getInstance().put(consult.getDoctor(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM.D_CT_01.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM.名医咨询.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM.您有新的名医咨询.name(), consult.getConsult());
			}else{
				PushMsgTask.getInstance().put(consult.getDoctor(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_CONSULT_TEAM.D_CT_01.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_CONSULT_TEAM.指定咨询.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_CONSULT_TEAM.您有新的指定咨询.name(), consult.getConsult());
			}
			return success("提交成功");
		} catch (Exception ex) {
			error(ex);
@ -345,6 +354,9 @@ public class ConsultController extends WeixinBaseController {
					  @RequestParam(required = false) String images,
					  @RequestParam(required = false) String voice) {
		try {
			//判断医生是否剩下咨询次数
			if (StringUtils.isEmpty(images)) {
				images = fetchWxImages();
			}
@ -363,8 +375,8 @@ public class ConsultController extends WeixinBaseController {
				return error(-1, "已经存在名医咨询!");
			}
			ConsultTeam consult = new ConsultTeam();
			// 设置咨询类型:1三师咨询,2家庭医生咨询 3.名医咨询
			consult.setType(3);
			// 设置咨询类型:1三师咨询,2家庭医生咨询 6.名医咨询
			consult.setType(6);
			// 设置发病时间
			consult.setWhen(when);
			// 设置主要症状
@ -386,7 +398,104 @@ public class ConsultController extends WeixinBaseController {
		}
	}
	/**
	 * 名医列表
	 * @return
     */
	@RequestMapping(value = "famousDoctorList")
	@ResponseBody
	public String famousDoctorList(
									@RequestParam(required = false) String name,
									long id,
									int pagesize) {
		try {
			JSONArray array = new JSONArray();
			Page<Doctor>list = doctorService.famousDoctorList(name, id, pagesize);
			if (list != null) {
				for (Doctor doctor : list) {
					if (doctor == null) {
						continue;
					}
					JSONObject json = new JSONObject();
					json.put("id", doctor.getId());
					// 医生标识
					json.put("code", doctor.getCode());
					// 医生姓名
					json.put("name", doctor.getName());
					// 所在医院名称
					json.put("hospital", doctor.getHospital());
					// 所在医院名称
					json.put("hospital_name", doctor.getHosptialName());
					// 科室名称
					json.put("dept_name", (doctor.getDeptName() == null ||
							StringUtils.isEmpty(doctor.getDeptName().toString())) ? " " : doctor.getDeptName());
					// 职称名称
					json.put("job_name", (doctor.getJobName() == null ||
							StringUtils.isEmpty(doctor.getJobName().toString())) ? " " : doctor.getJobName());
					// 头像
					json.put("photo", doctor.getPhoto());
					// 简介
					json.put("introduce", doctor.getIntroduce());
					// 专长
					json.put("expertise", doctor.getExpertise());
					// 剩余咨询次数
					//json.put("num", doctor.getExpertise());
					array.put(json);
				}
			}
			return write(200, "获取医院医生列表成功!", "list", array);
		} catch (Exception e) {
			error(e);
			return error(-1, "获取医院医生列表失败!");
		}
	}
	/**
	 * 名医主页
	 * @return
	 */
	@RequestMapping(value = "famousDoctorPage")
	@ResponseBody
	public String famousDoctorPage(
			 String doctorCode) {
		try {
			Doctor temp = doctorService.findDoctorByCode(doctorCode);
			if (temp != null) {
				JSONObject json = new JSONObject();
				// 设置医生手机号码
				json.put("mobile", temp.getMobile());
				// 设置医生标识
				json.put("code", temp.getCode());
				// 设置医生姓名
				json.put("name", temp.getName());
				// 设置医生头像
				json.put("photo", CommonUtil.getPhoneUrl(temp.getPhoto()));
				// 设置医生性别
				json.put("sex", temp.getSex());
				// 设置省名称
				json.put("provinceName", temp.getProvinceName());
				// 设置城市名称
				json.put("cityName", temp.getCityName());
				// 设置医院名称
				json.put("hospitalName", temp.getHosptialName());
				// 设置部门名称
				json.put("deptName", StringUtils.isNotEmpty(temp.getDeptName()) ? temp.getDeptName() : "");
				// 设置职称
				json.put("jobName", StringUtils.isNotEmpty(temp.getJobName()) ? temp.getJobName() : "");
				// 设置医生专长
				json.put("expertise", StringUtils.isNotEmpty(temp.getExpertise()) ? temp.getExpertise() : "");
				// 设置医生简介
				json.put("introduce", StringUtils.isNotEmpty(temp.getIntroduce()) ? temp.getIntroduce() : "");
				return write(200, "医生信息查询成功!", "data", json);
			} else {
				return error(-1, "医生信息查询失败!");
			}
		} catch (Exception e) {
			error(e);
			return invalidUserException(e, -1, "医生信息查询失败!");
		}
	}
	@RequestMapping(value = "status")
	@ResponseBody
@ -545,7 +654,6 @@ public class ConsultController extends WeixinBaseController {
	/**
	 * 网络咨询咨询日志查询
	 * @param consult 咨询标识
	 * @param patient 患者标识
	 * @param pagesize 每页显示数,默认为10
	 * @return
	 */