0027005599 пре 2 година
родитељ
комит
7895a112bf

+ 3 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/afterwaring/XCFYDataTransferService.java

@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.dynamic.db.DynamicDBUtil;
 import org.jeecg.common.util.dynamic.db.DynamicDBUtil;
 import org.jeecg.modules.medical.Constant;
 import org.jeecg.modules.medical.Constant;
+import org.jeecg.modules.medical.ruleengine.SPELUtil;
 import org.jeecg.modules.medical.ruleengine.TransferDataCallFunction;
 import org.jeecg.modules.medical.ruleengine.TransferDataCallFunction;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.DependsOn;
 import org.springframework.context.annotation.DependsOn;
@@ -47,4 +48,6 @@ public class XCFYDataTransferService {
     }
     }
 
 
 
 
+
+
 }
 }

+ 38 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/common/CommonUtil.java

@@ -0,0 +1,38 @@
+package org.jeecg.modules.medical.common;
+
+import org.jeecg.common.util.SpringContextUtils;
+import org.jeecg.modules.medical.Constant;
+import org.jeecg.modules.medical.ruleengine.RuleEngine;
+import org.jeecg.modules.medical.ruleengine.SPELUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.stereotype.Component;
+
+public class CommonUtil {
+    @Autowired
+    static RedisTemplate redisTemplate = SpringContextUtils.getBean(RedisTemplate.class);
+
+    public static String getProjectType(String projectCode) {
+        String projectType = null;
+        if (projectCode.startsWith(Constant.CONSUMABLE_START_KEY)) {
+            projectType = "consumable";
+        } else if (projectCode.startsWith(Constant.RESTORATIVES_T_START_KEY) ||
+                projectCode.startsWith(Constant.RESTORATIVES_X_START_KEY) ||
+                projectCode.startsWith(Constant.RESTORATIVES_Z_START_KEY)) {
+            projectType = "medicine";
+            //耗材都是字母c开头, 药品是X或Z T, 医疗服务是数字开头
+        } else if (SPELUtil.isNumeric(projectCode)) {
+            projectType = "diagnoses";
+        }
+        return projectType;
+    }
+
+    public static String[] getMedicalCodeAndName(String hisProjectCode){
+        Object value = redisTemplate.opsForHash().get(Constant.HIS_MEDICAL_DICT_KEY, hisProjectCode);
+        if (value == null) {
+            return null;
+        }
+        Object name = redisTemplate.opsForHash().get(Constant.MEDICAL_CODE_NAME_KEY, value.toString());
+        return new String[]{value.toString(), name.toString()};
+    }
+}

+ 29 - 4
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/job/AfterWaringLogJob.java

@@ -1,7 +1,10 @@
 package org.jeecg.modules.medical.job;
 package org.jeecg.modules.medical.job;
 
 
 import cn.hutool.core.collection.CollectionUtil;
 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.Constant;
+import org.jeecg.modules.medical.common.CommonUtil;
 import org.jeecg.modules.medical.entity.AfterIncidentDetailLog;
 import org.jeecg.modules.medical.entity.AfterIncidentDetailLog;
 import org.jeecg.modules.medical.entity.AfterIncidentLog;
 import org.jeecg.modules.medical.entity.AfterIncidentLog;
 import org.jeecg.modules.medical.entity.HospitalizatioSettleDetail;
 import org.jeecg.modules.medical.entity.HospitalizatioSettleDetail;
@@ -20,13 +23,13 @@ import org.quartz.JobExecutionException;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.scheduling.annotation.Async;
 
 
-import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.List;
 
 
 /**
 /**
  * 事后监管任务生成
  * 事后监管任务生成
  */
  */
