package thyyxxk.webserver.entity.datamodify;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import thyyxxk.webserver.utils.StringUtil;

import java.io.Serializable;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Date;
import java.util.List;

@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class MzChargeDetail implements Serializable {

    private static final long serialVersionUID = 6955612389655007957L;

    private String chargeCode;
    private BigDecimal chargeFee;
    private BigDecimal chargeFeeNew;
    private Double chargeAmount;
    private String chargeCodeMx;
    private Integer detailSn;

    @JsonInclude(JsonInclude.Include.NON_NULL)
    @TableField(exist = false)
    private long currentPage;

    @JsonInclude(JsonInclude.Include.NON_NULL)
    @TableField(exist = false)
    private long pageSize;

    /**
     * patientId
     */
    private String patientId;

    /**
     * times
     */
    private Integer times;

    /**
     * receiptNo
     */
    private Integer receiptNo;

    /**
     * orderNo
     */
    private Integer orderNo;

    private BigDecimal drugWin;

    /**
     * itemNo
     */
    private Integer itemNo;

    /**
     * chargeItemCode
     */
    private String chargeItemCode;

    /**
     * billItemCode
     * 项目类型
     */
    private String billItemCode;

    /**
     * quantity
     */
    private BigDecimal quantity;

    /**
     * unitPrice
     */
    private BigDecimal unitPrice;

    /**
     * payMark
     */
    private String payMark;

    /**
     * serial
     */
    private String serial;

    /**
     * chargeItemType
     */
    private String chargeItemType;

    /**
     * countryFlag
     */
    private String countryFlag;

    /**
     * drugFlag
     */
    private String drugFlag;

    /**
     * serialNo
     */
    private Integer serialNo;

    /**
     * name
     */
    private String name;

    /**
     * chargeDate
     */
    private Date chargeDate;
    private String chargeDateString;

    /**
     * confirmTime
     */
    private Date confirmTime;

    /**
     * groupNo
     */
    private String groupNo;

    /**
     * confirmId
     */
    private String confirmId;

    /**
     * inputId
     */
    private String inputId;

    /**
     * inputDate
     */
    private Date inputDate;

    /**
     * cashierId
     */
    private String cashierId;

    /**
     * windowsNo
     */
    private String windowsNo;

    /**
     * priceId
     */
    private String priceId;

    /**
     * priceTime
     */
    private Date priceTime;
    /**
     * execDept
     * 执行科室
     */
    private String execDept;
    /**
     * auditCode
     */
    private String auditCode;
    /**
     * gongnksFlag
     */
    private String gongnksFlag;
    /**
     * printFlag
     */
    private String printFlag;
    /**
     * responseType
     */
    private String responseType;
    /**
     * confirmFlag  标识:1确认发药 医技确认 2.打印药品清单 3.配药确认
     */
    private Integer confirmFlag;
    private Integer oldConfirmFlag;
    /**
     * warnDept
     * 应该是科室
     */
    private String warnDept;
    /**
     * ledYf
     */
    private String ledYf;
    /**
     * jzFlag
     */
    private String jzFlag;
    /**
     * groupOrder
     */
    private Integer groupOrder;
    /**
     * cashId
     */
    private String cashId;
    /**
     * doctorCode
     * 医生code
     */
    private String doctorCode;
    /**
     * supplyCode
     */
    private String supplyCode;
    /**
     * frequency
     */
    private String frequency;
    /**
     * drugQuan
     */
    private BigDecimal drugQuan;
    /**
     * drugUnit
     */
    private String drugUnit;
    /**
     * drugUnitName
     */
    private String drugUnitName;
    /**
     * doctorFlag
     */
    private String doctorFlag;
    /**
     * injectRes
     */
    private Double injectRes;
    /**
     * injectTimes
     */
    private Integer injectTimes;
    /**
     * confirmZs
     */
    private String confirmZs;
    /**
     * realNo
     */
    private Integer realNo;
    /**
     * windowsNoYf
     */
    private String windowsNoYf;
    /**
     * ybbxFlag
     */
    private String ybbxFlag;
    /**
     * tcNo
     */
    private String tcNo;
    /**
     * tcName
     */
    private String tcName;
    /**
     * detailFlag
     */
    private String detailFlag;
    /**
     * glPercent
     */
    private String glPercent;
    /**
     * orderType
     */
    private String orderType;
    /**
     * supplyNo
     */
    private String supplyNo;
    /**
     * instructionCode
     */
    private String instructionCode;
    /**
     * instructionText
     */
    private String instructionText;
    /**
     * orderDays
     */
    private Integer orderDays;
    /**
     * paySelf
     */
    private String paySelf;
    /**
     * tryFlag
     */
    private String tryFlag;
    /**
     * reqYj
     */
    private String reqYj;
    /**
     * reqNo
     */
    private Integer reqNo;
    /**
     * groupType
     */
    private String groupType;
    /**
     * orderBill
     */
    private Integer orderBill;
    /**
     * chargeBillCode
     */
    private String chargeBillCode;
    /**
     * selfFlag
     */
    private String selfFlag;
    /**
     * responceType
     */
    private String responceType;
    /**
     * decAmount
     */
    private String decAmount;
    /**
     * backSerial
     */
    private Integer backSerial;
    /**
     * inputTime
     */
    private Date inputTime;
    /**
     * cyMtjs
     */
    private Integer cyMtjs;
    /**
     * cyJsl
     */
    private Integer cyJsl;
    /**
     * cyZql
     */
    private Integer cyZql;
    /**
     * cyFj
     */
    private Integer cyFj;
    /**
     * cyFfcs
     */
    private Integer cyFfcs;
    /**
     * cyFysm
     */
    private Integer cyFysm;
    /**
     * supplyAmount
     */
    private Integer supplyAmount;
    /**
     * cyJssm
     */
    private String cyJssm;
    /**
     * deptNo
     */
    private String deptNo;
    /**
     * glPercentFt
     */
    private Double glPercentFt;
    /**
     * ybZfFlag
     */
    private String ybZfFlag;
    /**
     * origPrice
     */
    private String origPrice;
    /**
     * tryResult
     */
    private String tryResult;
    /**
     * supplyExec
     */
    private String supplyExec;
    /**
     * cyDj
     */
    private String cyDj;
    /**
     * receiveFlag
     */
    private String receiveFlag;
    /**
     * chequType
     */
    private String chequType;
    /**
     * printFlagYj
     */
    private String printFlagYj;
    /**
     * confirmFlagQx
     */
    private String confirmFlagQx;
    /**
     * ybType
     */
    private String ybType;
    /**
     * 金额
     */
    private BigDecimal consumption;
    /**
     * 输入人姓名
     */
    private String patientName;
    /**
     * 项目名称
     */
    private String itemName;

    // 一下都是通过急门诊费用转入 通过机制号 转入的
    /**
     * 单列标志
     */
    private String separateFlag;
    /**
     * 贵重标志
     */
    private String suppressFlag;
    /**
     * 金额
     */
    private BigDecimal price;
    /**
     * 总价
     */
    private BigDecimal pricechargeFee;
    /**
     * 写死的不知道是什么
     */
    private String checkFlag;
    private String icCardNo;
    private Date birthDay;
    private String phoneNo;
    private Integer sex;
    private String adress;
    private String age;
    private BigDecimal accountBalance;
    private String contractCode;
    private String chargeType;
    private String chargeName;
    private BigDecimal je;
    private String execDeptName;
    private String confirmIdName;
    private Integer xiangMuZhuangTai;
    private List<MzChargeDetail> list;
    private List<Integer> reqNos;
    /**
     * 来源 对外接口时 使用
     */
    private String source;

    private BigDecimal chargeQuantity;

    public BigDecimal getChargeQuantity() {
        return (null == quantity ? BigDecimal.ONE : quantity).multiply(null == drugWin ? BigDecimal.ONE : drugWin);
    }

    /**
     * 获取金额
     *
     * @return
     */
    public BigDecimal getChargeFee() {
        return getChargeQuantity().multiply(unitPrice == null ? BigDecimal.ZERO : unitPrice).setScale(2, RoundingMode.HALF_UP);
    }

    /**
     * 不知道为什么有这样的数据
     *
     * @return null 字符串返回 空
     */
    public String getExecDept() {
        if (StringUtil.isBlank(execDept)) {
            return null;
        }
        if ("null".equals(execDept)) {
            return null;
        }
        return execDept;
    }

    public Integer getOldConfirmFlag() {
        return confirmFlag;
    }
}
