package thyyxxk.webserver.entity.medicalinsurance.log;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;

@Data
@TableName("t_si_log")
public class SiLog implements Serializable {

	private static final long serialVersionUID =  3109706338397960444L;

	/**
	 * 报文ID
	 */
	@TableId(type=IdType.ASSIGN_UUID)
	private String msgid;

	/**
	 * 功能号
	 */
	private String infno;

	/**
	 * 功能号名称
	 */
	@TableField(exist = false)
	private String infname;

	/**
	 * 参保地医保区划
	 */
	private String insuplcAdmdvs;

	/**
	 * 经办人
	 */
	private String opter;

	/**
	 * 经办人姓名
	 */
	@TableField(exist = false)
	private String opterName;

	/**
	 * 交易输入
	 */
	private String body;

	/**
	 * 交易输出
	 */
	private String result;

	/**
	 * 住院号/门诊号
	 */
	private String patNo;

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

	/**
	 * 账页号
	 */
	private Integer ledgerSn;

	/**
	 * 日志类别：1-住院；2-门诊
	 * */
	private Integer logType;

	/**
	 * 记录生成时间
	 * */
	private Date createDatetime;

	/**
	 * 返回结果：0 成功，-1 失败
	 * */
	private Integer infcode;

	/**
	 * 人员编号
	 * */
	private String psnNo;

	public SiLog() {
	}

	public SiLog(JSONObject input, JSONObject result, String patNo, Integer times, Integer ledgerSn, Integer infcode, String psnNo) {
		if (null != result) {
			setResult(result.toJSONString());
		}
		setBody(input.toJSONString());
		setInfno(input.getString("infno"));
		setInsuplcAdmdvs(input.getString("insuplc_admdvs"));
		setMsgid(input.getString("msgid"));
		setOpter(input.getString("opter"));
		setPatNo(patNo);
		setTimes(times);
		setLedgerSn(ledgerSn);
		setLogType(1);
		setInfcode(infcode);
		setPsnNo(psnNo);
	}

	public SiLog(String msgid, String infno, String insuplcAdmdvs, String opter, String body,String result, String patNo, Integer times, Integer ledgerSn, Integer logType, String psnNo) {
		this.msgid = msgid;
		this.infno = infno;
		this.insuplcAdmdvs = insuplcAdmdvs;
		this.opter = opter;
		this.body = body;
		this.result = result;
		this.patNo = patNo;
		this.times = times;
		this.ledgerSn = ledgerSn;
		this.logType = logType;
		this.psnNo = psnNo;
	}
}
