package com.lantone.qc.kernel.catalogue.firstcourserecord;

import com.lantone.qc.kernel.catalogue.QCCatalogue;
import com.lantone.qc.kernel.util.RedisUtil;
import com.lantone.qc.pub.model.InputInfo;
import com.lantone.qc.pub.model.OutputInfo;
import com.lantone.qc.pub.model.doc.BeHospitalizedDoc;
import com.lantone.qc.pub.model.doc.FirstCourseRecordDoc;
import com.lantone.qc.pub.model.entity.Diag;
import com.lantone.qc.pub.model.label.DiagLabel;
import com.lantone.qc.pub.util.ListUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName : FIRC0095
 * @Description : 初步诊断不完整
 * 和入院记录的初步诊断比较
 * @Author : 楼辉荣
 * @Date: 2020-03-06 17:28
 */
@Component
public class FIRC0095 extends QCCatalogue {
    @Autowired
    private RedisUtil redisUtil;

    public void start(InputInfo inputInfo, OutputInfo outputInfo) {

        FirstCourseRecordDoc firstCourseRecordDoc = inputInfo.getFirstCourseRecordDoc();
        BeHospitalizedDoc beHospitalizedDoc = inputInfo.getBeHospitalizedDoc();
        if (firstCourseRecordDoc == null && beHospitalizedDoc == null) {
            status.set("0");
            return;
        }
        DiagLabel initialDiagLabel = firstCourseRecordDoc.getInitialDiagLabel();
        DiagLabel initialDiagLabel1 = beHospitalizedDoc.getInitialDiagLabel();
        if (initialDiagLabel != null && initialDiagLabel1 != null) {
            List<Diag> diags = initialDiagLabel.getDiags();
            List<Diag> diags1 = initialDiagLabel1.getDiags();
            List<String> firstDiags = new ArrayList<>();
            List<String> bhDiags = new ArrayList<>();
            if (diags != null && diags.size() > 0) {
                for (Diag firdiag : diags) {
                    firstDiags.add(firdiag.getHospitalDiagName());
                }
                for (Diag bhDig : diags1) {
                    bhDiags.add(bhDig.getHospitalDiagName());
                }
                if (ListUtil.equals(firstDiags, bhDiags)) {
                    status.set("0");
                }
            }
        }
    }
}
