package cn.hnthyy.thmz.mapper.his.yz;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

public interface YzZyPatientFeeMapper {

    /**
     * 查询医嘱住院接口表中的住院明细
     *
     * @param inpatientNo 住院号
     * @param admissTimes 住院次数
     * @param infantFlag  是否婴儿
     * @return
     */
    @Select({"<script>",
            "SELECT " +
                    " rtrim(inpatient_no) inpatientNo, " +
                    " admiss_times admissTimes, " +
                    " chargeDate = occ_time, " +
                    " rtrim(charge_code) chargeCode, " +
                    " infant_flag infantFlag, " +
                    " chargeStatus = " +
                    "CASE " +
                    "   " +
                    "  WHEN charge_status = '3' THEN " +
                    "  '8'  " +
                    "  WHEN charge_status = '2' THEN " +
                    "  '7' ELSE '6'  " +
                    " END, " +
                    " chargeFee = round( charge_fee * order_count, 2 ), " +
                    " self_flag selfFlag, " +
                    " separate_flag separateFlag, " +
                    " suppress_flag suppressFlag, " +
                    " ward_code wardCode, " +
                    " dept_code deptCode, " +
                    " orderNo = abs( act_order_no ), " +
                    " opFlag = '0', " +
                    " execUnit = exec_unit, " +
                    " chargeAmount = order_count  " +
                    "FROM " +
                    " yz_zy_patient_fee ( nolock )  " +
                    "WHERE " +
                    " inpatient_no = #{inpatientNo}  " +
                    " AND admiss_times = #{admissTimes}  " +
                    " AND charge_status IN ( '1', '2', '3', '5' )  " +
                    " AND infant_flag =#{infantFlag}"
            , "</script>"})
    List<Map<String, Object>> selectZyDetailChargesFromYzZyPatientFee(@Param("inpatientNo") String inpatientNo, @Param("admissTimes") Integer admissTimes, @Param("infantFlag") String infantFlag);
}
