org.cqframework.cql.elm.execution.Library Java Examples

The following examples show how to use org.cqframework.cql.elm.execution.Library. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestLibraryLoader.java    From cql_engine with Apache License 2.0 6 votes vote down vote up
private Library resolveLibrary(VersionedIdentifier libraryIdentifier) {
    if (libraryIdentifier == null) {
        throw new IllegalArgumentException("Library identifier is null.");
    }

    if (libraryIdentifier.getId() == null) {
        throw new IllegalArgumentException("Library identifier id is null.");
    }

    Library library = libraries.get(libraryIdentifier.getId());
    if (library != null && libraryIdentifier.getVersion() != null && !libraryIdentifier.getVersion().equals(library.getIdentifier().getVersion())) {
        throw new IllegalArgumentException(String.format("Could not load library %s, version %s because version %s is already loaded.",
                libraryIdentifier.getId(), libraryIdentifier.getVersion(), library.getIdentifier().getVersion()));
    }
    else {
        library = loadLibrary(libraryIdentifier);
        libraries.put(libraryIdentifier.getId(), library);
    }

    return library;
}
 
Example #2
Source File: TestLibraryLoader.java    From cql_engine with Apache License 2.0 6 votes vote down vote up
private Library resolveLibrary(VersionedIdentifier libraryIdentifier) {
    if (libraryIdentifier == null) {
        throw new IllegalArgumentException("Library identifier is null.");
    }

    if (libraryIdentifier.getId() == null) {
        throw new IllegalArgumentException("Library identifier id is null.");
    }

    Library library = libraries.get(libraryIdentifier.getId());
    if (library != null && libraryIdentifier.getVersion() != null && !libraryIdentifier.getVersion().equals(library.getIdentifier().getVersion())) {
        throw new IllegalArgumentException(String.format("Could not load library %s, version %s because version %s is already loaded.",
                libraryIdentifier.getId(), libraryIdentifier.getVersion(), library.getIdentifier().getVersion()));
    }
    else {
        library = loadLibrary(libraryIdentifier);
        libraries.put(libraryIdentifier.getId(), library);
    }

    return library;
}
 
Example #3
Source File: CqlTestSuite.java    From cql_engine with Apache License 2.0 6 votes vote down vote up
@Test
public void testErrorSuite() throws IOException, JAXBException, UcumException {
    Library library = translate("portable/CqlErrorTestSuite.cql");
    Context context = new Context(library, new DateTime(TemporalHelper.getDefaultOffset(), 2018, 1, 1, 7, 0, 0, 0));
    if (library.getStatements() != null) {
        for (ExpressionDef expression : library.getStatements().getDef()) {
            try {
                expression.evaluate(context);
                logger.error("Test " + expression.getName() + " should result in an error");
                Assert.fail();
            }
            catch (Exception e) {
                // pass
                logger.info(expression.getName() + " TEST PASSED");
            }
        }
    }
}
 
Example #4
Source File: LibraryHelper.java    From cqf-ruler with Apache License 2.0 6 votes vote down vote up
public static Library resolveLibraryById(String libraryId, org.opencds.cqf.cql.execution.LibraryLoader libraryLoader, LibraryResolutionProvider<org.hl7.fhir.r4.model.Library> libraryResourceProvider)
{
    // Library library = null;

    org.hl7.fhir.r4.model.Library fhirLibrary = libraryResourceProvider.resolveLibraryById(libraryId);
    return libraryLoader.load(new VersionedIdentifier().withId(fhirLibrary.getName()).withVersion(fhirLibrary.getVersion()));

    // for (Library l : libraryLoader.getLibraries()) {
    //     VersionedIdentifier vid = l.getIdentifier();
    //     if (vid.getId().equals(fhirLibrary.getName()) && LibraryResourceHelper.compareVersions(fhirLibrary.getVersion(), vid.getVersion()) == 0) {
    //         library = l;
    //         break;
    //     }
    // }

    // if (library == null) {

    // }

    // return library;
}
 
