Skip to main content

Handling conditions

What is a Condition?

A Condition is a piece of medical information that can be used to give more details about the context of a Observation.
It typically describes a long-lasting condition affecting a Patient. Conditions can be created by Patient and Practitioner. The sensitive information they contain are encrypted and can be read only by Data Owners with an explicit access.

note

To perform the following operations, we suppose you have at least a Patient and a Practitioner in your database.

Creating a Condition

In the following example, a Practitioner will create, for a Patient, a Condition describing a medical condition.

const newCondition = new Condition({
description: 'The patient has been diagnosed Pararibulitis',
codes: new Set([
new CodingReference({
id: 'SNOMEDCT|617|20020131',
type: 'SNOMEDCT',
code: '617',
version: '20020131',
}),
]),
openingDate: new Date('2019-10-12').getTime(),
})

const condition = await api.conditionApi.createOrModify(newCondition, patient.id)
newHealthcareElement
{
"id": "7a08d83c-9ef3-4c8d-b67e-0682501d77e5",
"identifiers": [],
"tags": {},
"codes": {},
"openingDate": 1570838400000,
"description": "The patient has been diagnosed Pararibulitis",
"notes": []
}
healthcareElement
{
"id": "7a08d83c-9ef3-4c8d-b67e-0682501d77e5",
"identifiers": [],
"rev": "1-e2edcfa8e1cb50baca862bdf1e8cc88f",
"created": 1700058614548,
"modified": 1700058614548,
"author": "17e392da-8e36-4e4e-abd7-7eef3e434395",
"responsible": "3ed06450-17e5-47b6-ba4f-7a0a084df56b",
"bodySite": {},
"tags": {},
"codes": {},
"healthcareElementId": "7a08d83c-9ef3-4c8d-b67e-0682501d77e5",
"recordedDate": 20231115143014,
"openingDate": 1570838400000,
"description": "The patient has been diagnosed Pararibulitis",
"notes": [],
"systemMetaData": {
"secretForeignKeys": [
"b6540caa-1eb3-42ce-bf4a-f02c42bd9fd7"
],
"cryptedForeignKeys": {},
"delegations": {},
"encryptionKeys": {},
"securityMetadata": {
"secureDelegations": {},
"keysEquivalences": {}
},
"encryptedSelf": "dpH5kYN2rqoS1N95ljz9OBO74PORyiWg9E2omh5sBHbI4qvylnFZMq9Ntkj9xxQVGn1iv5WfNquYq/lvx81y9pUxwKrdfgDjXt8IGJdnMWc=",
"tags": {}
}
}
note

If not specified, the value of the following parameters will be automatically set by the iCure API:

  • id (to a random UUID)
  • created (to the current timestamp)
  • modified (to the current timestamp)
  • author (to the id of the user who created this Healthcare Element)
  • responsible (to the id of the Data Owner id who created this Healthcare Element)
  • healthElementId (to the id of the current Healthcare Element)
  • valueDate (to the current timestamp)
  • openingDate (to the current timestamp)

When creating a new Condition, you must specify the Patient it is associated to.
If the method runs successfully, the Promise will return the newly created Condition. It is also possible to create a series of Conditions that describe a medical history. In a medical history, the conditions share the same healthcareElementId

const startCondition = await api.conditionApi.createOrModify(
new Condition({
description: 'The patient has been diagnosed Pararibulitis',
codes: new Set([
new CodingReference({
id: 'SNOMEDCT|617|20020131',
type: 'SNOMEDCT',
code: '617',
version: '20020131',
}),
]),
openingDate: new Date('2019-10-12').getTime(),
}),
patient.id,
)

const followUpCondition = await api.conditionApi.createOrModify(
new Condition({
description: 'The patient recovered',
openingDate: new Date('2020-11-08').getTime(),
healthcareElementId: startCondition.healthcareElementId,
}),
patient.id,
)
startHealthcareElement
{
"id": "0ec5906e-82fc-40a0-a986-86c9fcec8044",
"identifiers": [],
"rev": "1-a52c7f834ee781f30a27d535f40f3978",
"created": 1700058614662,
"modified": 1700058614662,
"author": "17e392da-8e36-4e4e-abd7-7eef3e434395",
"responsible": "3ed06450-17e5-47b6-ba4f-7a0a084df56b",
"bodySite": {},
"tags": {},
"codes": {},
"healthcareElementId": "0ec5906e-82fc-40a0-a986-86c9fcec8044",
"recordedDate": 20231115143014,
"openingDate": 1570838400000,
"description": "The patient has been diagnosed Pararibulitis",
"notes": [],
"systemMetaData": {
"secretForeignKeys": [
"b6540caa-1eb3-42ce-bf4a-f02c42bd9fd7"
],
"cryptedForeignKeys": {},
"delegations": {},
"encryptionKeys": {},
"securityMetadata": {
"secureDelegations": {},
"keysEquivalences": {}
},
"encryptedSelf": "KsVESEoeThQoielZ74jKHGZ+fb/0KGDXCIaN4REMcyq+8CKQCg80pgElD6wo5JMLmGMxRN4qT37lSdM0lR84SgqA5xu9eqjmn+qk1aJofRQ=",
"tags": {}
}
}
followUpHealthcareElement
{
"id": "f0daa23f-99ec-49f7-867d-d32ad7733c82",
"identifiers": [],
"rev": "1-bf35e39d2fc8aadbf226dc985efd8cc5",
"created": 1700058614689,
"modified": 1700058614689,
"author": "17e392da-8e36-4e4e-abd7-7eef3e434395",
"responsible": "3ed06450-17e5-47b6-ba4f-7a0a084df56b",
"bodySite": {},
"tags": {},
"codes": {},
"healthcareElementId": "0ec5906e-82fc-40a0-a986-86c9fcec8044",
"recordedDate": 20231115143014,
"openingDate": 1604793600000,
"description": "The patient recovered",
"notes": [],
"systemMetaData": {
"secretForeignKeys": [
"b6540caa-1eb3-42ce-bf4a-f02c42bd9fd7"
],
"cryptedForeignKeys": {},
"delegations": {},
"encryptionKeys": {},
"securityMetadata": {
"secureDelegations": {},
"keysEquivalences": {}
},
"encryptedSelf": "0sqDu8xbrbDNF4cERS/PEqSex702VpBodSitqNoerRvr6EVjqAi3NcvRPoh9IU/as5jaudCzPkE6BNQK9pg80g==",
"tags": {}
}
}
note

