Metadata
Each record inside the maternity record object contains a metadata-object that is added by the API, based on who created/last updated the resource.
This can be used to see who created or updated the information, and is also important when updating data, as we verify that the version sent in update requests (PUT) is the latest version of the object.
NB! Metadata for the whole Maternity record (Digitalt Helsekort for gravide) also includes the field status which gives information if a maternity record is active or not. More information about possible values for status will come at a later point in time.
Use case
When creating a new object with a POST-request, the response will contain the added metadata from the server. Example:
Create mother object with POST-request:
POST https://test.maternity-record.hit.nhn.no/api/maternity-record/v1/record/ID_OF_MATERNITY_RECORD/mother
body: {
"name": "Navn Navnesen"
}
Response:
{
"metadata": {
"version": 1,
"lastUpdated": "2024-10-29T11:45:06.866",
"lastUpdatedBy": {
"userType": "HEALTH_CARE_PROFESSIONAL",
"orgNr": "998570328",
"orgNrDisplay": "Munkholmen Legesenter",
"hprNr": "222200063",
"hprRole": "LE",
"name": "Lillehagen, Rolf Fos"
}
},
"name": "Navn Navnesen"
}
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.maternity-record.hit.nhn.no/api/maternity-record/v1/record/ID_OF_MATERNITY_RECORD/mother
body: {
"metadata": {
"version": 1,
},
"name": "Navn Navnesen",
"address": "Street 1"
}
Response:
{
"metadata": {
"version": 2,
"lastUpdated": "2024-10-29T11:45:06.866",
"lastUpdatedBy": {
"userType": "HEALTH_CARE_PROFESSIONAL",
"orgNr": "998570328",
"orgNrDisplay": "Munkholmen Legesenter",
"hprNr": "222200063",
"hprRole": "LE",
"name": "Lillehagen, Rolf Fos"
}
},
"name": "Navn Navnesen",
"address": "Street 1"
}
Like the example shows, the version of the object is now "2".
Data structure
Root object
Field | Type | Required | Description |
---|---|---|---|
id | uuid/String | x | The ID of the resource |
version | int | x | The version of the resource |
lastUpdated | dateTime | x | When the resource was last updated |
lastUpdatedBy | LastUpdatedBy | x | Hva som ble gjort (feks. lest, opprettet, redigert etc) |
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 | Organization number of the health care professional that last updated the resource (empty if userType=patient) | |
orgName | String | Organization name of the health care professional that last updated the resource (empty if userType=patient) | |
hprNr | String | Hpr-nr of the health care professional that last updated the resource (empty if userType=patient) | |
hprRole | String | Hpr-role of the health care professional that last updated the resource (empty if userType=patient) | |
name | String | Name of the health care professional that last updated the resource (empty if userType=patient) |