PatientApi
@icure/medical-device-sdk / PatientApi
SDK API: PatientApi
The PatientApi interface provides methods to manage patients.
Table of contents
Methods
- createOrModifyPatient
- deletePatient
- filterPatients
- getPatient
- getPatientAndTryDecrypt
- giveAccessTo
- giveAccessToAllDataOf
- giveAccessToPotentiallyEncrypted
- matchPatients
- modifyPotentiallyEncryptedPatient
- subscribeToPatientEvents
Methods
createOrModifyPatient
▸ createOrModifyPatient(patient
): Promise
<Patient
>
When modifying a patient, you must ensure that the rev obtained when getting or creating the patient is present as the rev is used to guarantee that the patient has not been modified by a third party. Create or update a [Patient]
Parameters
Name | Type |
---|---|
patient | Patient |
Returns
Promise
<Patient
>
Defined in
deletePatient
▸ deletePatient(patientId
): Promise
<string
>
Deletes the patient identified by the provided unique [patientId]. Delete a [Patient]
Parameters
Name | Type |
---|---|
patientId | string |
Returns
Promise
<string
>
Defined in
filterPatients
▸ filterPatients(filter
, nextPatientId?
, limit?
): Promise
<PaginatedListPatient
>
Filters are complex selectors that are built by combining basic building blocks. Examples of filters available for [Patient] are :
- PatientByHealthcarePartyDateOfBirthBetweenFilter;
- PatientByHealthcarePartyFilter;
- PatientByHealthcarePartyGenderEducationProfessionFilter;
- PatientByHealthcarePartyIdentifiersFilter;
- PatientByHealthcarePartyNameContainsFuzzyFilter;
- PatientByHealthcarePartySsinsFilter;
- and PatientsByIdsFilter.
This method returns a paginated list of patient (with a cursor that lets you query the following items). Load patients from the database by filtering them using the provided [filter].
Parameters
Name | Type | Description |
---|---|---|
filter | Filter <Patient > | The Filter object that describes which condition(s) the elements whose the ids should be returned must fulfill |
nextPatientId? | string | The id of the first patient in the next page |
limit? | number | The maximum number of patients that should contain the returned page. By default, a page contains 1000 patients |
Returns
Promise
<PaginatedListPatient
>
Defined in
getPatient
▸ getPatient(patientId
): Promise
<Patient
>
Each patient is uniquely identified by a patient id. The patient id is a UUID. This [patientId] is the preferred method to retrieve one specific patient. Get a [Patient]
Parameters
Name | Type |
---|---|
patientId | string |
Returns
Promise
<Patient
>
Defined in
getPatientAndTryDecrypt
▸ getPatientAndTryDecrypt(patientId
): Promise
<PotentiallyEncryptedPatient
>
Gets a patient and tries to decrypt its content. If it is not possible to decrypt the content only the unencrypted data will be available. This method is useful to allow new patient users to access some of their own data before their doctor actually gave them access to their own data: instead of giving an error if the data can't be decrypted (like what happens in getPatient) you will be able to get at least partial information.
Parameters
Name | Type |
---|---|
patientId | string |
Returns
Promise
<PotentiallyEncryptedPatient
>
Defined in
giveAccessTo
▸ giveAccessTo(patient
, delegatedTo
): Promise
<Patient
>
Service where current user gives access to the patient information to another dataOwner (HCP, patient or device). For this, the current user data owner should be able to access the patient provided in argument in order to provide access to another data owner.
Parameters
Name | Type | Description |
---|---|---|
patient | Patient | Patient 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
<Patient
>
Defined in
giveAccessToAllDataOf
▸ giveAccessToAllDataOf(patientId
): Promise
<SharingResult
>
Service that allows a Data Owner to share all the data of a Patient with the patient itself. This means this service is sharing :
- The information of the patient;
- All the observations linked to the patient;
- All the conditions linked to the patient;
Parameters
Name | Type | Description |
---|---|---|
patientId | string | the id of the Patient to which we want to give access back to its own data |
Returns
Promise
<SharingResult
>
Defined in
giveAccessToPotentiallyEncrypted
▸ giveAccessToPotentiallyEncrypted(patient
, delegatedTo
): Promise
<PotentiallyEncryptedPatient
>
Same as giveAccessTo but allowing also to share encrypted patients. This is useful if the delegator does not know the encryption key of the patient but has a secret id and wants to share it.
Parameters
Name | Type | Description |
---|---|---|
patient | PotentiallyEncryptedPatient | Patient 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
<PotentiallyEncryptedPatient
>
Defined in
matchPatients
▸ matchPatients(filter
): Promise
<string
[]>
Filters are complex selectors that are built by combining basic building blocks. Examples of filters available for [Patient] are AllPatientsFilter and PatientsByIdsFilter. This method returns the list of the ids of the users matching the [filter]. Load patient ids from the database by filtering them using the provided [filter].
Parameters
Name | Type | Description |
---|---|---|
filter | Filter <Patient > | The Filter object that describes which condition(s) the elements whose the ids should be returned must fulfill |
Returns
Promise
<string
[]>
Defined in
modifyPotentiallyEncryptedPatient
▸ modifyPotentiallyEncryptedPatient(modifiedPatient
): Promise
<PotentiallyEncryptedPatient
>
Modifies a potentially encrypted patient, ensuring that if originally the patient could not be decrypted then the modified patient does not change to data which should be encrypted according to the current api configuration. Similarly to getPatientAndTryDecrypt this method is useful when a patient needs to update his own data before an hcp gave him access to his own encrypted data.
Parameters
Name | Type |
---|---|
modifiedPatient | PotentiallyEncryptedPatient |
Returns
Promise
<PotentiallyEncryptedPatient
>
Defined in
subscribeToPatientEvents
▸ subscribeToPatientEvents(eventTypes
, filter
, eventFired
, options?
): Promise
<Connection
>
Opens a WebSocket Connection in order to receive all the Patients 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 <Patient > | Filter criteria to filter to the Patients you would like to receive |
eventFired | (patient : Patient ) => Promise <void > | Action applied each time you receive a Patient 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
>