Skip to main content

NDJSON Writer

Category: Data
Node id: ndjson-writer

Standards: EHDS, FHIR-Bulk-Data

Writes FHIR resources to NDJSON files (application/fhir+ndjson) with optional gzip compression and bulk export by resource type

What it does​

  • Single-file and bulk export write modes
  • Optional gzip compression for output files
  • Automatic resource type grouping for bulk export
  • Resource count tracking per type
  • Path security validation

Use cases​

  • Export FHIR resources as NDJSON for Bulk Data API compliance
  • Write transformed patient data to compressed NDJSON files
  • Bulk export resources grouped by type for interoperability exchange

Runtime​

  • Performance tier: medium

Input ports​

NameTypeRequiredDescription
resourcesjsonYesArray of FHIR resources to write

Output ports​

NameTypeRequiredDescription
file_pathtextNoPath to the written file (write operation)
resources_writtennumberNoNumber of resources written (write operation)
file_size_bytesnumberNoSize of the written file in bytes
compressedbooleanNoWhether gzip compression was applied
files_writtenjsonNoMap of resourceType to file path (write_bulk)
total_resourcesnumberNoTotal resources written across all files (write_bulk)
resource_countsjsonNoMap of resourceType to count (write_bulk)
successbooleanNoWhether the operation succeeded

Settings​

Basic​

SettingNameTypeRequiredDefaultAllowed valuesDescription
OperationoperationenumYeswritewrite, write_bulkWrite operation mode
File Pathfile_pathstringNoOutput file path (for write operation)
Output Directoryoutput_directorystringNoOutput directory for bulk export (for write_bulk operation)
CompresscompressbooleanNofalseApply gzip compression to output files

Advanced​

SettingNameTypeRequiredDefaultAllowed valuesDescription
Base Directorybase_directorystringNoBase directory for path security validation

Errors​

CodeDescription
WRITE_FAILEDFailed to write NDJSON data to disk
INVALID_RESOURCESInput resources is not a valid array
PATH_SECURITY_VIOLATIONOutput path is outside the allowed base directory

Runtime notes​

  • Output keys differ by operation: write returns file_path/resources_written/file_size_bytes; write_bulk returns files_written/total_resources/resource_counts
  • write_bulk groups resources by their 'resourceType' field and writes one file per type
  • Resources without a resourceType field are written to an 'Unknown' file in bulk mode
  • Parent directories are created automatically if they do not exist

See Build any workflow for how to put nodes together and Ports, types and data flow for how port types connect.

Something unclear? Send documentation feedback by email.