Browse Source

移动医保支付对账

lighter 11 months ago
parent
commit
6c8b364d7f

+ 12 - 0
src/main/java/thyyxxk/webserver/constants/sidicts/ClrType.java

@@ -16,6 +16,7 @@ public enum ClrType {
     OUTPATIENT_SLOW_SPECIAL_DSS("14", "门诊慢特病"),
 
     BIRTH_OUTPATIENT("53", "生育门诊"),
+
     INPATIENT("21", "住院"),
 
     REMOTE_INPATIENT("9902", "异地住院"),
@@ -55,4 +56,15 @@ public enum ClrType {
         }
         return null;
     }
+
+    public static boolean mzClrType(String code) {
+        ClrType clrType = get(code);
+        if (clrType == null) {
+            return false;
+        }
+        return clrType == OUTPATIENT ||
+                clrType == REMOTE_OUTPATIENT ||
+                clrType == OUTPATIENT_SLOW_SPECIAL_DSS ||
+                clrType == BIRTH_OUTPATIENT;
+    }
 }

+ 39 - 2
src/main/java/thyyxxk/webserver/dao/his/medicalinsurance/SiManageDao.java

@@ -4,6 +4,7 @@ import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 import org.apache.ibatis.annotations.Update;
+import thyyxxk.webserver.entity.dictionary.CodeName;
 import thyyxxk.webserver.entity.inpatient.patient.Overview;
 import thyyxxk.webserver.entity.medicalinsurance.manage.InstSetlLdgChkBrf;
 import thyyxxk.webserver.entity.medicalinsurance.manage.clinicinfo.ClinicDiseinfo;
@@ -54,6 +55,28 @@ public interface SiManageDao {
                                                           @Param("end") String end,
                                                           @Param("acctStatement") String acctStatement);
 