The healthcareElementId is the id of the first Condition of the series.

Several unrelated Conditions can also be created at once.

const condition1 = new Condition({
description: 'The patient has been diagnosed Pararibulitis',
codes: new Set([
new CodingReference({
id: 'SNOMEDCT|617|20020131',
type: 'SNOMEDCT',
code: '617',
version: '20020131',
}),
]),
openingDate: new Date('2019-10-12').getTime(),
})

const condition2 = new Condition({
description: 'The patient has also the flu',
openingDate: new Date('2020-11-08').getTime(),
})

const newConditions = await api.conditionApi.createOrModifyMany(
[condition1, condition2],
patient.id,
)
healthcareElement1
{
"id": "1b0803ed-213a-40a3-ba53-629926e56aef",
"identifiers": [],
"tags": {},
"codes": {},
"openingDate": 1570838400000,
"description": "The patient has been diagnosed Pararibulitis",
"notes": []
}
healthcareElement2
{
"id": "66d9b1d5-16e5-4303-bdf3-c9122da6828d",
"identifiers": [],
"tags": {},
"codes": {},
"openingDate": 1604793600000,
"description": "The patient has also the flu",
"notes": []
}
newElements
[
{
"id": "1b0803ed-213a-40a3-ba53-629926e56aef",
"identifiers": [],
"rev": "1-6fde1ba32e4d7735a5aac07cb1b534a9",
"created": 1700058614632,
"modified": 1700058614632,
"author": "17e392da-8e36-4e4e-abd7-7eef3e434395",
"responsible": "3ed06450-17e5-47b6-ba4f-7a0a084df56b",
"bodySite": {},
"tags": {},
"codes": {},
"healthcareElementId": "1b0803ed-213a-40a3-ba53-629926e56aef",
"recordedDate": 20231115143014,
"openingDate": 1570838400000,
"description": "The patient has been diagnosed Pararibulitis",
"notes": [],
"systemMetaData": {
"secretForeignKeys": [
"b6540caa-1eb3-42ce-bf4a-f02c42bd9fd7"
],
"cryptedForeignKeys": {},
"delegations": {},
"encryptionKeys": {},
"securityMetadata": {
"secureDelegations": {},
"keysEquivalences": {}
},
"encryptedSelf": "f5QpwmjIYhF95c2Lh6vGmwHmu/sP0op2GjHwoYE92PPbEuMQ+L+bkOGRnJR8OAzOjNTrJVcQLrkZKcqGX88dFT82JGs7MAckB6w3ZRYStBI=",
"tags": {}
}
},
{
"id": "66d9b1d5-16e5-4303-bdf3-c9122da6828d",
"identifiers": [],
"rev": "1-79bc068d8f926bc5661dbcaea408df24",
"created": 1700058614632,
"modified": 1700058614632,
"author": "17e392da-8e36-4e4e-abd7-7eef3e434395",
"responsible": "3ed06450-17e5-47b6-ba4f-7a0a084df56b",
"bodySite": {},
"tags": {},
"codes": {},
"healthcareElementId": "66d9b1d5-16e5-4303-bdf3-c9122da6828d",
"recordedDate": 20231115143014,
"openingDate": 1604793600000,
"description": "The patient has also the flu",
"notes": [],
"systemMetaData": {
"secretForeignKeys": [
"b6540caa-1eb3-42ce-bf4a-f02c42bd9fd7"
],
"cryptedForeignKeys": {},
"delegations": {},
"encryptionKeys": {},
"securityMetadata": {
"secureDelegations": {},
"keysEquivalences": {}
},
"encryptedSelf": "nZAKLHG49s1Tui3NtTjugf1Sq2Bgu4xwrRB0wfJI3+VvtyVfJXV1uHpxFjFFYbpiIRAanC1np6I0XgB2f7BC0A==",
"tags": {}
}
}
]
caution

Even if you associate a Condition to a Patient, the Patient does not automatically have access to it. You need to explicitly give access to the patient user to this created Condition by calling the service giveAccessTo.

Sharing a Condition with a Patient

After creating the Condition, the Practitioner can share it with the Patient.

const sharedCondition = await api.conditionApi.giveAccessTo(condition, patient.id)
sharedHealthcareElement
{
"id": "7a08d83c-9ef3-4c8d-b67e-0682501d77e5",
"identifiers": [],
"rev": "2-d3b5808036bc59fa33c5c4d156ad8b9d",
"created": 1700058614548,
"modified": 1700058614548,
"author": "17e392da-8e36-4e4e-abd7-7eef3e434395",
"responsible": "3ed06450-17e5-47b6-ba4f-7a0a084df56b",
"bodySite": {},
"tags": {},
"codes": {},
"healthcareElementId": "7a08d83c-9ef3-4c8d-b67e-0682501d77e5",
"recordedDate": 20231115143014,
"openingDate": 1570838400000,
"description": "The patient has been diagnosed Pararibulitis",
"notes": [],
"systemMetaData": {
"secretForeignKeys": [
"b6540caa-1eb3-42ce-bf4a-f02c42bd9fd7"
],
"cryptedForeignKeys": {},
"delegations": {},
"encryptionKeys": {},
"securityMetadata": {
"secureDelegations": {},
"keysEquivalences": {}
},
"encryptedSelf": "dpH5kYN2rqoS1N95ljz9OBO74PORyiWg9E2omh5sBHbI4qvylnFZMq9Ntkj9xxQVGn1iv5WfNquYq/lvx81y9pUxwKrdfgDjXt8IGJdnMWc=",
"tags": {}
}
}

If the operation is successful, the method returns a Promise with the updated Condition.
Using the same service, the Practitioner can share the Healthcare Element with another Healthcare Professional.

note

Any Data Owner that has access to a Condition can share it with another Data Owner using this service.
A Patient could allow another Patient or Practitioner to access a Condition.

