Procházet zdrojové kódy

添加医院审批申请与审核模块。

lighter před 2 roky
rodič
revize
5b3c9ef307

+ 49 - 0
src/main/java/thyyxxk/webserver/controller/medicalinsurance/HospitalApprovalController.java

@@ -0,0 +1,49 @@
+package thyyxxk.webserver.controller.medicalinsurance;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import thyyxxk.webserver.entity.ResultVo;
+import thyyxxk.webserver.entity.medicalinsurance.hospitalapproval.PatientFeeItem;
+import thyyxxk.webserver.service.medicalinsurance.HospitalApprovalService;
+
+import java.util.List;
+
+@RestController
+@RequestMapping("/hospitalApproval")
+public class HospitalApprovalController {
+    private final HospitalApprovalService service;
+
+    @Autowired
+    public HospitalApprovalController(HospitalApprovalService service) {
+        this.service = service;
+    }
+
+    @GetMapping("/getPatientFeeList")
+    public ResultVo<List<PatientFeeItem>> getPatientFeeList(@RequestParam("patNo") String patNo,
+                                                            @RequestParam("times") Integer times,
+                                                            @RequestParam("ledgerSn") Integer ledgerSn) {
+        return service.getPatientFeeList(patNo, times, ledgerSn);
+    }
+
+    @GetMapping("/getAppliedItems")
+    public ResultVo<List<PatientFeeItem>> getAppliedItems(@RequestParam("patNo") String patNo,
+                                                          @RequestParam("times") Integer times,
+                                                          @RequestParam("ledgerSn") Integer ledgerSn) {
+        return service.getAppliedItems(patNo, times, ledgerSn);
+    }
+
+    @PostMapping("/applyHospitalApproval")
+    public ResultVo<String> applyHospitalApproval(@RequestBody PatientFeeItem feeItem) {
+        return service.applyHospitalApproval(feeItem);
+    }
+
+    @GetMapping("/getAllApplies")
+    public ResultVo<List<PatientFeeItem>> getAllApplies(@RequestParam("month") String month) {
+        return service.getAllApplies(month);
+    }
+
+    @PostMapping("/confirmHandleApply")
+    public ResultVo<String> confirmHandleApply(@RequestBody PatientFeeItem feeItem) {
+        return service.confirmHandleApply(feeItem);
+    }
+}

+ 56 - 0
src/main/java/thyyxxk/webserver/dao/his/medicalinsurance/HospitalApprovalDao.java

@@ -0,0 +1,56 @@
+package thyyxxk.webserver.dao.his.medicalinsurance;
+
+import org.apache.ibatis.annotations.Insert;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.Update;
+import thyyxxk.webserver.entity.medicalinsurance.hospitalapproval.PatientFeeItem;
+
+import java.util.List;
+
+@Mapper
+public interface HospitalApprovalDao {
+
+    @Select("select rtrim(inpatient_no) as patNo,admiss_times as times,ledger_sn,ori_detail_sn, " +
+            "detail_sn,charge_code_mx,charge_amount,charge_fee,charge_date, " +
+            "charge_name=case when serial in ('', '00') then (select top 1 rtrim(name) from " +
+            "zd_charge_item where code=charge_code_mx) " +
+            "else (select top 1 rtrim(name) from yp_zd_dict where code=charge_code_mx) end, " +
+            "applyStatus=(select t.apply_status from t_hospital_approval_apply t where t.pat_no=#{patNo} " +
+            "and t.times=#{times} and t.ledger_sn=#{ledgerSn} and t.detail_sn=a.detail_sn) " +
+            "from zy_detail_charge a where inpatient_no=#{patNo} and admiss_times=#{times} and " +
+            "ledger_sn=#{ledgerSn} and isnull(trans_flag_yb,0)!=2 and isnull(infant_flag,0)=0 and " +
+            "charge_amount>0 " )
+    List<PatientFeeItem> getPatientFeeList(String patNo, Integer times, Integer ledgerSn);
+
+    @Select("select * from t_hospital_approval_apply where pat_no=#{patNo} and " +
+            "times=#{times} and ledger_sn=#{ledgerSn} and detail_sn=#{detailSn}")
+    PatientFeeItem selectAccurateApply(String patNo, Integer times, Integer ledgerSn, Integer detailSn);
+
+    @Select("select * from t_hospital_approval_apply where " +
+            "pat_no=#{patNo} and times=#{times} and ledger_sn=#{ledgerSn} ")
+    List<PatientFeeItem> selectPatientApplies(String patNo, Integer times, Integer ledgerSn);
+    
+    @Insert("insert into t_hospital_approval_apply (pat_no,times,ledger_sn,detail_sn,charge_code_mx, " +
+            "charge_name,charge_amount,charge_fee,charge_date,staff_id,apply_datetime,apply_status) " +
+            "values (#{patNo},#{times},#{ledgerSn},#{detailSn},#{chargeCodeMx},#{chargeName},#{chargeAmount}, " +
+            "#{chargeFee},#{chargeDate},#{staffId},getdate(),0) ")
+    void insertNewApply(PatientFeeItem item);
+
+    @Select("select *,rtrim(b.name) as name,b.sex as gender,rtrim(b.admiss_dept) as wardName from " +
+            "t_hospital_approval_apply a, zy_actpatient b where a.apply_datetime>=#{begntime} and " +
+            "a.apply_datetime<=#{endtime} and a.pat_no=b.inpatient_no and a.times=b.admiss_times " +
+            "and a.ledger_sn=b.times_billed")
+    List<PatientFeeItem> selectAllApplies(String begntime, String endtime);
+
+    @Update("update t_hospital_approval_apply set apply_status=#{applyStatus},apply_handler=#{applyHandler}, " +
+            "handle_datetime=getdate(),handle_remark=#{handleRemark} where pat_no=#{patNo} and times=#{times} " +
+            "and ledger_sn=#{ledgerSn} and detail_sn=#{detailSn}; " +
+            "update zy_detail_charge set hosp_appr_flag=#{applyStatus} where inpatient_no=#{patNo} and " +
+            "admiss_times=#{times} and ledger_sn=#{ledgerSn} and detail_sn=#{detailSn}")
+    void handleApply(PatientFeeItem item);
+
+    @Select("select trans_flag_yb from zy_detail_charge where inpatient_no=#{patNo} and " +
+            "admiss_times=#{times} and ledger_sn=#{ledgerSn} and detail_sn=#{detailSn}")
+    String selectFeeTransFlag(String patNo, Integer times, Integer ledgerSn, Integer detailSn);
+}

