LIJU 2 viikkoa sitten
vanhempi
commit
ad67d09f6f

+ 89 - 0
src/main/java/thyyxxk/sizyfeeoprnsystm/dao/SiZyDao.java

@@ -96,6 +96,7 @@ public interface SiZyDao {
             "psnNo=(select psn_no from t_si_pat_info b where b.pat_no=inpatient_no and b.times=admiss_times and b.ledger_sn=a.ledger_sn), " +
             "medType=(select med_type from t_si_pat_info b where b.pat_no=inpatient_no and b.times=admiss_times and b.ledger_sn=a.ledger_sn), " +
             "medListCodg=isnull((select max(national_code) from yp_zd_dict where code=charge_code_mx),(select max(national_code) from zd_charge_item where code=charge_code_mx)), " +
+            "medListCodgType=case when (select max(national_code) from yp_zd_dict where code=charge_code_mx) is not null then 1 else 2 end, " +
             "bilgDeptCodg=(select t.si_caty from zd_unit_code t where t.code=ward_code), " +
             "bilgDeptName=(select t.si_caty_name from zd_unit_code t where t.code=ward_code), " +
             "bilgDrCodg=isnull(" +
@@ -136,6 +137,7 @@ public interface SiZyDao {
             "psnNo=(select psn_no from t_si_pat_info b where b.pat_no=inpatient_no and b.times=admiss_times and b.ledger_sn=a.ledger_sn), " +
             "medType=(select med_type from t_si_pat_info b where b.pat_no=inpatient_no and b.times=admiss_times and b.ledger_sn=a.ledger_sn), " +
             "medListCodg=isnull((select max(national_code) from yp_zd_dict where code=charge_code_mx),(select max(national_code) from zd_charge_item where code=charge_code_mx)), " +
+            "medListCodgType=case when (select max(national_code) from yp_zd_dict where code=charge_code_mx) is not null then 1 else 2 end, " +
             "bilgDeptCodg=(select t.si_caty from zd_unit_code t where t.code=ward_code), " +
             "bilgDeptName=(select z.name from t_yb_dept z where z.code=" +
             "(select t.si_caty from zd_unit_code t where t.code=ward_code)), " +
@@ -304,6 +306,7 @@ public interface SiZyDao {
             "psnNo=(select psn_no from t_si_pat_info b where b.pat_no=inpatient_no and b.times=admiss_times and b.ledger_sn=a.ledger_sn), " +
             "medType=(select med_type from t_si_pat_info b where b.pat_no=inpatient_no and b.times=admiss_times and b.ledger_sn=a.ledger_sn), " +
             "medListCodg=isnull((select max(national_code) from yp_zd_dict where code=charge_code_mx),(select max(national_code) from zd_charge_item where code=charge_code_mx)), " +
+            "medListCodgType=case when (select max(national_code) from yp_zd_dict where code=charge_code_mx) is not null then 1 else 2 end, " +
             "bilgDeptCodg=(select t.si_caty from zd_unit_code t where t.code=ward_code), " +
             "bilgDeptName=(select z.name from t_yb_dept z where z.code=" +
             "(select t.si_caty from zd_unit_code t where t.code=ward_code)), " +
@@ -345,6 +348,7 @@ public interface SiZyDao {
             "psnNo=(select psn_no from t_si_pat_info b where b.pat_no=inpatient_no and b.times=admiss_times and b.ledger_sn=a.ledger_sn), " +
             "medType=(select med_type from t_si_pat_info b where b.pat_no=inpatient_no and b.times=admiss_times and b.ledger_sn=a.ledger_sn), " +
             "medListCodg=isnull((select max(national_code) from yp_zd_dict where code=charge_code_mx),(select max(national_code) from zd_charge_item where code=charge_code_mx)), " +
+            "medListCodgType=case when (select max(national_code) from yp_zd_dict where code=charge_code_mx) is not null then 1 else 2 end, " +
             "bilgDeptCodg=(select t.si_caty from zd_unit_code t where t.code=ward_code), " +
             "bilgDeptName=(select z.name from t_yb_dept z where z.code=" +
             "(select t.si_caty from zd_unit_code t where t.code=ward_code)), " +
@@ -392,4 +396,89 @@ public interface SiZyDao {
     @Update("update t_si_sign_in set sign_no=#{signNo}, " +
             "sign_date=getdate() where id='medInsurSignIn'")
     void updateSignNo(String signNo);
+
+    /**
+     * 根据费用明细流水号获取处方号
+     *
+     * @param patNo    住院号
+     * @param times    住院次数
+     * @param detailSn 费用明细流水号
+     * @return 处方号
+     */
+    @Select("select order_no from zy_detail_charge where inpatient_no=#{patNo} " +
+            "and admiss_times=#{times} and detail_sn=#{detailSn}")
+    String selectRxnoByDetailSn(@Param("patNo") String patNo,
+                                @Param("times") int times,
+                                @Param("detailSn") Integer detailSn);
+
+    /**
+     * 获取科室编码
+     *
+     * @param patNo    住院号
+     * @param times    住院次数
+     * @param ledgerSn 账页号
+     * @return 科室编码
+     */
+    @Select("select top 1 t.si_caty from zd_unit_code t " +
+            "inner join zy_detail_charge a on t.code = a.ward_code " +
+            "where a.inpatient_no=#{patNo} and a.admiss_times=#{times} and a.ledger_sn=#{ledgerSn} " +
+            "and t.si_caty is not null and t.si_caty != ''")
+    String selectAdmDeptCodg(@Param("patNo") String patNo,
+                             @Param("times") int times,
+                             @Param("ledgerSn") int ledgerSn);
+
+    /**
+     * 获取医生编码
+     *
+     * @param patNo    住院号
+     * @param times    住院次数
+     * @param ledgerSn 账页号
+     * @return 医生编码
+     */
+    @Select("select top 1 rtrim(yb_code) from a_employee_mi " +
+            "where code in (select top 1 isnull(isnull(nullif(doctor_code,''),refer_physician),op_id_code) " +
+            "from zy_detail_charge where inpatient_no=#{patNo} and admiss_times=#{times} and ledger_sn=#{ledgerSn} " +
+            "and charge_amount > 0 and isnull(infant_flag,0)=0 and isnull(trans_flag_yb,0) in ('',0)) " +
+            "and yb_code is not null and yb_code != ''")
+    String selectAtddrNo(@Param("patNo") String patNo,
+                         @Param("times") int times,
+                         @Param("ledgerSn") int ledgerSn);
+
+    /**
+     * 获取诊断编码
+     *
+     * @param patNo    住院号
+     * @param times    住院次数
+     * @return 诊断编码
+     */
+    @Select("select top 1 rtrim(dis_diag) from ba_first_page1 " +
+            "where inpatient_no=#{patNo} and admiss_times=#{times} and dis_diag_no=1 " +
+            "and dis_diag is not null and dis_diag != ''")
+    String selectDiagCode(@Param("patNo") String patNo,
+                          @Param("times") int times);
+
+    /**
+     * 获取诊断描述(多个诊断编码,以"|"分隔)
+     *
+     * @param patNo    住院号
+     * @param times    住院次数
+     * @return 诊断描述(最多三个诊断编码,以"|"分隔)
+     */
+    @Select("select top 1 " +
+            "case when count(*) >= 3 then " +
+            "  (select string_agg(rtrim(dis_diag), '|') from " +
+            "   (select top 3 dis_diag from ba_first_page1 " +
+            "    where inpatient_no=#{patNo} and admiss_times=#{times} " +
+            "    and dis_diag is not null and dis_diag != '' " +
+            "    order by dis_diag_no) t) " +
+            "else " +
+            "  (select string_agg(rtrim(dis_diag), '|') from ba_first_page1 " +
+            "   where inpatient_no=#{patNo} and admiss_times=#{times} " +
+            "   and dis_diag is not null and dis_diag != '') " +
+            "end as diag_dscr " +
+            "from ba_first_page1 " +
+            "where inpatient_no=#{patNo} and admiss_times=#{times} " +
+            "and dis_diag is not null and dis_diag != ''")
+    String selectDiagDscr(@Param("patNo") String patNo,
+                          @Param("times") int times);
 }

+ 5 - 0
src/main/java/thyyxxk/sizyfeeoprnsystm/pojo/FeeDtle.java

@@ -60,6 +60,11 @@ public class FeeDtle {
     @JSONField(name = "med_list_codg")
     private String medListCodg;
     
+    /**
+     * 医疗目录编码类型:1-药品,2-诊疗项目/材料
+     * */
+    private Integer medListCodgType;
+    
     /**
      * 医药机构目录编码
      * */

+ 76 - 7
src/main/java/thyyxxk/sizyfeeoprnsystm/service/SiZyFeeService.java

@@ -23,6 +23,7 @@ import thyyxxk.sizyfeeoprnsystm.utils.*;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.Date;
 
 /**
  * @author dj
@@ -641,9 +642,13 @@ public class SiZyFeeService {
             input.put("action", "transaction");
             input.put("transactionName", "2205");
             JSONObject businessParams = new JSONObject();
-            businessParams.put("feedetl_sn", detailSn);
-            businessParams.put("mdtrt_id", siPatInfo.getMdtrtId());
-            businessParams.put("psn_no", siPatInfo.getPsnNo());
+            businessParams.put("ipt_otp_no", siPatInfo.getMdtrtId());  // 门诊/住院流水号
+            
+            // 根据工伤文档要求:不允许传入处方号为空且处方流水号非空
+            // 需要获取对应的处方号
+            String rxno = zyDao.selectRxnoByDetailSn(p.getInpatientNo(), p.getAdmissTimes(), detailSn);
+            businessParams.put("rxno", StringUtil.isBlank(rxno) ? "" : rxno);  // 处方号
+            businessParams.put("feedetl_sn", detailSn.toString());  // 处方流水号
             input.put("businessParams", businessParams);
             
             // 调用工伤撤销接口
@@ -783,8 +788,32 @@ public class SiZyFeeService {
      * 执行工伤费用上传
      */
     private int[] executeWorkInjuryUploadFees(JSONObject input, List<FeeDtle> fees, ZyPatientInfo p) {
-        String ref = JSONArray.toJSONString(fees);
-        input.put("businessParams", JSONArray.parse(ref));
+        // 构建符合工伤接口文档的businessParams数组
+        JSONArray businessParams = new JSONArray();
+        
+        for (FeeDtle feeDtle : fees) {
+            JSONObject feeItem = new JSONObject();
+            
+            // 根据工伤接口文档构建字段映射
+            feeItem.put("ipt_otp_no", p.getMdtrtId());  // 门诊/住院流水号
+            feeItem.put("list_type", feeDtle.getMedListCodgType() != null ? feeDtle.getMedListCodgType().toString() : "2");  // 三大目录类别:1-药品,2-诊疗项目,3-材料
+            feeItem.put("rxno", feeDtle.getDrordNo());  // 处方号
+            feeItem.put("feedetl_sn", feeDtle.getFeedetlSn());  // 处方流水号
+            feeItem.put("fee_ocur_time", formatDateTime(feeDtle.getFeeOcurTime()));  // 处方日期
+            feeItem.put("med_list_codg", feeDtle.getMedListCodg());  // 收费项目中心编码
+            feeItem.put("pric", feeDtle.getPric());  // 单价
+            feeItem.put("cnt", feeDtle.getCnt());  // 数量
+            feeItem.put("umamt", feeDtle.getDetItemFeeSumamt());  // 总金额
+            feeItem.put("bilg_dr_codg", feeDtle.getBilgDrCodg());  // 医生编码
+            feeItem.put("bilg_dept_codg", feeDtle.getBilgDeptCodg());  // 科室编码
+            // 根据工伤文档要求:空默认为否,所以不传这两个字段,让系统使用默认值
+            // feeItem.put("min_unit", "");  // 是否最小计量单位
+            // feeItem.put("allSelfFlag", "");  // 全额自费标志
+            
+            businessParams.add(feeItem);
+        }
+        
+        input.put("businessParams", businessParams);
         
         // 调用工伤费用上传接口
         JSONObject result = exec.executeWorkInjuryTrade(input);
@@ -843,8 +872,33 @@ public class SiZyFeeService {
         JSONObject input = new JSONObject();
         input.put("action", "transaction");
         input.put("transactionName", "2206");
-        String ref = JSONObject.toJSONString(zyPreSetlmt);
-        input.put("businessParams", JSONObject.parseObject(ref));
+        
+        // 根据工伤接口文档构建预结算参数
+        JSONObject businessParams = new JSONObject();
+        businessParams.put("ipt_otp_no", zyPreSetlmt.getMdtrtId());  // 门诊/住院流水号
+        businessParams.put("mdtrt_id", "");  // 单据号(预结算传空)
+        businessParams.put("med_type", p.getMedType());  // 医疗类别(从患者信息获取)
+        businessParams.put("setl_time", formatDateTime(new Date()));  // 结算日期(当前时间)
+        businessParams.put("dscg_time", formatDateTime(new Date()));  // 出院日期(当前时间)
+        businessParams.put("dscg_trt_rslt", "01");  // 出院原因(默认治愈)
+        
+        // 从数据库获取诊断信息
+        String diagCode = zyDao.selectDiagCode(p.getInpatientNo(), p.getAdmissTimes());
+        String diagDscr = zyDao.selectDiagDscr(p.getInpatientNo(), p.getAdmissTimes());
+        
+        businessParams.put("diag_code", StringUtil.isBlank(diagCode) ? "" : diagCode);  // 出院诊断疾病主编码
+        businessParams.put("psn_no", zyPreSetlmt.getPsnNo());  // 个人唯一识别码
+        
+        // 从数据库获取科室编码和医生编码
+        String admDeptCodg = zyDao.selectAdmDeptCodg(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn());
+        String atddrNo = zyDao.selectAtddrNo(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn());
+        
+        businessParams.put("adm_dept_codg", StringUtil.isBlank(admDeptCodg) ? "" : admDeptCodg);  // 科室编码
+        businessParams.put("atddr_no", StringUtil.isBlank(atddrNo) ? "" : atddrNo);  // 医生编码
+        businessParams.put("diag_dscr", StringUtil.isBlank(diagDscr) ? "" : diagDscr);  // 出院诊断
+        businessParams.put("occupationalType", "01");  // 职业病类型(默认普通住院)
+        
+        input.put("businessParams", businessParams);
         
         // 调用工伤预结算接口
         JSONObject result = exec.executeWorkInjuryTrade(input);
@@ -942,4 +996,19 @@ public class SiZyFeeService {
         }
         log.info("工伤正负相抵完成,抵消费用总条目:{}", count);
     }
+    
+
+    
+    /**
+     * 格式化日期时间为工伤接口要求的格式
+     * @param date 日期时间
+     * @return 格式化的日期时间字符串 YYYYMMDDHH24MISS
+     */
+    private String formatDateTime(Date date) {
+        if (date == null) {
+            return "";
+        }
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
+        return sdf.format(date);
+    }
 }

+ 300 - 0
工伤接口文档.md

@@ -0,0 +1,300 @@
+# 工伤接口开发文档
+
+## 4.3.2.5 处方明细上报(2204)
+
+### 4.3.2.5.1 交易说明
+
+1. 允许同时上传多条处方明细。
+2. 协议机构门诊随时上传处方,住院可以在摆药时上传,也可以每天晚上批量上传。
+3. 按处方时间顺序上传,同一药品、项目、材料正数在前,负数在后。
+4. 同一个包内应只包含同一次住院的费用明细,不同住院的明细分别打包上传。
+5. 第九位入参总金额为单条处方数据的费用总额,等于第七位入参单价乘以第八位入参数量后四舍五入到小数点后两位。
+6. 第十二位入参是否按最小计量单位,如果为是表示该处方按最小计量单位收费。中心进行限价控制时会使用整装的限价除以包装数量后的最小计量限价进行计算。
+7. 单次交易最多允许上传50条处方。
+8. 输入为多行数据,输出与输入行数一一对应。
+
+### 4.3.2.5.2 输入
+
+**表 14 输入-费用明细列表(节点标识:feedetail)**
+
+| 序号 | 参数代码 | 参数名称 | 参数类型 | 参数长度 | 代码标识 | 是否必填 | 说明 |
+|------|----------|----------|----------|----------|----------|----------|------|
+| 1 | ipt_otp_no | 门诊/住院流水号 | 字符型 | 20 | | Y | 同登记时的门诊/住院流水号 |
+| 2 | list_type | 三大目录类别 | 字符型 | 3 | Y | Y | |
+| 3 | rxno | 处方号 | 字符型 | 20 | | Y | |
+| 4 | feedetl_sn | 处方流水号 | 字符型 | 30 | | Y | 单次就诊内唯一 |
+| 5 | fee_ocur_time | 处方日期 | 字符型 | | | Y | 按照日期格式 YYYYMMDDHH24MISS |
+| 6 | med_list_codg | 收费项目中心编码 | 字符型 | 50 | | Y | |
+| 7 | pric | 单价 | 数值型 | 16,4 | | Y | |
+| 8 | cnt | 数量 | 数值型 | 16,4 | | Y | |
+| 9 | umamt | 总金额 | 数值型 | 16,2 | | Y | 单条处方的总金额等于单价*数量后四舍五入两位 |
+| 10 | bilg_dr_codg | 医生编码 | 字符型 | 50 | | Y | |
+| 11 | bilg_dept_codg | 科室编码 | 字符型 | 50 | | Y | |
+| 12 | min_unit | 是否最小计量单位 | 字符型 | 3 | Y | | 空默认为否 |
+| 13 | allSelfFlag | 全额自费标志 | 字符型 | 3 | Y | | 空默认为否 |
+
+### 4.3.2.5.3 输出
+
+**表 15 输出(节点标识:output)**
+
+| 序号 | 参数代码 | 参数名称 | 参数类型 | 参数长度 | 代码标识 | 是否非空 | 说明 |
+|------|----------|----------|----------|----------|----------|----------|------|
+| 1 | rxno | 处方号 | 字符型 | 20 | | Y | |
+| 2 | feedetl_sn | 处方流水号 | 字符型 | 30 | | | 单次就诊内唯一 |
+| 3 | fee_ocur_time | 处方日期 | 字符型 | | | Y | 按照日期格式 YYYYMMDDHH24MISS |
+| 4 | med_list_codg | 收费项目中心编码 | 字符型 | 20 | | Y | |
+| 5 | umamt | 总金额 | 数值型 | 16,2 | | Y | |
+| 6 | ownpay_amt | 自费金额 | 数值型 | 16,2 | | Y | 丙类费用 |
+| 7 | alwpay_amt | 超限价金额 | 数值型 | 16,2 | | | 超上限部分 |
+| 8 | pric_uplmt_amt | 支付上限 | 数值型 | 16,2 | | | |
+| 9 | chrgitm_lv | 收费项目等级 | 字符型 | 3 | Y | | |
+| 10 | memo | 说明信息 | 字符型 | 1000 | | | |
+
+### 4.3.2.5.4 本交易对应二级代码
+
+| 序号 | 类别名称 | 代码值 | 代码名称 | 备注 |
+|------|----------|--------|----------|------|
+| 1 | 三大目录类别 | 1 | 药品 | |
+| 2 | 三大目录类别 | 2 | 诊疗项目 | |
+| 3 | 三大目录类别 | 3 | 材料 | |
+| 4 | 是否最小计量单位 | 0 | 否 | |
+| 5 | 是否最小计量单位 | 1 | 是 | |
+| 6 | 收费项目等级 | 1 | 甲类 | |
+| 7 | 收费项目等级 | 2 | 乙类 | |
+| 8 | 收费项目等级 | 3 | 丙类 | |
+| 9 | 全额自费标志 | 0 | 否 | |
+| 10 | 全额自费标志 | 1 | 是 | |
+
+---
+
+## 4.3.2.6 处方明细撤销(2205)
+
+### 4.3.2.6.1 交易说明
+
+1. 如果只传入门诊/住院流水号,处方号和处方流水号为空,则撤销该门诊/住院流水号下所有未结算处方。
+2. 如果传入门诊/住院流水号和处方号,处方流水号为空,则撤销该门诊/住院流水号下该处方号的所有未结算处方。
+3. 如果传入门诊/住院流水号、处方号和处方流水号,则撤销该门诊/住院流水号下该处方号对应的处方流水号的未结算处方。
+4. 不允许传入处方号为空且处方流水号非空。
+5. 输入为单行数据,无输出。
+
+### 4.3.2.6.2 输入
+
+**表 16 输入(节点标识:input)**
+
+| 序号 | 参数代码 | 参数名称 | 参数类型 | 参数长度 | 代码标识 | 是否必填 | 说明 |
+|------|----------|----------|----------|----------|----------|----------|------|
+| 1 | ipt_otp_no | 门诊/住院流水号 | 字符型 | 20 | | Y | 同登记时的门诊/住院流水号 |
+| 2 | rxno | 处方号 | 字符型 | 20 | | | |
+| 3 | feedetl_sn | 处方流水号 | 字符型 | 30 | | | 单次就诊内唯一 |
+
+### 4.3.2.6.3 输出
+
+无
+
+---
+
+## 4.3.2.7 费用预结算(2206)
+
+### 4.3.2.7.1 交易说明
+
+1. 预结算只计算待遇享受信息,不对数据进行保存及提交,可多次进行预结算。
+2. 出参平衡关系说明:本次医疗费总额=本次统筹支付金额+ 现金。
+3. 门诊类允许一次就诊登记多次进行结算。住院类一次就诊登记只能进行一次结算。
+4. 输入为单行数据,输出为单行数据。
+
+### 4.3.2.7.2 输入
+
+**表 17 输入(节点标识:input)**
+
+| 序号 | 参数代码 | 参数名称 | 参数类型 | 参数长度 | 代码标识 | 是否必填 | 说明 |
+|------|----------|----------|----------|----------|----------|----------|------|
+| 1 | ipt_otp_no | 门诊/住院流水号 | 字符型 | 20 | | Y | 同登记时的门诊/住院流水号 |
+| 2 | mdtrt_id | 单据号 | 字符型 | 20 | | Y | 预结算传空,结算时必传且不能为0 |
+| 3 | med_type | 医疗类别 | 字符型 | 3 | Y | Y | |
+| 4 | setl_time | 结算日期 | 字符型 | | | Y | 按照日期格式 YYYYMMDDHH24MISS |
+| 5 | dscg_time | 出院日期 | 字符型 | | | Y | 按照日期格式 YYYYMMDDHH24MISS |
+| 6 | dscg_trt_rslt | 出院原因 | 字符型 | 3 | Y | Y | |
+| 7 | diag_code | 出院诊断疾病主编码 | 字符型 | 50 | | Y | ICD10编码 |
+| 8 | psn_no | 个人唯一识别码 | 数值型 | 16 | | Y | |
+| 9 | adm_dept_codg | 科室编码 | 字符型 | 50 | | Y | |
+| 10 | atddr_no | 医生编码 | 字符型 | 50 | | Y | |
+| 11 | diag_dscr | 出院诊断 | 字符型 | 500 | | | 最多可上传三个ICD10病种编码,以"\|"分隔 |
+| 12 | occupationalType | 职业病类型 | 字符型 | 3 | Y | | 未执行重症职业病政策城市不要传入 |
+
+### 4.3.2.7.3 输出
+
+**表 18 输出(节点标识:output)**
+
+| 序号 | 参数代码 | 参数名称 | 参数类型 | 参数长度 | 代码标识 | 是否非空 | 说明 |
+|------|----------|----------|----------|----------|----------|----------|------|
+| 1 | ipt_otp_no | 门诊/住院流水号 | 字符型 | 20 | | Y | |
+| 2 | mdtrt_id | 单据号 | 字符型 | 20 | | Y | |
+| 3 | medfee_sumamt | 本次医疗费总额 | 数值型 | 16,2 | | Y | |
+| 4 | hifp_pay | 本次统筹支付金额 | 数值型 | 16,2 | | | |
+| 5 | psn_cash_pay | 本次现金支付总额 | 数值型 | 16,2 | | Y | |
+| 6 | med_list_codg | 说明信息 | 字符型 | 200 | | | |
+| 7 | umamt | 备注 | 字符型 | 16,4 | | | |
+| 8 | drug_fee | 药费合计 | 数值型 | 16,2 | | | |
+| 9 | dati_fee | 诊疗项目费合计 | 数值型 | 16,2 | | | |
+| 10 | ms_fee | 材料费合计 | 数值型 | 16,2 | | | |
+
+### 4.3.2.7.4 本交易对应二级代码
+
+| 序号 | 类别名称 | 代码值 | 代码名称 | 备注 |
+|------|----------|--------|----------|------|
+| 1 | 医疗类别 | 11 | 门诊肢体残 | |
+| 2 | 医疗类别 | 12 | 门诊职业病 | |
+| 3 | 医疗类别 | 13 | 门诊康复 | |
+| 4 | 医疗类别 | 21 | 住院肢体残 | |
+| 5 | 医疗类别 | 22 | 住院职业病 | |
+| 6 | 医疗类别 | 23 | 住院康复 | |
+| 7 | 出院原因 | 01 | 治愈 | |
+| 8 | 出院原因 | 02 | 死亡 | |
+| 9 | 出院原因 | 03 | 转院 | |
+| 10 | 出院原因 | 04 | 其它 | |
+| 11 | 出院原因 | 05 | 好转 | |
+| 12 | 职业病类型 | 01 | 普通住院 | |
+| 13 | 职业病类型 | 02 | 职业病伴并发症 | |
+| 14 | 职业病类型 | 03 | 重症职业病 | |
+| 15 | 职业病类型 | 04 | 急救抢救 | |
+
+---
+
+## 4.3.2.8 费用结算(2207)
+
+### 输入参数
+同费用预结算2206,参数2单据号不能为空,传入实际的单据号。
+
+### 输出参数
+同费用预结算2206
+
+---
+
+## 4.3.2.9 费用结算撤销(2208)
+
+### 4.3.2.9.1 交易说明
+
+1. 要撤销的门诊/住院号通过第四位出参"是否保留处方标志"控制是否保留处方,保留的处方可以继续进行处方撤销、费用结算。
+2. 如果结算交易和撤销结算交易跨月结算结算期,则结算交易数据在上一结算期进行月结算撤销结算数据在下一结算期进行月结算。
+3. 输入为单行数据,无输出。
+
+### 4.3.2.9.2 输入
+
+**表 19 输入(节点标识:input)**
+
+| 序号 | 参数代码 | 参数名称 | 参数类型 | 参数长度 | 代码标识 | 是否必填 | 说明 |
+|------|----------|----------|----------|----------|----------|----------|------|
+| 1 | ipt_otp_no | 门诊/住院流水号 | 字符型 | 20 | | Y | 同登记时的门诊/住院流水号 |
+| 2 | mdtrt_id | 单据号 | 字符型 | 20 | | Y | 同结算时的单据号 |
+| 3 | setl_time | 结算撤销日期 | 字符型 | | | Y | 按照日期格式 YYYYMMDDHH24MISS |
+| 4 | keep_tp_type | 是否保留处方标志 | 字符型 | 3 | Y | Y | |
+
+### 4.3.2.9.3 输出
+
+无
+
+### 4.3.2.9.4 本交易对应二级代码
+
+| 序号 | 类别名称 | 代码值 | 代码名称 |
+|------|----------|--------|----------|
+| 1 | 是否保留处方标志 | 0 | 不保留 |
+| 2 | 是否保留处方标志 | 1 | 保留 |
+
+---
+
+## 4.3.2.10 冲正交易(2209)
+
+### 4.3.2.10.1 交易说明
+
+1. 供HIS处理冲正交易时调用,建议只有协议机构数据和中心端数据出现单边账时调用。正常情况建议通过费用结算撤销交易2208撤销费用。月结算后不允许进行冲正,注意每月及时对帐;月结算后数据以中心端为准。
+2. 允许冲正交易编号:2201、2207、2208
+3. 输入为单行数据,输出为单行数据。
+
+### 4.3.2.10.2 输入
+
+**表 20 输入(节点标识:input)**
+
+| 序号 | 数据元标识 | 数据元名称 | 类型 | 长度 | 代码标识 | 是否必填 | 备注 |
+|------|------------|------------|------|------|----------|----------|------|
+| 1 | infno | 冲正交易编号 | 字符型 | 4 | | Y | 可冲正交易编号:2201、2207、2208 |
+| 2 | msgid | 发送方报文ID | 字符型 | 30 | | Y | 协议机构发送交易时上传的报文ID |
+
+### 4.3.2.10.3 输出
+
+**表 21 输出(节点标识:output)**
+
+| 序号 | 参数代码 | 参数名称 | 参数类型 | 参数长度 | 代码标识 | 是否非空 | 说明 |
+|------|----------|----------|----------|----------|----------|----------|------|
+| 1 | rec_state | 冲正状态 | 字符型 | 3 | Y | Y | |
+| 2 | medfee_sumamt | 冲正医疗费总额 | 数值型 | 16,2 | | | |
+
+### 4.3.2.10.4 本交易对应二级代码
+
+| 序号 | 类别名称 | 代码值 | 代码名称 | 备注 |
+|------|----------|--------|----------|------|
+| 1 | 冲正状态 | 1 | 有正单据 | 发起的冲正交易流水号找到并冲正成功 |
+| 2 | 冲正状态 | 0 | 无正单据 | 发起的冲正交易流水号未找到 |
+
+---
+
+## 接口调用示例
+
+### 2204 处方明细上报请求示例
+```json
+{
+  "action": "transaction",
+  "transactionName": "2204",
+  "businessParams": [
+    {
+      "ipt_otp_no": "ZY20240115001",
+      "list_type": "1",
+      "rxno": "RX001",
+      "feedetl_sn": "1001",
+      "fee_ocur_time": "20240115103000",
+      "med_list_codg": "YP001",
+      "pric": 100.00,
+      "cnt": 1,
+      "umamt": 100.00,
+      "bilg_dr_codg": "DR001",
+      "bilg_dept_codg": "DEPT001",
+      "min_unit": "0",
+      "allSelfFlag": "0"
+    }
+  ]
+}
+```
+
+### 2205 处方明细撤销请求示例
+```json
+{
+  "action": "transaction",
+  "transactionName": "2205",
+  "businessParams": {
+    "ipt_otp_no": "ZY20240115001",
+    "rxno": "RX001",
+    "feedetl_sn": "1001"
+  }
+}
+```
+
+### 2206 费用预结算请求示例
+```json
+{
+  "action": "transaction",
+  "transactionName": "2206",
+  "businessParams": {
+    "ipt_otp_no": "ZY20240115001",
+    "mdtrt_id": "",
+    "med_type": "21",
+    "setl_time": "20240115103000",
+    "dscg_time": "20240115103000",
+    "dscg_trt_rslt": "01",
+    "diag_code": "J18.9",
+    "psn_no": "123456789",
+    "adm_dept_codg": "DEPT001",
+    "atddr_no": "DR001",
+    "diag_dscr": "肺炎",
+    "occupationalType": "01"
+  }
+}
+``` 

+ 195 - 0
工伤相关文档.md

@@ -0,0 +1,195 @@
+4.3.2.5处方明细上报(2204)
+4.3.2.5.1交易说明
+1、允许同时上传多条处方明细。
+2、协议机构门诊随时上传处方,住院可以在摆药时上传,也可以每天晚上批量上传。
+3、按处方时间顺序上传,同一药品、项目、材料正数在前,负数在后。
+4、同一个包内应只包含同一次住院的费用明细,不同住院的明细分别打包上传。
+5、第九位入参总金额为单条处方数据的费用总额,等于第七位入参单价乘以第八位入参数量后四舍五入到小数点后两位。
+6、第十二位入参是否按最小计量单位,如果为是表示该处方按最小计量单位收费。中心进行限价控制时会使用整装的限价除以包装数量后的最小计量限价进行计算。
+7、单次交易最多允许上传50条处方。
+8、输入为多行数据,输出与输入行数一一对应。4.3.2.5.2输入
+表 14 输入-费用明细列表(节点标识:feedetail) 
+序
+号 	参数代码 	参数名称 	参数类型 	参数
+长度 	代码
+标识 	是否
+必填 	说明 
+1 	ipt_otp_no 	门诊/住院流水号 	字符型 	20 	 	Y 	同登记时的门诊/住院流水号
+2 	list_type 	三大目录类别	字符型 	3	Y 	Y 	 
+3 	rxno 	     处方号 	字符型 	20 	 	Y 	
+4 	feedetl_sn 	处方流水号 	字符型 	30 	 	Y 	单次就诊内唯一
+5 	fee_ocur_time 	处方日期 	字符型 	 	 	Y 	按照日期格式
+YYYYMMDDHH24MISS
+6 	med_list_codg 	收费项目中心编码 	字符型 	50 	 	Y 	
+7 	pric 	单价 	数值型 	16,4	 	Y 	 
+8 	cnt 	数量 	数值型 	16,4	 	Y 	 
+9 	umamt	总金额	数值型 	16,2	 	Y 	单条处方的总金额等于单价*数量后四舍五入两位。
+10 	bilg_dr_codg 	医生编码 	字符型	50	 	Y 	 
+11 	bilg_dept_codg 	科室编码 	字符型	50 	 	Y 	 
+12	min_unit	是否最小计量单位	字符型 	3	Y		空默认为否
+13	allSelfFlag	全额自费标志	字符型	3	Y		空默认为否
+4.3.2.5.3输出
+表 15 输出(节点标识:output) 
+序
+号 	参数代码 	参数名称 	参数类型 	参数长度 	代码标识 	是否非空 	说明 
+1 	rxno 	     处方号 	字符型 	20 	 	Y 	
+2 	feedetl_sn 	处方流水号 	字符型 	30 	 	 	单次就诊内唯一
+	fee_ocur_time 	处方日期 	字符型 	 	 	Y 	按照日期格式
+YYYYMMDDHH24MISS
+3 	med_list_codg 	收费项目中心编码 	字符型 	20 	 	Y 	
+4 	umamt	总金额 	数值型	16,2	 	Y 	 
+5 	ownpay_amt  	自费金额 	数值型 	16,2 	 	Y 	丙类费用
+6 	alwpay_amt	超限价金额 	数值型 	16,2 	 	 	 超上限部分
+7 	pric_uplmt_amt	支付上限 	数值型 	16,2 	 	 	 
+8 	chrgitm_lv 	   收费项目等级 	字符型 	3 	 Y	 	 
+9 	memo  	说明信息 	字符型 	1000 	 	 	 
+
+4.3.2.5.4本交易对应二级代码
+序号	类别名称	代码值	代码名称	备注
+1	三大目录类别	1	药品	
+2	三大目录类别	2	诊疗项目	
+3	三大目录类别	3	材料	
+4	是否最小计量单位	0	否	
+5	是否最小计量单位	1	是	
+6	收费项目等级	1	甲类	
+7	收费项目等级	2	乙类	
+8	收费项目等级	3	丙类	
+9	全额自费标志	0	否	
+10	全额自费标志	1	是	
+
+4.3.2.6处方明细撤销(2205)
+4.3.2.6.1交易说明
+1、如果只传入门诊/住院流水号,处方号和处方流水号为空,则撤销该门诊/住院流水号下所有未结算处方。
+2、如果传入门诊/住院流水号和处方号,处方流水号为空,则撤销该门诊/住院流水号下该处方号的所有未结算处方。
+3、如果传入门诊/住院流水号、处方号和处方流水号,则撤销该门诊/住院流水号下该处方号对应的处方流水号的未结算处方。
+4、不允许传入处方号为空且处方流水号非空。
+5、输入为单行数据,无输出。
+4.3.2.6.2输入
+表 16 输入(节点标识:input) 
+序
+号 	参数代码 	参数名称 	参数类型 	参数
+长度 	代码
+标识 	是否
+必填 	说明 
+1 	ipt_otp_no 	门诊/住院流水号 	字符型 	20 	 	Y 	同登记时的门诊/住院流水号
+2 	rxno 	     处方号 	字符型 	20 	 	 	
+3 	feedetl_sn 	处方流水号 	字符型 	30 	 	 	单次就诊内唯一
+4.3.2.6.3输出
+无
+
+4.3.2.7费用预结算(2206)
+4.3.2.7.1交易说明
+1、预结算只计算待遇享受信息,不对数据进行保存及提交,可多次进行预结算。
+2、出参平衡关系说明:本次医疗费总额=本次统筹支付金额+ 现金。
+3、门诊类允许一次就诊登记多次进行结算。住院类一次就诊登记只能进行一次结算。
+4、输入为单行数据,输出为单行数据。
+4.3.2.7.2输入
+表 17 输入(节点标识:input)
+序
+号 	参数代码 	参数名称 	参数类型 	参数
+长度 	代码
+标识 	是否
+必填 	说明 
+1 	ipt_otp_no 	门诊/住院流水号 	字符型 	20 	 	Y 	同登记时的门诊/住院流水号
+2 	mdtrt_id 	单据号	字符型 	20	 	Y 	预结算传空,结算时必传且不能为0
+3 	med_type 	医疗类别 	字符型 	3	Y 	Y 	 
+4 	setl_time 	结算日期 	字符型 	 	 	Y 	按照日期格式
+YYYYMMDDHH24MISS
+5 	dscg_time 	出院日期 	字符型 	 	 	Y 	按照日期格式
+YYYYMMDDHH24MISS
+6 	dscg_trt_rslt 	出院原因 	字符型 	3	Y 	Y 	
+7 	diag_code 	出院诊断疾病主编码 	字符型 	50	 	Y 	ICD10编码
+8 	psn_no 	个人唯一识别码	数值型	16 	 	Y	 
+9 	adm_dept_codg 	科室编码 	字符型 	50 	 	 Y	
+10 	atddr_no 	医生编码 	字符型 	50	 	Y	 
+11 	diag_dscr	出院诊断 	字符型 	500 	 		最多可上传三个ICD10病种编码,以“|”分隔
+12	occupationalType	职业病类型	字符型	3	Y		未执行重症职业病政策城市不要传入
+
+4.3.2.7.3输出
+表 18 输出(节点标识:output) 
+序
+号 	参数代码 	参数名称 	参数类型 	参数长度 	代码标识 	是否非空 	说明 
+1 	ipt_otp_no 	门诊/住院流水号 	字符型 	20 	 	Y 	
+2 	mdtrt_id 	单据号	字符型 	20	 	Y 	
+3 	medfee_sumamt	  本次医疗费总额 	数值型	16,2	 	Y 	
+4 	hifp_pay 	本次统筹支付金额 	数值型	16,2	 	 	
+5	psn_cash_pay	本次现金支付总额 	数值型	16,2	 	Y 	
+6 	med_list_codg 	说明信息 	字符型 	200 	 		
+7 	umamt	备注 	字符型 	16,4	 		 
+8 	drug_fee  	药费合计 	数值型	16,2	 		 
+9 	dati_fee 	诊疗项目费合计 	数值型	16,2	 		 
+10 	ms_fee	材料费合计 	数值型	16,2	 		 
+
+4.3.2.7.4本交易对应二级代码
+序号	类别名称	代码值	代码名称	备注
+1	医疗类别	11	门诊肢体残	
+2	医疗类别	12	门诊职业病	
+3	医疗类别	13	门诊康复	
+4	医疗类别	21	住院肢体残	
+5	医疗类别	22	住院职业病	
+6	医疗类别	23	住院康复	
+7	出院原因	01	治愈	
+8	出院原因	02	死亡	
+9	出院原因	03	转院	
+10	出院原因	04	其它	
+11	出院原因	05	好转	
+12	职业病类型	01	普通住院	
+13	职业病类型	02	职业病伴并发症	
+14	职业病类型	03	重症职业病	
+15	职业病类型	04	急救抢救	
+
+4.3.2.8费用结算(2207)
+输入参数:
+同费用预结算2206,参数2单据号不能为空,传入实际的单据号。
+输出参数:
+同费用预结算2206
+
+4.3.2.9费用结算撤销(2208)
+4.3.2.9.1交易说明
+1、要撤销的门诊/住院号通过第四位出参“是否保留处方标志”控制是否保留处方,保留的处方可以继续进行处方撤销、费用结算。
+2、如果结算交易和撤销结算交易跨月结算结算期,则结算交易数据在上一结算期进行月结算撤销结算数据在下一结算期进行月结算。
+3、输入为单行数据,无输出。
+4.3.2.9.2输入
+表 19 输入(节点标识:input)
+序
+号 	参数代码 	参数名称 	参数类型 	参数
+长度 	代码
+标识 	是否
+必填 	说明 
+1 	ipt_otp_no 	门诊/住院流水号 	字符型 	20 	 	Y 	同登记时的门诊/住院流水号
+2 	mdtrt_id 	单据号	字符型 	20	 	Y 	同结算时的单据号
+3 	setl_time 	结算撤销日期	字符型 	 	 	Y 	按照日期格式
+YYYYMMDDHH24MISS
+4 	keep_tp_type 	是否保留处方标志	字符型 	3	Y 	Y 	
+
+4.3.2.9.3输出
+无 
+4.3.2.9.4本交易对应二级代码
+序号	类别名称	代码值	代码名称
+1	是否保留处方标志	0	不保留
+2	是否保留处方标志	1	保留
+
+4.3.2.10冲正交易(2209)
+4.3.2.10.1交易说明
+1、供HIS处理冲正交易时调用,建议只有协议机构数据和中心端数据出现单边账时调用。正常情况建议通过费用结算撤销交易2208撤销费用。月结算后不允许进行冲正,注意每月及时对帐;月结算后数据以中心端为准。
+2、允许冲正交易编号:2201、2207、2208
+3、输入为单行数据,输出为单行数据。
+4.3.2.10.2输入
+表 20 输入(节点标识:input) 
+序
+号 	数据元标识 	数据元名称 	类型 	长度 	代码
+标识 	是否必填 	备注 
+1 	infno 	冲正交易编号 	字符型 	4 	 	Y 	可冲正交易编号:2201、2207、2208
+2 	msgid 	发送方报文ID 	字符型 	30 	 	Y 	协议机构发送交易时上传的报文ID
+
+4.3.2.10.3输出
+表 21 输出(节点标识:output)
+序
+号 	参数代码 	参数名称 	参数类型 	参数长度 	代码标识 	是否非空 	说明 
+1 	rec_state	     冲正状态	字符型	3	 Y	Y 	
+2 	medfee_sumamt	冲正医疗费总额	数值型	16,2	 	 	
+
+4.3.2.10.4本交易对应二级代码
+序号	类别名称	代码值	代码名称	备注
+1	冲正状态	1	有正单据	发起的冲正交易流水号找到并冲正成功
+2	冲正状态	0	无正单据	发起的冲正交易流水号未找到

+ 190 - 0
工伤费用上传.md

@@ -0,0 +1,190 @@
+工伤费用上传流程:
+┌─────────────────┐
+│ 前端调用工伤接口 │
+│ /uploadWorkInjuryFees │
+└─────────┬───────┘
+          ↓
+┌─────────────────┐
+│ uploadWorkInjury│
+│ FeeDetail       │
+└─────────┬───────┘
+          ↓
+┌─────────────────┐
+│ beforeWorkInjury│
+│ Upload          │ ← 工伤预处理
+│ - 修改费用时间  │
+│ - 正负相抵逻辑  │
+└─────────┬───────┘
+          ↓
+┌─────────────────┐
+│ getAllFeesNot   │
+│ Uploaded        │ ← 获取未上传费用
+│ - 正费用查询    │
+│ - 负费用查询    │
+└─────────┬───────┘
+          ↓
+┌─────────────────┐
+│ prepareWorkInjury│
+│ UploadFees      │
+└─────────┬───────┘
+          ↓
+┌─────────────────┐
+│ 构建工伤请求头  │
+│ action: "transaction" │
+│ transactionName: "2204" │
+│ businessParams: [...] │
+└─────────┬───────┘
+          ↓
+┌─────────────────┐
+│ 处理费用明细    │
+│ - 设置医生编码  │
+│ - 批量处理(100条) │
+│ - 医生编码验证  │
+└─────────┬───────┘
+          ↓
+┌─────────────────┐
+│ executeWorkInjury│
+│ UploadFees      │
+└─────────┬───────┘
+          ↓
+┌─────────────────┐
+│ exec.executeWorkInjuryTrade │
+└─────────┬───────┘
+          ↓
+┌─────────────────┐
+│ 调用工伤接口    │
+│ (2204)          │
+└─────────┬───────┘
+          ↓
+┌─────────────────┐
+│ 处理上传结果    │
+│ - 解析返回数据  │
+│ - 记录成功/失败 │
+└─────────┬───────┘
+          ↓
+┌─────────────────┐
+│ 更新数据库      │
+│ - t_si_charge_temp │
+│ - 更新trans_flag │
+└─────────┬───────┘
+          ↓
+┌─────────────────┐
+│ 工伤费用撤销    │
+│ (2205)          │
+└─────────┬───────┘
+          ↓
+┌─────────────────┐
+│ revokeWorkInjury│
+│ UploadFees      │
+└─────────┬───────┘
+          ↓
+┌─────────────────┐
+│ 遍历撤销明细    │
+│ for (detailSn)  │
+└─────────┬───────┘
+          ↓
+┌─────────────────┐
+│ 构建撤销请求    │
+│ action: "transaction" │
+│ transactionName: "2205" │
+│ businessParams: {单个对象} │
+└─────────┬───────┘
+          ↓
+┌─────────────────┐
+│ 调用工伤撤销接口│
+│ exec.executeWorkInjuryTrade │
+└─────────┬───────┘
+          ↓
+┌─────────────────┐
+│ 处理撤销结果    │
+│ - 记录成功明细  │
+│ - 记录失败明细  │
+└─────────┬───────┘
+          ↓
+┌─────────────────┐
+│ 精确更新数据库  │
+│ - 只更新成功撤销的明细 │
+│ - 保持数据一致性 │
+└─────────┬───────┘
+          ↓
+┌─────────────────┐
+│ 工伤预结算      │
+│ (2206)          │
+└─────────┬───────┘
+          ↓
+┌─────────────────┐
+│ workInjuryPreSettlement │
+└─────────┬───────┘
+          ↓
+┌─────────────────┐
+│ 构建预结算请求  │
+│ action: "transaction" │
+│ transactionName: "2206" │
+│ businessParams: {对象} │
+└─────────┬───────┘
+          ↓
+┌─────────────────┐
+│ 调用工伤预结算接口│
+│ exec.executeWorkInjuryTrade │
+└─────────┬───────┘
+          ↓
+┌─────────────────┐
+│ 处理预结算结果  │
+│ - 获取报销金额  │
+│ - 更新数据库    │
+└─────────┬───────┘
+          ↓
+┌─────────────────┐
+│ 返回成功消息    │
+│ "工伤费用预结算成功" │
+└─────────────────┘
+
+## 工伤接口调用详细分析
+
+### 外部接口调用情况:
+
+1. **2204 - 工伤费用上传**
+   - **URL**: `http://130.150.161.72:9206/thyy/api/public/injury/workinjury`
+   - **请求格式**: 
+     ```json
+     {
+       "action": "transaction",
+       "transactionName": "2204", 
+       "businessParams": [费用明细数组]
+     }
+     ```
+   - **参数来源**: 从 `t_fee_dtle` 表查询未上传费用
+
+2. **2205 - 工伤费用撤销**
+   - **URL**: `http://130.150.161.72:9206/thyy/api/public/injury/workinjury`
+   - **请求格式**:
+     ```json
+     {
+       "action": "transaction",
+       "transactionName": "2205",
+       "businessParams": {
+         "feedetl_sn": "费用明细流水号",
+         "mdtrt_id": "就医ID", 
+         "psn_no": "人员编号"
+       }
+     }
+     ```
+   - **特殊处理**: 循环调用,每个明细单独撤销
+
+3. **2206 - 工伤预结算**
+   - **URL**: `http://130.150.161.72:9206/thyy/api/public/injury/workinjury`
+   - **请求格式**:
+     ```json
+     {
+       "action": "transaction",
+       "transactionName": "2206",
+       "businessParams": {预结算对象}
+     }
+     ```
+   - **参数来源**: 从 `t_zy_pre_setlmt` 表查询预结算信息
+
+### 数据库操作:
+
+- **查询表**: `t_si_pat_info`, `t_fee_dtle`, `t_zy_patient_info`, `t_zy_pre_setlmt`
+- **更新表**: `t_fee_dtle`, `t_si_charge_temp`, `t_zy_ledger_file`
+- **插入表**: `t_si_charge_temp`, `t_si_log`