Metadata
Each resource object contains a metadata-object that is added by the API, based on who created/last updated the record.
The metadata can be used to see who created or updated the information. Please note that when updating data, we verify that the version sent in the update requests (PUT) is the latest version of the resource/record.
Use case
When creating a new object with a POST-request, the response will contain the added metadata from the server. Example:
Create communication need object with POST-request:
POST https://test.patient-info.hit.nhn.no/api/communicationNeeds
{
"communicationNeeds": [
{
"code": "KJ_KOMMUNIKASJON_6"
}
]
}
Response:
{
"communicationNeeds": [
{
"metadata": {
"resourceId": "123123",
"version": 1,
"patientInfoId": "2323",
"lastUpdated": "2025-03-05T06:41:27.217541Z",
"lastUpdatedBy": {
"userType": "HEALTH_CARE_PROFESSIONAL",
"orgNr": "998570328",
"orgName": null,
"treatmentFacilityName": "Andeby Helsestasjon",
"hprNr": "222200063",
"hprRole": "LE",
"name": "Lillehagen, Rolf Fos"
}
},
"code": {
"code": "KJ_KOMMUNIKASJON_6",
"codeSystem": "KJ_KOMMUNIKASJON",
"display": "Stum"
},
"status": true
}
]
}
Then, to update this object later, the version (1) needs to be included in the request metadata. Please note, that the version number refers to the version of the resource you're updating. This is to make sure only the latest version of an object is updated, and we do not allow updating a previous version Like so:
PUT https://test.patient-info.hit.nhn.no/api/communicationNeeds
{
"communicationNeeds": [
{
"metadata": {
"version": 1
},
"code": "KJ_KOMMUNIKASJON_6",
"comment": "communicates with sign language"
}
]
}
Response:
{
"communicationNeeds": [
{
"metadata": {
"resourceId": "123123",
"version": 2,
"patientInfoId": "2323",
"lastUpdated": "2025-03-05T07:41:27.217541Z",
"lastUpdatedBy": {
"userType": "HEALTH_CARE_PROFESSIONAL",
"orgNr": "998570328",
"orgName": null,
"treatmentFacilityName": "Andeby Helsestasjon",
"hprNr": "222200063",
"hprRole": "LE",
"name": "Lillehagen, Rolf Fos"
}
},
"code": {
"code": "KJ_KOMMUNIKASJON_6",
"codeSystem": "KJ_KOMMUNIKASJON",
"display": "Stum"
},
"comment": "communicates with sign language",
"status": true
}
]
}
Like the example shows, the version of the object is now "2".
Data structure
Resource metadata
| Field | Type | Required | Description |
|---|---|---|---|
| eventId | String | Optional event id | |
| resourceId | int | x | The ID of the resource |
| patientInfoId | int | x | The ID of the patient info record the resource belongs to |
| version | int | x | The version of the resource |
| lastUpdated | dateTime | x | When the resource was last updated |
| lastUpdatedBy | LastUpdatedBy | x | Who updated the object last |
Last updated by
| Field | Type | Required | Description |
|---|---|---|---|
| userType | Enum (HEALTH_CARE_PROFESSIONAL / PATIENT) | x | Who created/updated the resource (a health care professional or the patient themselves) |
| orgNr | String | x | The legal organization number of the health care professional that last updated the resource (empty if userType=patient). Source is HelseID token. |
| orgName | String | NB! Organization name is not set | |
| treatmentFacilityName | String | The treatment facility name of the health care professional that last updated the resource (empty if userType=patient). Source is HTTP header nhn-treatment-facility-name set by EPJ. | |
| hprNr | String | Hpr-nr of the health care professional that last updated the resource (empty if userType=patient). Source is HelseID token. | |
| hprRole | String | Hpr-role of the health care professional that last updated the resource (empty if userType=patient). Source is HTTP header nhn-user-role set by EPJ. | |
| name | String | x | Name of the health care professional that last updated the resource (empty if userType=patient). Source is HelseID token. |