package thyyxxk.webserver.entity.medicalinsurance.manage;

import lombok.Data;

/**
 * 明细对账结算
 * */
@Data
public class InsSetlDetlChkRslt {
    private String visitId;
    private String psnNo;
    private String mdtrtId;
    private String setlId;
    private String msgId;
    private String stmtRslt;
    private String refdSetlFlag;
    private String memo;
    private String medfeeSumamt;
    private String fundPaySumamt;

    public InsSetlDetlChkRslt() {
    }

    public InsSetlDetlChkRslt(InstSetlLdgChkBrf brf) {
        this.visitId = brf.getVisitId();
        this.psnNo = brf.getPsnNo();
        this.mdtrtId = brf.getMdtrtId();
        this.setlId = brf.getSetlId();
        this.msgId = brf.getMsgId();
        this.memo = analyzeMemo(brf);
        this.medfeeSumamt = this.memo.equals("对账成功。") ? brf.getMedfeeSumamt().toString() :
                "医保：" + brf.getMedfeeSumamt() + "；<br/>HIS：" + brf.getMedfeeSumamt2();
        this.fundPaySumamt = this.memo.equals("对账成功。") ? brf.getFundPaySumamt().toString() :
                "医保：" + brf.getFundPaySumamt() + "；<br/>HIS：" + brf.getFundPaySumamt2();
    }

    private String analyzeMemo(InstSetlLdgChkBrf brf) {
        if (null == brf.getMedfeeSumamt()) {
            return "对账失败：不存在该笔医保结算记录。";
        }
        if (null == brf.getMedfeeSumamt2()) {
            return "对账失败：不存在该笔HIS结算记录。";
        }
        if (brf.getMedfeeSumamt().compareTo(brf.getMedfeeSumamt2()) == 0 &&
                brf.getFundPaySumamt().compareTo(brf.getFundPaySumamt2()) == 0) {
            return "对账成功。";
        }
        return "对账失败：医保金额与HIS金额不一致。";
    }

    public InsSetlDetlChkRslt(String[] arr) {
        psnNo = arr[0];
        mdtrtId = arr[1];
        setlId = arr[2];
        msgId = arr[3];
        stmtRslt = arr[4];
        refdSetlFlag = arr[5];
        memo = arr[6];
        medfeeSumamt = arr[7];
        fundPaySumamt = arr[8];
    }
}
