File size: 1,042 Bytes
86f402d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | import { Patient, ChatMessage } from '../types';
const BASE = '/api';
export const api = {
// Patients
listPatients: (): Promise<{ patients: Patient[] }> =>
fetch(`${BASE}/patients`).then(r => r.json()),
createPatient: (name: string): Promise<{ patient: Patient }> =>
fetch(`${BASE}/patients`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ name }),
}).then(r => r.json()),
getPatient: (patientId: string): Promise<{ patient: Patient }> =>
fetch(`${BASE}/patients/${patientId}`).then(r => r.json()),
deletePatient: (patientId: string): Promise<void> =>
fetch(`${BASE}/patients/${patientId}`, { method: 'DELETE' }).then(() => {}),
// Chat (patient-level)
getChatHistory: (patientId: string): Promise<{ messages: ChatMessage[] }> =>
fetch(`${BASE}/patients/${patientId}/chat`).then(r => r.json()),
clearChat: (patientId: string): Promise<void> =>
fetch(`${BASE}/patients/${patientId}/chat`, { method: 'DELETE' }).then(() => {}),
};
|