package org.diagbot.bigdata.work;

import org.algorithm.util.AlgorithmClassify;
import org.apache.commons.lang3.StringUtils;
import org.diagbot.common.push.bean.SearchData;
import org.diagbot.common.push.work.ParamsDataProxy;
import org.diagbot.nlp.feature.FeatureType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @ClassName org.diagbot.bigdata.work.ParamsDataProxy
 * @Description TODO
 * @Author fyeman
 * @Date 2019/1/16/016 14:04
 * @Version 1.0
 **/
public class BigDataParamsProxy {
    Logger logger = LoggerFactory.getLogger(BigDataParamsProxy.class);

    public void createSearchData(SearchData searchData) throws Exception {
        ParamsDataProxy paramsDataProxy = new ParamsDataProxy();
        paramsDataProxy.createSearchData(searchData);
    }

    /**
     * featureType转算法模型类型
     *
     * @param sysCode
     * @param featureTypes
     * @param searchData
     */
    public AlgorithmClassify[] createAlgorithmClassify(String sysCode, String[] featureTypes, SearchData searchData) {
        AlgorithmClassify[] classifies = new AlgorithmClassify[featureTypes.length];
        //下了诊断且其他信息全为空 反推标识
        boolean reverse = !StringUtils.isEmpty(searchData.getDiag()) && StringUtils.isEmpty(searchData.getSymptom());
        for (int i = 0; i < featureTypes.length; i++) {
            if (featureTypes[i] != null) {
                //模型
                switch (FeatureType.parse(featureTypes[i])) {
                    case SYMPTOM:
                        if (reverse) {
                            classifies[i] = AlgorithmClassify.NEURAL_DIAG_SYMPTOM;
                        } else {
                            classifies[i] = AlgorithmClassify.NEURAL_SYMPTOM;
                        }
                        break;
                    case DIAG:
                        if (reverse) {
                            classifies[i] = null;
                        } else {
                            classifies[i] = AlgorithmClassify.NEURAL_DIAG;
                        }
                        break;
                    case VITAL:
                        if (reverse) {
                            classifies[i] = AlgorithmClassify.NEURAL_DIAG_VITAL;
                        } else {
                            classifies[i] = AlgorithmClassify.NEURAL_VITAL;
                        }
                        break;
                    case LIS:
                        if (reverse) {
                            classifies[i] = AlgorithmClassify.NEURAL_DIAG_LIS;
                        } else {
                            classifies[i] = AlgorithmClassify.NEURAL_LIS;
                        }
                        break;
                    case PACS:
                        if (reverse) {
                            classifies[i] = AlgorithmClassify.NEURAL_DIAG_PACS;
                        } else {
                            classifies[i] = AlgorithmClassify.NEURAL_PACS;
                        }
                        break;
                    case TREAT:
                        if (reverse) {
                            classifies[i] = AlgorithmClassify.NEURAL_DIAG_TREAT;
                        } else {
                            classifies[i] = AlgorithmClassify.NEURAL_TREAT;
                        }
                        break;
                    case HISTORY:
                        if (reverse) {
                            classifies[i] = AlgorithmClassify.NEURAL_DIAG_HISTORY;
                        } else {
                            classifies[i] = AlgorithmClassify.NEURAL_HISTORY;
                        }
                        break;
                }
            }
        }
        return classifies;
    }
}