package thyyxxk.webserver.entity.markmtfees;

import lombok.Data;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Date;

/**
 * @author dj
 */
@Data
public class MzReceipt {
    private String drugName;
    private String patientId;
    private Integer times;
    private Integer receiptNo;
    private Integer orderNo;
    private Integer itemNo;
    private String chargeItemCode;
    private String chargeBillCode;
    private Double quantity;
    private BigDecimal unitPrice;
    private Integer payMark;
    private String serial;
    private String serialNo;
    private String frequency;
    private Double drugQuan;
    private String drugUnit;
    private String supplyCode;
    private Integer orderDays;
    private String chargeDate;
    /**
     * 00 项目，其他 药品
     * */
    private String groupNo;
    private String specification;
    private Integer confirmFlag;
    private String instructionText;
    private Integer drugWin;
    private String priceTime;
    private String dosage;
    private String mediItemType;
    private String billItemCode;
    private String doctorCode;
    private String doctorName;
    private String name;
    private String responceType;
    private String tcNo;
    private String tcName;
    private BigDecimal price;
    private BigDecimal chargeFee;
    private Boolean checked;
    private String nationalCode;
    private String ybComment;
    private String hospApprFlag;

    public String getDrugName() {
        return null == drugName ? "" : (drugName).trim();
    }

    public String getPatientId() {
        return null == patientId ? "" : (patientId).trim();
    }

    public String getChargeItemCode() {
        return null == chargeItemCode ? "" : (chargeItemCode).trim();
    }

    public String getChargeBillCode() {
        return null == chargeBillCode ? "" : (chargeBillCode).trim();
    }

    public String getSerial() {
        return null == serial ? "" : (serial).trim();
    }

    public String getSerialNo() {
        return null == serialNo ? "" : (serialNo).trim();
    }

    public String getGroupNo() {
        return null == groupNo ? "" : (groupNo).trim();
    }

    public String getSpecification() {
        return null == specification ? "" : (specification).trim();
    }

    public String getDosage() {
        return null == dosage ? "" : (dosage).trim();
    }

    public String getDoctorCode() {
        return null == doctorCode ? "" : (doctorCode).trim();
    }

    public String getName() {
        return null == name ? "" : (name).trim();
    }

    public String getResponceType() {
        return null == responceType ? "" : (responceType).trim();
    }

    public String getTcNo() {
        return null == tcNo ? "" : (tcNo).trim();
    }

    public String getTcName() {
        return null == tcName ? "" : (tcName).trim();
    }

    public String getMediItemType() {
        if ("TC".equals(billItemCode.trim())) {
            return "TC";
        }
        switch (billItemCode.trim()) {
            // 西药
            case "010":
            case "1":
                return "1";
            // 中成药
            case "011":
            case "2":
                return "2";
            // 中草药
            case "012":
            case "3":
                return "3";
            // 其他
            default:
                return "0";
        }
    }

    public String getBillItemCode() {
        return null == billItemCode ? "" : (billItemCode).trim();
    }

    public BigDecimal getPrice() {
        BigDecimal price= (getUnitPrice() == null ? BigDecimal.ZERO : getUnitPrice()).setScale(2, RoundingMode.HALF_UP);
        return price.multiply(BigDecimal.valueOf(getDrugWin() == null ? 1D : getDrugWin()));
    }

    public BigDecimal getChargeFee() {
        return getPrice().multiply(BigDecimal.valueOf(getQuantity() == null ? 1D : getQuantity()));
    }

    public Boolean getChecked() {
        return null != checked && checked;
    }
}
