How to use the cql-execution.Repository function in cql-execution

To help you get started, we’ve selected a few cql-execution examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github AHRQ-CDS / AHRQ-CDS-Connect-Authoring-Tool / frontend / src / actions / artifacts.js View on Github external
function performExecuteArtifact(elmFiles, artifactName, params, patients, vsacCredentials, codeService, dataModel) {
  // Set up the library
  const elmFile = JSON.parse(_.find(elmFiles, f =>
    f.name.replace(/[\s-\\/]/g, '') === artifactName.replace(/[\s-\\/]/g, '')).content);
  const libraries = _.filter(elmFiles, f =>
    f.name.replace(/[\s-\\/]/g, '') !== artifactName.replace(/[\s-\\/]/g, '')).map(f => JSON.parse(f.content));
  const library = new cql.Library(elmFile, new cql.Repository(libraries));

  // Set up the parameters
  const cqlExecParams = convertParameters(params);

  // Create the patient source
  const patientSource = (dataModel.version === '3.0.0')
    ? cqlfhir.PatientSource.FHIRv300()
    : cqlfhir.PatientSource.FHIRv102();

  // Load the patient source with the patient
  patientSource.loadBundles(patients);

  // Extract the value sets from the ELM
  let valueSets = [];
  if (elmFile.library && elmFile.library.valueSets && elmFile.library.valueSets.def) {
    valueSets = elmFile.library.valueSets.def;
github HL7-DaVinci / dtr / src / elmExecutor / executeElm.js View on Github external
function executeElmAgainstPatientSource(executionInputs, patientSource) {
  // executionInputs.elmDependencies = [ fhirhelpersElm ]
  const repository = new cql.Repository(executionInputs.elmDependencies);
  const lib = new cql.Library(executionInputs.elm, repository);
  const codeService = new cql.CodeService(executionInputs.valueSetDB);
  const executor = new cql.Executor(lib, codeService, executionInputs.parameters);
  const results = executor.exec(patientSource);
  return results.patientResults[Object.keys(results.patientResults)[0]];
}
github HL7-DaVinci / dtr / frontend / src / elmExecutor / buildElmExecutor.js View on Github external
function executeElmAgainstPatientSource(executionInputs, patientSource) {
  executionInputs.elmDependencies = [ fhirhelpersElm ]
  const repository = new cql.Repository(executionInputs.elmDependencies);
  const lib = new cql.Library(executionInputs.elm, repository);
  const codeService = new cql.CodeService(executionInputs.valueSetDB);
  const executor = new cql.Executor(lib, codeService, executionInputs.parameters);
  const results = executor.exec(patientSource);
  return results.patientResults[Object.keys(results.patientResults)[0]];
}