Aotearoa Immunisation Register (AIR) FHIR Implementation Guide (API-V1)
1.30.0-SNAPSHOT - ci-build New Zealand

Aotearoa Immunisation Register (AIR) FHIR Implementation Guide (API-V1) - Local Development build (v1.30.0-SNAPSHOT) built by the FHIR (HL7® FHIR® Standard) Build Tools. See the Directory of published versions

Immunisation Event Upsert

Overview

The "upsert" operation is a conditional-create operation, which checks whether a single immunisation event with the same primary attributes exists, and if it does, it updates the event with the new details provided. If no corresponding event is found, or multiple are found, then a create operation is performed.

The operation is used by a PMS (Practice Management System) where the AIR Identifier (Immunization.id) for the record is not yet known to the PMS and the record is updated locally.

The operation also performs validation checks to ensure that the event is valid before it is saved. Validation includes Rejection Rules and Data Quality Rules.

Upon a successful response, AIR will return the AIR Identifier and current version number. The PMS system shall persist these values in its data store, so that subsequent updates use the Update operation.

The upsert operation achieves the following:

  • Deduplication where possible,
  • Deterministic update behaviour, and
  • Atomic processing (all-or-nothing).

It performs the following:

  1. Checks the authorization token for required permissions.
  2. Checks the event data with the Rejection Rules and Data Quality Rules.
  3. Checks for exact duplicates, changing the status if found.
  4. Searches for a record to update that has the same primary attributes. If none or multiple are found, Create is performed.
  5. Checks if the NHI of the existing event matches the NHI of the event submitted. If they do not match, then a meta tag in the response will reflect this.
  6. Returns the created or updated event and any validation issues, identified in the meta sections.

Operation

POST https://api_endpoint/Immunization/$upsert

Request Headers

All headers listed in the request headers.

Request Body

Post a full set of immunisation resource details. See below. The FHIR specification for an AIR Immunization resource is the AIR Immunization Profile.

Sample Request Payload

{
   "resource": {
       "resourceType": "Immunization",
       "patient": {
           "reference": "https://api.hip.digital.health.nz/fhir/nhi/v1/Patient/ZZZ7541",
           "identifier": {
               "system": "https://standards.digital.health.nz/ns/nhi-id",
               "value": "ZZZ7541"
           }
       },
       "occurrenceDateTime": "2023-01-29T00:00:00.000+13:00",
       "location": {
           "reference": "https://api.hip.digital.health.nz/fhir/hpi/v1/Location/FZZ835-E",
           "identifier": {
               "system": "https://standards.digital.health.nz/ns/hpi-facility-id",
               "value": "FZZ835-E"
           }
       }, 
       "status": "completed",
       "statusReason": {
           "coding": [
               {
                 "system": "https://standards.digital.health.nz/ns/air-status-reason-terms",
                 "code": "GIVEN"
               }
           ]
       },
       "vaccineCode": {
           "coding": [
               {
                   "system": "http://hl7.org/fhir/sid/cvx",
                   "code": "03"
               }
           ],
           "text": "Priorix"
       }
   }
}

Behaviour

When a request is received, the API performs the following:

  1. Checks that the authorization token contains the required permission. If it does not, then it returns an error message indicating that the user does not have the required scope to create or update an immunisation record.
  2. Checks the event data with the Rejection Rules. If rejected, it returns an error with an OperationOutcome describing the problem.
  3. Searches for exact duplicates of the record. If a single match is found, then it updates that record and returns its AIR Identifier. If more than one exact duplicate is found, then it sets incoming status to "entered-in-error" with status reason indicating a duplicate report and creates a new record. These values are returned in the response. Stateful API clients shall reflect this condition in the local record.
  4. Checks if an immunisation event with the same primary attributes exists. These include: Patient Identifier, Vaccine Product (CVX/NZVX), Event Date (conditionally exact instant), and conditionally Indications and/or Dose Number. The Patient Identifier may be any NHI number linked to the consumer.
    • If no corresponding immunisation event record is found, then it performs a Create.
    • If a single existing immunisation event record is found, then it performs an Update of that record.
    • If multiple event records are found, then it performs a Create and adds Data Quality violation information to the event.
    • See Duplicate Record Handling for detail.
  5. If an update, then it checks whether the NHI of the existing event matches the NHI of the event being updated. If they do not match, the existing NHI is preserved and the meta.tag "patient-identifier-immutable" is returned in the response.
  6. Checks the created or updated event against the Data Quality Rules.
  7. Returns the created or updated event and any validation issues, identified in the meta sections.