Retrieving a Condition Using its ID

A single Condition can be retrieved from the iCure Back-end using its id.

const retrievedCondition = await api.conditionApi.get(condition.id)
retrievedHealthcareElement
{
"id": "7a08d83c-9ef3-4c8d-b67e-0682501d77e5",
"identifiers": [],
"rev": "2-d3b5808036bc59fa33c5c4d156ad8b9d",
"created": 1700058614548,
"modified": 1700058614548,
"author": "17e392da-8e36-4e4e-abd7-7eef3e434395",
"responsible": "3ed06450-17e5-47b6-ba4f-7a0a084df56b",
"bodySite": {},
"tags": {},
"codes": {},
"healthcareElementId": "7a08d83c-9ef3-4c8d-b67e-0682501d77e5",
"recordedDate": 20231115143014,
"openingDate": 1570838400000,
"description": "The patient has been diagnosed Pararibulitis",
"notes": [],
"systemMetaData": {
"secretForeignKeys": [
"b6540caa-1eb3-42ce-bf4a-f02c42bd9fd7"
],
"cryptedForeignKeys": {},
"delegations": {},
"encryptionKeys": {},
"securityMetadata": {
"secureDelegations": {},
"keysEquivalences": {}
},
"encryptedSelf": "dpH5kYN2rqoS1N95ljz9OBO74PORyiWg9E2omh5sBHbI4qvylnFZMq9Ntkj9xxQVGn1iv5WfNquYq/lvx81y9pUxwKrdfgDjXt8IGJdnMWc=",
"tags": {}
}
}
caution

Trying to retrieve a Condition you do not have access to will produce an error.

Modifying a Condition

Given an existing Condition, it is possible to modify it.

note

The id and rev fields cannot be modified.

const yetAnotherCondition = await api.conditionApi.createOrModify(
new Condition({
description: 'To modify, I must create',
}),
patient.id,
)

const modifiedCondition = new Condition({
...yetAnotherCondition,
description: 'I can change and I can add',
openingDate: new Date('2019-10-12').getTime(),
})

const modificationResult = await api.conditionApi.createOrModify(modifiedCondition, patient.id)
yetAnotherHealthcareElement
{
"id": "1d12b3f7-c788-4877-ae38-51ae3f7f493c",
"identifiers": [],
"rev": "1-98b1150b44b659fd56a4b60a015fa24f",
"created": 1700058614809,
"modified": 1700058614809,
"author": "17e392da-8e36-4e4e-abd7-7eef3e434395",
"responsible": "3ed06450-17e5-47b6-ba4f-7a0a084df56b",
"bodySite": {},
"tags": {},
"codes": {},
"healthcareElementId": "1d12b3f7-c788-4877-ae38-51ae3f7f493c",
"recordedDate": 20231115143014,
"openingDate": 20231115153014,
"description": "To modify, I must create",
"notes": [],
"systemMetaData": {
"secretForeignKeys": [
"b6540caa-1eb3-42ce-bf4a-f02c42bd9fd7"
],
"cryptedForeignKeys": {},
"delegations": {},
"encryptionKeys": {},
"securityMetadata": {
"secureDelegations": {},
"keysEquivalences": {}
},
"encryptedSelf": "u0BsIMtdNpojV9x6LukR2ccNHzSvxNxsGcksCRm/DnFoyr6ATs/iJsrUcm08Pz4qtdZoCROntVGR0NYOHxKYOA==",
"tags": {}
}
}
modifiedHealthcareElement
{
"id": "1d12b3f7-c788-4877-ae38-51ae3f7f493c",
"identifiers": [],
"rev": "1-98b1150b44b659fd56a4b60a015fa24f",
"created": 1700058614809,
"modified": 1700058614809,
"author": "17e392da-8e36-4e4e-abd7-7eef3e434395",
"responsible": "3ed06450-17e5-47b6-ba4f-7a0a084df56b",
"bodySite": {},
"tags": {},
"codes": {},
"healthcareElementId": "1d12b3f7-c788-4877-ae38-51ae3f7f493c",
"recordedDate": 20231115143014,
"openingDate": 1570838400000,
"description": "I can change and I can add",
"notes": [],
"systemMetaData": {
"secretForeignKeys": [
"b6540caa-1eb3-42ce-bf4a-f02c42bd9fd7"
],
"cryptedForeignKeys": {},
"delegations": {},
"encryptionKeys": {},
"securityMetadata": {
"secureDelegations": {},
"keysEquivalences": {}
},
"encryptedSelf": "u0BsIMtdNpojV9x6LukR2ccNHzSvxNxsGcksCRm/DnFoyr6ATs/iJsrUcm08Pz4qtdZoCROntVGR0NYOHxKYOA==",
"tags": {}
}
}
modificationResult
{
"id": "1d12b3f7-c788-4877-ae38-51ae3f7f493c",
"identifiers": [],
"rev": "2-01a59611aeb122fd5243dd9090e70d1a",
"created": 1700058614809,
"modified": 1700058614809,
"author": "17e392da-8e36-4e4e-abd7-7eef3e434395",
"responsible": "3ed06450-17e5-47b6-ba4f-7a0a084df56b",
"bodySite": {},
"tags": {},
"codes": {},
"healthcareElementId": "1d12b3f7-c788-4877-ae38-51ae3f7f493c",
"recordedDate": 20231115143014,
"openingDate": 1570838400000,
"description": "I can change and I can add",
"notes": [],
"systemMetaData": {
"secretForeignKeys": [
"b6540caa-1eb3-42ce-bf4a-f02c42bd9fd7"
],
"cryptedForeignKeys": {},
"delegations": {},
"encryptionKeys": {},
"securityMetadata": {
"secureDelegations": {},
"keysEquivalences": {}
},
"encryptedSelf": "l2RtiWapV2z0m1H2KxtnvDyYX7PZftMfYyQ73touP9BOWIrhLzI+EFLRjJy1OsX5fL5D3aynahlAdE4seJonbw==",
"tags": {}
}
}

If the operation is successful, the method returns the updated Condition.

caution

