Browse Source

完成住院费用清单。

lighter 3 years ago
parent
commit
9de43c8a5b

+ 25 - 7
src/main/java/thyyxxk/webserver/controller/inpatient/ChargeListController.java

@@ -1,19 +1,19 @@
 package thyyxxk.webserver.controller.inpatient;
 
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 import thyyxxk.webserver.config.exception.ExceptionEnum;
 import thyyxxk.webserver.entity.ResultVo;
 import thyyxxk.webserver.entity.inpatient.chargelist.BriefPatInfo;
+import thyyxxk.webserver.entity.inpatient.chargelist.ChargeItem;
+import thyyxxk.webserver.entity.inpatient.chargelist.PatOverview;
 import thyyxxk.webserver.service.inpatient.ChargeListService;
 import thyyxxk.webserver.utils.ListUtil;
 import thyyxxk.webserver.utils.ResultVoUtil;
 import thyyxxk.webserver.utils.StringUtil;
 
 import java.util.List;
+import java.util.Map;
 
 @RestController
 @RequestMapping("/chargeList")
@@ -25,15 +25,33 @@ public class ChargeListController {
         this.service = service;
     }
 
-    @GetMapping("/selectBriefPatInfo")
-    public ResultVo<List<BriefPatInfo>> selectBriefPatInfo(@RequestParam("patNo") String patNo) {
+    @GetMapping("/selectPatOverviews")
+    public ResultVo<List<PatOverview>> selectPatOverviews(@RequestParam("patNo") String patNo) {
         if (StringUtil.isBlank(patNo)) {
             return ResultVoUtil.fail(ExceptionEnum.INVALID_PARAM, "住院号不能为空!");
         }
-        List<BriefPatInfo> resultList = service.selectBriefPatInfo(patNo);
+        List<PatOverview> resultList = service.selectPatOverviews(patNo);
         if (ListUtil.isBlank(resultList)) {
             return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST);
         }
         return ResultVoUtil.success(resultList);
     }
+
+    @PostMapping("/selectBriefPatInfo")
+    public ResultVo<BriefPatInfo> selectBriefPatInfo(@RequestBody PatOverview overview) {
+        BriefPatInfo result = service.selectBriefPatInfo(overview);
+        if (null == result) {
+            return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST, "没有查询到患者【" + overview.getPatNo() + "】在我院的住院记录。");
+        }
+        return ResultVoUtil.success(result);
+    }
+
+    @PostMapping("/selectChargeList")
+    public ResultVo<Map<String, Object>> selectChargeList(@RequestBody PatOverview overview) {
+        Map<String, Object> resultMap = service.selectChargeList(overview);
+        if (null == resultMap || resultMap.isEmpty()) {
+            return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST, "没有查询到患者的有效费用。");
+        }
+        return ResultVoUtil.success(resultMap);
+    }
 }

+ 22 - 3
src/main/java/thyyxxk/webserver/dao/his/inpatient/ChargeListDao.java

@@ -3,18 +3,37 @@ package thyyxxk.webserver.dao.his.inpatient;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Select;
 import thyyxxk.webserver.entity.inpatient.chargelist.BriefPatInfo;
