123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791 |
- 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;
- import org.apache.ibatis.annotations.Update;
- import java.util.Date;
- import java.util.List;
- import java.util.Map;
- /**
- * 门诊收费记录表的数据层
- */
- public interface MzChargeDetailMapper {
- /**
- * 统计符合条件的费用信息
- *
- * @param mzChargeDetailPageDto
- * @return
- */
- @Select({"<script>",
- "select count(*) from (",
- "select patient_id from mz_charge_detail where bill_item_code <![CDATA[<>]]> 'TC' ",
- "<when test='mzChargeDetail.payMark!=null'>",
- " and pay_mark =#{mzChargeDetail.payMark,jdbcType=CHAR}",
- "</when>",
- "<when test='mzChargeDetail.payMark!=null and mzChargeDetail.payMark eq 0'>",
- " and confirm_flag <![CDATA[<>]]> 4 ",
- "</when>",
- "<when test='mzChargeDetail.patientId!=null'>",
- " and patient_id =#{mzChargeDetail.patientId,jdbcType=CHAR}",
- "</when>",
- "<when test='mzChargeDetail.times!=null'>",
- " and times =#{mzChargeDetail.times,jdbcType=INTEGER}",
- "</when>",
- "<when test='mzChargeDetail.name!=null'>",
- " and name like #{mzChargeDetail.name,jdbcType=CHAR}",
- "</when>",
- "<when test='mzChargeDetail.warnDept!=null'>",
- " and warn_dept = #{mzChargeDetail.warnDept,jdbcType=CHAR}",
- "</when>",
- "<when test='mzChargeDetail.doctorCode!=null'>",
- " and doctor_code =#{mzChargeDetail.doctorCode,jdbcType=CHAR}",
- "</when>",
- "<when test='opId!=null and mzChargeDetail.payMark eq 0 '>",
- " and cash_id =#{opId,jdbcType=CHAR}",
- "</when>",
- "<when test='opId!=null and mzChargeDetail.payMark eq 1 '>",
- " and input_id =#{opId,jdbcType=CHAR}",
- "</when>",
- "<when test='beginTime!=null and mzChargeDetail.payMark eq 5'>",
- " and price_time >=#{beginTime,jdbcType=TIMESTAMP}",
- "</when>",
- "<when test='endTime!=null and mzChargeDetail.payMark eq 5'>",
- " and price_time <=#{endTime,jdbcType=TIMESTAMP}",
- "</when>",
- "<when test='beginTime!=null and mzChargeDetail.payMark eq 0'>",
- " and charge_date >=#{beginTime,jdbcType=TIMESTAMP}",
- "</when>",
- "<when test='endTime!=null and mzChargeDetail.payMark eq 0'>",
- " and charge_date <=#{endTime,jdbcType=TIMESTAMP}",
- "</when>",
- "<when test='beginTime!=null and mzChargeDetail.payMark eq 1'>",
- " and input_date >=#{beginTime,jdbcType=TIMESTAMP}",
- "</when>",
- "<when test='endTime!=null and mzChargeDetail.payMark eq 1'>",
- " and input_date <=#{endTime,jdbcType=TIMESTAMP}",
- "</when>",
- " group by patient_id,times,receipt_no,name,",
- "<when test='mzChargeDetail.payMark eq 0'>",
- " charge_date,",
- "</when>",
- "<when test='mzChargeDetail.payMark eq 1'>",
- " input_date,",
- "</when>",
- "<when test='mzChargeDetail.payMark eq 5'>",
- " price_time,",
- "</when>",
- "real_no)As mz_charge_detail_page",
- "</script>"})
- int countMzChargeDetail(MzChargeDetailPageDto mzChargeDetailPageDto);
- /**
- * 按照费用类型查询费用明细
- *
- * @param patientId
- * @param times
- * @param payMark
- * @param billItemCode 0 ,1 都是in 2 not in
- * @param billItemTypes
- * @return
- */
- @Select({"<script>",
- "select rtrim(patient_id) patient_id,times,receipt_no,order_no,item_no,rtrim(charge_item_code) charge_item_code,rtrim(bill_item_code) bill_item_code,",
- "quantity,unit_price,rtrim(pay_mark) pay_mark,rtrim(serial) serial,rtrim(charge_item_type) charge_item_type,rtrim(country_flag) country_flag,rtrim(drug_flag) drug_flag,",
- "serial_no,rtrim(name) name,charge_date,confirm_time,rtrim(group_no) group_no,rtrim(confirm_id) confirm_id,drug_win,rtrim(input_id) input_id,input_date,",
- "rtrim(cashier_id) cashier_id,rtrim(windows_no) windows_no,rtrim(price_id) price_id,price_time,rtrim(exec_dept) exec_dept,rtrim(audit_code) audit_code,",
- "rtrim(gongnks_flag) gongnks_flag,rtrim(print_flag) print_flag,confirm_flag,rtrim(warn_dept) warn_dept,rtrim(jz_flag) jz_flag,group_order,rtrim(cash_id) cash_id,",
- "rtrim(doctor_code) doctor_code,rtrim(supply_code) supply_code,rtrim(frequency) frequency,drug_quan,rtrim(drug_unit) drug_unit,rtrim(doctor_flag) doctor_flag,inject_res,inject_times,",
- "rtrim(confirm_zs) confirm_zs,real_no,windows_no_yf,ybbx_flag,tc_no,tc_name,rtrim(detail_flag) detail_flag,gl_percent,rtrim(order_type) order_type,supply_no,instruction_code,",
- "instruction_text,order_days,rtrim(pay_self) pay_self,rtrim(try_flag) try_flag,rtrim(req_yj) req_yj,req_no,rtrim(group_type) group_type,order_bill,charge_bill_code,",
- "rtrim(self_flag) self_flag,rtrim(responce_type) responce_type,dec_amount,back_serial,input_time,cy_mtjs,cy_jsl,cy_zql,cy_fj,cy_ffcs,cy_fysm,supply_amount,rtrim(cy_jssm) cy_jssm,",
- "dept_no,gl_percent_ft,rtrim(yb_zf_flag) yb_zf_flag,orig_price,rtrim(try_result) try_result,rtrim(supply_exec) supply_exec,rtrim(cy_dj) cy_dj,rtrim(receive_flag) receive_flag,",
- "rtrim(chequ_type) chequ_type,rtrim(print_flag_yj) print_flag_yj,rtrim(confirm_flag_qx) confirm_flag_qx ",
- "from dbo.mz_charge_detail where pay_mark=#{payMark,jdbcType=CHAR} and patient_id =#{patientId,jdbcType=CHAR} and times = #{times,jdbcType=INTEGER} ",
- "<choose>",
- "<when test='billItemCode==2'>",
- " and bill_item_code not in",
- "</when>",
- "<otherwise>",
- " and bill_item_code in",
- "</otherwise>",
- " </choose>",
- "<foreach item='item' index='index' collection='billItemTypes' open='(' separator=',' close=')'>",
- "#{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);
- /**
- * 分页查询收费合计信息
- *
- * @param mzChargeDetailPageDto
- * @return
- */
- @Select({"<script>",
- "select top ${pageSize} * FROM (SELECT ROW_NUMBER() OVER (ORDER BY mz_charge_detail_page.",
- "<when test='mzChargeDetail.payMark eq 5'>",
- "price_time",
- "</when>",
- "<when test='mzChargeDetail.payMark eq 0'>",
- "charge_date",
- "</when>",
- "<when test='mzChargeDetail.payMark eq 1'>",
- "input_date",
- "</when>",
- " desc) AS RowNumber,* from (" +
- "select rtrim(patient_id) patient_id,times,receipt_no,rtrim(name) name,",
- "<when test='mzChargeDetail.payMark eq 0'>",
- " charge_date,",
- "</when>",
- "<when test='mzChargeDetail.payMark eq 1'>",
- " input_date,",
- "</when>",
- "<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' ",
- "<when test='mzChargeDetail.payMark!=null'>",
- " and pay_mark =#{mzChargeDetail.payMark,jdbcType=CHAR}",
- "</when>",
- "<when test='mzChargeDetail.payMark!=null and mzChargeDetail.payMark eq 0'>",
- " and confirm_flag <![CDATA[<>]]> 4 ",
- "</when>",
- "<when test='mzChargeDetail.patientId!=null'>",
- " and patient_id =#{mzChargeDetail.patientId,jdbcType=CHAR}",
- "</when>",
- "<when test='mzChargeDetail.times!=null'>",
- " and times =#{mzChargeDetail.times,jdbcType=INTEGER}",
- "</when>",
- "<when test='mzChargeDetail.name!=null'>",
- " and name like #{mzChargeDetail.name,jdbcType=CHAR}",
- "</when>",
- "<when test='mzChargeDetail.warnDept!=null'>",
- " and warn_dept = #{mzChargeDetail.warnDept,jdbcType=CHAR}",
- "</when>",
- "<when test='mzChargeDetail.doctorCode!=null'>",
- " and doctor_code =#{mzChargeDetail.doctorCode,jdbcType=CHAR}",
- "</when>",
- "<when test='opId!=null and mzChargeDetail.payMark eq 0 '>",
- " and cash_id =#{opId,jdbcType=CHAR}",
- "</when>",
- "<when test='opId!=null and mzChargeDetail.payMark eq 1 '>",
- " and input_id =#{opId,jdbcType=CHAR}",
- "</when>",
- "<when test='beginTime!=null and mzChargeDetail.payMark eq 5'>",
- " and price_time >=#{beginTime,jdbcType=TIMESTAMP}",
- "</when>",
- "<when test='endTime!=null and mzChargeDetail.payMark eq 5'>",
- " and price_time <=#{endTime,jdbcType=TIMESTAMP}",
- "</when>",
- "<when test='beginTime!=null and mzChargeDetail.payMark eq 0'>",
- " and charge_date >=#{beginTime,jdbcType=TIMESTAMP}",
- "</when>",
- "<when test='endTime!=null and mzChargeDetail.payMark eq 0'>",
- " and charge_date <=#{endTime,jdbcType=TIMESTAMP}",
- "</when>",
- "<when test='beginTime!=null and mzChargeDetail.payMark eq 1'>",
- " and input_date >=#{beginTime,jdbcType=TIMESTAMP}",
- "</when>",
- "<when test='endTime!=null and mzChargeDetail.payMark eq 1'>",
- " and input_date <=#{endTime,jdbcType=TIMESTAMP}",
- "</when>",
- " group by patient_id,times,receipt_no,name,",
- "<when test='mzChargeDetail.payMark eq 0'>",
- " charge_date,",
- "</when>",
- "<when test='mzChargeDetail.payMark eq 1'>",
- " input_date,",
- "</when>",
- "<when test='mzChargeDetail.payMark eq 5'>",
- " price_time,",
- "</when>",
- "real_no) As mz_charge_detail_page",
- ") as A WHERE RowNumber >#{pageSize}*#{pageIndex} order by RowNumber asc",
- "</script>"})
- List<MzChargeDetail> selectMzChargeDetailWithPage(MzChargeDetailPageDto mzChargeDetailPageDto);
- /**
- * 查询收费合计信息
- *
- * @param mzChargeDetailPageDto
- * @return
- */
- @Select({"<script>",
- "select rtrim(patient_id) patient_id,times,receipt_no,rtrim(name) name,price_time," +
- "receipt_sn,sum(unit_price*quantity) amount from mz_charge_detail where 1=1 ",
- "<when test='mzChargeDetail.payMark!=null'>",
- " and pay_mark =#{mzChargeDetail.payMark,jdbcType=CHAR}",
- "</when>",
- "<when test='mzChargeDetail.patientId!=null'>",
- " and patient_id =#{mzChargeDetail.patientId,jdbcType=CHAR}",
- "</when>",
- "<when test='mzChargeDetail.name!=null'>",
- " and name like #{mzChargeDetail.name,jdbcType=CHAR}",
- "</when>",
- "<when test='mzChargeDetail.warnDept!=null'>",
- " and warn_dept = #{mzChargeDetail.warnDept,jdbcType=CHAR}",
- "</when>",
- "<when test='mzChargeDetail.doctorCode!=null'>",
- " and doctor_code =#{mzChargeDetail.doctorCode,jdbcType=CHAR}",
- "</when>",
- "<when test='beginTime!=null'>",
- " and price_time >=#{beginTime,jdbcType=TIMESTAMP}",
- "</when>",
- "<when test='endTime!=null'>",
- " and price_time <=#{endTime,jdbcType=TIMESTAMP}",
- "</when>",
- " group by patient_id,times,receipt_no,name,price_time,receipt_sn",
- "</script>"})
- List<MzChargeDetail> selectMzChargeDetail(MzChargeDetailPageDto mzChargeDetailPageDto);
- /**
- * 查询当前病人的就诊次数对应的最大的处方号
- *
- * @param patientId
- * @param times
- * @return
- */
- @Select("select max(order_no) from mz_charge_detail where patient_id =#{patientId,jdbcType=CHAR} and times =#{times,jdbcType=INTEGER}")
- Integer selectMaxOrderNo(@Param("patientId") String patientId, @Param("times") Integer times);
- /**
- * 查询当前病人的就诊次数对应的已经存在的收费记录(药品记录) 未缴费
- *
- * @param patientId
- * @param times
- * @return
- */
- @Select({"<script>",
- "select rtrim(patient_id) patient_id,times,receipt_no,order_no,item_no,rtrim(charge_item_code) charge_item_code,rtrim(bill_item_code) bill_item_code,",
- "quantity,unit_price,rtrim(pay_mark) pay_mark,rtrim(serial) serial,rtrim(charge_item_type) charge_item_type,rtrim(country_flag) country_flag,rtrim(drug_flag) drug_flag,",
- "serial_no,rtrim(name) name,charge_date,confirm_time,rtrim(group_no) group_no,rtrim(confirm_id) confirm_id,drug_win,rtrim(input_id) input_id,input_date,",
- "rtrim(cashier_id) cashier_id,rtrim(windows_no) windows_no,rtrim(price_id) price_id,price_time,rtrim(exec_dept) exec_dept,rtrim(audit_code) audit_code,",
- "rtrim(gongnks_flag) gongnks_flag,rtrim(print_flag) print_flag,confirm_flag,rtrim(warn_dept) warn_dept,rtrim(jz_flag) jz_flag,group_order,rtrim(cash_id) cash_id,",
- "rtrim(doctor_code) doctor_code,rtrim(supply_code) supply_code,rtrim(frequency) frequency,drug_quan,rtrim(drug_unit) drug_unit,rtrim(doctor_flag) doctor_flag,inject_res,inject_times,",
- "rtrim(confirm_zs) confirm_zs,real_no,windows_no_yf,ybbx_flag,tc_no,tc_name,rtrim(detail_flag) detail_flag,gl_percent,rtrim(order_type) order_type,supply_no,instruction_code,",
- "instruction_text,order_days,rtrim(pay_self) pay_self,rtrim(try_flag) try_flag,rtrim(req_yj) req_yj,req_no,rtrim(group_type) group_type,order_bill,charge_bill_code,",
- "rtrim(self_flag) self_flag,rtrim(responce_type) responce_type,dec_amount,back_serial,input_time,cy_mtjs,cy_jsl,cy_zql,cy_fj,cy_ffcs,cy_fysm,supply_amount,rtrim(cy_jssm) cy_jssm,",
- "dept_no,gl_percent_ft,rtrim(yb_zf_flag) yb_zf_flag,orig_price,rtrim(try_result) try_result,rtrim(supply_exec) supply_exec,rtrim(cy_dj) cy_dj,rtrim(receive_flag) receive_flag,",
- "rtrim(chequ_type) chequ_type,rtrim(print_flag_yj) print_flag_yj,rtrim(confirm_flag_qx) confirm_flag_qx ",
- "from dbo.mz_charge_detail where patient_id =#{patientId,jdbcType=CHAR} and times =#{times,jdbcType=INTEGER} and pay_mark=#{payMark,jdbcType=CHAR} order by order_no desc",
- "</script>"})
- List<MzChargeDetail> selectMzChargeDetailByPatientId(@Param("patientId") String patientId, @Param("times") Integer times, @Param("payMark") String payMark);
- /**
- * 根据当期那病人与就诊次数以及收费编码查询对应的药品数量与退药量
- *
- * @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);
- /**
- * 新增收费明细记录
- *
- * @param mzChargeDetail
- * @return
- */
- @Insert("INSERT INTO mz_charge_detail(patient_id,times,receipt_no,order_no,item_no,charge_item_code,bill_item_code,quantity,unit_price,pay_mark,serial,charge_item_type," +
- "country_flag,drug_flag,serial_no,name,charge_date,confirm_time,group_no,confirm_id,drug_win,input_id,input_date,cashier_id,windows_no,price_id,price_time,exec_dept," +
- "audit_code,gongnks_flag,print_flag,confirm_flag,warn_dept,jz_flag,group_order,cash_id,doctor_code,supply_code,frequency,drug_quan,drug_unit,doctor_flag,inject_res,inject_times," +
- "confirm_zs,real_no,windows_no_yf,ybbx_flag,tc_no,tc_name,detail_flag,gl_percent,order_type,supply_no,instruction_code,instruction_text,order_days,pay_self,try_flag,req_yj," +
- "req_no,group_type,order_bill,charge_bill_code,self_flag,responce_type,dec_amount,back_serial,input_time,cy_mtjs,cy_jsl,cy_zql,cy_fj,cy_ffcs,cy_fysm,supply_amount,cy_jssm," +
- "dept_no,gl_percent_ft,yb_zf_flag,orig_price,try_result,supply_exec,cy_dj,receive_flag,chequ_type,print_flag_yj,confirm_flag_qx) " +
- " VALUES (#{patientId,jdbcType=CHAR},#{times,jdbcType=INTEGER},#{receiptNo,jdbcType=SMALLINT},#{orderNo,jdbcType=TINYINT},#{itemNo,jdbcType=TINYINT}," +
- "#{chargeItemCode,jdbcType=CHAR},#{billItemCode,jdbcType=CHAR},#{quantity,jdbcType=DOUBLE},#{unitPriceStr,jdbcType=DECIMAL},#{payMark,jdbcType=CHAR}," +
- "#{serial,jdbcType=CHAR},#{chargeItemType,jdbcType=CHAR},#{countryFlag,jdbcType=CHAR},#{drugFlag,jdbcType=CHAR},#{serialNo,jdbcType=INTEGER},#{name,jdbcType=CHAR}," +
- "#{chargeDate,jdbcType=TIMESTAMP},#{confirmTime,jdbcType=TIMESTAMP},#{groupNo,jdbcType=CHAR},#{confirmId,jdbcType=CHAR},#{drugWin,jdbcType=TINYINT},#{inputId,jdbcType=CHAR}," +
- "#{inputDate,jdbcType=TIMESTAMP},#{cashierId,jdbcType=CHAR},#{windowsNo,jdbcType=CHAR},#{priceId,jdbcType=CHAR},#{priceTime,jdbcType=TIMESTAMP},#{execDept,jdbcType=CHAR}," +
- "#{auditCode,jdbcType=CHAR},#{gongnksFlag,jdbcType=CHAR},#{printFlag,jdbcType=CHAR},#{confirmFlag,jdbcType=INTEGER},#{warnDept,jdbcType=CHAR},#{jzFlag,jdbcType=CHAR}," +
- "#{groupOrder,jdbcType=SMALLINT},#{cashId,jdbcType=CHAR},#{doctorCode,jdbcType=CHAR},#{supplyCode,jdbcType=CHAR},#{frequency,jdbcType=CHAR},#{drugQuan,jdbcType=DOUBLE}," +
- "#{drugUnit,jdbcType=CHAR},#{doctorFlag,jdbcType=CHAR},#{injectRes,jdbcType=DOUBLE},#{injectTimes,jdbcType=SMALLINT},#{confirmZs,jdbcType=CHAR},#{realNo,jdbcType=INTEGER}," +
- "#{windowsNoYf,jdbcType=VARCHAR},#{ybbxFlag,jdbcType=VARCHAR},#{tcNo,jdbcType=VARCHAR},#{tcName,jdbcType=VARCHAR},#{detailFlag,jdbcType=CHAR},#{glPercent,jdbcType=DECIMAL}," +
- "#{orderType,jdbcType=CHAR},#{supplyNo,jdbcType=VARCHAR},#{instructionCode,jdbcType=VARCHAR},#{instructionText,jdbcType=VARCHAR},#{orderDays,jdbcType=SMALLINT}," +
- "#{paySelf,jdbcType=CHAR},#{tryFlag,jdbcType=CHAR},#{reqYj,jdbcType=CHAR},#{reqNo,jdbcType=INTEGER},#{groupType,jdbcType=CHAR},#{orderBill,jdbcType=SMALLINT}," +
- "#{chargeBillCode,jdbcType=VARCHAR},#{selfFlag,jdbcType=CHAR},#{responceType,jdbcType=CHAR},#{decAmount,jdbcType=DECIMAL},#{backSerial,jdbcType=INTEGER},#{inputTime,jdbcType=TIMESTAMP}," +
- "#{cyMtjs,jdbcType=SMALLINT},#{cyJsl,jdbcType=SMALLINT},#{cyZql,jdbcType=SMALLINT},#{cyFj,jdbcType=SMALLINT},#{cyFfcs,jdbcType=SMALLINT},#{cyFysm,jdbcType=SMALLINT}," +
- "#{supplyAmount,jdbcType=SMALLINT},#{cyJssm,jdbcType=CHAR},#{deptNo,jdbcType=VARCHAR},#{glPercentFt,jdbcType=DECIMAL},#{ybZfFlag,jdbcType=CHAR},#{origPriceStr,jdbcType=DECIMAL}," +
- "#{tryResult,jdbcType=CHAR},#{supplyExec,jdbcType=CHAR},#{cyDj,jdbcType=CHAR},#{receiveFlag,jdbcType=CHAR},#{chequType,jdbcType=CHAR},#{printFlagYj,jdbcType=CHAR},#{confirmFlagQx,jdbcType=CHAR}) ")
- int insertMzChargeDetail(MzChargeDetail mzChargeDetail);
- /**
- * 批量保存门诊收费明细记录
- *
- * @param mzChargeDetails
- * @return
- */
- @Insert({
- "<script>",
- "INSERT INTO mz_charge_detail(patient_id,times,receipt_no,order_no,item_no,charge_item_code,bill_item_code,quantity,unit_price,pay_mark,serial,charge_item_type,",
- "country_flag,drug_flag,serial_no,name,charge_date,confirm_time,group_no,confirm_id,drug_win,input_id,input_date,cashier_id,windows_no,price_id,price_time,exec_dept,",
- "audit_code,gongnks_flag,print_flag,confirm_flag,warn_dept,jz_flag,group_order,cash_id,doctor_code,supply_code,frequency,drug_quan,drug_unit,doctor_flag,inject_res,inject_times,",
- "confirm_zs,real_no,windows_no_yf,ybbx_flag,tc_no,tc_name,detail_flag,gl_percent,order_type,supply_no,instruction_code,instruction_text,order_days,pay_self,try_flag,req_yj,",
- "req_no,group_type,order_bill,charge_bill_code,self_flag,responce_type,dec_amount,back_serial,input_time,cy_mtjs,cy_jsl,cy_zql,cy_fj,cy_ffcs,cy_fysm,supply_amount,cy_jssm,",
- "dept_no,gl_percent_ft,yb_zf_flag,orig_price,try_result,supply_exec,cy_dj,receive_flag,chequ_type,print_flag_yj,confirm_flag_qx) VALUES ",
- "<foreach collection='mzChargeDetails' item='item' index='index' separator=','>",
- " (#{item.patientId,jdbcType=CHAR},#{item.times,jdbcType=INTEGER},#{item.receiptNo,jdbcType=SMALLINT},#{item.orderNo,jdbcType=TINYINT},#{item.itemNo,jdbcType=TINYINT},",
- "#{item.chargeItemCode,jdbcType=CHAR},#{item.billItemCode,jdbcType=CHAR},#{item.quantity,jdbcType=DOUBLE},#{item.unitPriceStr,jdbcType=DECIMAL},#{item.payMark,jdbcType=CHAR},",
- "#{item.serial,jdbcType=CHAR},#{item.chargeItemType,jdbcType=CHAR},#{item.countryFlag,jdbcType=CHAR},#{item.drugFlag,jdbcType=CHAR},#{item.serialNo,jdbcType=INTEGER},#{item.name,jdbcType=CHAR},",
- "#{item.chargeDate,jdbcType=TIMESTAMP},#{item.confirmTime,jdbcType=TIMESTAMP},#{item.groupNo,jdbcType=CHAR},#{item.confirmId,jdbcType=CHAR},#{item.drugWin,jdbcType=TINYINT},#{item.inputId,jdbcType=CHAR},",
- "#{item.inputDate,jdbcType=TIMESTAMP},#{item.cashierId,jdbcType=CHAR},#{item.windowsNo,jdbcType=CHAR},#{item.priceId,jdbcType=CHAR},#{item.priceTime,jdbcType=TIMESTAMP},#{item.execDept,jdbcType=CHAR},",
- "#{item.auditCode,jdbcType=CHAR},#{item.gongnksFlag,jdbcType=CHAR},#{item.printFlag,jdbcType=CHAR},#{item.confirmFlag,jdbcType=INTEGER},#{item.warnDept,jdbcType=CHAR},#{item.jzFlag,jdbcType=CHAR},",
- "#{item.groupOrder,jdbcType=SMALLINT},#{item.cashId,jdbcType=CHAR},#{item.doctorCode,jdbcType=CHAR},#{item.supplyCode,jdbcType=CHAR},#{item.frequency,jdbcType=CHAR},#{item.drugQuan,jdbcType=DOUBLE},",
- "#{item.drugUnit,jdbcType=CHAR},#{item.doctorFlag,jdbcType=CHAR},#{item.injectRes,jdbcType=DOUBLE},#{item.injectTimes,jdbcType=SMALLINT},#{item.confirmZs,jdbcType=CHAR},#{item.realNo,jdbcType=INTEGER},",
- "#{item.windowsNoYf,jdbcType=VARCHAR},#{item.ybbxFlag,jdbcType=VARCHAR},#{item.tcNo,jdbcType=VARCHAR},#{item.tcName,jdbcType=VARCHAR},#{item.detailFlag,jdbcType=CHAR},#{item.glPercent,jdbcType=DECIMAL},",
- "#{item.orderType,jdbcType=CHAR},#{item.supplyNo,jdbcType=VARCHAR},#{item.instructionCode,jdbcType=VARCHAR},#{item.instructionText,jdbcType=VARCHAR},#{item.orderDays,jdbcType=SMALLINT},",
- "#{item.paySelf,jdbcType=CHAR},#{item.tryFlag,jdbcType=CHAR},#{item.reqYj,jdbcType=CHAR},#{item.reqNo,jdbcType=INTEGER},#{item.groupType,jdbcType=CHAR},#{item.orderBill,jdbcType=SMALLINT},",
- "#{item.chargeBillCode,jdbcType=VARCHAR},#{item.selfFlag,jdbcType=CHAR},#{item.responceType,jdbcType=CHAR},#{item.decAmount,jdbcType=DECIMAL},#{item.backSerial,jdbcType=INTEGER},#{item.inputTime,jdbcType=TIMESTAMP},",
- "#{item.cyMtjs,jdbcType=SMALLINT},#{item.cyJsl,jdbcType=SMALLINT},#{item.cyZql,jdbcType=SMALLINT},#{item.cyFj,jdbcType=SMALLINT},#{item.cyFfcs,jdbcType=SMALLINT},#{item.cyFysm,jdbcType=SMALLINT},",
- "#{item.supplyAmount,jdbcType=SMALLINT},#{item.cyJssm,jdbcType=CHAR},#{item.deptNo,jdbcType=VARCHAR},#{item.glPercentFt,jdbcType=DECIMAL},#{item.ybZfFlag,jdbcType=CHAR},#{item.origPriceStr,jdbcType=DECIMAL},",
- "#{item.tryResult,jdbcType=CHAR},#{item.supplyExec,jdbcType=CHAR},#{item.cyDj,jdbcType=CHAR},#{item.receiveFlag,jdbcType=CHAR},#{item.chequType,jdbcType=CHAR},#{item.printFlagYj,jdbcType=CHAR},#{item.confirmFlagQx,jdbcType=CHAR}) ",
- "</foreach>",
- "</script>"
- })
- int batchInsertMzChargeDetail(@Param(value = "mzChargeDetails") List<MzChargeDetail> mzChargeDetails);
- /**
- * 查询近三天内没有缴费的药品处方
- *
- * @param patientId
- * @return
- */
- @Select({"<script>",
- "select rtrim(patient_id) patient_id,times =times,doctor_code=min(doctor_code), cf_type='1', order_count=count(distinct order_no), receipt_no =min(receipt_no),visit_date =min(price_time)," +
- "name=min(name) from mz_charge_detail where 1=1",
- "<when test='patientId!=null'>",
- " and patient_id=#{patientId,jdbcType=CHAR}",
- "</when>",
- " and pay_mark='5' and (datediff(day,price_time,getdate()) <![CDATA[ <= ]]> 3) group by patient_id,times",
- "</script>"})
- List<Map<String, Object>> selectUnPaidChargeDetail(@Param(value = "patientId") String patientId);
- /**
- * 修改当前病人当前就诊次数下的所有记录的付款状态和打印标记以及确认标记
- *
- * @param mzChargeDetail
- * @return
- */
- @Update({"<script>",
- "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>",
- "<when test='printFlag!=null'>",
- ",print_flag =#{printFlag,jdbcType=CHAR}",
- "</when>",
- "<when test='receiptNo!=null'>",
- ",receipt_no =#{receiptNo,jdbcType=INTEGER}",
- "</when>",
- "<when test='confirmFlag!=null'>",
- ",confirm_flag =#{confirmFlag,jdbcType=CHAR}",
- "</when>",
- "</trim>",
- "</script>"})
- int updatePayMakAndPrintFlag(MzChargeDetail mzChargeDetail);
- /**
- * 修改缴费明细记录
- *
- * @param mzChargeDetail
- * @return
- */
- @Update({"<script>",
- "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}",
- "</when>",
- "<when test='realNo!=null'>",
- ",real_no =#{realNo,jdbcType=INTEGER}",
- "</when>",
- "<when test='cashId!=null'>",
- ",cash_id =#{cashId,jdbcType=CHAR}",
- "</when>",
- "<when test='chargeDate!=null'>",
- ",charge_date =#{chargeDate,jdbcType=TIMESTAMP}",
- "</when>",
- "<when test='payMark!=null'>",
- ",pay_mark =#{payMark,jdbcType=CHAR}",
- "</when>",
- "<when test='printFlag!=null'>",
- ",print_flag =#{printFlag,jdbcType=CHAR}",
- "</when>",
- "<when test='windowsNoYf!=null'>",
- ",windows_no_yf =#{windowsNoYf,jdbcType=VARCHAR}",
- "</when>",
- "<when test='backSerial!=null'>",
- ",back_serial =#{backSerial,jdbcType=INTEGER}",
- "</when>",
- "</trim>",
- "</script>"})
- int updateMzChargeDetail(MzChargeDetail mzChargeDetail);
- /**
- * 查询所有的记账记录
- *
- * @param patientId
- * @param times
- * @return
- */
- @Select({"<script>",
- "select rtrim(patient_id) patient_id,times,receipt_no,order_no,item_no,rtrim(charge_item_code) charge_item_code,rtrim(bill_item_code) bill_item_code,",
- "quantity,unit_price,rtrim(pay_mark) pay_mark,rtrim(serial) serial,rtrim(charge_item_type) charge_item_type,rtrim(country_flag) country_flag,rtrim(drug_flag) drug_flag,",
- "serial_no,rtrim(name) name,charge_date,confirm_time,rtrim(group_no) group_no,rtrim(confirm_id) confirm_id,drug_win,rtrim(input_id) input_id,input_date,",
- "rtrim(cashier_id) cashier_id,rtrim(windows_no) windows_no,rtrim(price_id) price_id,price_time,rtrim(exec_dept) exec_dept,rtrim(audit_code) audit_code,",
- "rtrim(gongnks_flag) gongnks_flag,rtrim(print_flag) print_flag,confirm_flag,rtrim(warn_dept) warn_dept,rtrim(jz_flag) jz_flag,group_order,rtrim(cash_id) cash_id,",
- "rtrim(doctor_code) doctor_code,rtrim(supply_code) supply_code,rtrim(frequency) frequency,drug_quan,rtrim(drug_unit) drug_unit,rtrim(doctor_flag) doctor_flag,inject_res,inject_times,",
- "rtrim(confirm_zs) confirm_zs,real_no,windows_no_yf,ybbx_flag,tc_no,tc_name,rtrim(detail_flag) detail_flag,gl_percent,rtrim(order_type) order_type,supply_no,instruction_code,",
- "instruction_text,order_days,rtrim(pay_self) pay_self,rtrim(try_flag) try_flag,rtrim(req_yj) req_yj,req_no,rtrim(group_type) group_type,order_bill,charge_bill_code,",
- "rtrim(self_flag) self_flag,rtrim(responce_type) responce_type,dec_amount,back_serial,input_time,cy_mtjs,cy_jsl,cy_zql,cy_fj,cy_ffcs,cy_fysm,supply_amount,rtrim(cy_jssm) cy_jssm,",
- "dept_no,gl_percent_ft,rtrim(yb_zf_flag) yb_zf_flag,orig_price,rtrim(try_result) try_result,rtrim(supply_exec) supply_exec,rtrim(cy_dj) cy_dj,rtrim(receive_flag) receive_flag,",
- "rtrim(chequ_type) chequ_type,rtrim(print_flag_yj) print_flag_yj,rtrim(confirm_flag_qx) confirm_flag_qx ",
- "from dbo.mz_charge_detail where patient_id =#{patientId,jdbcType=CHAR} and pay_mark=0 and times =#{times} and receipt_no =#{receiptNo} ",
- "</script>"})
- List<MzChargeDetail> selectJiZhangDetails(@Param(value = "patientId") String patientId, @Param("times") Integer times, @Param("receiptNo") Integer receiptNo);
- /**
- * 查询当前就诊次数的所有取药号与药房信息
- *
- * @param patientId
- * @param times
- * @return
- */
- @Select("select back_serial,rtrim(group_no) group_no,windows_no_yf from mz_charge_detail where patient_id=#{patientId,jdbcType=CHAR} and times = #{times,jdbcType=INTEGER} and back_serial>0 group by back_serial,group_no,windows_no_yf")
- List<MzChargeDetail> selectFyJl(@Param("patientId") String patientId, @Param("times") Integer times);
- /**
- * 修改发票打印标记
- *
- * @param patientId
- * @param times
- * @return
- */
- @Update({"<script>",
- "update mz_charge_detail set print_flag =1 where patient_id = #{patientId} and times in ",
- "<foreach item='item' index='index' collection='times' open='(' separator=',' close=')'>",
- "#{item}",
- "</foreach>",
- "</script>"})
- int updatePrintFlag(@Param("patientId") String patientId, @Param("times") List<Integer> times);
- /**
- * 修改发票流水号与缴费次数 发票作废重打时调用
- *
- * @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);
- /**
- * 修改病人姓名 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);
- /**
- * 查询病人缴费记录
- *
- * @param patientId
- * @param name
- * @param serialNo
- * @param beginDate
- * @param endDate
- * @return
- */
- @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'>",
- " and a.patient_id like #{patientId}",
- "</when>",
- "<when test='name!=null'>",
- " and a.name like #{name}",
- "</when>",
- "<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);
- /**
- * 根据病人编码和收费流水号查询缴费明细
- *
- * @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," +
- " print_flag = (select max(cheque_type) from mz_receipt_serial where mz_receipt_serial.receipt_sn = a.real_no) " +
- " FROM mz_charge_detail a,yp_zd_dict 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," +
- " print_flag = (select max(cheque_type) from mz_receipt_serial where mz_receipt_serial.receipt_sn = a.real_no) " +
- " FROM mz_charge_detail a,zd_charge_item 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>> selectChargeDetailByPatient(@Param("patientId") String patientId, @Param("serialNo") String serialNo);
- /**
- * 查询病人缴费记录 (历史数据)
- *
- * @param patientId
- * @param name
- * @param serialNo
- * @param beginDate
- * @param endDate
- * @return
- */
- @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_b.cheque_type='Y' " +
- " and len(ltrim(rtrim(mz_receipt_serial_b.receipt_bill))) <![CDATA[>=]]> 10 then '本院记账' else '自费' end " +
- " FROM mz_charge_detail_b a,mz_receipt_serial_b " +
- " WHERE a.charge_date <![CDATA[>=]]> #{beginDate,jdbcType=TIMESTAMP} and a.charge_date <![CDATA[<=]]> #{endDate,jdbcType=TIMESTAMP} " +
- "<when test='patientId!=null'>",
- " and a.patient_id =#{patientId}",
- "</when>",
- "<when test='name!=null'>",
- " and a.name like #{name}",
- "</when>",
- "<when test='serialNo!=null'>",
- " and mz_receipt_serial_b.serial_no =#{serialNo}",
- "</when>",
- " 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);
- /**
- * 根据病人编码和收费流水号查询缴费明细 (历史数据)
- *
- * @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);
- /**
- * 根据病人就诊次数和门诊号查询有效的申请科室和医生编码
- *
- * @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);
- /**
- * 清洗老系统打印发票数据
- *
- * @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)")
- int refshOldSystemReceiptData();
- /**
- * 查询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);
- /**
- *
- * @param thmzmxsrParamsVo caseType = 1 申请科室核算报表 0 执行科室核算报表
- * @return
- */
- @Select({"<script>",
- "SELECT " +
- " exec_dept= z.name," +
- " 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= case when (b.pay_id ='99999' and b.charge_dcount_date <![CDATA[<=]]> '2021-12-01 23:59:59') then isnull(sum(round(convert(decimal(18,2),((convert(decimal(18,2),unit_price)) * (quantity * isnull(drug_win,1)))),2)),0) else isnull(sum(round(convert(decimal(18,3),((convert(decimal(18,3),unit_price)) * (quantity * isnull(drug_win,1)))),2)),0) end ," +
- " 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,pay_id 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, zd_unit_code z " +
- " 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 ( 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 )*=z.code " +
- // " and isnull(a.dept_no,'') like '%' " +
- "<when test='execDept!=null'>",
- " 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} " +
- "</when>" +
- "group by " +
- "z.name,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,b.pay_id ",
- "</script>"})
- List<Map<String, Object>> selectDepetBusinessReport(ThmzmxsrParamsVo thmzmxsrParamsVo);
- }
|