package thyyxxk.webserver.entity.datamodify;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import thyyxxk.webserver.utils.StringUtil;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * <p>
 *
 * </p>
 *
 * @author 肖蟾
 * @since 2021-03-13
 */
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "ZyDetailCharge对象", description = "")
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ZyDetailCharge implements Serializable {

    private static final long serialVersionUID = 1L;


    /**
     * 行 id
     */
    private String rowId;

    public String getRowId() {
        return inpatientNo + admissTimes + ledgerSn + detailSn;
    }

    public String getChargeCodeId() {
        if (StringUtil.notBlank(chargeCodeMx) && StringUtil.notBlank(serial)) {
            return chargeCodeMx + serial;
        }
        return null;
    }

    @TableId(value = "inpatient_no", type = IdType.NONE)
    @NotNull(message = "住院号不能为空")
    @NotBlank(message = "住院号不能为空")
    private String inpatientNo;

    private Integer rowIndex;

    @NotNull(message = "住院次数不能为空")
    @Min(value = 1, message = "住院次数最小为1")
    private Integer admissTimes;

    private String startTime;
    private String endTime;
    private String riQiPaiXu = "DESC";

    private String chargeCodeName;

    private BigDecimal origChargeFee;

    @NotNull(message = "账页号不能为空")
    @Min(value = 1, message = "账页号最小为1")
    private Integer ledgerSn;

    private Integer detailSn;

    private Date chargeDate;

    private String opIdCode;

    private String chargeCode;

    private String infantFlag;

    private String chargeStatus;

    private float retprice;

    private BigDecimal chargeAmount;

    private BigDecimal chargeFee;

    private BigDecimal newChargeFee;

    private String selfFlag;

    private String separateFlag;

    private String suppressFlag;

    private String wardCode;

    private String deptCode;

    private BigDecimal orderNo;
    private BigDecimal newOrderNo;
    private BigDecimal actOrderNo;

    private String opeFlag;

    private String execUnit;

    private Date genTime;

    private String oldGenTime;

    /**
     * 药品 库存
     */
    private Integer stockAmount;

    private float payPercent;

    private String zjFlag;

    private float zfl;

    private String chargeCodeMx;

    /**
     * 包装规格
     */
    private String serial;

    /**
     * 住院流水号
     */
    private String zySerialNo;

    private String doctorCode;

    private String ybSelfFlag;

    private BigDecimal yiTuiFei;

    private String confirmId;

    private String transFlagYb;

    private String ssCode;

    private String gsFlag;

    private String referPhysician;

    private String consultPhysician;

    /**
     * 下面的都是 项目录入需要使用的字段
     */

    @TableField(exist = false)
    private long pageSize;

    @TableField(exist = false)
    private long currentPage;

    private long total;

    @TableField(exist = false)
    private Integer feiYongLeiXingCode;

    private String billItemCode;

    private String chargeName;

    /**
     * 单位
     */
    private String spec;

    /**
     * 规格
     */
    private String descriptions;

    private String yblx;

    private BigDecimal price;

    private BigDecimal amount;

    private String execDept;

    private String groupNo;

    private String drugname;

    private String opName;

    private Integer oriDetailSn;

    private String chrgitmLv;

    private String medChrgitmType;

    private BigDecimal detItemFeeSumamt;

    private BigDecimal cnt;
    private BigDecimal pric;
    private BigDecimal inscpScpAmt;


    private BigDecimal selfpayProp;

    /**
     * 医保类型
     */
    private String responceType;

    /**
     * 床位
     */
    private String bedNo;

    /**
     * 余额
     */
    private BigDecimal balance;

    /**
     * 总费用
     */
    private BigDecimal totalCharge;

    private BigDecimal chargeType;

    private Integer timesBilled;

    /**
     * 入院诊断名称
     */
    private String admissDiagStr;

    /**
     * 入院诊断编码
     */
    private String admissDiag;

    /**
     * 入院时间
     */
    private Date admissDate;

    /**
     * 这里面是 存放需要退费
     */
    private List<ZyDetailCharge> list;


    // 下面这些是获取 项目录入模板的

    /**
     * 模板 名称
     */
    private String name;

    /**
     * 创建模板的科室
     */
    private String opDept;

    /**
     * 模板名称
     */
    private String patternName;

    /**
     * 模板排序
     */
    private String defaultNo;

    private String self;

    private String supriceFlag;

    private String infant;

    private BigDecimal per1;
    private BigDecimal per2;
    private BigDecimal per3;
    private BigDecimal per4;
    private BigDecimal per5;

    private String execUnitB;
    private Integer itemNo;

    /**
     * 执行科室
     */
    private String execUnitName;
    /**
     * 拼音码
     */
    private String pyCode;
    /**
     * 五笔码
     */
    private String wbCode;

    private String dCode;
    private BigDecimal priceB;

    /**
     * 下面是单独查询的
     */
    private String billItemOut;

    /**
     * 医保 厂家
     */
    private String ybComment;

    /**
     * 申请科室
     */
    private String dept;
    private String ward;


    /**
     * 费用类型 名称
     */
    private String billItemName;

    /**
     * 费用 类型
     * 0 - 项目  1 - 药品
     */
    private Integer feiYongType;

    /**
     * 0：全部
     * 1：未退费
     * 2：退费
     */
    private Integer tuiFeiFlag;

    /**
     * 国家项目编码
     */
    private String nationalCode;
    private String nationalName;

    /**
     * 药品类型 口服药是不能退的
     */
    private String drugClass;

    /**
     * 规格
     */
    private String specification;

    /**
     * 药品的类型 1 = 口服不能退
     */
    private String classCode;

    /**
     * refundOnly 药品仅退费标识
     */
    private String refundFlag;

    /**
     * 最小包装规格
     */
    private String miniUnit;

    /**
     * 厂家
     */
    private String manuName;


    public BigDecimal getOrderNo() {
        if (orderNo == null) {
            return new BigDecimal(0);
        } else {
            return orderNo;
        }
    }

    /**
     * 发票号，在费用录入时财务的可以用到
     */
    private String receiptNo;


}
