feature: Phase 2- splitting the treatment schema into TreatmentDetail and LabCase.
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
import { apiClient } from './client';
|
||||
import type {
|
||||
LabCaseResponse,
|
||||
LinkedOrganizationOption,
|
||||
PastTreatment,
|
||||
SaveTreatmentPayload,
|
||||
SendTreatmentCasePayload,
|
||||
TreatmentAttachmentMeta,
|
||||
TreatmentCaseSendInfo,
|
||||
SaveLabCasePayload,
|
||||
SavedTreatmentDetailPayload,
|
||||
} from '@/types/treatment';
|
||||
|
||||
export const treatmentsApi = {
|
||||
@@ -33,34 +32,53 @@ export const treatmentsApi = {
|
||||
|
||||
saveDraft: async (
|
||||
appointmentId: string,
|
||||
payload: Pick<SaveTreatmentPayload, 'cases'>,
|
||||
payload: { details: SavedTreatmentDetailPayload[] },
|
||||
): Promise<{ success: boolean; data: PastTreatment }> => {
|
||||
const response = await apiClient.put(`/treatments/appointments/${appointmentId}/draft`, payload);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
uploadCaseAttachments: async (
|
||||
saveLabCases: async (
|
||||
appointmentId: string,
|
||||
caseClientId: string,
|
||||
payload: { labCases: SaveLabCasePayload[] },
|
||||
): Promise<{ success: boolean; data: PastTreatment }> => {
|
||||
const response = await apiClient.put(
|
||||
`/treatments/appointments/${appointmentId}/lab-cases`,
|
||||
payload,
|
||||
);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
uploadDetailAttachments: async (
|
||||
appointmentId: string,
|
||||
detailClientId: string,
|
||||
files: File[],
|
||||
): Promise<{ success: boolean; data: TreatmentAttachmentMeta[] }> => {
|
||||
): Promise<{ success: boolean; data: import('@/types/treatment').TreatmentAttachmentMeta[] }> => {
|
||||
const form = new FormData();
|
||||
for (const file of files) {
|
||||
form.append('files', file);
|
||||
}
|
||||
const response = await apiClient.post(
|
||||
`/treatments/appointments/${appointmentId}/cases/${encodeURIComponent(caseClientId)}/attachments`,
|
||||
`/treatments/appointments/${appointmentId}/details/${encodeURIComponent(detailClientId)}/attachments`,
|
||||
form,
|
||||
{ headers: { 'Content-Type': 'multipart/form-data' }, timeout: 120_000 },
|
||||
);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
sendCase: async (
|
||||
caseId: string,
|
||||
payload: SendTreatmentCasePayload,
|
||||
): Promise<{ success: boolean; data: PastTreatmentCaseResponse }> => {
|
||||
const response = await apiClient.post(`/treatments/cases/${caseId}/send`, payload);
|
||||
/** @deprecated Use uploadDetailAttachments */
|
||||
uploadCaseAttachments: async (
|
||||
appointmentId: string,
|
||||
detailClientId: string,
|
||||
files: File[],
|
||||
) => {
|
||||
return treatmentsApi.uploadDetailAttachments(appointmentId, detailClientId, files);
|
||||
},
|
||||
|
||||
sendLabCase: async (
|
||||
labCaseId: string,
|
||||
): Promise<{ success: boolean; data: LabCaseResponse }> => {
|
||||
const response = await apiClient.post(`/treatments/lab-cases/${labCaseId}/send`);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
@@ -72,15 +90,3 @@ export const treatmentsApi = {
|
||||
return response.data;
|
||||
},
|
||||
};
|
||||
|
||||
export interface PastTreatmentCaseResponse {
|
||||
id: string;
|
||||
clientId: string;
|
||||
treatmentType: string;
|
||||
teeth: string[];
|
||||
notes: string | null;
|
||||
sentAt: string | null;
|
||||
sendToOrganizationIds: string[];
|
||||
sends: TreatmentCaseSendInfo[];
|
||||
attachmentMetas: TreatmentAttachmentMeta[];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user