+ 3 - 0
src/main/java/thyyxxk/webserver/dao/his/medicalinsurance/SiZyDao.java

@@ -109,6 +109,9 @@ public interface SiZyDao {
     void updateYbTransFlagInPair(@Param("zyh") String zyh, @Param("zycs") Integer zycs,
                                  @Param("sn") Integer sn, @Param("sn2") Integer sn2);
 
+    @Update("update zy_detail_charge set trans_flag_yb=2 where inpatient_no=#{zyh} and " +
+            "admiss_times=#{zycs} and detail_sn=#{sn} ")
+    void updateSingleYbTransFlag(@Param("zyh") String zyh, @Param("zycs") Integer zycs, @Param("sn") Integer sn);
 
     /**
      * 更新患者医保报销金额

+ 30 - 0
src/main/java/thyyxxk/webserver/entity/medicalinsurance/hospitalapproval/PatientFeeItem.java

@@ -0,0 +1,30 @@
+package thyyxxk.webserver.entity.medicalinsurance.hospitalapproval;
+
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class PatientFeeItem {
+    private String name;
+    private Integer gender;
+    private String patNo;
+    private Integer times;
+    private Integer ledgerSn;
+    private String wardName;
+    private Integer detailSn;
+    private String chargeCodeMx;
+    private String chargeName;
+    private String chargeAmount;
+    private String chargeFee;
+    private Date chargeDate;
+    private Integer oriDetailSn;
+    private String staffId;
+    private String staffName;
+    private Date applyDatetime;
+    private Integer applyStatus;
+    private String applyHandler;
+    private String handlerName;
+    private Date handleDatetime;
+    private String handleRemark;
+}

+ 93 - 0
src/main/java/thyyxxk/webserver/service/medicalinsurance/HospitalApprovalService.java

@@ -0,0 +1,93 @@
+package thyyxxk.webserver.service.medicalinsurance;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import thyyxxk.webserver.config.exception.ExceptionEnum;
+import thyyxxk.webserver.dao.his.medicalinsurance.HospitalApprovalDao;
+import thyyxxk.webserver.entity.ResultVo;
+import thyyxxk.webserver.entity.medicalinsurance.hospitalapproval.PatientFeeItem;
+import thyyxxk.webserver.service.redislike.RedisLikeService;
+import thyyxxk.webserver.utils.DateUtil;
+import thyyxxk.webserver.utils.ResultVoUtil;
+import thyyxxk.webserver.utils.TokenUtil;
+
+import java.util.List;
+import java.util.Objects;
+
+@Slf4j
+@Service
+public class HospitalApprovalService {
+    private final HospitalApprovalDao dao;
+    private final RedisLikeService redis;
+    private final SiZyService zyService;
+
+    @Autowired
+    public HospitalApprovalService(HospitalApprovalDao dao, RedisLikeService redis, SiZyService zyService) {
+        this.dao = dao;
+        this.redis = redis;
+        this.zyService = zyService;
+    }
+
+    public ResultVo<List<PatientFeeItem>> getPatientFeeList(String patNo, Integer times, Integer ledgerSn) {
+        return ResultVoUtil.success(dao.getPatientFeeList(patNo, times, ledgerSn));
+    }
+
+    public ResultVo<List<PatientFeeItem>> getAppliedItems(String patNo, Integer times, Integer ledgerSn) {
+        List<PatientFeeItem> applies = dao.selectPatientApplies(patNo, times, ledgerSn);
+        if (applies.isEmpty()) {
+            return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST, "患者没有已申请医院审批的费用。");
+        }
+        for (PatientFeeItem item : applies) {
+            item.setStaffName(redis.getEmployeeName(item.getStaffId()));
+            item.setHandlerName(redis.getEmployeeName(item.getApplyHandler()));
+        }
+        return ResultVoUtil.success(applies);
+    }
+
+    public ResultVo<String> applyHospitalApproval(PatientFeeItem feeItem) {
+        feeItem.setStaffId(TokenUtil.getTokenUserId());
+        log.info("申请医院审批:{}", feeItem);
+        PatientFeeItem existItem = dao.selectAccurateApply(feeItem.getPatNo(), feeItem.getTimes(),
+                feeItem.getLedgerSn(), feeItem.getDetailSn());
+        if (null == existItem) {
+            dao.insertNewApply(feeItem);
+            return ResultVoUtil.success("已发起申请,请等待医保科审核。");
+        }
+        if (existItem.getApplyStatus() == 2) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "此条费用的申请已被医保科驳回:"
+                    + existItem.getHandleRemark());
+        }
+        return ResultVoUtil.fail(ExceptionEnum.INTERNAL_SERVER_ERROR, "此条费用已申请过,请勿重复申请。");
+    }
+
+    public ResultVo<List<PatientFeeItem>> getAllApplies(String month) {
+        String begntime = month + "-01 00:00:00.000";
+        String endtime = DateUtil.getMonthEndtime(month);
+        List<PatientFeeItem> applies = dao.selectAllApplies(begntime, endtime);
+        if (applies.isEmpty()) {
+            return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST, "没有已申请医院审批的费用。");
+        }
+        for (PatientFeeItem item : applies) {
+            item.setStaffName(redis.getEmployeeName(item.getStaffId()));
+            item.setHandlerName(redis.getEmployeeName(item.getApplyHandler()));
+            item.setWardName(redis.getDeptName(item.getWardName()));
+        }
+        return ResultVoUtil.success(applies);
+    }
+
+    public ResultVo<String> confirmHandleApply(PatientFeeItem feeItem) {
+        feeItem.setApplyHandler(TokenUtil.getTokenUserId());
+        log.info("申审核医院审批:{}", feeItem);
+        dao.handleApply(feeItem);
+        if (feeItem.getApplyStatus() == 1) {
+            String transFlag = dao.selectFeeTransFlag(feeItem.getPatNo(), feeItem.getTimes(),
+                    feeItem.getLedgerSn(), feeItem.getDetailSn());
+            if (Objects.equals(transFlag, "1")) {
+                return zyService.revokeSingleCharge(feeItem.getPatNo(), feeItem.getTimes(),
+                        feeItem.getLedgerSn(), feeItem.getDetailSn());
+            }
+        }
+        return ResultVoUtil.success("处理成功。");
+    }
+}

+ 33 - 0
src/main/java/thyyxxk/webserver/service/medicalinsurance/SiZyService.java

@@ -367,6 +367,39 @@ public class SiZyService {
         return ResultVoUtil.success("退费处理成功。");
     }
 
+    public ResultVo<String> revokeSingleCharge(String patNo, int times, int ledgerSn, int detailSn) {
+        SiPatInfo siPatInfo = queryDao.selectSiPatInfoForZy(patNo, times, ledgerSn);
+        JSONObject input = exec.makeTradeHeaderWithInsureArea(SiFunction.REVOKE_HOSPITALIZATION_FEE_DETAILS,
+                siPatInfo.getInsuplcAdmdvs());
+        JSONArray data = new JSONArray();
+        JSONObject item = new JSONObject();
+        item.put("feedetl_sn", detailSn);
+        item.put("mdtrt_id", siPatInfo.getMdtrtId());
+        item.put("psn_no", siPatInfo.getPsnNo());
+        data.add(item);
+        input.getJSONObject("input").put("data", data);
+        JSONObject result = exec.executeTrade(input, SiFunction.REVOKE_HOSPITALIZATION_FEE_DETAILS);
+        log.info("【操作员:{}】退费处理:\n参数:{},\n结果:{}", TokenUtil.getTokenUserId(), input, result);
+        if (null == result) {
+            return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
+        }
+        Integer infcode = result.getInteger(RESULT_CODE);
+        logDao.insert(new SiLog(input, result, patNo, times, ledgerSn, infcode, siPatInfo.getPsnNo()));
+        if (null == infcode) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医保中心报错:" + result.getString("message"));
+        }
+        if (infcode == 0) {
+            QueryWrapper<SiChargeTemp> wrapper = new QueryWrapper<>();
+            wrapper.eq("pat_no", patNo);
+            wrapper.eq("times", times);
+            wrapper.eq("ledger_sn", ledgerSn);
+            wrapper.eq("feedetl_sn", detailSn);
+            chrgtmpdao.delete(wrapper);
+            dao.updateSingleYbTransFlag(patNo, times, detailSn);
+        }
+        return ResultVoUtil.success("处理成功。");
+    }
+
     public ResultVo<String> dischargeProcessing(ZyPatientInfo p) {
         if (null == p.getLedgerSn()) {
             p.setLedgerSn(dao.selectMaxLedgerSn(p.getInpatientNo(), p.getAdmissTimes()));