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
| Name | Type | Required | Description |
|---|---|---|---|
resources | json | Yes | Array of FHIR resources to write |
Output ports
| Name | Type | Required | Description |
|---|---|---|---|
file_path | text | No | Path to the written file (write operation) |
resources_written | number | No | Number of resources written (write operation) |
file_size_bytes | number | No | Size of the written file in bytes |
compressed | boolean | No | Whether gzip compression was applied |
files_written | json | No | Map of resourceType to file path (write_bulk) |
total_resources | number | No | Total resources written across all files (write_bulk) |
resource_counts | json | No | Map of resourceType to count (write_bulk) |
success | boolean | No | Whether the operation succeeded |
Settings
Basic
| Setting | Name | Type | Required | Default | Allowed values | Description |
|---|---|---|---|---|---|---|
| Operation | operation | enum | Yes | write | write, write_bulk | Write operation mode |
| File Path | file_path | string | No | Output file path (for write operation) | ||
| Output Directory | output_directory | string | No | Output directory for bulk export (for write_bulk operation) | ||
| Compress | compress | boolean | No | false | Apply gzip compression to output files |
Advanced
| Setting | Name | Type | Required | Default | Allowed values | Description |
|---|---|---|---|---|---|---|
| Base Directory | base_directory | string | No | Base directory for path security validation |
Errors
| Code | Description |
|---|---|
WRITE_FAILED | Failed to write NDJSON data to disk |
INVALID_RESOURCES | Input resources is not a valid array |
PATH_SECURITY_VIOLATION | Output 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.
¿Algo no está claro? Envíe sus comentarios sobre la documentación por correo electrónico..