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

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.BeHospitalizedDoc;
import com.lantone.qc.pub.model.entity.Clinical;
import org.springframework.stereotype.Component;

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


/**
 * @ClassName : BEH0560
 * @Description : 现病史中症状主诉未填写
 * @Author : Mark
 * @Date: 2020-04-04 17:48
 */
@Component
public class BEH0560 extends QCCatalogue {
    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
        status.set("0");
        BeHospitalizedDoc beHospitalizedDoc = inputInfo.getBeHospitalizedDoc();
        if (beHospitalizedDoc == null || beHospitalizedDoc.getChiefLabel() == null) {
            return;
        }
        String chiefTxt = beHospitalizedDoc.getChiefLabel().getText();
        if (chiefTxt.contains("检查") || chiefTxt.contains("术后") || chiefTxt.contains("药物") || chiefTxt.contains("发现")) {
            status.set("0");
            return;
        }
        List<Clinical> clinicalsChief = beHospitalizedDoc.getChiefLabel().getClinicals();
        List<Clinical> clinicalsPresent = beHospitalizedDoc.getPresentLabel().getClinicals();
        List<String> chiefSymp = new ArrayList<>();
        if (clinicalsChief != null && clinicalsChief.size() > 0) {
            for (Clinical clinical : clinicalsPresent) {
                if (clinical.getNegative() == null) {
                    if (chiefSymp.indexOf(clinical.getName()) == -1) {
                        chiefSymp.add(clinical.getName());
                    }
                }
            }
        }
        /*
        String chief_txt = beHospitalizedDoc.getChiefLabel().getText();
        String present_txt = beHospitalizedDoc.getPresentLabel
        String present_chief_txt = present_txt.split("伴")[0];
         */
        List<String> presentSymp = new ArrayList<>();
        for (Clinical clinical : clinicalsPresent) {
            if (clinical.getNegative() == null) {
                if (presentSymp.indexOf(clinical.getName()) == -1) {
                    presentSymp.add(clinical.getName());
                }
            }
        }
        if (chiefSymp.size() > 0 && presentSymp.size() > 0) {
            for (String cli : chiefSymp) {
                if (!presentSymp.contains(cli)) {
                    status.set("-1");
                    return;
                }
            }
        }
            /*for (String symp:present_symp) {
                if (present_chief_txt.contains(symp) && !chief_txt.contains(symp)) {
                    cnt += 1;
                }
            }

            if(cnt>0){
                status.set("-1");
            }*/
    }
}