package org.diagbot.graphWeb.work;

import org.diagbot.common.push.bean.SearchData;
import org.diagbot.graph.javabean.GdbResponse;
import org.diagbot.pub.api.Response;
import org.diagbot.pub.utils.PropertiesUtil;
import org.diagbot.pub.utils.http.HttpApi;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

public class HighRiskCalculate {
    public Response<GdbResponse> calculateHighRisk(HttpServletRequest request, SearchData searchData) throws Exception {
        GdbResponse responseData = new GdbResponse();
        Response<GdbResponse> objectResponse = new Response<>();
        PropertiesUtil propertiesUtil = new PropertiesUtil("url.properties");
        //调用图谱API
        HttpApi<Response> api = new HttpApi<Response>();
        // 根据疾病信息获取高危属性
        Response highRiskResponse = api.doPost(propertiesUtil.getProperty("highrisk.http.url"), searchData,
                Response.class);
        Map data = (Map<String, Map>)highRiskResponse.getData();
        responseData.setStatus(data.get("status").toString());
        responseData.setResult((Map<String,String>)data.get("result"));
        objectResponse.setData(responseData);
        return objectResponse;
    }
}
