All files / src/elm library.coffee

100% Statements 27/27
90% Branches 18/20
100% Functions 7/7
100% Lines 27/27

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50    1457x 1457x 2914x 1457x 1457x 2914x 232x 1457x 2914x 73x 1457x 2914x 115x 1457x 2914x 137x 1457x 2914x 124x 1457x 2914x 27239x 1457x 2914x 33x                                         1x 1x  
module.exports.Library = class Library
  constructor: (json, libraryManager) ->
    @source = json
    @usings = []
    for u in json.library.usings?.def ? []
      @usings.push {"name" : u.localIdentifier, "version" : u.version} if u.localIdentifier != "System"
    @parameters = {}
    for param in json.library.parameters?.def ? []
      @parameters[param.name] = new ParameterDef(param)
    @codesystems = {}
    for codesystem in json.library.codeSystems?.def ? []
      @codesystems[codesystem.name] = new CodeSystemDef(codesystem)
    @valuesets = {}
    for valueset in json.library.valueSets?.def ? []
      @valuesets[valueset.name] = new ValueSetDef(valueset)
    @codes = {}
    for code in json.library.codes?.def ? []
      @codes[code.name] = new CodeDef(code)
    @concepts = {}
    for concept in json.library.concepts?.def ? []
      @concepts[concept.name] = new ConceptDef(concept)
    @expressions = {}
    for expr in json.library.statements?.def ? []
      @expressions[expr.name] = if expr.type == "FunctionDef"  then new FunctionDef(expr) else new ExpressionDef(expr)
    @includes = {}
    for expr in json.library.includes?.def ? []
      if libraryManager then @includes[expr.localIdentifier] =  libraryManager.resolve(expr.path,expr.version)
 
  get: (identifier) ->
    @expressions[identifier] || @includes[identifier]
 
  getValueSet: (identifier) ->
    @valuesets[identifier]
 
  getCodeSystem: (identifier) ->
    @codesystems[identifier]
 
  getCode: (identifier) ->
    @codes[identifier]
 
  getConcept: (identifier) ->
    @concepts[identifier]
 
  getParameter: (name) ->
    @parameters[name]
# These requires are at the end of the file because having them first in the
# file creates errors due to the order that the libraries are loaded.
{ ExpressionDef, FunctionDef, ParameterDef, ValueSetDef, CodeSystemDef, CodeDef, ConceptDef } = require './expressions'
{ Results } = require '../runtime/results'