import request from '@/utils/request'
// 病历相关接口
/**
 * 获取患者列表
 */
export function getList(queryParams) {
  return request({
    url: '/doctor-station/main/patient-info',
    method: 'get',
    params: queryParams
  })
}

/**
 * 获取患者历史病历
 */
export function getEmrHistoryList(queryParams) {
  return request({
    url: '/doctor-station/emr/emr-page',
    method: 'get',
    params: queryParams
  })
}

/**
 * 获取病历模板列表
 */
export function getEmrTemplateList(queryParams) {
  return request({
    url: '/doctor-station/emr/emr-template-page',
    method: 'get',
    params: queryParams
  })
}

/**
 * 接诊
 */
export function receiveEncounter(encounterId) {
  return request({
    url: '/doctor-station/main/receive-encounter?encounterId=' + encounterId,
    method: 'get',
  })
}

/**
 * 暂离
 */
export function leaveEncounter(encounterId) {
  return request({
    url: '/doctor-station/main/leave-encounter?encounterId=' + encounterId,
    method: 'get',
  })
}

/**
 * 完诊
 */
export function completeEncounter(encounterId) {
  return request({
    url: '/doctor-station/main/complete-encounter?encounterId=' + encounterId,
    method: 'get',
  })
}

/**
 * 取消接诊
 */
export function cancelEncounter(encounterId, config = {}) {
  return request({
    url: '/doctor-station/main/cancel-encounter?encounterId=' + encounterId,
    method: 'get',
    ...config
  })
}

/**
 * 保存病历
 */
export function saveEmr(data) {
  return request({
    url: '/doctor-station/emr/emr',
    method: 'post',
    data: data
  })
}

/**
 * 删除病历模板
 */
export function deleteEmrTemplate(id){
  return request({
    url: '/doctor-station/emr/emr-template?id=' + id,
    method: 'delete',
  })
}

/**
 * 获取病历详情
 */
export function getEmrDetail(encounterId){
  return request({
    url: '/doctor-station/emr/emr-detail?encounterId=' + encounterId,
    method: 'get',
  })
}

/**
 * 保存病历模板
 */
export function saveEmrTemplate(data){
  return request({
    url: '/doctor-station/emr/emr-template',
    method: 'post',
    data: data
  })
}

// 诊断相关接口
/**
 * 保存诊断
 */
export function saveDiagnosis(data) {
  return request({
    url: '/doctor-station/diagnosis/save-doctor-diagnosis',
    method: 'post',
    data: data
  })
}

/**
 * 添加诊断绑定
 */
export function saveDiagnosisBind(data) {
  return request({
    url: '/doctor-station/diagnosis/diagnosis-belong-binding',
    method: 'post',
    data: data
  })
}
/**
 * 删除诊断绑定
 */
export function deleteDiagnosisBind(id) {
  return request({
    url: '/doctor-station/diagnosis/diagnosis-belong-binding?id=' + id,
    method: 'delete',
  })
}

/**
 * 获取诊断定义列表
 */
export function getDiagnosisDefinitionList(queryParams) {
  return request({
    url: '/doctor-station/diagnosis/condition-definition-metadata',
    method: 'get',
    params: queryParams
  })
}

/**
 * 获取诊断分类数据，历史诊断/个人常用诊断/科室常用诊断
 */
export function getConditionDefinitionInfo(patientId) {
  return request({
    url: '/doctor-station/diagnosis/get-condition-definition-class?patientId=' + patientId,
    method: 'get',
  })
}

/**
 * 获取诊断基础下拉数据
 */
export function diagnosisInit() {
  return request({
    url: '/doctor-station/diagnosis/init',
    method: 'get',
  })
}

/**
 * 
 * 获取诊断回显数据
 */
export function getEncounterDiagnosis(encounterId) {
  return request({
    url: '/doctor-station/diagnosis/get-encounter-diagnosis?encounterId=' + encounterId,
    method: 'get',
  })
}

/**
 * 
 * 获取诊断集合数据
 */
export function getDiagnosisList(searchKey) {
    return request({
        url: '/doctor-station/diagnosis/get-diagnosis-list?searchKey=' + searchKey,
        method: 'get',
    })
}

/**
 * 
 * 删除就诊诊断
 */
export function delEncounterDiagnosis(conditionId) {
  return request({
    url: '/doctor-station/diagnosis/encounter-diagnosis?conditionId=' + conditionId,
    method: 'delete',
  })
}

// 处方相关接口
/**
 * 获取药品列表
 */
export function getAdviceBaseInfo(queryParams) {
  return request({
    url: '/doctor-station/advice/advice-base-info',
    method: 'get',
    params: queryParams
  })
}

/**
 * 获取耗材目录列表
 */