+@Slf4j
 public class AfterWaringLogJob implements Job {
 public class AfterWaringLogJob implements Job {
     @Autowired
     @Autowired
     IAfterIncidentLogService afterIncidentLogService;
     IAfterIncidentLogService afterIncidentLogService;
@@ -55,7 +58,8 @@ public class AfterWaringLogJob implements Job {
     @Async("commonTaskAsyncPool")
     @Async("commonTaskAsyncPool")
     public void dealAftertask(MasterAdmissionBill masterAdmissionBill) {
     public void dealAftertask(MasterAdmissionBill masterAdmissionBill) {
         boolean updateCount = masterAdmissionBillService.lambdaUpdate().set(MasterAdmissionBill::getState, Constant.DEALING).eq(MasterAdmissionBill::getId, masterAdmissionBill.getId()).update();
         boolean updateCount = masterAdmissionBillService.lambdaUpdate().set(MasterAdmissionBill::getState, Constant.DEALING).eq(MasterAdmissionBill::getId, masterAdmissionBill.getId()).update();
-        if(!updateCount){
+        if (!updateCount) {
+            log.error("住院结算主单为:{} 未更新到处理状态", masterAdmissionBill.getId());
             return;
             return;
         }
         }
         AfterIncidentLog afterIncidentLog = afterIncidentLogService.addAfterIncidentLog(masterAdmissionBill);
         AfterIncidentLog afterIncidentLog = afterIncidentLogService.addAfterIncidentLog(masterAdmissionBill);
@@ -74,8 +78,17 @@ public class AfterWaringLogJob implements Job {
             afterIncidentDetailLog.setMedical_diagnose_name_str(masterAdmissionBill.getYbAdmissionDiseaseName());
             afterIncidentDetailLog.setMedical_diagnose_name_str(masterAdmissionBill.getYbAdmissionDiseaseName());
             afterIncidentDetailLog.setMedical_diagnose_code_str(masterAdmissionBill.getYbAdmissionDiseaseId());
             afterIncidentDetailLog.setMedical_diagnose_code_str(masterAdmissionBill.getYbAdmissionDiseaseId());
             afterIncidentDetailLog.setAmount(hospitalizatioSettleDetail.getCost());
             afterIncidentDetailLog.setAmount(hospitalizatioSettleDetail.getCost());
-            afterIncidentDetailLog.setMedical_project_code(hospitalizatioSettleDetail.getItemId());
-            afterIncidentDetailLog.setMedical_project_name(hospitalizatioSettleDetail.getItemName());
+
+            if (StringUtils.isNotBlank(hospitalizatioSettleDetail.getItemId())) {
+                afterIncidentDetailLog.setMedical_project_code(hospitalizatioSettleDetail.getItemId());
+                afterIncidentDetailLog.setMedical_project_name(hospitalizatioSettleDetail.getItemName());
+            } else {
+                String[] itemIdNameArr = CommonUtil.getMedicalCodeAndName(hospitalizatioSettleDetail.getItemId());
+                if (null != itemIdNameArr) {
+                    afterIncidentDetailLog.setMedical_project_code(itemIdNameArr[0]);
+                    afterIncidentDetailLog.setMedical_project_name(itemIdNameArr[1]);
+                }
+            }
             afterIncidentDetailLog.setProject_name(hospitalizatioSettleDetail.getItemNameHosp());
             afterIncidentDetailLog.setProject_name(hospitalizatioSettleDetail.getItemNameHosp());
             afterIncidentDetailLog.setProject_code(hospitalizatioSettleDetail.getItemIdHosp());
             afterIncidentDetailLog.setProject_code(hospitalizatioSettleDetail.getItemIdHosp());
             afterIncidentDetailLog.setCreateTime(afterIncidentLog.getCreateTime());
             afterIncidentDetailLog.setCreateTime(afterIncidentLog.getCreateTime());
@@ -101,6 +114,18 @@ public class AfterWaringLogJob implements Job {
             afterIncidentDetailLog.setPatient_id(masterAdmissionBill.getPatientId());
             afterIncidentDetailLog.setPatient_id(masterAdmissionBill.getPatientId());
             afterIncidentDetailLog.setPatient_name(masterAdmissionBill.getPatientName());
             afterIncidentDetailLog.setPatient_name(masterAdmissionBill.getPatientName());
             afterIncidentDetailLog.setPatient_age(masterAdmissionBill.getPatientAge());
             afterIncidentDetailLog.setPatient_age(masterAdmissionBill.getPatientAge());
+            afterIncidentDetailLog.setDischarge_status(masterAdmissionBill.getDischargeStatus());
+//            afterIncidentDetailLog.setSingle_dose_number();
+//            afterIncidentDetailLog.setSingle_dose_unit();
+            afterIncidentDetailLog.setVisit_no(masterAdmissionBill.getZyh());
+            afterIncidentDetailLog.setRecipe_no(masterAdmissionBill.getRecipeNo());
+            afterIncidentDetailLog.setVisit_type(Constant.TREAMENT_TYPE_HOSP);
+            afterIncidentDetailLog.setState(Constant.WATING);
+            String projectType = CommonUtil.getProjectType(afterIncidentDetailLog.getMedical_project_code());
+            afterIncidentDetailLog.setProject_type(projectType);
+            afterIncidentDetailLog.setQuantity(hospitalizatioSettleDetail.getNum());
+            afterIncidentDetailLog.setPatient_gender(masterAdmissionBill.getPatientGender());
+//            afterIncidentDetailLog.setInvoice_project()
 //            afterIncidentDetailLog.setOrderType();
 //            afterIncidentDetailLog.setOrderType();
 //            afterIncidentDetailLog.setOrderCatalog();
 //            afterIncidentDetailLog.setOrderCatalog();
             afterIncidentDetailLogList.add(afterIncidentDetailLog);
             afterIncidentDetailLogList.add(afterIncidentDetailLog);

+ 12 - 1
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/job/XCFYDatav_master_admission_billJob.java

@@ -2,7 +2,9 @@ package org.jeecg.modules.medical.job;
 
 
 import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.collection.CollectionUtil;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.StringUtils;
 import org.jeecg.modules.medical.afterwaring.XCFYDataTransferService;
 import org.jeecg.modules.medical.afterwaring.XCFYDataTransferService;
+import org.jeecg.modules.medical.common.CommonUtil;
 import org.jeecg.modules.medical.entity.MasterAdmissionBill;
 import org.jeecg.modules.medical.entity.MasterAdmissionBill;
 import org.jeecg.modules.medical.ruleengine.TransferDataCallFunction;
 import org.jeecg.modules.medical.ruleengine.TransferDataCallFunction;
 import org.jeecg.modules.medical.service.IMasterAdmissionBillService;
 import org.jeecg.modules.medical.service.IMasterAdmissionBillService;
@@ -33,7 +35,7 @@ public class XCFYDatav_master_admission_billJob implements Job {
 
 
     @Override
     @Override
     public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
     public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
-        String sql = "select * from v_master_admission_bill where rownum<1000 %s order by VISIT_TIME asc";
+        String sql = "select * from V_MASTER_ADMISSION_BILL where rownum<1000 %s ";
         while (true) {
         while (true) {
             log.info("开始同步master_admission_bill数据");
             log.info("开始同步master_admission_bill数据");
             String whereSql = "";
             String whereSql = "";
@@ -48,12 +50,21 @@ public class XCFYDatav_master_admission_billJob implements Job {
             Integer count = xcfyDataTransferService.transferDataList(querySql, insertSql, paramMap, new TransferDataCallFunction() {
             Integer count = xcfyDataTransferService.transferDataList(querySql, insertSql, paramMap, new TransferDataCallFunction() {
                 @Override
                 @Override
                 public void transferData(Map<String, Object> dataMap) throws Exception {
                 public void transferData(Map<String, Object> dataMap) throws Exception {
+                    String diagCode = dataMap.getOrDefault("ADMISSION_DISEASE_ID", "").toString();
+                    if (StringUtils.isNotBlank(diagCode)) {
+                        String[] ybDiagCode = CommonUtil.getMedicalCodeAndName(diagCode);
+                        if (null != ybDiagCode) {
+                            dataMap.put("YB_ADMISSION_DISEASE_ID", ybDiagCode[0]);
+                            dataMap.put("YB_ADMISSION_DISEASE_NAME", ybDiagCode[1]);
+                        }
+                    }
                     dataMap.put("CREATE_BY", "auto");
                     dataMap.put("CREATE_BY", "auto");
                     dataMap.put("CREATE_TIME", new Date());
                     dataMap.put("CREATE_TIME", new Date());
                 }
                 }
             });
             });
 
 
             if (count <= 0) {
             if (count <= 0) {
+                log.error("V_MASTER_ADMISSION_BILL 未查询到大于住院ID:{} 的数据, 停止同步", id);
                 return;
                 return;
             }
             }