Jelajahi Sumber

优化项目录入

xiaochan 3 tahun lalu
induk
melakukan
ec7314423a

+ 9 - 0
src/main/java/thyyxxk/webserver/controller/yibao/XiangMuLuRuController.java

@@ -92,4 +92,13 @@ public class XiangMuLuRuController {
         return service.shanChuMuBan(patterName, opIdCode);
     }
 
+    @GetMapping("/getPyCode")
+    public ResultVo<ZyDetailCharge> getPyCode(String inputStr) {
+        return service.getPyCode(inputStr);
+    }
+
+    @GetMapping("/getBingQuDuiYingKeShi")
+    public ResultVo<List<GetDropdownBox>> getBingQuDuiYingKeShi(String ward) {
+        return service.getBingQuDuiYingKeShi(ward);
+    }
 }

+ 160 - 20
src/main/java/thyyxxk/webserver/dao/his/yibao/XiangMuLuRuDao.java

@@ -19,6 +19,108 @@ import java.util.List;
 @Mapper
 public interface XiangMuLuRuDao {
 
+
+    @Select("<script>" +
+            "SELECT a.admiss_times,      " +
+            "            a.inpatient_no,      " +
+            "            a.ledger_sn,  " +
+            "            a.detail_sn,  " +
+            "            a.charge_date,  " +
+            "            a.op_id_code,  " +
+            "            d.name op_name,  " +
+            "            a.charge_code,  " +
+            "            a.charge_fee,  " +
+            "            a.charge_status  ,  " +
+            "            bill_item_code= b.bill_item_zy,  " +
+            "            bill_item_name=(select name from zy_bill_item where code = b.bill_item_zy),  " +
+            "            charge_name=b.name,  " +
+            "            spec=b.charge_unit,  " +
+            "            a.charge_code_mx,  " +
+            "            a.serial,  " +
+            "            price=0.0000,  " +
+            "            charge_amount=a.charge_amount,  " +
+            "            exec_dept=(select name from zd_unit_code where code = a.exec_unit),  " +
+            "            dept_code = (select name from zd_unit_code where code = a.ward_code) ,  " +
+            "            self_flag=isnull(a.self_flag,0),  " +
+            "            suppress_flag=a.suppress_flag,  " +
+            "            group_no='00',  " +
+            "            separate_flag=a.separate_flag,  " +
+            "            ope_flag=a.ope_flag,  " +
+            "            drugname=c.name,  " +
+            "            a.ori_detail_sn  " +
+            "FROM zy_detail_charge a  ,zd_charge_item b,yp_zd_dict c , a_employee_mi d  " +
+            "where a.charge_code=b.code and  a.serial=c.serial and a.charge_code like 'BILL%' and  c.code= a.charge_code_mx  and a.ledger_sn &gt; 0  " +
+            "and d.code = a.op_id_code and trans_flag_yb !=2 and inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and a.infant_flag = #{infantFlag} " +
+            "<if test=\"chargeCode != null and chargeCode != '' \">" +
+            "and charge_code_mx = #{chargeCode} " +
+            "</if>" +
+            "<if test=\"startTime != null and startTime!= '' \">" +
+            "and convert(varchar(100),a.charge_date,23) = #{startTime} " +
+            "</if>" +
+            "<if test=\"dept != null and dept != '' \"> " +
+            "and a.exec_unit=#{dept}   " +
+            "</if>" +
+            "</script>")
+    List<ZyDetailCharge> huanZheYaoPinFeiYong(@Param("inpatientNo") String inpatientNo,
+                                              @Param("admissTimes") Integer admissTimes,
+                                              @Param("chargeCode") String chargeCode,
+                                              @Param("infantFlag") int infantFlag,
+                                              @Param("startTime") String startTime,
+                                              @Param("orderNo") BigDecimal orderNo,
+                                              @Param("dept") String dept);
+
+
+    @Select("<script>" +
+            "SELECT a.admiss_times,      " +
+            "       a.inpatient_no,   " +
+            "       a.ledger_sn,   " +
+            "       a.detail_sn,   " +
+            "       a.charge_date,   " +
+            "       a.op_id_code,   " +
+            "       c.name op_name,   " +
+            "       a.charge_code,   " +
+            "       a.charge_fee,   " +
+            "       a.charge_status  ,   " +
+            "       bill_item_code = b.bill_item_zy,   " +
+            "       bill_item_name=(select name from zy_bill_item where code = b.bill_item_zy),   " +
+            "       charge_name=b.name,   " +
+            "       spec=b.charge_unit,   " +
+            "       a.charge_code_mx,   " +
+            "       a.serial,   " +
+            "       price=0.0000,   " +
+            "       charge_amount=a.charge_amount,   " +
+            "       exec_dept=(select name from zd_unit_code where code = a.exec_unit),   " +
+            "       dept_code = (select name from zd_unit_code  where code = a.ward_code) ,   " +
+            "       self_flag=a.self_flag,   " +
+            "       suppress_flag=a.suppress_flag,   " +
+            "       group_no='00',   " +
+            "       separate_flag=a.separate_flag,   " +
+            "       ope_flag=a.ope_flag,   " +
+            "       drugname=b.name,   " +
+            "       a.ori_detail_sn   " +
+            "       FROM zy_detail_charge a  ,zd_charge_item b , a_employee_mi c   " +
+            "       where    a.inpatient_no= #{inpatientNo} and   " +
+            "       a.admiss_times= #{admissTimes} and   " +
+            "       a.infant_flag = #{infantFlag} and c.code = a.op_id_code and trans_flag_yb !=2   " +
+            "       AND a.charge_code not like 'BILL%' and a.ledger_sn &gt; 0  and a.charge_code=b.code " +
+            "<if test=\"chargeCode != null and chargeCode != '' \">" +
+            "and charge_code_mx = #{chargeCode} " +
+            "</if>" +
+            "<if test=\"startTime != null and startTime!= '' \">" +
+            "and convert(varchar(100),a.charge_date,23) = #{startTime} " +
+            "</if>" +
+            "<if test=\"dept != null and dept != '' \"> " +
+            "and a.exec_unit=#{dept}   " +
+            "</if>" +
+            "</script>")
+    List<ZyDetailCharge> huanZheXiangMuFeiYong(@Param("inpatientNo") String inpatientNo,
+                                               @Param("admissTimes") Integer admissTimes,
+                                               @Param("chargeCode") String chargeCode,
+                                               @Param("infantFlag") int infantFlag,
+                                               @Param("startTime") String startTime,
+                                               @Param("orderNo") BigDecimal orderNo,
+                                               @Param("dept") String dept);
+
     /**
      * 获取患者的费用
      *
@@ -48,7 +150,7 @@ public interface XiangMuLuRuDao {
             "       price=0.0000, " +
             "       charge_amount=a.charge_amount, " +
             "       exec_dept=(select name from zd_unit_code where code = a.exec_unit), " +
-            "       dept_code = (select name from zd_unit_code where code = a.dept_code) , " +
+            "       dept_code = (select name from zd_unit_code where code = a.ward_code) , " +
             "       self_flag=isnull(a.self_flag,0), " +
             "       suppress_flag=a.suppress_flag, " +
             "       group_no='00', " +
@@ -82,9 +184,8 @@ public interface XiangMuLuRuDao {
             "</otherwise>" +
             "</choose>" +
             "</if>" +
-
-            "        a.serial=c.serial and " +
-            "        c.code= a.charge_code_mx and a.charge_code like 'BILL%' and " +
+            "        a.serial=c.serial and a.charge_code like 'BILL%' and " +
+            "        c.code= a.charge_code_mx  and a.ledger_sn &gt; 0 and " +
             "        a.infant_flag = #{infantFlag} and d.code = a.op_id_code and trans_flag_yb !=2 " +
             "union " +
             "SELECT a.admiss_times, " +
@@ -106,7 +207,7 @@ public interface XiangMuLuRuDao {
             "       price=0.0000, " +
             "       charge_amount=a.charge_amount, " +
             "       exec_dept=(select name from zd_unit_code where code = a.exec_unit), " +
-            "       ward_code = (select name from zd_unit_code  where code = a.ward_code) , " +
+            "       dept_code = (select name from zd_unit_code  where code = a.ward_code) , " +
             "       self_flag=a.self_flag, " +
             "       suppress_flag=a.suppress_flag, " +
             "       group_no='00', " +
@@ -140,8 +241,8 @@ public interface XiangMuLuRuDao {
             "</otherwise>" +
             "</choose>" +
             "</if>" +
-            "        a.charge_code not like 'BILL%' and " +
-            "        a.infant_flag = #{infantFlag} and c.code = a.op_id_code and trans_flag_yb !=2 ) temp" +
+            "a.infant_flag = #{infantFlag} and c.code = a.op_id_code and trans_flag_yb !=2 AND a.charge_code not like 'BILL%' " +
+            "and a.ledger_sn &gt; 0  ) temp" +
             "</script>")
     List<ZyDetailCharge> getHuanZheFeiYong(@Param("inpatientNo") String inpatientNo,
                                            @Param("admissTimes") Integer admissTimes,
@@ -161,15 +262,14 @@ public interface XiangMuLuRuDao {
      * @param pyCode 拼音编码
      * @return 获取项目的名称和code
      */
-    @Select("select code,name from  zd_charge_item where (py_code like #{pyCode} or code like #{pyCode} or name like #{pyCode})" +
+    @Select("select distinct code,name from  zd_charge_item where (py_code like #{pyCode} or code like #{pyCode} or name like #{pyCode})" +
             "union all " +
-            "select code,name from  yp_zd_dict where (py_code like #{pyCode} or code like #{pyCode} or name like #{pyCode})")
+            "select distinct code,name from  yp_zd_dict where (py_code like #{pyCode} or code like #{pyCode} or name like #{pyCode})")
     List<GetDropdownBox> getChargeCode(String pyCode);
 
     /**
      * @param inpatientNo 住院次数
      * @param admissTimes 住院号
-     * @param ledgerSn    结算次数
      * @param list        需要退费的流水号
      * @return 获取患者的全部详细信息 因为要生成一条一样的数据 只是 费用和数量不一致 以及录入人 和 录入时间
      */
@@ -213,7 +313,7 @@ public interface XiangMuLuRuDao {
             "       refer_physician, " +
             "       consult_physician, " +
             "       ori_detail_sn" +
-            " from zy_detail_charge where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes}  and detail_sn in " +
+            " from zy_detail_charge where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn > 0 and detail_sn in " +
             "<foreach collection='list' item='item' index='index' open='(' close=')' separator=','>" +
             "#{item.detailSn}" +
             "</foreach>" +
@@ -227,7 +327,6 @@ public interface XiangMuLuRuDao {
      *
      * @param inpatientNo 住院号
      * @param admissTimes 住院次数
-     * @param ledgerSn    结算次数
      * @param list        流水号
      * @return 返回 已经退过费用的数据
      */
@@ -340,7 +439,7 @@ public interface XiangMuLuRuDao {
      */
     @Select("SELECT charge_name=RTRIM(b.name),   " +
             "       pattern_name=zy_charge_pattern.pattern_name,   " +
-            "       charge_code=b.code,   " +
+            "       charge_code_mx=b.code,   " +
             "       spec=charge_unit,   " +
             "       group_no='00',   " +
             "       serial='00',   " +
@@ -369,13 +468,12 @@ public interface XiangMuLuRuDao {
             "WHERE ( zy_charge_pattern.pattern_name = #{patternName})    and   " +
             "      zy_charge_pattern.op_id_code=#{opIdCode} and   " +
             "      zy_charge_pattern.charge_code=b.code and   " +
-            "      (isnull(zy_charge_pattern.group_no,'00')='00' or zy_charge_pattern.group_no='') and   " +
             "      (isnull(b.del_flag,'0') <> '1' ) and  " +
             "      zy_charge_pattern.exec_unit*=c.code   " +
             "union all   " +
             "SELECT charge_name=RTRIM(d.name),   " +
             "       pattern_name=zy_charge_pattern.pattern_name,   " +
-            "       charge_code=b.charge_code,   " +
+            "       charge_code_mx=b.charge_code,   " +
             "       spec=d.specification,   " +
             "       group_no=b.group_no,   " +
             "       serial=isnull(b.serial,'01'),   " +
@@ -403,7 +501,6 @@ public interface XiangMuLuRuDao {
             "FROM zy_charge_pattern ,zd_unit_code c,yp_base_yf b,yp_zd_dict d   " +
             "WHERE ( zy_charge_pattern.pattern_name = #{patternName}) and   " +
             "      zy_charge_pattern.op_id_code=#{opIdCode} and   " +
-            "      zy_charge_pattern.group_no='00' and   " +
             "      zy_charge_pattern.group_no=b.group_no and   " +
             "      zy_charge_pattern.charge_code=b.charge_code and   " +
             "      isnull(zy_charge_pattern.serial,'01')=b.serial and   " +
@@ -449,6 +546,37 @@ public interface XiangMuLuRuDao {
             "         (a.py_code like #{pyCode} or a.code like #{pyCode} or a.name like #{pyCode})")
     List<ZyDetailCharge> queryXiangMu(String pyCode);
 
+
+    @Select("SELECT distinct a.code charge_code_mx, " +
+            "                charge_code = (select charge_code from zy_bill_item where a.bill_item_zy = zy_bill_item.code), " +
+            "                a.serial, " +
+            "                RTRIM(a.name) charge_name, " +
+            "                a.pack_size amount, " +
+            "                charge_amount=a.pack_retprice, " +
+            "                spec=a.specification, " +
+            "                a.drug_flag  , " +
+            "                a.fix_price, " +
+            "                c.stock_amount, " +
+            "                self_flag=isnull(a.self_flag,'0'), " +
+            "                suppress_flag=a.suprice_flag, " +
+            "                group_no=c.group_no, " +
+            "                bill_item_code=a.bill_item_zy, " +
+            "                bill_item_name=(select name from zy_bill_item where code = a.bill_item_zy), " +
+            "                ybbz=a.yb_comment_new, " +
+            "                yblx=(select name from yp_zd_yb_type where code=a.yb_flag_new), " +
+            "                xnh=a.xnh_flag " +
+            "FROM yp_zd_dict a ,yp_print_name b  , " +
+            "     yp_base_yf c " +
+            "where " +
+            "(a.py_code like #{pyCode} or a.name like #{pyCode} or a.code like #{pyCode}) and" +
+            "        a.code=b.charge_code and " +
+            "        a.code=c.charge_code and " +
+            "        a.serial=c.serial    and " +
+            "        c.visible_flag_mz <> '1' and " +
+            "        c.visible_flag_zy <> '1' and " +
+            "        c.group_no='73'")
+    List<ZyDetailCharge> queryYaoPin(String pyCode);
+
     /**
      * 插入项目录入费用
      *
@@ -460,14 +588,22 @@ public interface XiangMuLuRuDao {
             "  , op_id_code, charge_code, infant_flag, charge_status, charge_fee  " +
             "  , self_flag, separate_flag, suppress_flag, ward_code, dept_code  " +
             "  , order_no, ope_flag, exec_unit, charge_amount, gen_time  " +
-            "  , zy_serial_no, charge_code_mx, serial)  " +
+            "  , zy_serial_no, charge_code_mx, serial,ss_code,yb_self_flag,refer_physician)  " +
             "VALUES " +
             "<foreach collection='list' item='item' separator=','>" +
             "(#{zyDetailCharge.inpatientNo}, #{zyDetailCharge.admissTimes}, 1, #{item.detailSn}, getdate()  " +
             "  , #{zyDetailCharge.opIdCode}, #{item.chargeCode}, #{infantFlag}, '2', cast(#{item.chargeAmount,jdbcType=DECIMAL} as decimal(14,5))  " +
             "  , '0', '0', NULL, #{zyDetailCharge.ward}, #{zyDetailCharge.dept}  " +
             "  , 0, '0', #{item.deptCode}, cast(#{item.amount,jdbcType=DECIMAL} as decimal(14,5)), getdate()  " +
-            "  , #{zyDetailCharge.zySerialNo}, #{item.chargeCodeMx}, '00')" +
+            "  , #{zyDetailCharge.zySerialNo}, #{item.chargeCodeMx}, #{item.serial},#{zyDetailCharge.ssCode}," +
+            // 是否医保报销 标志 默认为空值
+            "<if test=\"item.ybSelfFlag == null\">" +
+            "0" +
+            "</if>" +
+            "<if test=\"item.ybSelfFlag != null\">" +
+            "#{item.ybSelfFlag}" +
+            "</if>" +
+            ",#{zyDetailCharge.referPhysician})" +
             "</foreach>" +
             "</script>")
     void chaRuFeiYong(@Param("zyDetailCharge") ZyDetailCharge zyDetailCharge,
@@ -484,7 +620,7 @@ public interface XiangMuLuRuDao {
     @Update("<script>" +
             "update zy_actpatient " +
             "<trim prefix='set' suffixOverrides=','> " +
-            "total_charge = total_charge + #{fy.totalCharge} ,\n" +
+            "total_charge = total_charge + #{fy.totalCharge} , " +
             "balance = balance - #{fy.totalCharge}," +
             "<if test=\"fy.charge1 !=null \">" +
             "charge1 =charge1 + #{fy.charge1} ," +
@@ -637,7 +773,7 @@ public interface XiangMuLuRuDao {
             "                               )" +
             "                               VALUES " +
             "<foreach collection='param.list' item='item' index='index' separator=','>" +
-            "( substring(#{item.chargeName},0,15) , #{param.name} , #{item.chargeCode} , '00', '00', cast(#{item.amount,jdbcType=DECIMAL} as decimal(14,5)) , " +
+            "( substring(#{item.chargeName},0,15) , #{param.name} , #{item.chargeCodeMx} , #{item.groupNo}, #{item.serial}, cast(#{item.amount,jdbcType=DECIMAL} as decimal(14,5)) , " +
             "'0', '0', '0', '0', 1, 1, 1, 1, 1, #{index} + 1 , #{param.opIdCode} ,  #{param.pyCode} , #{param.dCode} , cast(#{item.chargeAmount,jdbcType=DECIMAL} as decimal(14,5)) ," +
             " #{param.deptCode} , " +
             "#{param.defaultNo} )" +
@@ -689,4 +825,8 @@ public interface XiangMuLuRuDao {
     @Select("select code,rtrim(name) name from zd_unit_code where code  like '8%'")
     List<GetDropdownBox> getWard();
 
+
+    @Select("SELECT small_dept code,name=(select name from zd_unit_code where code = small_dept)  FROM zd_dept_all where dept = #{dept}")
+    List<GetDropdownBox> getBingQuDuiYingKeShi(@Param("dept") String dept);
+
 }

+ 106 - 24
src/main/java/thyyxxk/webserver/service/yibao/XiangMuLuRuService.java

@@ -45,11 +45,15 @@ public class XiangMuLuRuService {
 
     /**
      * 获取患者费用
+     * 费用 类型  1 - 医嘱  2 - 项目费用  3 - 医技 4 - 全部  5 -药品费用
      *
      * @param param 查询条件
      * @return 返回患者费用
      */
     public ResultVo<List<ZyDetailCharge>> getHuanZheFeiYong(ZyDetailCharge param) {
+        if (StringUtil.isBlank(param.getInpatientNo()) || param.getAdmissTimes() == null) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "住院号或住院次数为空");
+        }
         log.info("查询患者费用==》住院号{},住院次数:{},项目名称:{},录入日期:{},费用类型:{},科室:{}", param.getInpatientNo(), param.getAdmissTimes(),
                 param.getChargeCode(), param.getStartTime(), param.getOrderNo(), param.getDept());
         int infantFlag = 0;
@@ -58,20 +62,34 @@ public class XiangMuLuRuService {
             param.setInpatientNo(param.getInpatientNo().split("\\$")[0]);
             infantFlag = 1;
         }
-        List<ZyDetailCharge> list = dao.getHuanZheFeiYong(param.getInpatientNo(), param.getAdmissTimes(), param.getChargeCode(), infantFlag,
-                param.getStartTime(), param.getOrderNo(), param.getDept());
-        List<ZyDetailCharge> tuiFeiList = dao.tuiFeiList(param.getInpatientNo(), param.getAdmissTimes());
-        Map<Integer, Integer> map = new HashMap<>();
-        for (ZyDetailCharge zyDetailCharge : tuiFeiList) {
-            map.put(zyDetailCharge.getOriDetailSn(), zyDetailCharge.getDetailSn());
+        List<ZyDetailCharge> list = null;
+        if (param.getOrderNo().compareTo(new BigDecimal(2)) == 0) {
+            list = dao.huanZheXiangMuFeiYong(param.getInpatientNo(), param.getAdmissTimes(), param.getChargeCode(), infantFlag,
+                    param.getStartTime(), param.getOrderNo(), param.getDept());
+        } else if (param.getOrderNo().compareTo(new BigDecimal(5)) == 0) {
+            list = dao.huanZheYaoPinFeiYong(param.getInpatientNo(), param.getAdmissTimes(), param.getChargeCode(), infantFlag,
+                    param.getStartTime(), param.getOrderNo(), param.getDept());
+        } else {
+            list = dao.getHuanZheFeiYong(param.getInpatientNo(), param.getAdmissTimes(), param.getChargeCode(), infantFlag,
+                    param.getStartTime(), param.getOrderNo(), param.getDept());
         }
-        for (ZyDetailCharge zyDetailCharge : list) {
-            // 判断 退费的数据
-            if (map.containsKey(zyDetailCharge.getDetailSn())) {
-                zyDetailCharge.setTuiFeiFlag(1);
+        if (list.isEmpty()) {
+            return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST);
+        }
+        List<ZyDetailCharge> tuiFeiList = dao.tuiFeiList(param.getInpatientNo(), param.getAdmissTimes());
+        if (!tuiFeiList.isEmpty()) {
+            Map<Integer, Integer> map = new HashMap<>();
+            for (ZyDetailCharge zyDetailCharge : tuiFeiList) {
+                map.put(zyDetailCharge.getOriDetailSn(), zyDetailCharge.getDetailSn());
             }
-            if (zyDetailCharge.getOriDetailSn() != null) {
-                zyDetailCharge.setTuiFeiFlag(1);
+            for (ZyDetailCharge zyDetailCharge : list) {
+                // 判断 退费的数据
+                if (map.containsKey(zyDetailCharge.getDetailSn())) {
+                    zyDetailCharge.setTuiFeiFlag(1);
+                }
+                if (zyDetailCharge.getOriDetailSn() != null) {
+                    zyDetailCharge.setTuiFeiFlag(1);
+                }
             }
         }
         return ResultVoUtil.success(list);
@@ -132,14 +150,14 @@ public class XiangMuLuRuService {
             }
             // 管理员角色可以无视
             if (!yongHuJueSe.contains(1)) {
-                // 人员角色为 3 就不是医技科室 只有医技科室可以退药品
-                if (yongHuJueSe.contains(4)) {
+                // 科室开头 是 8 就不是医技科室 只有医技科室可以退药品
+                if (param.getDeptCode().startsWith("8")) {
                     if (!zhiXinKeShi.contains(pojo.getExecUnit())) {
                         return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, String.format("流水号为【%s】,请对应的执行科室进行退费。", pojo.getDetailSn()));
                     }
                     // 护士是不可以退药品的
-                    if (pojo.getChargeCode().equals("BILL01") || pojo.getChargeCode().equals("BILL02")) {
-                        return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, String.format("流水号为【%s】,中草药费或西药费,无法退费。", pojo.getDetailSn()));
+                    if (pojo.getChargeCode().equals("BILL01") || pojo.getChargeCode().equals("BILL02") || pojo.getChargeCode().equals("BILL28")) {
+                        return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, String.format("流水号为【%s】,包含药品费用,无法退费。", pojo.getDetailSn()));
                     }
                 } else if (!param.getDeptCode().equals(pojo.getExecUnit())) {
                     return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, String.format("流水号为【%s】,请对应的执行科室进行退费。", pojo.getDetailSn()));
@@ -235,10 +253,26 @@ public class XiangMuLuRuService {
         if (param.getList().size() > 50) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "一次性项目录入大于50条");
         }
-        if (StringUtil.isBlank(param.getInpatientNo()) || param.getAdmissTimes() == null || param.getList().size() == 0
-                || StringUtil.isBlank(param.getWard()) || StringUtil.isBlank(param.getDept()) || StringUtil.isBlank(param.getZySerialNo())) {
-            return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "患者信息不全。");
+        StringBuilder errorStr = new StringBuilder();
+        if (StringUtil.isBlank(param.getInpatientNo()) || param.getAdmissTimes() == null) {
+            errorStr.append("1、住院号和住院次数为空<br />");
+        }
+        if (param.getList().size() == 0) {
+            errorStr.append("2、没有要录入的项目 <br />");
+        }
+        if (StringUtil.isBlank(param.getWard())) {
+            errorStr.append("3、病区为空 <br />");
         }
+        if (StringUtil.isBlank(param.getDept())) {
+            errorStr.append("4、申请科室为空 <br />");
+        }
+        if (StringUtil.isBlank(param.getZySerialNo())) {
+            errorStr.append("5、住院流水号为空 <br />");
+        }
+        if (errorStr.length() > 3) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, errorStr.toString());
+        }
+
         // 婴儿 要特殊处理
         int infantFlag = 0;
         // 如果带有这个 $ 说明是婴儿
@@ -255,15 +289,22 @@ public class XiangMuLuRuService {
         param.setOpIdCode(TokenUtil.getTokenUserId());
 
         for (ZyDetailCharge zyDetailCharge : param.getList()) {
-            zyDetailCharge.setDetailSn(maxDetailSn += 1);
+            if (zyDetailCharge.getBillItemCode().equals("001")) {
+                zyDetailCharge.setSerial("01");
+                zyDetailCharge.setChargeCode("BILL01");
+            } else if (zyDetailCharge.getBillItemCode().equals("002")) {
+                zyDetailCharge.setSerial("01");
+                zyDetailCharge.setChargeCode("BILL02");
+            } else {
+                //  Serial 00 项目标志 01 药品标志
+                zyDetailCharge.setSerial("00");
+                zyDetailCharge.setChargeCode(zyDetailCharge.getChargeCodeMx());
+            }
             // 判断患者的费用是否存在负数
             if (zyDetailCharge.getChargeAmount().signum() == -1 || zyDetailCharge.getAmount().signum() == -1) {
                 return ResultVoUtil.fail(ExceptionEnum.EXIST_NEGATIVE_FEES);
             }
-            sum = sum.add(zyDetailCharge.getChargeAmount().multiply(zyDetailCharge.getAmount()));
-            // 这里不会保存单价 只会总价
-            zyDetailCharge.setChargeAmount(zyDetailCharge.getChargeAmount().multiply(zyDetailCharge.getAmount()));
-            if (StringUtil.isBlank(zyDetailCharge.getChargeCode())) {
+            if (StringUtil.isBlank(zyDetailCharge.getChargeCodeMx())) {
                 return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "项目编码空值。");
             }
             if (StringUtil.isBlank(zyDetailCharge.getDeptCode())) {
@@ -272,6 +313,10 @@ public class XiangMuLuRuService {
             if (zyDetailCharge.getChargeCodeMx() == null) {
                 zyDetailCharge.setChargeCodeMx(zyDetailCharge.getChargeCode());
             }
+            sum = sum.add(zyDetailCharge.getChargeAmount().multiply(zyDetailCharge.getAmount()));
+            // 这里不会保存单价 只会总价
+            zyDetailCharge.setChargeAmount(zyDetailCharge.getChargeAmount().multiply(zyDetailCharge.getAmount()));
+            zyDetailCharge.setDetailSn(maxDetailSn += 1);
         }
         FeiYongLeiXin fy = JiSuanFeiYong.jiSuan(param.getList(), true);
         fy.setTotalCharge(sum);
@@ -288,11 +333,25 @@ public class XiangMuLuRuService {
      * @param zyDetailCharge 模板的一些数据
      * @return 返回成功提示
      */
+    @Transactional(rollbackFor = Exception.class)
     public ResultVo<String> shangChuanMuBan(ZyDetailCharge zyDetailCharge) {
         if (dao.chaKanMuBanMingChengSFcunZi(zyDetailCharge.getName(), TokenUtil.getTokenUserId()) > 0) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "模板名称重复");
         }
         zyDetailCharge.setOpIdCode(TokenUtil.getTokenUserId());
+
+        for (ZyDetailCharge detailCharge : zyDetailCharge.getList()) {
+            if (detailCharge.getBillItemCode().equals("001")) {
+                detailCharge.setSerial("01");
+                detailCharge.setGroupNo("73");
+            } else if (detailCharge.getBillItemCode().equals("002")) {
+                detailCharge.setSerial("01");
+                detailCharge.setGroupNo("73");
+            } else {
+                //  Serial 00 项目标志 01 药品标志
+                detailCharge.setSerial("00");
+            }
+        }
         // 在创建新的模板之前 需要先删除 原来的
         dao.delMuBan(zyDetailCharge.getName(), zyDetailCharge.getOpIdCode());
         dao.baoCunMuBan(zyDetailCharge);
@@ -348,6 +407,29 @@ public class XiangMuLuRuService {
         return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "删除成功");
     }
 
+    /**
+     * 生成拼音和五笔码
+     *
+     * @param inputStr 中文
+     * @return 返回编码
+     */
+    public ResultVo<ZyDetailCharge> getPyCode(String inputStr) {
+        ZyDetailCharge zyDetailCharge = new ZyDetailCharge();
+        zyDetailCharge.setPyCode(PingYinUtils.getAllPinYinHeadChar(inputStr));
+        zyDetailCharge.setWbCode(PingYinUtils.getWBCode(inputStr));
+        return ResultVoUtil.success(zyDetailCharge);
+    }
+
+    /**
+     * 根据病人科室
+     *
+     * @param ward 科室编码
+     * @return 返回对应的
+     */
+    public ResultVo<List<GetDropdownBox>> getBingQuDuiYingKeShi(String ward) {
+        return ResultVoUtil.success(dao.getBingQuDuiYingKeShi(ward));
+    }
+
 
 }