package com.lantone.qc.kernel.catalogue.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.LeaveHospitalDoc;
import org.springframework.stereotype.Component;

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

/**
 * @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(i -> i.getOperationRecordDoc()).filter(i -> i != null).count();
        long od_count = inputInfo.getOperationDocs().stream().map(i -> i.getOperationDiscussionDoc()).filter(i -> i != null
                && i.getStructureMap().containsKey("术后诊断")
        && !i.getStructureMap().get("术后诊断").contains("平产")
        && !i.getStructureMap().get("术后诊断").contains("顺产")).count();
        if(od_count > 0 && cou == 0){
            status.set("-1");
            return;
        }
        /*for (DoctorAdviceDoc dad:doctorAdviceDocs) {
            String name = dad.getStructureMap().get("医嘱项目名称");
            if(name.contains("手术") && cou == 0){
                status.set("-1");
            }
        }*/
        /*long cou = inputInfo.getOperationDocs().stream().map(i -> i.getOperationRecordDoc()).filter(i -> i != null).count();
        if (cou == 0) {
            status.set("-1");
        }*/
    }

}