package com.lantone.qc.kernel.catalogue.yiwu.doctorsadvice;

import com.lantone.qc.kernel.catalogue.QCCatalogue;
import com.lantone.qc.pub.model.InputInfo;
import com.lantone.qc.pub.model.OutputInfo;
import com.lantone.qc.pub.model.doc.DoctorAdviceDoc;
import com.lantone.qc.pub.model.doc.LisDoc;
import com.lantone.qc.pub.util.StringUtil;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Objects;

/**
 * @ClassName : ADVI03084
 * @Description : 医嘱中无免疫球蛋白
 *
 * @Author : 胡敬
 * @Date: 2020-03-28 17:35
 */
@Component
public class ADVI03084 extends QCCatalogue {
    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
        status.set("0");
        List<DoctorAdviceDoc> doctorAdviceDocs = inputInfo.getDoctorAdviceDocs();
        List<LisDoc> lisDocs = inputInfo.getLisDocs();
//        if (doctorAdviceDocs.size() == 0 || lisDocs.size() == 0) {
//            return;
//        }
        long itemCount = doctorAdviceDocs
                .stream()
                .map(DoctorAdviceDoc::getStructureMap)
                .map(i -> i.get("医嘱项目名称"))
                .filter(Objects::nonNull)
                .filter(i -> i.contains("免疫球蛋白"))
                .count();
        long lisItemCount = lisDocs
                .stream()
                .map(LisDoc::getStructureMap)
                .filter(i -> StringUtil.isNotBlank(i.get("报告名称")) && "乙肝表面抗原".equals(i.get("报告名称")) && StringUtil.isNotBlank(i.get("检验结果")) && "阳性".equals(i.get("检验结果")))
                .count();
        if (lisItemCount > 0 && itemCount == 0) {
            status.set("-1");
        }
    }
}