package com.yihu.wlyy.entity.doctor.profile;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.yihu.wlyy.entity.IdEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;

import com.fasterxml.jackson.annotation.JsonFormat;

/**
 * 医生信息
 * @author George
 */
@Entity
@Table(name = "wlyy_doctor")
public class Doctor extends IdEntity {
	private static final long serialVersionUID = -6585552029939285364L;
    
	private String code;        // 业务主键
	
	private String name;
	private Integer sex;        // 性别（1男，2女）
	private Date birthday;
	private String photo;
	private String mobile;
	private String password;
	private String salt;        // 密码标识
	private Integer status;     // 状态（1正常，0禁用）
	
	private String province;
	private String city;
	private String town;

	private String provinceName;
	private String cityName;
    private String townName;
	
	private String hospital;        // 医院代码
	private String hosptialName;
	private String dept;            // 科室代码
	private String deptName;
	private String job;             // 职称代码
	private String jobName;         // 职称名
	
	private String expertise;       // 医生专长
	private String introduce;       // 医生介绍
	
	private Integer level;          // 类型：1专科医生，2全科医生，3健康管理师
	private Integer iscertified;   // 资格是否认证通过，1是，0否

    private String qrcode;          // 二维码
	
	private Date czrq;              // 更新时间
	private Integer del;            // 状态（1正常，0删除）

	private String idcard;          //身份证号
	private Integer isFamous;       //是否是名医 1是  0或者空不是

	public Doctor() {}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public Doctor(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Integer getSex() {
		return sex;
	}

	public void setSex(Integer sex) {
		this.sex = sex;
	}

	@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+08:00")
	public Date getBirthday() {
		return birthday;
	}

	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}

	public String getPhoto() {
		return photo;
	}

	public void setPhoto(String photo) {
		this.photo = photo;
	}

	public String getMobile() {
		return mobile;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getSalt() {
		return salt;
	}

	public void setSalt(String salt) {
		this.salt = salt;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public String getProvince() {
		return province;
	}

	public void setProvince(String province) {
		this.province = province;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}
	public String getTown() {
		return town;
	}

	public void setTown(String town) {
		this.town = town;
	}
	
	@Column(name = "province_name")
	public String getProvinceName() {
		return provinceName;
	}

	public void setProvinceName(String provinceName) {
		this.provinceName = provinceName;
	}

	@Column(name = "city_name")
	public String getCityName() {
		return cityName;
	}

	public void setCityName(String cityName) {
		this.cityName = cityName;
	}
	@Column(name = "town_name")
	public String getTownName() {
		return townName;
	}

	public void setTownName(String townName) {
		this.townName = townName;
	}
	
	@Column(name = "hospital_name")
	public String getHosptialName() {
		return hosptialName;
	}

	public void setHosptialName(String hosptialName) {
		this.hosptialName = hosptialName;
	}

	@Column(name = "dept_name")
	public String getDeptName() {
		return deptName;
	}

	public void setDeptName(String deptName) {
		this.deptName = deptName;
	}

	@Column(name = "job_name")
	public String getJobName() {
		return jobName;
	}

	public void setJobName(String jobName) {
		this.jobName = jobName;
	}

	public String getHospital() {
		return hospital;
	}

	public void setHospital(String hospital) {
		this.hospital = hospital;
	}

	public String getDept() {
		return dept;
	}

	public void setDept(String dept) {
		this.dept = dept;
	}

	public String getJob() {
		return job;
	}

	public void setJob(String job) {
		this.job = job;
	}
	public String getExpertise() {
		return expertise;
	}

	public void setExpertise(String expertise) {
		this.expertise = expertise;
	}

	public String getIntroduce() {
		return introduce;
	}

	public void setIntroduce(String introduce) {
		this.introduce = introduce;
	}

	public Integer getLevel() {
		return level;
	}

	public void setLevel(Integer level) {
		this.level = level;
	}

    @Column(name = "iscertified")
    public Integer getIscertified() {
		return iscertified;
	}

	public void setIscertified(Integer isCertified) {
		this.iscertified = isCertified;
	}

	public String getQrcode() {
		return qrcode;
	}

	public void setQrcode(String qrcode) {
		this.qrcode = qrcode;
	}

	// 设定JSON序列化时的日期格式
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getCzrq() {
		return czrq;
	}

	public void setCzrq(Date czrq) {
		this.czrq = czrq;
	}

	@Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this);
	}

	@Column(name = "del")
	public Integer getDel() {
		return del;
	}

	public void setDel(Integer del) {
		this.del = del;
	}

	public String getIdcard() {
		return idcard;
	}

	public void setIdcard(String idcard) {
		this.idcard = idcard;
	}

	@Column(name = "is_famous")
	public Integer getIsFamous() {
		return isFamous;
	}

	public void setIsFamous(Integer isFamous) {
		this.isFamous = isFamous;
	}

    /**
     * 是否为专科医生。
     *
     * @return
     */
    @Transient
	public boolean isProfessionalDoctor(){
	    return level == 1;
    }

    /**
     * 是否为全科医生。
     *
     * @return
     */
    @Transient
	public boolean isGeneralDoctor(){
	    return level == 2;
    }

    /**
     * 是否为健康管理师。
     *
     * @return
     */
    @Transient
    public boolean isHealthDoctor(){
        return level == 3;
    }
}