Register your application with the auth provider in Aidbox to obtain a client ID and secret.
Please follow the aidbox documentation
import { Client } from 'aidbox-sdk-js'
const aidbox = new Client({
url: 'www.aidbox-url.com',
auth: { type: 'basic', username: 'name', password: 'password' }
});
import { Client } from 'aidbox-sdk-js'
const aidbox = new Client({
url: 'www.aidbox-url.com',
auth: { type: 'client-credentials', clientId: 'client', secret: 'secret' }
});
import { Client } from 'aidbox-sdk-js'
const aidbox = new Client({
url: 'www.aidbox-url.com',
auth: { type: 'resource-owner', clientId: 'client' }
});
const signIn = (username: string, password: string) => {
return aidbox.recourseOwnerAuth(username, password)
}
(ResourceType, SearchParams) => Array<Resource>
const patient = await aidbox.api.getResource('Patient', searchParams);
(ResourceType, SearchParams, Resource ) => Resource
const updatedPatient = await aidbox.api.patchResource('Patient', searchParams, { ...resource });
(ResourceType, SearchParams) => Resource
const deletedPatient = await aidbox.api.deleteResource('Patient', searchParams);
type SearchParams = {
id?: string
[Resource.fieldName]: string | Record<{
[searchParameterName | or | and | gt | lte | exact | ... ]: string | string[]
}>
}
const patient = await aidbox.api.getResource('Patient', { id: 'patient-id', name: { $or: ['Vlad','Rost'] } })
Search params as a query-builder (second variant, reference):
const patient = await aidbox.api.getResource('Patient', 'patient-id')
.and('name', 'Vlad', 'Anton')
.exact('birthDate', '2020-01-01');
(ResourceType, string) => Array<ResourceVersiose>
const allPatientVersions = await aidbox.api.getResourceHistory('Patient', 'patient-id');
(resourceType, id: string, version: number) => Resource
const oldPatient = await aidbox.api.getResourceVersion('Patient', 'patient-id', 0);
type ValidationModes = { mode: 'create' | 'update' | 'delete' | 'patch' | 'merge-patch' | 'json-patch' }
(ResourceType, Resource, ValidationModes) => VlidationResult
const result1 = await aidbox.api.validateResource('Patient', resource);
const result2 = await aidbox.api.validateResource('Patient', resource, { mode: 'create' })
const result3 = await aidbox.api.validateResource('Patient', resource, { mode: 'delete' })
(ResourceType, Resource, threshold: 0-1) => Resource[]
const similarResources = await aidbox.api.matchResource('Patient', resource, 0)
(patientId: string) => Resource
const resources = await aidbox.api.everything('patient-id')
type Params = {
id?: string;
version?: number | { 'lower-version': number, 'upper-version': number };
fhir?: boolean;
'omit-resources'?: boolean;
_count?: number;
_page?: number;
_total?: 'none' | 'estimate' | 'accurate';
}
const changes = await aidbox.changes(params)
(resources: Array<Resource>) => Array<Resource>;
const resources = await aidbox.batch.upsert(resources)
Batch set
type Body = Array<{
resource: Array<Resource>
request: { method: HTTPMethods, url: string }
}>
(body: Body) => Resources
const resources = await aidbox.batch.set(body)
Batch update
type Body = Array<{
resource: Array<Resource>
request: { method: HTTPMethods, url: string }
}>
(body: Body) => Resources
let resources = await aidbox.batch.update(body)
Get History
(ResourceName, string) => HistoryOfResource
let history = await aidboxClient.batch.history('Patient', 'patient-id')