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

import java.util.List;
import java.util.Map;
/**
 * @ClassName : MI0160
 * @Description: 病程记录缺少细菌培养结果
 * @author: zh
 * @time: 2021/04/06 11:22
 */

public class MI0160 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<ThreeLevelWardDoc> allDoctorWradDocs = inputInfo.getThreeLevelWardDocs().get(0).getAllDoctorWradDocs();
                            if(ListUtil.isNotEmpty(allDoctorWradDocs)&&allDoctorWradDocs.size()>0){
                                for (ThreeLevelWardDoc allDoctorWradDoc : allDoctorWradDocs) {
                                    String allDoctorStr = allDoctorWradDoc.getStructureMap().get("病情记录");
                                    if(allDoctorStr.contains("细菌培养")){
                                        status.set("0");
                                        return;
                                    }
                                }
                            }

                        }
                    }
                }
            }
        }
}
