package com.lantone.qc.kernel.catalogue.ninghaiyiyi.operationdiscussion;

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.operation.OperationDoc;
import org.springframework.stereotype.Component;

import java.text.ParseException;
import java.util.List;
import java.util.Objects;

/**
 * @Description: 手术患者无手术记录
 * @author: Mark
 * @time: 2020/04/04 11:22
 */
@Component
public class OPE0322 extends QCCatalogue {

    @Override
    protected void start(InputInfo inputInfo, OutputInfo outputInfo) throws ParseException {
        status.set("0");
        //先判断医嘱里有无手术
        List<DoctorAdviceDoc> doctorAdviceDocs = inputInfo.getDoctorAdviceDocs();
        if (doctorAdviceDocs.size() == 0) {
            return;
        }
        long cou = inputInfo.getOperationDocs().stream().map(OperationDoc::getOperationRecordDoc).filter(Objects::nonNull).count();
        for (DoctorAdviceDoc dad : doctorAdviceDocs) {
            String name = dad.getStructureMap().get("医嘱项目名称");
            String daStartDateStr = dad.getStructureMap().get("医嘱开始时间");
            if (name.contains("非手术") || name.contains("手术室") || (name.contains("手术") && name.contains("取消")) || (name.contains("暂停") && name.contains("手术")) || name.contains("静脉穿刺置管术") || name.startsWith("停") || name.contains("前一次")
                    || name.contains("特殊病人手术使用一次性卫生材料") || name.contains("人免疫缺陷病毒抗体检测免费")) {
                continue;
            }
            if (name.contains("手术") && cou == 0) {
                info.set("医嘱时间" + daStartDateStr);
                status.set("-1");
                return;
            }
        }
        /*long cou = inputInfo.getOperationDocs().stream().map(i -> i.getOperationRecordDoc()).filter(i -> i != null).count();
        if (cou == 0) {
            status.set("-1");
        }*/
    }

}