Managing patients

Creating a patient is not complicated, but it requires some preliminary work to make sure that everything is set up for encryption. In the following example, we make sure that we are logged in as a user previously created, and we import the previously generated private key.

Prepare for patient creation
import {
    Api,
    Filter,
    FilterChainPatient,
    Patient,
    PatientByHcPartyNameContainsFuzzyFilter,
    hex2ua
} from '@icure/api'
import {crypto} from '@icure/api/node-compat.js'

const host = 'https://kraken.icure.dev/rest/v1';
const { patientApi, userApi, healthcarePartyApi, cryptoApi } = Api(host, 'esmith', 'mypassword', crypto)

const loggedUser = await userApi.getCurrentUser();
const loggedHcp = await healthcarePartyApi.getCurrentHealthcareParty()

await cryptoApi.loadKeyPairsAsTextInBrowserLocalStorage(
    loggedUser.healthcarePartyId,
    hex2ua("308204bc02...473a613059")
)
await cryptoApi.checkPrivateKeyValidity(loggedHcp)

Patients are identified by their id.

The preferred way to search for patients is to use filters. Most filters will require you to set a healthcare party (hcp) to limit the search to patients this hcp can actually access and decrypt.

It is not always very user-friendly to express filters by declaring an object tree. This is why we also provide an easy to use declarative api for filters.

Last updated

Was this helpful?