metms_fe/src/services/consultationServices.ts
2026-06-08 11:24:57 +07:00

241 lines
5.5 KiB
TypeScript

import axiosClient from ".";
export interface GetConsultationParams {
Page?: number;
PageSize?: number;
Search?: string;
PatientId?: string;
SortBy?: string;
Desc?: boolean;
}
export interface ConsultationItem {
id: string;
patientId: string;
patientName: string;
sessionCode: string;
visitDate: string;
status: number;
chiefComplaint: string | null;
symptomsText: string | null;
vitalSigns: string | null;
diagnosis: string | null;
treatmentPlan: string | null;
doctorNotes: string | null;
createdBy: string;
isDeleted: boolean;
specialtyClinics: {
id: string;
specialtyId: string;
specialtyName: string;
specialtyNotes: string | null;
diagnosis: string | null;
procedureNotes: string | null;
glassRequired: string | null;
glassType: string | null;
examinerName: string;
specialtyStatus: string | number;
sharedItems: {
id: string;
prescriptionId: string;
medicineName: string;
dosage: string;
frequency: string;
duration: string;
instructions: string;
}[];
}[];
aggregatedPrescriptionItems: {
id: string;
prescriptionId: string;
medicineName: string;
dosage: string;
frequency: string;
duration: string;
instructions: string;
}[];
}
export interface AttachmentFile {
fileName: string;
path: string;
}
export interface ConsultationDetail {
id: string;
patientId: string;
patientName: string;
patientDateOfBirth: string | null;
sessionCode: string;
visitDate: string;
status: string | number;
chiefComplaint: string | null;
symptomsText: string | null;
vitalSigns: string | null;
diagnosis: string | null;
treatmentPlan: string | null;
doctorNotes: string | null;
isGlassesDelivered: boolean;
createdBy: string;
createdByName: string;
isDeleted: boolean;
generalAttachmentUrls: string[];
specialtyClinics: {
id: string;
specialtyId: string;
specialtyName: string;
specialtyNotes: string | null;
diagnosis: string | null;
procedureNotes: string | null;
glassRequired: boolean | null;
glassType: string | null;
isGlassesDelivered: boolean;
examinerName: string;
specialtyStatus: string | number | undefined;
attachmentUrls: string[];
sharedItems: {
id: string;
prescriptionId: string;
medicineName: string;
dosage: string;
frequency: string;
duration: string;
instructions: string;
}[];
}[];
aggregatedPrescriptionItems: {
id: string;
prescriptionId: string;
medicineName: string;
dosage: string;
frequency: string;
duration: string;
instructions: string;
}[];
}
export interface ConsultationResponse {
items: ConsultationItem[];
page: number;
pageSize: number;
total: number;
totalPages: number;
}
export interface ReportResponse {
fromDate: string;
toDate: string;
totalSessions: number;
totalSpecialtySubSessions: number;
specialtyDetails: {
specialtyId: string;
specialtyCode: string;
specialtyName: string;
totalCases: number;
}[];
totalPrescriptionsIssued: number;
totalGlassesDelivered: number;
}
const consultationServices = {
getConsultations: (params?: GetConsultationParams, tokenAxios?: any) => {
return axiosClient.get<ConsultationResponse>(
`/api/v1/ExaminationSession/list`,
{
params,
cancelToken: tokenAxios,
},
);
},
getConsultationsReport: (
params: { FromDate: string; ToDate: string },
tokenAxios?: any,
) => {
return axiosClient.get<ReportResponse>(
`/api/v1/ExaminationSession/report`,
{
params,
cancelToken: tokenAxios,
},
);
},
createConsultations: (
data?: {
patientId: string;
chiefComplaint: string;
symptomsText: string;
vitalSigns: string;
specialtyIds: string[];
},
tokenAxios?: any,
) => {
return axiosClient.post(`/api/v1/ExaminationSession`, data, {
cancelToken: tokenAxios,
});
},
detailConsultations: (id: string, tokenAxios?: any) => {
return axiosClient.get<ConsultationDetail>(
`/api/v1/ExaminationSession/${id}`,
{
cancelToken: tokenAxios,
},
);
},
putConsultations: (
id: string,
data: {
chiefComplaint: string | null;
symptomsText: string | null;
vitalSigns: string | null;
diagnosis: string | null;
treatmentPlan: string | null;
doctorNotes: string | null;
isGlassesDelivered: boolean;
fileUrls: string[];
},
tokenAxios?: any,
) => {
return axiosClient.put(`/api/v1/ExaminationSession/${id}`, data, {
cancelToken: tokenAxios,
});
},
cancelConsultations: (id: string, tokenAxios?: any) => {
return axiosClient.post(`/api/v1/ExaminationSession/${id}/cancel`, {
cancelToken: tokenAxios,
});
},
completeConsultations: (id: string, tokenAxios?: any) => {
return axiosClient.post(`/api/v1/ExaminationSession/${id}/complete`, {
cancelToken: tokenAxios,
});
},
specialtyResults: (
specialtyAssignmentId: string,
data: {
specialtyNotes: string;
diagnosis: string;
procedureNotes: string;
glassRequired: boolean;
glassType: string;
isGlassesDelivered: boolean;
fileUrls: string[];
},
tokenAxios?: any,
) => {
return axiosClient.put(
`/api/v1/ExaminationSession/specialty-results/${specialtyAssignmentId}`,
data,
{
cancelToken: tokenAxios,
},
);
},
};
export default consultationServices;