To update a Condition, both id and rev fields must be valid:

  • the id should be the one of an existing Condition
  • the rev is a field automatically managed by the iCure API to handle conflicts. It must be equal to the one received from the server when creating or getting the Condition you want to modify.

Retrieving Condition Using Complex Search Criteria

If you want to retrieve a set of Condition that satisfy complex criteria, you can use a Filter.
In the following example, you will instantiate a filter to retrieve all the Condition of a Patient that a Practitioner can access

const conditionFilter = await new ConditionFilter(api)
.forDataOwner(user.healthcarePartyId)
.forPatients([patient])
.build()
healthcareElementFilter
{
"filters": [
{
"healthcarePartyId": "3ed06450-17e5-47b6-ba4f-7a0a084df56b",
"tagType": "ICURE_INTERNAL_FHIR_TYPE",
"tagCode": "CONDITION",
"$type": "HealthElementByHealthcarePartyTagCodeFilter"
},
{
"healthcarePartyId": "3ed06450-17e5-47b6-ba4f-7a0a084df56b",
"patientSecretForeignKeys": [
"b6540caa-1eb3-42ce-bf4a-f02c42bd9fd7",
"03a08319-c8b0-4dcd-b9a1-6c25eaca79b3"
],
"$type": "HealthElementByHealthcarePartyPatientFilter"
}
],
"$type": "IntersectionFilter"
}
note

You can learn more about filters in the how to.

After creating a filter, you can use it to retrieve the Conditions.

