44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
|
|
import { apiClient } from './client';
|
||
|
|
import {
|
||
|
|
CreatePatientInput,
|
||
|
|
CreateTreatmentHistoryInput,
|
||
|
|
Patient,
|
||
|
|
PatientsListResponse,
|
||
|
|
TreatmentHistoryItem,
|
||
|
|
} from '@/types/patient';
|
||
|
|
|
||
|
|
export const patientsApi = {
|
||
|
|
list: async (params?: { q?: string; page?: number; limit?: number }): Promise<PatientsListResponse> => {
|
||
|
|
const response = await apiClient.get('/patients', { params });
|
||
|
|
return response.data;
|
||
|
|
},
|
||
|
|
|
||
|
|
create: async (data: CreatePatientInput): Promise<{ success: boolean; data: Patient }> => {
|
||
|
|
const response = await apiClient.post('/patients', data);
|
||
|
|
return response.data;
|
||
|
|
},
|
||
|
|
|
||
|
|
getOne: async (id: string): Promise<{ success: boolean; data: Patient }> => {
|
||
|
|
const response = await apiClient.get(`/patients/${id}`);
|
||
|
|
return response.data;
|
||
|
|
},
|
||
|
|
|
||
|
|
listTreatments: async (
|
||
|
|
patientId: string,
|
||
|
|
limit = 20,
|
||
|
|
): Promise<{ success: boolean; data: TreatmentHistoryItem[] }> => {
|
||
|
|
const response = await apiClient.get(`/patients/${patientId}/treatments`, {
|
||
|
|
params: { limit },
|
||
|
|
});
|
||
|
|
return response.data;
|
||
|
|
},
|
||
|
|
|
||
|
|
addTreatment: async (
|
||
|
|
patientId: string,
|
||
|
|
data: CreateTreatmentHistoryInput,
|
||
|
|
): Promise<{ success: boolean; data: TreatmentHistoryItem }> => {
|
||
|
|
const response = await apiClient.post(`/patients/${patientId}/treatments`, data);
|
||
|
|
return response.data;
|
||
|
|
},
|
||
|
|
};
|