wangzhinan 10 mesiacov pred
rodič
commit
18513a97fd

+ 4 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/PrescriptionDao.java

@ -70,6 +70,10 @@ public interface PrescriptionDao extends PagingAndSortingRepository<WlyyPrescrip
    @Query("select a from WlyyPrescriptionDO a where a.createTime>?1 and  a.createTime <?2 and a.status <30 and a.status>=0")
    List<WlyyPrescriptionDO> findListByCheckStatus(Date startTime,Date endTime);
    @Query("select a from WlyyPrescriptionDO a where  a.status <30 and a.status>=20")
    List<WlyyPrescriptionDO> findListByCheckStatusNoDate();
    @Query("select a from WlyyPrescriptionDO a where a.createTime>?1 and  a.createTime <?2 and a.status >=30 ")
    List<WlyyPrescriptionDO> findListBySuccessStatus(Date startTime,Date endTime);

+ 7 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java

@ -16735,4 +16735,11 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        return flag;
    }
    public void delYlzRelationCode(String outpatientId){
        YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
        ylzMedicailRelationDao.delete(ylzMedicalRelationDO);
    }
}

+ 64 - 21
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/service/channel/PrescriptionDeleteService.java

@ -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);
            }
        }

+ 16 - 1
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/web/quota/JobController.java

@ -95,6 +95,9 @@ public class JobController extends BaseController {
    @Autowired
    private TimeoutOverDueService timeoutOverDueService;
    @Autowired
    private PrescriptionDeleteService prescriptionDeleteService;
    @Autowired
    public JobController(JobService jobService, QuartzHelper quartzHelper) {
        this.jobService = jobService;
@ -306,7 +309,7 @@ public class JobController extends BaseController {
                    break;
                case "prescription_auto_delete_job" :
                    //互联网医院 监管平台上报
                    //互联网医院 处方自动删除
                    if (!quartzHelper.isExistJob("prescription_auto_delete_job")) {
                        String trigger = SystemConf.getInstance().getSystemProperties().getProperty("prescription_auto_delete_job");
                        quartzHelper.addJob(PrescriptionAutoDeleteJob.class, trigger, "prescription_auto_delete_job", new HashMap<String, Object>());
@ -1036,4 +1039,16 @@ public class JobController extends BaseController {
        }
    }
    @RequestMapping(value = "/deletePrescription", method = RequestMethod.GET)
    @ApiOperation("测试超时6天作废处方")
    public String deletePrescription(){
        try {
            prescriptionDeleteService.deletePrescription();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return success("操作成功");
    }
}