Response

AIR returns the created or updated Immunization resource. If there were any failures or it was rejected, the response will contain an OperationOutcome resource array. The OperationOutcome resource has an informational issue indicating that the upsert operation failed. The issue array of the OperationOutcome resource would contain additional issues with appropriate severity and code values.

Sample Response Payload

{   
    "resourceType": "Immunization",
    "id": "c3640160-ad52-4aff-9bf3-fcf454c3962d",
    "meta": {
        "extension": [
            {
                "url": "https://standards.digital.health.nz/fhir/air/StructureDefinition/air-created-source-system",
                "valueString": "Postman"
            },
            {
                "url": "https://standards.digital.health.nz/fhir/air/StructureDefinition/air-created-by",
                "valueString": "PostmanUser"
            },
            {
                "url": "http://hl7.org/fhir/StructureDefinition/firstCreated",
                "valueInstant": "2023-10-09T21:34:29.475+13:00"
            },
            {
                "url": "https://standards.digital.health.nz/fhir/air/StructureDefinition/air-modified-by",
                "valueString": "PostmanUser"
            },
            {
                "url": "https://standards.digital.health.nz/fhir/air/StructureDefinition/air-modified-source-system",
                "valueString": "Postman"
            }
        ],
        "versionId": "1",
        "lastUpdated": "2023-10-09T21:46:16.918+13:00",
        "profile": [
            "https://standards.digital.health.nz/fhir/air/StructureDefinition/air-immunization"
        ]
    },        
    "patient": {
        "reference": "https://api.hip.digital.health.nz/fhir/nhi/v1/Patient/ZZZ7541",
        "identifier": {
            "system": "https://standards.digital.health.nz/ns/nhi-id",
            "value": "ZZZ7541"
        }
    },
    "occurrenceDateTime": "2023-01-29T00:00:00.000+13:00",
    "location": {
        "reference": "https://api.hip.digital.health.nz/fhir/hpi/v1/Location/FZZ835-E",
        "identifier": {
            "system": "https://standards.digital.health.nz/ns/hpi-facility-id",
            "value": "FZZ835-E"
        }
    }, 
    "status": "completed",
    "statusReason": {
        "coding": [
            {
              "system": "https://standards.digital.health.nz/ns/air-status-reason-terms",
              "code": "GIVEN",
              "display": "Vaccination given"
            }
        ]
    },
    "vaccineCode": {
        "coding": [
            {
                "system": "http://hl7.org/fhir/sid/cvx",
                "version": "1.0.0",
                "code": "03",
                "display": "MMR"
            }
        ],
        "text": "Priorix"
    }
}
patient-identifier-immutable in the response

The NHI number is immutable. When the NHI number in the request does not match the NHI of the stored record, then the meta.tag "patient-identifier-immutable" is inserted in the response. The updated record is stored with the existing NHI number, not the one provided.

"meta" : {
    ... // other meta elements
    "tag" : [
        {
            "system" : "https://standards.digital.health.nz/ns/air-processing-terms",
            "code" : "patient-identifier-immutable",
            "display" : "Patient identifier not updated - identifier is immutable for this operation"
        }
    ]
}

Scope/s required

Any FHIR scope that includes system/immunization.c or system/immunization.u, for example system/immunization.cruds or system/immunization.c

Notes

The Upsert API may be invoked only when a PMS updates a record that was persisted in its local data store prior to the AIR API coming into use. The record would have been sent to the AIR via HL7 messaging, in which case it has yet to be linked to the AIR by the AIR Identifier. Applications that do not persist immunisation event records locally shall not use the Upsert API.

  • The PMS shall use the Create API when creating new records locally. See Create Immunisation Event.
  • The PMS shall determine before calling $upsert whether the local record has an AIR Identifier.
  • If the record does have an AIR Identifier, then the PMS shall call the Update API instead. See Update Immunisation Event.
  • If the record does not have an AIR Identifier, then the PMS shall call the Upsert API.
  • When an $upsert request is received, AIR attempts to locate an existing immunisation event using linking rules.
  • Based on the outcome, AIR creates or updates an event and returns a response with AIR Identifier.
  • When the PMS receives a successful response from AIR, then the PMS shall update its local record with the AIR Identifier.