Error Handling
In the event that the API returns an error, the response body will contain a error message and error code in the JSON format shown below.
We're also sending all error codes in the response header nhn-error-code.
You can use this header if you're only interested in the error code to avoid parsing the response body.
When error response the HTTP status will be in the range 3xx-5xx. When ok response the HTTP status will be in the 2xx range.
In case the service sees too high load then the request might be rate limited and the client will in that case receive a response with status code 429 and empty body.
Example of an error response body returned from the API:
{
"errorCode": "DHG-0009",
"errorMessage": "An active maternity record already exists for patient. Cannot have multiple active maternity records.",
"eventId": "c65f8f64-2c9c-4624-a4f0-3dbc4bde3300"
}
Error Codes
Error codes has prefix "DHG".
For errors related to authorization go here.
| Error code | Cause |
|---|---|
| DHG-0001 | Unknown technical error |
| DHG-0002 | Patient is deceased, creating / updating DHG data is not allowed |
| DHG-0003 | Patient has not consented to DHG - cannot read / create / update DHG |
| DHG-0004 | Patient has confidential address, reading / creating / updating DHG data is not allowed |
| DHG-0005 | Invalid auth role |
| DHG-0006 | Technical error with DB |
| DHG-0007 | Resource does not exist to update |
| DHG-0008 | Invalid version sent in update request. Only newest version of a resource can be updated, make sure to read DHG before making any updates. Can also mean that the max version (255) was reached. |
| DHG-0009 | Cannot create resource that already exists - use update |
| DHG-0010 | Invalid user |
| DHG-0011 | Deserialization error |
| DHG-0012 | Data validation error |
| DHG-0013 | Invalid nin (fnr/dnr) |
| DHG-0015 | Invalid or inactive maternity record (id) |
| DHG-0016 | Invalid code system |
| DHG-0017 | Resource is deleted, cannot be updated |
| DHG-0018 | The maximum number of resources (255) has been reached for this data type (eg. antenatal appointments) |
| DHG-0019 | The datetime is invalid (e.g set in the future, when updating Maternity RecordStatus) |
| DHG-0024 TEST ONLY | The new resource in an update/PUT operation contained no functional changes compared to the existing resource |
Warnings
In some cases, a warning accompanied by status OK is returned instead of an error accompanied by status 4xx/5xx
| Causes | Environments |
|---|---|
| Resource in update/PUT request contains no changes | PROD, QA |