Metadata

Each maternity record object contains a metadata-object that is added by the API, based on who created/last updated the record.

Each resource inside the maternity record object also contains a metadata object that is added by the API, based on who created/last updated the resource.

There are small differences between the metadata for a resource and the record, the differences are listed below

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.

To see examples on how to use the record metadata to update status of a maternity record - see Ending maternity record

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

{
  "name": "Navn Navnesen"
}

Response:

{
  "metadata": {
    "id": "6673a401-37b7-4084-a3e2-cfbffb16ad4a",
    "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

{
  "metadata": {
    "version": 1
  },
  "name": "Navn Navnesen",
  "address": "Street 1"
}

Response:

{
  "metadata": {
    "id": "6673a401-37b7-4084-a3e2-cfbffb16ad4a",
    "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

Resource metadata

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 Who updated the object last

Record metadata

Field Type Required Description
recordId uuid/String x The ID of the record
recordStatus RecordStatus x The status of the record
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 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)

RecordStatus

Field Type Required Description
status Enum ("ACTIVE", "DELIVERED","TERMINATED", "ENTERED IN ERROR") x The status of the record
deliveryDate dateTime The date of delivery of fetus - only required if status is delivered
liveBirth boolean Whether the fetus was born alive - only required if status is delivered
terminationDate dateTime The date for when pregnancy was terminated - only required if status is terminated