|  | @@ -2,6 +2,7 @@ package cn.hnthyy.thmz.mapper.his;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import cn.hnthyy.thmz.entity.his.MzChargeDetail;
 | 
	
		
			
				|  |  |  import cn.hnthyy.thmz.pageDto.MzChargeDetailPageDto;
 | 
	
		
			
				|  |  | +import cn.hnthyy.thmz.vo.ThmzmxsrParamsVo;
 | 
	
		
			
				|  |  |  import org.apache.ibatis.annotations.Insert;
 | 
	
		
			
				|  |  |  import org.apache.ibatis.annotations.Param;
 | 
	
		
			
				|  |  |  import org.apache.ibatis.annotations.Select;
 | 
	
	
		
			
				|  | @@ -85,10 +86,11 @@ public interface MzChargeDetailMapper {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 按照费用类型查询费用明细
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  |       * @param patientId
 | 
	
		
			
				|  |  |       * @param times
 | 
	
		
			
				|  |  |       * @param payMark
 | 
	
		
			
				|  |  | -     * @param billItemCode 0 ,1 都是in 2 not in
 | 
	
		
			
				|  |  | +     * @param billItemCode  0 ,1 都是in 2 not in
 | 
	
		
			
				|  |  |       * @param billItemTypes
 | 
	
		
			
				|  |  |       * @return
 | 
	
		
			
				|  |  |       */
 | 
	
	
		
			
				|  | @@ -117,7 +119,7 @@ public interface MzChargeDetailMapper {
 | 
	
		
			
				|  |  |              "#{item}",
 | 
	
		
			
				|  |  |              "</foreach>",
 | 
	
		
			
				|  |  |              "</script>"})
 | 
	
		
			
				|  |  | -    List<MzChargeDetail> selectMzChargeDetailByBillItemCode(@Param("patientId") String patientId, @Param("times") Integer times,@Param("payMark") String payMark, @Param("billItemCode") String billItemCode, @Param("billItemTypes") List<String> billItemTypes);
 | 
	
		
			
				|  |  | +    List<MzChargeDetail> selectMzChargeDetailByBillItemCode(@Param("patientId") String patientId, @Param("times") Integer times, @Param("payMark") String payMark, @Param("billItemCode") String billItemCode, @Param("billItemTypes") List<String> billItemTypes);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
	
		
			
				|  | @@ -148,7 +150,7 @@ public interface MzChargeDetailMapper {
 | 
	
		
			
				|  |  |              "<when test='mzChargeDetail.payMark eq 5'>",
 | 
	
		
			
				|  |  |              " price_time,",
 | 
	
		
			
				|  |  |              "</when>",
 | 
	
		
			
				|  |  | -                    "real_no,sum(unit_price*quantity*drug_win) amount from mz_charge_detail  where bill_item_code <![CDATA[<>]]> 'TC' ",
 | 
	
		
			
				|  |  | +            "real_no,sum(unit_price*quantity*drug_win) amount from mz_charge_detail  where bill_item_code <![CDATA[<>]]> 'TC' ",
 | 
	
		
			
				|  |  |              "<when test='mzChargeDetail.payMark!=null'>",
 | 
	
		
			
				|  |  |              " and pay_mark =#{mzChargeDetail.payMark,jdbcType=CHAR}",
 | 
	
		
			
				|  |  |              "</when>",
 | 
	
	
		
			
				|  | @@ -280,15 +282,18 @@ public interface MzChargeDetailMapper {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 根据当期那病人与就诊次数以及收费编码查询对应的药品数量与退药量
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  |       * @param patientId
 | 
	
		
			
				|  |  |       * @param times
 | 
	
		
			
				|  |  |       * @param chargeItemCode
 | 
	
		
			
				|  |  |       * @return
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      @Select("select * from mz_charge_detail where patient_id =#{patientId,jdbcType=CHAR} and times =#{times,jdbcType=INTEGER} and charge_item_code=#{chargeItemCode,jdbcType=CHAR} and order_no =#{orderNo} and quantity>0")
 | 
	
		
			
				|  |  | -    List<MzChargeDetail> selectMzChargeDetailByChargeItemCode(@Param("patientId") String patientId, @Param("times") Integer times, @Param("chargeItemCode") String chargeItemCode,@Param("orderNo") Integer orderNo);
 | 
	
		
			
				|  |  | +    List<MzChargeDetail> selectMzChargeDetailByChargeItemCode(@Param("patientId") String patientId, @Param("times") Integer times, @Param("chargeItemCode") String chargeItemCode, @Param("orderNo") Integer orderNo);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 新增收费明细记录
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  |       * @param mzChargeDetail
 | 
	
		
			
				|  |  |       * @return
 | 
	
		
			
				|  |  |       */
 | 
	
	
		
			
				|  | @@ -374,8 +379,8 @@ public interface MzChargeDetailMapper {
 | 
	
		
			
				|  |  |       * @return
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      @Update({"<script>",
 | 
	
		
			
				|  |  | -            "update mz_charge_detail " ,
 | 
	
		
			
				|  |  | -                    "<trim prefix='set' prefixOverrides=',' suffix=' where patient_id = #{patientId} and times=#{times}' >",
 | 
	
		
			
				|  |  | +            "update mz_charge_detail ",
 | 
	
		
			
				|  |  | +            "<trim prefix='set' prefixOverrides=',' suffix=' where patient_id = #{patientId} and times=#{times}' >",
 | 
	
		
			
				|  |  |              "<when test='payMark!=null'>",
 | 
	
		
			
				|  |  |              ",pay_mark =#{payMark,jdbcType=CHAR}",
 | 
	
		
			
				|  |  |              "</when>",
 | 
	
	
		
			
				|  | @@ -393,7 +398,6 @@ public interface MzChargeDetailMapper {
 | 
	
		
			
				|  |  |      int updatePayMakAndPrintFlag(MzChargeDetail mzChargeDetail);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 修改缴费明细记录
 | 
	
		
			
				|  |  |       *
 | 
	
	
		
			
				|  | @@ -401,7 +405,7 @@ public interface MzChargeDetailMapper {
 | 
	
		
			
				|  |  |       * @return
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      @Update({"<script>",
 | 
	
		
			
				|  |  | -            "update mz_charge_detail " ,
 | 
	
		
			
				|  |  | +            "update mz_charge_detail ",
 | 
	
		
			
				|  |  |              "<trim prefix='set' prefixOverrides=',' suffix=' where patient_id = #{patientId} and times=#{times} and charge_item_code=#{chargeItemCode,jdbcType=CHAR}' >",
 | 
	
		
			
				|  |  |              "<when test='serialNo!=null'>",
 | 
	
		
			
				|  |  |              "serial_no =#{serialNo,jdbcType=INTEGER}",
 | 
	
	
		
			
				|  | @@ -432,7 +436,6 @@ public interface MzChargeDetailMapper {
 | 
	
		
			
				|  |  |      int updateMzChargeDetail(MzChargeDetail mzChargeDetail);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 查询所有的记账记录
 | 
	
		
			
				|  |  |       *
 | 
	
	
		
			
				|  | @@ -485,27 +488,30 @@ public interface MzChargeDetailMapper {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 修改发票流水号与缴费次数  发票作废重打时调用
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  |       * @param receiptNo
 | 
	
		
			
				|  |  |       * @param serialNo
 | 
	
		
			
				|  |  |       * @param oriSerialNo
 | 
	
		
			
				|  |  |       * @return
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      @Update("update mz_charge_detail set receipt_no =#{receiptNo},serial_no=#{serialNo},real_no=#{serialNo} where serial_no = #{oriSerialNo}")
 | 
	
		
			
				|  |  | -    int updateBySerialNo(@Param("receiptNo") Integer receiptNo,@Param("serialNo") Integer serialNo,@Param("oriSerialNo") Integer oriSerialNo);
 | 
	
		
			
				|  |  | +    int updateBySerialNo(@Param("receiptNo") Integer receiptNo, @Param("serialNo") Integer serialNo, @Param("oriSerialNo") Integer oriSerialNo);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 修改病人姓名  120病人缴费时调用
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  |       * @param name
 | 
	
		
			
				|  |  |       * @param patientId
 | 
	
		
			
				|  |  |       * @param times
 | 
	
		
			
				|  |  |       * @return
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      @Update("update mz_charge_detail set name =#{name} where patient_id = #{patientId} and times = #{times}")
 | 
	
		
			
				|  |  | -    int updateNameByPatientIdAndTimes(@Param("name") String name,@Param("patientId") String patientId,@Param("times") Integer times);
 | 
	
		
			
				|  |  | +    int updateNameByPatientIdAndTimes(@Param("name") String name, @Param("patientId") String patientId, @Param("times") Integer times);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 查询病人缴费记录
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  |       * @param patientId
 | 
	
		
			
				|  |  |       * @param name
 | 
	
		
			
				|  |  |       * @param serialNo
 | 
	
	
		
			
				|  | @@ -515,11 +521,11 @@ public interface MzChargeDetailMapper {
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      @Select({"<script>",
 | 
	
		
			
				|  |  |              "SELECT distinct rtrim(a.patient_id) patient_id,name,a.times,a.receipt_no,charge_date=convert(char(10),a.charge_date,111) ,a.serial_no,real_no ,a.responce_type," +
 | 
	
		
			
				|  |  | -            " cheque_type=case when mz_receipt_serial.cheque_type='Y' and cash_id <![CDATA[<>]]> '99999' " +
 | 
	
		
			
				|  |  | -            " and len(ltrim(rtrim(mz_receipt_serial.receipt_bill))) <![CDATA[>=]]> 10 then '本院记账' else '自费' end " +
 | 
	
		
			
				|  |  | -            "    FROM mz_charge_detail a,mz_receipt_serial " +
 | 
	
		
			
				|  |  | -            "    WHERE a.charge_date <![CDATA[>=]]> #{beginDate,jdbcType=TIMESTAMP} and a.charge_date <![CDATA[<=]]> #{endDate,jdbcType=TIMESTAMP}  " +
 | 
	
		
			
				|  |  | -            "<when test='patientId!=null'>",
 | 
	
		
			
				|  |  | +                    " cheque_type=case when mz_receipt_serial.cheque_type='Y' and cash_id <![CDATA[<>]]> '99999' " +
 | 
	
		
			
				|  |  | +                    " and len(ltrim(rtrim(mz_receipt_serial.receipt_bill))) <![CDATA[>=]]> 10 then '本院记账' else '自费' end " +
 | 
	
		
			
				|  |  | +                    "    FROM mz_charge_detail a,mz_receipt_serial " +
 | 
	
		
			
				|  |  | +                    "    WHERE a.charge_date <![CDATA[>=]]> #{beginDate,jdbcType=TIMESTAMP} and a.charge_date <![CDATA[<=]]> #{endDate,jdbcType=TIMESTAMP}  " +
 | 
	
		
			
				|  |  | +                    "<when test='patientId!=null'>",
 | 
	
		
			
				|  |  |              " and a.patient_id like #{patientId}",
 | 
	
		
			
				|  |  |              "</when>",
 | 
	
		
			
				|  |  |              "<when test='name!=null'>",
 | 
	
	
		
			
				|  | @@ -528,13 +534,14 @@ public interface MzChargeDetailMapper {
 | 
	
		
			
				|  |  |              "<when test='serialNo!=null'>",
 | 
	
		
			
				|  |  |              " and mz_receipt_serial.serial_no like #{serialNo}",
 | 
	
		
			
				|  |  |              "</when>",
 | 
	
		
			
				|  |  | -            " and  real_no=receipt_sn"+
 | 
	
		
			
				|  |  | -            "</script>"})
 | 
	
		
			
				|  |  | -    List<Map<String,Object>> selectChargeListByPatient(@Param("patientId") String patientId, @Param("name") String name,@Param("serialNo") String serialNo,@Param("beginDate") Date beginDate, @Param("endDate") Date endDate);
 | 
	
		
			
				|  |  | +            " and  real_no=receipt_sn" +
 | 
	
		
			
				|  |  | +                    "</script>"})
 | 
	
		
			
				|  |  | +    List<Map<String, Object>> selectChargeListByPatient(@Param("patientId") String patientId, @Param("name") String name, @Param("serialNo") String serialNo, @Param("beginDate") Date beginDate, @Param("endDate") Date endDate);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 根据病人编码和收费流水号查询缴费明细
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  |       * @param patientId
 | 
	
		
			
				|  |  |       * @param serialNo
 | 
	
		
			
				|  |  |       * @return
 | 
	
	
		
			
				|  | @@ -557,7 +564,7 @@ public interface MzChargeDetailMapper {
 | 
	
		
			
				|  |  |              "         op_id        =a.cash_id," +
 | 
	
		
			
				|  |  |              "         real_no      =a.real_no," +
 | 
	
		
			
				|  |  |              "         group_no=a.group_no," +
 | 
	
		
			
				|  |  | -            "         total_price=a.quantity * drug_win* a.unit_price,"+
 | 
	
		
			
				|  |  | +            "         total_price=a.quantity * drug_win* a.unit_price," +
 | 
	
		
			
				|  |  |              "         tybm=b.code ," +
 | 
	
		
			
				|  |  |              "         unit=b.pack_unit," +
 | 
	
		
			
				|  |  |              "         warn_dept=warn_dept," +
 | 
	
	
		
			
				|  | @@ -587,7 +594,7 @@ public interface MzChargeDetailMapper {
 | 
	
		
			
				|  |  |              "         op_id        =a.cash_id," +
 | 
	
		
			
				|  |  |              "         real_no      =a.real_no," +
 | 
	
		
			
				|  |  |              "         group_no=a.group_no," +
 | 
	
		
			
				|  |  | -            "         total_price=a.quantity * drug_win* a.unit_price,"+
 | 
	
		
			
				|  |  | +            "         total_price=a.quantity * drug_win* a.unit_price," +
 | 
	
		
			
				|  |  |              "         tybm=isnull(b.s_code,b.code)," +
 | 
	
		
			
				|  |  |              "         unit=charge_unit," +
 | 
	
		
			
				|  |  |              "         warn_dept=warn_dept," +
 | 
	
	
		
			
				|  | @@ -599,13 +606,12 @@ public interface MzChargeDetailMapper {
 | 
	
		
			
				|  |  |              "         a.charge_item_code=b.code   and " +
 | 
	
		
			
				|  |  |              "         a.serial <>'01' and " +
 | 
	
		
			
				|  |  |              "         a.serial <>'99'")
 | 
	
		
			
				|  |  | -    List<Map<String,Object>> selectChargeDetailByPatient(@Param("patientId") String patientId,@Param("serialNo") String serialNo);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | +    List<Map<String, Object>> selectChargeDetailByPatient(@Param("patientId") String patientId, @Param("serialNo") String serialNo);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 查询病人缴费记录 (历史数据)
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  |       * @param patientId
 | 
	
		
			
				|  |  |       * @param name
 | 
	
		
			
				|  |  |       * @param serialNo
 | 
	
	
		
			
				|  | @@ -628,88 +634,91 @@ public interface MzChargeDetailMapper {
 | 
	
		
			
				|  |  |              "<when test='serialNo!=null'>",
 | 
	
		
			
				|  |  |              " and mz_receipt_serial_b.serial_no =#{serialNo}",
 | 
	
		
			
				|  |  |              "</when>",
 | 
	
		
			
				|  |  | -            " and  real_no=receipt_sn"+
 | 
	
		
			
				|  |  | +            " and  real_no=receipt_sn" +
 | 
	
		
			
				|  |  |                      "</script>"})
 | 
	
		
			
				|  |  | -    List<Map<String,Object>> selectHisChargeListByPatient(@Param("patientId") String patientId, @Param("name") String name, @Param("serialNo") String serialNo, @Param("beginDate") Date beginDate, @Param("endDate") Date endDate);
 | 
	
		
			
				|  |  | +    List<Map<String, Object>> selectHisChargeListByPatient(@Param("patientId") String patientId, @Param("name") String name, @Param("serialNo") String serialNo, @Param("beginDate") Date beginDate, @Param("endDate") Date endDate);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 根据病人编码和收费流水号查询缴费明细 (历史数据)
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  |       * @param patientId
 | 
	
		
			
				|  |  |       * @param serialNo
 | 
	
		
			
				|  |  |       * @return
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      @Select("SELECT   patient_id=a.patient_id," +
 | 
	
		
			
				|  |  | -                    "         times     =a.times," +
 | 
	
		
			
				|  |  | -                    "         receipt_no=a.receipt_no," +
 | 
	
		
			
				|  |  | -                    "         order_no  =a.order_no," +
 | 
	
		
			
				|  |  | -                    "         quantity  =a.quantity * drug_win," +
 | 
	
		
			
				|  |  | -                    "         unit_price=a.unit_price," +
 | 
	
		
			
				|  |  | -                    "         name      =a.name," +
 | 
	
		
			
				|  |  | -                    "         drugname  =b.name," +
 | 
	
		
			
				|  |  | -                    "         specification=b.specification," +
 | 
	
		
			
				|  |  | -                    "         frequency    =a.frequency," +
 | 
	
		
			
				|  |  | -                    "         supply_code  =a.supply_code," +
 | 
	
		
			
				|  |  | -                    "         amount       =a.drug_quan," +
 | 
	
		
			
				|  |  | -                    "         drug_unit    =a.drug_unit," +
 | 
	
		
			
				|  |  | -                    "         item_no      =a.item_no," +
 | 
	
		
			
				|  |  | -                    "         doctor_code  =a.doctor_code," +
 | 
	
		
			
				|  |  | -                    "         op_id        =a.cash_id," +
 | 
	
		
			
				|  |  | -                    "         real_no      =a.real_no," +
 | 
	
		
			
				|  |  | -                    "         group_no=a.group_no," +
 | 
	
		
			
				|  |  | -                    "         total_price=a.quantity * drug_win* a.unit_price,"+
 | 
	
		
			
				|  |  | -                    "         tybm=b.code ," +
 | 
	
		
			
				|  |  | -                    "         unit=b.pack_unit," +
 | 
	
		
			
				|  |  | -                    "         warn_dept=warn_dept," +
 | 
	
		
			
				|  |  | -                    "         charge_date," +
 | 
	
		
			
				|  |  | -                    "    FROM mz_charge_detail_b a,yp_zd_dict_b b " +
 | 
	
		
			
				|  |  | -                    "   WHERE  a.patient_id = #{patientId}     AND  " +
 | 
	
		
			
				|  |  | -                    "          a.real_no=#{serialNo}  and " +
 | 
	
		
			
				|  |  | -                    "         a.charge_item_code=b.code and " +
 | 
	
		
			
				|  |  | -                    "         a.serial=b.serial  " +
 | 
	
		
			
				|  |  | -                    " union all " +
 | 
	
		
			
				|  |  | -                    "SELECT   patient_id=a.patient_id," +
 | 
	
		
			
				|  |  | -                    "         times     =a.times," +
 | 
	
		
			
				|  |  | -                    "         receipt_no=a.receipt_no," +
 | 
	
		
			
				|  |  | -                    "         order_no  =a.order_no," +
 | 
	
		
			
				|  |  | -                    "         quantity  =a.quantity * drug_win," +
 | 
	
		
			
				|  |  | -                    "         unit_price=a.unit_price," +
 | 
	
		
			
				|  |  | -                    "         name      =a.name," +
 | 
	
		
			
				|  |  | -                    "         drugname  =b.name," +
 | 
	
		
			
				|  |  | -                    "         specification=b.charge_unit," +
 | 
	
		
			
				|  |  | -                    "         frequency    =a.frequency," +
 | 
	
		
			
				|  |  | -                    "         supply_code  =a.supply_code," +
 | 
	
		
			
				|  |  | -                    "         amount       =a.drug_quan," +
 | 
	
		
			
				|  |  | -                    "         drug_unit    =a.drug_unit," +
 | 
	
		
			
				|  |  | -                    "         item_no      =a.item_no," +
 | 
	
		
			
				|  |  | -                    "         doctor_code  =a.doctor_code," +
 | 
	
		
			
				|  |  | -                    "         op_id        =a.cash_id," +
 | 
	
		
			
				|  |  | -                    "         real_no      =a.real_no," +
 | 
	
		
			
				|  |  | -                    "         group_no=a.group_no," +
 | 
	
		
			
				|  |  | -                    "         total_price=a.quantity * drug_win* a.unit_price,"+
 | 
	
		
			
				|  |  | -                    "         tybm=isnull(b.s_code,b.code)," +
 | 
	
		
			
				|  |  | -                    "         unit=charge_unit," +
 | 
	
		
			
				|  |  | -                    "         warn_dept=warn_dept," +
 | 
	
		
			
				|  |  | -                    "         charge_date," +
 | 
	
		
			
				|  |  | -                    "    FROM mz_charge_detail_b a,zd_charge_item_b b" +
 | 
	
		
			
				|  |  | -                    "   WHERE  a.patient_id = #{patientId}   AND  " +
 | 
	
		
			
				|  |  | -                    "          a.real_no=#{serialNo}  and " +
 | 
	
		
			
				|  |  | -                    "         a.charge_item_code=b.code   and " +
 | 
	
		
			
				|  |  | -                    "         a.serial <>'01' and " +
 | 
	
		
			
				|  |  | -                    "         a.serial <>'99'")
 | 
	
		
			
				|  |  | -    List<Map<String,Object>> selectHisChargeDetailByPatient(@Param("patientId") String patientId,@Param("serialNo") String serialNo);
 | 
	
		
			
				|  |  | +            "         times     =a.times," +
 | 
	
		
			
				|  |  | +            "         receipt_no=a.receipt_no," +
 | 
	
		
			
				|  |  | +            "         order_no  =a.order_no," +
 | 
	
		
			
				|  |  | +            "         quantity  =a.quantity * drug_win," +
 | 
	
		
			
				|  |  | +            "         unit_price=a.unit_price," +
 | 
	
		
			
				|  |  | +            "         name      =a.name," +
 | 
	
		
			
				|  |  | +            "         drugname  =b.name," +
 | 
	
		
			
				|  |  | +            "         specification=b.specification," +
 | 
	
		
			
				|  |  | +            "         frequency    =a.frequency," +
 | 
	
		
			
				|  |  | +            "         supply_code  =a.supply_code," +
 | 
	
		
			
				|  |  | +            "         amount       =a.drug_quan," +
 | 
	
		
			
				|  |  | +            "         drug_unit    =a.drug_unit," +
 | 
	
		
			
				|  |  | +            "         item_no      =a.item_no," +
 | 
	
		
			
				|  |  | +            "         doctor_code  =a.doctor_code," +
 | 
	
		
			
				|  |  | +            "         op_id        =a.cash_id," +
 | 
	
		
			
				|  |  | +            "         real_no      =a.real_no," +
 | 
	
		
			
				|  |  | +            "         group_no=a.group_no," +
 | 
	
		
			
				|  |  | +            "         total_price=a.quantity * drug_win* a.unit_price," +
 | 
	
		
			
				|  |  | +            "         tybm=b.code ," +
 | 
	
		
			
				|  |  | +            "         unit=b.pack_unit," +
 | 
	
		
			
				|  |  | +            "         warn_dept=warn_dept," +
 | 
	
		
			
				|  |  | +            "         charge_date," +
 | 
	
		
			
				|  |  | +            "    FROM mz_charge_detail_b a,yp_zd_dict_b b " +
 | 
	
		
			
				|  |  | +            "   WHERE  a.patient_id = #{patientId}     AND  " +
 | 
	
		
			
				|  |  | +            "          a.real_no=#{serialNo}  and " +
 | 
	
		
			
				|  |  | +            "         a.charge_item_code=b.code and " +
 | 
	
		
			
				|  |  | +            "         a.serial=b.serial  " +
 | 
	
		
			
				|  |  | +            " union all " +
 | 
	
		
			
				|  |  | +            "SELECT   patient_id=a.patient_id," +
 | 
	
		
			
				|  |  | +            "         times     =a.times," +
 | 
	
		
			
				|  |  | +            "         receipt_no=a.receipt_no," +
 | 
	
		
			
				|  |  | +            "         order_no  =a.order_no," +
 | 
	
		
			
				|  |  | +            "         quantity  =a.quantity * drug_win," +
 | 
	
		
			
				|  |  | +            "         unit_price=a.unit_price," +
 | 
	
		
			
				|  |  | +            "         name      =a.name," +
 | 
	
		
			
				|  |  | +            "         drugname  =b.name," +
 | 
	
		
			
				|  |  | +            "         specification=b.charge_unit," +
 | 
	
		
			
				|  |  | +            "         frequency    =a.frequency," +
 | 
	
		
			
				|  |  | +            "         supply_code  =a.supply_code," +
 | 
	
		
			
				|  |  | +            "         amount       =a.drug_quan," +
 | 
	
		
			
				|  |  | +            "         drug_unit    =a.drug_unit," +
 | 
	
		
			
				|  |  | +            "         item_no      =a.item_no," +
 | 
	
		
			
				|  |  | +            "         doctor_code  =a.doctor_code," +
 | 
	
		
			
				|  |  | +            "         op_id        =a.cash_id," +
 | 
	
		
			
				|  |  | +            "         real_no      =a.real_no," +
 | 
	
		
			
				|  |  | +            "         group_no=a.group_no," +
 | 
	
		
			
				|  |  | +            "         total_price=a.quantity * drug_win* a.unit_price," +
 | 
	
		
			
				|  |  | +            "         tybm=isnull(b.s_code,b.code)," +
 | 
	
		
			
				|  |  | +            "         unit=charge_unit," +
 | 
	
		
			
				|  |  | +            "         warn_dept=warn_dept," +
 | 
	
		
			
				|  |  | +            "         charge_date," +
 | 
	
		
			
				|  |  | +            "    FROM mz_charge_detail_b a,zd_charge_item_b b" +
 | 
	
		
			
				|  |  | +            "   WHERE  a.patient_id = #{patientId}   AND  " +
 | 
	
		
			
				|  |  | +            "          a.real_no=#{serialNo}  and " +
 | 
	
		
			
				|  |  | +            "         a.charge_item_code=b.code   and " +
 | 
	
		
			
				|  |  | +            "         a.serial <>'01' and " +
 | 
	
		
			
				|  |  | +            "         a.serial <>'99'")
 | 
	
		
			
				|  |  | +    List<Map<String, Object>> selectHisChargeDetailByPatient(@Param("patientId") String patientId, @Param("serialNo") String serialNo);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 根据病人就诊次数和门诊号查询有效的申请科室和医生编码
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  |       * @param patientId
 | 
	
		
			
				|  |  |       * @param times
 | 
	
		
			
				|  |  |       * @return
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      @Select("select top 1 rtrim(warn_dept) warn_dept,rtrim(doctor_code) doctor_code,rtrim(print_flag) print_flag from mz_charge_detail where  patient_id = #{patientId} and times = #{times} and warn_dept is not null and doctor_code is not null and warn_dept<> '' and doctor_code<> '' ")
 | 
	
		
			
				|  |  | -    MzChargeDetail selectWarnDeptAndDoctor(@Param("patientId") String patientId,@Param("times") Integer times);
 | 
	
		
			
				|  |  | +    MzChargeDetail selectWarnDeptAndDoctor(@Param("patientId") String patientId, @Param("times") Integer times);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 清洗老系统打印发票数据
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  |       * @return
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      @Update("update mz_charge_detail set confirm_flag=4  where real_no in (select abs(real_no) from mz_charge_detail where real_no <0 group by real_no)")
 | 
	
	
		
			
				|  | @@ -717,10 +726,67 @@ public interface MzChargeDetailMapper {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 查询120 病人姓名
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  |       * @param patientId
 | 
	
		
			
				|  |  |       * @param times
 | 
	
		
			
				|  |  |       * @return
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      @Select("select top 1 name from mz_charge_detail where  patient_id = #{patientId} and times = #{times} and name is not null and  name <> '' ")
 | 
	
		
			
				|  |  | -    String selectJZName(@Param("patientId") String patientId,@Param("times") Integer times);
 | 
	
		
			
				|  |  | +    String selectJZName(@Param("patientId") String patientId, @Param("times") Integer times);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  | +     * @param thmzmxsrParamsVo  caseType = 1 申请科室核算报表  0 执行科室核算报表
 | 
	
		
			
				|  |  | +     * @return
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    @Select({"<script>",
 | 
	
		
			
				|  |  | +            "SELECT " +
 | 
	
		
			
				|  |  | +                    "  exec_dept=case '1' when #{caseType} then " +
 | 
	
		
			
				|  |  | +                    "      case when isnull(a.warn_dept,'')='' then  a.exec_dept else a.warn_dept end " +
 | 
	
		
			
				|  |  | +                    "      else  " +
 | 
	
		
			
				|  |  | +                    "     case when isnull(a.exec_dept,'') ='' then a.warn_dept else a.exec_dept end " +
 | 
	
		
			
				|  |  | +                    "  end ," +
 | 
	
		
			
				|  |  | +                    "       charge_bill_code= case a.charge_bill_code when 'BILL10' then 'BILL01' when 'BILL11' then 'BILL28' when 'BILL12' then 'BILL02' else a.charge_bill_code end," +
 | 
	
		
			
				|  |  | +                    "         parent=max( d.parent_code )," +
 | 
	
		
			
				|  |  | +                    "         total_charge=isnull(sum(round(convert(decimal(18,3),((convert(decimal(18,3),unit_price)) * (quantity * isnull(drug_win,1)))),2)),0)," +
 | 
	
		
			
				|  |  | +                    "         audit_code=case when isnull(a.group_no,'00')='71' then max(d.name)+'(门诊)' when isnull(a.group_no,'00')='72' then max(d.name)+'(急诊)' else max(d.name) end," +
 | 
	
		
			
				|  |  | +                    " charge_dcount_date=b.charge_dcount_date  " +
 | 
	
		
			
				|  |  | +                    "    FROM ${firstTableName} a(nolock),   " +
 | 
	
		
			
				|  |  | +                    "         (select distinct patient_id,times,receipt_no, serial_no,receipt_sn,charge_dcount_date from ${secondTableName} " +
 | 
	
		
			
				|  |  | +                    "          where (case 1 when '0' then charge_date " +
 | 
	
		
			
				|  |  | +                    "                 else charge_dcount_date end) <![CDATA[>=]]> #{beginDate} and " +
 | 
	
		
			
				|  |  | +                    "                (case 1 when '0' then charge_date " +
 | 
	
		
			
				|  |  | +                    "                 else charge_dcount_date end) <![CDATA[<=]]> #{endDate} and " +
 | 
	
		
			
				|  |  | +                    "                (case 1 when '0' then isnull(dcount_no,0) " +
 | 
	
		
			
				|  |  | +                    "                 else 1 end) = isnull(dcount_no,0) ) as b, " +
 | 
	
		
			
				|  |  | +                    "         zd_charge_item c," +
 | 
	
		
			
				|  |  | +                    "         zy_zd_audit_item d " +
 | 
	
		
			
				|  |  | +                    "   WHERE ( a.patient_id = b.patient_id )    and  " +
 | 
	
		
			
				|  |  | +                    "           a.times=b.times and " +
 | 
	
		
			
				|  |  | +                    "           a.receipt_no=b.receipt_no and   " +
 | 
	
		
			
				|  |  | +                    "           case a.charge_bill_code when 'BILL10' then 'BILL01' when 'BILL11' then 'BILL28' when 'BILL12' then 'BILL02' else a.charge_bill_code end*=c.code and " +
 | 
	
		
			
				|  |  | +                    "           isnull(c.audit_code,d.code)=d.code and " +
 | 
	
		
			
				|  |  | +                    "           a.serial_no=b.serial_no and " +
 | 
	
		
			
				|  |  | +                    "           a.real_no=b.receipt_sn and " +
 | 
	
		
			
				|  |  | +                    "            a.bill_item_code <![CDATA[<>]]> 'TC'  " +
 | 
	
		
			
				|  |  | +//                    "          and isnull(a.dept_no,'') like '%' " +
 | 
	
		
			
				|  |  | +                    "          and ( case '1' when #{caseType} then " +
 | 
	
		
			
				|  |  | +                    "      case when isnull(a.warn_dept,'')='' then  a.exec_dept else a.warn_dept end " +
 | 
	
		
			
				|  |  | +                    "      else  " +
 | 
	
		
			
				|  |  | +                    "     case when isnull(a.exec_dept,'') ='' then a.warn_dept else a.exec_dept end " +
 | 
	
		
			
				|  |  | +                    "  end " +
 | 
	
		
			
				|  |  | +                    ") =#{execDept} " +
 | 
	
		
			
				|  |  | +                    "group by " +
 | 
	
		
			
				|  |  | +                    "  case '1' when #{caseType} then " +
 | 
	
		
			
				|  |  | +                    "      case when isnull(a.warn_dept,'')='' then  a.exec_dept else a.warn_dept end " +
 | 
	
		
			
				|  |  | +                    "      else  " +
 | 
	
		
			
				|  |  | +                    "     case when isnull(a.exec_dept,'') ='' then a.warn_dept else a.exec_dept end " +
 | 
	
		
			
				|  |  | +                    "  end ," +
 | 
	
		
			
				|  |  | +                    "c.audit_code,isnull(a.group_no,'00')," +
 | 
	
		
			
				|  |  | +                    " case a.charge_bill_code when 'BILL10' then 'BILL01' when 'BILL11' then 'BILL28' when 'BILL12' then 'BILL02' else a.charge_bill_code end" +
 | 
	
		
			
				|  |  | +                    ",b.charge_dcount_date ",
 | 
	
		
			
				|  |  | +            "</script>"})
 | 
	
		
			
				|  |  | +    List<Map<String, Object>> selectDepetBusinessReport(ThmzmxsrParamsVo thmzmxsrParamsVo);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  }
 |