import request from '@/utils/request'
import requestDownload from '@/utils/request-download'
export function addBaseLineLesion(param) {
  return request({
    url: '/report/addBaseLineLesion',
    method: 'post',
    data: param
  })
}

export function getBLLineLesion(trialCode, subjectCode, tpCode) {
  return request({
    url: `/report/getBLLineLesion/${trialCode}/${subjectCode}/${tpCode}`,
    method: 'get'
  })
}

export function getVisitLineLesion(trialCode, subjectCode, visitNum, tpCode) {
  return request({
    url: `/report/getVisitLineLesion/${trialCode}/${subjectCode}/${visitNum}/${tpCode}`,
    method: 'get'
  })
}

export function saveVisitReport(param) {
  return request({
    url: '/report/saveVisitReport',
    method: 'post',
    data: param
  })
}

export function submiteReport(tpId) {
  return request({
    url: `/report/submiteReport/${tpId}`,
    method: 'post'
  })
}

export function saveImageLabelList(param) {
  return request({
    url: '/study/saveImageLabelList',
    method: 'post',
    data: param
  })
}

export function getStudyInfo(studyId, params) {
  return request({
    url: `/Study/item/${studyId}`,
    method: 'get',
    params
  })
}
export function getSeriesList(url) {
  return request({
    url: url,
    method: 'get'
  })
}
export function getInstanceList(seriesId) {
  return request({
    url: `/instance/list/id/${seriesId}`,
    method: 'get'
  })
}
export function getImageLabelList(tpCode) {
  return request({
    url: `/study/getImageLabelList/${tpCode}`,
    method: 'get'
  })
}
export function getRelationVisitList(visitNum, tpCode) {
  return request({
    url: `/study/getRelationVisitList/${visitNum}/${tpCode}`,
    method: 'get'
  })
}
export function getAllRelationStudyList(studyId, params) {
  return request({
    url: `/study/getAllRelationStudyList/${studyId}`,
    method: 'get',
    params
  })
}
export function getTrialListByReviewer(param) {
  return request({
    url: `/trial/getTrialListByReviewer`,
    method: 'post',
    data: param
  })
}

export function updateEnrollStatus(trialId, status) {
  return request({
    url: `/trial/updateEnrollStatus/${trialId}/${status}`,
    method: 'post'
  })
}

export function getHistoryVisitRsList(trialId, subjectId, visitNum, globalId, globalCode) {
  return request({
    url: `/globalReport/getHistoryVisitRsList/${trialId}/${subjectId}/${visitNum}/${globalId}/${globalCode}`,
    method: 'get'
  })
}

export function getHistoryGlobalRsList(trialId, subjectCode, visitNum, globalId) {
  return request({
    url: `/globalReport/getHistoryGlobalRsList/${trialId}/${subjectCode}/${visitNum}/${globalId}`,
    method: 'get'
  })
}

export function AddGlobalReport(param) {
  return request({
    url: `/globalReport/AddGlobalReport`,
    method: 'post',
    data: param
  })
}

export function GetAdReport(adId) {
  return request({
    url: `/globalReport/getAdReport/${adId}`,
    method: 'get'
  })
}

export function AddAdjudicationReport(param) {
  return request({
    url: `/globalReport/AddAdjudicationReport`,
    method: 'post',
    data: param
  })
}

export function getVisitStudyList(trialId, subjectVisitId, isReading, visitTaskId) {
  let url = `/SubjectVisit/getVisitStudyList/${trialId}/${subjectVisitId}/${isReading}`
  url = visitTaskId ? `${url}?visitTaskId=${visitTaskId}` : url
  return request({
    url: url,
    method: 'get'
  })
}

export function uploadPrintscreen(param, subjectId) {
  return request({
    url: `/Printscreen/UploadPrintscreen/${subjectId}`,
    method: 'post',
    data: param
  })
}

export function submitCustomTag(param) {
  return request({
    url: `/ReadingImageTask/submitCustomTag`,
    method: 'post',
    data: param
  })
}

