package thyyxxk.webserver.entity.casefrontsheet.request;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import thyyxxk.webserver.utils.StringUtil;

import java.util.Date;

@Data
public class SheetOverview {
    private Integer fileStatus;
    private Integer inOutFlag;
    private String bedNo;
    private String bah;
    private String patNo;
    private Integer times;
    private String name;
    private Integer sex;
    private String genderName;
    private Date admissDate;
    private String deptName;
    private String doctorCode;
    private String doctorName;
    private Date disDate;
    private String zyDismissWay;
    private String zyDismissWayName;
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date signDate;
    private Date signDateOrigin;
    private String signStaff;
    private String signStaffName;
    private String signTime;
    private Integer lateDays;
    private Integer lateFlag;
    private Integer lendOutCount;
    private Integer unarcheivTimes;

    public String getPatNo() {
        return null == patNo ? bah :  patNo;
    }

    public Integer getLateDays() {
        if (null == lateDays) return 0;
        return Math.max(lateDays - 8, 0);
    }

    public String getGenderName() {
        if (null == sex) {
            return "未填写";
        }
        if (sex == 1) {
            return "男";
        }
        if (sex == 2) {
            return "女";
        }
        return "未知";
    }

    public String getZyDismissWayName() {
        if (StringUtil.isBlank(this.zyDismissWay)) {
            return "";
        }
        if (this.zyDismissWay.equals("4")) {
            return "已死亡";
        }
        return "";
    }

    public Integer getLateFlag() {
        return null == lateFlag ? 0 : lateFlag;
    }

    public Integer getFileStatus() {
        return null == fileStatus ? 0 : fileStatus;
    }

    public Integer getInOutFlag() {
        return null == inOutFlag ? 1 : inOutFlag;
    }
}