metms_fe/src/services/patientServices.ts
2026-05-24 23:33:43 +07:00

119 lines
2.5 KiB
TypeScript

import axiosClient from ".";
export interface PatientItem {
id: string;
patientCode: string;
identificationNumber: string;
fullName: string;
dateOfBirth: string;
gender: string;
phone: string;
email: string;
address: string;
emergencyContactName?: string;
emergencyContactPhone?: string;
allergyNotes?: string;
chronicDiseaseNotes?: string;
insuranceNumber?: string;
notes?: string;
isActive: boolean;
}
export interface PatientDetail {
id: string;
patientCode: string;
identificationNumber: string;
fullName: string;
dateOfBirth: string;
gender: string;
phone: string;
email: string;
address: string;
emergencyContactName: string | null;
emergencyContactPhone: string | null;
allergyNotes: string | null;
chronicDiseaseNotes: string | null;
insuranceNumber: string | null;
notes: string | null;
isActive: boolean;
}
export interface GetPatientParams {
Page?: number;
PageSize?: number;
Search?: string;
IdentificationNumber?: string;
SortBy?: string;
Desc?: boolean;
}
export interface PatientResponse {
items: PatientItem[];
page: number;
pageSize: number;
total: number;
totalPages: number;
}
const patientServices = {
getPatient: (params?: GetPatientParams, tokenAxios?: any) => {
return axiosClient.get<PatientResponse>(`/Patient/list`, {
params,
cancelToken: tokenAxios,
});
},
createPatient: (
data: {
identificationNumber: string;
fullName: string;
dateOfBirth: string;
gender: string;
phone: string;
email: string;
address: string;
},
tokenAxios?: any,
) => {
return axiosClient.post(`/Patient`, data, {
cancelToken: tokenAxios,
});
},
putPatient: (
id: string,
data: {
fullName: string;
gender: string;
phone: string;
email: string;
address: string;
emergencyContactName: string;
emergencyContactPhone: string;
allergyNotes: string;
chronicDiseaseNotes: string;
insuranceNumber: string;
notes: string;
},
tokenAxios?: any,
) => {
return axiosClient.put(`/Patient/${id}`, data, {
cancelToken: tokenAxios,
});
},
detailPatient: (id: string, tokenAxios?: any) => {
return axiosClient.get<PatientDetail>(`/Patient/${id}`, {
cancelToken: tokenAxios,
});
},
deletePatient: (id: string, tokenAxios?: any) => {
return axiosClient.delete(`/Patient/${id}`, {
cancelToken: tokenAxios,
});
},
};
export default patientServices;