|
|
|
|
@ -2,11 +2,16 @@ package com.ynxbd.common.service; |
|
|
|
|
|
|
|
|
|
import com.ynxbd.common.bean.Dept; |
|
|
|
|
import com.ynxbd.common.bean.Doctor; |
|
|
|
|
import com.ynxbd.common.bean.Patient; |
|
|
|
|
import com.ynxbd.common.bean.ai.AIDept; |
|
|
|
|
import com.ynxbd.common.bean.ai.AIDoctor; |
|
|
|
|
import com.ynxbd.common.bean.ai.AIDoctorSchedule; |
|
|
|
|
import com.ynxbd.common.bean.ai.AIPatient; |
|
|
|
|
import com.ynxbd.common.dao.RegisterDao; |
|
|
|
|
import com.ynxbd.common.dao.his.HisRegisterDao; |
|
|
|
|
import com.ynxbd.common.helper.common.DateHelper; |
|
|
|
|
import com.ynxbd.common.helper.common.IDNumberHelper; |
|
|
|
|
import com.ynxbd.common.helper.common.JsonHelper; |
|
|
|
|
import com.ynxbd.common.helper.common.URLHelper; |
|
|
|
|
import com.ynxbd.common.result.Result; |
|
|
|
|
import com.ynxbd.common.result.ResultEnum; |
|
|
|
|
@ -54,7 +59,7 @@ public class AIGuidanceService { |
|
|
|
|
|
|
|
|
|
map.put("location", ""); // 经纬度,逗号分割
|
|
|
|
|
map.put("miniAppId", ""); // 经纬度,逗号分割
|
|
|
|
|
map.put("isHTML", false); // 经纬度,逗号分割
|
|
|
|
|
map.put("isHTML", false); // 介绍信息是否为HTML 文档
|
|
|
|
|
|
|
|
|
|
resultList.add(map); |
|
|
|
|
return Result.success(ResultEnum.AI_SUCCESS, resultList); |
|
|
|
|
@ -132,7 +137,7 @@ public class AIGuidanceService { |
|
|
|
|
item.setParentDeptId(isSubDept ? dept.getDeptCode() : ""); |
|
|
|
|
item.setFeatureFlag(0); // 是否特色科室
|
|
|
|
|
item.setTreatrange(""); // 诊疗范围
|
|
|
|
|
item.setIsHTML(true); |
|
|
|
|
item.setIsHTML(true); // 介绍信息是否为HTML 文档
|
|
|
|
|
|
|
|
|
|
item.setDeptMiniWxUrl(""); |
|
|
|
|
item.setDeptMiniAlipayUrl(""); |
|
|
|
|
@ -169,15 +174,17 @@ public class AIGuidanceService { |
|
|
|
|
return Result.success(ResultEnum.AI_SUCCESS, new ArrayList<>()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
HisRegisterDao hisRegisterDao = new HisRegisterDao(); |
|
|
|
|
|
|
|
|
|
List<Doctor> doctorList; |
|
|
|
|
if (AIGuidanceConfig.IS_SPLIT_TIME_REG) { // 分时段
|
|
|
|
|
String curDate = DateHelper.getCurDate(); |
|
|
|
|
doctorList = new HisRegisterDao().queryHisTimeRegDoctorList(deptId, branchId, curDate, DateHelper.getMoveDate(curDate, 7)); |
|
|
|
|
doctorList = hisRegisterDao.queryHisTimeRegDoctorList(deptId, branchId, curDate, DateHelper.getMoveDate(curDate, 7)); |
|
|
|
|
} else { |
|
|
|
|
HisRegisterDao hisRegisterDao = new HisRegisterDao(); |
|
|
|
|
doctorList = hisRegisterDao.queryHisResRegDoctorList(deptId, null); |
|
|
|
|
List<Doctor> todayDoctorList = hisRegisterDao.queryHisRegTodayDoctorList(deptId, null); |
|
|
|
|
for (Doctor doctor : todayDoctorList) { |
|
|
|
|
// 注意:需先查询今日挂号
|
|
|
|
|
doctorList = hisRegisterDao.queryHisRegTodayDoctorList(deptId, null); // 今日挂号
|
|
|
|
|
List<Doctor> resDoctorList = hisRegisterDao.queryHisResRegDoctorList(deptId, null); // 预约挂号
|
|
|
|
|
for (Doctor doctor : resDoctorList) { |
|
|
|
|
Doctor findItem = doctorList.stream().filter(o -> o.getDoctCode().equals(doctor.getDoctCode())).findFirst().orElse(null); |
|
|
|
|
if (findItem == null) { |
|
|
|
|
doctorList.add(doctor); |
|
|
|
|
@ -197,7 +204,7 @@ public class AIGuidanceService { |
|
|
|
|
doctorList = new DoctorService().doctorListFilter(doctorList); |
|
|
|
|
|
|
|
|
|
RegisterDao registerDao = new RegisterDao(); |
|
|
|
|
List<Dept> wxDeptList = registerDao.selectDeptList(); |
|
|
|
|
List<Dept> dbDeptList = registerDao.selectDeptList(); |
|
|
|
|
|
|
|
|
|
String domain = WeChatConfig.getDomain(true); |
|
|
|
|
String deptName, deptCode, headImg, doctCode; |
|
|
|
|
@ -212,10 +219,14 @@ public class AIGuidanceService { |
|
|
|
|
doctCode = doctCode.trim(); |
|
|
|
|
if ("*".equals(doctCode)) { // 任意医生
|
|
|
|
|
item.setDoctorId("0"); |
|
|
|
|
item.setDoctorSex(-1); |
|
|
|
|
doctCode = "0"; |
|
|
|
|
item.setDoctorSex(1); |
|
|
|
|
} else { |
|
|
|
|
item.setDoctorSex(-1); |
|
|
|
|
int doctorSex = 1; |
|
|
|
|
if ("2".equals(doctor.getGenderCode())) { |
|
|
|
|
doctorSex = 2; |
|
|
|
|
} |
|
|
|
|
item.setDoctorSex(doctorSex); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
deptCode = doctor.getDeptCode(); |
|
|
|
|
@ -238,7 +249,7 @@ public class AIGuidanceService { |
|
|
|
|
item.setDoctorLifeAlipayUrl(""); |
|
|
|
|
item.setDoctorEmbedAlipayUrl(""); |
|
|
|
|
|
|
|
|
|
dept = registerDao.deptFilter(wxDeptList, deptCode, deptName, null, null); |
|
|
|
|
dept = registerDao.deptFilter(dbDeptList, deptCode, deptName, null, null); |
|
|
|
|
if (!ObjectUtils.isEmpty(dept.getDeptAlias())) { |
|
|
|
|
deptName = dept.getDeptAlias(); |
|
|
|
|
} |
|
|
|
|
@ -259,11 +270,123 @@ public class AIGuidanceService { |
|
|
|
|
item.setDoctorUrl(webReqURL + "reg-reserve.html#/reg-doctor" + URLHelper.mapParamsToUrl(map, true)); |
|
|
|
|
} |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error(e.getMessage()); |
|
|
|
|
item.setDoctorUrl(""); |
|
|
|
|
log.error("[智能导诊]医生链接异常:{}", e.getMessage()); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
resultList.add(item); |
|
|
|
|
} |
|
|
|
|
return resultList; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 4.1.5 查询就诊人列表 |
|
|
|
|
* |
|
|
|
|
* @param patientId 患者id |
|
|
|
|
* @return map |
|
|
|
|
*/ |
|
|
|
|
public Result getPatientCardList(String patientId, String hosId, String branchId) { |
|
|
|
|
List<AIPatient> cardList = new ArrayList<>(); |
|
|
|
|
Map<String, Object> resp = new HashMap<>(); |
|
|
|
|
resp.put("hospitalId", AIGuidanceConfig.HOS_ID); |
|
|
|
|
resp.put("cardList", cardList); |
|
|
|
|
|
|
|
|
|
if (!hosId.equals(AIGuidanceConfig.HOS_ID)) { // 医院id校验
|
|
|
|
|
log.warn("[智能导诊]查询就诊人列表-hosId不匹配"); |
|
|
|
|
return Result.success(ResultEnum.AI_SUCCESS, resp); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Patient patient = new PatientService().queryOnePatientByPatientId(patientId); |
|
|
|
|
if (patient == null) { |
|
|
|
|
return Result.success(ResultEnum.AI_SUCCESS, resp); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
String birthday = patient.getBirthday(); |
|
|
|
|
String idCardNo = patient.getIdCardNo(); |
|
|
|
|
if ((ObjectUtils.isEmpty(birthday) || birthday.length() != 10) && !ObjectUtils.isEmpty(idCardNo)) { |
|
|
|
|
birthday = IDNumberHelper.getBirthday(idCardNo); |
|
|
|
|
} |
|
|
|
|
if (birthday == null) { |
|
|
|
|
return Result.success(ResultEnum.AI_SUCCESS, resp); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
AIPatient item = new AIPatient(); |
|
|
|
|
item.setName(patient.getName()); |
|
|
|
|
item.setGender("女".equals(patient.getSex()) ? "女" : "男"); // 防空->默认男
|
|
|
|
|
item.setEcardNo(patientId); |
|
|
|
|
item.setBirthday(birthday); |
|
|
|
|
cardList.add(item); |
|
|
|
|
|
|
|
|
|
resp.put("cardList", cardList); |
|
|
|
|
return Result.success(ResultEnum.AI_SUCCESS, resp); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 4.1.9 获取医生号源排班信息(必选) |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
public Result getDoctorSchedule(String hosId, String branchId, String doctorsJson) { |
|
|
|
|
List<AIDoctorSchedule> doctors = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
if (ObjectUtils.isEmpty(doctors)) { |
|
|
|
|
return Result.success(ResultEnum.AI_SUCCESS, doctors); |
|
|
|
|
} |
|
|
|
|
List<AIDoctorSchedule> doctorScheduleList = JsonHelper.parseArray(doctorsJson, AIDoctorSchedule.class); |
|
|
|
|
if (doctorScheduleList.isEmpty()) { |
|
|
|
|
return Result.success(ResultEnum.AI_SUCCESS, doctors); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
List<Doctor> regDoctorList = new ArrayList<>(); |
|
|
|
|
List<Doctor> hisDoctorList; |
|
|
|
|
HisRegisterDao hisRegisterDao = new HisRegisterDao(); |
|
|
|
|
for (AIDoctorSchedule aiDoctorSchedule : doctorScheduleList) { |
|
|
|
|
String departmentId = aiDoctorSchedule.getDepartmentId(); |
|
|
|
|
if (ObjectUtils.isEmpty(departmentId)) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (AIGuidanceConfig.IS_SPLIT_TIME_REG) { // 分时段
|
|
|
|
|
String curDate = DateHelper.getCurDate(); |
|
|
|
|
hisDoctorList = hisRegisterDao.queryHisTimeRegDoctorList(departmentId, branchId, curDate, DateHelper.getMoveDate(curDate, 7)); |
|
|
|
|
} else { |
|
|
|
|
hisDoctorList = hisRegisterDao.queryHisRegTodayDoctorList(departmentId, null); |
|
|
|
|
List<Doctor> resDoctorList = hisRegisterDao.queryHisResRegDoctorList(departmentId, null); |
|
|
|
|
for (Doctor doctor : resDoctorList) { |
|
|
|
|
Doctor findItem = hisDoctorList.stream().filter(o -> o.getDoctCode().equals(doctor.getDoctCode())).findFirst().orElse(null); |
|
|
|
|
if (findItem == null) { |
|
|
|
|
hisDoctorList.add(doctor); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
regDoctorList.addAll(hisDoctorList); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
regDoctorList = new DoctorService().doctorListFilter(regDoctorList); |
|
|
|
|
|
|
|
|
|
String domain = WeChatConfig.getDomain(true); |
|
|
|
|
|
|
|
|
|
AIDoctorSchedule item; |
|
|
|
|
String headImg; |
|
|
|
|
for (Doctor doctor : regDoctorList) { |
|
|
|
|
item = new AIDoctorSchedule(); |
|
|
|
|
item.setDocId(doctor.getDoctCode()); |
|
|
|
|
item.setName(doctor.getDoctName()); |
|
|
|
|
item.setHosId(AIGuidanceConfig.HOS_ID); |
|
|
|
|
item.setDepartmentId(doctor.getDeptCode()); |
|
|
|
|
item.setDoctorLevel(""); |
|
|
|
|
item.setDescription(ObjectUtils.isEmpty(doctor.getDescription()) ? "暂无介绍" : doctor.getDescription()); |
|
|
|
|
headImg = doctor.getHeadImg(); |
|
|
|
|
if (headImg != null && !ObjectUtils.isEmpty(headImg.trim())) { |
|
|
|
|
if (!headImg.contains("data:image/")) { // 不是base64
|
|
|
|
|
item.setIconURL(domain + headImg); // 头像
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
item.setUrl(""); // 挂号链接
|
|
|
|
|
|
|
|
|
|
// item.sets
|
|
|
|
|
doctors.add(item); |
|
|
|
|
} |
|
|
|
|
return Result.success(ResultEnum.AI_SUCCESS, doctors); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|