package cn.hnthyy.thmz.service.his.mz;


import cn.hnthyy.thmz.entity.MzException;
import cn.hnthyy.thmz.entity.his.mz.MzReceiptSerial;
import cn.hnthyy.thmz.entity.thmz.User;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

public interface MzReceiptSerialService {
    /**
     * 查询当前病人的所有记账费用明细
     *
     * @param patientId
     * @return
     */
    List<MzReceiptSerial> queryTallyReceiptSerial(String patientId);

    /**
     * 查询当前病人的所有记账费用
     *
     * @param patientId
     * @return
     */
    BigDecimal queryTallyTotalCharge(String patientId);

    /**
     * 新增门诊发票记录
     *
     * @param mzReceiptSerial
     * @return
     */
    int saveMzReceiptSerial(MzReceiptSerial mzReceiptSerial);


    /**
     * 批量保存门诊发票记录
     *
     * @param mzReceiptSerials
     * @return
     */
    int batchSaveMzReceiptSerial(List<MzReceiptSerial> mzReceiptSerials);

    /**
     * 根据病人编号和就诊次数查询其当次缴费对应的所有发票
     *
     * @param patientId
     * @param times
     * @return
     */
    MzReceiptSerial queryAllSerialForThisTime(String patientId, Integer times,Integer receiptNo);


    /**
     * 根据病人编号和就诊次数查询其当次缴费已经打印的发票
     *
     * @param patientId
     * @param times
     * @return
     */
    List<MzReceiptSerial> queryPrintedSerialForThisTime(String patientId, Integer times,String receiptBill);

    /**
     * 根据就诊次数查询当前病人的记账费用明细
     *
     * @param patientId
     * @return
     */
    List<MzReceiptSerial> queryTallyReceiptSerialByIdAndTimes(String patientId, Integer times,Integer receiptNo);

    /**打印发票
     * @param mzReceiptSerial
     * @param user
     * @return
     */
    String printReceiptSerial(MzReceiptSerial mzReceiptSerial,User user) throws MzException;


    /**
     * 根据机制号查询发票信息
     *
     * @param serialNo
     * @return
     */
    MzReceiptSerial queryReceiptSerialBySerialNo(Integer serialNo);
    /**
     * 根据发票流水号查询发票信息
     *
     * @param receiptSn
     * @return
     */
    MzReceiptSerial queryReceiptDetailsByReceiptSn(Integer receiptSn);



    /**
     * 作废当前发票并重新打印发票
     * @param mzReceiptSerial 需要作废的发票
     * @param user
     * @return
     */
    String obsoleteAndRepPrint(MzReceiptSerial mzReceiptSerial, User user) throws MzException;


    /**
     * 查询病人缴费记录
     *
     * @param patientIds
     * @param serialNo
     * @param beginDate
     * @param endDate
     * @return
     */
    List<Map<String, Object>> queryChargeListByPatient(List<String> patientIds, String serialNo, Date beginDate, Date endDate, String tableName);


    /**
     * 查询病人当天的费用
     * @param beginDate
     * @param endDate
     * @param patientId
     * @return
     */
    BigDecimal querySumByPatientId(String beginDate, String endDate,String patientId);

    /**
     * 修复数据从备份库
     * @param patientId
     * @param times
     * @param receiptNo
     * @return
     */
    int repairDataFromBack(String patientId, Integer times,Integer receiptNo);

}
