Batch Integration

This page documents FHIR-based batch integration patterns for SGCDI.

Overview

For systems that cannot support real-time FHIR REST APIs, FHIR Bulk Data (NDJSON-based file exchange) is the approved approach. This allows existing batch file integrations to transition to FHIR-compliant formats without requiring full REST API adoption.

Integration Pattern Format Use Case
FHIR REST API application/fhir+json (per-resource or Bundle) Real-time, request/response (NEHR submissions)
FHIR Bulk Data Export NDJSON (one resource per line) Bulk export from a source system to NEHR or a central repository
FHIR Bulk Data Import NDJSON (one resource per line) Bulk import into a target system (e.g., DMD drug formulary sync)

NDJSON Format

Each line in an NDJSON file is a complete, standalone FHIR resource serialised as a single-line JSON object. All resources in a single file MUST be of the same FHIR resource type.

{"resourceType":"Encounter","id":"enc-001","meta":{"profile":["https://fhir.synapxe.sg/StructureDefinition/profile-encounter"]},...}
{"resourceType":"Encounter","id":"enc-002","meta":{"profile":["https://fhir.synapxe.sg/StructureDefinition/profile-encounter"]},...}

Rules:

  • Each line is a valid FHIR R5 resource conforming to the applicable SGCDI profile
  • meta.profile MUST be present on every resource, identifying the SGCDI profile URL
  • File naming convention: {ResourceType}_{timestamp}.ndjson (e.g., Encounter_20260528T0800+0800.ndjson)
  • Files MUST be UTF-8 encoded, with Unix line endings (\n)

FHIR Bulk Data API

For systems that expose FHIR REST endpoints, the HL7 FHIR Bulk Data Access specification defines the standard operations:

Export (Source System → NEHR)

GET [base]/$export?_type=Encounter,Observation,MedicationDispense&_since=2026-05-01T00:00:00+08:00

The server responds asynchronously:

  1. 202 Accepted with Content-Location header pointing to a status endpoint
  2. Poll GET {statusUrl} until 200 OK with a manifest JSON body
  3. Download each NDJSON file listed in the manifest

Import (NEHR ← Source System)

POST [base]/$import
Content-Type: application/fhir+json

{
  "resourceType": "Parameters",
  "parameter": [
    { "name": "inputFormat", "valueString": "application/fhir+ndjson" },
    { "name": "inputSource", "valueUrl": "https://source.example.sg/exports/batch-20260528/" },
    { "name": "input", "part": [
        { "name": "type", "valueString": "Encounter" },
        { "name": "url", "valueUrl": "https://source.example.sg/exports/Encounter_20260528.ndjson" }
    ]}
  ]
}

SGCDI Resources Supported for Batch

The following SGCDI data objects are applicable for batch integration. Each corresponds to a single FHIR resource type suitable for NDJSON files.

Data Object FHIR Resource Type SGCDI Profile
Event / Visit Encounter profile-encounter
Allergy AllergyIntolerance profile-allergyintolerance
Medical Alert Flag profile-flag
Vital Signs Observation profile-observation
Immunization Immunization profile-immunization
Procedure Procedure profile-procedure
Lab Result DiagnosticReport profile-labreport
Ordered Medications MedicationRequest profile-medicationrequest
Dispensed Medications MedicationDispense profile-medicationdispense
Patient Medication List MedicationStatement profile-medicationstatement
Screening Summary Observation profile-observation
Coverage Coverage profile-coverage

Note: Document-type resources (Composition-based, such as Discharge Summary, ED Notes, OT Notes) are not suitable for single-resource NDJSON batch. These must be submitted as Bundles via the $submit REST operation or as Bundle NDJSON files where each line is a complete transaction Bundle.

Batch Bundle Files

For document-type resources, each line in the NDJSON file is a complete FHIR transaction Bundle conforming to the applicable SGCDI Bundle profile:

{"resourceType":"Bundle","id":"bundle-001","meta":{"profile":["https://fhir.synapxe.sg/StructureDefinition/profile-bundle-dischargesummary"]},"type":"transaction",...}
{"resourceType":"Bundle","id":"bundle-002","meta":{"profile":["https://fhir.synapxe.sg/StructureDefinition/profile-bundle-ednotes"]},"type":"transaction",...}

Error Handling

Batch processing errors are returned as OperationOutcome resources, one per failed resource line, in a separate NDJSON error file. The manifest includes the URL of this error file alongside each successfully processed resource file.

{
  "resourceType": "OperationOutcome",
  "issue": [{
    "severity": "error",
    "code": "invalid",
    "details": { "text": "Missing required element: Encounter.subject" },
    "diagnostics": "Line 47 in Encounter_20260528.ndjson"
  }]
}

Integration with HEALIX and MOH DMD

  • HEALIX: FHIR JSON batch integration (Encounter, MedicationDispense, Observation) is targeted for adoption by Dec 2026, with the DNA team operating HEALIX as the primary integrating party.
  • MOH DMD: NDJSON-based bulk import/export is the agreed approach for medication formulary and dispensing data exchange, addressing DMD's concern about how to use HL7 FHIR JSON for batch file integration (query closure targeted Sep 2026).