|
@ -0,0 +1,69 @@
|
|
|
package com.yihu.jw.service.channel;
|
|
|
|
|
|
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDO;
|
|
|
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDiagnosisDO;
|
|
|
import com.yihu.jw.hospital.prescription.dao.PrescriptionDao;
|
|
|
import com.yihu.jw.hospital.prescription.dao.PrescriptionDiagnosisDao;
|
|
|
import com.yihu.jw.hospital.prescription.service.entrance.XzzxEntranceService;
|
|
|
import com.yihu.jw.util.DateUtil;
|
|
|
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.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.Calendar;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
@Component
|
|
|
@Transactional
|
|
|
public class PrescriptionDeleteService {
|
|
|
private static Logger logger = LoggerFactory.getLogger(PrescriptionDeleteService.class);
|
|
|
|
|
|
@Autowired
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
@Value("${wechat.ids}")
|
|
|
private String wechatId;
|
|
|
@Value("${hlwyyEntrance.url}")
|
|
|
private String hlwyyEntranceUrl;
|
|
|
@Autowired
|
|
|
private PrescriptionDao prescriptionDao;
|
|
|
@Autowired
|
|
|
private XzzxEntranceService xzzxEntranceService;
|
|
|
@Autowired
|
|
|
private PrescriptionDiagnosisDao prescriptionDiagnosisDao;
|
|
|
//定时作废处方
|
|
|
public void deletePrescription() throws Exception{
|
|
|
Date d = new Date();
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
String s = sdf.format(d);
|
|
|
List<WlyyPrescriptionDO> prescriptionDOS = prescriptionDao.findListByCheckStatus(DateUtil.strToDate(s+" 00:00:00"));
|
|
|
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());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
prescriptionDO.setStatus(-1);
|
|
|
prescriptionDO.setCheckStatus(4);
|
|
|
prescriptionDO.setCheckReason("已删除");
|
|
|
logger.info("处方:"+prescriptionDO.getId()+"已删除");
|
|
|
prescriptionDao.save(prescriptionDO);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|