Browse Source

完成结算单修改的功能

xiaochan 3 years ago
parent
commit
f7603910d9

+ 1 - 1
pom.xml

@@ -10,7 +10,7 @@
     </parent>
     <groupId>thyyxxk</groupId>
     <artifactId>web-server</artifactId>
-    <version>10.7.3</version>
+    <version>10.7.4</version>
     <name>web-server</name>
     <description>server for yibao-web</description>
     <properties>

+ 38 - 0
src/main/java/thyyxxk/webserver/controller/medicalinsurance/SetlListUpldController.java

@@ -6,6 +6,8 @@ import org.springframework.web.bind.annotation.*;
 import thyyxxk.webserver.config.auth.PassToken;
 import thyyxxk.webserver.entity.ResultVo;
 import thyyxxk.webserver.entity.datamodify.GetDropdownBox;
+import thyyxxk.webserver.entity.datamodify.TYbSetModifyTime;
+import thyyxxk.webserver.entity.datamodify.TYbSetlModifyReq;
 import thyyxxk.webserver.entity.medicalinsurance.inpatient.ZyInactpatient;
 import thyyxxk.webserver.entity.medicalinsurance.setllistupld.UpldCollection;
 import thyyxxk.webserver.entity.querydata.JieSuanDanChaXun;
@@ -14,6 +16,7 @@ import thyyxxk.webserver.service.medicalinsurance.SetlListUpldService;
 
 import javax.servlet.http.HttpServletResponse;
 import java.util.List;
+import java.util.Map;
 
 /**
  * <p>
@@ -81,4 +84,39 @@ public class SetlListUpldController {
                                                          @RequestParam("currentPage") long currentPage) {
         return service.shouShuBianMa(content, currentPage);
     }
+
+    @PostMapping("/setlModifyReq")
+    public ResultVo<String> setlModifyReq(@RequestBody ZyInactpatient param) {
+        return service.setlModifyReq(param);
+    }
+
+    @PostMapping("/setlUploadAudit")
+    public ResultVo<String> setlUploadAudit(@RequestBody TYbSetlModifyReq param) {
+        return service.setlUploadAudit(param.getId(), param.getAuditFlag(), param.getAuditRemark(), param.getAuditStaff(), param.getAuditName());
+    }
+
+    @GetMapping("/xianZhiShiJian")
+    public ResultVo<TYbSetModifyTime> xianZhiShiJian() {
+        return service.xianZhiShiJian();
+    }
+
+    @GetMapping("/sheZhiShiJian")
+    public ResultVo<String> sheZhiShiJian(@RequestParam("startTime") String startTime,
+                                          @RequestParam("endTime") String endTime,
+                                          @RequestParam("opId") String opId) {
+        return service.sheZhiShiJian(startTime, endTime, opId);
+    }
+
+    @GetMapping("/getHuanZheFeiYong")
+    public ResultVo<List<Map<String, String>>> getHuanZheFeiYong(@RequestParam("patNo") String patNo,
+                                                                 @RequestParam("times") Integer times) {
+        return service.getHuanZheFeiYong(patNo, times);
+    }
+
+    @GetMapping("/xiuGaiGuanChuangYiShen")
+    public ResultVo<String> xiuGaiGuanChuangYiShen(@RequestParam("patNo") String patNo,
+                                                   @RequestParam("times") Integer times,
+                                                   @RequestParam("code") String code) {
+        return service.xiuGaiGuanChuangYiShen(patNo, times, code);
+    }
 }

+ 4 - 1
src/main/java/thyyxxk/webserver/controller/yibao/DictionaryController.java

@@ -42,7 +42,7 @@ public class DictionaryController {
 
     /**
      * 这是给病案首页填医保诊断用的
-     * */
+     */
     @PassToken
     @PostMapping("/searchYbDiag")
     public ResultVo<List<PureCodeName>> searchYbDiag(@RequestBody SearchDataParam param) {
@@ -59,6 +59,9 @@ public class DictionaryController {
         }
         int start = param.getPage() * 10;
         int end = param.getPage() * 10 + 10;
+        // todo 诊断搜索 这里使用编码 和 中文名称的时候 会报 下面这个错误
+        //  ervlet.service() for servlet [dispatcherServlet] in context with path [] threw exception
+        //  [Request processing failed; nested exception is java.lang.IllegalArgumentException: fromIndex(10) > toIndex(1)] with root cause
         return ResultVoUtil.success(res.getData().subList(start, Math.min(res.getData().size(), end)));
     }
 }

+ 131 - 16
src/main/java/thyyxxk/webserver/dao/his/medicalinsurance/UpIdCollectionDao.java

@@ -1,11 +1,9 @@
 package thyyxxk.webserver.dao.his.medicalinsurance;
 
-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 org.apache.ibatis.annotations.*;
 import thyyxxk.webserver.entity.datamodify.GetDropdownBox;
 import thyyxxk.webserver.entity.datamodify.TYbSetModifyTime;
+import thyyxxk.webserver.entity.datamodify.TYbSetlModifyReq;
 import thyyxxk.webserver.entity.medicalinsurance.inpatient.BatjBa4;
 import thyyxxk.webserver.entity.medicalinsurance.inpatient.YbZyDisDiag;
 import thyyxxk.webserver.entity.medicalinsurance.inpatient.ZyDisDiagYb;
