import request from '/@/utils/request';
import type { AxiosPromise } from 'axios';
import type { ICommonListParams } from '../common.type';
import type { DrugOrderTemplate, DrugTemplate } from './types/index';

export function addTemplate(data: object) {
  return request({
    url: '/patient/drug/order/template/add',
    method: 'post',
    data
  })
}
/**
 * 获取药物医嘱模板列表
 * @param params 
 * @returns 
 */
export function getTemplateList(params: ICommonListParams) :AxiosPromise<DrugOrderTemplate> {
  return request({
    url: '/patient/drug/order/template/list',
    method: 'post',
    params
  })
}

/**
 * 获取药物医嘱模板列表API2
 * @param params 
 * @returns 
 */
export function getTemplateList2(params: object) :AxiosPromise<DrugTemplate[]> {
  return request({
      url: '/patient/drug/order/template/listTemplate',
      method: 'post',
      headers: {
          'Content-Type': 'application/x-www-form-urlencoded'
      },
      params
  })
}
// 编辑医嘱
export function updateTemplate(data: object) {
  return request({
    url: '/patient/drug/order/template/update',
    method: 'post',
    data
  })
}
// 删除模板名称
export function deleteTemplate(id: number) {
  return request({
    url: '/patient/drug/order/template/delete',
    method: 'post',
    params: {
      id
    }
  })
}
export function saveSubOrder(params: object) {
  return request({
    url: '/patient/drug/order/vs/template/order/saveSubOrder',
    method: 'post',
    data:params
  })
}
export function saveOrder(params: object) {
  return request({
      url: '/patient/drug/order/template/saveOrder',
      method: 'post',
      data:params
  })
}
export function deleteOrder(params: object) {
  return request({
      url: '/patient/drug/order/template/deleteOrder',
      method: 'post',
      headers: {
          'Content-Type': 'application/x-www-form-urlencoded'
      },
      params
  })
}