export function getDeviceList(queryParams) {
  return request({
    url: '/data-dictionary/device/information-page',
    method: 'get',
    params: queryParams
  })
}
/**
 * 保存处方(单条)
 */
export function savePrescription(data) {
  return request({
    url: '/doctor-station/advice/save-advice',
    method: 'post',
    data: data
  })
}
/**
 * 签发处方
 */
export function savePrescriptionSign(data) {
  return request({
    url: '/doctor-station/advice/sign-advice',
    method: 'post',
    data: data
  })
}
/**
 * 处方签退
 */
export function singOut(data) {
  return request({
    url: '/doctor-station/advice/sign-off',
    method: 'post',
    data: data,
    skipErrorMsg: true
  })
}
/**
 * 获取患者本次就诊处方
 */
export function getPrescriptionList(encounterId) {
  return request({
    url: '/doctor-station/advice/request-base-info?encounterId=' + encounterId,
    method: 'get',
  })
}
/**
 * 获取科室列表
 */
export function getOrgTree() {
  return request({
    url: '/base-data-manage/organization/organization',
    method: 'get',
  })
}
/**
 * 获取退费账单
 */
export function getEncounterPatientPayment(encounterId) {
  return request({
    url: '/charge-manage/refund/patient-payment?encounterId=' + encounterId,
    method: 'get',
  })
}
/**
 * 申请退费
 */
export function refundPayment(data) {
  return request({
    url: '/charge-manage/refund/refund-payment',
    method: 'post',
    data: data
  })
}


// 电子处方相关接口
/**
 * 电子处方查询
 */
export function getVeriPrescriptionInfo(queryParams) {
  return request({
    url: '/ybelep-request/get-PrescriptionInfo',
    method: 'get',
    params: queryParams
  })
}

// 处方开立相关接口
/**
 * 获取全部药品信息
 */
export function getAllMedicationInfo(queryParams) {
  return request({
    url: '/doctor-station/elep/get-allMedicationInfo',
    method: 'get',
    params: queryParams
  })
}
// 当返回的list为空时在调用get-allMedicationInfo
export function getAllMedicationUsualInfo(queryParams) {
  return request({
    url: '/doctor-station/elep/get-allMedicationUsualInfo',
    method: 'get',
    params: queryParams
  })
}
/**
 * 电子处方下拉框
 */
export function elepPrescriptionInit() {
  return request({
    url: '/doctor-station/elep/init',
    method: 'get'
  })
}

/**
 * 获取处方信息
 */
export function getPrescriptionInfo(queryParams) {
  return request({
    url: '/doctor-station/elep/get-prescriptionInfo',
    method: 'get',
    params: queryParams
  })
}

/**
 * 获取药品信息
 */
export function getMedicationInfo(queryParams) {
  return request({
    url: '/doctor-station/elep/get-medicationInfo',
    method: 'get',
    params: queryParams
  })
}

/**
 * 获取单据号
 */
export function prescriptionNoInit() {
  return request({
    url: '/doctor-station/elep/prescriptionNoInit',
    method: 'get'
  })
}

/**
 * 新增处方
 */
export function savePrescriptionInfo(data) {
  return request({
    url: '/doctor-station/elep/save-prescriptionInfo',
    method: 'post',
    data: data
  })
}

/**
 * 修改处方
 */
export function updatePrescriptionInfo(data) {
  return request({
    url: '/doctor-station/elep/update-prescriptionInfo',
    method: 'post',
    data: data
  })
}

/**
 * 删除处方
 */
export function deletePrescriptionInfo(data) {
  return request({
    url: '/doctor-station/elep/delete-prescriptionInfo',
    method: 'post',
    data: data
  })
}

/**
 * 签发处方
 */
export function issuancePrescription(prescriptionNoList) {
  return request({
    url: '/doctor-station/elep/issuance-prescription',
    method: 'post',
    data: prescriptionNoList
  })
}

/**
 * 获取医嘱历史数据
 */
export function getAdviceHistoryInfo(params) {
  return request({
    url: '/doctor-station/advice/request-history-info',
    method: 'get',
    params: params
  })
}

/**
 * 组合/拆组
 */
export function updateGroupId(data) {
  return request({
    url: '/doctor-station/advice/update-groupid',
    method: 'put',
    data: data
  })
}

/**
 * 组套列表
 */
export function getOrderGroupList(params) {
  return request({
    url: '/personalization/order-group/order-group',
    method: 'get',
    params: params
  })
}

/**
 * 获取费用性质
 */
export function getContract(params) {
  return request({
    url: '/doctor-station/advice/get-encounter-contract',
    method: 'get',
    params: params
  })
}


/**
 * 取得药品最新数据
 */
export function queryYbCatalogue(params) {
  return request({
    url: '/yb-request/query-yb-catalogue',
    method: 'post',
    params: params
  })
}

/**
 * 获取人员慢性病诊断
 */
