|
@ -0,0 +1,235 @@
|
|
|
package com.yihu.jw.hospital.appointment.service;
|
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.yihu.jw.entity.hospital.appointment.WlyyAppointmentDO;
|
|
|
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
|
|
|
import com.yihu.jw.hospital.appointment.dao.WlyyAppointmentDao;
|
|
|
import com.yihu.jw.hospital.mapping.service.DoctorMappingService;
|
|
|
import com.yihu.jw.hospital.mapping.service.PatientMappingService;
|
|
|
import com.yihu.jw.hospital.prescription.service.PrescriptionService;
|
|
|
import com.yihu.jw.hospital.prescription.service.entrance.RegisterService;
|
|
|
import com.yihu.jw.restmodel.hospital.register.RegisterAmVO;
|
|
|
import com.yihu.mysql.query.BaseJpaService;
|
|
|
import net.sf.json.JSONArray;
|
|
|
import net.sf.json.JSONObject;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
/**
|
|
|
* Created by Trick on 2019/10/29.
|
|
|
*/
|
|
|
@Service
|
|
|
@Transactional
|
|
|
public class AppointmentService extends BaseJpaService<WlyyAppointmentDO, WlyyAppointmentDao> {
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(PrescriptionService.class);
|
|
|
|
|
|
@Autowired
|
|
|
private RegisterService registerService;
|
|
|
@Autowired
|
|
|
private DoctorMappingService doctorMappingService;
|
|
|
@Autowired
|
|
|
private PatientMappingService patientMappingService;
|
|
|
@Autowired
|
|
|
private WlyyAppointmentDao wlyyAppointmentDao;
|
|
|
@Autowired
|
|
|
private ObjectMapper objectMapper;
|
|
|
|
|
|
@Value("${demo.flag}")
|
|
|
private boolean demoFlag;
|
|
|
|
|
|
/**
|
|
|
* 获取医生号源
|
|
|
* @param dept
|
|
|
* @param docMappingCode
|
|
|
* @param specialCode
|
|
|
* @param startDate
|
|
|
* @param endDate
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public JSONArray getDoctorSchedule(String dept, String docMappingCode,String nameKey,String specialCode,String chargeType,String startDate,String endDate)throws Exception{
|
|
|
logger.info("getDoctorSchedule :");
|
|
|
return registerService.BS10045(dept,docMappingCode,nameKey,specialCode,chargeType,startDate,endDate,demoFlag);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取医生具体号源时间
|
|
|
* @param dept
|
|
|
* @param docMappingCode
|
|
|
* @param date
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public JSONArray getDoctorScheduleTime(String dept,String docMappingCode,String date,String ampm)throws Exception{
|
|
|
logger.info("getDoctorScheduleTime :");
|
|
|
return registerService.BS10046(dept,docMappingCode,date,ampm,demoFlag);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取预约记录列表
|
|
|
* @param patient
|
|
|
* @param doctor
|
|
|
* @param doctorName
|
|
|
* @param opId
|
|
|
* @param startDate
|
|
|
* @param endDate
|
|
|
* @param chargeType
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public JSONArray getAppointmentList(String patient,String doctor,String doctorName,String opId,String startDate,String endDate,String chargeType)throws Exception{
|
|
|
logger.info("getAppointmentList :");
|
|
|
String patientMappingId = null;
|
|
|
if(StringUtils.isNotBlank(patient)){
|
|
|
patientMappingId = patientMappingService.findHisPatNoByPatient(patient);
|
|
|
logger.info("getAppointmentList patientMappingId:"+patientMappingId);
|
|
|
}
|
|
|
|
|
|
String doctorMappingId = null;
|
|
|
if(StringUtils.isNotBlank(doctor)){
|
|
|
DoctorMappingDO doctorMappingDO = doctorMappingService.findMappingCode(doctor,"350211A1002");
|
|
|
if(doctorMappingDO!=null){
|
|
|
doctorMappingId = doctorMappingDO.getMappingCode();
|
|
|
logger.info("getAppointmentList doctorMappingId:"+doctorMappingId);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
String opDoctorId = null;
|
|
|
if(StringUtils.isNotBlank(opId)){
|
|
|
DoctorMappingDO doctorMappingDO = doctorMappingService.findMappingCode(opId,"350211A1002");
|
|
|
if(doctorMappingDO!=null){
|
|
|
opDoctorId = doctorMappingDO.getMappingCode();
|
|
|
logger.info("getAppointmentList opDoctorId:"+opDoctorId);
|
|
|
}
|
|
|
}
|
|
|
return registerService.BS10047(patientMappingId,doctorMappingId,doctorName,opDoctorId,startDate,endDate,chargeType,demoFlag);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 预约
|
|
|
* @param appointmentJson
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public WlyyAppointmentDO makeAppointment(String appointmentJson)throws Exception{
|
|
|
logger.info("getAppointmentList :");
|
|
|
|
|
|
WlyyAppointmentDO wlyyAppointmentDO = objectMapper.readValue(appointmentJson,WlyyAppointmentDO.class);
|
|
|
|
|
|
RegisterAmVO registerAmVO = objectMapper.readValue(appointmentJson,RegisterAmVO.class);
|
|
|
|
|
|
//查找居民映射id
|
|
|
if(StringUtils.isNotBlank(registerAmVO.getPatientId())){
|
|
|
String patientMappingId = patientMappingService.findHisPatNoByPatient(registerAmVO.getPatientId());
|
|
|
if(StringUtils.isBlank(patientMappingId)){
|
|
|
throw new RuntimeException("未找到居民卡信息");
|
|
|
}
|
|
|
registerAmVO.setPatientId(patientMappingId);
|
|
|
}else{
|
|
|
throw new RuntimeException("未找到居民卡信息");
|
|
|
}
|
|
|
|
|
|
//查找医生映射id
|
|
|
if(StringUtils.isNotBlank(registerAmVO.getAppType())){
|
|
|
DoctorMappingDO doctorMappingDO = doctorMappingService.findMappingCode(registerAmVO.getAppType(),"350211A1002");
|
|
|
if(doctorMappingDO!=null){
|
|
|
String doctorMappingId = doctorMappingDO.getMappingCode();
|
|
|
if(StringUtils.isBlank(doctorMappingId)){
|
|
|
throw new RuntimeException("未找医生映射信息");
|
|
|
}
|
|
|
registerAmVO.setAppType(doctorMappingId);
|
|
|
}else{
|
|
|
throw new RuntimeException("未找医生映射信息");
|
|
|
}
|
|
|
}else{
|
|
|
throw new RuntimeException("医生信息为空");
|
|
|
}
|
|
|
|
|
|
if(StringUtils.isNotBlank(registerAmVO.getDoctor())){
|
|
|
DoctorMappingDO doctorMappingDO = doctorMappingService.findMappingCode(registerAmVO.getDoctor(),"350211A1002");
|
|
|
if(doctorMappingDO!=null){
|
|
|
String doctorMappingId = doctorMappingDO.getMappingCode();
|
|
|
if(StringUtils.isBlank(doctorMappingId)){
|
|
|
throw new RuntimeException("未找医生映射信息");
|
|
|
}
|
|
|
registerAmVO.setDoctor(doctorMappingId);
|
|
|
}else{
|
|
|
throw new RuntimeException("未找医生映射信息");
|
|
|
}
|
|
|
}else{
|
|
|
throw new RuntimeException("医生信息为空");
|
|
|
}
|
|
|
|
|
|
|
|
|
net.sf.json.JSONObject res = registerService.BS10048(registerAmVO,demoFlag);
|
|
|
|
|
|
logger.info(res.toString());
|
|
|
|
|
|
wlyyAppointmentDO.setCreateTime(new Date());
|
|
|
wlyyAppointmentDO.setStatus(2);
|
|
|
wlyyAppointmentDO.setType(1);
|
|
|
wlyyAppointmentDO.setHttpLog(res.toString());
|
|
|
wlyyAppointmentDao.save(wlyyAppointmentDO);
|
|
|
|
|
|
return wlyyAppointmentDO;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 取消预约
|
|
|
* @param appointmentJson
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public net.sf.json.JSONObject cancelAppointment(String appointmentJson)throws Exception{
|
|
|
|
|
|
RegisterAmVO registerAmVO = objectMapper.readValue(appointmentJson,RegisterAmVO.class);
|
|
|
//查找居民映射id
|
|
|
if(StringUtils.isNotBlank(registerAmVO.getPatientId())){
|
|
|
String patientMappingId = patientMappingService.findHisPatNoByPatient(registerAmVO.getPatientId());
|
|
|
if(StringUtils.isBlank(patientMappingId)){
|
|
|
throw new RuntimeException("未找到居民卡信息");
|
|
|
}
|
|
|
registerAmVO.setPatientId(patientMappingId);
|
|
|
}else{
|
|
|
throw new RuntimeException("未找到居民卡信息");
|
|
|
}
|
|
|
|
|
|
//查找医生映射id
|
|
|
if(StringUtils.isNotBlank(registerAmVO.getDoctor())){
|
|
|
DoctorMappingDO doctorMappingDO = doctorMappingService.findMappingCode(registerAmVO.getDoctor(),"350211A1002");
|
|
|
if(doctorMappingDO!=null){
|
|
|
String doctorMappingId = doctorMappingDO.getMappingCode();
|
|
|
if(StringUtils.isBlank(doctorMappingId)){
|
|
|
throw new RuntimeException("未找医生映射信息");
|
|
|
}
|
|
|
registerAmVO.setDoctor(doctorMappingId);
|
|
|
}else{
|
|
|
throw new RuntimeException("未找医生映射信息");
|
|
|
}
|
|
|
}else{
|
|
|
throw new RuntimeException("医生信息为空");
|
|
|
}
|
|
|
|
|
|
net.sf.json.JSONObject res = registerService.BS10049(registerAmVO,demoFlag);
|
|
|
logger.info(res.toString());
|
|
|
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据映射id查询互联网医生ID
|
|
|
* @param mappingCode
|
|
|
* @return
|
|
|
*/
|
|
|
public DoctorMappingDO getDoctorByMappingCode(String mappingCode){
|
|
|
return doctorMappingService.findByOrgCodeAndMappingCode("350211A1002",mappingCode);
|
|
|
}
|
|
|
}
|