improvement: v1 standalone treatment/case creation made possible.

This commit is contained in:
2026-08-19 15:05:58 +03:30
parent e5c39c6b7e
commit 8bfa8c88fe
39 changed files with 3296 additions and 387 deletions

View File

@@ -2,10 +2,36 @@ import { apiClient } from './client';
import type {
CasesFilterOptions,
AssignableTaskStaff,
LabCaseAttachmentMeta,
LabCaseDetail,
ListLabCasesParams,
PaginatedLabCases,
} from '@/types/cases';
import type { LinkedOrganizationOption } from '@/types/treatment';
export interface LabInternalCaseLinePayload {
clientId: string;
id?: string;
teeth: string[];
toothSelectionGroups?: Array<{ groupId: string; kind: string; teeth: string[] }>;
comment?: string;
toothProsthesis?: Array<{
tooth: string;
prosthesisTypeCode: string;
selectionGroupId?: string;
}>;
attachmentIds?: string[];
}
export interface LabInternalCasePayload {
referringClinicName?: string | null;
referringDentistName?: string | null;
patientDisplayName?: string | null;
patientDisplayMobile?: string | null;
partnerClinicOrganizationId?: string | null;
dueDate?: string | null;
lines?: LabInternalCaseLinePayload[];
}
export const casesApi = {
list: async (
@@ -15,6 +41,48 @@ export const casesApi = {
return response.data;
},
create: async (
payload: LabInternalCasePayload = {},
): Promise<{ success: boolean; data: LabCaseDetail }> => {
const response = await apiClient.post('/cases', payload);
return response.data;
},
update: async (
id: string,
payload: LabInternalCasePayload,
): Promise<{ success: boolean; data: LabCaseDetail }> => {
const response = await apiClient.put(`/cases/${id}`, payload);
return response.data;
},
start: async (id: string): Promise<{ success: boolean; data: LabCaseDetail }> => {
const response = await apiClient.post(`/cases/${id}/start`);
return response.data;
},
uploadLineAttachments: async (
caseId: string,
lineClientId: string,
files: File[],
): Promise<{ success: boolean; data: LabCaseAttachmentMeta[] }> => {
const form = new FormData();
for (const file of files) {
form.append('files', file);
}
const response = await apiClient.post(
`/cases/${caseId}/lines/${encodeURIComponent(lineClientId)}/attachments`,
form,
{ headers: { 'Content-Type': 'multipart/form-data' }, timeout: 120_000 },
);
return response.data;
},
listLinkedClinics: async (): Promise<{ success: boolean; data: LinkedOrganizationOption[] }> => {
const response = await apiClient.get('/cases/linked-clinics');
return response.data;
},
getOne: async (id: string): Promise<{ success: boolean; data: LabCaseDetail }> => {
const response = await apiClient.get(`/cases/${id}`);
return response.data;

View File

@@ -46,6 +46,68 @@ export const treatmentsApi = {
return response.data;
},
createStandalone: async (payload: {
patientId?: string;
walkIn?: boolean;
treatmentAt: string;
}): Promise<{ success: boolean; data: PastTreatment }> => {
const response = await apiClient.post('/treatments', payload);
return response.data;
},
deleteStandalone: async (treatmentId: string): Promise<{ success: boolean }> => {
const response = await apiClient.delete(`/treatments/${treatmentId}`);
return response.data;
},
listDayStandalone: async (params: {
from: string;
to: string;
}): Promise<{ success: boolean; data: PastTreatment[] }> => {
const response = await apiClient.get('/treatments/day', { params });
return response.data;
},
getDraftByTreatment: async (
treatmentId: string,
): Promise<{ success: boolean; data: PastTreatment | null }> => {
const response = await apiClient.get(`/treatments/${treatmentId}/draft`);
return response.data;
},
saveDraftByTreatment: async (
treatmentId: string,
payload: { details: SavedTreatmentDetailPayload[] },
): Promise<{ success: boolean; data: PastTreatment }> => {
const response = await apiClient.put(`/treatments/${treatmentId}/draft`, payload);
return response.data;
},
saveLabCasesByTreatment: async (
treatmentId: string,
payload: { labCases: SaveLabCasePayload[] },
): Promise<{ success: boolean; data: PastTreatment }> => {
const response = await apiClient.put(`/treatments/${treatmentId}/lab-cases`, payload);
return response.data;
},
uploadDetailAttachmentsByTreatment: async (
treatmentId: string,
detailClientId: string,
files: File[],
): 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/${treatmentId}/details/${encodeURIComponent(detailClientId)}/attachments`,
form,
{ headers: { 'Content-Type': 'multipart/form-data' }, timeout: 120_000 },
);
return response.data;
},
saveDraft: async (
appointmentId: string,
payload: { details: SavedTreatmentDetailPayload[] },