const conditionsFirstPage = await api.conditionApi.filterBy(conditionFilter, undefined, 10)
healthcareElementsFirstPage
{
"rows": [
{
"id": "02ac45db-5be0-4e9a-84ce-f45d8a90d934",
"identifiers": [],
"rev": "1-4b03f1f668de5055c1e206ebf0965cd5",
"created": 1700058615120,
"modified": 1700058615120,
"author": "17e392da-8e36-4e4e-abd7-7eef3e434395",
"responsible": "3ed06450-17e5-47b6-ba4f-7a0a084df56b",
"bodySite": {},
"tags": {},
"codes": {},
"healthcareElementId": "02ac45db-5be0-4e9a-84ce-f45d8a90d934",
"recordedDate": 20231115143015,
"openingDate": 1570838400000,
"description": "Condition 6",
"notes": [],
"systemMetaData": {
"secretForeignKeys": [
"b6540caa-1eb3-42ce-bf4a-f02c42bd9fd7"
],
"cryptedForeignKeys": {},
"delegations": {},
"encryptionKeys": {},
"securityMetadata": {
"secureDelegations": {},
"keysEquivalences": {}
},
"encryptedSelf": "ajci7osPePJMLMvwSpF0FGDnVvVreuU/f8HsoE33x5MilBcbSwisHPVZhL15PuYJ",
"tags": {}
}
},
{
"id": "0738d47c-b9fa-4924-9116-20495fe3ef30",
"identifiers": [],
"rev": "1-bda863f9c627f2fc9725300d5cae9498",
"created": 1700058615155,
"modified": 1700058615155,
"author": "17e392da-8e36-4e4e-abd7-7eef3e434395",
"responsible": "3ed06450-17e5-47b6-ba4f-7a0a084df56b",
"bodySite": {},
"tags": {},
"codes": {},
"healthcareElementId": "0738d47c-b9fa-4924-9116-20495fe3ef30",
"recordedDate": 20231115143015,
"openingDate": 1570838400000,
"description": "Condition 7",
"notes": [],
"systemMetaData": {
"secretForeignKeys": [
"b6540caa-1eb3-42ce-bf4a-f02c42bd9fd7"
],
"cryptedForeignKeys": {},
"delegations": {},
"encryptionKeys": {},
"securityMetadata": {
"secureDelegations": {},
"keysEquivalences": {}
},
"encryptedSelf": "0tnleU72GYh9S6yExpKlxDQGuiJ+iWQ8SvtM0G56qgoyOK4qWcfgUg/bdQK4ZwLA",
"tags": {}
}
},
{
"id": "0ec5906e-82fc-40a0-a986-86c9fcec8044",
"identifiers": [],
"rev": "1-a52c7f834ee781f30a27d535f40f3978",
"created": 1700058614662,
"modified": 1700058614662,
"author": "17e392da-8e36-4e4e-abd7-7eef3e434395",
"responsible": "3ed06450-17e5-47b6-ba4f-7a0a084df56b",
"bodySite": {},
"tags": {},
"codes": {},
"healthcareElementId": "0ec5906e-82fc-40a0-a986-86c9fcec8044",
"recordedDate": 20231115143014,
"openingDate": 1570838400000,
"description": "The patient has been diagnosed Pararibulitis",
"notes": [],
"systemMetaData": {
"secretForeignKeys": [
"b6540caa-1eb3-42ce-bf4a-f02c42bd9fd7"
],
"cryptedForeignKeys": {},
"delegations": {},
"encryptionKeys": {},
"securityMetadata": {
"secureDelegations": {},
"keysEquivalences": {}
},
"encryptedSelf": "KsVESEoeThQoielZ74jKHGZ+fb/0KGDXCIaN4REMcyq+8CKQCg80pgElD6wo5JMLmGMxRN4qT37lSdM0lR84SgqA5xu9eqjmn+qk1aJofRQ=",
"tags": {}
}
},
{
"id": "0f7b840e-c65d-48dd-a81b-47a968fae1e2",
"identifiers": [],
"rev": "1-8abced7b97dc77b405a3eee33f412ee3",
"created": 1700058615221,
"modified": 1700058615221,
"author": "17e392da-8e36-4e4e-abd7-7eef3e434395",
"responsible": "3ed06450-17e5-47b6-ba4f-7a0a084df56b",
"bodySite": {},
"tags": {},
"codes": {},
"healthcareElementId": "0f7b840e-c65d-48dd-a81b-47a968fae1e2",
"recordedDate": 20231115143015,
"openingDate": 1570838400000,
"description": "Condition 9",
"notes": [],
"systemMetaData": {
"secretForeignKeys": [
"b6540caa-1eb3-42ce-bf4a-f02c42bd9fd7"
],
"cryptedForeignKeys": {},
"delegations": {},
"encryptionKeys": {},
"securityMetadata": {
"secureDelegations": {},
"keysEquivalences": {}
},
"encryptedSelf": "jbpgPBtKYHV4u/0B+1KZYGHcpkAbQCiA3Gh4k+CkB4Ml0zVyepujiQDfX+erLJxT",
"tags": {}
}
},
{
"id": "1b0803ed-213a-40a3-ba53-629926e56aef",
"identifiers": [],
"rev": "1-6fde1ba32e4d7735a5aac07cb1b534a9",
"created": 1700058614632,
"modified": 1700058614632,
"author": "17e392da-8e36-4e4e-abd7-7eef3e434395",
"responsible": "3ed06450-17e5-47b6-ba4f-7a0a084df56b",
"bodySite": {},
"tags": {},
"codes": {},
"healthcareElementId": "1b0803ed-213a-40a3-ba53-629926e56aef",
"recordedDate": 20231115143014,
"openingDate": 1570838400000,
"description": "The patient has been diagnosed Pararibulitis",
"notes": [],
"systemMetaData": {
"secretForeignKeys": [
"b6540caa-1eb3-42ce-bf4a-f02c42bd9fd7"
],
"cryptedForeignKeys": {},
"delegations": {},
"encryptionKeys": {},
"securityMetadata": {
"secureDelegations": {},
"keysEquivalences": {}
},
"encryptedSelf": "f5QpwmjIYhF95c2Lh6vGmwHmu/sP0op2GjHwoYE92PPbEuMQ+L+bkOGRnJR8OAzOjNTrJVcQLrkZKcqGX88dFT82JGs7MAckB6w3ZRYStBI=",
"tags": {}
}
},
{
"id": "1d12b3f7-c788-4877-ae38-51ae3f7f493c",
"identifiers": [],
"rev": "2-01a59611aeb122fd5243dd9090e70d1a",
"created": 1700058614809,
"modified": 1700058614809,
"author": "17e392da-8e36-4e4e-abd7-7eef3e434395",
"responsible": "3ed06450-17e5-47b6-ba4f-7a0a084df56b",
"bodySite": {},
"tags": {},
"codes": {},
"healthcareElementId": "1d12b3f7-c788-4877-ae38-51ae3f7f493c",
"recordedDate": 20231115143014,
"openingDate": 1570838400000,
"description": "I can change and I can add",
"notes": [],
"systemMetaData": {
"secretForeignKeys": [
"b6540caa-1eb3-42ce-bf4a-f02c42bd9fd7"
],
"cryptedForeignKeys": {},
"delegations": {},
"encryptionKeys": {},
"securityMetadata": {
"secureDelegations": {},
"keysEquivalences": {}
},
"encryptedSelf": "l2RtiWapV2z0m1H2KxtnvDyYX7PZftMfYyQ73touP9BOWIrhLzI+EFLRjJy1OsX5fL5D3aynahlAdE4seJonbw==",
"tags": {}
}
},
{
"id": "1e97fb4c-cf8c-4997-83c8-730f38b74299",
"identifiers": [],
"rev": "1-2de4cb34312ffbfbe97a2b2b151b5782",
"created": 1700058615087,
"modified": 1700058615087,
"author": "17e392da-8e36-4e4e-abd7-7eef3e434395",
"responsible": "3ed06450-17e5-47b6-ba4f-7a0a084df56b",
"bodySite": {},
"tags": {},
"codes": {},
"healthcareElementId": "1e97fb4c-cf8c-4997-83c8-730f38b74299",
"recordedDate": 20231115143015,
"openingDate": 1570838400000,
"description": "Condition 5",
"notes": [],
"systemMetaData": {
"secretForeignKeys": [
"b6540caa-1eb3-42ce-bf4a-f02c42bd9fd7"
],
"cryptedForeignKeys": {},
"delegations": {},
"encryptionKeys": {},
"securityMetadata": {
"secureDelegations": {},
"keysEquivalences": {}
},
"encryptedSelf": "BHi0GmYXMiLGR1TV42CJkm3+GD3g8nwynBp4Lna2zT5xx4jrS7EST8dS5uwHkVCp",
"tags": {}
}
},
{
"id": "28014a62-66f2-445c-8bc0-bf192f5f5801",
"identifiers": [],
"rev": "2-e6892f5903da7491508b4a414717cbe1",
"created": 1700058596247,
"modified": 1700058596247,
"author": "17e392da-8e36-4e4e-abd7-7eef3e434395",
"responsible": "3ed06450-17e5-47b6-ba4f-7a0a084df56b",
"bodySite": {},
"tags": {},
"codes": {},
"healthcareElementId": "28014a62-66f2-445c-8bc0-bf192f5f5801",
"recordedDate": 20231115142956,
"openingDate": 20231115152956,
"description": "My diagnosis is that the patient has Hay Fever",
"notes": [],
"systemMetaData": {
"secretForeignKeys": [
"b6540caa-1eb3-42ce-bf4a-f02c42bd9fd7"
],
"cryptedForeignKeys": {},
"delegations": {},
"encryptionKeys": {},
"securityMetadata": {
"secureDelegations": {},
"keysEquivalences": {}
},
"encryptedSelf": "8rZNR5of3tHwQYaDTQAvikxmu6QgE+LYW779oc9xafjJ/h/G/SCf8R5HPbLZjhfcd1v6/W4RcbNYBLvsyaqKjM8NtoY8vLjMr6OgyxcNtTw=",
"tags": {}
}
},
{
"id": "31a6c29e-ffe3-4ec7-86b8-6a151e458a53",
"identifiers": [],
"rev": "1-59060f6e8754634eb91164086beeaa89",
"created": 1700058614925,
"modified": 1700058614925,
"author": "17e392da-8e36-4e4e-abd7-7eef3e434395",
"responsible": "3ed06450-17e5-47b6-ba4f-7a0a084df56b",
"bodySite": {},
"tags": {},
"codes": {},
"healthcareElementId": "31a6c29e-ffe3-4ec7-86b8-6a151e458a53",
"recordedDate": 20231115143014,
"openingDate": 1570838400000,
"description": "Condition 0",
"notes": [],
"systemMetaData": {
"secretForeignKeys": [
"b6540caa-1eb3-42ce-bf4a-f02c42bd9fd7"
],
"cryptedForeignKeys": {},
"delegations": {},
"encryptionKeys": {},
"securityMetadata": {
"secureDelegations": {},
"keysEquivalences": {}
},
"encryptedSelf": "dGRE5RmhScLfDZuvrQdz+IhoSJ5OuFLF66BgcffHvFYizbgq43gkJn3LjtQbPoNb",
"tags": {}
}
},
{
"id": "4f3205e0-0440-4fea-b784-88f2680aebb5",
"identifiers": [],
"rev": "1-2b6d46e0b819b84aaffb38569a506bf8",
"created": 1700058614953,
"modified": 1700058614953,
"author": "17e392da-8e36-4e4e-abd7-7eef3e434395",
"responsible": "3ed06450-17e5-47b6-ba4f-7a0a084df56b",
"bodySite": {},
"tags": {},
"codes": {},
"healthcareElementId": "4f3205e0-0440-4fea-b784-88f2680aebb5",
"recordedDate": 20231115143014,
"openingDate": 1570838400000,
"description": "Condition 1",
"notes": [],
"systemMetaData": {
"secretForeignKeys": [
"b6540caa-1eb3-42ce-bf4a-f02c42bd9fd7"
],
"cryptedForeignKeys": {},
"delegations": {},
"encryptionKeys": {},
"securityMetadata": {
"secureDelegations": {},
"keysEquivalences": {}
},
"encryptedSelf": "bycVTCWeSp/JDPIdIXWl7HI/WsXG9RmnJ7c4ZeXyabLrw0zsfJnOsdXGakf9OsKp",
"tags": {}
}
}
],
"nextKeyPair": {
"startKey": "5944fbdd-9b57-4f5d-bfa4-c95a75b49e85",
"startKeyDocId": "5944fbdd-9b57-4f5d-bfa4-c95a75b49e85"
}
}

