UNPKG

@eka-care/patient-ts-sdk

Version:

TypeScript SDK for Trinity Patient Profile Management System

94 lines (93 loc) 2.43 kB
/** * Patient CRUD operations */ import { HttpClient } from '../client'; import { ApiResponse, CreatePatientData, LocalMinifiedPatient, Patient, UpdatePatientData } from '../types'; /** * Patient CRUD methods */ export declare class PatientMethods { private client; private readonly basePath; private indexedDBUpdateCallback; constructor(client: HttpClient); /** * Set callback for updating IndexedDB after patient operations */ setIndexedDBUpdateCallback(callback: (patient: LocalMinifiedPatient) => Promise<void>): void; /** * Create a new patient profile * * @param data Patient creation data * @returns Created patient or just the OID if is_developer flag is set * * @example * ```typescript * const patient = await sdk.patients.create({ * oid: 'unique-id', * wid: 'workspace-id', * gen: 'M', * dob: '1990-01-01', * fn: 'John', * ln: 'Doe', * mobile: '1234567890', * email: 'john@example.com' * }); * ``` */ create(data: CreatePatientData): Promise<Patient | { oid: string; }>; /** * Get a patient by ID * * @param id Patient OID * @returns Patient profile * * @example * ```typescript * const patient = await sdk.patients.get('patient-oid'); * ``` */ get(id: string): Promise<Patient>; /** * Update a patient profile * * @param id Patient OID * @param data Update data * @returns Updated patient profile * * @example * ```typescript * const updated = await sdk.patients.update('patient-oid', { * fn: 'Jane', * email: 'jane@example.com' * }); * ``` */ update(id: string, data: UpdatePatientData): Promise<Patient>; /** * Delete a patient profile * * @param id Patient OID * @returns Success response * * @example * ```typescript * await sdk.patients.delete('patient-oid'); * ``` */ delete(id: string): Promise<ApiResponse>; /** * Get patients by username * * @param username Username to search for * @returns Array of patients (typically one) * * @example * ```typescript * const patients = await sdk.patients.getByUsername('john.doe'); * ``` */ getByUsername(username: string): Promise<Patient[]>; }