Browse Source

血糖优化以及退药单有退药理由

xiaochan 2 years ago
parent
commit
48a9cb18f7

+ 7 - 5
src/main/java/thyyxxk/webserver/controller/inpatient/XiangMuLuRuController.java

@@ -1,5 +1,6 @@
 package thyyxxk.webserver.controller.inpatient;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -169,10 +170,11 @@ public class XiangMuLuRuController {
     }
 
     @GetMapping("/generateMedicationList")
-    public ResultVo<Integer> generateMedicationList(@RequestParam("startDate") String startDate,
-                                                   @RequestParam("endDate") String endDate,
-                                                   @RequestParam("groupNo") String groupNo) {
-        return service.generateMedicationList(startDate, endDate, groupNo);
+    public ResultVo<JSONObject> generateMedicationList(@RequestParam("startDate") String startDate,
+                                                       @RequestParam("endDate") String endDate,
+                                                       @RequestParam("groupNo") String groupNo,
+                                                       @RequestParam("refundReason") Integer refundReason) {
+        return service.generateMedicationList(startDate, endDate, groupNo, refundReason);
     }
 
     @GetMapping("/getPrescription")
@@ -183,7 +185,7 @@ public class XiangMuLuRuController {
 
 
     @GetMapping("/getAPrescriptionByPageNo")
-    public ResultVo<List<DrugReturnForm>> getAPrescriptionByPageNo(@RequestParam("pageNo") Integer pageNo) {
+    public ResultVo<JSONObject> getAPrescriptionByPageNo(@RequestParam("pageNo") Integer pageNo) {
         return service.getAPrescriptionByPageNo(pageNo);
     }
 

+ 2 - 1
src/main/java/thyyxxk/webserver/dao/his/examinations/BloodSugarQueryDao.java

@@ -40,7 +40,8 @@ public interface BloodSugarQueryDao {
             "       rtrim(result_unit) result_unit " +
             "from data_blood_glouse " +
             "where inpatient_no = #{patNo}" +
-            " and admiss_times = #{times}")
+            " and admiss_times = #{times}" +
+            " order by test_time ")
     List<BgNursingTestSync> getPatientLoodSugar(@Param("patNo") String patNo,
                                                 @Param("times") Integer times);
 

+ 8 - 4
src/main/java/thyyxxk/webserver/dao/his/inpatient/XiangMuLuRuDao.java

@@ -235,12 +235,13 @@ public interface XiangMuLuRuDao extends BaseMapper<ZyDetailCharge> {
      * 退药汇总单
      */
     @Insert("insert into yz_yp_page_no (page_no, dept_code, ward_code, submit_time, submit_name, " +
-            "                           submit_flag, page_class, page_name, group_no) " +
-            "values (#{pageNo}, #{wardCode}, #{wardCode}, getdate(), #{userCode}, 1, 'HT', '护士退药单', #{groupNo})")
+            "                           submit_flag, page_class, page_name, group_no,refund_reason) " +
+            "values (#{pageNo}, #{wardCode}, #{wardCode}, getdate(), #{userCode}, 1, 'HT', '护士退药单', #{groupNo},#{refundReason})")
     void drugReturnForm(@Param("pageNo") Integer pageNo,
                         @Param("wardCode") String wardCode,
                         @Param("userCode") String userCode,
-                        @Param("groupNo") String groupNo);
+                        @Param("groupNo") String groupNo,
+                        @Param("refundReason") Integer refundReason);
 
     @Insert("<script>" +
             "insert into yz_yp_zy_order (inpatient_no, admiss_times, name, bed_no, dept_code, ward_code, charge_code, amount, " +
@@ -250,7 +251,7 @@ public interface XiangMuLuRuDao extends BaseMapper<ZyDetailCharge> {
             "<foreach collection='list' item='item' index='index' separator=','>" +
             "(#{patNo}, #{times}, #{name}, #{bedNo}, #{wardCode},  #{wardCode}, #{item.chargeCodeMx}, #{item.chargeAmount,jdbcType=REAL}, " +
             "       (select pack_retprice from yp_zd_dict where code = #{item.chargeCodeMx} and serial = #{item.serial}), getdate(), #{infantFlag}, #{userCode}, 'a', '1', " +
-            "       #{item.drugClass},  getdate(), #{item.orderNo}, #{item.serial}, #{groupNo}, " +
+            "       #{item.drugClass},  getdate(), ${index}, #{item.serial}, #{groupNo}, " +
             "       #{item.doctorCode}, #{pageNo},#{ledgerSn},#{item.detailSn},0,'HT')" +
             "</foreach>" +
             "</script>")
@@ -951,5 +952,8 @@ public interface XiangMuLuRuDao extends BaseMapper<ZyDetailCharge> {
     List<DrugReturnForm> getAPrescriptionByPageNo(Integer pageNo);
 
 
+    @Select("select refund_reason from yz_yp_page_no where page_no = #{pageNo}")
+    Integer selectRefundReasonByPageNo(Integer pageNo);
+
 
 }

+ 18 - 11
src/main/java/thyyxxk/webserver/service/examinations/BloodSugarQueryServer.java

@@ -53,18 +53,25 @@ public class BloodSugarQueryServer {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有查询到该患者的血糖信息。");
         }
         AtomicInteger count = new AtomicInteger();
+        Map<String, List<BgNursingTestSync>> map = new TreeMap<>();
 
-        Map<String, List<BgNursingTestSync>> map = list.stream().collect(
-                Collectors.groupingBy(item -> {
-                    if (!NAME_LIST.contains(item.getTimecodeName())) {
-                        item.setTimecodeName("随机血糖");
-                    }
-                    if (!StringUtil.isChinese(item.getTestResult())) {
-                        count.incrementAndGet();
-                    }
-                    return DateUtil.formatDatetime(item.getTestTime(), DateUtil.DATE);
-                })
-        );
+        list.forEach(item -> {
+            if (!NAME_LIST.contains(item.getTimecodeName())) {
+                item.setTimecodeName("随机血糖");
+            }
+            if (!StringUtil.isChinese(item.getTestResult())) {
+                count.incrementAndGet();
+            }
+            String key = DateUtil.formatDatetime(item.getTestTime(), DateUtil.DATE);
+
+            if (map.containsKey(key)) {
+                map.get(key).add(item);
+            } else {
+                List<BgNursingTestSync> temp = new ArrayList<>();
+                temp.add(item);
+                map.put(key, temp);
+            }
+        });
 
         List<PackagedBloodGlucoseData> data = new ArrayList<>();
 

+ 29 - 10
src/main/java/thyyxxk/webserver/service/inpatient/XiangMuLuRuService.java

@@ -33,6 +33,8 @@ import thyyxxk.webserver.utils.*;
 import javax.servlet.http.HttpServletResponse;
 import java.math.BigDecimal;
 import java.util.*;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.function.Consumer;
 import java.util.stream.Collectors;
 
 /**
@@ -884,20 +886,24 @@ public class XiangMuLuRuService {
 
     public ResultVo<List<DrugReturnForm>> getNoMedicineReturnOrderGenerated(String startDate, String endDate, String groupNo) {
         UserInfo us = redisLikeService.getUserInfoByToken();
-        return ResultVoUtil.success(groupingValues(dao.selectNoMedicineReturnOrderGenerated(startDate, endDate, us.getDeptCode(), groupNo)));
+        return ResultVoUtil.success(groupingValues(dao.selectNoMedicineReturnOrderGenerated(startDate, endDate, us.getDeptCode(), groupNo), null));
     }
 
-    public List<DrugReturnForm> groupingValues(List<DrugReturnForm> list) {
+    public List<DrugReturnForm> groupingValues(List<DrugReturnForm> list, Consumer<DrugReturnForm> consumer) {
         if (ListUtil.isBlank(list)) {
             return list;
         }
         Map<String, DrugReturnForm> map = new HashMap<>(list.size());
         list.forEach(item -> {
+            if (consumer != null) {
+                consumer.accept(item);
+            }
             if (map.containsKey(item.getChargeCode())) {
                 DrugReturnForm temp = map.get(item.getChargeCode());
                 temp.setAmount(temp.getAmount().add(item.getAmount()));
-                temp.setRetprice(temp.getRetprice().add(item.getRetprice()));
+                temp.setRetprice(temp.getRetprice().add(item.getRetprice().multiply(item.getAmount().abs())));
             } else {
+                item.setRetprice(item.getRetprice().multiply(item.getAmount().abs()));
                 map.put(item.getChargeCode(), item);
             }
         });
@@ -912,11 +918,11 @@ public class XiangMuLuRuService {
      * @param groupNo   药房
      * @return 返回提示
      */
-    public ResultVo<Integer> generateMedicationList(String startDate, String endDate, String groupNo) {
+    public ResultVo<JSONObject> generateMedicationList(String startDate, String endDate, String groupNo, Integer refundReason) {
         UserInfo us = redisLikeService.getUserInfoByToken();
         Integer pageNo = publicServer.getTheDrugListNo();
-        getThis().generateMedicationListFunc(startDate, endDate, groupNo, pageNo, us.getDeptCode());
-        return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "药单生成成功。", pageNo);
+        getThis().generateMedicationListFunc(startDate, endDate, groupNo, pageNo, us.getDeptCode(), refundReason);
+        return getAPrescriptionByPageNo(pageNo);
     }
 
     /**
@@ -929,12 +935,12 @@ public class XiangMuLuRuService {
      * @param dept      科室
      */
     @Transactional(rollbackFor = Exception.class)
-    public void generateMedicationListFunc(String startDate, String endDate, String groupNo, Integer pageNo, String dept) {
+    public void generateMedicationListFunc(String startDate, String endDate, String groupNo, Integer pageNo, String dept, Integer refundReason) {
         int count = dao.generateMedicationList(startDate, endDate, dept, groupNo, pageNo);
         if (count == 0) {
             throw new BizException(ExceptionEnum.LOGICAL_ERROR, "取数为空无法生成药单。");
         }
-        dao.drugReturnForm(pageNo, dept, TokenUtil.getTokenUserId(), groupNo);
+        dao.drugReturnForm(pageNo, dept, TokenUtil.getTokenUserId(), groupNo, refundReason);
         log.info("退药药单生成成功操作人:{},药单号:{}", TokenUtil.getTokenUserId(), pageNo);
     }
 
@@ -956,8 +962,21 @@ public class XiangMuLuRuService {
      * @param pageNo
      * @return
      */
-    public ResultVo<List<DrugReturnForm>> getAPrescriptionByPageNo(Integer pageNo) {
-        return ResultVoUtil.success(groupingValues(dao.getAPrescriptionByPageNo(pageNo)));
+    public ResultVo<JSONObject> getAPrescriptionByPageNo(Integer pageNo) {
+        JSONObject js = new JSONObject();
+        // 总金额
+        AtomicReference<BigDecimal> totalFee = new AtomicReference<>(new BigDecimal("0"));
+        // 计算数据
+        List<DrugReturnForm> list = groupingValues(dao.getAPrescriptionByPageNo(pageNo), (item) -> {
+            BigDecimal amount = item.getAmount().abs();
+            totalFee.set(totalFee.get().add(amount.multiply(item.getRetprice())));
+        });
+
+        js.put("totalFee", totalFee.get().negate());
+        js.put("refundReason", dao.selectRefundReasonByPageNo(pageNo));
+        js.put("data", list);
+        js.put("pageNo", pageNo);
+        return ResultVoUtil.success(js);
     }
 
 }

+ 2 - 4
src/main/java/thyyxxk/webserver/service/zhuyuanyisheng/emr/EmrControlRuleSeverV2.java

@@ -18,7 +18,6 @@ import thyyxxk.webserver.entity.zhuyuanyisheng.emr.ProblemQualityControl;
 import thyyxxk.webserver.entity.zhuyuanyisheng.emrcontrolrule.EmrRuleV2;
 import thyyxxk.webserver.entity.zhuyuanyisheng.emrcontrolrule.FinalQuery;
 import thyyxxk.webserver.entity.zhuyuanyisheng.emrcontrolrule.QualityControlAnalysisOfMedicalRecords;
-import thyyxxk.webserver.entity.zhuyuanyisheng.yizhuluru.XinZhenYzActOrder;
 import thyyxxk.webserver.service.externalhttp.emr.EmrEditor;
 import thyyxxk.webserver.utils.*;
 import thyyxxk.webserver.websocket.WebSocketServer;
@@ -26,7 +25,6 @@ import thyyxxk.webserver.websocket.WebSocketServer;
 import javax.websocket.Session;
 import java.util.*;
 import java.util.concurrent.ConcurrentHashMap;
-import java.util.function.Consumer;
 import java.util.stream.Collectors;
 
 @Service
@@ -190,7 +188,7 @@ public class EmrControlRuleSeverV2 {
             Date b;
             Map<String, String> errorMap = new HashMap<>();
             errorMap.put("start", DateUtil.formatDatetime(a));
-            Date c = DateUtil.addDateMinut(a, ruleV2.getPrescription());
+            Date c = DateUtil.addDateHour(a, ruleV2.getPrescription());
             errorMap.put("gfsj", DateUtil.formatDatetime(c));
             try {
                 b = executionSource.get(i);
@@ -294,7 +292,7 @@ public class EmrControlRuleSeverV2 {
 
         if (end == null) {
             // 规范时间
-            Date normalizeTime = DateUtil.addDateMinut(start, ruleV2.getPrescription());
+            Date normalizeTime = DateUtil.addDateHour(start, ruleV2.getPrescription());
             errMap.put("gfsj", DateUtil.formatDatetime(normalizeTime));
             Date newDate = new Date();
             // 如果当前的时间大于了规范的时间,那么就要判断超时了多久

+ 0 - 46
src/main/java/thyyxxk/webserver/utils/CacheOnce.java

@@ -44,50 +44,4 @@ public class CacheOnce<V> {
         }
     }
 
-    public <T> T getObject(String name, Function<String, Object> filter, Class<T> tClass) {
-        Objects.requireNonNull(filter);
-
-        if (map.containsKey(name)) {
-            String oldOb = JSON.toJSONString(map.get(name));
-            return JSON.parseObject(oldOb, tClass);
-        }
-
-        if (notQueried.contains(name)) {
-            return null;
-        }
-
-        Object object = filter.apply(name);
-        if (object == null) {
-            notQueried.add(name);
-            return null;
-        } else {
-            map.put(name, object);
-            String oldOb = JSON.toJSONString(object);
-            return JSON.parseObject(oldOb, tClass);
-        }
-    }
-
-    public <T> List<T> getList(String name, Function<String, Object> filter, Class<T> tClass) {
-        Objects.requireNonNull(filter);
-
-        if (map.containsKey(name)) {
-            String oldOb = JSON.toJSONString(map.get(name));
-            return JSON.parseArray(oldOb, tClass);
-        }
-
-        if (notQueried.contains(name)) {
-            return null;
-        }
-
-        Object object = filter.apply(name);
-        if (object == null) {
-            notQueried.add(name);
-            return null;
-        } else {
-            map.put(name, object);
-            String oldOb = JSON.toJSONString(object);
-            return JSON.parseArray(oldOb, tClass);
-        }
-    }
-
 }

+ 2 - 3
src/main/java/thyyxxk/webserver/utils/DateUtil.java

@@ -18,7 +18,6 @@ import java.util.List;
  */
 @Slf4j
 public class DateUtil {
-
     public static final String DEFAULT_PATTERN = "yyyy-MM-dd HH:mm:ss";
     public static final String DATE = "yyyy-MM-dd";
 
@@ -309,7 +308,7 @@ public class DateUtil {
      * @param hour 需要加的时间
      * @return 给当前的时间添加 自定义小时
      */
-    public static String addDateMinut(String day, int hour) {
+    public static String addDateHour(String day, int hour) {
         SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         Date date = null;
         try {
@@ -334,7 +333,7 @@ public class DateUtil {
         return cal.getTime();
     }
 
-    public static Date addDateMinut(Date day, int hour) {
+    public static Date addDateHour(Date day, int hour) {
         if (day == null) {
             return null;
         }

+ 1 - 1
src/main/java/thyyxxk/webserver/utils/EntityStringTrim.java

@@ -82,7 +82,7 @@ public class EntityStringTrim {
                 fieldName.substring(0, 1).toUpperCase() +
                 fieldName.substring(1);
 
-        Method method = null;
+        Method method;
 
         // 当你的编码可能存在警告时,比如安全警告,可以用它来消除
         @SuppressWarnings("rawtypes")