Example #5
Source File: DataRequirementsProvider.java    From cqf-ruler with Apache License 2.0 6 votes vote down vote up
public void formatCql(org.hl7.fhir.r4.model.Library library) {
    for (Attachment att : library.getContent()) {
        if (att.getContentType().equals("text/cql")) {
            try {
                FormatResult fr = CqlFormatterVisitor.getFormattedOutput(new ByteArrayInputStream(
                        Base64.getDecoder().decode(att.getDataElement().getValueAsString())));

                // Only update the content if it's valid CQL.
                if (fr.getErrors().size() == 0) {
                    Base64BinaryType bt = new Base64BinaryType(
                            new String(Base64.getEncoder().encode(fr.getOutput().getBytes())));
                    att.setDataElement(bt);
                }
            } catch (IOException e) {
                // Intentionally empty for now
            }
        }
    }
}
 
Example #6
Source File: DataRequirementsProvider.java    From cqf-ruler with Apache License 2.0 6 votes vote down vote up
public CqlTranslator getTranslator(org.hl7.fhir.r4.model.Library library, LibraryManager libraryManager, ModelManager modelManager) {
    Attachment cql = null;
    for (Attachment a : library.getContent()) {
        if (a.getContentType().equals("text/cql")) {
            cql = a;
            break;
        }
    }

    if (cql == null) {
        return null;
    }

    return TranslatorHelper.getTranslator(
            new ByteArrayInputStream(Base64.getDecoder().decode(cql.getDataElement().getValueAsString())),
            libraryManager, modelManager);
}
 
Example #7
Source File: CqlEngine.java    From cql_engine with Apache License 2.0 6 votes vote down vote up
private LibraryResult evaluateLibrary(Context context, Library library, Set<String> expressions) {
    LibraryResult result = new LibraryResult();

    for (String expression : expressions) {
        ExpressionDef def = context.resolveExpressionRef(expression);

        // TODO: We should probably move this validation further up the chain.
        // For example, we should tell the user that they've tried to evaluate a function def through incorrect
        // CQL or input parameters. And the code that gather the list of expressions to evaluate together should
        // not include function refs.
        if (def instanceof FunctionDef) {
            continue;
        }
        
        context.enterContext(def.getContext());
        Object object = def.evaluate(context);
        result.expressionResults.put(expression, object);
    }

    return result;
}
 
Example #8
Source File: CqlEngine.java    From cql_engine with Apache License 2.0 6 votes vote down vote up
private Library loadLibrary(VersionedIdentifier libraryIdentifier) {
    Library library = this.libraryLoader.load(libraryIdentifier);

    if (library == null) {
        throw new IllegalArgumentException(String.format("Unable to load library %s", 
            libraryIdentifier.getId() + libraryIdentifier.getVersion() != null ? "-" + libraryIdentifier.getVersion() : ""));
    }

    // TODO: Removed this validation pending more intelligent handling at the service layer
    // For example, providing a mock or dummy data provider in the event there's no data store
    //this.validateDataRequirements(library);
    this.validateTerminologyRequirements(library);

    // TODO: Optimization ?
    // TODO: Validate Expressions as well?

    return library;
}
 
Example #9
Source File: CqlEngine.java    From cql_engine with Apache License 2.0 6 votes vote down vote up
private void validateDataRequirements(Library library) {
    if (library.getUsings() != null && library.getUsings().getDef() != null && !library.getUsings().getDef().isEmpty())
    {
        for (UsingDef using : library.getUsings().getDef()) {
            // Skip system using since the context automatically registers that.
            if (using.getUri().equals("urn:hl7-org:elm-types:r1"))
            {
                continue;
            }

            if (this.dataProviders == null || !this.dataProviders.containsKey(using.getUri())) {
                throw new IllegalArgumentException(String.format("Library %1$s is using %2$s and no data provider is registered for uri %2$s.",
                this.getLibraryDescription(library.getIdentifier()),
                using.getUri()));
            }
        }
    }
}
 
Example #10
Source File: CqlEngineTests.java    From cql_engine with Apache License 2.0 6 votes vote down vote up
@Test
public void test_twoExpressions_oneRequested_oneReturned() throws IOException, JAXBException {
    Library library = this.toLibrary("library Test version '1.0.0'\ndefine X:\n5+5\ndefine Y: 2 + 2");

    LibraryLoader libraryLoader = new InMemoryLibraryLoader(Collections.singleton(library));

    CqlEngine engine = new CqlEngine(libraryLoader);

    EvaluationResult result = engine.evaluate(this.toExpressionMap(library.getIdentifier(), "Y"));

    assertNotNull(result);
    assertEquals(1, result.libraryResults.size());
    assertEquals(1, result.forLibrary(library.getIdentifier()).expressionResults.size());
    
    Object expResult = result.forLibrary(library.getIdentifier()).forExpression("Y");
    assertThat(expResult, is(4));
}
 
