import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { DiagnosisVO, DiagnosisForm, DiagnosisQuery } from '@/api/patients/diagnosis/types';

/**
 * 查询营养诊断列表
 * @param query
 * @returns {*}
 */

export const listDiagnosis = (query?: DiagnosisQuery): AxiosPromise<DiagnosisVO[]> => {
    return request({
        url: '/patients/nutritionDiagnosis/list',
        method: 'get',
        params: query
    });
};

/**
 * 查询模板列表
 * @param query
 * @returns {*}
 */

export const queryTemplateList = () => {
    return request({
        url: '/patients/nutritionDiagnosis/queryTemplateList',
        method: 'get',
    });
};

/**
 * 查询营养诊断详细
 * @param id
 */
export const getDiagnosis = (id: string | number): AxiosPromise<DiagnosisVO> => {
    return request({
        url: '/patients/nutritionDiagnosis/' + id,
        method: 'get'
    });
};

/**
 * 新增营养诊断
 * @param data
 */
export const addDiagnosis = (data: DiagnosisForm) => {
    return request({
        url: '/patients/nutritionDiagnosis',
        method: 'post',
        data: data
    });
};

/**
 * 修改营养诊断
 * @param data
 */
export const updateDiagnosis = (data: DiagnosisForm) => {
    return request({
        url: '/patients/nutritionDiagnosis',
        method: 'put',
        data: data
    });
};

/**
 * 删除营养诊断
 * @param id
 */
export const delDiagnosis = (id: string | number | Array<string | number>) => {
    return request({
        url: '/patients/nutritionDiagnosis/' + id,
        method: 'delete'
    });
};
