use of org.hl7.elm.r1.ExpressionDef in project clinical_quality_language by cqframework.
the class BaseTest method testEXM165.
@Test
public void testEXM165() throws IOException {
CqlTranslator translator = TestUtils.runSemanticTest("qicore/v410/EXM165_QICore4-8.5.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 BaseTest method testFHIRHelpers.
@Test
public void testFHIRHelpers() throws IOException {
CqlTranslator translator = TestUtils.runSemanticTest("fhir/r401/TestFHIRHelpers.cql", 0);
CompiledLibrary translatedLibrary = translator.getTranslatedLibrary();
assertResultType(translatedLibrary, "TestExtensions", "FHIR", "Extension");
assertResultType(translatedLibrary, "TestElementExtensions", "FHIR", "Extension");
assertResultType(translatedLibrary, "TestModifierExtensions", "FHIR", "Extension");
assertResultType(translatedLibrary, "TestElementModifierExtensions", "FHIR", "Extension");
ExpressionDef ed = translatedLibrary.resolveExpressionRef("TestChoiceConverts");
DataType resultType = ed.getExpression().getResultType();
assertThat(resultType, instanceOf(ChoiceType.class));
assertThat(resultType.toString(), equalTo("choice<System.String,System.Boolean,System.Date,System.DateTime,System.Decimal,System.Integer,System.Time,System.Quantity,System.Concept,System.Code,interval<System.Quantity>,interval<System.DateTime>,System.Ratio,FHIR.Address,FHIR.Annotation,FHIR.Attachment,FHIR.ContactPoint,FHIR.HumanName,FHIR.Identifier,FHIR.Money,FHIR.Reference,FHIR.SampledData,FHIR.Signature,FHIR.Timing,FHIR.ContactDetail,FHIR.Contributor,FHIR.DataRequirement,FHIR.Expression,FHIR.ParameterDefinition,FHIR.RelatedArtifact,FHIR.TriggerDefinition,FHIR.UsageContext,FHIR.Dosage,FHIR.Meta>"));
}
use of org.hl7.elm.r1.ExpressionDef in project clinical_quality_language by cqframework.
the class BaseTest method assertResultType.
private void assertResultType(CompiledLibrary translatedLibrary, String expressionName, String namespace, String name) {
ExpressionDef ed = translatedLibrary.resolveExpressionRef(expressionName);
DataType resultType = ed.getExpression().getResultType();
assertThat(resultType, instanceOf(ClassType.class));
ClassType resultClassType = (ClassType) resultType;
assertThat(resultClassType.getNamespace(), equalTo(namespace));
assertThat(resultClassType.getSimpleName(), equalTo(name));
}
use of org.hl7.elm.r1.ExpressionDef in project clinical_quality_language by cqframework.
the class SemanticTests method testTypeOperators.
@Test
public void testTypeOperators() throws IOException {
CqlTranslator translator = runSemanticTest("OperatorTests/TypeOperators.cql");
org.hl7.elm.r1.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("TestIf");
assertThat(def.getResultType(), instanceOf(ChoiceType.class));
ChoiceType choiceType = (ChoiceType) def.getResultType();
DataType type = null;
for (DataType dt : choiceType.getTypes()) {
if (type == null) {
type = dt;
assertThat(dt, instanceOf(NamedType.class));
assertThat(((NamedType) dt).getName(), equalTo("System.String"));
} else {
assertThat(dt, instanceOf(NamedType.class));
assertThat(((NamedType) dt).getName(), equalTo("System.Boolean"));
}
}
def = defs.get("TestCase");
assertThat(def.getResultType(), instanceOf(ChoiceType.class));
choiceType = (ChoiceType) def.getResultType();
type = null;
for (DataType dt : choiceType.getTypes()) {
if (type == null) {
type = dt;
assertThat(dt, instanceOf(NamedType.class));
assertThat(((NamedType) dt).getName(), equalTo("System.String"));
} else {
assertThat(dt, instanceOf(NamedType.class));
assertThat(((NamedType) dt).getName(), equalTo("System.Boolean"));
}
}
}
use of org.hl7.elm.r1.ExpressionDef in project clinical_quality_language by cqframework.
the class NullologicalOperatorsTest method testIsNull.
@Test
public void testIsNull() {
ExpressionDef def = defs.get("IsNullExpression");
assertThat(def, hasTypeAndResult(IsNull.class, "System.Boolean"));
IsNull isNull = (IsNull) def.getExpression();
assertThat(isNull.getOperand(), literalFor(1));
}
Aggregations