package thyyxxk.webserver.entity.zygl;

import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.util.Date;
import java.util.Map;

/**
 * 病人对象
 */
@Data
public class MzPatientMi  {
    //身份证号码
    private String socialNo;
    //VIP卡号(医疗证号)
    private String hicNo;
    //姓名
    private String name;
    //性别  1-男 2-女 0 未知 GenderEnum
    private Integer sex;
    //最后一次访问日期
    private Date lvDate;
    //病人ID码 门诊号
    private String patientId;
    //条形码
    private String pBarCode;
    //欠费标记
    private Integer baddebtMark;
    //病人身份
    private String responseType;
    //费用类别 1-普通 2 -儿科 无特殊意义了
    private String chargeType;
    //就诊次数
    private Integer times;
    //预约删除标志
    private Integer reqdelMark;
    //年龄
    private Integer age;
    //出生日期
    private Date birthDay;
    //IC卡号
    private String icCardNo;
    //电话号码
    private String phoneNo;
    //地址
    private String address;
    //医保卡号
    private String ybCardNo;
    //初次就诊时间
    private String firstDate;
    //联系人
    private String relName;
    //借用为紧急联系人电话
    private String contractName;
    //借用为紧急联系人身份证号码
    private String contractHz;
    /**
     * 证件类型
     */
    private String certificateType;
    //工作单位
    private String workUnit;
    //单位地址
    private String workAddress;
    //单位电话
    private String workTel;
    //省编码
    private String provinceCode;
    //市编码
    private String cityCode;
    //区县编码
    private String districtCode;
    //详细地址
    private String detail;

    //最后一次访问日期 字符串
    private String lvDateStr;
    //出生日期 字符串
    private String birthDayStr;

    //性别描述  非数据库字段
    private String gender;
    //医保身份描述 非数据库字段
    private String responseTypeName;
    //父病人id 就是混检需要 非数据库字段
    private String parentPatientId;
    //年龄描述
    private String ageString;
    //证件类型描述
    private String certificateTypeName;
    //修改人
    private String updateUser;
    //修改时间
    private Date updateTime;
    //最后就诊时间
    private String lastVisitDate;



    @Override
    public String toString() {
        return "MzPatientMi{" +
                "socialNo='" + socialNo + '\'' +
                ", hicNo='" + hicNo + '\'' +
                ", name='" + name + '\'' +
                ", sex=" + sex +
                ", lvDate=" + lvDate +
                ", patientId='" + patientId + '\'' +
                ", pBarCode='" + pBarCode + '\'' +
                ", baddebtMark=" + baddebtMark +
                ", responseType='" + responseType + '\'' +
                ", chargeType='" + chargeType + '\'' +
                ", times=" + times +
                ", reqdelMark=" + reqdelMark +
                ", age=" + age +
                ", birthDay=" + birthDay +
                ", icCardNo='" + icCardNo + '\'' +
                ", phoneNo='" + phoneNo + '\'' +
                ", address='" + address + '\'' +
                ", ybCardNo='" + ybCardNo + '\'' +
                ", firstDate='" + firstDate + '\'' +
                ", relName='" + relName + '\'' +
                ", contractName='" + contractName + '\'' +
                ", contractHz='" + contractHz + '\'' +
                ", lvDateStr='" + lvDateStr + '\'' +
                '}';
    }

    /**
     * 设置完整的地址
     * @param regionMap
     * @param sbf
     */
    public void setFullAddress(Map<String, String> regionMap,StringBuffer sbf){
        if (address == null || StringUtils.isBlank(address)) {
            String pro = regionMap.get(provinceCode);
            if (pro != null && StringUtils.isNotBlank(pro)) {
                sbf.append(pro);
            }
            String city = regionMap.get(cityCode);
            if (city != null && StringUtils.isNotBlank(city)) {
                sbf.append(city);
            }
            String district = regionMap.get(districtCode);
            if (district != null && StringUtils.isNotBlank(district)) {
                sbf.append(district);
            }
            if (detail != null && StringUtils.isNotBlank(detail)) {
                sbf.append(detail);
            }
            address=sbf.toString();
            sbf.setLength(0);
        }else {
            address=address.replaceAll("null","");
        }
    }
}