Example #11
Source File: CqlEngineTests.java    From cql_engine with Apache License 2.0 6 votes vote down vote up
@Test
public void test_twoExpressions_byLibrary_allReturned() throws IOException, JAXBException {
    Library library = this.toLibrary("library Test version '1.0.0'\ndefine X:\n5+5\ndefine Y: 2 + 2");

    LibraryLoader libraryLoader = new InMemoryLibraryLoader(Collections.singleton(library));

    CqlEngine engine = new CqlEngine(libraryLoader);

    EvaluationResult result = engine.evaluate(library.getIdentifier());

    assertNotNull(result);
    assertEquals(1, result.libraryResults.size());
    assertEquals(2, result.forLibrary(library.getIdentifier()).expressionResults.size());

    Object expResult = result.forLibrary(library.getIdentifier()).forExpression("X");
    assertThat(expResult, is(10));

    expResult = result.forLibrary(library.getIdentifier()).forExpression("Y");
    assertThat(expResult, is(4));
}
 
Example #12
Source File: DataRequirementsProvider.java    From cqf-ruler with Apache License 2.0 6 votes vote down vote up
public CqlTranslator getTranslator(org.hl7.fhir.dstu3.model.Library library, LibraryManager libraryManager, ModelManager modelManager) {
    Attachment cql = null;
    for (Attachment a : library.getContent()) {
        if (a.getContentType().equals("text/cql")) {
            cql = a;
            break;
        }
    }

    if (cql == null) {
        return null;
    }

    CqlTranslator translator = TranslatorHelper.getTranslator(
            new ByteArrayInputStream(Base64.getDecoder().decode(cql.getDataElement().getValueAsString())),
            libraryManager, modelManager);

    return translator;
}
 
Example #13
Source File: LibraryLoader.java    From cqf-ruler with Apache License 2.0 6 votes vote down vote up
private Library resolveLibrary(VersionedIdentifier libraryIdentifier) {
    if (libraryIdentifier == null) {
        throw new IllegalArgumentException("Library identifier is null.");
    }

    if (libraryIdentifier.getId() == null) {
        throw new IllegalArgumentException("Library identifier id is null.");
    }

    String mangledId = this.mangleIdentifer(libraryIdentifier);

    Library library = libraries.get(mangledId);
    if (library == null) {
        library = loadLibrary(libraryIdentifier);
        libraries.put(mangledId, library);
    }

    return library;
}
 
Example #14
Source File: CqlEngineTests.java    From cql_engine with Apache License 2.0 5 votes vote down vote up
private String toXml(org.hl7.elm.r1.Library library) {
    try {
        return convertToXml(library);
    }
    catch (JAXBException e) {
        throw new IllegalArgumentException("Could not convert library to XML.", e);
    }
}
 
Example #15
Source File: LibraryHelper.java    From cqf-ruler with Apache License 2.0 5 votes vote down vote up
public static LibraryLoader createLibraryLoader(LibraryResolutionProvider<org.hl7.fhir.r4.model.Library> provider) {
    ModelManager modelManager = new ModelManager();
    LibraryManager libraryManager = new LibraryManager(modelManager);
    libraryManager.getLibrarySourceLoader().clearProviders();
    
    libraryManager.getLibrarySourceLoader().registerProvider(
        new LibrarySourceProvider<org.hl7.fhir.r4.model.Library, org.hl7.fhir.r4.model.Attachment>(
            provider, 
            x -> x.getContent(),
            x -> x.getContentType(),
            x -> x.getData()));

    return new LibraryLoader(libraryManager, modelManager);
}
 
Example #16
Source File: CqlEngine.java    From cql_engine with Apache License 2.0 5 votes vote down vote up
private Map<VersionedIdentifier, Set<String>> getExpressionMap(Library library) {
    Map<VersionedIdentifier, Set<String>> map = new HashMap<>();
    Set<String> expressionNames = new HashSet<>();
    if (library.getStatements() != null && library.getStatements().getDef() != null) {
        for (ExpressionDef ed : library.getStatements().getDef()) {
            expressionNames.add(ed.getName());
        }
    }

    map.put(library.getIdentifier(), expressionNames);

    return map;
}
 
