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

import com.google.common.collect.Lists;
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.BeHospitalizedDoc;
import com.lantone.qc.pub.util.StringUtil;
import org.springframework.stereotype.Component;

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

/**
 * @ClassName : BEH03048
 * @Description : 入院记录体格检查与专科检查不一致
 * @Author : 胡敬
 * @Date: 2020-07-28 09:52
 */
@Component
public class BEH03048 extends QCCatalogue {
    private List<String> vitals = Lists.newArrayList("Murphy征", "麦氏点压痛");

    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
        status.set("0");
        if (inputInfo.getBeHospitalizedDoc() == null) {
            return;
        }

        BeHospitalizedDoc beHospitalizedDoc = inputInfo.getBeHospitalizedDoc();
        Map<String, String> beHospitalStructureMap = beHospitalizedDoc.getStructureMap();
        String vitalLabelSpecial = beHospitalStructureMap.get("专科体格检查");
        if (StringUtil.isBlank(vitalLabelSpecial)) {
            return;
        }
        vitalLabelSpecial = vitalLabelSpecial.replace("墨菲氏征", "Murphy征");

        for (String vital : vitals) {
            String v = beHospitalStructureMap.get(vital);
            if (StringUtil.isNotBlank(v)) {
                v = v.replace("无", "阴性");
                v = vital + v;
                if (vitalLabelSpecial.contains(vital) && !vitalLabelSpecial.contains(v)) {
                    status.set("-1");
                    info.set(vital);
                    return;
                }
            }

        }
    }
}