At the end of this tutorial, you will be able to use iCure to :
Create a patient;
Read the previous created patient;
Create observations/measures for that patient;
Read previous created observations;
Before starting
Before making your first requests, you will need to complete the following steps.
Create your iCure user
Make sure to be registered on the before going ahead.
Setting up your environment
As soon as you have access to iCure (online or locally), you will need to set up your environment. To do this, you can follow this which will help you initialize a node application communicating with the iCure solution.
Authenticating with iCure from your code
After completing the steps above, you will be able to dive into writing some code. For this, you will need the encryption private key you downloaded during the registration process of your user.
In the following example, the private key is MIIEvAIBAD...9HOmEwWQ==. Also, do not forget to replace the username - password (esmith - mypassword) by your own values.
const patient = await patientApi.createPatientWithUser(loggedUser,
await patientApi.newInstance(
loggedUser,
new Patient({
firstName: 'Gustave',
lastName: 'Eiffel',
dateOfBirth:19731011,
note: 'A very private information'
}))
)
As you can see in the code above, we are using some specific API methods to create our patient (createPatientWithUser instead of createPatient, api.newInstance instead of "only" creating a new object, ...). This is because those methods are taking care of the data end-to-end encryption for us.
Load a patient
After creating a patient, you can find it back using its id :
Before adding new medical data into the iCure system, you then absolutely need to create :
a patient (See sections Create a patient and Load a patient for more information);
The following code shows you how to create an observation, represented in iCure system as a contact containing a service.
Create a contact with services
const serviceToCreate = await contactApi.service().newInstance(
loggedUser,
new Service({
valueDate: 20211020,
status: 0,
label: 'Hepatitis B virus surface',
codes: [
new CodeStub({
id: 'http://loinc.org|16935-9|2',
context: 'code',
type: 'http://loinc.org',
code: '16935-9',
version: '2',
label: {
en: 'Hepatitis B virus surface Ab [Units/volume] in Serum'
}
})
],
content: {
en: new Content({
measureValue: new Measure({
value: 99.0,
unit: '[iU]/L',
unitCodes: [new CodeStub({
id: 'http://unitsofmeasure.org|[iU]/L',
type: 'http://unitsofmeasure.org',
code: '[iU]/L'
})]
})
})
}
})
)
const contact = await contactApi.createContactWithUser(loggedUser,
await contactApi.newInstance(
loggedUser,
patient,
new Contact({
responsible: loggedUser.healthcarePartyId,
services: [serviceToCreate]
}))
)
Once you are authenticated, you can easily create a patient. The Patient data model is described .
We encourage you to have a look at our in order to know all about them.
In iCure, medical data is stored inside contacts. A groups a batch of measures/observations (represented in iCure data model as ) in one single transaction. A contact always links together a healthcare party (A care provider) to one patient.