The filterBy method returns a PaginatedList that contains at most the number of elements stated in the method's parameter. If you do not specify any number, the default value is 1000.
To retrieve more Conditions, you can call the same method again, using the startDocumentId provided in the previous PaginatedList.

const conditionsSecondPage = await api.conditionApi.filterBy(
conditionFilter,
conditionsFirstPage.nextKeyPair.startKeyDocId,
10,
)
healthcareElementsSecondPage
{
"rows": [
{
"id": "5944fbdd-9b57-4f5d-bfa4-c95a75b49e85",
"identifiers": [],
"rev": "1-cc6f4b6685a30b52570de2c17fe08496",
"created": 1700058614991,
"modified": 1700058614991,
"author": "17e392da-8e36-4e4e-abd7-7eef3e434395",
"responsible": "3ed06450-17e5-47b6-ba4f-7a0a084df56b",
"bodySite": {},
"tags": {},
"codes": {},
"healthcareElementId": "5944fbdd-9b57-4f5d-bfa4-c95a75b49e85",
"recordedDate": 20231115143015,
"openingDate": 1570838400000,
"description": "Condition 2",
"notes": [],
"systemMetaData": {
"secretForeignKeys": [
"b6540caa-1eb3-42ce-bf4a-f02c42bd9fd7"
],
"cryptedForeignKeys": {},
"delegations": {},
"encryptionKeys": {},
"securityMetadata": {
"secureDelegations": {},
"keysEquivalences": {}
},
"encryptedSelf": "rF/d3imitB1Mb/xNsq1HympuYFUSBscI81OinKEloh0jTBK5qQoyQTWv5AZlSGcs",
"tags": {}
}
},
{
"id": "5c33fba3-9de3-434d-b36f-81ebef1f9d9c",
"identifiers": [],
"rev": "1-47232ebd835c57df827cee6c4745c4df",
"created": 1700058615023,
"modified": 1700058615023,
"author": "17e392da-8e36-4e4e-abd7-7eef3e434395",
"responsible": "3ed06450-17e5-47b6-ba4f-7a0a084df56b",
"bodySite": {},
"tags": {},
"codes": {},
"healthcareElementId": "5c33fba3-9de3-434d-b36f-81ebef1f9d9c",
"recordedDate": 20231115143015,
"openingDate": 1570838400000,
"description": "Condition 3",
"notes": [],
"systemMetaData": {
"secretForeignKeys": [
"b6540caa-1eb3-42ce-bf4a-f02c42bd9fd7"
],
"cryptedForeignKeys": {},
"delegations": {},
"encryptionKeys": {},
"securityMetadata": {
"secureDelegations": {},
"keysEquivalences": {}
},
"encryptedSelf": "fvPEk8VA2MKm1vg3fITzelo/avWgOzLxmzx5np1SiYKZ2+FFmeqT0GboplHsUlda",
"tags": {}
}
},
{
"id": "60017bf9-b6dc-4875-9eb7-b7febc71c87a",
"identifiers": [],
"rev": "1-6ca1edc334be3460129f6752d1e563ce",
"created": 1700058615057,
"modified": 1700058615057,
"author": "17e392da-8e36-4e4e-abd7-7eef3e434395",
"responsible": "3ed06450-17e5-47b6-ba4f-7a0a084df56b",
"bodySite": {},
"tags": {},
"codes": {},
"healthcareElementId": "60017bf9-b6dc-4875-9eb7-b7febc71c87a",
"recordedDate": 20231115143015,
"openingDate": 1570838400000,
"description": "Condition 4",
"notes": [],
"systemMetaData": {
"secretForeignKeys": [
"b6540caa-1eb3-42ce-bf4a-f02c42bd9fd7"
],
"cryptedForeignKeys": {},
"delegations": {},
"encryptionKeys": {},
"securityMetadata": {
"secureDelegations": {},
"keysEquivalences": {}
},
"encryptedSelf": "g0lpnJNACoqURlSXQ4Zpbg0xOpKsHt0KXFFetAIG1J4p/LsRjpym5Rn2TUKHoom7",
"tags": {}
}
},
{
"id": "62f452f5-af9a-4dd8-95a1-382353008f37",
"identifiers": [],
"rev": "1-bc8528e6fcf7feec2d710e37bfd0e110",
"created": 1700058593360,
"modified": 1700058593360,
"author": "17e392da-8e36-4e4e-abd7-7eef3e434395",
"responsible": "3ed06450-17e5-47b6-ba4f-7a0a084df56b",
"bodySite": {},
"tags": {},
"codes": {},
"healthcareElementId": "62f452f5-af9a-4dd8-95a1-382353008f37",
"recordedDate": 20231115142953,
"openingDate": 20231115152953,
"description": "My diagnosis is that the patient has Hay Fever",
"notes": [],
"systemMetaData": {
"secretForeignKeys": [
"b6540caa-1eb3-42ce-bf4a-f02c42bd9fd7"
],
"cryptedForeignKeys": {},
"delegations": {},
"encryptionKeys": {},
"securityMetadata": {
"secureDelegations": {},
"keysEquivalences": {}
},
"encryptedSelf": "4GLWVHlH5fVTZp0ogpJN/oZNKagNuwRx+foGVZFripFVplV97VKrMC6DilY+Ab0QDGln1eBOC7Li6dalchfff0beKrFspSslx4PkjuscRrc=",
"tags": {}
}
},
{
"id": "66d9b1d5-16e5-4303-bdf3-c9122da6828d",
"identifiers": [],
"rev": "1-79bc068d8f926bc5661dbcaea408df24",
"created": 1700058614632,
"modified": 1700058614632,
"author": "17e392da-8e36-4e4e-abd7-7eef3e434395",
"responsible": "3ed06450-17e5-47b6-ba4f-7a0a084df56b",
"bodySite": {},
"tags": {},
"codes": {},
"healthcareElementId": "66d9b1d5-16e5-4303-bdf3-c9122da6828d",
"recordedDate": 20231115143014,
"openingDate": 1604793600000,
"description": "The patient has also the flu",
"notes": [],
"systemMetaData": {
"secretForeignKeys": [
"b6540caa-1eb3-42ce-bf4a-f02c42bd9fd7"
],
"cryptedForeignKeys": {},
"delegations": {},
"encryptionKeys": {},
"securityMetadata": {
"secureDelegations": {},
"keysEquivalences": {}
},
"encryptedSelf": "nZAKLHG49s1Tui3NtTjugf1Sq2Bgu4xwrRB0wfJI3+VvtyVfJXV1uHpxFjFFYbpiIRAanC1np6I0XgB2f7BC0A==",
"tags": {}
}
},
{
"id": "68c30b72-d56a-481d-85fd-cc3935020199",
"identifiers": [],
"rev": "1-c95debef56aa06677acef76b973d981c",
"created": 1700058594075,
"modified": 1700058594075,
"author": "17e392da-8e36-4e4e-abd7-7eef3e434395",
"responsible": "3ed06450-17e5-47b6-ba4f-7a0a084df56b",
"bodySite": {},
"tags": {},
"codes": {},
"healthcareElementId": "68c30b72-d56a-481d-85fd-cc3935020199",
"recordedDate": 20231115142954,
"openingDate": 1700058594068,
"description": "The patient is pregnant",
"notes": [],
"systemMetaData": {
"secretForeignKeys": [
"b6540caa-1eb3-42ce-bf4a-f02c42bd9fd7"
],
"cryptedForeignKeys": {},
"delegations": {},
"encryptionKeys": {},
"securityMetadata": {
"secureDelegations": {},
"keysEquivalences": {}
},
"encryptedSelf": "NMI/4ShAwLRB3BM6MzNup0SevaSmPWUgKpgaVAHiPVSXAPdtVOi/kUrhVWHnZSlbvP4VmqpPHn0ZPqWAsVV3JA==",
"tags": {}
}
},
{
"id": "7a08d83c-9ef3-4c8d-b67e-0682501d77e5",
"identifiers": [],
"rev": "2-d3b5808036bc59fa33c5c4d156ad8b9d",
"created": 1700058614548,
"modified": 1700058614548,
"author": "17e392da-8e36-4e4e-abd7-7eef3e434395",
"responsible": "3ed06450-17e5-47b6-ba4f-7a0a084df56b",
"bodySite": {},
"tags": {},
"codes": {},
"healthcareElementId": "7a08d83c-9ef3-4c8d-b67e-0682501d77e5",
"recordedDate": 20231115143014,
"openingDate": 1570838400000,
"description": "The patient has been diagnosed Pararibulitis",
"notes": [],
"systemMetaData": {
"secretForeignKeys": [
"b6540caa-1eb3-42ce-bf4a-f02c42bd9fd7"
],
"cryptedForeignKeys": {},
"delegations": {},
"encryptionKeys": {},
"securityMetadata": {
"secureDelegations": {},
"keysEquivalences": {}
},
"encryptedSelf": "dpH5kYN2rqoS1N95ljz9OBO74PORyiWg9E2omh5sBHbI4qvylnFZMq9Ntkj9xxQVGn1iv5WfNquYq/lvx81y9pUxwKrdfgDjXt8IGJdnMWc=",
"tags": {}
}
},
{
"id": "d588da9a-ccf5-4bcc-b77e-98a5377d875d",
"identifiers": [],
"rev": "1-89055db25db9fcc3b2c9d4aa6d6d7877",
"created": 1700058615189,
"modified": 1700058615189,
"author": "17e392da-8e36-4e4e-abd7-7eef3e434395",
"responsible": "3ed06450-17e5-47b6-ba4f-7a0a084df56b",
"bodySite": {},
"tags": {},
"codes": {},
"healthcareElementId": "d588da9a-ccf5-4bcc-b77e-98a5377d875d",
"recordedDate": 20231115143015,
"openingDate": 1570838400000,
"description": "Condition 8",
"notes": [],
"systemMetaData": {
"secretForeignKeys": [
"b6540caa-1eb3-42ce-bf4a-f02c42bd9fd7"
],
"cryptedForeignKeys": {},
"delegations": {},
"encryptionKeys": {},
"securityMetadata": {
"secureDelegations": {},
"keysEquivalences": {}
},
"encryptedSelf": "jHeL4jlFmltoI9ge/XAuIWia40fd5yF+7BWjZfYmzqs2NrIE9R/Ehq0LgYAgJFQt",
"tags": {}
}
},
{
"id": "f0daa23f-99ec-49f7-867d-d32ad7733c82",
"identifiers": [],
"rev": "1-bf35e39d2fc8aadbf226dc985efd8cc5",
"created": 1700058614689,
"modified": 1700058614689,
"author": "17e392da-8e36-4e4e-abd7-7eef3e434395",
"responsible": "3ed06450-17e5-47b6-ba4f-7a0a084df56b",
"bodySite": {},
"tags": {},
"codes": {},
"healthcareElementId": "0ec5906e-82fc-40a0-a986-86c9fcec8044",
"recordedDate": 20231115143014,
"openingDate": 1604793600000,
"description": "The patient recovered",
"notes": [],
"systemMetaData": {
"secretForeignKeys": [
"b6540caa-1eb3-42ce-bf4a-f02c42bd9fd7"
],
"cryptedForeignKeys": {},
"delegations": {},
"encryptionKeys": {},
"securityMetadata": {
"secureDelegations": {},
"keysEquivalences": {}
},
"encryptedSelf": "0sqDu8xbrbDNF4cERS/PEqSex702VpBodSitqNoerRvr6EVjqAi3NcvRPoh9IU/as5jaudCzPkE6BNQK9pg80g==",
"tags": {}
}
}
]
}

