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;

/**
 * @ClassName : BEH03049
 * @Description : 入院记录中脉搏与心率不一致
 * @Author : 楼辉荣
 * @Date: 2020-03-06 17:28
 */
@Component
public class BEH03049 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 initialDiag = structureMap.get("初步诊断");
        if (StringUtil.isBlank(initialDiag)) {
            return;
        }
        String souval = structureMap.get("脉搏");
        String tarval = structureMap.get("心率");
        if (StringUtil.isNotBlank(souval)
                && StringUtil.isNotBlank(tarval)
                && initialDiag.indexOf("房颤") == -1
                && initialDiag.indexOf("纤颤") == -1
                && initialDiag.indexOf("房扑") == -1) {
            souval = souval.replaceAll("[^0-9]*", "");
            tarval = tarval.replaceAll("[^0-9]*", "");
            if (StringUtil.isNotBlank(souval) && StringUtil.isNotBlank(tarval) && !souval.equals(tarval)) {
                status.set("-1");
            }
        }
    }

}