export function deleteCustomTag(param) {
  return request({
    url: `/ReadingImageTask/deleteCustomTag/{id}`,
    method: 'post',
    data: param
  })
}

export function getCustomTag(param) {
  return request({
    url: `/ReadingImageTask/getCustomTag`,
    method: 'post',
    data: param
  })
}

export function clearSkipReadingCache(param) {
  return request({
    url: `/ReadingImageTask/clearSkipReadingCache`,
    method: 'post',
    data: param
  })
}

export function setSkipReadingCache(param) {
  return request({
    url: `/ReadingImageTask/setSkipReadingCache`,
    method: 'post',
    data: param
  })
}
export function resetReadingTask(param) {
  return request({
    url: `/ReadingImageTask/resetReadingTask`,
    method: 'post',
    data: param
  })
}
export function getTaskUploadedDicomStudyList(param) {
  return request({
    url: `/DownloadAndUpload/getTaskUploadedDicomStudyList`,
    method: 'post',
    data: param
  })
}
export function getIVUSTemplate(param) {
  return requestDownload({
    url: '/IVUSCalculate/getIVUSTemplate',
    method: 'post',
    responseType: 'blob',
    data: param
  })
}
export function getIVUSTemplatesZip(param) {
  return requestDownload({
    url: '/IVUSCalculate/getIVUSTemplatesZip',
    method: 'post',
    responseType: 'blob',
    data: param
  })
}
export function uploadIVUSTemplate(param) {
  return request({
    url: `/IVUSCalculate/uploadIVUSTemplate`,
    method: 'post',
    data: param
  })
}

export function getOCTFCTTemplate(param) {
  return requestDownload({
    url: '/OCTCalculate/getOCTFCTTemplate',
    method: 'post',
    responseType: 'blob',
    data: param
  })
}
export function getOCTFCTTemplatesZip(param) {
  return requestDownload({
    url: '/OCTCalculate/getOCTFCTTemplatesZip',
    method: 'post',
    responseType: 'blob',
    data: param
  })
}
export function uploadOCTFCTTemplate(param) {
  return request({
    url: `/OCTCalculate/uploadOCTFCTTemplate`,
    method: 'post',
    data: param
  })
}

export function getOCTLipidAngleTemplate(param) {
  return requestDownload({
    url: '/OCTCalculate/getOCTLipidAngleTemplate',
    method: 'post',
    responseType: 'blob',
    data: param
  })
}
export function uploadOCTLipidAngleTemplate(param) {
  return request({
    url: `/OCTCalculate/uploadOCTLipidAngleTemplate`,
    method: 'post',
    data: param
  })
}

export function saveTableQuestionMark(param, type) {
  return request({
    url: `/saveTableQuestionMark/${type}`,
    method: 'post',
    data: param
  })
}

export function deleteTableQuestionMark(param, type) {
  return request({
    url: `/deleteTableQuestionMark/${type}`,
    method: 'post',
    data: param
  })
}

export function submitTaskRowInfo(param, type) {
  return request({
    url: `/SubmitTaskRowInfo/${type}`,
    method: 'post',
    data: param
  })
}

export function deleteSingleTableQuestionMark(param, type) {
  return request({
    url: `/DeleteSingleTableQuestionMark/${type}`,
    method: 'post',
    data: param
  })
}

// 阅片导入
export function readingImport(param) {
  return request({
    url: `/ReadingCalculate/readingImport`,
    method: 'post',
    data: param
  })
}

// 非dicom阅片保存标记
export function saveAnswerAndBindingNoneDicomMark(param) {
  return request({
    url: `/ReadingImageTask/saveAnswerAndBindingNoneDicomMark`,
    method: 'post',
    data: param
  })
}
// 非dicom按比例修改答案
export function changePlottingScaleChangeAnswer(param) {
  return request({
    url: `/ReadingImageTask/changePlottingScaleChangeAnswer`,
    method: 'post',
    data: param
  })
}
// 阅片获取图表数据
export function getReportsChartData(param) {
  return request({
    url: `/ReadingImageTask/getReportsChartData`,
    method: 'post',
    data: param
  })
}