Example #17
Source File: CqlEngine.java    From cql_engine with Apache License 2.0 5 votes vote down vote up
private void validateTerminologyRequirements(Library library) {
    if ((library.getCodeSystems() != null && library.getCodeSystems().getDef() != null && !library.getCodeSystems().getDef().isEmpty()) || 
        (library.getCodes() != null  && library.getCodes().getDef() != null && !library.getCodes().getDef().isEmpty()) || 
        (library.getValueSets() != null  && library.getValueSets().getDef() != null && !library.getValueSets().getDef().isEmpty())) {
        if (this.terminologyProvider == null) {
            throw new IllegalArgumentException(String.format("Library %s has terminology requirements and no terminology provider is registered.",
                this.getLibraryDescription(library.getIdentifier())));
        }
    }
}
 
Example #18
Source File: DataRequirementsProvider.java    From cqf-ruler with Apache License 2.0 5 votes vote down vote up
public void ensureDataRequirements(org.hl7.fhir.dstu3.model.Library library, CqlTranslator translator) {
    library.getDataRequirement().clear();

    List<DataRequirement> reqs = new ArrayList<DataRequirement>();

    for (org.hl7.elm.r1.Retrieve retrieve : translator.toRetrieves()) {
        DataRequirement dataReq = new DataRequirement();
        dataReq.setType(retrieve.getDataType().getLocalPart());
        if (retrieve.getCodeProperty() != null) {
            DataRequirement.DataRequirementCodeFilterComponent codeFilter = new DataRequirement.DataRequirementCodeFilterComponent();
            codeFilter.setPath(retrieve.getCodeProperty());
            if (retrieve.getCodes() instanceof ValueSetRef) {
                Type valueSetName = new StringType(
                        getValueSetId(((ValueSetRef) retrieve.getCodes()).getName(), translator));
                codeFilter.setValueSet(valueSetName);
            }
            dataReq.setCodeFilter(Collections.singletonList(codeFilter));
        }
        // TODO - Date filters - we want to populate this with a $data-requirements
        // request as there isn't a good way through elm analysis
        reqs.add(dataReq);
    }


    // 
    // org.hl7.elm.r1.Library elm = translator.toELM();
    // Codes codes = elm.getCodes();
    // for (CodeDef cd : codes.getDef()) {
    //     cd.
    // }

    library.setDataRequirement(reqs);     
}
 
Example #19
Source File: DataRequirementsProvider.java    From cqf-ruler with Apache License 2.0 5 votes vote down vote up
public String getValueSetId(String valueSetName, CqlTranslator translator) {
    org.hl7.elm.r1.Library.ValueSets valueSets = translator.toELM().getValueSets();
    if (valueSets != null) {
        for (org.hl7.elm.r1.ValueSetDef def : valueSets.getDef()) {
            if (def.getName().equals(valueSetName)) {
                return def.getId();
            }
        }
    }

    return valueSetName;
}
 
Example #20
Source File: DataRequirementsProvider.java    From cqf-ruler with Apache License 2.0 5 votes vote down vote up
private Map<VersionedIdentifier, Pair<Library, org.hl7.fhir.dstu3.model.Library>>  createLibraryMap(Measure measure, LibraryResolutionProvider<org.hl7.fhir.dstu3.model.Library> libraryResourceProvider) {
    LibraryLoader libraryLoader = LibraryHelper.createLibraryLoader(libraryResourceProvider);
    List<Library> libraries = LibraryHelper.loadLibraries(measure, libraryLoader, libraryResourceProvider);
    Map<VersionedIdentifier, Pair<Library, org.hl7.fhir.dstu3.model.Library>> libraryMap = new HashMap<>();

    for (Library library : libraries) {
        VersionedIdentifier vi = library.getIdentifier();
        org.hl7.fhir.dstu3.model.Library libraryResource = libraryResourceProvider.resolveLibraryByName(vi.getId(), vi.getVersion());
        libraryMap.put(vi, Pair.of(library, libraryResource));
    }

    return libraryMap;
}
 
Example #21
Source File: CqlEngineTests.java    From cql_engine with Apache License 2.0 5 votes vote down vote up
public String convertToXml(org.hl7.elm.r1.Library library) throws JAXBException {
    Marshaller marshaller = getJaxbContext().createMarshaller();
    marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
    StringWriter writer = new StringWriter();
    marshaller.marshal(new ObjectFactory().createLibrary(library), writer);
    return writer.getBuffer().toString();
}
 
