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

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.util.StringUtil;
import org.springframework.stereotype.Component;

import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @ClassName : BEH03058
 * @Description : 入院记录体格检查疼痛评分与专科检查疼痛评分不一致
 * @Author : 楼辉荣
 * @Date: 2020-03-06 17:28
 */
@Component
public class BEH03058 extends QCCatalogue {

    public void start(InputInfo inputInfo, OutputInfo outputInfo) {
        status.set("0");
        if (inputInfo.getBeHospitalizedDoc() == null || inputInfo.getBeHospitalizedDoc().getStructureMap() == null) {
            return;
        }
        Map<String, String> structureMap = inputInfo.getBeHospitalizedDoc().getStructureMap();
        String souval = structureMap.get("疼痛评分");
        String tarval = null;
        String vitalLabelSpecial = structureMap.get("专科体格检查");
        if (StringUtil.isNotBlank(vitalLabelSpecial)) {
            Pattern pattern = Pattern.compile("(疼痛)[^，；。,;体温|脉搏|呼吸|血压|疼痛]+");
            Matcher matcher = pattern.matcher(vitalLabelSpecial);
            if (matcher.find()) {
                pattern = Pattern.compile("[0-9]+[./]*[0-9]*");
                matcher = pattern.matcher(matcher.group());
                if (matcher.find()) {
                    tarval = matcher.group();
                }
            }
        }
        if (StringUtil.isNotBlank(souval) && StringUtil.isNotBlank(tarval) && !souval.equals(tarval)) {
            status.set("-1");
        }
    }

}