Skip to main content

Handling practitioners

Practitioners are doctors, nurses, physiotherapists, etc. They are the people who are going to use the medical device to take care of patients.
Practitioners can also in certain cases be a healthcare organizations.
The healthcareProfessionalApi allows you to manage Practitioners.

Create a practitioner

You first need to instantiate a Practitioner object. Pass the Practitioner to the create method of the practitionerApi to create it in the database.

const practitioner: Practitioner = new Practitioner({
firstName: 'John',
lastName: 'Keats',
speciality: 'Psychiatrist',
codes: new Set([new CodingReference({ type: 'practitioner-specialty', code: practitionerCode })]),
addresses: [
new Location({
telecoms: [
new ContactPoint({
system: ContactPointTelecomTypeEnum.EMAIL,
value: `jk@hospital.care`,
}),
],
}),
],
})

const createdPractitioner = await api.practitionerApi.createOrModify(practitioner)
createdHcp
{
"id": "74a13408-abc8-4ddf-84ba-727f3a34e564",
"rev": "1-446af2b4b046320a49f51aad3cde0275",
"created": 1700058612222,
"modified": 1700058612222,
"identifiers": [],
"tags": {},
"codes": {},
"name": "Keats John",
"lastName": "Keats",
"firstName": "John",
"names": [
{
"family": "Keats",
"given": [
"John"
],
"prefix": [],
"suffix": [],
"text": "Keats John",
"use": "official"
}
],
"speciality": "Psychiatrist",
"addresses": [
{
"notes": [],
"telecoms": [
{
"system": "email",
"value": "jk@hospital.care"
}
]
}
],
"languages": [],
"specialityCodes": {},
"description": {},
"properties": {},
"systemMetaData": {
"hcPartyKeys": {},
"privateKeyShamirPartitions": {},
"aesExchangeKeys": {},
"transferKeys": {},
"publicKeysForOaepWithSha256": [],
"tags": {}
}
}

Load a practitioner by id

The get method of the practitionerApi allows you to load a Practitioner by id.

const loadedPractitioner = await api.practitionerApi.get(createdPractitioner.id)
loadedHcp
{
"id": "74a13408-abc8-4ddf-84ba-727f3a34e564",
"rev": "1-446af2b4b046320a49f51aad3cde0275",
"created": 1700058612222,
"modified": 1700058612222,
"identifiers": [],
"tags": {},
"codes": {},
"name": "Keats John",
"lastName": "Keats",
"firstName": "John",
"names": [
{
"family": "Keats",
"given": [
"John"
],
"prefix": [],
"suffix": [],
"text": "Keats John",
"use": "official"
}
],
"speciality": "Psychiatrist",
"addresses": [
{
"notes": [],
"telecoms": [
{
"system": "email",
"value": "jk@hospital.care"
}
]
}
],
"languages": [],
"specialityCodes": {},
"description": {},
"properties": {},
"systemMetaData": {
"hcPartyKeys": {},
"privateKeyShamirPartitions": {},
"aesExchangeKeys": {},
"transferKeys": {},
"publicKeysForOaepWithSha256": [],
"tags": {}
}
}

Filter practitioners

You can build complex queries and use them to retrieve Practitioners using the filterBy method of the practitionerApi.

You can build filters by hand or use the DSL provided by the PractitionerFilter class.

const practitioners = await api.practitionerApi.filterBy(
await new PractitionerFilter(api)
.byLabelCodeFilter(undefined, undefined, 'practitioner-specialty', practitionerCode)
.build(),
)
hcps
{
"rows": [
{
"id": "74a13408-abc8-4ddf-84ba-727f3a34e564",
"rev": "1-446af2b4b046320a49f51aad3cde0275",
"created": 1700058612222,
"modified": 1700058612222,
"identifiers": [],
"tags": {},
"codes": {},
"name": "Keats John",
"lastName": "Keats",
"firstName": "John",
"names": [
{
"family": "Keats",
"given": [
"John"
],
"prefix": [],
"suffix": [],
"text": "Keats John",
"use": "official"
}
],
"speciality": "Psychiatrist",
"addresses": [
{
"notes": [],
"telecoms": [
{
"system": "email",
"value": "jk@hospital.care"
}
]
}
],
"languages": [],
"specialityCodes": {},
"description": {},
"properties": {},
"systemMetaData": {
"hcPartyKeys": {},
"privateKeyShamirPartitions": {},
"aesExchangeKeys": {},
"transferKeys": {},
"publicKeysForOaepWithSha256": [],
"tags": {}
}
}
]
}

Delete a practitioner

The delete method of the practitionerApi allows you to delete a Practitioner by id.

const deletedPractitioner = await api.practitionerApi.delete(createdPractitioner.id)
deletedHcp
3-683d9df5cd162cd162a658a2183bf6f5