|
@ -1,10 +1,15 @@
|
|
|
package com.yihu.jw.service.channel;
|
|
|
|
|
|
import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
|
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
|
|
|
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDO;
|
|
|
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDiagnosisDO;
|
|
|
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
|
|
|
import com.yihu.jw.hospital.prescription.dao.PrescriptionDao;
|
|
|
import com.yihu.jw.hospital.prescription.dao.PrescriptionDiagnosisDao;
|
|
|
import com.yihu.jw.hospital.prescription.service.entrance.EntranceService;
|
|
|
import com.yihu.jw.hospital.prescription.service.entrance.XzzxEntranceService;
|
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
|
import com.yihu.jw.util.DateUtil;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
@ -37,34 +42,72 @@ public class PrescriptionDeleteService {
|
|
|
private XzzxEntranceService xzzxEntranceService;
|
|
|
@Autowired
|
|
|
private PrescriptionDiagnosisDao prescriptionDiagnosisDao;
|
|
|
|
|
|
@Autowired
|
|
|
private WlyyHospitalSysDictDao hospitalSysDictDao;
|
|
|
@Autowired
|
|
|
private EntranceService entranceService;
|
|
|
@Autowired
|
|
|
private BasePatientDao basePatientDao;
|
|
|
//定时作废处方
|
|
|
public void deletePrescription() throws Exception{
|
|
|
Calendar ca = Calendar.getInstance();//得到一个Calendar的实例
|
|
|
ca.setTime(new Date()); //设置时间为当前时间
|
|
|
ca.add(Calendar.DATE, -1); //天数减1
|
|
|
Date d = ca.getTime();
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
String s = sdf.format(d);
|
|
|
logger.info("开始日期:"+s);
|
|
|
List<WlyyPrescriptionDO> prescriptionDOS = prescriptionDao.findListByCheckStatus(DateUtil.strToDate(s+" 00:00:00"),DateUtil.strToDate(s+" 23:59:59"));
|
|
|
int amount = 30;
|
|
|
WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("deletePrescription");
|
|
|
if (hospitalSysDictDO!=null){
|
|
|
amount = Integer.parseInt(hospitalSysDictDO.getDictValue());
|
|
|
}
|
|
|
Date date = new Date();
|
|
|
logger.info("开始日期:"+DateUtil.dateToStrLong(date));
|
|
|
List<WlyyPrescriptionDO> prescriptionDOS = prescriptionDao.findListByCheckStatusNoDate();
|
|
|
if (null!=prescriptionDOS&&prescriptionDOS.size()>0){
|
|
|
for (WlyyPrescriptionDO prescriptionDO:prescriptionDOS){
|
|
|
logger.info("处方删除时间满足条件");
|
|
|
String hisId = prescriptionDO.getHisId();
|
|
|
if("xm_xzzx_wx".equalsIgnoreCase(wechatId)){
|
|
|
List<WlyyPrescriptionDiagnosisDO> wlyyPrescriptionDiagnosisDOs = prescriptionDiagnosisDao.findByPrescriptionId(prescriptionDO.getId(),1);
|
|
|
if (null!=wlyyPrescriptionDiagnosisDOs&&wlyyPrescriptionDiagnosisDOs.size()>0){
|
|
|
xzzxEntranceService.deleteCheckInputInfo(hisId,"0",prescriptionDO.getDoctor(),prescriptionDO.getPatientCode(),wlyyPrescriptionDiagnosisDOs);
|
|
|
if (StringUtils.isNotBlank(prescriptionDO.getRealOrder())){
|
|
|
xzzxEntranceService.deletePrescriptionToEntrance(prescriptionDO.getRealOrder());
|
|
|
long num = date.getTime()-prescriptionDO.getCreateTime().getTime();
|
|
|
long day = num/(1000*60*60*24);
|
|
|
if (day>=amount){
|
|
|
logger.info("处方:"+prescriptionDO.getRealOrder()+"已作废时间:"+day);
|
|
|
logger.info("处方删除时间满足条件");
|
|
|
String hisId = prescriptionDO.getHisId();
|
|
|
if("xm_xzzx_wx".equalsIgnoreCase(wechatId)){
|
|
|
List<WlyyPrescriptionDiagnosisDO> wlyyPrescriptionDiagnosisDOs = prescriptionDiagnosisDao.findByPrescriptionId(prescriptionDO.getId(),1);
|
|
|
if (null!=wlyyPrescriptionDiagnosisDOs&&wlyyPrescriptionDiagnosisDOs.size()>0){
|
|
|
xzzxEntranceService.deleteCheckInputInfo(hisId,"0",prescriptionDO.getDoctor(),prescriptionDO.getPatientCode(),wlyyPrescriptionDiagnosisDOs);
|
|
|
if (StringUtils.isNotBlank(prescriptionDO.getRealOrder())){
|
|
|
xzzxEntranceService.deletePrescriptionToEntrance(prescriptionDO.getRealOrder());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
prescriptionDO.setStatus(-4);
|
|
|
prescriptionDO.setCheckStatus(5);
|
|
|
prescriptionDO.setCheckReason("已作废");
|
|
|
logger.info("处方:"+prescriptionDO.getId()+"已作废");
|
|
|
BasePatientDO patientDO =basePatientDao.findById(prescriptionDO.getPatientCode());
|
|
|
String first = "处方超时未结算";
|
|
|
String contentMsg = "您的在线问诊处方已作废,因超过六天未支付。";
|
|
|
String remark="";
|
|
|
prescriptionDao.save(prescriptionDO);
|
|
|
if ("xm_zsyy_wx".equalsIgnoreCase(wechatId)){
|
|
|
String prefix="https://hlwyy.xmzsh.com";
|
|
|
String msgUrl="/ims-wx/index.html#/returnVisit/prescriptionDetail?outpatientId="+prescriptionDO.getOutpatientId()+"&id="+prescriptionDO.getId();
|
|
|
|
|
|
try {
|
|
|
entranceService.ehospitalNotice(
|
|
|
patientDO.getName(),
|
|
|
patientDO.getIdcard(),
|
|
|
patientDO.getMobile(),
|
|
|
first,
|
|
|
prefix+msgUrl,
|
|
|
contentMsg,
|
|
|
remark
|
|
|
);
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
prescriptionDO.setStatus(-1);
|
|
|
prescriptionDO.setCheckStatus(4);
|
|
|
prescriptionDO.setCheckReason("已删除");
|
|
|
logger.info("处方:"+prescriptionDO.getId()+"已删除");
|
|
|
prescriptionDao.save(prescriptionDO);
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|