@@ -15,6 +13,7 @@ import thyyxxk.webserver.entity.querydata.SiSetlinfoTemp;
 
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 /**
@@ -222,12 +221,16 @@ public interface UpIdCollectionDao {
             "select top ${pageSize} * from (" +
             "select " +
             "row_number() over (order by setl_time) as rowNumber," +
-            "rtrim(pat_no) pat_no,times,ledger_sn,psn_name,gend,brdy,insutype,psn_type,mdtrt_id,setl_id,setl_time, " +
+            "rtrim(a.pat_no) pat_no,a.times,ledger_sn,psn_name,gend,brdy,insutype,psn_type,mdtrt_id,setl_id,setl_time, " +
             "       a.med_type,medfee_sumamt,fund_pay_sumamt, " +
             "       acct_pay,psn_cash_pay,clr_optins,clr_optins_name = (select name from t_region where code=clr_optins), " +
             "       outDeptName=(select rtrim(name) from zd_unit_code where code=small_dept), " +
-            "       setl_list_id,datediff(day ,b.admiss_date ,b.dis_date) as act_ipt_days,b.operation " +
+            "       setl_list_id,datediff(day ,b.admiss_date ,b.dis_date) as act_ipt_days,b.operation,b.dec_type," +
+            "       id,req_op_id,rtrim(req_op_name) req_op_name,req_op_date,rtrim(req_remark) req_remark," +
+            "audit_staff,audit_name,audit_date,rtrim(audit_remark) audit_remark,audit_flag," +
+            "refer_physician_name = (select top 1 rtrim(name) from a_employee_mi where code = b.refer_physician),b.refer_physician " +
             "from t_si_setlinfo a left join  zy_inactpatient b on (a.pat_no = b.inpatient_no and a.times = b.admiss_times) " +
+            "left join t_yb_setl_modify_req c on (a.pat_no = c.pat_no and a.times = c.times) " +
             "where revoked = 0 " +
             "<if test=\"startTime !=null and startTime != '' \">" +
             " and setl_time &gt;= #{startTime} and setl_time &lt;= #{endTime} " +
@@ -274,6 +277,9 @@ public interface UpIdCollectionDao {
             "<if test=\"flag == 2 \">" +
             " and a.setl_list_id is not null " +
             "</if>" +
+            "<if test=\"auditFlag != 4 \">" +
+            " and c.audit_flag = #{auditFlag} " +
+            "</if>" +
             "<if test=\"referPhysician != null and  referPhysician != '' \">" +
             " and b.refer_physician = #{referPhysician} " +
             "</if>" +
@@ -290,6 +296,7 @@ public interface UpIdCollectionDao {
                                              @Param("clrOptins") List<String> clrOptins,
                                              @Param("flag") Integer flag,
                                              @Param("referPhysician") String referPhysician,
+                                             @Param("auditFlag") Integer auditFlag,
                                              @Param("currentPage") long currentPage,
                                              @Param("pageSize") long pageSize);
 
@@ -297,6 +304,7 @@ public interface UpIdCollectionDao {
     @Select("<script>" +
             "select count(*) " +
             "from t_si_setlinfo a left join  zy_inactpatient b on (a.pat_no = b.inpatient_no and a.times = b.admiss_times) " +
+            "left join t_yb_setl_modify_req c on (a.pat_no = c.pat_no and a.times = c.times) " +
             "where revoked = 0 " +
             "<if test=\"startTime !=null and startTime != '' \">" +
             " and setl_time &gt;= #{startTime} and setl_time &lt;= #{endTime} " +
@@ -343,6 +351,9 @@ public interface UpIdCollectionDao {
             "<if test=\"flag == 2 \">" +
             " and a.setl_list_id is not null " +
             "</if>" +
+            "<if test=\"auditFlag != 4 \">" +
+            " and c.audit_flag = #{auditFlag} " +
+            "</if>" +
             "<if test=\"referPhysician != null and referPhysician != '' \">" +
             " and b.refer_physician = #{referPhysician} " +
             "</if>" +
@@ -357,28 +368,34 @@ public interface UpIdCollectionDao {
                                   @Param("psnTypes") List<String> psnTypes,
                                   @Param("clrOptins") List<String> clrOptins,
                                   @Param("flag") Integer flag,
-                                  @Param("referPhysician") String referPhysician);
+                                  @Param("referPhysician") String referPhysician,
+                                  @Param("auditFlag") Integer auditFlag);
 
 
-    @Select("select opName = (select top(1) rtrim(name) from a_employee_mi where code = op_id_code),* " +
-            "from zy_dis_diag_yb where inpatient_no = #{patNo} and admiss_times = #{times} ")
+    @Select("select opName = (select top(1) rtrim(name) from a_employee_mi where code = op_id_code)," +
+            "rtrim(inpatient_no) inpatient_no, admiss_times, dis_diag_no, dis_diag_type,rtrim(dis_diag) dis_diag," +
+            "rtrim(dis_diag_comment) dis_diag_comment," +
+            "op_id_code, op_diag_date, dis_diag_bzfx, dis_diag_status, operation, si_diag_type  " +
+            "from ${tableName} where inpatient_no = #{patNo} and admiss_times = #{times} ")
     List<YbZyDisDiag> zhenDuanXinXi(@Param("patNo") String patNo,
-                                    @Param("times") Integer times);
+                                    @Param("times") Integer times,
+                                    @Param("tableName") String tableName);
 
 
     @Select("select ssys_name = (select top(1) rtrim(name) from a_employee_mi where code = ssys), " +
-            "       ssys_name1 = (select top(1) rtrim(name) from a_employee_mi where code = sszs1), " +
-            "       ssys_name2 = (select top(1) rtrim(name) from a_employee_mi where code = sszs2), " +
+            "       sszsName1 = (select top(1) rtrim(name) from a_employee_mi where code = sszs1), " +
+            "       sszsName2 = (select top(1) rtrim(name) from a_employee_mi where code = sszs2), " +
             "       mzys_name = (select top(1) rtrim(name) from a_employee_mi where code = mzys)," +
             "       bah, zyh, zycs, ssxh, ssrq, sstj, ssys, sszs1, sszs2, mzys, ssbm, ssmc, rtrim(mzff) mzff, rtrim(qkjb) qkjb," +
             "rtrim(yhqk) yhqk, ssbfz, fhqk, ssjb, cut_heal" +
-            " from batj_ba4 where zyh = #{patNo} and zycs = #{times} ")
+            " from ${tableName} where zyh = #{patNo} and zycs = #{times} ")
     List<BatjBa4> shouShuXinXi(@Param("patNo") String patNo,
-                               @Param("times") Integer times);
+                               @Param("times") Integer times,
+                               @Param("tableName") String tableName);
 
 
-    @Select("select inpatient_no,admiss_times,name,admiss_date,dis_date,responce_type,operation, " +
-            "       responce_type_name = (select rtrim(name) from zy_zd_responce_type where code = responce_type),sex " +
+    @Select("select rtrim(inpatient_no) inpatient_no,admiss_times,rtrim(name) name,admiss_date,dis_date,responce_type,operation, " +
+            "       responce_type_name = (select rtrim(name) from zy_zd_responce_type where code = responce_type),sex,rtrim(refer_physician) refer_physician " +
             "from zy_inactpatient where inpatient_no = #{patNo} and admiss_times = #{times}")
     ZyInactpatient huanZheXinXi(@Param("patNo") String patNo,
                                 @Param("times") Integer times);
@@ -407,4 +424,102 @@ public interface UpIdCollectionDao {
     long searchSurgeryTotal(@Param("content") String content);
 
 
+    @Delete("delete zy_dis_diag_yb_modify where inpatient_no = #{patNo} and admiss_times = #{times}; " +
+            "delete batj_ba4_modify where zyh = #{patNo} and zycs = #{times}; " +
+            "delete t_yb_setl_modify_req where pat_no = #{patNo} and times = #{times};")
+    void delReq(@Param("patNo") String patNo, @Param("times") Integer times);
+
+
+    @Insert("insert into t_yb_setl_modify_req (pat_no, times, req_op_id, req_op_name, req_remark) " +
+            "values (#{param.inpatientNo},#{param.admissTimes},#{param.opIdCode},#{param.opIdName},#{param.reqRemark})")
+    void setlModifyReq(@Param("param") ZyInactpatient param);
+
+    @Insert("<script>" +
+            "insert into ${tableName} (inpatient_no, admiss_times, dis_diag_no, dis_diag_type, dis_diag, dis_diag_comment, " +
+            "op_id_code, op_diag_date, dis_diag_bzfx, dis_diag_status, operation, si_diag_type) " +
+            "values " +
+            "<foreach collection='list' item='param' separator=','>" +
+            "(#{param.inpatientNo},#{param.admissTimes},#{param.disDiagNo},'13',#{param.disDiag},#{param.disDiagComment}, " +
+            "        #{param.opIdCode},#{param.opDiagDate},'001',#{param.disDiagStatus},null,#{param.siDiagType})" +
+            "</foreach>" +
+            "</script>")
+    void setlModDis(@Param("list") List<YbZyDisDiag> param,
+                    @Param("tableName") String tableName);
+
+    @Insert("<script>" +
+            "insert into ${tableName} (bah, zyh, zycs, ssxh, ssrq, sstj, ssys, sszs1, sszs2, " +
+            "mzys, ssbm, ssmc, mzff, qkjb, yhqk, ssbfz, fhqk, ssjb, cut_heal) " +
+            "values " +
+            "<foreach collection='list' item='param' separator=','>" +
+            "(#{param.zyh},#{param.zyh},#{param.zycs},#{param.ssxh},#{param.ssrq},null,#{param.ssys},#{param.sszs1}," +
+            "#{param.sszs2},#{param.mzys},#{param.ssbm},#{param.ssmc},#{param.mzff},#{param.qkjb},#{param.yhqk},null,null,#{param.ssjb},null)" +
+            "</foreach>" +
+            "</script>")
+    void setlModBat(@Param("list") List<BatjBa4> batjBa4s,
+                    @Param("tableName") String tableName);
+
+
+    @Select("update zy_inactpatient set operation = #{operation} /*治疗方式*/ , dec_type = #{decType} /*申报类型*/ " +
+            "where  inpatient_no = #{patNo} and admiss_times = #{times}")
+    void shenBao(@Param("operation") String operation,
+                 @Param("decType") Integer decType,
+                 @Param("patNo") String patNo,
+                 @Param("times") Integer times);
+
+    @Select("select * from t_yb_setl_modify_req where id = #{id}")
+    TYbSetlModifyReq shenHeXinXi(Integer id);
+
+    @Update("update t_yb_setl_modify_req set audit_flag = #{auditFlag} where id = #{id}")
+    void upAuditFlag(@Param("id") Integer id,
+                     @Param("auditFlag") Integer auditFlag);
+
+    @Delete("delete zy_dis_diag_yb where inpatient_no = #{patNo} and admiss_times = #{times};" +
+            "delete batj_ba4 where zyh = #{patNo} and zycs = #{times}")
+    void delYuanShuJu(@Param("patNo") String patNo,
+                      @Param("times") Integer times);
+
+
+    @Insert("insert into zy_dis_diag_yb (inpatient_no, admiss_times, dis_diag_no, dis_diag_type, dis_diag, " +
+            "                            dis_diag_comment, op_id_code, op_diag_date, dis_diag_bzfx, dis_diag_status, " +
+            "                            operation, si_diag_type) " +
+            "select inpatient_no, admiss_times, dis_diag_no, dis_diag_type, dis_diag, " +
+            "       dis_diag_comment, op_id_code, op_diag_date, dis_diag_bzfx, dis_diag_status, " +
+            "       operation, si_diag_type from zy_dis_diag_yb_modify " +
+            "where inpatient_no = #{patNo} and admiss_times = #{times}; " +
+            "insert into batj_ba4 (bah, zyh, zycs, ssxh, ssrq, sstj, ssys, sszs1, sszs2, mzys, ssbm, ssmc, mzff, qkjb, " +
+            "                      yhqk, ssbfz, fhqk, ssjb, cut_heal) " +
+            "select bah, zyh, zycs, ssxh, ssrq, sstj, ssys, sszs1, sszs2, mzys, ssbm, ssmc, mzff, qkjb, yhqk, ssbfz, fhqk, ssjb, cut_heal " +
+            "from batj_ba4_modify where zyh = #{patNo} and zycs = #{times};")
+    void auditTongGuo(@Param("patNo") String patNo,
+                      @Param("times") Integer times);
+
+
+    @Update("update t_yb_setl_modify_req set audit_staff = #{auditStaff},audit_remark = #{remark},audit_name = #{auditName}," +
+            "audit_date = getdate() " +
+            "where id = #{id}")
+    void updateReq(@Param("id") Integer id,
+                   @Param("remark") String remark,
+                   @Param("auditStaff") String auditStaff,
+                   @Param("auditName") String auditName);
+
+    @Select("select top 1 *,op_id_name = (select top 1 rtrim(name) from a_employee_mi where op_id = code) from t_yb_set_modify_time")
+    TYbSetModifyTime xianZhiShiJian();
+
+    @Select("update t_yb_set_modify_time set start_time = #{startTime} ,end_time = #{endTime}, op_id = #{opId} ,op_date = getdate()")
+    void sheZhiShiJian(@Param("startTime") String startTime,
+                       @Param("endTime") String endTime,
+                       @Param("opId") String opId);
+
+    @Select("select exec_unit as execUnit,execUnitName = (select rtrim(name) from zd_unit_code where code = exec_unit), " +
+            "       sum(charge_amount) chargeAmount,sum(charge_fee) chargeFee " +
+            "from zy_detail_charge where inpatient_no = #{patNo} and admiss_times = #{times} " +
+            "group by exec_unit order by chargeFee desc")
+    List<Map<String, String>> getHuanZheFeiYong(@Param("patNo") String patNo,
+                                                @Param("times") Integer times);
+
+    @Update("update  zy_inactpatient set refer_physician = #{code} where inpatient_no = #{patNo} and admiss_times = #{times}")
+    void xiuGaiGuanChaungYiShen(@Param("patNo") String patNo,
+                                @Param("times") Integer times,
+                                @Param("code") String code);
+
 }

