UNPKG

@phema/cql-execution

Version:

An execution framework for the Clinical Quality Language (CQL)

40 lines (32 loc) 753 B
"use strict"; var E = require('./expressions'); var _require = require('../util/util'), typeIsArray = _require.typeIsArray; function build(json) { if (json == null) { return json; } if (typeIsArray(json)) { return json.map(function (child) { return build(child); }); } if (json.type === 'FunctionRef') { return new E.FunctionRef(json); } else if (json.type === 'Literal') { return E.Literal.from(json); } else if (functionExists(json.type)) { return constructByName(json.type, json); } else { return null; } } function functionExists(name) { return typeof E[name] === 'function'; } function constructByName(name, json) { return new E[name](json); } module.exports = { build: build };