Browse Source

Merge branch 'dev-1.1.1' of https://172.16.32.165/hurugang/thmz_system into dev-1.1.1

hurugang 3 years ago
parent
commit
ce0236e334

+ 1 - 1
src/main/java/cn/hnthyy/thmz/controller/yf/YfWardPrescriptionController.java

@@ -373,7 +373,7 @@ public class YfWardPrescriptionController {
             String pageNos = yfWardPrescriptionService.queryYzYpPageNoStr(groupNo, wardCode, pageClass);
             resultMap.put("code", 0);
             resultMap.put("message", "查询病房近期(三天)请领单药品汇总信息成功");
-            resultMap.put("data", yfWardVos);
+            resultMap.put("data", yfWardVos.stream().sorted(Comparator.comparing(YfWardVo::getLocation)).collect(Collectors.toList()));
             resultMap.put("pageNos", pageNos);
             return resultMap;
         } catch (Exception e) {

+ 2 - 2
src/main/java/cn/hnthyy/thmz/entity/his/zy/ZyDetailCharge.java

@@ -1,9 +1,8 @@
 package cn.hnthyy.thmz.entity.his.zy;
 
-import java.io.Serializable;
-
 import lombok.Data;
 
+import java.io.Serializable;
 import java.util.Date;
 
 /**
@@ -173,6 +172,7 @@ public class ZyDetailCharge implements Serializable {
 
     /**
      * trans_flag_yb
+     * 上传费用标志
      */
     private String transFlagYb;
 

+ 1 - 1
src/main/java/cn/hnthyy/thmz/mapper/his/yp/YpZdDictMapper.java

@@ -13,7 +13,7 @@ public interface YpZdDictMapper {
      * @param code
      * @return
      */
-    @Select("select code,name,specification,mz_restrict,bill_item_mz,pack_retprice,country_flag,supply_type,pack_unit,weight,volum,weigh_unit,vol_unit,pack_size,manu_code,frequency,serial,drug_flag,mini_unit,ps_flag,retprice,fix_price,buy_price,isnull(byj_flag,0) byj_flag,national_code from yp_zd_dict WITH(NOLOCK) where code = #{code,jdbcType=VARCHAR} and serial = #{serial}")
+    @Select("select code,name,specification,mz_restrict,bill_item_mz,bill_item_zy,pack_retprice,country_flag,supply_type,pack_unit,weight,volum,weigh_unit,vol_unit,pack_size,manu_code,frequency,serial,drug_flag,mini_unit,ps_flag,retprice,fix_price,buy_price,isnull(byj_flag,0) byj_flag,national_code from yp_zd_dict WITH(NOLOCK) where code = #{code,jdbcType=VARCHAR} and serial = #{serial}")
     YpZdDict selectYpZdDictByCodeAndSerial(@Param("code") String code,@Param("serial") String serial);
 
     /**

+ 1 - 1
src/main/java/cn/hnthyy/thmz/mapper/his/yz/YzActOrderMapper.java

@@ -141,6 +141,6 @@ public interface YzActOrderMapper {
             "drug_weight =isnull(drug_weight,0)," +
             "drug_weight_unit =isnull(drug_weight_unit,'')," +
             "drug_vol_unit =isnull(drug_vol_unit,'')," +
-            "drug_volume =isnull(drug_volume,0),mini_unit,start_time,order_name,performance_time from yz_act_order WITH(NOLOCK) where act_order_no=#{actOrderNo}")
+            "drug_volume =isnull(drug_volume,0),mini_unit,start_time,order_name,performance_time,exec_unit,yb_self_flag,consult_physician from yz_act_order WITH(NOLOCK) where act_order_no=#{actOrderNo}")
     YzActOrder selectYzActOrderByActOrderNo(@Param("actOrderNo") double actOrderNo);
 }

+ 53 - 0
src/main/java/cn/hnthyy/thmz/mapper/his/zy/ZyDetailChargeMapper.java

@@ -111,4 +111,57 @@ public interface ZyDetailChargeMapper {
      */
     @Update("update zy_detail_charge SET charge_status ='2' WHERE inpatient_no =#{inpatientNo} AND admiss_times =#{admissTimes} AND ledger_sn =#{ledgerSn} AND charge_status ='3'  ")
     int updateZyDetailChargeForCanCel(@Param("inpatientNo") String inpatientNo, @Param("admissTimes") Integer admissTimes, @Param("ledgerSn") Integer ledgerSn);
+
+    /**
+     * 获取当次住院最大流水号
+     * @param inpatientNo
+     * @param admissTimes
+     * @return
+     */
+    @Select("select isnull(max(detail_sn),0) from zy_detail_charge WHERE inpatient_no =#{inpatientNo} AND admiss_times =#{admissTimes}  ")
+    int selectMaxDetailSn(@Param("inpatientNo") String inpatientNo, @Param("admissTimes") Integer admissTimes);
+
+    /**
+     * 批量保存住院费用记录
+     * @param zyDetailCharges
+     * @return
+     */
+    @Insert({"<script>" +
+            "INSERT INTO zy_detail_charge ( inpatient_no , admiss_times , ledger_sn , detail_sn , charge_date , op_id_code , charge_code , infant_flag , charge_status ," +
+            " retprice, charge_amount,charge_fee , self_flag , separate_flag , suppress_flag , ward_code , dept_code , order_no , ope_flag , exec_unit , gen_time, charge_code_mx , serial ," +
+            " doctor_code , yb_self_flag ,refer_physician,consult_physician) " +
+            " VALUES " +
+            "<foreach collection='list' item='item' index='index' separator=',' >" +
+            "  (#{item.inpatientNo},#{item.admissTimes},#{item.ledgerSn},#{item.detailSn},#{item.chargeDate},#{item.opIdCode},#{item.chargeCode},#{item.infantFlag},#{item.chargeStatus}," +
+            "   #{item.retprice},#{item.chargeAmount},#{item.chargeFee},#{item.selfFlag},#{item.separateFlag},#{item.suppressFlag},#{item.wardCode},#{item.deptCode},#{item.orderNo},#{item.opeFlag},#{item.execUnit},#{item.genTime},#{item.chargeCodeMx},#{item.serial}," +
+            "   #{item.doctorCode},#{item.ybSelfFlag},#{item.referPhysician},#{item.consultPhysician})" +
+            "</foreach>" +
+            "</script>"})
+    int insertZyDetailCharges(List<ZyDetailCharge> zyDetailCharges);
+
+    /**
+     * 费用查询
+     *
+     * @return
+     */
+    @Select({"<script>",
+            "select rtrim(inpatient_no), admiss_times, ledger_sn, detail_sn, charge_date, op_id_code, charge_code, infant_flag, charge_status, retprice, charge_amount, " ,
+                    "charge_fee, self_flag, separate_flag, suppress_flag, ward_code, dept_code, order_no, ope_flag, exec_unit, gen_time, pay_percent, zj_flag, zfl, " ,
+                    "charge_code_mx, serial, zy_serial_no, doctor_code, yb_self_flag, orig_charge_fee, confirm_id, trans_flag_yb, ss_code, gs_flag, refer_physician, " ,
+                    "consult_physician, ori_detail_sn from zy_detail_charge " ,
+            " where 1=1",
+            "<when test='inpatientNo!=null'>",
+            " and inpatient_no = #{inpatientNo}",
+            "</when>",
+            "<when test='admissTimes!=null'>",
+            " and admiss_times = #{admissTimes}",
+            "</when>",
+            "<when test='chargeCodeMx!=null'>",
+            " and charge_code_mx = #{chargeCodeMx}",
+            "</when>",
+            "<when test='chargeDate!=null'>",
+            " and charge_date = #{chargeDate}",
+            "</when>",
+            "</script>"})
+    List<ZyDetailCharge> selectZyDetailChargeList(ZyDetailCharge zyDetailCharge);
 }

+ 12 - 1
src/main/java/cn/hnthyy/thmz/mapper/his/zy/ZyDrugMapper.java

@@ -55,7 +55,8 @@ public interface ZyDrugMapper {
             "       zy_serial_no =a.zy_serial_no, " +
             "       group_no=a.group_no, " +
             "       ledger_sn=a.ledger_sn, " +
-            "       detail_sn=a.detail_sn " +
+            "       detail_sn=a.detail_sn," +
+            "       exec_unit=a.exec_unit " +
             " FROM zy_drug a WITH(NOLOCK)" +
             " where a.page_no =#{pageNo} " +
             "<when test='submitFlag!=null'>"+
@@ -100,4 +101,14 @@ public interface ZyDrugMapper {
                     " and confirm_flag in (1,2)",
             "</script>"})
     int selectIsInitFlag(@Param("pageNo") String pageNo);
+
+    /**
+     * 查询请领单执行科室
+     * @param pageNo
+     * @return
+     */
+    @Select({"<script>"+
+            "select exec_unit from zy_drug where page_no =#{pageNo} group by exec_unit" +
+            "</script>"})
+    String selectExecUnitPageNo(@Param("pageNo") String pageNo);
 }

