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

import com.google.common.collect.Lists;
import com.lantone.qc.kernel.catalogue.QCCatalogue;
import com.lantone.qc.kernel.util.CatalogueUtil;
import com.lantone.qc.pub.model.InputInfo;
import com.lantone.qc.pub.model.OutputInfo;
import com.lantone.qc.pub.util.StringUtil;
import org.springframework.stereotype.Component;

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

/**
 * @ClassName : LEA02968
 * @Description :  出院小结查体与性别不匹配
 * @Author : 胡敬
 * @Date: 2020-06-13 16:25
 */
@Component
public class LEA02968 extends QCCatalogue {
    @Override
    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
        status.set("0");
        if (inputInfo.getLeaveHospitalDoc() == null) {
            return;
        }

        Map<String, String> structureMap = inputInfo.getLeaveHospitalDoc().getStructureMap();
        String gender = structureMap.get("性别");
        if (StringUtil.isBlank(gender)) {
            return;
        }
        List<String> noMatchWords = null;
        if (gender.contains("男")) {
            /* 男性不合理词 */
            noMatchWords = Lists.newArrayList("阴道", "宫颈", "子宫", "宫底", "胎位", "胎数", "胎心",
                    "宫缩", "宫口", "输卵管", "卵巢", "输卵管", "阴唇", "阴蒂", "阴道前庭", "前庭大腺", "处女膜");
        } else if (gender.contains("女")) {
            /* 女性不合理词 */
            noMatchWords = Lists.newArrayList("睾丸", "阴茎", "精索", "包皮", "附睾", "输精管",
                    "射精管", "尿道海绵体", "冠状沟", "精阜", "精囊腺");
        }

        if (noMatchWords == null || noMatchWords.size() == 0) {
            return;
        }
        List<String> keys = Lists.newArrayList("入院诊断", "出院诊断", "入院情况", "诊治经过", "出院情况", "出院医嘱"
                , "随访计划", "主诉", "专科检查", "健康教育", "辅助检查", "影像学检查", "实验室检查");
        String text = CatalogueUtil.structureMapJoin(structureMap, keys);

        for (String noMatchWord : noMatchWords) {
            if (text.contains(noMatchWord)) {
                status.set("-1");
                info.set(noMatchWord);
                return;
            }
        }
    }
}