package thyyxxk.webserver.entity.casefrontsheet;

import java.io.Serializable;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import thyyxxk.webserver.utils.StringUtil;

import java.util.Date;

/**
 * @author dj
 */
@Data
@TableName(value = "t_case_frontsheet_surgery")
public class CaseFrontsheetSurgery implements Serializable {

	private static final long serialVersionUID =  7108736575632532984L;

	/**
	 * 病案号（和住院号一样）
	 */
	private String bah;

	/**
	 * 住院次数
	 */
	private Integer times;

	/**
	 * 手术序号
	 */
	private Integer no;

	/**
	 * 手术名称
	 */
	private String name;

	/**
	 * 手术编码
	 */
	private String code;

	/**
	 * 手术时间
	 */
	private Date date;

	/**
	 * 手术级别
	 */
	private String level;

	/**
	 * 术者
	 */
	private String operator;

	/**
	 * 术者姓名
	 */
	private String operatorName;

	/**
	 * 一助
	 */
	private String assistantOne;

	/**
	 * 一助姓名
	 */
	private String assistantOneName;

	/**
	 * 二助
	 */
	private String assistantTwo;

	/**
	 * 二助姓名
	 */
	private String assistantTwoName;

	/**
	 * 切口等级：Ⅰ,Ⅱ,Ⅲ
	 */
	private String cut;

	/**
	 * 愈合等级：甲，乙，丙
	 */
	private String heal;

	/**
	 * 麻醉方式
	 */
	private String anaesthesia;

	/**
	 * 麻醉医师
	 */
	private String anaesthesiaor;

	/**
	 * 麻醉医师姓名
	 */
	private String anaesthesiaorName;

	@TableField(exist = false)
	private Date opEndDate;

	@TableField(exist = false)
	private Date anstStartDate;

	@TableField(exist = false)
	private Date anstEndDate;

	/**
	 * 切口愈合等级  切口：Ⅰ,Ⅱ,Ⅲ；愈合：甲，乙，丙
	 * */
	@TableField(exist = false)
	private String cutHeal;

	@TableField(exist = false)
	private Integer wjwCutHeal;

	public String getCutHeal() {
		if (StringUtil.isBlank(cutHeal)) {
			if (getCut() != null && getHeal() != null) {
				String first = getCutHealFirstPart(getCut());
				String last = getCutHealLastPart(getHeal());
				return first + "/" + last;
			} else {
				return "";
			}
		}
		return cutHeal.trim();
	}

	private String getCutHealFirstPart(String cut) {
		switch (cut) {
			case "0":
				return "0";
			case "1":
				return "Ⅰ";
			case "2":
				return "Ⅱ";
			case "3":
				return "Ⅲ";
			default:
				return null;
		}
	}

	private String getCutHealLastPart(String heal) {
		switch (heal) {
			case "0":
				return "0";
			case "1":
				return "甲";
			case "2":
				return "乙";
			case "3":
				return "丙";
			default:
				return null;
		}
	}

	public String getCut() {
		if (StringUtil.notBlank(cut)) {
			return cut.trim();
		}
		if (StringUtil.isBlank(cutHeal)) {
			return null;
		}
		String[] arrs = cutHeal.split("/");
		switch (arrs[0]) {
			case "0":
				return "0";
			case "Ⅰ":
				return "1";
			case "Ⅱ":
				return "2";
			case "Ⅲ":
				return "3";
			default:
				return null;
		}
	}

	public String getHeal() {
		if (StringUtil.notBlank(heal)) {
			return heal.trim();
		}
		if (StringUtil.isBlank(cutHeal)) {
			return null;
		}
		String[] arrs = cutHeal.split("/");
		switch (arrs[1]) {
			case "0":
				return "0";
			case "甲":
				return "1";
			case "乙":
				return "2";
			case "丙":
				return "3";
			default:
				return null;
		}
	}
}