+ 81 - 7
src/main/java/cn/hnthyy/thmz/service/impl/his/yf/YfWardPrescriptionServiceImpl.java

@@ -1,5 +1,6 @@
 package cn.hnthyy.thmz.service.impl.his.yf;
 
+import cn.hnthyy.thmz.common.Constants;
 import cn.hnthyy.thmz.entity.MzException;
 import cn.hnthyy.thmz.entity.his.YzActOrder;
 import cn.hnthyy.thmz.entity.his.mz.Employee;
@@ -22,7 +23,9 @@ import cn.hnthyy.thmz.mapper.his.zy.*;
 import cn.hnthyy.thmz.service.his.yf.YfWardPrescriptionService;
 import cn.hnthyy.thmz.vo.YfWardVo;
 import cn.hnthyy.thmz.vo.YzYpPageNoVo;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
+import org.json.JSONObject;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -39,6 +42,7 @@ import java.util.stream.Collectors;
 /**
  * 病房医嘱药品请领单
  */
+@Slf4j
 @Service
 public class YfWardPrescriptionServiceImpl implements YfWardPrescriptionService {
 
@@ -87,10 +91,12 @@ public class YfWardPrescriptionServiceImpl implements YfWardPrescriptionService
     @SuppressWarnings("all")
     @Autowired
     private PrescriptionMapper prescriptionMapper;
-
     @SuppressWarnings("all")
     @Autowired
     private YpZdManufactoryMapper ypZdManufactoryMapper;
+    @SuppressWarnings("all")
+    @Autowired
+    private ZyDetailChargeMapper zyDetailChargeMapper;
 
     @Override
     public List<YzYpPageNoVo> queryYzYpPageNo(YzYpPageNoVo yzYpPageNoVo){
@@ -198,18 +204,18 @@ public class YfWardPrescriptionServiceImpl implements YfWardPrescriptionService
     @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, timeout = 36000, rollbackFor = Exception.class)
     public Map<String, Object> sendWard(List<YzYpZyOrder> yzYpZyOrders,String pageNo,String userCode) throws MzException {
         Map<String, Object> resultMap = new HashMap<>();
-        List<YpZyPatient> ypZyPatients = new ArrayList<>();
         String[] pageNos = pageNo.split("/");
         List<YzYpZyOrder> yyzos;
         int count =0;
         for (int j = 0; j < pageNos.length; j++) {
+            List<YpZyPatient> ypZyPatients = new ArrayList<>();
             String pageNoStr = pageNos[j];
             if(yzYpZyOrders.get(0).getPageClass().equals("A")){//医技药单
                 count = zyDrugMapper.selectDrugCountByPageNo(pageNoStr);
             }else if(!yzYpZyOrders.get(0).getPageClass().equals("T")){
                 count = yzYpZyOrderMapper.selectDrugCountByPageNo(Integer.parseInt(pageNoStr));
             }
-            if(StringUtils.isBlank(yzYpZyOrders.get(0).getName())){
+            if(StringUtils.isBlank(yzYpZyOrders.get(0).getName())){//判断前端传值是否为明细
                 List<YfWardVo> yfWardVos = getDetail(pageNoStr, yzYpZyOrders.get(0).getPageClass(), "1,3,4");
                 List<YzYpZyOrder> yyzo = new ArrayList<>();
                 Set<String> chargeCodes = yzYpZyOrders.parallelStream().map(YzYpZyOrder::getChargeCode).distinct().collect(Collectors.toSet());
@@ -242,7 +248,7 @@ public class YfWardPrescriptionServiceImpl implements YfWardPrescriptionService
                 }
                 ypZyPatient.setOrderDate(yzYpZyOrder.getOccTime());
                 ypZyPatient.setSectionCode("");
-                ypZyPatient.setAcctSign(yzYpZyOrder.getAmount()>=0?"2":"0");
+                ypZyPatient.setAcctSign(yzYpZyOrder.getAmount()==0?"2":"0");
                 ypZyPatient.setOutSeri(i+1);
                 ypZyPatient.setKeeper(userCode);
                 ypZyPatient.setTotalFlag("");
@@ -285,10 +291,30 @@ public class YfWardPrescriptionServiceImpl implements YfWardPrescriptionService
                     supplyCode = "w";
                 }
                 ypZyPatient.setSupplyCode(supplyCode);
-                ypZyPatients.add(ypZyPatient);
-                if(yzYpZyOrder.getPageClass().equals("4") || yzYpZyOrder.getPageClass().equals("3")){//基数药和大输液
+                if(yzYpZyOrder.getPageClass().equals("4") || yzYpZyOrder.getPageClass().equals("3")){//基数药、大输液
                     ypZyPatientMapper.updateYpZyPatient(ypZyPatient);
                 }else{
+                    if(yzYpZyOrder.getPageClass().equals("A")){//医技
+                        ZyDetailCharge zyDetailCharge = new ZyDetailCharge();
+                        zyDetailCharge.setInpatientNo(ypZyPatient.getInpatientNo());
+                        zyDetailCharge.setAdmissTimes(ypZyPatient.getAdmissTimes());
+                        zyDetailCharge.setChargeCodeMx(ypZyPatient.getChargeCode());
+                        zyDetailCharge.setChargeDate(ypZyPatient.getOrderDate());
+                        List<ZyDetailCharge> zyDetailCharges = zyDetailChargeMapper.selectZyDetailChargeList(zyDetailCharge);
+                        String zySerialNo = "";
+                        if(zyDetailCharges.size() >0){
+                            zySerialNo = zyDetailCharges.get(0).getZySerialNo();
+                        }else{
+                            log.info("未查询到该病人的住院流水号[{}]", JSONObject.valueToString(zyDetailCharge));
+                        }
+                        ypZyPatient.setZySerialNo(zySerialNo);
+                        String execUnit = zyDrugMapper.selectExecUnitPageNo(pageNoStr);
+                        ypZyPatient.setSectionCode(execUnit);
+                    }else{
+                        if(ypZyPatient.getAmount() != 0){
+                            ypZyPatients.add(ypZyPatient);
+                        }
+                    }
                     ypZyPatientMapper.insertYpZyPatient(ypZyPatient);
                 }
                 if(ypZyPatient.getAmount() != 0){
@@ -296,6 +322,7 @@ public class YfWardPrescriptionServiceImpl implements YfWardPrescriptionService
                             ,ypZyPatient.getGroupNo(), -ypZyPatient.getAmount(), BigDecimal.valueOf(-ypZyPatient.getAmount() * ypZyPatient.getRetprice()))){
                         throw new MzException("保存住院病人发药记录失败,更新库存异常");
                     }
+
                 }
                 if(yzYpZyOrder.getPageClass().equals("A")){//医技药单
                     if(0 == zyDrugMapper.updateZyDrugConfirm(ypZyPatient.getAmount()==0?"2":"1",userCode,ypZyPatient.getAmount()==0?"2":"1",yzYpZyOrder.getInpatientNo(),yzYpZyOrder.getAdmissTimes(),yzYpZyOrder.getLedgerSn(),yzYpZyOrder.getDetailSn())){
@@ -313,6 +340,9 @@ public class YfWardPrescriptionServiceImpl implements YfWardPrescriptionService
                     }
                 }
             }
+            /*if(ypZyPatients.size() > 0){
+                saveZyDetailCharge(ypZyPatients);
+            }*/
             if (yzYpZyOrders.get(0).getPageClass().equals("5") || yzYpZyOrders.get(0).getPageClass().equals("6")){
                 savePrescription(ypZyPatients);
             }
@@ -326,7 +356,51 @@ public class YfWardPrescriptionServiceImpl implements YfWardPrescriptionService
     }
 
     /**
-     * 发药记录插入摆药机中间表
+     * 确认发药费用上账
+     * @param ypZyPatients
+     */
+    public void saveZyDetailCharge(List<YpZyPatient> ypZyPatients){
+        List<ZyDetailCharge> zyDetailCharges = new ArrayList<>();
+        int maxDetailSn = zyDetailChargeMapper.selectMaxDetailSn(ypZyPatients.get(0).getInpatientNo(), ypZyPatients.get(0).getAdmissTimes());
+        for (YpZyPatient ypZyPatient : ypZyPatients) {
+            ZyDetailCharge zyDetailCharge = new ZyDetailCharge();
+            zyDetailCharge.setInpatientNo(ypZyPatient.getInpatientNo());
+            zyDetailCharge.setAdmissTimes(ypZyPatient.getAdmissTimes());
+            zyDetailCharge.setLedgerSn(1);
+            maxDetailSn += 1;
+            zyDetailCharge.setDetailSn(maxDetailSn);
+            zyDetailCharge.setChargeDate(ypZyPatient.getOrderDate());
+            zyDetailCharge.setOpIdCode(ypZyPatient.getDrawer());
+            YpZdDict ypZdDict = ypZdDictMapper.selectYpZdDictByCodeAndSerial(ypZyPatient.getChargeCode(),ypZyPatient.getSerial());
+            zyDetailCharge.setChargeCode(Constants.BILL_ITEM_CODE_prev + ypZdDict.getBillItemZy().substring(1));
+            zyDetailCharge.setInfantFlag(ypZyPatient.getInpatientNo().indexOf("$")==-1?"0":"1");
+            zyDetailCharge.setChargeStatus("2");
+            zyDetailCharge.setChargeAmount(ypZyPatient.getAmount()+"");
+            zyDetailCharge.setChargeFee((ypZyPatient.getAmount()*ypZyPatient.getRetprice())+"");
+            zyDetailCharge.setSelfFlag(ypZdDict.getSelfFlag()==null?"0":ypZdDict.getSelfFlag());
+            zyDetailCharge.setSeparateFlag(ypZdDict.getSeparateFlag()==null?"0":ypZdDict.getSeparateFlag());
+            zyDetailCharge.setSuppressFlag(ypZdDict.getSupriceFlag()==null?"0":ypZdDict.getSupriceFlag());
+            YzActOrder yzActOrder = yzActOrderMapper.selectYzActOrderByActOrderNo(ypZyPatient.getActOrderNo());
+            ZyActpatient zyActpatient = zyActpatientMapper.selectByInpatientNo("zy_actpatient", ypZyPatient.getInpatientNo(), ypZyPatient.getAdmissTimes());
+            zyDetailCharge.setWardCode(zyActpatient.getZkWard());
+            zyDetailCharge.setDeptCode(ypZyPatient.getDeptCode());
+            zyDetailCharge.setOrderNo((float) ypZyPatient.getActOrderNo());
+            zyDetailCharge.setOpeFlag("0");
+            zyDetailCharge.setExecUnit(yzActOrder.getExecUnit());
+            zyDetailCharge.setGenTime(new Date());
+            zyDetailCharge.setChargeCodeMx(ypZyPatient.getChargeCode());
+            zyDetailCharge.setSerial(ypZyPatient.getSerial());
+            zyDetailCharge.setDoctorCode(ypZyPatient.getDoctorName());
+            zyDetailCharge.setYbSelfFlag(yzActOrder.getYbSelfFlag());
+            zyDetailCharge.setReferPhysician(ypZyPatient.getDoctorName());
+            zyDetailCharge.setConsultPhysician(yzActOrder.getConsultPhysician());
+            zyDetailCharges.add(zyDetailCharge);
+        }
+        zyDetailChargeMapper.insertZyDetailCharges(zyDetailCharges);
+    }
+
+    /**
+     * 确认发药插入摆药机中间表
      * @param ypZyPatients
      * @return
      */

