# API - Aotearoa Immunisation Register (AIR) FHIR Implementation Guide v1.31.0

* [**Table of Contents**](toc.md)
* **API**

## API

The Aotearoa Immunisation Register (AIR) FHIR v4.0.1 API

### REST APIs

#### Resource Level Interactions

##### Immunization

**Interactions**

* Code: create
  * Verb: POST
  * URL: [base]/Immunization/
  * Documentation: The "create" operation is used to create a new immunisation event. This method performs validation checks to ensure that the event is valid before it is created. Returns either the created Immunization record or if there were any issues with the create, the response will contain an OperationOutcome resource array. The OperationOutcome resource has an informational issue indicating that the create operation failed. The issue array of the OperationOutcome resource would contain additional issues with appropriate severity and code values.
* Code: read
  * Verb: GET
  * URL: [base]/Immunization/[id]
  * Documentation: The "read" operation is used to read an immunisation event. This method takes an immunisation event id and returns back the FHIR resource for the immunization event.
* Code: update
  * Verb: PUT
  * URL: [base]/Immunization/[id]
  * Documentation: The "update" operation is used to update an existing immunisation event. This method checks if the immunisation event with the given ID exists, and if it does, it updates the event with the new details provided. The method also performs validation checks to ensure that the updated event is valid before it is saved. Returns either the the updated immunisation record or an OperationOutcome if there were any issues with the update. On success - returns the updated immunisation record. data quality issues will be identified and sent as part of the response in the meta section of the resource. On Fail - if there were any issues with the update, the response will contain an OperationOutcome resource array. The OperationOutcome resource has an informational issue indicating that the update operation failed. The issue array of the OperationOutcome resource would contain additional issues with appropriate severity and code values.
* Code: history-instance
  * Verb: GET
  * URL: [base]/Immunization/[id]_history
  * Documentation: The _history interaction is used to return all the versions of an immunization event including the data quality. This method takes an immsot_id and returns back the FHIR bundle, which is a collection of immunization event resources where each resource in the bundle represents a version.

* Name: upsert
  * Definition: [ https://standards.digital.health.nz/fhir/air/OperationDefinition/immunization-upsert ](upsert.xml)
  * Documentation: Update or add an immunisation event
* Name: bulk-update
  * Definition: [ https://standards.digital.health.nz/fhir/air/OperationDefinition/immunization-bulk-update ](bulk-update.xml)
  * Documentation: Update or add immunisation events in bulk.

**Search Parameters**

* Name: patient
  * Type: [reference](http://hl7.org/fhir/search.html#reference)
  * Documentation: Definition: http://hl7.org/fhir/SearchParameter/patientNHI number of the patient
* Name: protocolApplied.targetDisease
  * Type: [token](http://hl7.org/fhir/search.html#token)
  * Documentation: Definition: http://hl7.org/fhir/SearchParameter/target-diseaseVaccine-preventable disease being targeted by an immunisation.
* Name: status-reason:not-in
  * Type: [token](http://hl7.org/fhir/search.html#token)
  * Documentation: Definition: http://hl7.org/fhir/SearchParameter/Immunization-StatusReasonExclude immunisation events with specified status reason codes
* Name: status:not-in
  * Type: [token](http://hl7.org/fhir/search.html#token)
  * Documentation: Definition: http://hl7.org/fhir/SearchParameter/Immunization-StatusExclude immunisation events with specified statuses
* Name: data-quality
  * Type: [special](http://hl7.org/fhir/search.html#special)
  * Documentation: Definition: https://standards.digital.health.nz/fhir/air/StructureDefinition/immunization-data-qualityQuery search for immunisation events with data quality issues. Restricted to admin users.

**Search includes**

* Name: *
* Name: Immunization.patient
* Name: Immunization.performer.actor
* Name: Immunization.location

**These are the _include parameters that are supported on searches**

##### Patient

**Interactions**

* Code: read
  * Verb: GET
  * URL: [base]/Patient/[id]
  * Documentation: Read the current state of an ImmSOT Consumer. Consumer state held in ImmSOT is returned as a FHIR AIR Patient. When an optional header "origin-nhi-version" is included which contains the NHI version, the API will check if it is the same NHI version we have stored in ImmSoT database for the Consumer. If it is the same, we return the current data we have in ImmSoT database. If it is not the same, we do a Consumer sync with NHI and update the data we have in ImmSoT database and then return this updated data in the response.

* Name: update-state
  * Definition: [ https://standards.digital.health.nz/fhir/air/OperationDefinition/update-patient-state ](update-state.xml)
  * Documentation: Update the current state of an ImmSOT Consumer. Updates the Consumer state and/or sub status only. Input is the Consumer version previously read (used for operation optimistic locking) and the desired Consumer state. At least one of state and subStatus must be specified. If state or subStatus is not specified, then these attributes will not be updated. Setting subStatus to null will clear the current sub status. A 412 Preconditioned Failed will be returned if the version received in the payload does not match the server version.
* Name: reassign-schedules
  * Definition: [ https://standards.digital.health.nz/fhir/air/OperationDefinition/reassign-patient-schedules ](reassign-schedules.xml)
  * Documentation: Reassign immunisation schedules for a patient. Cancels the existing schedules and then creates a new set of schedules based on the new onboarding date. Input is the new onboarding date.
* Name: patient-history
  * Definition: [ https://standards.digital.health.nz/fhir/air/OperationDefinition/patient-history ](patient-history.xml)
  * Documentation: Fetch all the versions of an ImmSOT Patient/Consumer.

#### Server Level Interactions

**Operations**

* Name: process-message
  * Definitions: http://hl7.org/fhir/OperationDefinition/MessageHeader-process-message

### Messages

**Definitions**

* Name: sender
  * Definitions: http://hl7.org.nz/fhir/MessageDefinition/UpdateImmunisationRequestMessageDefinition
* Name: sender
  * Definitions: http://hl7.org.nz/fhir/MessageDefinition/UpdateImmunisationResponsetMessageDefinition

