Skip to main content

RelatedPerson

The RelatedPerson is an encryptable root-level entity, available since SDK 2.12.0, that represents a person related to one or more patients who is neither a patient nor a healthcare party: typically a contact person, such as the parent of a child patient, a caregiver, or a legal guardian.

A RelatedPerson is referenced from the partnerships of a Patient with partnerType = RelatedPerson. Note that, differently from patients and healthcare parties, a RelatedPerson is not a data owner: it cannot be associated to a User, cannot log in, and data cannot be shared with it.

Fields Encrypted by Default​

By default, the following fields of this entity will be encrypted:

  • created
  • modified
  • companyName
  • languages
  • civility

You can customize the encrypted fields as explained in this how to.

caution

Note that, differently from most other entities, the created and modified timestamps of a RelatedPerson are encrypted by default.

Properties​

Below you will find an explanation of the most commonly used properties in the entity that are not among the shared fields. For a full list, check the reference documentation (🚧).

firstName​

The first name of the related person.

lastName​

The last name (surname) of the related person.

names​

The list of all the names of the related person, also containing the official full name information.

companyName​

The name of the company this related person is member of.

languages​

The list of languages spoken by the related person, in ISO 639-2 alpha-2 code.

addresses​

The addresses and telecoms (phone numbers, email addresses, ...) of the related person.

civility​

The civility of the related person (Mr., Ms., Pr., Dr., ...).

gender​

The gender of the related person.

A RelatedPerson is created like any other encryptable entity: you first initialize its encryption metadata, then you commit the creation. Since it is a root entity, it is not linked to any owning entity, so you don't have to pass a patient (or any other entity) when initializing the encryption metadata.

The link between a Patient and a RelatedPerson is instead stored on the patient side, by adding to the partnerships of the patient an entry with the id of the related person as partnerId and PartnerType.RelatedPerson as partnerType:

import com.icure.cardinal.sdk.model.DecryptedRelatedPerson
import com.icure.cardinal.sdk.model.embed.DecryptedPartnership
import com.icure.cardinal.sdk.model.embed.PartnerType
import com.icure.cardinal.sdk.model.embed.PartnershipStatus
import com.icure.cardinal.sdk.model.embed.PartnershipType
import kotlin.uuid.Uuid

// Create the related person
val relatedPerson = sdk.relatedPerson.createRelatedPerson(
sdk.relatedPerson.withEncryptionMetadata(
DecryptedRelatedPerson(
id = Uuid.random().toString(),
firstName = "Anna",
lastName = "Dupont",
)
)
)

// Link it to the patient through a partnership
val patient = sdk.patient.getPatient(patientId)!!
sdk.patient.modifyPatient(
patient.copy(
partnerships = patient.partnerships + DecryptedPartnership(
partnerId = relatedPerson.id,
partnerType = PartnerType.RelatedPerson,
type = PartnershipType.Mother,
status = PartnershipStatus.Active,
)
)
)

To retrieve the related persons of a patient, collect the partnerIds of the partnerships with partnerType = RelatedPerson and retrieve them by id:

import com.icure.cardinal.sdk.model.embed.PartnerType

val relatedPersonIds = patient.partnerships
.filter { it.partnerType == PartnerType.RelatedPerson }
.mapNotNull { it.partnerId }
val relatedPersons = sdk.relatedPerson.getRelatedPersons(relatedPersonIds)

You can also search the related persons accessible to the current data owner by name or by identifier, using the RelatedPersonFilters with the filterRelatedPersonsBy and matchRelatedPersonsBy methods of the relatedPerson api.