use of org.cqframework.cql.cql2elm.model.CompiledLibrary in project clinical_quality_language by cqframework.
the class LibraryManager method tryCompiledLibraryElm.
private CompiledLibrary tryCompiledLibraryElm(VersionedIdentifier libraryIdentifier, CqlTranslatorOptions options) {
CompiledLibrary result = null;
InputStream librarySource = null;
if (librarySourceLoader instanceof LibrarySourceLoaderExt) {
LibrarySourceLoaderExt sourceLoaderExt = (LibrarySourceLoaderExt) librarySourceLoader;
Set<LibraryContentType> supportedTypes = sourceLoaderExt.getSupportedContentTypes();
for (LibraryContentType type : supportedTypes) {
if (type != LibraryContentType.CQL) {
try {
librarySource = sourceLoaderExt.getLibrarySource(libraryIdentifier, type);
if (librarySource == null) {
continue;
}
result = generateCompiledLibraryFromElm(libraryIdentifier, librarySource, type, options);
if (result != null) {
break;
}
} catch (Exception e) {
continue;
}
}
}
}
return result;
}
use of org.cqframework.cql.cql2elm.model.CompiledLibrary in project clinical_quality_language by cqframework.
the class ElmRequirementsContext method reportExpressionRef.
public ElmRequirement reportExpressionRef(ExpressionRef expressionRef) {
CompiledLibrary targetLibrary = prepareLibraryVisit(getCurrentLibraryIdentifier(), expressionRef.getLibraryName());
try {
ExpressionDef ed = targetLibrary.resolveExpressionRef(expressionRef.getName());
if (!visited.contains(ed)) {
visitor.visitElement(ed, this);
}
ElmRequirement inferredRequirements = getInferredRequirements(ed);
// Report data requirements for this expression def to the current context (that are not already part of the inferred requirements
ElmRequirements reportedRequirements = getReportedRequirements(ed);
if (reportedRequirements != null) {
reportRequirements(reportedRequirements, inferredRequirements);
}
// Return the inferred requirements for the expression def
return inferredRequirements;
} finally {
unprepareLibraryVisit(expressionRef.getLibraryName());
}
}
use of org.cqframework.cql.cql2elm.model.CompiledLibrary in project clinical_quality_language by cqframework.
the class BaseTest method testRetrieveWithConcept.
@Test
public void testRetrieveWithConcept() throws IOException {
CqlTranslator translator = TestUtils.runSemanticTest("fhir/dstu2/TestRetrieveWithConcept.cql", 0);
CompiledLibrary library = translator.getTranslatedLibrary();
ExpressionDef expressionDef = library.resolveExpressionRef("Test Tobacco Smoking Status");
assertThat(expressionDef.getExpression(), instanceOf(Retrieve.class));
Retrieve retrieve = (Retrieve) expressionDef.getExpression();
assertThat(retrieve.getCodes(), instanceOf(ToList.class));
ToList toList = (ToList) retrieve.getCodes();
assertThat(toList.getOperand(), instanceOf(CodeRef.class));
}
use of org.cqframework.cql.cql2elm.model.CompiledLibrary in project clinical_quality_language by cqframework.
the class BaseTest method testEqualityWithConversions.
@Test
public void testEqualityWithConversions() throws IOException {
CompiledLibrary library = visitFileLibrary("fhir/r4/EqualityWithConversions.cql");
ExpressionDef getGender = library.resolveExpressionRef("GetGender");
assertThat(getGender.getExpression(), instanceOf(Equal.class));
Equal equal = (Equal) getGender.getExpression();
assertThat(equal.getOperand().get(0), instanceOf(FunctionRef.class));
FunctionRef functionRef = (FunctionRef) equal.getOperand().get(0);
assertThat(functionRef.getName(), is("ToString"));
assertThat(functionRef.getLibraryName(), is("FHIRHelpers"));
}
use of org.cqframework.cql.cql2elm.model.CompiledLibrary in project clinical_quality_language by cqframework.
the class BaseTest method testEqualityWithConversions.
@Test
public void testEqualityWithConversions() throws IOException {
CompiledLibrary library = visitFileLibrary("fhir/r401/EqualityWithConversions.cql");
ExpressionDef getGender = library.resolveExpressionRef("GetGender");
assertThat(getGender.getExpression(), instanceOf(Equal.class));
Equal equal = (Equal) getGender.getExpression();
assertThat(equal.getOperand().get(0), instanceOf(FunctionRef.class));
FunctionRef functionRef = (FunctionRef) equal.getOperand().get(0);
assertThat(functionRef.getName(), is("ToString"));
assertThat(functionRef.getLibraryName(), is("FHIRHelpers"));
}
Aggregations