+ 5 - 1
src/main/java/thyyxxk/webserver/entity/datamodify/TYbSetModifyTime.java

@@ -8,7 +8,7 @@ import java.util.Date;
 @Data
 public class TYbSetModifyTime implements Serializable {
 
-    private static final long serialVersionUID = 6477219458859495432L;
+    private static final long serialVersionUID = 2232208300700719479L;
 
     /**
      * id
@@ -29,6 +29,10 @@ public class TYbSetModifyTime implements Serializable {
      * 设置这个的人
      */
     private String opId;
+    /**
+     * 设置这个的人姓名
+     */
+    private String opIdName;
 
     /**
      * opDate

+ 73 - 0
src/main/java/thyyxxk/webserver/entity/datamodify/TYbSetlModifyReq.java

@@ -0,0 +1,73 @@
+package thyyxxk.webserver.entity.datamodify;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+@Data
+public class TYbSetlModifyReq implements Serializable {
+
+    private static final long serialVersionUID = 7888519002348052752L;
+
+    /**
+     * id
+     */
+    private Integer id;
+
+    /**
+     * 住院号
+     */
+    private String patNo;
+
+    /**
+     * 住院次数
+     */
+    private Integer times;
+
+    /**
+     * 申请id
+     */
+    private String reqOpId;
+
+    /**
+     * 申请姓名
+     */
+    private String reqOpName;
+
+    /**
+     * 申请日期
+     */
+    private Date reqOpDate;
+
+    /**
+     * 申请备注
+     */
+    private String reqRemark;
+
+    /**
+     * 审核人 code
+     */
+    private String auditStaff;
+
+    /**
+     * 审核姓名
+     */
+    private String auditName;
+
+    /**
+     * 审核时间
+     */
+    private Date auditDate;
+
+    /**
+     * 审核备注
+     */
+    private String auditRemark;
+
+    /**
+     * 审核状态 0-待审核 1-审核通过 2-驳回 3-正在审核中
+     */
+    private Integer auditFlag;
+
+}

