cql 0.6.3 copy "cql: ^0.6.3" to clipboard
cql: ^0.6.3 copied to clipboard

Model-independent CQL (Clinical Quality Language) translator and execution engine. FHIR-free — data access via ModelResolver; bindings are fhir_r4/r5/r6_cql.

example/main.dart

// A minimal end-to-end demo of the model-independent CQL engine:
// translate CQL source to an executable library, run it, and inspect the
// results. Run with: dart run example/main.dart
// ignore_for_file: avoid_print
import 'package:cql/cql.dart';

Future<void> main() async {
  const source = '''
library Example version '1.0.0'

define "TheAnswer": 6 * 7
define "Greeting": 'Hello, ' + 'CQL!'
define "SystolicRange": Interval[90, 120]
define "InRange": 100 in Interval[90, 120]
define "DoseSum": 5 'mg' + 2.5 'mg'
define "SecondsInADay": 24 * 60 * 60
''';

  // 1. Translate CQL source text into an executable library (ELM).
  final library = libraryFromCql(source);
  print('Translated library: ${library.identifier?.id} '
      'version ${library.identifier?.version}');

  // 2. Execute every define statement. The result is a map keyed by the
  //    define names, holding CQL System values (CqlInteger, CqlString,
  //    CqlInterval, ...).
  final results = await library.execute() as Map<String, dynamic>;
  print('');
  for (final entry in results.entries) {
    print('${entry.key}: ${entry.value} (${entry.value.runtimeType})');
  }

  // 3. The translated library round-trips through ELM JSON, so it can be
  //    stored and reloaded without re-translating the CQL source.
  final elmJson = library.toJson();
  final reloaded = CqlLibrary.fromJson(elmJson);
  final reloadedResults = await reloaded.execute() as Map<String, dynamic>;
  print('');
  print('Reloaded from ELM JSON, TheAnswer is still: '
      '${reloadedResults['TheAnswer']}');
}
0
likes
160
points
163
downloads

Documentation

API reference

Publisher

verified publisherfhirfli.dev

Weekly Downloads

Model-independent CQL (Clinical Quality Language) translator and execution engine. FHIR-free — data access via ModelResolver; bindings are fhir_r4/r5/r6_cql.

Homepage
Repository (GitHub)
View/report issues

Topics

#cql #fhir #hl7 #healthcare #interoperability

License

MIT (license)

Dependencies

antlr4, collection, json_annotation, meta, ucum, xml2json, yaml

More

Packages that depend on cql