+import thyyxxk.webserver.entity.inpatient.chargelist.ChargeItem;
+import thyyxxk.webserver.entity.inpatient.chargelist.PatOverview;
 
 import java.util.List;
 
 @Mapper
 public interface ChargeListDao {
 
-    @Select("select rtrim(inpatient_no) as patNo,admiss_times as times, " +
+    @Select("select rtrim(inpatient_no) as patNo,admiss_times as times,total_charge, " +
             "rtrim(name) as name, admiss_date as admdate,dis_date as disdate " +
             "from zy_inactpatient where inpatient_no=#{patNo} " +
             "union " +
-            "select rtrim(inpatient_no) as patNo,admiss_times as times, " +
+            "select rtrim(inpatient_no) as patNo,admiss_times as times,total_charge, " +
             "rtrim(name) as name, admiss_date as admdate,dis_date as disdate " +
             "from zy_actpatient where inpatient_no=#{patNo}")
-    List<BriefPatInfo> selectBriefPatInfo(String patNo);
+    List<PatOverview> selectPatOverviews(String patNo);
+
+    @Select("select rtrim(inpatient_no) as patNo,rtrim(name) as name,rtrim(a.bed_no) as bedNo, " +
+            "gender=(case when sex='1' then '男' when sex='2' then '女' else '未知' end), " +
+            "rtrim(admiss_dept) as dept,admiss_date as admdate,med_type as medtype, " +
+            "admiss_date as begndate,isnull(dis_date,getdate()) as enddate, " +
+            "datediff(day,admiss_date,isnull(dis_date,getdate())) as days, " +
+            "balance=(select ((select isnull(sum(t.depo_amount),0) from zy_deposit_file t where t.inpatient_no=a.inpatient_no " +
+            "and t.admiss_times=a.admiss_times and t.status in (1,2))- " +
+            "(select isnull(sum(t.charge_fee),0) from zy_detail_charge t where t.inpatient_no=a.inpatient_no " +
+            "and t.admiss_times=a.admiss_times))),a.total_charge as totalCost " +
+            "from ${table} a where a.inpatient_no=#{patNo} and a.admiss_times=#{times}")
+    BriefPatInfo selectBriefPatInfo(String patNo, int times, String table);
+
+    @Select("execute zy_receive_drug #{patNo},#{times},#{patNo},'0';" +
+            "execute zy_receive_one #{patNo},#{times},#{patNo},'0';" +
+            "execute dbo.zy_cxtj_mxqd_new #{patNo},#{times}")
+    List<ChargeItem> selectChargeList(String patNo, int times);
 }

+ 0 - 7
src/main/java/thyyxxk/webserver/dao/his/inpatient/DismissDao.java

@@ -139,13 +139,6 @@ public interface DismissDao {
                                       @Param("compare") String compare,
                                       @Param("timeLimit") Date timeLimit);
 
-    @Update("update zy_ledger_file set deposit=(select isnull(sum(depo_amount),0) from zy_deposit_file f with(nolock) " +
-            "where f.inpatient_no=#{zyh} and f.admiss_times=#{times} and f.ledger_sn=#{ledger} and f.status in (1,2)) " +
-            "where inpatient_no=#{zyh} and admiss_times=#{times} and ledger_sn=#{ledger}")
-    void recountDeposit(@Param("zyh") String zyh,
-                        @Param("times") int times,
-                        @Param("ledger") int ledger);
-
     @Delete("delete zy_ledger_file_yb where inpatient_no=#{patNo} and admiss_times=#{times} and ledger_sn=#{ledgerSn}")
     void deleteZyLedgerFileYb(@Param("patNo") String patNo,
                               @Param("times") Integer times,

+ 9 - 4
src/main/java/thyyxxk/webserver/entity/inpatient/chargelist/BriefPatInfo.java

@@ -4,23 +4,28 @@ import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 import org.springframework.format.annotation.DateTimeFormat;
 
+import java.math.BigDecimal;
 import java.util.Date;
 
 @Data
 public class BriefPatInfo {
+    private String bedNo;
     private String patNo;
-    private Integer times;
     private String name;
+    private String gender;
+    private String dept;
     @DateTimeFormat(pattern = "yyyy-MM-dd")
     @JsonFormat(pattern = "yyyy-MM-dd")
     private Date admdate;
-    @DateTimeFormat(pattern = "yyyy-MM-dd")
-    @JsonFormat(pattern = "yyyy-MM-dd")
-    private Date disdate;
+    private String medtype;
     @DateTimeFormat(pattern = "yyyy-MM-dd")
     @JsonFormat(pattern = "yyyy-MM-dd")
     private Date begndate;
     @DateTimeFormat(pattern = "yyyy-MM-dd")
     @JsonFormat(pattern = "yyyy-MM-dd")
     private Date enddate;
+    private Integer days;
+    private String ledger = "全部";
+    private BigDecimal balance;
+    private BigDecimal totalCost;
 }

+ 35 - 0
src/main/java/thyyxxk/webserver/entity/inpatient/chargelist/ChargeItem.java

@@ -0,0 +1,35 @@
+package thyyxxk.webserver.entity.inpatient.chargelist;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+
+@Data
+public class ChargeItem {
+    private String code;
+    private String name;
+    private String specification;
+    private String unit;
+    private BigDecimal price;
+    private BigDecimal quantity;
+    private BigDecimal cost;
+    private String execDept;
+    private String billItemCode;
+    private String billItemName;
+    private String priceString;
+    private String quantityString;
+    private String costString;
+
+    public String getPriceString() {
+        return price.setScale(2, RoundingMode.HALF_DOWN).toString();
+    }
+
+    public String getQuantityString() {
+        return quantity.setScale(1, RoundingMode.HALF_DOWN).toString();
+    }
+
+    public String getCostString() {
+        return cost.setScale(2, RoundingMode.HALF_DOWN).toString();
+    }
+}

+ 28 - 0
src/main/java/thyyxxk/webserver/entity/inpatient/chargelist/PatOverview.java

@@ -0,0 +1,28 @@
+package thyyxxk.webserver.entity.inpatient.chargelist;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Data
+public class PatOverview {
+    private String patNo;
+    private Integer times;
+    private BigDecimal totalCharge;
+    private String name;
+    @DateTimeFormat(pattern = "yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private Date admdate;
+    @DateTimeFormat(pattern = "yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private Date disdate;
+    @DateTimeFormat(pattern = "yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private Date begndate;
+    @DateTimeFormat(pattern = "yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private Date enddate;
+}

+ 57 - 3
src/main/java/thyyxxk/webserver/service/inpatient/ChargeListService.java

@@ -2,21 +2,75 @@ package thyyxxk.webserver.service.inpatient;
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import thyyxxk.webserver.constants.sidicts.MedType;
 import thyyxxk.webserver.dao.his.inpatient.ChargeListDao;
 import thyyxxk.webserver.entity.inpatient.chargelist.BriefPatInfo;
+import thyyxxk.webserver.entity.inpatient.chargelist.ChargeItem;
+import thyyxxk.webserver.entity.inpatient.chargelist.PatOverview;
+import thyyxxk.webserver.service.redislike.RedisLikeService;
 
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 @Service
 public class ChargeListService {
     private final ChargeListDao dao;
+    private final RedisLikeService redis;
 
     @Autowired
-    public ChargeListService(ChargeListDao dao) {
+    public ChargeListService(ChargeListDao dao, RedisLikeService redis) {
         this.dao = dao;
+        this.redis = redis;
     }
 
-    public List<BriefPatInfo> selectBriefPatInfo(String patNo) {
-        return dao.selectBriefPatInfo(patNo);
+    public List<PatOverview> selectPatOverviews(String patNo) {
+        return dao.selectPatOverviews(patNo);
+    }
+
+    public BriefPatInfo selectBriefPatInfo(PatOverview overview) {
+        BriefPatInfo briefPatInfo = dao.selectBriefPatInfo(overview.getPatNo(), overview.getTimes(), "zy_actpatient");
+        if (null == briefPatInfo) {
+            briefPatInfo = dao.selectBriefPatInfo(overview.getPatNo(), overview.getTimes(), "zy_inactpatient");
+        }
+        if (null != briefPatInfo) {
+            briefPatInfo.setMedtype(MedType.getName(briefPatInfo.getMedtype()));
+            briefPatInfo.setDept(redis.getDeptName(briefPatInfo.getDept()));
+            if (briefPatInfo.getDays() < 1) {
+                briefPatInfo.setDays(1);
+            }
+        }
+        return briefPatInfo;
+    }
+
+    public Map<String, Object> selectChargeList(PatOverview overview) {
+        List<ChargeItem> chargeList = dao.selectChargeList(overview.getPatNo(), overview.getTimes());
+        Map<String, List<ChargeItem>> chargeListMap = new HashMap<>();
+        Map<String, BigDecimal> sumsTempMap = new HashMap<>();
+        sumsTempMap.put("总计", BigDecimal.ZERO);
+        for (ChargeItem chargeItem : chargeList) {
+            String mapKey = chargeItem.getBillItemName();
+            sumsTempMap.replace("总计", sumsTempMap.get("总计").add(chargeItem.getCost()));
+            if (chargeListMap.containsKey(mapKey)) {
+                chargeListMap.get(mapKey).add(chargeItem);
+                sumsTempMap.replace(mapKey, sumsTempMap.get(mapKey).add(chargeItem.getCost()));
+            } else {
+                List<ChargeItem> tempList = new ArrayList<>();
+                tempList.add(chargeItem);
+                chargeListMap.put(mapKey, tempList);
+                sumsTempMap.put(mapKey, chargeItem.getCost());
+            }
+        }
+        Map<String, String> sumsMap = new HashMap<>();
+        for (Map.Entry<String, BigDecimal> entry : sumsTempMap.entrySet()) {
+            sumsMap.put(entry.getKey(), entry.getValue().setScale(2, RoundingMode.HALF_DOWN).toString());
+        }
+        Map<String, Object> resultMap = new HashMap<>();
+        resultMap.put("chargeList", chargeListMap);
+        resultMap.put("sumsMap", sumsMap);
+        return resultMap;
     }
 }