package thyyxxk.webserver.entity.datamodify;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;

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

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

    public YzActOrder() {

    }

    private static final long serialVersionUID = 1L;

    /**
     * 一组医嘱的标识
     */
    private String orderGroup;

    private BigDecimal actOrderNo;
    private String actOrderNoStr;
    private BigDecimal actOrderNoTf;
    private String inpatientNo;
    /**
     * 病人的姓名
     */
    private String patientName;
    private Integer admissTimes;
    private String orderCode;
    private String bedNoName;
    private Date orderTime;
    private String frequCode;
    private String frequCodeName;
    private Date enterTime;
    private String enterOper;
    private String enterOperName;
    private Date startTime;
    private Date endTime;
    private String startTimeString;
    private String endTimeString;
    private String alwaysFlag;
    // 是否 自备药
    private Boolean buyFlag;
    //  自备名称
    private String ibBuyName;
    private String occType;
    private String mzFlag;

    /**
     * 停止人
     */
    private String modifier;
    private String modifierName;
    private String infantFlag;
    private String drugFlag;
    private String supplyCode;
    private String supplyClass;
    private String supplyCodeName;
    private Date performanceTime;
    /**
     * 医生
     */
    private String physician;
    private String physicianName;
    private Date confirmTime;
    /**
     * 确认人
     */
    private String signer;
    private String signerName;
    private String statusFlag;
    private Date statusTime;
    private BigDecimal drugQuan;
    private String drugQuanName;
    private String instruction;
    private String drugSpecification;
    private String miniUnit;
    private String miniUnitName;
    private Float drugWeight;
    private String drugWeightUnit;
    private String printOrderChange;
    private BigDecimal parentNo;
    private String parentNoName;
    private String selfBuy;
    private String eatCardFlag;
    private BigDecimal drugVolume;
    private String drugVolUnit;
    private BigDecimal dose;
    private String doseUnit;
    private String doseUnitName;
    private BigDecimal drugOcc;
    private String printOrder;
    private String printOrderOnce;
    private String printOrderAnew;
    private String printInfusion;
    private Date excluBackTime;
    private Float excluActOrderNo;
    private String orderName;
    private String discription;
    private String delFlag;
    private String paySelf;
    private String serial;
    private String serialName;
    private String groupNo;
    private String groupNoName;
    private String wardCode;
    private String ybSelfFlag;
    private String doctorFlag;
    private String deptCode;
    private String execUnit;
    private String execUnitName;
    private String clCode;
    private String zySerialNo;
    private String executer1;
    private String executer2;
    private String regFlag;
    private String msgFlag;
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date execTime;
    private String execId;
    private String psStatus;
    private String psOper;
    private Date psTime;
    private String execId2;
    private BigDecimal actOrderNo2;
    private float newActOrderNo;
    private Integer printPage;
    private Integer printPageOnce;
    private String printOrderChangeEnd;
    private String emergencyFlag;
    private String reqReceiveFlag;
    private String inspectStuff;
    private String chargeStatus;
    private Date psResultTime;
    private String opIdCode;
    private Date chargeDate;
    private String kfFlag;
    private String modifierOper;
    private String passFlag;
    private String passId;
    private String passDate;
    private String passComment;
    private String referPhysician;
    private String consultPhysician;
    private List<YzActOrder> tuiFeiList;
    private Integer tfFlag;
    private long currentPage;
    private long pageSize;
    private String queryStartTime;
    private String queryEndTime;
    // 下面是医嘱确费 需要使用到的
    private Integer ledgerSn;
    private String name;
    private String bedNo;
    private String doctorName;
    private String docotrName;
    private Integer comfirmFlag;
    private String wardName;
    private String chargeCode;
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private BigDecimal chargeFee;
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private BigDecimal orderCount;
    private Integer sex;
    private Date admissDate;
    private BigDecimal totalCharge;
    private String responceType;
    private String responceTypeName;
    private Date occTime;
    private String occTimeString;
    private String chargeName;
    private String billItemCode;
    private List<YzActOrder> list;
    private List<YzActOrder> children;
    private long total;
    private String opIdName;
    private Date opDate;
    private Integer fenLei;
    private Integer shiFouYouChuYuanYiZhu;
    private Integer liShi;
    private Integer yiQueRen;
    private Integer quXiao;
    private Integer weiQueRen;
    private Integer yiChanShenFeiYong;

    @Builder.Default
    private Boolean isChildren = false;

    private String zkWardCode;
    private String zkDeptCode;
    /**
     * 用药方式
     * 0-无
     * 1-手术预防用药 2-非手术预防用药 3-治疗用药-标本已送检 4-治疗用药-标本未已送检
     * 5-皮试用药
     */
    private Integer yyfs;
    /**
     * 手术切口
     * 0-无
     * 1-Ⅰ类切口 2-Ⅱ类切口  3-Ⅲ类切口
     * 4-微创 5-介入 6-其他
     */
    private Integer ssqk;
    /**
     * 术前用药时间
     * 0-无
     * 1-0.5至1小时
     * 2-2小时
     * 3-其他
     */
    private Integer yysj;

    /**
     * 抗菌药物 专用 需要在 yz_act_record_kss 中插入
     */
    private String kjywFlag;

    /**
     * 取模板时候的 id
     */
    private String id;

    public String getActOrderNoStr() {
        if (actOrderNo != null) {
            actOrderNoStr = actOrderNo.stripTrailingZeros().toPlainString();
        }
        return actOrderNoStr;
    }


    /* 费用标志 自备标志 1 自备 2 嘱托 3 基数药 */
    public String getSelfBuyName() {
        if (selfBuy == null) {
            return "";
        }
        switch (selfBuy) {
            case "1":
                return "自备";
            case "2":
                return "嘱托";
            case "3":
                return "基数药";
            case "4":
                return "出院带药";
            case "5":
                return "GCP自费";
            default:
                return "";
        }
    }

    public String getDrugFlagName() {
        if (drugFlag == null) {
            return "";
        }
        switch (drugFlag) {
            case "d":
                return "西药";
            case "i":
                return "大输液";
            case "z":
                return "中成药";
            case "o":
                return "医嘱";
            case "p":
                return "手术";
            case "h":
                return "护理";
            default:
                return drugFlag + " 未知";
        }
    }
}