Example #22
Source File: DataRequirementsProvider.java    From cqf-ruler with Apache License 2.0 5 votes vote down vote up
public String getValueSetId(String valueSetName, CqlTranslator translator) {
    org.hl7.elm.r1.Library.ValueSets valueSets = translator.toELM().getValueSets();
    if (valueSets != null) {
        for (org.hl7.elm.r1.ValueSetDef def : valueSets.getDef()) {
            if (def.getName().equals(valueSetName)) {
                return def.getId();
            }
        }
    }

    return valueSetName;
}
 
Example #23
Source File: LibraryHelper.java    From cqf-ruler with Apache License 2.0 5 votes vote down vote up
public static Library resolvePrimaryLibrary(PlanDefinition planDefinition, org.opencds.cqf.cql.execution.LibraryLoader libraryLoader, LibraryResolutionProvider<org.hl7.fhir.dstu3.model.Library> libraryResourceProvider) {
    String id = planDefinition.getLibraryFirstRep().getReferenceElement().getIdPart();

    Library library = resolveLibraryById(id, libraryLoader, libraryResourceProvider);

    if (library == null) {
        throw new IllegalArgumentException(String.format("Could not resolve primary library for PlanDefinition/%s", planDefinition.getIdElement().getIdPart()));
    }

    return library;
}
 
Example #24
Source File: LibraryHelper.java    From cqf-ruler with Apache License 2.0 5 votes vote down vote up
public static Library resolvePrimaryLibrary(Measure measure, org.opencds.cqf.cql.execution.LibraryLoader libraryLoader, LibraryResolutionProvider<org.hl7.fhir.dstu3.model.Library> libraryResourceProvider)
{
    // default is the first library reference
    String id = measure.getLibraryFirstRep().getReferenceElement().getIdPart();

    Library library = resolveLibraryById(id, libraryLoader, libraryResourceProvider);

    if (library == null) {
        throw new IllegalArgumentException(String
                .format("Could not resolve primary library for Measure/%s.", measure.getIdElement().getIdPart()));
    }

    return library;
}
 
Example #25
Source File: CqlEngineTests.java    From cql_engine with Apache License 2.0 5 votes vote down vote up
@Test
public void test_twoLibraries_expressionsForEach() throws IOException, JAXBException {

    Map<org.hl7.elm.r1.VersionedIdentifier, String> libraries = new HashMap<>();
    libraries.put(this.toElmIdentifier("Common", "1.0.0"), 
        "library Common version '1.0.0'\ndefine Z:\n5+5\n");
    libraries.put(toElmIdentifier("Test", "1.0.0"),
        "library Test version '1.0.0'\ninclude Common version '1.0.0' named \"Common\"\ndefine X:\n5+5\ndefine Y: 2 + 2\ndefine W: \"Common\".Z + 5");


    LibraryManager libraryManager = this.toLibraryManager(libraries);
    List<CqlTranslatorException> errors = new ArrayList<>();
    List<Library> executableLibraries = new ArrayList<>();
    for (org.hl7.elm.r1.VersionedIdentifier id : libraries.keySet()) {
        TranslatedLibrary translated = libraryManager.resolveLibrary(id, ErrorSeverity.Error, SignatureLevel.All, new CqlTranslator.Options[0], errors);
        String xml = this.convertToXml(translated.getLibrary());
        executableLibraries.add(this.readXml(xml));
    }

    Map<VersionedIdentifier, Set<String>> expressions = this.mergeExpressionMaps(
        this.toExpressionMap(toExecutionIdentifier("Common", "1.0.0"), "Z"),
        this.toExpressionMap(toExecutionIdentifier("Test", "1.0.0"), "X", "Y", "W")
    );

    LibraryLoader libraryLoader = new InMemoryLibraryLoader(executableLibraries);

    CqlEngine engine = new CqlEngine(libraryLoader);

    EvaluationResult result = engine.evaluate(expressions);

    assertNotNull(result);
    assertEquals(2, result.libraryResults.size());
    assertEquals(1, result.forLibrary(executableLibraries.get(0).getIdentifier()).expressionResults.size());
    assertThat(result.forLibrary(executableLibraries.get(0).getIdentifier()).forExpression("Z"), is(10));
    
    assertEquals(3, result.forLibrary(executableLibraries.get(1).getIdentifier()).expressionResults.size());
    assertThat(result.forLibrary(executableLibraries.get(1).getIdentifier()).forExpression("X"), is(10));
    assertThat(result.forLibrary(executableLibraries.get(1).getIdentifier()).forExpression("Y"), is(4));
    assertThat(result.forLibrary(executableLibraries.get(1).getIdentifier()).forExpression("W"), is(15));
}
 