If the nextKeyPair property of the result is undefined, than there are no more Conditions to retrieve.
You can also retrieve just the id of the Condition instead of the whole documents by using the match method.

const conditionsIdList = await api.conditionApi.matchBy(conditionFilter)
healthcareElementsIdList
[
"02ac45db-5be0-4e9a-84ce-f45d8a90d934",
"0738d47c-b9fa-4924-9116-20495fe3ef30",
"0ec5906e-82fc-40a0-a986-86c9fcec8044",
"0f7b840e-c65d-48dd-a81b-47a968fae1e2",
"1b0803ed-213a-40a3-ba53-629926e56aef",
"1d12b3f7-c788-4877-ae38-51ae3f7f493c",
"1e97fb4c-cf8c-4997-83c8-730f38b74299",
"28014a62-66f2-445c-8bc0-bf192f5f5801",
"31a6c29e-ffe3-4ec7-86b8-6a151e458a53",
"4f3205e0-0440-4fea-b784-88f2680aebb5",
"5944fbdd-9b57-4f5d-bfa4-c95a75b49e85",
"5c33fba3-9de3-434d-b36f-81ebef1f9d9c",
"60017bf9-b6dc-4875-9eb7-b7febc71c87a",
"62f452f5-af9a-4dd8-95a1-382353008f37",
"66d9b1d5-16e5-4303-bdf3-c9122da6828d",
"68c30b72-d56a-481d-85fd-cc3935020199",
"7a08d83c-9ef3-4c8d-b67e-0682501d77e5",
"d588da9a-ccf5-4bcc-b77e-98a5377d875d",
"f0daa23f-99ec-49f7-867d-d32ad7733c82"
]

