|
@ -8,13 +8,19 @@ import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
|
|
import com.yihu.jw.entity.base.org.BaseOrgDO;
|
|
import com.yihu.jw.entity.base.org.BaseOrgDO;
|
|
import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
import com.yihu.jw.entity.base.patient.PatientMedicareCardDO;
|
|
import com.yihu.jw.entity.base.patient.PatientMedicareCardDO;
|
|
import com.yihu.jw.entity.hospital.consult.WlyyDoctorClinicRoomDO;
|
|
|
|
|
|
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
|
|
import com.yihu.jw.entity.hospital.consult.WlyyHospitalWaitingRoomDO;
|
|
import com.yihu.jw.entity.hospital.consult.WlyyHospitalWaitingRoomDO;
|
|
|
|
import com.yihu.jw.entity.hospital.dict.WlyyChargeDictDO;
|
|
|
|
import com.yihu.jw.entity.hospital.doctor.WlyyDoctorWorkTimeDO;
|
|
|
|
import com.yihu.jw.entity.hospital.doctor.WlyyPatientRegisterTimeDO;
|
|
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
|
|
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
|
|
import com.yihu.jw.entity.hospital.prescription.*;
|
|
import com.yihu.jw.entity.hospital.prescription.*;
|
|
import com.yihu.jw.hospital.consult.dao.DoctorClinicRoomConsultDao;
|
|
import com.yihu.jw.hospital.consult.dao.DoctorClinicRoomConsultDao;
|
|
import com.yihu.jw.hospital.consult.dao.HospitalWaitingRoomDao;
|
|
import com.yihu.jw.hospital.consult.dao.HospitalWaitingRoomDao;
|
|
import com.yihu.jw.hospital.mapping.dao.DoctorMappingDao;
|
|
|
|
|
|
import com.yihu.jw.hospital.dict.WlyyChargeDictDao;
|
|
|
|
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
|
|
|
|
import com.yihu.jw.hospital.doctor.dao.DoctorWorkTimeDao;
|
|
|
|
import com.yihu.jw.hospital.doctor.dao.PatientRegisterTimeDao;
|
|
import com.yihu.jw.hospital.mapping.service.DoctorMappingService;
|
|
import com.yihu.jw.hospital.mapping.service.DoctorMappingService;
|
|
import com.yihu.jw.hospital.mapping.service.PatientMappingService;
|
|
import com.yihu.jw.hospital.mapping.service.PatientMappingService;
|
|
import com.yihu.jw.hospital.prescription.dao.*;
|
|
import com.yihu.jw.hospital.prescription.dao.*;
|
|
@ -24,21 +30,18 @@ import com.yihu.jw.patient.dao.BasePatientDao;
|
|
import com.yihu.jw.patient.dao.BasePatientMedicareCardDao;
|
|
import com.yihu.jw.patient.dao.BasePatientMedicareCardDao;
|
|
import com.yihu.jw.restmodel.base.dict.DictHospitalDeptVO;
|
|
import com.yihu.jw.restmodel.base.dict.DictHospitalDeptVO;
|
|
import com.yihu.jw.restmodel.base.org.BaseOrgVO;
|
|
import com.yihu.jw.restmodel.base.org.BaseOrgVO;
|
|
|
|
import com.yihu.jw.restmodel.hospital.doctor.WlyyDoctorWorkTimeVO;
|
|
import com.yihu.jw.restmodel.hospital.prescription.*;
|
|
import com.yihu.jw.restmodel.hospital.prescription.*;
|
|
import com.yihu.jw.restmodel.web.MixEnvelop;
|
|
import com.yihu.jw.restmodel.web.MixEnvelop;
|
|
import com.yihu.jw.rm.base.BaseRequestMapping;
|
|
|
|
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
|
|
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
|
|
import com.yihu.jw.util.common.IdCardUtil;
|
|
import com.yihu.jw.util.common.IdCardUtil;
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
import com.yihu.mysql.query.BaseJpaService;
|
|
import com.yihu.mysql.query.BaseJpaService;
|
|
import jxl.*;
|
|
|
|
import jxl.write.*;
|
|
import jxl.write.*;
|
|
import net.sf.json.JSONArray;
|
|
import net.sf.json.JSONArray;
|
|
import net.sf.json.JSONObject;
|
|
import net.sf.json.JSONObject;
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.time.DateUtils;
|
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
@ -49,10 +52,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.io.OutputStream;
|
|
import java.io.OutputStream;
|
|
import java.lang.Boolean;
|
|
import java.lang.Boolean;
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
/**
|
|
* Created by Trick on 2019/5/17.
|
|
* Created by Trick on 2019/5/17.
|
|
@ -97,6 +97,14 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
|
|
private OutpatientDao outpatientDao;
|
|
private OutpatientDao outpatientDao;
|
|
@Autowired
|
|
@Autowired
|
|
private ObjectMapper objectMapper;
|
|
private ObjectMapper objectMapper;
|
|
|
|
@Autowired
|
|
|
|
private WlyyChargeDictDao wlyyChargeDictDao;
|
|
|
|
@Autowired
|
|
|
|
private WlyyHospitalSysDictDao sysDictDao;
|
|
|
|
@Autowired
|
|
|
|
private DoctorWorkTimeDao doctorWorkTimeDao;
|
|
|
|
@Autowired
|
|
|
|
private PatientRegisterTimeDao patientRegisterTimeDao;
|
|
|
|
|
|
@Value("${demo.flag}")
|
|
@Value("${demo.flag}")
|
|
private boolean demoFlag;
|
|
private boolean demoFlag;
|
|
@ -193,6 +201,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
|
|
" o.origin_adm_no AS originAdmNo, " +
|
|
" o.origin_adm_no AS originAdmNo, " +
|
|
" o.register_no AS registerNo, " +
|
|
" o.register_no AS registerNo, " +
|
|
" o.origin_register_no AS originRegisterNo, " +
|
|
" o.origin_register_no AS originRegisterNo, " +
|
|
|
|
" o.origin_con_no AS originConNo," +
|
|
|
|
" o.con_no AS conNo," +
|
|
" o.hospital," +
|
|
" o.hospital," +
|
|
" o.hospital_name AS hospitalName," +
|
|
" o.hospital_name AS hospitalName," +
|
|
" o.win_no AS winNo," +
|
|
" o.win_no AS winNo," +
|
|
@ -461,10 +471,9 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
|
|
* @return
|
|
* @return
|
|
* @throws Exception
|
|
* @throws Exception
|
|
*/
|
|
*/
|
|
public Boolean appointmentRevisit(String outpatientJson,String expressageJson)throws Exception{
|
|
|
|
|
|
public Boolean appointmentRevisit(String outpatientJson,String expressageJson,String registerJson)throws Exception{
|
|
|
|
|
|
//1.保存就诊实体
|
|
//1.保存就诊实体
|
|
|
|
|
|
WlyyOutpatientDO outpatientDO = objectMapper.readValue(outpatientJson,WlyyOutpatientDO.class);
|
|
WlyyOutpatientDO outpatientDO = objectMapper.readValue(outpatientJson,WlyyOutpatientDO.class);
|
|
BasePatientDO patientDO = basePatientDao.findById(outpatientDO.getPatient());
|
|
BasePatientDO patientDO = basePatientDao.findById(outpatientDO.getPatient());
|
|
|
|
|
|
@ -476,6 +485,20 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
|
|
|
|
|
|
WlyyOutpatientDO outpatient = outpatientDao.save(outpatientDO);
|
|
WlyyOutpatientDO outpatient = outpatientDao.save(outpatientDO);
|
|
|
|
|
|
|
|
WlyyPatientRegisterTimeDO registerTimeDO = null;
|
|
|
|
|
|
|
|
try {
|
|
|
|
//如果是视频预约咨询
|
|
|
|
if(StringUtils.isNotBlank(registerJson)){
|
|
|
|
registerTimeDO = objectMapper.readValue(registerJson,WlyyPatientRegisterTimeDO.class);
|
|
|
|
registerTimeDO.setOutpatientId(outpatient.getId());
|
|
|
|
registerTimeDO.setCreateTime(new Date());
|
|
|
|
patientRegisterTimeDao.save(registerTimeDO);
|
|
|
|
}
|
|
|
|
}catch (Exception e){
|
|
|
|
throw new RuntimeException("号源已经被预约,请选择其他号源");
|
|
|
|
}
|
|
|
|
|
|
//2.物流信息
|
|
//2.物流信息
|
|
WlyyPrescriptionExpressageDO expressageDO = objectMapper.readValue(expressageJson,WlyyPrescriptionExpressageDO.class);
|
|
WlyyPrescriptionExpressageDO expressageDO = objectMapper.readValue(expressageJson,WlyyPrescriptionExpressageDO.class);
|
|
expressageDO.setDel(1);
|
|
expressageDO.setDel(1);
|
|
@ -489,61 +512,6 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
// /**
|
|
|
|
// *
|
|
|
|
// * @param json
|
|
|
|
// * @return
|
|
|
|
// */
|
|
|
|
// public String paymentCallback(JSONObject json)throws Exception{
|
|
|
|
//
|
|
|
|
// //创建续方
|
|
|
|
// createPrescription(json);
|
|
|
|
// //创建诊室
|
|
|
|
// createRoom(json);
|
|
|
|
// return null;
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// public Boolean createPrescription(JSONObject json) throws Exception{
|
|
|
|
//
|
|
|
|
// String patient = json.getString("patient");
|
|
|
|
// String doctor = json.getString("doctor");
|
|
|
|
//
|
|
|
|
// String originRealOrder = json.getString("originRealOrder");
|
|
|
|
// String originAdmNo = json.getString("originAdmNo");
|
|
|
|
// String serialNo = json.getString("serialNo");
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// BasePatientDO basePatientDO = basePatientDao.findById(patient);
|
|
|
|
// PatientMedicareCardDO cardDO = basePatientMedicareCardDao.findByTypeAndPatientCodeAndDel(PatientMedicareCardDO.Type.MedicareCard.getType(),patient,"1");
|
|
|
|
// BaseDoctorDO baseDoctorDO = baseDoctorDao.findOne(doctor);
|
|
|
|
// String patNo = patientMappingService.findHisPatNoByIdCard(basePatientDO.getIdcard());
|
|
|
|
//
|
|
|
|
// WlyyPrescriptionVO originPrescriptionVO = findOriginPrescription(serialNo,patNo,originAdmNo,originRealOrder,demoFlag);
|
|
|
|
//
|
|
|
|
// WlyyPrescriptionDO prescription = new WlyyPrescriptionDO();
|
|
|
|
// prescription.setOriginAdmNo(originAdmNo);
|
|
|
|
// prescription.setOriginRealOrder(originRealOrder);
|
|
|
|
// prescription.setOriginSerialNo(serialNo);
|
|
|
|
// prescription.setStatus(0);
|
|
|
|
// prescription.setPatientCode(patient);
|
|
|
|
// prescription.setPatientName(basePatientDO.getName());
|
|
|
|
// prescription.setSsc(cardDO.getCode());
|
|
|
|
// prescription.setDoctor(doctor);
|
|
|
|
// prescription.setDoctorName(baseDoctorDO.getName());
|
|
|
|
//
|
|
|
|
// List<WlyyPrescriptionInfoVO> originInfoVOs = originPrescriptionVO.getInfoVOs();
|
|
|
|
// List<WlyyPrescriptionInfoDO> infoDOs = new ArrayList<>();
|
|
|
|
// List<WlyyPrescriptionDiagnosisVO> diagnosisVOs = originPrescriptionVO.getDiagnosisVOs();
|
|
|
|
// List<WlyyPrescriptionDiagnosisDO> diagnosisDOs = new ArrayList<>();
|
|
|
|
//
|
|
|
|
// prescriptionInfoDao.save(convertToModels(originInfoVOs,infoDOs,WlyyPrescriptionInfoDO.class));
|
|
|
|
// prescriptionDiagnosisDao.save(convertToModels(diagnosisVOs,diagnosisDOs,WlyyPrescriptionDiagnosisDO.class));
|
|
|
|
// prescriptionDao.save(prescription);
|
|
|
|
// return true;
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* 创建候诊室
|
|
* 创建候诊室
|
|
* @param outpatientDO
|
|
* @param outpatientDO
|
|
@ -648,10 +616,20 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
|
|
* @param orgCode
|
|
* @param orgCode
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public List<DictHospitalDeptVO> findDeptByHospital(String orgCode){
|
|
|
|
|
|
public List<DictHospitalDeptVO> findDeptByHospital(String orgCode,String dept){
|
|
List<DictHospitalDeptDO> list = dictHospitalDeptDao.findByOrgCodeIn(orgCode);
|
|
List<DictHospitalDeptDO> list = dictHospitalDeptDao.findByOrgCodeIn(orgCode);
|
|
List<DictHospitalDeptVO> rs = new ArrayList<>();
|
|
List<DictHospitalDeptVO> rs = new ArrayList<>();
|
|
return convertToModels(list,rs,DictHospitalDeptVO.class);
|
|
|
|
|
|
convertToModels(list,rs,DictHospitalDeptVO.class);
|
|
|
|
if(rs!=null&&rs.size()>0&&StringUtils.isNotBlank(dept)){
|
|
|
|
//排序
|
|
|
|
for(int i=0;i<rs.size();i++){
|
|
|
|
String id = rs.get(i).getCode();
|
|
|
|
if(dept.equals(id)){
|
|
|
|
Collections.swap(list,0,i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return rs;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@ -660,23 +638,106 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
|
|
* @param dept
|
|
* @param dept
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public List<Map<String,Object>> findDoctorByHospitalAndDept(String orgCode,String dept){
|
|
|
|
|
|
public List<Map<String,Object>> findDoctorByHospitalAndDept(String orgCode,String chargeType,String dept,String doctorCode){
|
|
String sql ="SELECT " +
|
|
String sql ="SELECT " +
|
|
" d.id, " +
|
|
" d.id, " +
|
|
" d.photo, " +
|
|
" d.photo, " +
|
|
" d.`name`, " +
|
|
" d.`name`, " +
|
|
" h.doctor_duty_code, " +
|
|
|
|
" h.doctor_duty_name " +
|
|
|
|
|
|
" d.expertise," +
|
|
|
|
" d.introduce," +
|
|
|
|
" d.job_title_code AS jobTitleCode, " +
|
|
|
|
" d.job_title_name AS jobTitleName," +
|
|
|
|
" d.charge_type AS chargeType" +
|
|
" FROM " +
|
|
" FROM " +
|
|
" base_doctor d " +
|
|
" base_doctor d " +
|
|
" JOIN base_doctor_hospital h ON h.doctor_code = d.id " +
|
|
" JOIN base_doctor_hospital h ON h.doctor_code = d.id " +
|
|
" WHERE " +
|
|
" WHERE " +
|
|
" h.dept_code = '"+dept+"' " +
|
|
" h.dept_code = '"+dept+"' " +
|
|
" AND h.org_code = '"+orgCode+"'";
|
|
" AND h.org_code = '"+orgCode+"'";
|
|
|
|
if(StringUtils.isNotBlank(chargeType)){
|
|
|
|
sql+=" AND d.charge_type ='"+chargeType+"'";
|
|
|
|
}
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
|
|
|
|
|
if(list!=null&&list.size()>0&&StringUtils.isNotBlank(doctorCode)){
|
|
|
|
//排序
|
|
|
|
for(int i=0;i<list.size();i++){
|
|
|
|
String id = (String)list.get(i).get("id");
|
|
|
|
if(doctorCode.equals(id)){
|
|
|
|
Collections.swap(list,0,i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
return list;
|
|
return list;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取医生列表
|
|
|
|
* @param orgCode
|
|
|
|
* @param dept
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public MixEnvelop findDoctorWithWork(String orgCode,String dept,String chargeType,String doctorCode,Integer page,Integer size){
|
|
|
|
|
|
|
|
String totalSql ="SELECT " +
|
|
|
|
" count(1) AS total " +
|
|
|
|
" FROM " +
|
|
|
|
" base_doctor d " +
|
|
|
|
" JOIN base_doctor_hospital h ON h.doctor_code = d.id " +
|
|
|
|
" WHERE " +
|
|
|
|
" h.dept_code = '"+dept+"' " +
|
|
|
|
" AND h.org_code = '"+orgCode+"'";
|
|
|
|
if(StringUtils.isNotBlank(chargeType)){
|
|
|
|
totalSql+=" AND d.charge_type ='"+chargeType+"'";
|
|
|
|
}
|
|
|
|
List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql);
|
|
|
|
|
|
|
|
Long count = 0L;
|
|
|
|
if (rstotal != null && rstotal.size() > 0) {
|
|
|
|
count = (Long) rstotal.get(0).get("total");
|
|
|
|
}
|
|
|
|
|
|
|
|
String sql ="SELECT " +
|
|
|
|
" d.id, " +
|
|
|
|
" d.photo, " +
|
|
|
|
" d.`name`, " +
|
|
|
|
" d.expertise," +
|
|
|
|
" d.introduce," +
|
|
|
|
" d.job_title_code AS jobTitleCode, " +
|
|
|
|
" d.job_title_name AS jobTitleName," +
|
|
|
|
" d.charge_type AS chargeType" +
|
|
|
|
" FROM " +
|
|
|
|
" base_doctor d " +
|
|
|
|
" JOIN base_doctor_hospital h ON h.doctor_code = d.id " +
|
|
|
|
" WHERE " +
|
|
|
|
" h.dept_code = '"+dept+"' " +
|
|
|
|
" AND h.org_code = '"+orgCode+"'";
|
|
|
|
if(StringUtils.isNotBlank(chargeType)){
|
|
|
|
sql+=" AND d.charge_type ='"+chargeType+"'";
|
|
|
|
}
|
|
|
|
sql += " LIMIT " + (page - 1) * size + "," + size + "";
|
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
|
if(list!=null&&list.size()>0){
|
|
|
|
//获取排班
|
|
|
|
for(Map<String,Object> doctor :list){
|
|
|
|
String id = (String)doctor.get("id");
|
|
|
|
List<WlyyDoctorWorkTimeVO> times = findDoctorWorkTime(id);
|
|
|
|
doctor.put("workTime",times);
|
|
|
|
}
|
|
|
|
if(StringUtils.isNotBlank(doctorCode)){
|
|
|
|
//排序
|
|
|
|
for(int i=0;i<list.size();i++){
|
|
|
|
String id = (String)list.get(i).get("id");
|
|
|
|
if(doctorCode.equals(id)){
|
|
|
|
Collections.swap(list,0,i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return MixEnvelop.getSuccessListWithPage(BaseHospitalRequestMapping.Prescription.api_success, list, page, size, count);
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 挂号
|
|
* 挂号
|
|
* @return
|
|
* @return
|
|
@ -695,6 +756,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
|
|
//存储挂号号
|
|
//存储挂号号
|
|
String serialNo = (String)rs.get("serial_no");
|
|
String serialNo = (String)rs.get("serial_no");
|
|
outpatientDO.setRegisterNo(serialNo);
|
|
outpatientDO.setRegisterNo(serialNo);
|
|
|
|
String conNo = (String)rs.get("@times");
|
|
|
|
outpatientDO.setCardNo(conNo);
|
|
}
|
|
}
|
|
|
|
|
|
return rs;
|
|
return rs;
|
|
@ -1059,4 +1122,239 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
|
|
}
|
|
}
|
|
ws.addCell(label);
|
|
ws.addCell(label);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public List<WlyyChargeDictVO> findByDeptTypeCode(String deptTypeCode){
|
|
|
|
List<WlyyChargeDictDO> dictDOs = wlyyChargeDictDao.findByDeptTypeCode(deptTypeCode);
|
|
|
|
List<WlyyChargeDictVO> dictVOs = new ArrayList<>();
|
|
|
|
return convertToModels(dictDOs,dictVOs,WlyyChargeDictVO.class);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<WlyyDoctorWorkTimeVO> findDoctorWorkTime(String doctor){
|
|
|
|
//获取医生排班规则
|
|
|
|
List<WlyyHospitalSysDictDO> list = sysDictDao.findByDictName("Scheduling");
|
|
|
|
|
|
|
|
Calendar ncTime = Calendar.getInstance();
|
|
|
|
ncTime.setTime(new Date());
|
|
|
|
|
|
|
|
Calendar scTime = Calendar.getInstance();
|
|
|
|
scTime.setTime(new Date());
|
|
|
|
|
|
|
|
Calendar ecTime = Calendar.getInstance();
|
|
|
|
ecTime.setTime(new Date());
|
|
|
|
|
|
|
|
//设置几天号源,及最后天号源的开放时间
|
|
|
|
int days =Integer.parseInt(findHospitalSysDictValue(list,"OpenDays"));
|
|
|
|
String closeTime = findHospitalSysDictValue(list,"CloseTime");
|
|
|
|
|
|
|
|
//比较当前时间是否超过开放时间
|
|
|
|
if(DateUtil.strToDate(DateUtil.getTimeShort(),DateUtil.HH_MM_SS).after(DateUtil.strToDate(closeTime,DateUtil.HH_MM))){
|
|
|
|
//当前时间超过开放时间,可以预约最后一天全部号源
|
|
|
|
ecTime.add(Calendar.DAY_OF_MONTH,days);
|
|
|
|
ecTime.set(ecTime.get(Calendar.YEAR),ecTime.get(Calendar.MONTH),ecTime.get(Calendar.DATE),23,59,59);
|
|
|
|
}else{
|
|
|
|
//当前时间没超过开放时间,可以预约最后一天前一天全部号源
|
|
|
|
ecTime.add(Calendar.DAY_OF_MONTH,days>1?days-1:0);
|
|
|
|
ecTime.set(ecTime.get(Calendar.YEAR),ecTime.get(Calendar.MONTH),ecTime.get(Calendar.DATE),23,59,59);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
List<WlyyDoctorWorkTimeDO> times = doctorWorkTimeDao.findDoctorWorkTime(doctor,scTime.getTime(),ecTime.getTime());
|
|
|
|
|
|
|
|
workTimeFilter(list,times);
|
|
|
|
|
|
|
|
List<WlyyDoctorWorkTimeVO> timeVOs = new ArrayList<>();
|
|
|
|
|
|
|
|
convertToModels(times,timeVOs,WlyyDoctorWorkTimeVO.class);
|
|
|
|
|
|
|
|
if(timeVOs!=null&&timeVOs.size()>0){
|
|
|
|
for(WlyyDoctorWorkTimeVO timeVO : timeVOs){
|
|
|
|
timeVO.setCount(findWorkTimeCount(timeVO.getId()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return timeVOs;
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<WlyyDoctorWorkTimeDO> workTimeFilter(List<WlyyHospitalSysDictDO> sys,List<WlyyDoctorWorkTimeDO> times){
|
|
|
|
|
|
|
|
if(times!=null&×.size()>0){
|
|
|
|
//上午号源开放的最早天数
|
|
|
|
int AMCloseDays =Integer.parseInt(findHospitalSysDictValue(sys,"AMCloseDays"));
|
|
|
|
//每一天上午的最早预约的过号时间
|
|
|
|
String AMCloseTime = findHospitalSysDictValue(sys,"AMCloseTime");
|
|
|
|
//下午号源开放的最早天数
|
|
|
|
int PMCloseDays =Integer.parseInt(findHospitalSysDictValue(sys,"PMCloseDays"));
|
|
|
|
//每一天下午的最早预约的过号时间
|
|
|
|
String PMCloseTime = findHospitalSysDictValue(sys,"PMCloseTime");
|
|
|
|
|
|
|
|
Iterator it = times.iterator();
|
|
|
|
while (it.hasNext()){
|
|
|
|
//设置上午过号时间
|
|
|
|
Calendar scAMTime = Calendar.getInstance();
|
|
|
|
scAMTime.setTime(new Date());
|
|
|
|
scAMTime.add(Calendar.DAY_OF_MONTH,AMCloseDays);
|
|
|
|
|
|
|
|
//设置下午午过号时间
|
|
|
|
Calendar scPMTime = Calendar.getInstance();
|
|
|
|
scPMTime.setTime(new Date());
|
|
|
|
scPMTime.add(Calendar.DAY_OF_MONTH,PMCloseDays);
|
|
|
|
|
|
|
|
WlyyDoctorWorkTimeDO time = (WlyyDoctorWorkTimeDO)it.next();
|
|
|
|
|
|
|
|
Boolean filter = true;
|
|
|
|
|
|
|
|
//1.【上午的排班中】 且 【排班结束时间】如果在【开放时间】前,则移除
|
|
|
|
if(filter&&"1".equals(time.getTimeType())&&time.getEndTime().before(scAMTime.getTime())){
|
|
|
|
it.remove();
|
|
|
|
filter=false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//2.【下午午的排班中】 且 【排班结束时间】如果在【开放时间】前,则移除该排班
|
|
|
|
if(filter&&"2".equals(time.getTimeType())&&time.getEndTime().before(scPMTime.getTime())){
|
|
|
|
it.remove();
|
|
|
|
filter=false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//3.如果【当前时间】过了【上午放号时间】,则移除所有上午的排班
|
|
|
|
if(filter&&"1".equals(time.getTimeType())&&
|
|
|
|
DateUtil.strToDate(DateUtil.getTimeShort(),DateUtil.HH_MM_SS).after(DateUtil.strToDate(AMCloseTime,DateUtil.HH_MM))){
|
|
|
|
scAMTime.set(scAMTime.get(Calendar.YEAR),scAMTime.get(Calendar.MONTH),scAMTime.get(Calendar.DATE),12,00,00);
|
|
|
|
|
|
|
|
if(time.getEndTime().before(scAMTime.getTime())){
|
|
|
|
it.remove();
|
|
|
|
filter=false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//4.如果【当前时间】过了【下午午放号时间】,则移除所有下午的排班
|
|
|
|
if(filter&&"2".equals(time.getTimeType())&&
|
|
|
|
DateUtil.strToDate(DateUtil.getTimeShort(),DateUtil.HH_MM_SS).after(DateUtil.strToDate(PMCloseTime,DateUtil.HH_MM))){
|
|
|
|
scPMTime.set(scAMTime.get(Calendar.YEAR),scAMTime.get(Calendar.MONTH),scAMTime.get(Calendar.DATE),12,00,00);
|
|
|
|
|
|
|
|
if(time.getEndTime().before(scPMTime.getTime())){
|
|
|
|
it.remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return times;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public String findHospitalSysDictValue(List<WlyyHospitalSysDictDO> list,String dictCode){
|
|
|
|
|
|
|
|
if(list!=null&&list.size()>0){
|
|
|
|
for(WlyyHospitalSysDictDO sysDictDO : list){
|
|
|
|
if(dictCode.equals(sysDictDO.getDictCode())){
|
|
|
|
return sysDictDO.getDictValue();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取卡信息
|
|
|
|
* @param cardNo
|
|
|
|
* @param demoFlag
|
|
|
|
* @return
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
public net.sf.json.JSONObject getCardInfo(String cardNo, boolean demoFlag) throws Exception {
|
|
|
|
return entranceService.qutpatientBalance(cardNo,demoFlag);
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<Map<String,Object>> findWorkTimeInfo(String id){
|
|
|
|
WlyyDoctorWorkTimeDO timeDO = doctorWorkTimeDao.findOne(id);
|
|
|
|
Calendar sc = Calendar.getInstance();
|
|
|
|
sc.setTime(timeDO.getStartTime());
|
|
|
|
|
|
|
|
List<Map<String,Object>> rs = new ArrayList<>();
|
|
|
|
|
|
|
|
//1.根据当前时间,去取已过时间的号源
|
|
|
|
while (sc.getTime().before(timeDO.getEndTime())){
|
|
|
|
if(new Date().before(sc.getTime())){
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
//加上时间间隔
|
|
|
|
sc.add(Calendar.MINUTE,timeDO.getTimeInterval());
|
|
|
|
}
|
|
|
|
|
|
|
|
List<WlyyPatientRegisterTimeDO> registerTimeDOs = patientRegisterTimeDao.findByDoctorAndWorkId(timeDO.getDoctor(),id);
|
|
|
|
|
|
|
|
//2.根据时间间隔拆分号源
|
|
|
|
while (sc.getTime().before(timeDO.getEndTime())){
|
|
|
|
|
|
|
|
Map<String,Object> t = new HashedMap();
|
|
|
|
t.put("startTime",DateUtil.dateToStr(sc.getTime(),"yyyy-MM-dd HH:mm:ss"));
|
|
|
|
//加上时间间隔
|
|
|
|
sc.add(Calendar.MINUTE,timeDO.getTimeInterval());
|
|
|
|
|
|
|
|
if(sc.getTime().after(timeDO.getEndTime())){
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
t.put("endTime",DateUtil.dateToStr(sc.getTime(),"yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
|
|
|
if(registerTimeDOs!=null&®isterTimeDOs.size()>0){
|
|
|
|
Boolean registered = false;
|
|
|
|
for(WlyyPatientRegisterTimeDO registerTimeDO : registerTimeDOs){
|
|
|
|
if(t.get("startTime").equals(DateUtil.dateToStr(registerTimeDO.getStartTime(),"yyyy-MM-dd HH:mm:ss"))){
|
|
|
|
registered = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
t.put("registered",registered);
|
|
|
|
}
|
|
|
|
rs.add(t);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rs;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Integer findWorkTimeCount(String id){
|
|
|
|
WlyyDoctorWorkTimeDO timeDO = doctorWorkTimeDao.findOne(id);
|
|
|
|
Calendar sc = Calendar.getInstance();
|
|
|
|
sc.setTime(timeDO.getStartTime());
|
|
|
|
|
|
|
|
List<Map<String,Object>> rs = new ArrayList<>();
|
|
|
|
|
|
|
|
//1.根据当前时间,去取已过时间的号源
|
|
|
|
while (sc.getTime().before(timeDO.getEndTime())){
|
|
|
|
if(new Date().before(sc.getTime())){
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
//加上时间间隔
|
|
|
|
sc.add(Calendar.MINUTE,timeDO.getTimeInterval());
|
|
|
|
}
|
|
|
|
|
|
|
|
List<WlyyPatientRegisterTimeDO> registerTimeDOs = patientRegisterTimeDao.findByDoctorAndWorkId(timeDO.getDoctor(),id);
|
|
|
|
|
|
|
|
//2.根据时间间隔拆分号源
|
|
|
|
while (sc.getTime().before(timeDO.getEndTime())){
|
|
|
|
|
|
|
|
Map<String,Object> t = new HashedMap();
|
|
|
|
t.put("startTime",DateUtil.dateToStr(sc.getTime(),"yyyy-MM-dd HH:mm:ss"));
|
|
|
|
//加上时间间隔
|
|
|
|
sc.add(Calendar.MINUTE,timeDO.getTimeInterval());
|
|
|
|
|
|
|
|
if(sc.getTime().after(timeDO.getEndTime())){
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
t.put("endTime",DateUtil.dateToStr(sc.getTime(),"yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
|
|
|
if(registerTimeDOs!=null&®isterTimeDOs.size()>0){
|
|
|
|
Boolean registered = false;
|
|
|
|
for(WlyyPatientRegisterTimeDO registerTimeDO : registerTimeDOs){
|
|
|
|
if(t.get("startTime").equals(DateUtil.dateToStr(registerTimeDO.getStartTime(),"yyyy-MM-dd HH:mm:ss"))){
|
|
|
|
registered = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!registered){
|
|
|
|
rs.add(t);
|
|
|
|
}
|
|
|
|
}else {
|
|
|
|
rs.add(t);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rs.size();
|
|
|
|
}
|
|
}
|
|
}
|