+    @Select("select med_org_ord as pat_no,times=0,ledger_sn=0, " +
+            "fee_sumamt as medfee_sumamt,psn_acct_pay as acct_pay, " +
+            "fund_pay as fund_pay_sumamt,hosp_part_amt=0 " +
+            "from powersi_mip_setlinfo where insu_type=#{insutype} " +
+            "and clr_type=#{clrType} and ord_state='SETTLED' " +
+            "and clr_optins=#{clrOptins} and trace_time>=#{start} " +
+            "and trace_time<=#{end} and ${acctStatement} and insu_code like '43%'")
+    List<InstSetlLdgChkBrf> selectYbydzfSetlChkBrfs(@Param("clrType") String clrType,
+                                                    @Param("insutype") String insutype,
+                                                    @Param("clrOptins") String clrOptins,
+                                                    @Param("start") String start,
+                                                    @Param("end") String end,
+                                                    @Param("acctStatement") String acctStatement);
+
+    @Select("select clr_optins as code from powersi_mip_setlinfo " +
+            "where insu_type=#{insutype} and clr_type=#{clrType} and ord_state='SETTLED' " +
+            "and trace_time>=#{start} and trace_time<=#{end} and insu_code like '43%'")
+    List<CodeName> selectYdybzfClrOptins(@Param("clrType") String clrType,
+                                         @Param("insutype") String insutype,
+                                         @Param("start") String start,
+                                         @Param("end") String end);
+
     @Select("select visitId=pat_no+'_'+cast(times as varchar)+'_'+cast(ledger_sn as varchar), " +
             "setl_id,mdtrt_id,psn_no,medins_setl_id as msgId,medfee_sumamt,acct_pay,fund_pay_sumamt, " +
             "hosp_part_amt from t_si_setlinfo where setl_type=#{clrType} and revoked=0 and " +
@@ -91,6 +114,20 @@ public interface SiManageDao {
                                               @Param("end") String end,
                                               @Param("acctStatement") String acctStatement);
 
+    @Select("select pat_no=med_org_ord,times=0,ledger_sn=0, " +
+            "hi_doc_sn as setl_id,mdtrt_id=hi_rgs_sn,psn_no, " +
+            "fee_sumamt as medfee_sumamt, " +
+            "psn_acct_pay as acct_pay, " +
+            "fund_pay as fund_pay_sumamt, " +
+            "ownpay_amt as psn_cash_pay, hosp_part_amt=0  " +
+            "from powersi_mip_setlinfo where clr_type=#{clrType} and ord_state='SETTLED' and clr_optins=#{clrOptins} and  " +
+            "${acctStatement} and trace_time>=#{start} and trace_time<=#{end} and insu_code like '43%' ")
+    List<InstSetlLdgChkBrf> selectYbydzfSetlChkBrfs2(@Param("clrType") String clrType,
+                                                   @Param("clrOptins") String clrOptins,
+                                                   @Param("start") String start,
+                                                   @Param("end") String end,
+                                                   @Param("acctStatement") String acctStatement);
+
     @Select("select count(1) from dj_user_role where user_code=#{code} and role_id=41")
     Integer recoveryTradePermission(@Param("code") String code);
 
@@ -230,9 +267,9 @@ public interface SiManageDao {
 
     @Select("select mdtrt_id,medinsAdmdvs='430105',medinsLv='03',begntime as adm_date,endtime as dscg_date, " +
             "dscgMainDiseCodg=(select rtrim(dis_diag) from zy_dis_diag_yb where inpatient_no=a.pat_no and " +
-            "          admiss_times=a.times and dis_diag_no=1), " +
+            "admiss_times=a.times and dis_diag_no=1), " +
             "dscgMainDiseName=(select rtrim(dis_diag_comment) from zy_dis_diag_yb where inpatient_no=a.pat_no and " +
-            "          admiss_times=a.times and dis_diag_no=1), " +
+            "admiss_times=a.times and dis_diag_no=1), " +
             "drCodg=(select rtrim(op_id_code) from zy_dis_diag_yb where inpatient_no=a.pat_no and " +
             " admiss_times=a.times and dis_diag_no=1), " +
             "admDeptCodg=(select rtrim(small_dept) from zy_inactpatient where inpatient_no=a.pat_no and admiss_times=a.times), " +

+ 30 - 7
src/main/java/thyyxxk/webserver/service/medicalinsurance/SiManageService.java

@@ -11,11 +11,7 @@ import thyyxxk.webserver.constants.Capacity;
 import thyyxxk.webserver.constants.Message;
 import thyyxxk.webserver.constants.YesOrNo;
 import thyyxxk.webserver.constants.frntsheet.CaseClassification;
-import thyyxxk.webserver.constants.sidicts.Admdvs;
-import thyyxxk.webserver.constants.sidicts.DrordDrProfttl;
-import thyyxxk.webserver.constants.sidicts.ListType;
-import thyyxxk.webserver.constants.sidicts.SiFunction;
-import thyyxxk.webserver.constants.sidicts.StmtRslt;
+import thyyxxk.webserver.constants.sidicts.*;
 import thyyxxk.webserver.dao.his.medicalinsurance.SiLogDao;
 import thyyxxk.webserver.dao.his.medicalinsurance.SiManageDao;
 import thyyxxk.webserver.dao.his.medicalinsurance.SiSetlinfoDao;
@@ -206,10 +202,16 @@ public class SiManageService {
         String startdate = DateUtil.getDayStartTime(instStlLdgChk.getStmtBegndate());
         String enddate = DateUtil.getDayEndTime(instStlLdgChk.getStmtEnddate());
         String acctStatement = instStlLdgChk.getAcctPayFlag() == 1 ? "(fund_pay_sumamt+acct_pay)!=0" : "fund_pay_sumamt!=0";
+        String acctStatement2 = instStlLdgChk.getAcctPayFlag() == 1 ? "(fund_pay+psn_acct_pay)!=0" : "fund_pay!=0";
         List<InstSetlLdgChkBrf> setlBrfs = instStlLdgChk.getMode() == 1 ?
                 dao.selectSetlChkBrfsWithInsutype(instStlLdgChk.getClrType(), instStlLdgChk.getInsutype(),
                         instStlLdgChk.getSetlOptins(), startdate, enddate, acctStatement) :
                 dao.selectSetlinfoBrfsForHisCheck(instStlLdgChk.getClrType(), startdate, enddate);
+        if (instStlLdgChk.getMode() == 1 && ClrType.mzClrType(instStlLdgChk.getClrType())) {
+            setlBrfs.addAll(dao.selectYbydzfSetlChkBrfs(instStlLdgChk.getClrType(), instStlLdgChk.getInsutype(),
+                    instStlLdgChk.getSetlOptins(), startdate, enddate, acctStatement2));
+        }
+
         fillInstStlLdgChk(instStlLdgChk, setlBrfs);
 
         if (instStlLdgChk.getMode() == 2) {
@@ -323,8 +325,12 @@ public class SiManageService {
             return ResultVoUtil.fail(ExceptionEnum.INVALID_PARAM, "暂不支持HIS与医保的明细对账。");
         }
         String acctStatement = setlChk.getAcctPayFlag() == 1 ? "(fund_pay_sumamt+acct_pay)!=0" : "fund_pay_sumamt!=0";
-        List<InstSetlLdgChkBrf> setlBrfs = dao.selectSetlChkBrfs(setlChk.getClrType(),
-                setlChk.getSetlOptins(), startdate, enddate, acctStatement);
+        String acctStatement2 = setlChk.getAcctPayFlag() == 1 ? "(fund_pay+psn_acct_pay)!=0" : "fund_pay!=0";
+        List<InstSetlLdgChkBrf> setlBrfs = dao.selectSetlChkBrfs(setlChk.getClrType(), setlChk.getSetlOptins(), startdate, enddate, acctStatement);
+        if (ClrType.mzClrType(setlChk.getClrType())) {
+            setlBrfs.addAll(dao.selectYbydzfSetlChkBrfs2(setlChk.getClrType(), setlChk.getSetlOptins(), startdate, enddate, acctStatement2));
+        }
+
         fillInstStlLdgChk(setlChk, setlBrfs);
         String snowId = SnowFlakeId.instance().nextId();
         String filename = snowId + ".txt";
@@ -404,6 +410,7 @@ public class SiManageService {
             wrapper.apply("insuplc_admdvs like '43%' ");
         }
         List<SiSetlinfo> list = setlinfoDao.selectList(wrapper);
+
         if (null == list || list.isEmpty()) {
             return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "没有查询到符合条件的数据。");
         }
@@ -445,6 +452,22 @@ public class SiManageService {
         Map<String, Object> map = new HashMap<>(Capacity.TWO);
         Map<String, String> optinsMap = new HashMap<>();
         List<CodeName> optinList = new ArrayList<>();
+
+        if (prm.getMode() == 1 && ClrType.mzClrType(prm.getClrType())) {
+            List<CodeName> ydybzfClrOptins = dao.selectYdybzfClrOptins(prm.getClrType(), prm.getInsutype(), begndate, enddate);
+            for (CodeName item : ydybzfClrOptins) {
+                Admdvs admdvs = Admdvs.get(item.getCode());
+                if (null == admdvs) {
+                    item.setName(redis.getRegionName(item.getCode()));
+                } else {
+                    item.setName(admdvs.getName());
+                }
+                if (!optinsMap.containsKey(item.getCode())) {
+                    optinsMap.put(item.getCode(), item.getName());
+                }
+            }
+        }
+
         list.forEach(item -> {
             Admdvs admdvs = Admdvs.get(item.getClrOptins());
             if (null == admdvs) {