fhir_bulk 0.13.0 copy "fhir_bulk: ^0.13.0" to clipboard
fhir_bulk: ^0.13.0 copied to clipboard

FHIR Bulk Data Access (NDJSON, compressed files, $export and $import) for every FHIR version, over the fhir_node reflection contract.

fhir_bulk #

pub package

FHIR Bulk Data Access for every FHIR version: NDJSON as lists and as streams, compressed bulk files (zip, gz, tar.gz), the $export client with the Bulk Data Access IG 2.0.0 kick-off and manifest shapes, and the $import client HAPI reads.

FHIR® is the registered trademark of HL7 and is used with the permission of HL7. Use of the FHIR trademark does not constitute endorsement of this product by HL7.

How it is version-free #

Resources are read by element name through the fhir_node contract and built through a BulkModel<R> that a version's binding supplies: its FHIR version, its resource type names, and a resource from and to JSON. The bindings are fhir_r4_bulk, fhir_r5_bulk and fhir_r6_bulk; each re-exports this package with its model filled in, so an application on one version writes FhirBulk.fromNdJson(text) and gets that version's resources.

Usage with a binding #

import 'package:fhir_r4_bulk/fhir_r4_bulk.dart';

final resources = FhirBulk.fromNdJson(ndjsonText);     // List<Resource>
final text = FhirBulk.toNdJson(resources);

// Streams: one resource a line, never a whole file in memory.
final stream = NdjsonStream.resources(NdjsonStream.lines(file.openRead()));
await NdjsonStream.write(NdjsonStream.encode(stream), sink, flush: sink.flush);

// $export, polled to completion, every output file fetched and decoded.
final exported = await BulkRequestPatient(
  base: Uri.parse('https://example.com/fhir'),
  types: [WhichResource(R4ResourceType.Patient)],
  since: '2024-01-01T00:00:00Z'.toFhirDateTime,
).request();

// $import (HAPI / Smile CDR).
final outcome = await BulkImportRequest(
  base: Uri.parse('https://example.com/fhir'),
  files: [
    ImportFile(
      resourceType: R4ResourceType.Patient,
      url: Uri.parse('https://data.example.com/patients.ndjson'),
    ),
  ],
).importData();

Usage without a binding #

Supply a BulkModel for whatever implements FhirNode:

import 'package:fhir_bulk/fhir_bulk.dart';

class MyModel extends BulkModel<MyResource> { ... }

const bulk = FhirBulk(MyModel());
final resources = bulk.fromNdJson(text);

Server-side shapes #

BulkExportKickoff.fromQuery / .fromParameters read a kick-off request (repeated and comma-delimited values become one list, as export.html requires), TypeFilter parses a _typeFilter query and names the response parameters it must not carry, and BulkExportManifest is the complete-status body, checked against the specification's own example.

7
likes
150
points
683
downloads

Documentation

API reference

Publisher

verified publisherfhirfli.dev

Weekly Downloads

FHIR Bulk Data Access (NDJSON, compressed files, $export and $import) for every FHIR version, over the fhir_node reflection contract.

Homepage
Repository (GitHub)
View/report issues

Topics

#fhir #hl7 #healthcare #bulk-data #ndjson

License

MIT (license)

Dependencies

archive, fhir_node, http, mime

More

Packages that depend on fhir_bulk