0027005599 vor 1 Jahr
Ursprung
Commit
db32511ed4

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

@@ -4,16 +4,15 @@ import cn.hutool.core.collection.CollectionUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.dynamic.db.DynamicDBUtil;
 import org.jeecg.modules.medical.Constant;
-import org.jeecg.modules.medical.ruleengine.SPELUtil;
+import org.jeecg.modules.medical.common.CommonUtil;
 import org.jeecg.modules.medical.ruleengine.TransferDataCallFunction;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.DependsOn;
-import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
 import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
 import org.springframework.stereotype.Component;
 
 import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -21,6 +20,36 @@ import java.util.Map;
 @Component
 public class XCFYDataTransferService {
 
+    String checkListInsertSql = "INSERT INTO check_list (id, hisid, patient_id, gender, age, department, inp_outpatient_number, check_list_num, item_id, item_name, check_time, create_time, create_by, report_time) VALUES (:ID,:HISID,:PATIENT_ID,:GENDER,:AGE,:DEPARTMENT,:INP_OUTPATIENT_NUMBER,:CHECK_LIST_NUM,:ITEM_ID,:ITEM_NAME,:CHECK_TIME,:CREATE_TIME,:CREATE_BY,:REPORT_TIME)";
+
+
+    String prescriptionOrderInsertSql = "INSERT INTO prescription_order (patient_id, inp_outpatient_number, order_number, " +
+            "order_time, stop_order_time, order_status, order_type, order_catalog, item_id, item_name, drug_spec, " +
+            "each_dose, dose_unit, exe_frequency, days_timelines, medication_method, drug_use_total, inspection_site, " +
+            "mark, start_exc_time, intended_stop_time, input_operator, input_time, order_doctor, order_department, " +
+            "proof_nurse, proof_time, stop_order_operater, stop_order_exc_time, stop_order_doctor, exc_operater, " +
+            "exc_department, approver, approval_time, medical_insurance_mark, create_time, create_by, " +
+            "medical_insurance_ratio) VALUES (:PATIENT_ID,:INP_OUTPATIENT_NUMBER,:ORDER_NUMBER," +
+            ":ORDER_TIME,:STOP_ORDER_TIME,:ORDER_STATUS,:ORDER_TYPE,:ORDER_CATALOG,:ITEM_ID,:ITEM_NAME," +
+            ":DRUG_SPEC,:EACH_DOSE,:DOSE_UNIT,:EXE_FREQUENCY,:DAYS_TIMELINES,:MEDICATION_METHOD,:DRUG_USE_TOTAL," +
+            ":INSPECTION_SITE,:MARK,:START_EXC_TIME,:INTENDED_STOP_TIME,:INPUT_OPERATOR,:INPUT_TIME,:ORDER_DOCTOR," +
+            ":ORDER_DEPARTMENT,:PROOF_NURSE,:PROOF_TIME,:STOP_ORDER_OPERATER,:STOP_ORDER_EXC_TIME,:STOP_ORDER_DOCTOR," +
+            ":EXC_OPERATER,:EXC_DEPARTMENT,:APPROVER,:APPROVAL_TIME,:MEDICAL_INSURANCE_MARK,:CREATE_TIME,:CREATE_BY," +
+            ":MEDICAL_INSURANCE_RATIO)";
+
+
+    public static String operationInsertSql = "INSERT INTO operation (visit_no, treatment_type, operation_no, operation_code, patient_id, patient_name, patient_gender, operation_name, operation_start_time, " +
+            "operation_end_time, operation_doc_no, operation_doc_name, operation_dept_no, operation_dept_name, operation_source, operation_order_time, operation_room_no, " +
+            "operation_site_code, operation_diag_code, operation_diag_name, suf_diag_code, suf_diag_name, operation_type, operation_level, reoperation, incision_healing_code, " +
+            "incision_type, is_implant, implant_no, implant_name, first_doc_no, first_doc_name, second_doc_no, second_doc_name, third_doc_no, third_doc_name, direct_doc_no, " +
+            "direct_doc_name, anesthesia_type_name, anesthesia_doc_no, " +
+            "anesthesia_doc_name, anesthesia_start_time, anesthesia_end_time, antibacterial_time, premedication_time_point, intraoperative_dosing, amount, create_by, create_time) " +
+            "VALUES (:VISIT_NO,:TREATMENT_TYPE,:OPERATION_NO,:OPERATION_CODE,:PATIENT_ID,:PATIENT_NAME,:PATIENT_GENDER,:OPERATION_NAME,:OPERATION_START_TIME,:OPERATION_END_TIME," +
+            ":OPERATION_DOC_NO,:OPERATION_DOC_NAME,:OPERATION_DEPT_NO,:OPERATION_DEPT_NAME,:OPERATION_SOURCE,:OPERATION_ORDER_TIME,:OPERATION_ROOM_NO,:OPERATION_SITE_CODE," +
+            ":OPERATION_DIAG_CODE,:OPERATION_DIAG_NAME,:SUF_DIAG_CODE,:SUF_DIAG_NAME,:OPERATION_TYPE,:OPERATION_LEVEL,:REOPERATION,:INCISION_HEALING_CODE,:INCISION_TYPE," +
+            ":IS_IMPLANT,:IMPLANT_NO,:IMPLANT_NAME,:FIRST_DOC_NO,:FIRST_DOC_NAME,:SECOND_DOC_NO,:SECOND_DOC_NAME,:THIRD_DOC_NO,:THIRD_DOC_NAME,:DIRECT_DOC_NO,:DIRECT_DOC_NAME," +
+            ":ANESTHESIA_TYPE_NAME,:ANESTHESIA_DOC_NO,:ANESTHESIA_DOC_NAME,:ANESTHESIA_START_TIME,:ANESTHESIA_END_TIME,:ANTIBACTERIAL_TIME,:PREMEDICATION_TIME_POINT," +
+            ":INTRAOPERATIVE_DOSING,:AMOUNT,:CREATE_BY,:CREATE_TIME)";
 
     public Integer transferDataList(String querySql, String insertSql, Map<String, Object> paramMap, TransferDataCallFunction transferDataCallFunction) {
         NamedParameterJdbcTemplate namedParameterJdbcTemplate = DynamicDBUtil.getNamedParameterJdbcTemplate(Constant.FY_ORACLE);
@@ -48,6 +77,71 @@ public class XCFYDataTransferService {
     }
 
 
+    /**
+     * 同步对应hisid检查列表
+     *
+     * @param hsdId
+     * @return
+     */
+    public Integer transferCheckList(String hsdId) {
+        String querySql = "select * from V_CHECK_LIST where HISID=:HISID ";
+        log.info("开始同步v_check_list数据,获取HISID:{}", hsdId);
+        Map<String, Object> paramMap = new HashMap<>();
+        paramMap.put("HISID", hsdId);
+        Integer count = transferDataList(querySql, checkListInsertSql, paramMap, new TransferDataCallFunction() {
+            @Override
+            public void transferData(Map<String, Object> dataMap) throws Exception {
+                dataMap.put("CREATE_BY", "auto");
+                dataMap.put("CREATE_TIME", new Date());
+                Object patientGender = dataMap.get("GENDER");
+                dataMap.put("GENDER", CommonUtil.getMedicalSex(patientGender));
+            }
+        });
+        log.info("结束同步v_check_list数据,获取HISID:{} 条数:{}", hsdId, count);
+        return count;
+    }
+
+    /**
+     * 同步医嘱
+     *
+     * @param vistNo
+     * @return
+     */
+    public Integer transferPrescriptionOrder(String vistNo) {
+        String querySql = "select * from V_PRESCRIPTION_ORDER where inp_outpatient_number=:INP_OUTPATIENT_NUMBER";
+        log.info("开始同步V_PRESCRIPTION_ORDER数据,获取住院号:{}", vistNo);
+        Map<String, Object> paramMap = new HashMap<>();
+        paramMap.put("INP_OUTPATIENT_NUMBER", vistNo);
+
+        Integer count = transferDataList(querySql, prescriptionOrderInsertSql, paramMap, new TransferDataCallFunction() {
+            @Override
+            public void transferData(Map<String, Object> dataMap) throws Exception {
+                dataMap.put("CREATE_BY", "auto");
+                dataMap.put("CREATE_TIME", new Date());
+            }
+        });
+        log.info("结束同步V_PRESCRIPTION_ORDER数据,获取住院号:{} 条数:{}", vistNo, count);
+        return count;
+
+    }
+
+    public Integer transferOperation(String visitNo) {
+        String querySql = "select * from V_OPERATION where VISIT_NO=:VISIT_NO";
+
+        log.info("开始同步V_OPERATION数据,获取住院号/门诊号:{}", visitNo);
+        Map<String, Object> paramMap = new HashMap<>();
+        paramMap.put("VISIT_NO", visitNo);
+        Integer count = transferDataList(querySql, operationInsertSql, paramMap, new TransferDataCallFunction() {
+            @Override
+            public void transferData(Map<String, Object> dataMap) throws Exception {
+                dataMap.put("CREATE_BY", "auto");
+                dataMap.put("CREATE_TIME", new Date());
+            }
+        });
+        log.info("结束同步V_OPERATION数据,获取住院号/门诊号:{} 条数:{}", visitNo, count);
+        return count;
+
+    }
 
 
 }

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

@@ -4,12 +4,11 @@ import cn.hutool.core.date.DateUtil;
 import lombok.extern.slf4j.Slf4j;
 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;
 
+import java.time.LocalDate;
+import java.time.Period;
 import java.util.Date;
 
 @Slf4j
@@ -32,7 +31,7 @@ public class CommonUtil {
         return projectType;
     }
 
-    public static String[] getMedicalCodeAndName(String hisProjectCode){
+    public static String[] getMedicalCodeAndName(String hisProjectCode) {
         Object value = redisTemplate.opsForHash().get(Constant.HIS_MEDICAL_DICT_KEY, hisProjectCode);
         if (value == null) {
             return null;
@@ -41,12 +40,12 @@ public class CommonUtil {
         return new String[]{value.toString(), name.toString()};
     }
 
-    public static Object getNameByCode(String value){
+    public static Object getNameByCode(String value) {
         Object name = redisTemplate.opsForHash().get(Constant.MEDICAL_CODE_NAME_KEY, value);
         return name;
     }
 
-    public static boolean checkProjectCodeInItems(String projectCode){
+    public static boolean checkProjectCodeInItems(String projectCode) {
         Object value = redisTemplate.opsForHash().get(Constant.HIS_MEDICAL_DICT_KEY, projectCode);
         if (value == null) {
             return false;
@@ -55,31 +54,66 @@ public class CommonUtil {
     }
 
 
-    public static String getProjectUseDay(Object projectUseTime){
-        if(null == projectUseTime){
+    public static String getProjectUseDay(Object projectUseTime) {
+        if (null == projectUseTime) {
             return null;
         }
-        if(projectUseTime instanceof String){
-            String projectUseTimeStr  = (String) projectUseTime;
-            if(projectUseTimeStr.length()>15){
+        if (projectUseTime instanceof String) {
+            String projectUseTimeStr = (String) projectUseTime;
+            if (projectUseTimeStr.length() > 15) {
                 return projectUseTimeStr.substring(0, 10);
             }
-        }else if(projectUseTime instanceof java.util.Date || projectUseTime instanceof java.sql.Date){
+        } else if (projectUseTime instanceof java.util.Date || projectUseTime instanceof java.sql.Date) {
             Date projectUseTimeDate = (Date) projectUseTime;
             return DateUtil.formatDate(projectUseTimeDate);
-        }else if(projectUseTime instanceof java.lang.Long){
+        } else if (projectUseTime instanceof java.lang.Long) {
             Date projectUseTimeDate = new Date(((Long) projectUseTime));
             return DateUtil.formatDate(projectUseTimeDate);
 
-        }else{
+        } else {
             log.error("时间类型匹配不上:{}", projectUseTime.getClass());
         }
         return projectUseTime.toString();
     }
 
+
+
+    public static Integer getDays(String ageString) {
+
+        // 将年龄字符串解析为LocalDate对象
+        LocalDate birthDate = LocalDate.now().minus(Period.parse("P" + ageString));
+
+        // 计算出生日期到今天的天数
+        int days = Period.between(birthDate, LocalDate.now()).getDays();
+
+        System.out.println("年龄为 " + ageString + " 的人的天数为 " + days + " 天");
+
+        return 0;
+    }
+
+    public static String getMedicalSex(Object patientGender){
+        if(null != patientGender){
+            String patientGenderStr = patientGender.toString();
+            String patientGenderInt = "1";
+            if("男".equals(patientGenderStr)){
+                patientGenderInt = "1";
+            }else if("女".equals(patientGenderStr)){
+                patientGenderInt = "2";
+            }else if("未知".equals(patientGenderStr)){
+                patientGenderInt = "0";
+            }else {
+                patientGenderInt = "9";
+            }
+            return patientGenderInt;
+        }
+        return "9";
+    }
+
     public static void main(String[] args) {
 //        String day = "2023-11-09 19:10:11";
         Long day = 1607475808000l;
         System.out.println(getProjectUseDay(day));
+
+        LocalDate birthDate = LocalDate.now().minus(Period.parse("P" + "3年2月4日"));
     }
 }

+ 3 - 3
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/entity/Operation.java

@@ -37,9 +37,9 @@ public class Operation implements Serializable {
     @ApiModelProperty(value = "主键ID")
     private java.lang.Integer id;
 	/**结算单据号;*/
-	@Excel(name = "结算单据号;", width = 15)
-    @ApiModelProperty(value = "结算单据号;")
-    private java.lang.String hisid;
+	@Excel(name = "住院号/门诊号;", width = 15)
+    @ApiModelProperty(value = "住院号/门诊号;")
+    private java.lang.String visitNo;
 	/**就诊类型;1 住院 、2 门诊*/
 	@Excel(name = "就诊类型;1 住院 、2 门诊", width = 15)
     @ApiModelProperty(value = "就诊类型;1 住院 、2 门诊")

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

@@ -32,7 +32,7 @@ public class XCFYDatav_check_listJob implements Job {
 
     @Override
     public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
-        String sql = "select * from V_CHECK_LIST where rownum<1000 %s";
+        String sql = "select * from V_CHECK_LIST where rownum<1000 %s and hisid is not null";
         while (true) {
             log.info("开始同步v_check_list数据");
             String whereSql = "";

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

@@ -96,6 +96,7 @@ public class XCFYDatav_hospitalizatio_settle_detailJob implements Job {
 
     }
 
+
     public Long getLastId() {
         List<HospitalizatioSettleDetail> hospitalizatioSettleDetails = hospitalizatioSettleDetailService.lambdaQuery().orderByDesc(HospitalizatioSettleDetail::getId).last("limit 1").list();
         if (CollectionUtil.isEmpty(hospitalizatioSettleDetails)) {

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

@@ -5,15 +5,14 @@ import cn.hutool.core.date.DateUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
 import org.jeecg.common.system.vo.DictModel;
-import org.jeecg.common.util.DateUtils;
 import org.jeecg.modules.medical.Constant;
-import org.jeecg.modules.medical.SystemEventAttrConstant;
 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.ruleengine.TransferDataCallFunction;
 import org.jeecg.modules.medical.service.IMasterAdmissionBillService;
 import org.jeecg.modules.system.service.ISysDictService;
+import org.jeecg.modules.utils.DateTimeUtil;
 import org.quartz.Job;
 import org.quartz.JobExecutionContext;
 import org.quartz.JobExecutionException;
@@ -38,22 +37,56 @@ public class XCFYDatav_master_admission_billJob implements Job {
     @Autowired
     ISysDictService sysDictService;
 
-    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`, `refund_date`, `admission_dept_id`, `admission_dept_name`, `adm_bed`, `transfer_dept_id`, `transfer_dept_name`, `discharge_dept_id`, `discharge_dept_name`, `dscg_bed`, `doctor_id`, `doctor_name`, `patient_id`, `patient_name`, `patient_gender`, `patient_birthday`, `patient_age`, `patient_age_days`, `claim_type`, `visit_time`, `if_local_flag`, `admission_date`, `discharge_date`, `zyts`, `discharge_status`, `pre_admission_date`, `days_re_admission_31`, `yb_admission_disease_id`, `yb_admission_disease_name`, `yb_discharge_disease_id_main`, `yb_discharge_disease_name_main`, `admission_disease_id`, `admission_disease_name`, `discharge_disease_id_main`, `discharge_disease_name_main`, `yb_pay_type`, `drgs_code`, `drgs_name`, `medfee_sumamt`, `fulamt_ownpay_amt`, `overlmt_selfpay`, `preselfpay_amt`, `inscp_scp_amt`, `act_pay_dedc`, `hifp_pay`, `pool_prop_selfpay`, `cvlserv_pay`, `hifes_pay`, `hifmi_pay`, `hifob_pay`, `maf_pay`, `oth_pay`, `fund_pay_sumamt`, `state`, `create_time`, `create_by`) " +
-            "VALUES (: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,:REFUND_DATE,:ADMISSION_DEPT_ID,:ADMISSION_DEPT_NAME,:ADM_BED,:TRANSFER_DEPT_ID,:TRANSFER_DEPT_NAME,:DISCHARGE_DEPT_ID,:DISCHARGE_DEPT_NAME,:DSCG_BED,:DOCTOR_ID,:DOCTOR_NAME,:PATIENT_ID,:PATIENT_NAME,:PATIENT_GENDER,:PATIENT_BIRTHDAY,:PATIENT_AGE,:PATIENT_AGE_DAYS,:CLAIM_TYPE,:VISIT_TIME,:IF_LOCAL_FLAG,:ADMISSION_DATE,:DISCHARGE_DATE,:ZYTS,:DISCHARGE_STATUS,:PRE_ADMISSION_DATE,:DAYS_RE_ADMISSION_31,:YB_ADMISSION_DISEASE_ID,:YB_ADMISSION_DISEASE_NAME,:YB_DISCHARGE_DISEASE_ID_MAIN,:YB_DISCHARGE_DISEASE_NAME_MAIN,:ADMISSION_DISEASE_ID,:ADMISSION_DISEASE_NAME,:DISCHARGE_DISEASE_ID_MAIN,:DISCHARGE_DISEASE_NAME_MAIN,:YB_PAY_TYPE,:DRGS_CODE,:DRGS_NAME,:MEDFEE_SUMAMT,:FULAMT_OWNPAY_AMT,:OVERLMT_SELFPAY,:PRESELFPAY_AMT,:INSCP_SCP_AMT,:ACT_PAY_DEDC,:HIFP_PAY,:POOL_PROP_SELFPAY,:CVLSERV_PAY,:HIFES_PAY,:HIFMI_PAY,:HIFOB_PAY,:MAF_PAY,:OTH_PAY,:FUND_PAY_SUMAMT,:STATE,:CREATE_TIME,:CREATE_BY)";
+    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`, " +
+            "`refund_date`, `admission_dept_id`, `admission_dept_name`, `adm_bed`, `transfer_dept_id`, `transfer_dept_name`, " +
+            "`discharge_dept_id`, `discharge_dept_name`, `dscg_bed`, `doctor_id`, `doctor_name`, `patient_id`, `patient_name`, " +
+            "`patient_gender`, `patient_birthday`, `patient_age`, `patient_age_days`, `claim_type`, `visit_time`, `if_local_flag`, " +
+            "`admission_date`, `discharge_date`, `zyts`, `discharge_status`, `pre_admission_date`, `days_re_admission_31`, " +
+            "`yb_admission_disease_id`, `yb_admission_disease_name`, `yb_discharge_disease_id_main`, `yb_discharge_disease_name_main`, " +
+            "`admission_disease_id`, `admission_disease_name`, `discharge_disease_id_main`, `discharge_disease_name_main`, " +
+            "`yb_pay_type`, `drgs_code`, `drgs_name`, `medfee_sumamt`, `fulamt_ownpay_amt`, `overlmt_selfpay`, `preselfpay_amt`, " +
+            "`inscp_scp_amt`, `act_pay_dedc`, `hifp_pay`, `pool_prop_selfpay`, `cvlserv_pay`, `hifes_pay`, `hifmi_pay`, `hifob_pay`, " +
+            "`maf_pay`, `oth_pay`, `fund_pay_sumamt`, `state`, `create_time`, `create_by`, settle_type, invalid_operator, invalid_date, back_receipt_no) " +
+            "VALUES (: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,:REFUND_DATE,:ADMISSION_DEPT_ID,:ADMISSION_DEPT_NAME," +
+            ":ADM_BED,:TRANSFER_DEPT_ID,:TRANSFER_DEPT_NAME,:DISCHARGE_DEPT_ID,:DISCHARGE_DEPT_NAME,:DSCG_BED,:DOCTOR_ID," +
+            ":DOCTOR_NAME,:PATIENT_ID,:PATIENT_NAME,:PATIENT_GENDER,:PATIENT_BIRTHDAY,:PATIENT_AGE,:PATIENT_AGE_DAYS," +
+            ":CLAIM_TYPE,:VISIT_TIME,:IF_LOCAL_FLAG,:ADMISSION_DATE,:DISCHARGE_DATE,:ZYTS,:DISCHARGE_STATUS," +
+            ":PRE_ADMISSION_DATE,:DAYS_RE_ADMISSION_31,:YB_ADMISSION_DISEASE_ID,:YB_ADMISSION_DISEASE_NAME,:YB_DISCHARGE_DISEASE_ID_MAIN," +
+            ":YB_DISCHARGE_DISEASE_NAME_MAIN,:ADMISSION_DISEASE_ID,:ADMISSION_DISEASE_NAME,:DISCHARGE_DISEASE_ID_MAIN," +
+            ":DISCHARGE_DISEASE_NAME_MAIN,:YB_PAY_TYPE,:DRGS_CODE,:DRGS_NAME,:MEDFEE_SUMAMT,:FULAMT_OWNPAY_AMT,:OVERLMT_SELFPAY," +
+            ":PRESELFPAY_AMT,:INSCP_SCP_AMT,:ACT_PAY_DEDC,:HIFP_PAY,:POOL_PROP_SELFPAY,:CVLSERV_PAY,:HIFES_PAY,:HIFMI_PAY," +
+            ":HIFOB_PAY,:MAF_PAY,:OTH_PAY,:FUND_PAY_SUMAMT,:STATE,:CREATE_TIME,:CREATE_BY,:SETTLE_TYPE, :INVALID_OPERATOR, :INVALID_DATE, :BACK_RECEIPT_NO)";
+
+    String hosSeDetailInsertSql = "INSERT INTO hospitalizatio_settle_detail (id, hisid, patient_id, zyh, hospital_id, p_category, " +
+            "categories_items, usage_date, discharge_dept_id, discharge_dept_name, item_id, item_name, item_id_hosp, " +
+            "item_name_hosp, drug_spec, dosage_form, package_unit, unit_price, num, cost, use_day, bmi_convered_amount, " +
+            "bmi_pay_amount, individual_payment_amount, amount_refusal, amount_reason, discharge_medication, refund_falge, " +
+            "refund_date, p_type, p_type_pct, create_time, create_by) VALUES (:ID,:HISID,:PATIENT_ID,:ZYH,:HOSPITAL_ID," +
+            ":P_CATEGORY,:CATEGORIES_ITEMS,:USAGE_DATE,:DISCHARGE_DEPT_ID,:DISCHARGE_DEPT_NAME,:ITEM_ID,:ITEM_NAME," +
+            ":ITEM_ID_HOSP,:ITEM_NAME_HOSP,:DRUG_SPEC,:DOSAGE_FORM,:PACKAGE_UNIT,:UNIT_PRICE,:NUM,:COST,:USE_DAY," +
+            ":BMI_CONVERED_AMOUNT,:BMI_PAY_AMOUNT,:INDIVIDUAL_PAYMENT_AMOUNT,:AMOUNT_REFUSAL,:AMOUNT_REASON,:DISCHARGE_MEDICATION," +
+            ":REFUND_FALGE,:REFUND_DATE,:P_TYPE,:P_TYPE_PCT,:CREATE_TIME,:CREATE_BY)";
+
+    String recordHomePageInsertSql = "INSERT INTO medical_record_homepage (id, bridge_id, zyh, hospital_id, patient_name, patient_id, social_card_id, patient_address, patient_company, icd10_code_basy, icd10_name_basy, icd10_name_describe, special_remarks, disease_id1, disease_name1, icd9_code_basy, icd9_name_basy, icd9_code1, icd9_name1, nb_weight, nb_admission_weight, bm_hours, icu_flag, icu_hours, main_con_desc, treatment_process, pathological_findings, discharge_condition, discharge_order, death_date, death_diagnosis, death_cause, admission_plan, disease_his, past_his, personal_his, auxiliary_inspection, assist_lab_test_results, auxiliary_imaging_ex_results, discharge_status, create_time, create_by) " +
+            "VALUES (:ID,:BRIDGE_ID,:ZYH,:HOSPITAL_ID,:PATIENT_NAME,:PATIENT_ID,:SOCIAL_CARD_ID,:PATIENT_ADDRESS,:PATIENT_COMPANY,:ICD10_CODE_BASY,:ICD10_NAME_BASY,:ICD10_NAME_DESCRIBE,:SPECIAL_REMARKS,:DISEASE_ID1,:DISEASE_NAME1,:ICD9_CODE_BASY,:ICD9_NAME_BASY,:ICD9_CODE1,:ICD9_NAME1,:NB_WEIGHT,:NB_ADMISSION_WEIGHT,:BM_HOURS,:ICU_FLAG,:ICU_HOURS,:MAIN_CON_DESC,:TREATMENT_PROCESS,:PATHOLOGICAL_FINDINGS,:DISCHARGE_CONDITION,:DISCHARGE_ORDER,:DEATH_DATE,:DEATH_DIAGNOSIS,:DEATH_CAUSE,:ADMISSION_PLAN,:DISEASE_HIS,:PAST_HIS,:PERSONAL_HIS,:AUXILIARY_INSPECTION,:ASSIST_LAB_TEST_RESULTS,:AUXILIARY_IMAGING_EX_RESULTS,:DISCHARGE_STATUS,:CREATE_TIME,:CREATE_BY)";
 
     @Override
     public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
-        String sql = "select * from V_MASTER_ADMISSION_BILL where rownum<1000 %s ";
+        String sql = "select * from V_MASTER_ADMISSION_BILL where hisid is not null and bill_date<=:END_BILL_DATE %s and rownum<=1000 ";
+        Date endBillDate = DateUtil.yesterday();
+        endBillDate = DateUtil.endOfDay(endBillDate);
         while (true) {
-            log.info("开始同步master_admission_bill数据");
             String whereSql = "";
-            Long id = getLastId();
-            log.info("开始同步master_admission_bill数据,获取上个同步记录主键ID:{}", id);
+            Date billDate = getBillDate();
+            log.info("开始同步master_admission_bill数据,获取上个同步开始结算日期:{} 结束日期:{}", billDate, endBillDate);
             Map<String, Object> paramMap = new HashMap<>();
-            if (null != id && id > 0) {
-                whereSql = "and ID>:ID";
-                paramMap.put("ID", id);
+            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
@@ -64,65 +97,149 @@ public class XCFYDatav_master_admission_billJob implements Job {
                         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)){
+                    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.get("PATIENT_AGE");
+                    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){
+                    if (null != patientBirthday && days <= 0) {
                         Date patientBirthDayDate = (Date) patientBirthday;
 
-                        if(null != visitTime){
+                        if (null != visitTime) {
                             Date visitTimeDate = (Date) visitTime;
                             ageDays = DateUtil.betweenDay(patientBirthDayDate, visitTimeDate, false);
-                        }else{
+                        } else {
                             ageDays = DateUtil.betweenDay(patientBirthDayDate, new Date(), false);
                         }
                         dataMap.put("PATIENT_AGE_DAYS", ageDays.doubleValue());
-                    }else{
-                        if(null != patientAge){
-                            try {
-                                Double patientAgeDouble = Double.parseDouble(patientAge.toString());
-                                Double patientAgeDays = patientAgeDouble * 365;
-                                dataMap.put("PATIENT_AGE_DAYS", patientAgeDays);
-                            }catch (Exception e){
-                                log.error(e.getMessage(), e);
-                            }
-                        }
+                    } 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));
+                    String hisId = dataMap.get("HISID").toString();
+                    Integer count = transferHospSettleDetail(hisId);
+                    if (null == count || count <= 0) {
+                        return;
+                    }
+                    xcfyDataTransferService.transferCheckList(hisId);
+                    String zyh = dataMap.get("ZYH").toString();
+                    xcfyDataTransferService.transferPrescriptionOrder(zyh);
+                    transferMedicalRecordHomePage(zyh);
+                    xcfyDataTransferService.transferOperation(zyh);
                 }
             });
-
             if (count <= 0) {
-                log.error("V_MASTER_ADMISSION_BILL 未查询到大于住院ID:{} 的数据, 停止同步", id);
+                log.error("V_MASTER_ADMISSION_BILL 未查询到大于住院billdate:{} 小于等于住院billdate:{} 的数据,停止同步", billDate, endBillDate);
                 return;
             }
-
         }
+    }
 
+    /**
+     * 根据主单hisid同步明细数据
+     *
+     * @param hisId
+     * @return
+     */
+    public Integer transferHospSettleDetail(String hisId) {
+        try {
+            List<DictModel> cateGoriesList = sysDictService.getDictItems(Constant.DICT_CATEGORIES_ITEMS_KEY);
+            Map<String, String> cateGoriesMap = new HashMap<>();
+            for (DictModel dictModel : cateGoriesList) {
+                cateGoriesMap.put(dictModel.getText(), dictModel.getValue());
+            }
+            String whereSql = "";
+            log.info("开始同步v_hospitalizatio_settle_detail数据,HISID:{}", hisId);
+            String sql = "select * from V_HOSPITALIZATIO_SETTLE_DETAIL where hisid=:HISID";
+            Map<String, Object> paramMap = new HashMap<>();
+
+            paramMap.put("HISID", hisId);
+
+            String querySql = String.format(sql, whereSql);
+            Integer count = xcfyDataTransferService.transferDataList(querySql, hosSeDetailInsertSql, paramMap, new TransferDataCallFunction() {
+                @Override
+                public void transferData(Map<String, Object> dataMap) throws Exception {
+                    dataMap.put("CREATE_BY", "auto");
+                    dataMap.put("CREATE_TIME", new Date());
+                    String itemIDHosp = dataMap.getOrDefault("ITEM_ID_HOSP", "").toString();
+                    String itemId = dataMap.getOrDefault("ITEM_ID", "").toString();
+                    if (StringUtils.isNotBlank(itemIDHosp) && StringUtils.isBlank(itemId)) {
+                        String[] itemIdArr = CommonUtil.getMedicalCodeAndName(itemIDHosp);
+                        if (null != itemIdArr) {
+                            dataMap.put("ITEM_ID", itemIdArr[0]);
+                            dataMap.put("ITEM_NAME", itemIdArr[1]);
+                        } else {
+                            log.error("住院结算明细医院项目编码:{} 医保在基础信息目录未匹配到", itemIDHosp);
+                        }
+                    }
+                    Object useDay = dataMap.get("USE_DAY");
+                    if (null == useDay) {
+                        dataMap.put("USE_DAY", 1);
+                    }
+                    String pCategory = dataMap.getOrDefault("P_CATEGORY", "").toString();
+                    if (StringUtils.isNotBlank(pCategory)) {
+                        dataMap.put("P_CATEGORY", cateGoriesMap.getOrDefault(pCategory, pCategory));
+                    }
+
+                    String categoriesItems = dataMap.getOrDefault("CATEGORIES_ITEMS", "").toString();
+                    if (StringUtils.isNotBlank(pCategory)) {
+                        dataMap.put("CATEGORIES_ITEMS", cateGoriesMap.getOrDefault(categoriesItems, categoriesItems));
+                    }
+                    //甲类
+                    dataMap.put("P_TYPE", "01");
+                }
+            });
+            log.info("结束同步v_hospitalizatio_settle_detail数据,HISID:{} 条数:{}", hisId, count);
+            return count;
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+        }
+        return 0;
     }
 
+    public Integer transferMedicalRecordHomePage(String zyh) {
+        String querySql = "select * from V_MEDICAL_RECORD_HOMEPAGE where ZYH=:ZYH";
+
+        log.info("开始同步V_MEDICAL_RECORD_HOMEPAGE数据,获取zyh:{}", zyh);
+        Map<String, Object> paramMap = new HashMap<>();
+
+        paramMap.put("ZYH", zyh);
+        Integer count = xcfyDataTransferService.transferDataList(querySql, recordHomePageInsertSql, paramMap, new TransferDataCallFunction() {
+            @Override
+            public void transferData(Map<String, Object> dataMap) throws Exception {
+                dataMap.put("CREATE_BY", "auto");
+                dataMap.put("CREATE_TIME", new Date());
+            }
+        });
+        log.info("结束同步V_MEDICAL_RECORD_HOMEPAGE数据,获取zyh:{} 条数:{}", zyh, count);
+        return count;
+    }
 
 
-    public Long getLastId() {
-        List<MasterAdmissionBill> masterAdmissionBillList = masterAdmissionBillService.lambdaQuery().orderByDesc(MasterAdmissionBill::getId).last("limit 1").list();
+    public Date getBillDate() {
+        List<MasterAdmissionBill> masterAdmissionBillList = masterAdmissionBillService.lambdaQuery().orderByDesc(MasterAdmissionBill::getBillDate).last("limit 1").list();
         if (CollectionUtil.isEmpty(masterAdmissionBillList)) {
             return null;
         }
-        return masterAdmissionBillList.get(0).getId();
+        return masterAdmissionBillList.get(0).getBillDate();
     }
 
 }

+ 27 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/utils/DateTimeUtil.java

@@ -1,6 +1,8 @@
 package org.jeecg.modules.utils;
 
 
+import lombok.extern.slf4j.Slf4j;
+
 import java.time.*;
 import java.time.format.DateTimeFormatter;
 import java.time.temporal.ChronoUnit;
@@ -12,6 +14,7 @@ import java.util.Date;
  * @apiNote 常用的日期时间转换工具类
  * @Time 2022年10月8日15:30:17
  */
+@Slf4j
 public class DateTimeUtil {
 
     public static final String FULL_STYLE = "yyyy-MM-dd HH:mm:ss";
@@ -318,4 +321,28 @@ public class DateTimeUtil {
     }
 
 
+    public static int getDayByAgeStr(String ageString){
+        ageString = ageString.replace("岁","Y");
+//        ageString = ageString.replace("年","Y");
+        ageString = ageString.replace("个月","M");
+//        ageString = ageString.replace("月","M");
+//        ageString = ageString.replace("周","W");
+        ageString = ageString.replace("天","D");
+//        ageString = ageString.replace("日","D");
+//        ageString = ageString.replace("时","H");
+        Period agePeriod = null;
+        try {
+            // 将年龄字符串解析为Period对象
+            agePeriod = Period.parse("P" + ageString);
+        }catch (Exception e){
+            log.error(e.getMessage(), e);
+            return 0;
+        }
+
+        // 获取年龄的总天数
+        int ageInDays = agePeriod.getYears() * 365 + agePeriod.getMonths() * 30 + agePeriod.getDays();
+
+        return ageInDays;
+    }
+
 }

+ 19 - 7
jeecg-module-system/jeecg-system-start/src/test/java/org/jeecg/TestMain.java

@@ -1,14 +1,9 @@
 package org.jeecg;
 
-import com.alibaba.fastjson.JSONObject;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import org.jeecg.common.util.RestUtil;
-import org.jeecg.modules.medical.entity.AfterIncidentDetailLog;
 import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpMethod;
 import org.springframework.http.MediaType;
-import org.springframework.http.ResponseEntity;
 
+import java.time.Period;
 import java.util.regex.Pattern;
 
 /**
@@ -41,9 +36,26 @@ public class TestMain {
 
 //        Pattern p=Pattern.compile("^ABC");
 //        p.pattern();//返回 \
-        System.out.println(Pattern.matches("^ABC.","ABCA"));
+        System.out.println(Pattern.matches("^ABC.", "ABCA"));
+
+
+        String ageString = "3年2月4日";
+        ageString = ageString.replace("年","Y");
+        ageString = ageString.replace("月","M");
+        ageString = ageString.replace("周","W");
+        ageString = ageString.replace("日","D");
+
+        // 将年龄字符串解析为Period对象
+        Period agePeriod = Period.parse("P" + ageString);
+
+        // 获取年龄的总天数
+        int ageInDays = agePeriod.getYears() * 365 + agePeriod.getMonths() * 30 + agePeriod.getDays();
+
+        System.out.println("年龄为 " + ageString + " 的人的天数为 " + ageInDays + " 天");
+
 
     }
+
     private static HttpHeaders getHeaders() {
         String token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.50h-g6INOZRVnznExiawFb1U6PPjcVVA4POeYRA5a5Q";
         System.out.println("请求Token:" + token);