|
@@ -5,6 +5,7 @@ import cn.hutool.core.date.DateUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.jeecg.common.system.vo.DictModel;
|
|
import org.jeecg.common.system.vo.DictModel;
|
|
|
|
|
+import org.jeecg.common.util.DateUtils;
|
|
|
import org.jeecg.modules.medical.Constant;
|
|
import org.jeecg.modules.medical.Constant;
|
|
|
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.common.CommonUtil;
|
|
@@ -18,6 +19,7 @@ import org.quartz.Job;
|
|
|
import org.quartz.JobExecutionContext;
|
|
import org.quartz.JobExecutionContext;
|
|
|
import org.quartz.JobExecutionException;
|
|
import org.quartz.JobExecutionException;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.data.redis.core.RedisTemplate;
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
@@ -38,6 +40,8 @@ public class XCFYDatav_master_admission_billJob implements Job {
|
|
|
IMasterAdmissionBillService masterAdmissionBillService;
|
|
IMasterAdmissionBillService masterAdmissionBillService;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
ISysDictService sysDictService;
|
|
ISysDictService sysDictService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ RedisTemplate redisTemplate;
|
|
|
|
|
|
|
|
String insertSql = "INSERT INTO `master_admission_bill` (`id`, `bridge_id`, `hisid`, `zyh`, `recipe_no`, `pay_method`, `benefit_type`," +
|
|
String insertSql = "INSERT INTO `master_admission_bill` (`id`, `bridge_id`, `hisid`, `zyh`, `recipe_no`, `pay_method`, `benefit_type`," +
|
|
|
" `hospital_id`, `hospital_name`, `p_level_yy`, `refund_flag`, `p_level`, `bmi_area_id`, `bmi_area_name`, `bill_date`, " +
|
|
" `hospital_id`, `hospital_name`, `p_level_yy`, `refund_flag`, `p_level`, `bmi_area_id`, `bmi_area_name`, `bill_date`, " +
|
|
@@ -76,94 +80,96 @@ 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 hisid is not null and pay_method!='自费' and bill_date<=:END_BILL_DATE %s and rownum<=1000 order by bill_date asc";
|
|
|
|
|
|
|
+ String sql = "select * from V_MASTER_ADMISSION_BILL where hisid is not null and pay_method!='自费' and bill_date<=:END_BILL_DATE %s order by bill_date asc";
|
|
|
Date endBillDate = DateUtil.yesterday();
|
|
Date endBillDate = DateUtil.yesterday();
|
|
|
endBillDate = DateUtil.endOfDay(endBillDate);
|
|
endBillDate = DateUtil.endOfDay(endBillDate);
|
|
|
List<DictModel> dictModelList = sysDictService.getDictItems("discharge_method");
|
|
List<DictModel> dictModelList = sysDictService.getDictItems("discharge_method");
|
|
|
- Map<String,String> dischargeMethodMap = new HashMap<>();
|
|
|
|
|
- for(DictModel dictModel : dictModelList){
|
|
|
|
|
|
|
+ Map<String, String> dischargeMethodMap = new HashMap<>();
|
|
|
|
|
+ for (DictModel dictModel : dictModelList) {
|
|
|
dischargeMethodMap.put(dictModel.getText(), dictModel.getValue());
|
|
dischargeMethodMap.put(dictModel.getText(), dictModel.getValue());
|
|
|
}
|
|
}
|
|
|
- while (true) {
|
|
|
|
|
- String whereSql = "";
|
|
|
|
|
- Date billDate = getBillDate();
|
|
|
|
|
- log.info("开始同步master_admission_bill数据,获取上个同步开始结算日期:{} 结束日期:{}", billDate, endBillDate);
|
|
|
|
|
- Map<String, Object> paramMap = new HashMap<>();
|
|
|
|
|
- if (null != billDate) {
|
|
|
|
|
- whereSql = " and BILL_DATE>:BILL_DATE";
|
|
|
|
|
- paramMap.put("BILL_DATE", billDate);
|
|
|
|
|
- }
|
|
|
|
|
- paramMap.put("END_BILL_DATE", endBillDate);
|
|
|
|
|
- String querySql = String.format(sql, whereSql);
|
|
|
|
|
- Integer count = xcfyDataTransferService.transferDataList(querySql, insertSql, paramMap, new TransferDataCallFunction() {
|
|
|
|
|
- @Override
|
|
|
|
|
- public Boolean transferData(Map<String, Object> dataMap) throws Exception {
|
|
|
|
|
- dataMap.put("PAY_METHOD", 1);
|
|
|
|
|
- String hisId = dataMap.get("HISID").toString();
|
|
|
|
|
- Integer count = transferHospSettleDetail(hisId);
|
|
|
|
|
- if (null == count || count <= 0) {
|
|
|
|
|
- log.error("hisid:{} 未查询到住院结算清单", hisId);
|
|
|
|
|
- return false;
|
|
|
|
|
- }
|
|
|
|
|
- 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]);
|
|
|
|
|
- } else {
|
|
|
|
|
- log.error("医院诊断编码:{} 有hisid 缺少医保编码映射关系", diagCode);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
|
|
+ String whereSql = "";
|
|
|
|
|
+ Date billDate = getBillDate();
|
|
|
|
|
+ log.info("开始同步master_admission_bill数据,获取上个同步开始结算日期:{} 结束日期:{}", billDate, endBillDate);
|
|
|
|
|
+ Map<String, Object> paramMap = new HashMap<>();
|
|
|
|
|
+ if (null != billDate) {
|
|
|
|
|
+ whereSql = " and BILL_DATE>:BILL_DATE";
|
|
|
|
|
+ paramMap.put("BILL_DATE", billDate);
|
|
|
|
|
+ }
|
|
|
|
|
+ paramMap.put("END_BILL_DATE", endBillDate);
|
|
|
|
|
+ String querySql = String.format(sql, whereSql);
|
|
|
|
|
+ Integer count = xcfyDataTransferService.transferDataList(querySql, insertSql, paramMap, new TransferDataCallFunction() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Boolean transferData(Map<String, Object> dataMap) throws Exception {
|
|
|
|
|
+ dataMap.put("PAY_METHOD", 1);
|
|
|
|
|
+ String hisId = dataMap.get("HISID").toString();
|
|
|
|
|
+ Integer count = transferHospSettleDetail(hisId);
|
|
|
|
|
+ String billDateStr = DateUtils.date2Str((Date) dataMap.get("BILL_DATE"), DateUtils.date_sdf.get());
|
|
|
|
|
+ redisTemplate.opsForHash().put(Constant.JOB_CONTINUE_PARAM, "MASTER_ADMISSION_BILL", billDateStr);
|
|
|
|
|
+ if (null == count || count <= 0) {
|
|
|
|
|
+ log.error("hisid:{} 未查询到住院结算清单", hisId);
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ 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]);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ log.error("医院诊断编码:{} 有hisid 缺少医保编码映射关系", diagCode);
|
|
|
}
|
|
}
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- String disDiagCode = dataMap.getOrDefault("DISCHARGE_DISEASE_ID_MAIN", "").toString();
|
|
|
|
|
- if (StringUtils.isNotBlank(disDiagCode)) {
|
|
|
|
|
- String[] ybDiagCode = CommonUtil.getMedicalCodeAndName(disDiagCode);
|
|
|
|
|
- if (null != ybDiagCode) {
|
|
|
|
|
- dataMap.put("YB_DISCHARGE_DISEASE_ID_MAIN", ybDiagCode[0]);
|
|
|
|
|
- dataMap.put("YB_DISCHARGE_DISEASE_NAME_MAIN", ybDiagCode[1]);
|
|
|
|
|
- } else {
|
|
|
|
|
- log.error("医院诊断编码:{} 有hisid 缺少医保编码映射关系", diagCode);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ String disDiagCode = dataMap.getOrDefault("DISCHARGE_DISEASE_ID_MAIN", "").toString();
|
|
|
|
|
+ if (StringUtils.isNotBlank(disDiagCode)) {
|
|
|
|
|
+ String[] ybDiagCode = CommonUtil.getMedicalCodeAndName(disDiagCode);
|
|
|
|
|
+ if (null != ybDiagCode) {
|
|
|
|
|
+ dataMap.put("YB_DISCHARGE_DISEASE_ID_MAIN", ybDiagCode[0]);
|
|
|
|
|
+ dataMap.put("YB_DISCHARGE_DISEASE_NAME_MAIN", ybDiagCode[1]);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ log.error("医院诊断编码:{} 有hisid 缺少医保编码映射关系", diagCode);
|
|
|
}
|
|
}
|
|
|
- Object patientAge = dataMap.getOrDefault("PATIENT_AGE", "0天");
|
|
|
|
|
- Integer days = DateTimeUtil.getDayByAgeStr(patientAge.toString());
|
|
|
|
|
- Object visitTime = dataMap.get("VISIT_TIME");
|
|
|
|
|
- Object patientBirthday = dataMap.get("PATIENT_BIRTHDAY");
|
|
|
|
|
- Long ageDays = 0l;
|
|
|
|
|
- if (null != patientBirthday && days <= 0) {
|
|
|
|
|
- Date patientBirthDayDate = (Date) patientBirthday;
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ Object patientAge = dataMap.getOrDefault("PATIENT_AGE", "0天");
|
|
|
|
|
+ Integer days = DateTimeUtil.getDayByAgeStr(patientAge.toString());
|
|
|
|
|
+ Object visitTime = dataMap.get("VISIT_TIME");
|
|
|
|
|
+ Object patientBirthday = dataMap.get("PATIENT_BIRTHDAY");
|
|
|
|
|
+ Long ageDays = 0l;
|
|
|
|
|
+ if (null != patientBirthday && days <= 0) {
|
|
|
|
|
+ Date patientBirthDayDate = (Date) patientBirthday;
|
|
|
|
|
|
|
|
- if (null != visitTime) {
|
|
|
|
|
- Date visitTimeDate = (Date) visitTime;
|
|
|
|
|
- ageDays = DateUtil.betweenDay(patientBirthDayDate, visitTimeDate, false);
|
|
|
|
|
- } else {
|
|
|
|
|
- ageDays = DateUtil.betweenDay(patientBirthDayDate, new Date(), false);
|
|
|
|
|
- }
|
|
|
|
|
- dataMap.put("PATIENT_AGE_DAYS", ageDays.doubleValue());
|
|
|
|
|
|
|
+ if (null != visitTime) {
|
|
|
|
|
+ Date visitTimeDate = (Date) visitTime;
|
|
|
|
|
+ ageDays = DateUtil.betweenDay(patientBirthDayDate, visitTimeDate, false);
|
|
|
} else {
|
|
} else {
|
|
|
- dataMap.put("PATIENT_AGE_DAYS", days.doubleValue());
|
|
|
|
|
|
|
+ ageDays = DateUtil.betweenDay(patientBirthDayDate, new Date(), false);
|
|
|
}
|
|
}
|
|
|
- dataMap.put("CREATE_BY", "auto");
|
|
|
|
|
- dataMap.put("CREATE_TIME", new Date());
|
|
|
|
|
- Object patientGender = dataMap.get("PATIENT_GENDER");
|
|
|
|
|
- dataMap.put("PATIENT_GENDER", CommonUtil.getMedicalSex(patientGender));
|
|
|
|
|
|
|
+ dataMap.put("PATIENT_AGE_DAYS", ageDays.doubleValue());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ dataMap.put("PATIENT_AGE_DAYS", days.doubleValue());
|
|
|
|
|
+ }
|
|
|
|
|
+ dataMap.put("CREATE_BY", "auto");
|
|
|
|
|
+ dataMap.put("CREATE_TIME", new Date());
|
|
|
|
|
+ Object patientGender = dataMap.get("PATIENT_GENDER");
|
|
|
|
|
+ dataMap.put("PATIENT_GENDER", CommonUtil.getMedicalSex(patientGender));
|
|
|
|
|
|
|
|
- xcfyDataTransferService.transferCheckList(hisId);
|
|
|
|
|
- String zyh = dataMap.get("ZYH").toString();
|
|
|
|
|
- xcfyDataTransferService.transferPrescriptionOrder(zyh);
|
|
|
|
|
|
|
+ xcfyDataTransferService.transferCheckList(hisId);
|
|
|
|
|
+ String zyh = dataMap.get("ZYH").toString();
|
|
|
|
|
+ xcfyDataTransferService.transferPrescriptionOrder(zyh);
|
|
|
// transferMedicalRecordHomePage(zyh, dischargeMethodMap);
|
|
// transferMedicalRecordHomePage(zyh, dischargeMethodMap);
|
|
|
- xcfyDataTransferService.transferOperation(zyh);
|
|
|
|
|
- return true;
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- if (count <= 0) {
|
|
|
|
|
- log.error("V_MASTER_ADMISSION_BILL 未查询到大于住院billdate:{} 小于等于住院billdate:{} 的数据,停止同步", billDate, endBillDate);
|
|
|
|
|
- return;
|
|
|
|
|
|
|
+ xcfyDataTransferService.transferOperation(zyh);
|
|
|
|
|
+ return true;
|
|
|
}
|
|
}
|
|
|
|
|
+ });
|
|
|
|
|
+ if (count <= 0) {
|
|
|
|
|
+ log.error("V_MASTER_ADMISSION_BILL 未查询到大于住院billdate:{} 小于等于住院billdate:{} 的数据,停止同步", billDate, endBillDate);
|
|
|
|
|
+ return;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 根据主单hisid同步明细数据
|
|
* 根据主单hisid同步明细数据
|
|
|
*
|
|
*
|
|
@@ -227,7 +233,7 @@ public class XCFYDatav_master_admission_billJob implements Job {
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public Integer transferMedicalRecordHomePage(String zyh,Map<String,String> dischargeMethodMap) {
|
|
|
|
|
|
|
+ public Integer transferMedicalRecordHomePage(String zyh, Map<String, String> dischargeMethodMap) {
|
|
|
String querySql = "select * from V_MEDICAL_RECORD_HOMEPAGE where ZYH=:ZYH";
|
|
String querySql = "select * from V_MEDICAL_RECORD_HOMEPAGE where ZYH=:ZYH";
|
|
|
|
|
|
|
|
log.info("开始同步V_MEDICAL_RECORD_HOMEPAGE数据,获取zyh:{}", zyh);
|
|
log.info("开始同步V_MEDICAL_RECORD_HOMEPAGE数据,获取zyh:{}", zyh);
|
|
@@ -247,8 +253,8 @@ public class XCFYDatav_master_admission_billJob implements Job {
|
|
|
//4非医嘱离院
|
|
//4非医嘱离院
|
|
|
//5死亡
|
|
//5死亡
|
|
|
//9其他
|
|
//9其他
|
|
|
- String dischargeStatus = dataMap.getOrDefault("DISCHARGE_STATUS","其他").toString();
|
|
|
|
|
- if(dischargeMethodMap.containsKey(dischargeStatus)){
|
|
|
|
|
|
|
+ String dischargeStatus = dataMap.getOrDefault("DISCHARGE_STATUS", "其他").toString();
|
|
|
|
|
+ if (dischargeMethodMap.containsKey(dischargeStatus)) {
|
|
|
dataMap.put("DISCHARGE_STATUS", dischargeMethodMap.get(dischargeStatus));
|
|
dataMap.put("DISCHARGE_STATUS", dischargeMethodMap.get(dischargeStatus));
|
|
|
}
|
|
}
|
|
|
return true;
|
|
return true;
|
|
@@ -260,11 +266,17 @@ public class XCFYDatav_master_admission_billJob implements Job {
|
|
|
|
|
|
|
|
|
|
|
|
|
public Date getBillDate() {
|
|
public Date getBillDate() {
|
|
|
- List<MasterAdmissionBill> masterAdmissionBillList = masterAdmissionBillService.lambdaQuery().orderByDesc(MasterAdmissionBill::getBillDate).last("limit 1").list();
|
|
|
|
|
- if (CollectionUtil.isEmpty(masterAdmissionBillList)) {
|
|
|
|
|
|
|
+// List<MasterAdmissionBill> masterAdmissionBillList = masterAdmissionBillService.lambdaQuery().orderByDesc(MasterAdmissionBill::getBillDate).last("limit 1").list();
|
|
|
|
|
+// if (CollectionUtil.isEmpty(masterAdmissionBillList)) {
|
|
|
|
|
+// return null;
|
|
|
|
|
+// }
|
|
|
|
|
+// return masterAdmissionBillList.get(0).getBillDate();
|
|
|
|
|
+ Object startBillDate = redisTemplate.opsForHash().get(Constant.JOB_CONTINUE_PARAM, "MASTER_ADMISSION_BILL");
|
|
|
|
|
+ if(null == startBillDate){
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
- return masterAdmissionBillList.get(0).getBillDate();
|
|
|
|
|
|
|
+ return DateUtils.str2Date(startBillDate.toString(), DateUtils.date_sdf.get());
|
|
|
|
|
+// return (Date) startBillDate;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|