// 分割相关
// 获取分割组
export function getSegmentationList(param) {
  return request({
    url: `/Segmentation/getSegmentationList`,
    method: 'post',
    data: param
  })
}
// 新增修改分割组
export function addOrUpdateSegmentation(param) {
  return request({
    url: `/Segmentation/addOrUpdateSegmentation`,
    method: 'post',
    data: param
  })
}
// 删除分割组
export function deleteSegmentation(segmentationId) {
  return request({
    url: `/Segmentation/deleteSegmentation/${segmentationId}`,
    method: 'delete'
  })
}
// 获取分割
export function getSegmentList(param) {
  return request({
    url: `/Segmentation/getSegmentList`,
    method: 'post',
    data: param
  })
}
// 新增修改分割
export function addOrUpdateSegment(param) {
  return request({
    url: `/Segmentation/addOrUpdateSegment`,
    method: 'post',
    data: param
  })
}
// 删除分割
export function deleteSegment(segmentId) {
  return request({
    url: `/Segmentation/deleteSegment/${segmentId}`,
    method: 'delete'
  })
}
// 获取分割绑定关系
export function getSegmentBindingList(param) {
  return request({
    url: `/Segmentation/getSegmentBindingList`,
    method: 'post',
    data: param
  })
}
// 保存分割绑定关系（可用作修改删除）
export function saveSegmentBindingAndAnswer(param) {
  return request({
    url: `/Segmentation/saveSegmentBindingAndAnswer`,
    method: 'post',
    data: param
  })
}

// 获取表格问题配置
export function getReadingTableQuestionTrialById(params) {
  return request({
    url: `/ReadingQuestion/getReadingTableQuestionTrialById`,
    method: 'post',
    params
  })
}
// 获取外层问题配置
export function getReadingQuestionTrialById(params) {
  return request({
    url: `/ReadingQuestion/getReadingQuestionTrialById`,
    method: 'post',
    params
  })
}
// 修改分割组保存状态
export function changeSegmentationSavedStatus(data) {
  return request({
    url: `/Segmentation/changeSegmentationSavedStatus`,
    method: 'post',
    data
  })
}
// 修改分割片段锁定状态
export function lockOrUnLockSegment(data) {
  return request({
    url: `/Segmentation/lockOrUnLockSegment`,
    method: 'post',
    data
  })
}
// 图像数据匿名
export function studyMaskImage(data) {
  return request({
    url: `/Study/studyMaskImage`,
    method: 'post',
    data
  })
}
// 撤销匿名
export function studyUndoMaskImage(data) {
  return request({
    url: `/Study/studyUndoMaskImage`,
    method: 'post',
    data
  })
}
// 非dicom图像数据匿名
export function noneDicomStudyMaskImage(data) {
  return request({
    url: `/NoneDicomStudy/noneDicomStudyMaskImage`,
    method: 'post',
    data
  })
}
// 非dicom图像数据撤销匿名
export function noneDicomStudyUndoMaskImage(data) {
  return request({
    url: `/NoneDicomStudy/noneDicomStudyUndoMaskImage`,
    method: 'post',
    data
  })
}
// 获取分割组历史版本
export function getSegmentationVersionList(data) {
  return request({
    url: `/Segmentation/getSegmentationVersionList`,
    method: 'post',
    data
  })
}
// 恢复分割历史版本
export function restoreSegmentationVersion(data) {
  return request({
    url: `/Segmentation/restoreSegmentationVersion`,
    method: 'post',
    data
  })
}

// 获取标记信息
export function getMarkList(data) {
  return request({
    url: `/ReadingImageTask/getMarkList`,
    method: 'post',
    data
  })
}
export function getNoneDicomMarkList(data) {
  return request({
    url: `/ReadingImageTask/getNoneDicomMarkList`,
    method: 'post',
    data
  })
}

export function getFilterTableQuestion(data) {
  return request({
    url: `/ReadingImageTask/getFilterTableQuestion`,
    method: 'post',
    data
  })
}
