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

  updateEntityName: "/healsphere/entity/updateEntityName",

  createRelationship: "/healsphere/relationship/createRelationship",
  findRelationshipType: "/healsphere/relationship/findRelationshipType", //根据名称模糊查询关系
  updateRelationshipType: "/healsphere/relationship/updateRelationshipType",
  createEntityProperty: "/healsphere/property/createEntityProperty", //批量新增实体属性
  deleteRelationship: "/healsphere/relationship/deleteRelationship",//批量删除关系
  findEntityListByName: "/healsphere/entity/findEntityListByName", //实体列表查询（根据标签和名字模糊查询实体）
  updateEntityProperty: "/healsphere/property/updateEntityProperty", //更新实体属性
  deleteEntityProperty: "/healsphere/property/deleteEntityProperty", //删除实体属性

  getCountList: "/healsphere/kg/count/getCountList",
  getCountInfo: "/healsphere/kg/count/getCountInfo",
  userGraphs: "/open-platform/kb/user_sub_graphs",
  getSelfTreeByUser: "/open-platform/kb/tree_structure",
  getSelfNode: '/open-platform/graph_mg/entity/search',

  // 自定义知识图谱
  createCustomEntity: '/open-platform/graph_mg/entity/create', //新建实体
  deleteCustomEntity: '/open-platform/graph_mg/entity/delete', //删除实体
  updateCustomEntity: '/open-platform/graph_mg/entity/update', //更新实体
  findCustomEntity: '/open-platform/graph_mg/entity/find', //查询实体（根据id查询实体）
  searchCustomEntity: '/open-platform/graph_mg/entity/search', //查询实体（根据名称模糊查询实体）
  createCustomRelationship: '/open-platform/graph_mg/relationship/create', //新建实体关系
  deleteCustomRelationship: '/open-platform/graph_mg/relationship/delete', //删除实体关系
  updateCustomRelationship: '/open-platform/graph_mg/relationship/update', //更新实体关系
  searchCustomRelationship: '/open-platform/graph_mg/relationship/search', //查询实体关系
  createCustomProperty: '/open-platform/graph_mg/property/create', //新建实体属性
  deleteCustomProperty: '/open-platform/graph_mg/property/delete', //删除实体属性
  updateCustomProperty: '/open-platform/graph_mg/property/update', //更新实体属性
  graphCategories: "/open-platform/kb/graph_categories",//查询类型列表
  graphMerge: "/open-platform/agent/job"//知识图谱融合

};
$(".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: 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 get = function (url, data) {
  return new Promise((resolve, reject) => {
    $.ajax({
      method: 'get',
      url: url,
      data: data,
      // contentType: "application/json; charset=UTF-8",
      beforeSend: function (xmlHttp) {
        xmlHttp.setRequestHeader("If-Modified-Since", "0");
        xmlHttp.setRequestHeader("Cache-Control", "no-cache");
      },
      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,
  get,
  typeLisName,
  typeLis,
  getUrlArgObject,
  ifHideLogo
}