import request from '@/utils/request';
import {AxiosPromise} from 'axios';
import {EnteralNutritionVO, EnteralNutritionForm, EnteralNutritionQuery, EnteralNutritionSaveForm} from '@/api/patients/nutrition/types';

/**
 * 查询肠内营养列表
 * @param query
 * @returns {*}
 *
 */

export const listEnteralNutrition = (query?: EnteralNutritionQuery): AxiosPromise<EnteralNutritionVO[]> => {
  return request({
    url: '/system/nutrition/list',
    method: 'get',
    params: query
  });
};

export const listEnteralNutritionHistory = (query?: EnteralNutritionQuery): AxiosPromise<EnteralNutritionVO[]> => {
  return request({
    url: '/system/nutrition/listHistory',
    method: 'get',
    params: query
  });
};

export const listEnteralNutritionDetail = (id?: number): AxiosPromise<EnteralNutritionVO[]> => {
  return request({
    url: '/system/nutrition/detail?id=' + id,
    method: 'get'
  });
};

/**
 * 查询肠内营养详细
 * @param id
 */
export const getEnteralNutrition = (id: string | number): AxiosPromise<EnteralNutritionVO> => {
  return request({
    url: '/system/nutrition/' + id,
    method: 'get'
  });
};

/**
 * 新增肠内营养
 * @param data
 */
export const addEnteralNutrition = (data: EnteralNutritionSaveForm) => {
  return request({
    url: '/system/nutrition',
    method: 'post',
    data: data
  });
};

/**
 * 修改肠内营养
 * @param data
 */
export const updateEnteralNutrition = (data: EnteralNutritionForm) => {
  return request({
    url: '/system/nutrition',
    method: 'put',
    data: data
  });
};

/**
 * 删除肠内营养
 * @param id
 */
export const delEnteralNutrition = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/nutrition/' + id,
    method: 'delete'
  });
};