+ 2 - 0
src/main/java/thyyxxk/webserver/entity/medicalinsurance/inpatient/BatjBa4.java

@@ -111,4 +111,6 @@ public class BatjBa4 implements Serializable {
     private String sszsName2;
     private String mzysName;
 
+    private Boolean newData = false;
+
 }

+ 2 - 0
src/main/java/thyyxxk/webserver/entity/medicalinsurance/inpatient/YbZyDisDiag.java

@@ -24,4 +24,6 @@ public class YbZyDisDiag {
     private String disDiagStatus;
     private String operation;
     private String siDiagType;
+
+    private Boolean newData = false;
 }

+ 37 - 0
src/main/java/thyyxxk/webserver/entity/medicalinsurance/inpatient/ZyInactpatient.java

@@ -3,6 +3,7 @@ package thyyxxk.webserver.entity.medicalinsurance.inpatient;
 import lombok.Data;
 
 import java.io.Serializable;
+import java.math.BigDecimal;
 import java.util.Date;
 import java.util.List;
 
@@ -101,6 +102,11 @@ public class ZyInactpatient implements Serializable {
      */
     private String disDiag;
 
+    /**
+     * 诊断名称
+     */
+    private String disDiagComment;
+
     /**
      * disStatus
      */
@@ -371,6 +377,11 @@ public class ZyInactpatient implements Serializable {
      */
     private String opIdCode;
 
+    /**
+     * opIdCode
+     */
+    private String opIdName;
+
     /**
      * archiveCode
      */
@@ -826,6 +837,28 @@ public class ZyInactpatient implements Serializable {
      */
     private String matnType;
 
+    /**
+     * 总费用
+     */
+    private BigDecimal medfeeSumamt;
+
+    /**
+     * 报销金额
+     */
+    private BigDecimal fundPaySumamt;
+
+    /**
+     * 住院天数
+     */
+    private String actIptDays;
+
+    /**
+     * 申请备注
+     */
+    private String reqRemark;
+
+    private Integer ledgerSn;
+
 
     /**
      * 申报类型
@@ -837,4 +870,8 @@ public class ZyInactpatient implements Serializable {
     // 诊断编码
     private List<YbZyDisDiag> ybZyDisDiag;
 
+    // 手术信息
+    private List<BatjBa4> newBatjBa4;
+    // 诊断编码
+    private List<YbZyDisDiag> newYbZyDisDiag;
 }

+ 5 - 0
src/main/java/thyyxxk/webserver/entity/querydata/JieSuanDanChaXun.java

@@ -57,6 +57,11 @@ public class JieSuanDanChaXun {
      */
     private Integer flag;
 
+    /**
+     * 审核类型
+     */
+    private Integer auditFlag;
+
 
     private long currentPage;
     private long pageSize;

+ 57 - 0
src/main/java/thyyxxk/webserver/entity/querydata/SiSetlinfoTemp.java

@@ -291,9 +291,66 @@ public class SiSetlinfoTemp implements Serializable {
      * 治疗方式
      */
     private String operation;
+    /**
+     * 申报类型
+     */
+    private Integer decType;
 
     private String disDiag;
     private String disDiagComment;
+    private String referPhysicianName;
+    private String referPhysician;
+
+    /*            审核信息                  */
+    /**
+     * id
+     */
+    private Integer id;
+
+    /**
+     * reqOpId
+     */
+    private String reqOpId;
+
+    /**
+     * reqOpName
+     */
+    private String reqOpName;
+
+    /**
+     * reqOpDate
+     */
+    private Date reqOpDate;
+
+    /**
+     * 申请备注
+     */
+    private String reqRemark;
+
+    /**
+     * 审核人 code
+     */
+    private String auditStaff;
+
+    /**
+     * 审核姓名
+     */
+    private String auditName;
+
+    /**
+     * 审核时间
+     */
+    private Date auditDate;
+
+    /**
+     * 审核备注
+     */
+    private String auditRemark;
+
+    /**
+     * 审核状态 0-待审核 1-审核通过 2-驳回 3-正在审核中
+     */
+    private Integer auditFlag;
 
 
     public String getOperationName() {

+ 171 - 32
src/main/java/thyyxxk/webserver/service/medicalinsurance/SetlListUpldService.java

@@ -3,11 +3,13 @@ package thyyxxk.webserver.service.medicalinsurance;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.dynamic.datasource.annotation.DS;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.ListUtils;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 import thyyxxk.webserver.config.exception.ExceptionEnum;
 import thyyxxk.webserver.constants.GetDateFormat;
 import thyyxxk.webserver.constants.sidicts.*;
@@ -17,6 +19,9 @@ import thyyxxk.webserver.dao.his.yibao.DismissDao;
 import thyyxxk.webserver.entity.ResultVo;
 import thyyxxk.webserver.entity.datamodify.GetDropdownBox;
 import thyyxxk.webserver.entity.datamodify.TYbSetModifyTime;
+import thyyxxk.webserver.entity.datamodify.TYbSetlModifyReq;
+import thyyxxk.webserver.entity.medicalinsurance.inpatient.BatjBa4;
+import thyyxxk.webserver.entity.medicalinsurance.inpatient.YbZyDisDiag;
 import thyyxxk.webserver.entity.medicalinsurance.inpatient.ZyDisDiagYb;
 import thyyxxk.webserver.entity.medicalinsurance.inpatient.ZyInactpatient;
 import thyyxxk.webserver.entity.medicalinsurance.query.SiSetlFeeDetl;
@@ -28,7 +33,6 @@ import thyyxxk.webserver.utils.*;
 import thyyxxk.webserver.websocket.WebSocketServer;
 
 import javax.servlet.http.HttpServletResponse;
-import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -77,15 +81,15 @@ public class SetlListUpldService {
         JSONObject jsonObject = exec.makeTradeHeaderWithInsureArea(SiFunction.UPLOAD_SI_SETTLE_INFO, upldCollection.getData().getSetlinfo().getInsuplc());
         jsonObject.replace("input", input);
         // 这里是上传
-        JSONObject result = exec.executeTrade(jsonObject, SiFunction.UPLOAD_SI_SETTLE_INFO);
-
-//        JSONObject result = new JSONObject();
-//        if (times % 2 == 0) {
-//            result.put("infcode", 0);
-//        } else {
-//            result.put("infcode", -1);
-//            result.put("err_msg", "知道你为啥失败吗?");
-//        }
+//        JSONObject result = exec.executeTrade(jsonObject, SiFunction.UPLOAD_SI_SETTLE_INFO);
+
+        JSONObject result = new JSONObject();
+        if (times % 2 == 0) {
+            result.put("infcode", 0);
+        } else {
+            result.put("infcode", -1);
+            result.put("err_msg", "知道你为啥失败吗?");
+        }
         log.info("医保结算信息上传 \n操作人:{}\n参数:{} \n结果:{}", TokenUtil.getTokenUserId(), jsonObject, result);
         if (null == result) {
             return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
@@ -94,7 +98,7 @@ public class SetlListUpldService {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, String.format("医保中心报错:【%s】 ", result.getString("message")));
         }
         if (result.getIntValue(RESULT_CODE) == 0) {
-            dao.fanHuiLiuShuiHao(result.getJSONObject(OUTPUT).getString("setl_list_id"), upldCollection.getData().getSetlinfo().getSetlId());
+//            dao.fanHuiLiuShuiHao(result.getJSONObject(OUTPUT).getString("setl_list_id"), upldCollection.getData().getSetlinfo().getSetlId());
             return ResultVoUtil.success(ExceptionEnum.SUCCESS, "上传成功");
         }
         return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, String.format("医保中心报错:【%s】 ", result.getString("err_msg")));
@@ -257,12 +261,13 @@ public class SetlListUpldService {
             try {
                 ResultVo<String> resultVo = upldSetlList(siPatInfo.getPatNo(), siPatInfo.getTimes(), siPatInfo.getLedgerSn());
                 upldSetlErrorMessage(siPatInfo.getPatNo(), siPatInfo.getTimes(), siPatInfo.getLedgerSn(),
-                        resultVo.getMessage(), resultVo.getCode() == 200 ? 0 : 1, percentage);
+                        resultVo.getMessage(), resultVo.getCode() == 200 ? 0 : 1, percentage, siPatInfo.getOutDeptName(),
+                        siPatInfo.getPsnName(), siPatInfo.getReferPhysicianName());
             } catch (Exception e) {
                 log.info("批量上传结算单错误:{}", JSON.toJSONString(e));
                 e.printStackTrace();
                 upldSetlErrorMessage(siPatInfo.getPatNo(), siPatInfo.getTimes(), siPatInfo.getLedgerSn(),
-                        e.getMessage(), 2, percentage);
+                        e.getMessage(), 2, percentage, siPatInfo.getOutDeptName(), siPatInfo.getPsnName(), siPatInfo.getReferPhysicianName());
             }
         }
         return ResultVoUtil.success();
@@ -293,14 +298,18 @@ public class SetlListUpldService {
      *
      * @param meg 错误消息
      */
-    public void upldSetlErrorMessage(String patNo, Integer times, Integer ledgerSn, String meg, int type, int percentage) {
+    public void upldSetlErrorMessage(String patNo, Integer times, Integer ledgerSn, String meg,
+                                     int type, int percentage, String outDeptName, String psnName, String referPhysicianName) {
         JSONObject obj = new JSONObject();
         obj.put("name", "upldSetlListMessage");
-        obj.put("patNo#住院号|1", patNo);
-        obj.put("times#住院次数|2", times);
-        obj.put("ledgerSn#账页号|3", ledgerSn);
-        obj.put("message#上传结果|4", meg);
-        obj.put("type#类型|5", type);
+        obj.put("psnName#患者姓名|1", psnName);
+        obj.put("patNo#住院号|2", patNo);
+        obj.put("times#住院次数|3", times);
+        obj.put("ledgerSn#账页号|4", ledgerSn);
+        obj.put("message#上传结果|5", meg);
+        obj.put("outDeptName#出院科室|6", outDeptName);
+        obj.put("referPhysicianName#管床医生|7", referPhysicianName);
+        obj.put("type#类型|8", type);
         obj.put("percentage", percentage);
         obj.put("title", String.format("住院号:【%s】,住院次数:【%d】,账页号:【%d】。", patNo, times, ledgerSn));
         String message = obj.toJSONString();
@@ -375,7 +384,8 @@ public class SetlListUpldService {
     public ResultVo<IPage<SiSetlinfoTemp>> huoQuJieSuanRenYuan(JieSuanDanChaXun param) {
         IPage<SiSetlinfoTemp> page = new Page<>();
         page.setRecords(dao.huoQuJieSuanRenYuan(param.getStartTime(), param.getEndTime(), param.getClrType(), param.getPatNo(),
-                param.getInsutype(), param.getOutDept(), param.getMedType(), param.getPsnType(), param.getClrOptins(), param.getFlag(), param.getReferPhysician(), param.getCurrentPage(),
+                param.getInsutype(), param.getOutDept(), param.getMedType(), param.getPsnType(), param.getClrOptins(), param.getFlag(),
+                param.getReferPhysician(), param.getAuditFlag(), param.getCurrentPage(),
                 param.getPageSize()));
         if (ListUtil.isBlank(page.getRecords())) {
             return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST);
@@ -413,7 +423,8 @@ public class SetlListUpldService {
         }
         if (param.getTotal() == 0) {
             page.setTotal(dao.huoQuJieSuanRenYuanTotal(param.getStartTime(), param.getEndTime(), param.getClrType(), param.getPatNo(),
-                    param.getInsutype(), param.getOutDept(), param.getMedType(), param.getPsnType(), param.getClrOptins(), param.getFlag(), param.getReferPhysician()));
+                    param.getInsutype(), param.getOutDept(), param.getMedType(), param.getPsnType(), param.getClrOptins(), param.getFlag(),
+                    param.getReferPhysician(), param.getAuditFlag()));
         }
         return ResultVoUtil.success(page);
     }
@@ -445,7 +456,7 @@ public class SetlListUpldService {
         param.setCurrentPage(1);
         log.info("医保结算单: {}", JSON.toJSONStringWithDateFormat(param, GetDateFormat.DATE));
         List<SiSetlinfoTemp> list = huoQuJieSuanRenYuan(param).getData().getRecords();
-        String[] title = {"姓名", "出院科室", "住院号/门诊号", "性别", "住院天数", "诊断编码", "诊断名称", "治疗方式", "总费用", "报销金额", "险种类型", "人员类别", "结算时间", "医疗类别", "清算机构"};
+        String[] title = {"姓名", "出院科室", "住院号/门诊号", "性别", "住院天数", "诊断编码", "诊断名称", "治疗方式", "总费用", "报销金额", "险种类型", "人员类别", "结算时间", "医疗类别", "清算机构", "管床医生"};
         String[][] content = new String[list.size()][];
         for (int i = 0; i < list.size(); i++) {
             content[i] = new String[title.length];
@@ -465,6 +476,7 @@ public class SetlListUpldService {
             content[i][12] = DateUtil.formatDatetime(pojo.getSetlTime(), GetDateFormat.DATE_TIME);
             content[i][13] = pojo.getMedTypeName();
             content[i][14] = pojo.getClrOptinsName();
+            content[i][15] = pojo.getReferPhysicianName();
         }
         //传三个参数 一个是 固定的 response ,excel的头部信息,excel的内容
         ExcelUtil.exportExcel(response, title, content);
@@ -479,15 +491,10 @@ public class SetlListUpldService {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "该患者参保地不属于长沙市,无法上传结算清单。");
         }
         ZyInactpatient zy = dao.huanZheXinXi(patNo, times);
-        String[] strNow1 = new SimpleDateFormat("yyyy-MM").format(setlinfoUpld.getSetlEndDate()).split("-");
-        String[] strNow2 = new SimpleDateFormat("yyyy-MM").format(new Date()).split("-");
         List<Integer> code = publicServer.getRoleCode().getData();
         if (!code.contains(1) && !code.contains(8)) {
-            if (!strNow1[0].equals(strNow2[0])) {
-                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "当前年份和患者的结算年份不一致。");
-            }
-            if (!strNow1[1].equals(strNow2[1])) {
-                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "当前月份和患者的结算月份不一致。");
+            if (zy.getReferPhysician() == null || !zy.getReferPhysician().equals(TokenUtil.getTokenUserId())) {
+                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "您不是该患者的管床医生。");
             }
             TYbSetModifyTime modifyTime = dao.keXiuGaiShiJian();
             if (!DateUtil.isEffectiveDate(new Date(), modifyTime.getStartTime(), modifyTime.getEndTime())) {
@@ -500,10 +507,12 @@ public class SetlListUpldService {
         if (zy == null) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "未查询到患者信息。");
         }
-        // 手术
-        zy.setBatjBa4(dao.shouShuXinXi(patNo, times));
+        // 新老一起查
+        zy.setBatjBa4(dao.shouShuXinXi(patNo, times, "batj_ba4"));
+        zy.setNewBatjBa4(dao.shouShuXinXi(patNo, times, "batj_ba4_modify"));
         // 诊断编码
-        zy.setYbZyDisDiag(dao.zhenDuanXinXi(patNo, times));
+        zy.setYbZyDisDiag(dao.zhenDuanXinXi(patNo, times, "zy_dis_diag_yb"));
+        zy.setNewYbZyDisDiag(dao.zhenDuanXinXi(patNo, times, "zy_dis_diag_yb_modify"));
         return ResultVoUtil.success(zy);
     }
 
@@ -514,4 +523,134 @@ public class SetlListUpldService {
         return ResultVoUtil.success(page);
     }
 
+    @Transactional(rollbackFor = Exception.class)
+    @DS("dev")
+    public ResultVo<String> setlModifyReq(ZyInactpatient param) {
+        log.info("申请入参:{}", JSONObject.toJSONStringWithDateFormat(param, DateUtil.DEFAULT_PATTERN));
+        param.setLedgerSn(publicServer.getLedgerSn(param.getInpatientNo(), param.getAdmissTimes()));
+        Set<String> zhenDuanBianMa = new HashSet<>();
+        Set<String> shouShuBianMa = new HashSet<>();
+        for (YbZyDisDiag item : param.getYbZyDisDiag()) {
+            zhenDuanBianMa.add(item.getDisDiag());
+            if (item.getNewData()) {
+                item.setInpatientNo(param.getInpatientNo());
+                item.setAdmissTimes(param.getAdmissTimes());
+                item.setOpDiagDate(new Date());
+                item.setOpIdCode(param.getOpIdCode());
+            } else {
+                if (StringUtil.isBlank(item.getDisDiagStatus()) || item.getDisDiagStatus().trim().equals("0")) {
+                    return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, String.format("诊断为【%s】请填写出院病情,出院病情不能为 0 。", item.getDisDiagComment()));
+                }
+                if (StringUtil.isBlank(item.getDisDiag())) {
+                    return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "请填写诊断。");
+                }
+            }
+        }
+        int ssxh = 0;
+        for (BatjBa4 item : param.getBatjBa4()) {
+            shouShuBianMa.add(item.getSsbm());
+            item.setZyh(param.getInpatientNo());
+            item.setZycs(param.getAdmissTimes());
+            item.setSsxh(ssxh + 1);
+            if (!item.getNewData()) {
+                if (item.getSsrq() == null) {
+                    return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "手术日期不能为空。");
+                }
+                if (StringUtil.isBlank(item.getSsys())) {
+                    return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "手术医生不能为空");
+                }
+                if (StringUtil.isBlank(item.getSsmc())) {
+                    return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "手术名称不能为空");
+                }
+                if (StringUtil.isBlank(item.getSsjb())) {
+                    return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "手术级别不能为空");
+                }
+                if (StringUtil.isBlank(item.getSsbm())) {
+                    return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "手术编码不能为空");
+                }
+                if (StringUtil.isBlank(item.getSszs1())) {
+                    return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "手术助手至少有一个不能为空");
+                }
+                if (StringUtil.isBlank(item.getQkjb()) || StringUtil.isBlank(item.getYhqk())) {
+                    return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "切口愈合等级不能为空");
+                }
+                if (StringUtil.isBlank(item.getMzys())) {
+                    return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "麻醉医生不能为空");
+                }
+                if (StringUtil.isBlank(item.getMzff())) {
+                    return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "麻醉方法不能为空");
+                }
+            }
+        }
+        if (param.getYbZyDisDiag().size() != zhenDuanBianMa.size()) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "不可以有相同的诊断。");
+        }
+        if (param.getBatjBa4().size() != shouShuBianMa.size()) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "不可以有相同的手术编码。");
+        }
+        dao.delReq(param.getInpatientNo(), param.getAdmissTimes());
+        dao.setlModifyReq(param);
+        dao.setlModDis(param.getYbZyDisDiag(), "zy_dis_diag_yb_modify");
+        dao.setlModBat(param.getBatjBa4(), "batj_ba4_modify");
+        dao.shenBao(param.getOperation(), param.getDecType(), param.getInpatientNo(), param.getAdmissTimes());
+        return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "申请成功,请等待医保科审核。");
+    }
+
+    @DS("dev")
+    @Transactional(rollbackFor = Exception.class)
+    public ResultVo<String> setlUploadAudit(Integer id, Integer auditFlag, String remark, String auditStaff, String auditName) {
+        TYbSetlModifyReq req = dao.shenHeXinXi(id);
+        if (req == null) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有找到对应的信息,可能医生重新提交了,请刷新页面后重试。");
+        } else if (req.getAuditFlag() != 0) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR,
+                    String.format("该数据已被审核<br>审核人:【%s】<br>审核日期:【%s】"
+                            , req.getAuditName(), DateUtil.formatDatetime(req.getAuditDate())));
+        }
+        dao.upAuditFlag(id, 3);
+        if (auditFlag == 1) {
+            // 审核通过需要 删除 并更新
+            dao.delYuanShuJu(req.getPatNo(), req.getTimes());
+            dao.auditTongGuo(req.getPatNo(), req.getTimes());
+            dao.updateReq(id, remark, auditStaff, auditName);
+            return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "审核已通过 (*^▽^*)");
+        }
+        if (StringUtil.isBlank(remark)) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "驳回信息不能为空。");
+        }
+        dao.upAuditFlag(id, auditFlag);
+        return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "审核已驳回 (╯﹏╰)b");
+    }
+
+    public ResultVo<TYbSetModifyTime> xianZhiShiJian() {
+        return ResultVoUtil.success(dao.xianZhiShiJian());
+    }
+
+    public ResultVo<String> sheZhiShiJian(String startTime, String endTime, String opId) {
+        dao.sheZhiShiJian(startTime, endTime, opId);
+        return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "设置成功 (o゚▽゚)o  ");
+    }
+
+    /**
+     * 获取患者的科室费用
+     *
+     * @param patNo 住院号
+     * @param times 住院次数
+     * @return 返回费用
+     */
+    public ResultVo<List<Map<String, String>>> getHuanZheFeiYong(String patNo, Integer times) {
+        return ResultVoUtil.success(dao.getHuanZheFeiYong(patNo, times));
+    }
+
+    public ResultVo<String> xiuGaiGuanChuangYiShen(String patNo, Integer times, String code) {
+        if (StringUtil.isBlank(patNo) || times == null || times == 0) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "住院号或住院次数为空。");
+        } else if (StringUtil.isBlank(code)) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "管床医生不能设置为空。");
+        }
+        dao.xiuGaiGuanChaungYiShen(patNo, times, code);
+        return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "管床医生修改成功。");
+    }
+
+
 }