import request from "@/utils/request";

// 患者管理-随访患者
const BASE_URL = "/sf-work/patient";
const BASE_URL2 = "/sf-work/patient-doctor";
const BASE_URL3 = "/sf-work/follow-document";
// 查询随访患者列表
export function patientPageList(query) {
  return request({
    url: `${BASE_URL}/list`,
    method: "get",
    params: query,
  });
}

// 患者管理-批量导入
export function batchImportPatient(file) {
  const formData = new FormData();
  formData.append("file", file);
  return request({
    timeout: 60 * 1000 * 10, // 10分钟
    url: `${BASE_URL}/import`,
    method: "post",
    data: formData,
    headers: {
      "Content-Type": "multipart/form-data",
    },
  });
}

// 患者管理-患者详情
export function patientDetail(id) {
  return request({
    url: `${BASE_URL}/detail/${id}`,
    method: "get",
  });
}

// 患者管理-新增患者
export function addPatient(data) {
  return request({
    url: `${BASE_URL}/save`,
    method: "post",
    data,
  });
}

// 患者管理-编辑患者
export function editPatient(data) {
  return request({
    url: `${BASE_URL}/edit`,
    method: "patch",
    data,
  });
}
// 绑定医生
export function bindDoctorApi(data) {
  return request({
    url: `${BASE_URL2}/binding`,
    method: 'post',
    data
  })
}
// 解绑医生
export function unbindDoctorApi(data) {
  return request({
    url: `${BASE_URL2}/unbind`,
    method: "post",
    data,
  });
}

// 查看就诊人报道状态
export function getReportStatusApi(patientId) {
  return request({
    url: `${BASE_URL2}/list/${patientId}`,
  });
}

// 患者管理-删除患者
export function delPatient(id) {
  return request({
    url: `${BASE_URL}/del/${id}`,
    method: "post",
  });
}
// 患者管理-获取患者就诊记录
export function getMedicalRecordList(patientId) {
  return request({
    url: `${BASE_URL}-medical-record/list/${patientId}`,
    method: "get",
  });
}

// 患者管理-新增患者就诊记录
export function addMedicalRecord(data) {
  return request({
    url: `${BASE_URL}-medical-record/save`,
    method: "post",
    data,
  });
}

// 患者管理-编辑患者就诊记录
export function editMedicalRecord(data) {
  return request({
    url: `${BASE_URL}-medical-record/save`,
    method: "patch",
    data,
  });
}

// 患者管理-删除患者就诊记录
export function delMedicalRecord(id) {
  return request({
    url: `${BASE_URL}-medical-record/del/${id}`,
    method: "post",
  });
}

// 校验删除责任医生
export function patientCheckDelDoctor(query) {
  return request({
    url: `${BASE_URL}/checkDelDoctor`,
    method: "get",
    params: query,
  });
}

// 获取随访计划
export function getFollowupPlanListApi(params) {
  return request({
    url: `${BASE_URL3}/select-follow-page`,
    method: "get",
    params,
  });
}
// 获取报到列表
export function getFollowupReportListAPi(patientId) {
  return request({
    url: `${BASE_URL2}/list/${patientId}`,
    method: "get",
    params: {},
  });
}

// 提交随访计划
export function submitFollowupPlanApi(data) {
  return request({
    url: `${BASE_URL3}/submit`,
    method: "post",
    data
  })
}

// 查询随访计划
export function getFollowTaskDetailApi(data) {
  return request({
    url: `${BASE_URL3}/get-follow-task`,
    method: "post",
    data
  })
}

// 停止随访计划
export function stopFollowDocumentApi(data) {
  return request({
    url: `${BASE_URL3}/cancel`,
    method: 'post',
    data
  })
}
// 删除随访计划
export function deleteFollowDocumentApi(data) {
  return request({
    url: `${BASE_URL3}/delete`,
    method: 'post',
    data
  })
}

// 完成问卷
export function finishWaitProcessItemApi(data) {
  return request({
    url: `${BASE_URL3}/process-item`,
    method: 'post',
    data
  })
}
