|
|
@@ -0,0 +1,146 @@
|
|
|
+package org.jeecg.modules.medical.job;
|
|
|
+
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+import org.jeecg.modules.medical.Constant;
|
|
|
+import org.jeecg.modules.medical.common.CommonUtil;
|
|
|
+import org.jeecg.modules.medical.entity.AfterIncidentDetailLog;
|
|
|
+import org.jeecg.modules.medical.entity.AfterIncidentLog;
|
|
|
+import org.jeecg.modules.medical.entity.HospitalizatioSettleDetail;
|
|
|
+import org.jeecg.modules.medical.entity.MasterAdmissionBill;
|
|
|
+import org.jeecg.modules.medical.entity.OutpatientSettleBill;
|
|
|
+import org.jeecg.modules.medical.entity.OutpatientSettlementDetails;
|
|
|
+import org.jeecg.modules.medical.ruleengine.RuleEngine;
|
|
|
+import org.jeecg.modules.medical.service.IAfterIncidentDetailLogService;
|
|
|
+import org.jeecg.modules.medical.service.IAfterIncidentLogService;
|
|
|
+import org.jeecg.modules.medical.service.IHospitalizatioSettleDetailService;
|
|
|
+import org.jeecg.modules.medical.service.IMasterAdmissionBillService;
|
|
|
+import org.jeecg.modules.medical.service.IOutpatientSettleBillService;
|
|
|
+import org.jeecg.modules.medical.service.IOutpatientSettlementDetailsService;
|
|
|
+import org.jeecg.modules.system.entity.SysUser;
|
|
|
+import org.jeecg.modules.system.service.ISysUserService;
|
|
|
+import org.quartz.Job;
|
|
|
+import org.quartz.JobExecutionContext;
|
|
|
+import org.quartz.JobExecutionException;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 门诊事后监管任务生成
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+public class OutpatientAuditLogJob implements Job {
|
|
|
+ @Autowired
|
|
|
+ IAfterIncidentLogService afterIncidentLogService;
|
|
|
+ @Autowired
|
|
|
+ IAfterIncidentDetailLogService afterIncidentDetailLogService;
|
|
|
+ @Autowired
|
|
|
+ RuleEngine ruleEngine;
|
|
|
+ @Autowired
|
|
|
+ IOutpatientSettleBillService outpatientSettleBillService;
|
|
|
+ @Autowired
|
|
|
+ IOutpatientSettlementDetailsService outpatientSettlementDetailsService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ISysUserService sysUserService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
|
|
+ List<OutpatientSettleBill> outpatientSettleBillList = outpatientSettleBillService.lambdaQuery().isNull(OutpatientSettleBill::getState).last(" limit 1000").list();
|
|
|
+ for (OutpatientSettleBill outpatientSettleBill : outpatientSettleBillList) {
|
|
|
+ dealAftertask(outpatientSettleBill);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Async("commonTaskAsyncPool")
|
|
|
+ public void dealAftertask(OutpatientSettleBill outpatientSettleBill) {
|
|
|
+ boolean updateCount = outpatientSettleBillService.lambdaUpdate().set(OutpatientSettleBill::getState, Constant.DEALING).eq(OutpatientSettleBill::getId, outpatientSettleBill.getId()).update();
|
|
|
+ if (!updateCount) {
|
|
|
+ log.error("门诊结算主单为:{} 未更新到处理状态", outpatientSettleBill.getId());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ AfterIncidentLog afterIncidentLog = afterIncidentLogService.addAfterIncidentLogByOutpatient(outpatientSettleBill);
|
|
|
+ List<OutpatientSettlementDetails> outpatientSettlementDetailsList = outpatientSettlementDetailsService.lambdaQuery().eq(OutpatientSettlementDetails::getHisid, outpatientSettleBill.getHisid()).list();
|
|
|
+ List<AfterIncidentDetailLog> afterIncidentDetailLogList = new ArrayList<>();
|
|
|
+ AfterIncidentDetailLog afterIncidentDetailLog = null;
|
|
|
+ List<SysUser> sysUserList = sysUserService.lambdaQuery().eq(SysUser::getDoctorId, afterIncidentLog.getDoctorId()).list();
|
|
|
+ String doctorLevel = "0";
|
|
|
+ if (CollectionUtil.isNotEmpty(sysUserList)) {
|
|
|
+ doctorLevel = sysUserList.get(0).getDoctorLevel();
|
|
|
+ }
|
|
|
+ for (OutpatientSettlementDetails outpatientSettlementDetails : outpatientSettlementDetailsList) {
|
|
|
+ afterIncidentDetailLog = new AfterIncidentDetailLog();
|
|
|
+
|
|
|
+ afterIncidentDetailLog.setAfterIncidentLogId(afterIncidentLog.getId());
|
|
|
+ afterIncidentDetailLog.setMedicalDiagnoseNameStr(outpatientSettleBill.getYbAdmissionDiseaseName().trim());
|
|
|
+ afterIncidentDetailLog.setMedicalDiagnoseCodeStr(outpatientSettleBill.getYbAdmissionDiseaseId().trim());
|
|
|
+ afterIncidentDetailLog.setAmount(outpatientSettlementDetails.getCost().doubleValue());
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(outpatientSettlementDetails.getItemId())) {
|
|
|
+ afterIncidentDetailLog.setMedicalProjectCode(outpatientSettlementDetails.getItemId());
|
|
|
+ afterIncidentDetailLog.setMedicalProjectName(outpatientSettlementDetails.getItemName());
|
|
|
+ } else {
|
|
|
+ String[] itemIdNameArr = CommonUtil.getMedicalCodeAndName(outpatientSettlementDetails.getItemId());
|
|
|
+ if (null != itemIdNameArr) {
|
|
|
+ afterIncidentDetailLog.setMedicalProjectCode(itemIdNameArr[0]);
|
|
|
+ afterIncidentDetailLog.setMedicalProjectName(itemIdNameArr[1]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ afterIncidentDetailLog.setProjectName(outpatientSettlementDetails.getItemNameHosp());
|
|
|
+ afterIncidentDetailLog.setProjectCode(outpatientSettlementDetails.getItemIdHosp());
|
|
|
+ afterIncidentDetailLog.setCreateTime(afterIncidentLog.getCreateTime());
|
|
|
+ afterIncidentDetailLog.setDoctorCode(afterIncidentLog.getDoctorId());
|
|
|
+ afterIncidentDetailLog.setDoctorName(afterIncidentLog.getDoctorName());
|
|
|
+
|
|
|
+ afterIncidentDetailLog.setDoctorLevel(doctorLevel);
|
|
|
+ afterIncidentDetailLog.setUseDay(outpatientSettlementDetails.getUseDay());
|
|
|
+// afterIncidentDetailLog.setDose_day();
|
|
|
+ afterIncidentDetailLog.setDoseForm(outpatientSettlementDetails.getDosageForm());
|
|
|
+ afterIncidentDetailLog.setDoseUnit(outpatientSettlementDetails.getPackageUnit());
|
|
|
+ afterIncidentDetailLog.setPrice(outpatientSettlementDetails.getUnitPrice());
|
|
|
+// afterIncidentDetailLog.setDscgBed(outpatientSettleBill.getAdmBed());
|
|
|
+ afterIncidentDetailLog.setExpenseCategory(outpatientSettlementDetails.getPCategory());
|
|
|
+ afterIncidentDetailLog.setProjectUseTime(outpatientSettlementDetails.getUsageDate());
|
|
|
+ afterIncidentDetailLog.setChangeClass(outpatientSettlementDetails.getPCategory());
|
|
|
+// afterIncidentDetailLog.setInspectionSite();
|
|
|
+// afterIncidentDetailLog.setOutHospDate(outpatientSettleBill.getDischargeDate());
|
|
|
+ afterIncidentDetailLog.setDiagnoseCodeStr(outpatientSettleBill.getAdmissionDiseaseId().trim());
|
|
|
+ afterIncidentDetailLog.setDiagnoseNameStr(outpatientSettleBill.getAdmissionDiseaseName().trim());
|
|
|
+ afterIncidentDetailLog.setMedicalInsuranceMark(outpatientSettleBill.getPayMethod());
|
|
|
+ afterIncidentDetailLog.setMedicalSpecification(outpatientSettlementDetails.getDrugSpec());
|
|
|
+ afterIncidentDetailLog.setTotalAmount(outpatientSettleBill.getMedfeeSumamt().doubleValue());
|
|
|
+ afterIncidentDetailLog.setMedicalDeptCode(outpatientSettleBill.getAdmissionDeptId());
|
|
|
+ afterIncidentDetailLog.setMedicalDeptName(outpatientSettleBill.getAdmissionDeptName());
|
|
|
+ afterIncidentDetailLog.setPatientId(outpatientSettleBill.getPatientId());
|
|
|
+ afterIncidentDetailLog.setPatientName(outpatientSettleBill.getPatientName());
|
|
|
+ afterIncidentDetailLog.setPatientAge(outpatientSettleBill.getPatientAge());
|
|
|
+ afterIncidentDetailLog.setPatientAgeDays(outpatientSettleBill.getPatientAgeDays());
|
|
|
+// afterIncidentDetailLog.setDischargeStatus(outpatientSettleBill.getDischargeStatus());
|
|
|
+// afterIncidentDetailLog.setSingle_dose_number();
|
|
|
+// afterIncidentDetailLog.setSingle_dose_unit();
|
|
|
+ afterIncidentDetailLog.setVisitNo(outpatientSettleBill.getVisitNo());
|
|
|
+ afterIncidentDetailLog.setRecipeNo(outpatientSettleBill.getRecipeNo());
|
|
|
+ afterIncidentDetailLog.setVisit_type(Constant.TREAMENT_TYPE_HOSP);
|
|
|
+ afterIncidentDetailLog.setState(Constant.WATING);
|
|
|
+ String projectType = CommonUtil.getProjectType(afterIncidentDetailLog.getMedicalProjectCode());
|
|
|
+ afterIncidentDetailLog.setProjectType(projectType);
|
|
|
+ afterIncidentDetailLog.setQuantity(outpatientSettlementDetails.getNum());
|
|
|
+ afterIncidentDetailLog.setPatientGender(outpatientSettleBill.getPatientGender());
|
|
|
+// afterIncidentDetailLog.setInHospDate(outpatientSettleBill.getAdmissionDate());
|
|
|
+// afterIncidentDetailLog.setInvoice_project()
|
|
|
+// afterIncidentDetailLog.setOrderType();
|
|
|
+// afterIncidentDetailLog.setOrderCatalog();
|
|
|
+ afterIncidentDetailLogList.add(afterIncidentDetailLog);
|
|
|
+ }
|
|
|
+
|
|
|
+ afterIncidentDetailLogService.saveBatch(afterIncidentDetailLogList);
|
|
|
+ outpatientSettleBillService.lambdaUpdate().set(OutpatientSettleBill::getState, Constant.SUCCESS).eq(OutpatientSettleBill::getId, outpatientSettleBill.getId()).update();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|