UNPKG

aitriage-sdk-dev

Version:

A JavaScript SDK for seamless integration with the Aitriage API. Provides methods for authentication, assessment management, patient data retrieval, and more.

74 lines (52 loc) 2.94 kB
# Aitriage SDK (JavaScript) ## Overview The Aitriage SDK is a JavaScript library designed to simplify integration with the Aitriage API. It provides convenient methods for authentication, retrieval, and management of data related to medical assessments and patient information. ## Features - **Authentication:** Secure login using API keys. - **Assessment Management:** - Fetch lists of assessments and detailed information for specific assessments. - Retrieve segments (parts) of assessments. - Export assessment reports as PDF files. - **Patient Management:** - Fetch lists of patients and detailed information for specific patients. - Retrieve notes associated with patients. ## Installation Install the Aitriage SDK using npm or yarn: ```bash npm install aitriage-sdk # or yarn add aitriage-sdk ``` ## Usage Follow these steps to integrate and use the Aitriage SDK in your JavaScript project: 1. **Import and Initialize:** ```javascript import { AitriageSdk, MODE } from 'aitriage-sdk' const apiKey = 'YOUR_API_KEY' const accountNo = 'YOUR_ACCOUNT_NO' const aitriageSdk = new AitriageSdk(apiKey, accountNo, MODE.DEVELOPMENT) // Or MODE.PRODUCTION for production environment ``` 2. **Authenticate:** ```javascript const loginResponse = await aitriageSdk.loginByApiKey() ``` 3. **Interact with the API:** ```javascript try { const assessmentQuery = { limit: 10, page: 1 } const assessments = await aitriageSdk.getListAssessment(assessmentQuery) console.log('Assessments:', assessments) const patientDetails = await aitriageSdk.getDetailPatient('CUSTOMER_ID') console.log('Patient details:', patientDetails) // ... Use other SDK methods as needed (see API Reference) } catch (error) { console.error('API Error:', error) // Handle API errors appropriately } ``` ## Important Notes - **Authentication is Key:** Always call `loginByApiKey()` before using other SDK methods. This ensures proper authentication and authorization for your API requests. - **Asynchronous Operations:** Many SDK methods (e.g., `getListAssessment`, `getDetailPatient`) are asynchronous. Use `await` within `async` functions or `.then()` to handle their results and potential errors. - **Error Handling:** Implement robust error handling around SDK method calls. Catch and handle errors to prevent your application from crashing and to provide informative feedback to users. - **Rate Limits:** Be aware of the Aitriage API's rate limits to avoid exceeding them. If you encounter rate limiting errors, implement backoff strategies to retry requests after a delay. - **Type Definitions:** Leverage the TypeScript type definitions included in the SDK to get autocompletion, type checking, and better code maintainability. Refer to the `types.ts` file for details on available types.