You can also retrieve all the Conditions belonging to a specific patient that the current Data Owner can access.

const conditionsForPatient = await api.conditionApi.getAllForPatient(existingPatient)
healthcareElementsForPatient
[
{
"id": "bbcecec6-edf1-46a6-b98b-ef0b983f1fec",
"identifiers": [],
"rev": "1-d2a9c258595345580e42223f97436710",
"created": 1700058614893,
"modified": 1700058614893,
"author": "17e392da-8e36-4e4e-abd7-7eef3e434395",
"responsible": "3ed06450-17e5-47b6-ba4f-7a0a084df56b",
"bodySite": {},
"tags": {},
"codes": {},
"healthcareElementId": "bbcecec6-edf1-46a6-b98b-ef0b983f1fec",
"recordedDate": 20231115143014,
"openingDate": 20231115153014,
"description": "To modify, I must create",
"notes": [],
"systemMetaData": {
"secretForeignKeys": [
"e9cff62b-8f69-4a5b-9cf8-37869cc45ee7"
],
"cryptedForeignKeys": {},
"delegations": {},
"encryptionKeys": {},
"securityMetadata": {
"secureDelegations": {},
"keysEquivalences": {}
},
"encryptedSelf": "q1KGXi8DkLjSSXovgULW8eBJQleG3fM/DFlmCriu9s7/MJbyv8tJ7luNZKbHSM/25iO5Ob/0pePZRKSmKp5nXA==",
"tags": {}
}
}
]

Deleting a Condition

Finally, a Data Owner that has access to a Condition can decide to delete it.

const conditionsToDelete = await api.conditionApi.createOrModify(
new Condition({
description: 'I am doomed',
}),
patient.id,
)

const deletedCondition = await api.conditionApi.delete(conditionsToDelete.id)
healthcareElementToDelete
{
"id": "dd8d6342-e38f-4e64-b930-5beb0809fe7d",
"identifiers": [],
"rev": "1-783c7fca1bde63e5fba8c60c24c039f0",
"created": 1700058615379,
"modified": 1700058615379,
"author": "17e392da-8e36-4e4e-abd7-7eef3e434395",
"responsible": "3ed06450-17e5-47b6-ba4f-7a0a084df56b",
"bodySite": {},
"tags": {},
"codes": {},
"healthcareElementId": "dd8d6342-e38f-4e64-b930-5beb0809fe7d",
"recordedDate": 20231115143015,
"openingDate": 20231115153015,
"description": "I am doomed",
"notes": [],
"systemMetaData": {
"secretForeignKeys": [
"b6540caa-1eb3-42ce-bf4a-f02c42bd9fd7"
],
"cryptedForeignKeys": {},
"delegations": {},
"encryptionKeys": {},
"securityMetadata": {
"secureDelegations": {},
"keysEquivalences": {}
},
"encryptedSelf": "QLwoFIag651HYxjs47MYxDu6rwkxi4BkfYSjt8KfkYecdE4ixmnDVmOp7kVHLJPD",
"tags": {}
}
}
deletedHealthcareElement
2-a9b4c46a2b2b1a23cbff419fd900a29c