+ 7 - 7
src/main/resources/static/js/yf/ward_prescription.js

@@ -36,7 +36,6 @@ $(function () {
     $('#btn_clean').click(function () {
         cleanParams();
     });
-
     $("#btn_query").click(function (t) {
         $("#initButton").find("button").each(function (index, element) {
             if ($(element).hasClass("btn-primary")) {
@@ -671,7 +670,6 @@ function queryParams(params) {
  * 清空查询条件
  */
 function cleanParams() {
-    //$('#reportrange span').html(moment().subtract(10, 'days').format('YYYY-MM-DD') + ' - ' + moment().format('YYYY-MM-DD'));
     $("#pageNoSearch").val(null);
     $("#pageClassSearch").val(null);
     $("#wardCode").selectpicker('val','');
@@ -835,15 +833,19 @@ function printDetail(datas,kfFlag,flag) {
  *
  */
 function printDetailHtml(datas,flag) {
-    console.log(datas);
     let html = '';
     let totalMoney = 0;
     let oldInpatientNo = '';//记录上一个病人
     let title = '病房明细领药单('+$("#pageClassSearch").find("option:selected").text()+')';
     if(pageClass == '5'){
-        title = '长期口服领药单'
+        title = '长期口服领药单';
+        $(".wardName").text(datas[0].wardName);
     }else if(pageClass == '6'){
-        title = '临时口服领药单'
+        title = '临时口服领药单';
+        $(".wardName").text(datas[0].wardName);
+    }else{
+        let w_code = $("#wardCode").find("option:selected").text();
+        $(".wardName").text(w_code.substring(0,w_code.lastIndexOf("(")));
     }
     if(flag == 1 && datas[0].byjFlag == 1){
         title += '(摆药机)'
@@ -852,8 +854,6 @@ function printDetailHtml(datas,flag) {
     }
     $(".title").text(title);
     $(".groupName").text(groupNo==71?'门诊西药房':'住院药房');
-    let w_code = $("#wardCode").find("option:selected").text();
-    $(".wardName").text(w_code.substring(0,w_code.lastIndexOf("(")));
     $(".pageNo").text(pageNo);
     $(".printDate").html(format(new Date(),"yyyy-MM-dd HH:mm"));
     $('.sjh').remove();