You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
365 lines
14 KiB
365 lines
14 KiB
package com.ynxbd.common.action;
|
|
|
|
import com.ynxbd.ali.helper.AliUploadHelper;
|
|
import com.ynxbd.common.action.base.BaseAction;
|
|
import com.ynxbd.common.bean.Dept;
|
|
import com.ynxbd.common.bean.Doctor;
|
|
import com.ynxbd.common.bean.enums.MerchantEnum;
|
|
import com.ynxbd.common.bean.pay.Register;
|
|
import com.ynxbd.common.dao.RegisterDao;
|
|
import com.ynxbd.common.dao.his.HisRegisterDao;
|
|
import com.ynxbd.common.helper.common.DateHelper;
|
|
import com.ynxbd.common.result.Result;
|
|
import com.ynxbd.common.result.ResultEnum;
|
|
import com.ynxbd.common.service.DoctorService;
|
|
import com.ynxbd.wx.utils.DesEncryptHelper;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
import org.apache.struts2.convention.annotation.Action;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.stream.Collectors;
|
|
|
|
/**
|
|
* @Author wsq
|
|
* @Date 2020/10/27 17:13
|
|
* @Copyright @ 2020 云南新八达科技有限公司 All rights reserve
|
|
*/
|
|
@Slf4j
|
|
public class RegisterAction extends BaseAction {
|
|
|
|
|
|
/**
|
|
* [推送] 获取预约今日的所有患者openId
|
|
* @return openId列表
|
|
*/
|
|
@Action("getTodayRegOpenId")
|
|
public Result getTodayRegOpenId() {
|
|
return Result.success(new RegisterDao().selectTodayRegisterOpenId());
|
|
}
|
|
|
|
|
|
/**
|
|
* [科室]获取科室信息
|
|
*/
|
|
@Action("getDeptInfo")
|
|
public Result getDeptInfo(String deptCode) {
|
|
log.info("[科室]获取科室信息 deptCode={}", deptCode);
|
|
|
|
if (deptCode == null) {
|
|
return Result.error(ResultEnum.PARAM_IS_DEFECT);
|
|
}
|
|
Dept dept = new RegisterDao().selectDeptByDeptCode(deptCode);
|
|
if (dept == null) {
|
|
return Result.error(ResultEnum.DATA_NOT_FOUND);
|
|
}
|
|
return Result.success(dept);
|
|
}
|
|
|
|
|
|
/**
|
|
* [医生]查询医生信息
|
|
*/
|
|
@Action("getDoctorInfo")
|
|
public Result getDoctorInfo(String doctCode) {
|
|
log.info("[医生]查询医生信息 doctCode={}", doctCode);
|
|
if (doctCode == null) {
|
|
return Result.error(ResultEnum.PARAM_IS_DEFECT);
|
|
}
|
|
Doctor doctor = new RegisterDao().selectDoctorByDoctCode(doctCode);
|
|
if (doctor == null) {
|
|
return Result.error(ResultEnum.DATA_NOT_FOUND);
|
|
}
|
|
new DoctorService().docStateHandle(doctor, doctor);
|
|
return Result.success(doctor);
|
|
}
|
|
|
|
/**
|
|
* [分时段挂号]查询科室列表
|
|
*
|
|
* @return 科室列表
|
|
*/
|
|
@Action("getTimeDeptList")
|
|
public Result getTimeDeptList(String merCode, String begDate, String endDate,String deptCode) {
|
|
log.info("[分时段挂号]查询科室列表 begDate={}, endDate={}", begDate, endDate);
|
|
if (begDate == null || endDate == null) {
|
|
return Result.error(ResultEnum.PARAM_IS_DEFECT);
|
|
}
|
|
|
|
List<Dept> deptList = new HisRegisterDao().getTimeDeptList(begDate, endDate,deptCode);
|
|
|
|
MerchantEnum merchantEnum = MerchantEnum.getMerchantEnumByCode(merCode);
|
|
if (MerchantEnum.ALI.equals(merchantEnum)) {
|
|
AliUploadHelper.uploadDept(deptList, true);
|
|
}
|
|
return Result.success(deptList);
|
|
}
|
|
|
|
/**
|
|
* [挂号]查询科室列表
|
|
*
|
|
* @param isReserve 是否为预约挂号 { true:预约挂号; false:今日挂号 }
|
|
* @param hasSourcesFlag 有号源标识 { 1:仅返回有号源科室; 0:有无号源科室都返回(默认值)}
|
|
* @param isDeptTypeGroup 是否按deptType分组
|
|
*/
|
|
@Action("getRegDeptList")
|
|
public Result getRegDeptList(String merCode, Boolean isReserve, String hasSourcesFlag, Boolean isDeptTypeGroup) {
|
|
log.info("[挂号]查询科室列表 isReserve={}, hasSourcesFlag={}, isDeptTypeGroup={}", isReserve, hasSourcesFlag, isDeptTypeGroup);
|
|
if (isDeptTypeGroup == null) {
|
|
isDeptTypeGroup = false;
|
|
}
|
|
|
|
if (isReserve == null) {
|
|
return Result.error(ResultEnum.PARAM_IS_DEFECT);
|
|
}
|
|
|
|
log.info("[{}挂号] 获取科室列表", isReserve ? "预约" : "今日");
|
|
|
|
HisRegisterDao hisRegisterDao = new HisRegisterDao();
|
|
|
|
List<Dept> deptList = isReserve
|
|
? hisRegisterDao.getRegResDeptList()
|
|
: hisRegisterDao.getRegTodayDeptList(hasSourcesFlag);
|
|
|
|
if (!isDeptTypeGroup) { // 不按deptType分组
|
|
return Result.success(deptList);
|
|
}
|
|
|
|
List<Dept> resultList = new ArrayList<>();
|
|
|
|
List<Dept> deptTypeList = new ArrayList<>();
|
|
for (Dept dept : deptList) {
|
|
if (!ObjectUtils.isEmpty(dept.getDeptTypeCode())) {
|
|
deptTypeList.add(dept);
|
|
} else {
|
|
resultList.add(dept);
|
|
}
|
|
}
|
|
|
|
Map<String, List<Dept>> stringListMap = deptTypeList.stream().collect(Collectors.groupingBy(Dept::getDeptTypeCode));
|
|
|
|
Dept dept;
|
|
String deptTypeName;
|
|
List<Dept> groupList;
|
|
for (Map.Entry<String, List<Dept>> entry : stringListMap.entrySet()) {
|
|
groupList = entry.getValue();
|
|
dept = groupList.get(0);
|
|
deptTypeName = dept.getDeptTypeName();
|
|
if (ObjectUtils.isEmpty(deptTypeName)) {
|
|
deptTypeName = groupList.stream().map(Dept::getDeptName).collect(Collectors.joining("、"));
|
|
}
|
|
dept.setDeptName(deptTypeName);
|
|
dept.setDeptCode(groupList.stream().map(Dept::getDeptCode).collect(Collectors.joining(",")));
|
|
resultList.add(dept);
|
|
}
|
|
|
|
MerchantEnum merchantEnum = MerchantEnum.getMerchantEnumByCode(merCode);
|
|
if (MerchantEnum.ALI.equals(merchantEnum)) {
|
|
AliUploadHelper.uploadDept(resultList, isReserve);
|
|
}
|
|
return Result.success(resultList);
|
|
}
|
|
|
|
|
|
/**
|
|
* [挂号]查询科室的下的医生列表
|
|
*/
|
|
@Action("getRegDoctorList")
|
|
public Result getRegDoctorList(String regDate, String deptCode, String timeInterval) {
|
|
if (deptCode == null) {
|
|
return Result.error(ResultEnum.PARAM_IS_DEFECT);
|
|
}
|
|
|
|
log.info("[{}挂号] 查询科室的下的医生列表 deptCode={}, regDate={}, timeInterval={}", (regDate == null ? "现场" : "预约"), deptCode, regDate, timeInterval);
|
|
|
|
HisRegisterDao hisRegisterDao = new HisRegisterDao();
|
|
|
|
List<Doctor> doctorList = new ArrayList<>();
|
|
for (String code : deptCode.split(",")) {
|
|
doctorList.addAll((regDate == null)
|
|
? hisRegisterDao.getRegTodayDoctorList(code, timeInterval)
|
|
: hisRegisterDao.getRegReserveDoctorList(code, regDate)
|
|
);
|
|
}
|
|
doctorList = new DoctorService().docListHandle(doctorList);
|
|
return Result.success(doctorList);
|
|
}
|
|
|
|
|
|
/**
|
|
* [现场挂号]查询挂号记录
|
|
*/
|
|
@Action("getSiteHistory")
|
|
public Result getSiteHistory(String begDate, String endDate, String patientId) {
|
|
log.info("[现场挂号]查询挂号记录 patientId={}, begDate={},endDate={}", patientId, begDate, endDate);
|
|
if (patientId == null || begDate == null || endDate == null) {
|
|
return Result.error(ResultEnum.PARAM_IS_DEFECT);
|
|
}
|
|
|
|
patientId = getDecodeString(patientId);
|
|
List<Register> hisList = new HisRegisterDao().getRegSiteHistory(patientId, null);
|
|
|
|
List<Register> resultList = new ArrayList<>();
|
|
String regDate;
|
|
for (Register reg : hisList) {
|
|
regDate = reg.getRegDate();
|
|
if (regDate != null) {
|
|
regDate = DateHelper.dateFormatShort(regDate);
|
|
if (regDate != null && DateHelper.inDateRange(begDate, endDate, regDate, DateHelper.DateEnum.yyyy_MM_dd)) {
|
|
resultList.add(reg);
|
|
}
|
|
}
|
|
}
|
|
return Result.success(resultList);
|
|
}
|
|
|
|
|
|
/**
|
|
* [预约挂号]获取预约记录
|
|
*/
|
|
@Action("getReserveHistory")
|
|
public Result getReserveHistory(String begDate, String endDate, String patientId) {
|
|
log.info("[预约挂号]查询挂号记录 patientId={}, begDate={},endDate={}", patientId, begDate, endDate);
|
|
if (patientId == null || begDate == null || endDate == null) {
|
|
return Result.error(ResultEnum.PARAM_IS_DEFECT);
|
|
}
|
|
List<Register> resultList = new HisRegisterDao().getRegReserveHistory(patientId, null);
|
|
return Result.success(resultList);
|
|
}
|
|
|
|
|
|
/**
|
|
* [挂号]查询某天某个科室,某个类型的号源是否被占用
|
|
*/
|
|
@Action("hasReg")
|
|
public Result hasReg(String regDate, String deptCode, String patientId) {
|
|
log.info("[挂号]查询号源是否被占用regDate={}, deptCode={}, patientId={}", regDate, deptCode, patientId);
|
|
if (regDate == null || deptCode == null || patientId == null) {
|
|
return Result.error(ResultEnum.PARAM_IS_DEFECT);
|
|
}
|
|
|
|
if (new RegisterDao().hasReg(patientId, regDate, deptCode)) {
|
|
log.info("[挂号]同一天,同一科室,已挂过号");
|
|
return Result.error(ResultEnum.REG_TODAY_HAS);
|
|
}
|
|
return Result.success();
|
|
}
|
|
|
|
|
|
/**
|
|
* [分时段挂号]查询医生列表
|
|
*
|
|
* @return 医生列表
|
|
*/
|
|
@Action("getTimeDoctorList")
|
|
public Result getTimeDoctorList(String begDate, String endDate, String deptCode, String subDeptCode) {
|
|
log.info("[分时段挂号]查询医生列表 begDate={}, endDate={}, deptCode={}, subDeptCode={}", begDate, endDate, deptCode, subDeptCode);
|
|
if (deptCode == null || begDate == null || endDate == null) {
|
|
return Result.error(ResultEnum.PARAM_IS_DEFECT);
|
|
}
|
|
|
|
List<Doctor> doctorList = new HisRegisterDao().getTimeDoctorList(deptCode, subDeptCode, begDate, endDate);
|
|
|
|
doctorList = new DoctorService().docListHandle(doctorList);
|
|
return Result.success(doctorList);
|
|
}
|
|
|
|
|
|
/**
|
|
* [分时段挂号]查询号源
|
|
*
|
|
* @return 号源
|
|
*/
|
|
@Action("getTimeSourceList")
|
|
public Result getTimeSourceList(String begDate, String endDate, String deptCode, String doctCode, String subDeptCode) {
|
|
log.info("[分时段挂号]查询号源 begDate={}, endDate={}, deptCode={}, subDeptCode={}, doctCode={}", begDate, endDate, deptCode, subDeptCode, doctCode);
|
|
if (deptCode == null || doctCode == null || begDate == null || endDate == null) {
|
|
return Result.error(ResultEnum.PARAM_IS_DEFECT);
|
|
}
|
|
|
|
List<Map<Object, Object>> dataList = new HisRegisterDao().getTimeSource(deptCode, subDeptCode, doctCode, begDate, endDate);
|
|
return Result.success(dataList);
|
|
}
|
|
|
|
@Action("getDoctorSchedule")
|
|
public Result getDoctorSchedule(String begDate, String endDate,String doctCode) {
|
|
log.info("[医生排班信息] begDate={}, endDate={}, doctCode={}", begDate, endDate,doctCode);
|
|
if (doctCode == null || begDate == null || endDate == null) {
|
|
return Result.error(ResultEnum.PARAM_IS_DEFECT);
|
|
}
|
|
return Result.success(new HisRegisterDao().getDoctorSchedule(begDate, endDate, doctCode));
|
|
}
|
|
|
|
|
|
// /**
|
|
// * [预约挂号]获取指定科室医生信息
|
|
// */
|
|
// @Action("getReserveDoctorList")
|
|
// public String getReserveDoctorList() {
|
|
// String deptCode = request.getParameter("deptCode");
|
|
// String regDate = request.getParameter("regDate");
|
|
// if (regDate == null) {
|
|
// return Result.error(ResultEnum.PARAM_NOT_COMPLETE);
|
|
// }
|
|
//
|
|
// if (deptCode == null) deptCode = "0310";
|
|
// List<Doctor> doctors = new HisRegisterDao().getRegReserveDoctList(deptCode, regDate);
|
|
// RegisterDao registerDao = new RegisterDao();
|
|
// String description; // 特长
|
|
// for (Doctor item : doctors) {
|
|
// Doctor doctor = registerDao.selectDoctorByCodeOName(item.getDoctCode(), item.getDoctName());
|
|
// if (doctor != null) {
|
|
// item.setTitle(doctor.getTitle());
|
|
// item.setHeadImg(doctor.getHeadImg());
|
|
// item.setPym(doctor.getPym());
|
|
// description = doctor.getDescription();
|
|
// if (description != null && !"".equals(description)) { // 医生特长以wx为主
|
|
// item.setDescription(description);
|
|
// }
|
|
// }
|
|
// }
|
|
// return Result.success(doctors);
|
|
// }
|
|
//
|
|
// /**
|
|
// * [现场挂号]获取指定科室医生信息
|
|
// */
|
|
// @Action("getSiteDoctorList")
|
|
// public String getSiteDoctorList() {
|
|
// String deptCode = request.getParameter("deptCode");
|
|
//
|
|
// if (deptCode == null) deptCode = "";
|
|
//
|
|
// List<Doctor> doctors = new HisRegisterDao().getRegSiteDoctList(deptCode);
|
|
// RegisterDao registerDao = new RegisterDao();
|
|
// String description; // 特长
|
|
// for (Doctor item : doctors) {
|
|
// Doctor doctor = registerDao.selectDoctorByCodeOName(item.getDoctCode(), item.getDoctName());
|
|
// if (doctor != null) {
|
|
// String title = item.getTitle();
|
|
// if (title == null) {
|
|
// item.setTitle(doctor.getTitle());
|
|
// }
|
|
// item.setHeadImg(doctor.getHeadImg());
|
|
// item.setPym(doctor.getPym());
|
|
// description = doctor.getDescription();
|
|
// if (description != null && !"".equals(description)) { // 医生特长以wx为主
|
|
// item.setDescription(description);
|
|
// }
|
|
// }
|
|
// }
|
|
// return Result.success(doctors);
|
|
// }
|
|
// /**
|
|
// * [预约挂号]获取所有科室信息
|
|
// */
|
|
// @Action("getReserveDeptList")
|
|
// public String getReserveDeptList() {
|
|
// log.info("[预约挂号]查询科室");
|
|
// List<Dept> resultList = new HisRegisterDao().getRegReserveDeptList();
|
|
// return Result.success(resultList);
|
|
// }
|
|
|
|
}
|
|
|