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

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.ThreeLevelWardDoc;
import com.lantone.qc.pub.model.label.ThreeLevelWardLabel;
import com.lantone.qc.pub.util.ListUtil;
import com.lantone.qc.pub.util.StringUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @ClassName : THR0430
 * @Description : 抢救患者上级医师(副高及以上)查房记录无病情分析及评估
 * @Author : 胡敬
 * @Date: 2020-03-25 14:20
 */
@Component
public class THR0430 extends QCCatalogue {
    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
        status.set("0");
        if (ListUtil.isEmpty(inputInfo.getRescueDocs())) {
            return;
        }
        if (inputInfo.getThreeLevelWardDocs().size() > 0) {
            List<ThreeLevelWardDoc> allDoctorWradDocs = inputInfo.getThreeLevelWardDocs().get(0).getAllDoctorWradDocs();
            for (ThreeLevelWardDoc threeLevelWardDoc : allDoctorWradDocs) {
                List<ThreeLevelWardLabel> threeLevelWardLabels = threeLevelWardDoc.getThreeLevelWardLabel();
                for (ThreeLevelWardLabel threeLevelWardLabel : threeLevelWardLabels) {
                    if (threeLevelWardLabel.getSerious() != 3) {
                        continue;
                    }
                    if (!(threeLevelWardLabel.getDiags().size() > 0
                            || StringUtil.isNotBlank(threeLevelWardLabel.getDiagBasisText())
                            || (threeLevelWardLabel.getDiffDiag().size() > 0 || StringUtils.isNotEmpty(threeLevelWardLabel.getDiffDiagText()))
                            || threeLevelWardLabel.getTreatmentPlans().size() > 0)) {
                        status.set("-1");
                        return;
                    }
                }
            }
        }
    }
}