export function getChronicDisease(params) {
  return request({
    url: '/yb-request/getConditionDefinition',
    method: 'get',
    params: params
  })
}

/**
 * 获取中药列表
 */
export function getTcmMedicine(params) {
  return request({
    url: '/doctor-station/chinese-medical/tcm-advice-base-info',
    method: 'get',
    params: params
  })
}

/**
 * 获取中医诊断
 */
export function getTcmCondition(params) {
  return request({
    url: '/doctor-station/chinese-medical/condition-info',
    method: 'get',
    params: params
  })
}

/**
 * 获取辩证分型
 */
export function getTcmSyndrome(params) {
  return request({
    url: '/doctor-station/chinese-medical/syndrome-info',
    method: 'get',
    params: params
  })
}

/**
 * 获取本次就诊中医诊断
 */
export function getTcmDiagnosis(params) {
  return request({
    url: '/doctor-station/chinese-medical/get-tcm-encounter-diagnosis',
    method: 'get',
    params: params
  })
}

/**
 * 保存中医诊断
 */
export function saveTcmDiagnosis(data) {
  return request({
    url: '/doctor-station/chinese-medical/save-tcm-diagnosis',
    method: 'post',
    data: data
  })
}

/**
 * 删除中医诊断
 */
export function deleteTcmDiagnosis(syndromeGroupNo) {
  return request({
    url: '/doctor-station/chinese-medical/tcm-diagnosis?syndromeGroupNo=' + syndromeGroupNo,
    method: 'delete',
  })
}

/**
 * 保存中医医嘱
 */
export function saveTcmAdvice(data) {
  return request({
    url: '/doctor-station/chinese-medical/save-tcm-advice',
    method: 'post',
    data: data
  })
}

/**
 * 签发中医医嘱
 */
export function signTcmAdvice(data) {
  return request({
    url: '/doctor-station/chinese-medical/sign-tcm-advice',
    method: 'post',
    data: data
  })
}

/**
 * 签退中医医嘱
 */
export function signOutTcmAdvice(data) {
  return request({
    url: '/doctor-station/chinese-medical/sign-tcm-off',
    method: 'post',
    data: data
  })
}

/**
 * 获取本次就诊中医医嘱
 */
export function getTcmAdviceList(params) {
  return request({
    url: '/doctor-station/chinese-medical/tcm-request-base-info',
    method: 'get',
    params: params
  })
}


/**
 * 获取预约记录
 */
export function getReservationInfo(params) {
  return request({
    url: '/doctor-station/reservation-record/reservation-info',
    method: 'get',
    params: params
  })
}

/**
 * 新增预约记录
 */
export function addReservationInfo(data) {
  return request({
    url: '/doctor-station/reservation-record/save-reservation',
    method: 'post',
    data: data
  })
}

/**
 * 修改预约记录
 */
export function editReservationInfo(data) {
  return request({
    url: '/doctor-station/reservation-record/edit-reservation',
    method: 'put',
    data: data
  })
}

/**
 * 删除预约记录
 */
export function delReservationInfo(id) {
  return request({
    url: '/doctor-station/reservation-record/del-reservation',
    method: 'delete',
    params: id
  })
}


// 查询初期所需数据
export function getInit() {
  return request({
    url: '/charge-manage/register/init',
    method: 'get'
  })
}

/**
 * 查询参与者下拉列表
 */
export function queryParticipantList(params) {
  return request({
    url: '/app-common/practitioner-list',
    method: 'get',
    params: params
  })
}

/**
 * 获取科室下拉列表
 */
export function getOrgList() {
  return request({
    url: '/base-data-manage/organization/organization',
    method: 'get',
  })
}

/**
 * 查询病区下拉列表
 */
export function wardList(params) {
  return request({
    url: '/app-common/ward-list',
    method: 'get',
    params: params
  })
}

/**
 * 办理入院
 */
export function handleHospitalization(data) {
  return request({
    url: '/inhospital-charge/register/by-doctor',
    method: 'post',
    data: data
  })
}

/**
 * 获取本次就诊处方单
 */
export function getEnPrescriptionInfo(data) {
  return request({
    url: '/doctor-station/main/prescription-page-info',
    method: 'get',
    params: data
  })
}

/**
 * 获取组套列表
 */
export function getOrderGroup(data) {
  return request({
    url: '/personalization/orders-group-package/group-package-for-order',
    method: 'get',
    params: data
  })
}

/**
 * 查询项目绑定信息
 */
export function getBindDevice(data) {
  return request({
    url: '/doctor-station/advice/order-bind-info',
    method: 'get',
    params: data
  })
}

/**
 * 是否是食源性诊断
 */
export function isFoodDiseasesNew(params) {
  return request({
    url: '/external-integration/foodborne-acquisition/is-food-diseases-new',
    method: 'get',
    params: params
  })
}