Example #26
Source File: LibraryHelper.java    From cqf-ruler with Apache License 2.0 5 votes vote down vote up
public static LibraryLoader createLibraryLoader(LibraryResolutionProvider<org.hl7.fhir.dstu3.model.Library> provider) {
    ModelManager modelManager = new ModelManager();
    LibraryManager libraryManager = new LibraryManager(modelManager);
    libraryManager.getLibrarySourceLoader().clearProviders();
    
    libraryManager.getLibrarySourceLoader().registerProvider(
        new LibrarySourceProvider<org.hl7.fhir.dstu3.model.Library, org.hl7.fhir.dstu3.model.Attachment>(
            provider, 
            x -> x.getContent(),
            x -> x.getContentType(),
            x -> x.getData()));

    return new LibraryLoader(libraryManager, modelManager);
}
 
Example #27
Source File: InMemoryLibraryLoader.java    From cql_engine with Apache License 2.0 5 votes vote down vote up
public Library load(VersionedIdentifier libraryIdentifier) {
    Library library = this.libraries.get(libraryIdentifier);
    if (library == null) {
        throw new IllegalArgumentException(String.format("Unable to load library %s", libraryIdentifier.getId()));
    }

    return library;
}
 
Example #28
Source File: CqlTestSuite.java    From cql_engine with Apache License 2.0 5 votes vote down vote up
@Test
public void testMainSuite() throws IOException, JAXBException, UcumException {
    Library library = translate("portable/CqlTestSuite.cql");
    Context context = new Context(library, new DateTime(TemporalHelper.getDefaultOffset(), 2018, 1, 1, 7, 0, 0, 0));
    if (library.getStatements() != null) {
        for (ExpressionDef expression : library.getStatements().getDef()) {
            if (expression instanceof FunctionDef) {
                continue;
            }
            if (expression.getName().startsWith("test")) {
                logger.info((String) expression.evaluate(context));
            }
        }
    }
}
 
Example #29
Source File: CqlTestSuite.java    From cql_engine with Apache License 2.0 5 votes vote down vote up
private Library translate(String file)  throws UcumException, JAXBException, IOException {
    ModelManager modelManager = new ModelManager();
    LibraryManager libraryManager = new LibraryManager(modelManager);
    UcumService ucumService = new UcumEssenceService(UcumEssenceService.class.getResourceAsStream("/ucum-essence.xml"));

    File cqlFile = new File(URLDecoder.decode(this.getClass().getResource(file).getFile(), "UTF-8"));

    CqlTranslator translator = CqlTranslator.fromFile(cqlFile, modelManager, libraryManager, ucumService);

    if (translator.getErrors().size() > 0) {
        System.err.println("Translation failed due to errors:");
        ArrayList<String> errors = new ArrayList<>();
        for (CqlTranslatorException error : translator.getErrors()) {
            TrackBack tb = error.getLocator();
            String lines = tb == null ? "[n/a]" : String.format("[%d:%d, %d:%d]",
                    tb.getStartLine(), tb.getStartChar(), tb.getEndLine(), tb.getEndChar());
            System.err.printf("%s %s%n", lines, error.getMessage());
            errors.add(lines + error.getMessage());
        }
        throw new IllegalArgumentException(errors.toString());
    }

    assertThat(translator.getErrors().size(), is(0));

    String xml = translator.toXml();

    return CqlLibraryReader.read(new StringReader(xml));
}
 
Example #30
Source File: ElmTests.java    From cql_engine with Apache License 2.0 5 votes vote down vote up
@Test
public void TestLibraryLoad() {
    try {
        Library library = CqlLibraryReader.read(ElmTests.class.getResourceAsStream("CMS53Draft/PrimaryPCIReceivedWithin90MinutesofHospitalArrival-7.0.001.xml"));
    } catch (IOException | JAXBException e) {
        throw new IllegalArgumentException("Error reading ELM: " + e.getMessage());
    }
}