DataSampleApi
@icure/medical-device-sdk / DataSampleApi
SDK API: DataSampleApi
The DataSampleApi interface provides methods to manage observations.
Table of contents
Methods
- createOrModifyDataSampleFor
- createOrModifyDataSamplesFor
- deleteAttachment
- deleteDataSample
- deleteDataSamples
- extractPatientId
- filterDataSample
- getDataSample
- getDataSampleAttachmentContent
- getDataSampleAttachmentDocument
- getDataSamplesForPatient
- giveAccessTo
- matchDataSample
- setDataSampleAttachment
- subscribeToDataSampleEvents
Methods
createOrModifyDataSampleFor
▸ createOrModifyDataSampleFor(patientId
, dataSample
): Promise
<DataSample
>
When modifying an observation, you can't update the patient of it : For this, you need to delete the faulty observation and create a new one. When modifying the observation, you also need to keep the same batchId : It is not possible to change the batch of an observation. Create or update a [DataSample] for a patient
Parameters
Name | Type |
---|---|
patientId | string |
dataSample | DataSample |
Returns
Promise
<DataSample
>
Defined in
createOrModifyDataSamplesFor
▸ createOrModifyDataSamplesFor(patientId
, dataSample
): Promise
<DataSample
[]>
All the provided observations will be created in the same batch. If you are trying to update some observations, then those ones need to come from the same batch. When modifying an observation, you can't update the patient of it : For this, you need to delete the faulty observation and create a new one. When modifying the observation, you also need to keep the same batchId : It is not possible to change the batch of an observation. Create or update a batch of [DataSample] for a patient
Parameters
Name | Type |
---|---|
patientId | string |
dataSample | DataSample [] |
Returns
Promise
<DataSample
[]>
Defined in
deleteAttachment
▸ deleteAttachment(dataSampleId
, documentId
): Promise
<string
>
Deletes an attachment, using its corresponding documentId Delete an attachment of a DataSample
Parameters
Name | Type |
---|---|
dataSampleId | string |
documentId | string |
Returns
Promise
<string
>
Defined in
deleteDataSample
▸ deleteDataSample(dataSampleId
): Promise
<string
>
Deletes the observation identified by the provided unique [dataSampleId]. Delete a [DataSample] by its id
Parameters
Name | Type |
---|---|
dataSampleId | string |
Returns
Promise
<string
>
Defined in
deleteDataSamples
▸ deleteDataSamples(requestBody
): Promise
<string
[]>
Deletes the batch of observations identified by the provided [dataSampleIds]. The observations to delete need to be part of the same batch Delete a batch of [Observations]
Parameters
Name | Type |
---|---|
requestBody | string [] |
Returns
Promise
<string
[]>
Defined in
extractPatientId
▸ extractPatientId(dataSample
): Promise
<undefined
| string
>
Parameters
Name | Type |
---|---|
dataSample | DataSample |
Returns
Promise
<undefined
| string
>
Defined in
filterDataSample
▸ filterDataSample(filter
, nextDataSampleId?
, limit?
): Promise
<PaginatedListDataSample
>
Filters are complex selectors that are built by combining basic building blocks. Examples of filters available for [DataSample] are :
- DataSampleByHealthcarePartyFilter;
- DataSampleByHealthcarePartyHealthcareElementFilter;
- DataSampleByHealthcarePartyIdentifiersFilter;
- DataSampleByHealthcarePartyPatientFilter;
- DataSampleByHealthcarePartyTagCodeDateFilter;
- and DataSamplesByIdsFilter.
This method returns a paginated list of observations (with a cursor that lets you query the following items). Find observations using the provided [filter].
Parameters
Name | Type | Description |
---|---|---|
filter | Filter <DataSample > | The Filter object that describes which condition(s) the elements whose the ids should be returned must fulfill |
nextDataSampleId? | string | The id of the first observation in the next page |
limit? | number | The maximum number of observations that should contain the returned page. By default, a page contains 1000 observations |
Returns
Promise
<PaginatedListDataSample
>
Defined in
getDataSample
▸ getDataSample(dataSampleId
): Promise
<DataSample
>
Each observation is uniquely identified by an observation id which is a UUID. This [dataSampleId] is the preferred method to retrieve one specific observation. Get a [DataSample] by its id
Parameters
Name | Type |
---|---|
dataSampleId | string |
Returns
Promise
<DataSample
>
Defined in
getDataSampleAttachmentContent
▸ getDataSampleAttachmentContent(dataSampleId
, documentId
, attachmentId
): Promise
<ArrayBuffer
>
Observations may contain attachments such as prescriptions, reports, ... Use this method to get the content of an attachment Get attachment content of a DataSample
Parameters
Name | Type |
---|---|
dataSampleId | string |
documentId | string |
attachmentId | string |
Returns
Promise
<ArrayBuffer
>
Defined in
getDataSampleAttachmentDocument
▸ getDataSampleAttachmentDocument(dataSampleId
, documentId
): Promise
<Document
>
Observations may contain attachments such as prescriptions, reports, ... Use this method to get the document metadata information of an attachment Get document metadata of a DataSample attachment
Parameters
Name | Type |
---|---|
dataSampleId | string |
documentId | string |
Returns
Promise
<Document
>
Defined in
getDataSamplesForPatient
▸ getDataSamplesForPatient(patient
): Promise
<DataSample
[]>
Gets all the Observations associated to a Patient that the current dataOwner can access.
Parameters
Name | Type | Description |
---|---|---|
patient | Patient | the Patient associated to the Observations to get |
Returns
Promise
<DataSample
[]>
an array containing the Observations
Defined in
giveAccessTo
▸ giveAccessTo(dataSample
, delegatedTo
): Promise
<DataSample
>
Service where current user gives access to the observation information to another dataOwner (HCP, patient or device). For this, the current user data owner should be able to access the observation provided in argument in order to provide access to another data owner.
Parameters
Name | Type | Description |
---|---|---|
dataSample | DataSample | Observation the current data owner would like to share with another data owner |
delegatedTo | string | ID of the data owner to which current user would like to give access |
Returns
Promise
<DataSample
>
The dataSample with updated access rights
Defined in
matchDataSample
▸ matchDataSample(filter
): Promise
<string
[]>
Filters are complex selectors that are built by combining basic building blocks. Examples of filters available for [DataSample] are AllDataSamplesFilter and DataSamplesByIdsFilter. This method returns a paginated list of observations (with a cursor that lets you query the following items). Find observations ids using the provided Filter.
Parameters
Name | Type | Description |
---|---|---|
filter | Filter <DataSample > | The Filter object that describes which condition(s) the elements whose the ids should be returned must fulfill |
Returns
Promise
<string
[]>
Defined in
setDataSampleAttachment
▸ setDataSampleAttachment(dataSampleId
, body
, documentName?
, documentVersion?
, documentExternalUuid?
, documentLanguage?
): Promise
<Document
>
Link an attachment or update the attachment of an observation Add or update the attachment of a DataSample
Parameters
Name | Type |
---|---|
dataSampleId | string |
body | ArrayBuffer |
documentName? | string |
documentVersion? | string |
documentExternalUuid? | string |
documentLanguage? | string |
Returns
Promise
<Document
>
Defined in
subscribeToDataSampleEvents
▸ subscribeToDataSampleEvents(eventTypes
, filter
, eventFired
, options?
): Promise
<Connection
>
Opens a WebSocket Connection in order to receive all the Observations corresponding to specific filter criteria.
Parameters
Name | Type | Description |
---|---|---|
eventTypes | ("CREATE" | "UPDATE" | "DELETE" )[] | Type of event you would like to listen. It can be CREATE, UPDATE or DELETE |
filter | Filter <DataSample > | Filter criteria to filter to the observations you would like to receive |
eventFired | (dataSample : DataSample ) => Promise <void > | Action applied each time you receive an observation through the WebSocket |
options? | Object | Options to configure the WebSocket. - keepAlive : How long to keep connection alive (ms); - lifetime : How long to keep the WebSocket alive (ms); - connectionMaxRetry : how many time retrying to reconnect to the iCure WebSocket; - connectionRetryIntervalInMs : How long base interval will be between two retry. The retry attempt is exponential and using a random value (connectionRetryIntervalMs * (random between 1 and 2))^nbAttempts) |
options.connectionMaxRetry? | number | - |
options.connectionRetryIntervalMs? | number | - |
Returns
Promise
<Connection
>