use of org.hl7.elm.r1.ExpressionDef in project clinical_quality_language by cqframework.
the class BaseTest method testQICore.
@Test
public void testQICore() throws IOException {
CqlTranslator translator = TestUtils.runSemanticTest("qicore/v410/TestQICore.cql", 0);
Library library = translator.toELM();
Map<String, ExpressionDef> defs = new HashMap<>();
if (library.getStatements() != null) {
for (ExpressionDef def : library.getStatements().getDef()) {
defs.put(def.getName(), def);
}
}
ExpressionDef def = defs.get("TestAdverseEvent");
assertThat(def.getExpression(), instanceOf(Retrieve.class));
Retrieve retrieve = (Retrieve) def.getExpression();
assertThat(retrieve.getTemplateId(), is("http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-adverseevent"));
}
use of org.hl7.elm.r1.ExpressionDef in project clinical_quality_language by cqframework.
the class BaseTest method testEXM124.
@Test
public void testEXM124() throws IOException {
CqlTranslator translator = TestUtils.runSemanticTest("qicore/v410/EXM124_QICore4-8.2.000.cql", 0);
Library library = translator.toELM();
Map<String, ExpressionDef> defs = new HashMap<>();
if (library.getStatements() != null) {
for (ExpressionDef def : library.getStatements().getDef()) {
defs.put(def.getName(), def);
}
}
ExpressionDef def = defs.get("Initial Population");
}
use of org.hl7.elm.r1.ExpressionDef in project clinical_quality_language by cqframework.
the class CqlComparisonOperatorsTest method setup.
@BeforeTest
public void setup() throws IOException {
ModelManager modelManager = new ModelManager();
CqlTranslator translator = CqlTranslator.fromStream(CqlComparisonOperatorsTest.class.getResourceAsStream("../OperatorTests/CqlComparisonOperators.cql"), modelManager, new LibraryManager(modelManager));
assertThat(translator.getErrors().size(), is(0));
Library library = translator.toELM();
defs = new HashMap<>();
if (library.getStatements() != null) {
for (ExpressionDef def : library.getStatements().getDef()) {
defs.put(def.getName(), def);
}
}
}
use of org.hl7.elm.r1.ExpressionDef in project clinical_quality_language by cqframework.
the class NullologicalOperatorsTest method testCoalesce.
@Test
public void testCoalesce() {
ExpressionDef def = defs.get("CoalesceList");
assertThat(def, hasTypeAndResult(Coalesce.class, "System.Integer"));
Coalesce coalesce = (Coalesce) def.getExpression();
assertThat(coalesce.getOperand(), hasSize(1));
assertThat(coalesce.getOperand().get(0), instanceOf(org.hl7.elm.r1.List.class));
org.hl7.elm.r1.List args = (org.hl7.elm.r1.List) coalesce.getOperand().get(0);
assertThat(args.getElement(), hasSize(5));
int i = 1;
for (Expression arg : args.getElement()) {
assertThat(arg, literalFor(i++));
}
def = defs.get("CoalesceTwoArgument");
assertThat(def, hasTypeAndResult(Coalesce.class, "System.Integer"));
assertIntegerArgs((Coalesce) def.getExpression(), 1, 2);
def = defs.get("CoalesceThreeArgument");
assertThat(def, hasTypeAndResult(Coalesce.class, "System.Integer"));
assertIntegerArgs((Coalesce) def.getExpression(), 1, 2, 3);
def = defs.get("CoalesceFourArgument");
assertThat(def, hasTypeAndResult(Coalesce.class, "System.Integer"));
assertIntegerArgs((Coalesce) def.getExpression(), 1, 2, 3, 4);
def = defs.get("CoalesceFiveArgument");
assertThat(def, hasTypeAndResult(Coalesce.class, "System.Integer"));
assertIntegerArgs((Coalesce) def.getExpression(), 1, 2, 3, 4, 5);
}
use of org.hl7.elm.r1.ExpressionDef in project clinical_quality_language by cqframework.
the class DataRequirementsProcessor method extractParameters.
private List<ParameterDefinition> extractParameters(ElmRequirementsContext context, ElmRequirements requirements, VersionedIdentifier libraryIdentifier, Iterable<ExpressionDef> expressionDefs) {
List<ParameterDefinition> result = new ArrayList<>();
// TODO: Support library qualified parameters
// Until then, name clashes should result in a warning
Map<String, ParameterDefinition> pds = new HashMap<String, ParameterDefinition>();
for (ElmRequirement def : requirements.getParameterDefs()) {
ParameterDefinition pd = toParameterDefinition(def.getLibraryIdentifier(), (ParameterDef) def.getElement());
if (pds.containsKey(pd.getName())) {
ParameterDefinition existingPd = pds.get(pd.getName());
if (!isEquivalentDefinition(existingPd, pd)) {
// Issue a warning that the parameter has a duplicate name but an incompatible type
validationMessages.add(new ValidationMessage(ValidationMessage.Source.Publisher, ValidationMessage.IssueType.NOTSUPPORTED, "CQL Library Packaging", String.format("Parameter declaration %s.%s is already defined in a different library with a different type. Parameter binding may result in errors during evaluation.", def.getLibraryIdentifier().getId(), pd.getName()), ValidationMessage.IssueSeverity.WARNING));
}
} else {
pds.put(pd.getName(), pd);
result.add(pd);
}
}
for (ExpressionDef def : expressionDefs) {
if (def != null && !(def instanceof FunctionDef) && (def.getAccessLevel() == null || def.getAccessLevel() == AccessModifier.PUBLIC)) {
result.add(toOutputParameterDefinition(libraryIdentifier, def));
}
}
return result;
}
Aggregations