Error Handling

In the event that the critical-information API returns an error, the response body will contain a error message in JSON format in accordance with the OperationOutcome FHIR standard.

We're also sending all error codes in the response header nhn-error-code (see below). 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.

The error code, and other details, can also be found in OperationOutcome.issue.details.coding by searching for the relevant coding system shown in the example below.

The error message can be found in OperationOutcome.issue.diagnostics, and the event ID for the request in OperationOutcome.id.

The FHIR path in which the error occured is in OperationOutcome.issue.location. It may be empty.

Example of a error response body returned from the API:

{
  "resourceType": "OperationOutcome",
  "id": "c65f8f64-2c9c-4624-a4f0-3dbc4bde3300",
  "issue": [
    {
      "severity": "fatal",
      "code": "invariant",
      "diagnostics": "Invalid element content - max: 500",
      "location": [
        "Condition.note"
      ],
      "details": {
        "coding": [
          {
            "system": "http://nhn.no/hit/fhir/error/CodeSystem/ErrorCode",
            "code": "KI-0014"
          },
          {
            "system": "http://nhn.no/hit/fhir/error/CodeSystem/ErrorCodeKjLegacy",
            "code": "KI-0014"
          },
          {
            "system": "http://nhn.no/hit/fhir/error/CodeSystem/ApiVersion",
            "code": "v1"
          },
          {
            "system": "http://nhn.no/hit/fhir/error/CodeSystem/ApplicationVersion",
            "code": "8527aa3a"
          },
          {
            "system": "http://nhn.no/hit/fhir/error/CodeSystem/Environment",
            "code": "test1"
          },
          {
            "system": "http://nhn.no/hit/fhir/error/CodeSystem/ServiceName",
            "code": "critical-information"
          }
        ]
      }
    }
  ]
}

Error Codes

Authorization

For errors related to authorization go here.

Application Error Codes

As mentioned above we're sending all error codes in the response header nhn-error-code. Error codes has prefix "KI" (capital i).

In order to support Kjernejournal backwards compatibility we've kept some of the old error codes (prefix KJF). We're also sending all error codes in the response header X-KJ-Feilkode to keep backwards compatibility. Other Kjernejournal error codes which are not listed below are no longer in use for critical-information. Note that both the old Kjernejournal error codes and response header will be phased out in future API-versions.

Error code Error code KJ legacy Cause
KI-0001 KI-0001 Failure during init of application.
KI-0002 KI-0002 Something failed in a scheduled job.
KI-0003 KI-0003 Migrating data from KJ classic failed.
KI-0004 KI-0004 Something went wrong when communicating with Kafka.
KI-0005 KI-0005 A batch job failed.
KI-0006 KI-0006 Internal technical error.
KI-0007 KI-0007 Some part of the http request is invalid like e.g. the body. See error message for details.
KI-0008 KI-0008 Failed to merge patient nins.
KI-0009 KI-0009 An error related to id-mapping.
KI-0010 KI-0010 The patient nin in the FHIR resource does not match the patient nin in the header.
KI-0011 KI-0011 Updating an old version of a Critical Information record is not allowed.
KI-0012 KI-0012 The operation is not implemented. See error message for details.
KI-0013 KI-0013 No changes were detected in the update.
KI-0014 KI-0014 A field in the FHIR profile is invalid. See error message for details.
KI-0015 KI-0015 The requested Critical Information record does not exist.
KI-0016 KI-0016 A business rule was violated. See error message for details.
KI-0017 KI-0017 The user does not have access to the requested endpoint. See error message for details.
KI-0018 KJF-000352 The user tried to lookup a patient but has been blocked by the patient (blokkering).
KI-0019 KJF-000179 The user is requesting access to data that the patient has set restricted access to (sperring).