
const api = {
  getGraph: '/kg/getGraph',
  getNode: '/kg/getNode',
  getSchema: '/api/ltkg/kg/getSchema',
  getTree: '/kg/getTree',
  entity_predict: 'api/ltkg/nlp/getNlp',
  getMrInfo: '/api/ltkg/presetInfo/getMrInfo',
  getAnswer: '/api/ltkg/qa/charBot',
  getTerm: '/api/ltkg/term/getTerm',
  check: 'http://192.168.2.121:7010/test/testStandConvert',
  findEntity: "/entity/findEntity", //实体详情查询（根据id查询实体）
  deleteEntity: "/entity/deleteEntity", //批量删除实体
  mergeEntity: "/entity/mergeEntity",//实体合并

};
$(".goto-homeStatic").on("click", function () {
  window.location.href = "http://192.168.2.121:5666" + $(this).attr("link");
});
const getUrlArgObject = function (name) {//
  var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
  var reg_rewrite = new RegExp("(^|/)" + name + "/([^/]*)(/|$)", "i");
  var r = window.location.search.slice(1).match(reg);
  var q = window.location.pathname.slice(1).match(reg_rewrite);
  if (r != null) {
    return decodeURIComponent(r[2]);
  } else if (q != null) {
    return decodeURIComponent(q[2]);
  } else {
    return null;
  }
}
//判断隐藏logo
const ifHideLogo = function () {
  const hideLg = getUrlArgObject("hideLg");
  if (hideLg) {
    $(".ltLogo").hide();
  }
}



const post = function (url, data, pId) {
  const securityCode = getUrlArgObject("code");
  const appKeyId = getUrlArgObject("appI");
  const appKeySecret = getUrlArgObject("appS");
  const productId = getUrlArgObject("productId");
  return new Promise((resolve, reject) => {
    $.ajax({
      method: 'post',
      url: '/api' + url,
      data: JSON.stringify(data),
      contentType: "application/json; charset=UTF-8",
      beforeSend: function (xmlHttp) {
        xmlHttp.setRequestHeader("If-Modified-Since", "0");
        xmlHttp.setRequestHeader("Cache-Control", "no-cache");
        xmlHttp.setRequestHeader("appKeyId", appKeyId);
        xmlHttp.setRequestHeader("appKeySecret", appKeySecret);
        xmlHttp.setRequestHeader("securityCode", securityCode);
        xmlHttp.setRequestHeader("productId", productId);
      },
      success: function (res) {
        resolve({ data: res });
      },
      error: function (error) {
        reject(error);
      },
    });
  });
}

const typeLis = {
  "临床表现": "symptom",
  "疾病名称": "disease",
  "手术名称": "operation",
  "药物名称": "drug",
  "药物过敏原": "drug",
  "实验室检查套餐": "lis",
  "实验室检查": "lis",
  "辅助检查": "pacs",
  "体征": "vital",
}
const typeLisName = {
  "临床表现": "症状",
  "疾病名称": "疾病",
  "手术名称": "手术和操作",
  "药物名称": "药品",
  "药物过敏原": "药品",
  "实验室检查套餐": "实验室检查",
  "实验室检查": "实验室检查",
  "辅助检查": "辅助检查",
  "体征": "辅助检查",
}
module.exports = {
  post,
  api,
  typeLisName,
  typeLis,
  getUrlArgObject,
  ifHideLogo
}