package com.lantone.qc.kernel.catalogue.beilun.majorInspection;

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.ListUtil;
import com.lantone.qc.pub.util.StringUtil;

import java.util.List;
import java.util.Map;

/**
 * @ClassName : MI0589
 * @Description: 报告单缺少细菌培养记录
 * @author: zh
 * @time: 2021/04/06 11:22
 */

public class MI0589 extends QCCatalogue {
        public void start(InputInfo inputInfo, OutputInfo outputInfo){
            status.set("0");
            List<DoctorAdviceDoc> doctorAdviceDocList = inputInfo.getDoctorAdviceDocs();
            if(ListUtil.isNotEmpty(doctorAdviceDocList)){
                for (DoctorAdviceDoc doctorAdviceDoc : doctorAdviceDocList) {
                    Map<String, String> doctorAdviceDocStructureMap = doctorAdviceDoc.getStructureMap();
                    String doctorAsks = doctorAdviceDocStructureMap.get("医嘱类型判别");
                    if("临时医嘱".equals(doctorAsks)){
                        String doctorAsksName = doctorAdviceDocStructureMap.get("医嘱项目名称");
                        if(StringUtil.isNotEmpty(doctorAsksName)&&doctorAsksName.contains("细菌培养")){
                            status.set("-1");
                            List<LisDoc> lisDocs = inputInfo.getLisDocs();
                            if(ListUtil.isNotEmpty(lisDocs)){
                                for (LisDoc lisDoc : lisDocs) {
                                    String lisDocStr = lisDoc.getStructureMap().get("报告名称");
                                    if(StringUtil.isNotEmpty(lisDocStr)&&lisDocStr.contains("细菌培养")){
                                        status.set("0");
                                        return;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
}
