use of org.hl7.elm_modelinfo.r1.TypeSpecifier in project clinical_quality_language by cqframework.
the class ElmRequirementsContext method reportFunctionRef.
public void reportFunctionRef(FunctionRef functionRef) {
CompiledLibrary targetLibrary = prepareLibraryVisit(getCurrentLibraryIdentifier(), functionRef.getLibraryName());
try {
List<DataType> signature;
signature = new ArrayList<DataType>();
for (TypeSpecifier ts : functionRef.getSignature()) {
signature.add(typeResolver.resolveTypeSpecifier(ts));
}
// Signature sizes will only be different in the case that the signature is not present in the ELM, so needs to be constructed
if (signature.size() != functionRef.getOperand().size()) {
for (Expression e : functionRef.getOperand()) {
if (e.getResultType() != null) {
signature.add(e.getResultType());
} else if (e.getResultTypeName() != null) {
signature.add(typeResolver.resolveTypeName(e.getResultTypeName()));
} else if (e.getResultTypeSpecifier() != null) {
signature.add(typeResolver.resolveTypeSpecifier(e.getResultTypeSpecifier()));
} else {
// Signature could not be constructed, fall back to reporting all function defs
signature = null;
break;
}
}
}
Iterable<FunctionDef> fds = targetLibrary.resolveFunctionRef(functionRef.getName(), signature);
for (FunctionDef fd : fds) {
if (!visited.contains(fd)) {
visitor.visitElement(fd, this);
}
}
} finally {
unprepareLibraryVisit(functionRef.getLibraryName());
}
}
use of org.hl7.elm_modelinfo.r1.TypeSpecifier in project quality-measure-and-cohort-service by Alvearie.
the class ElmUtils method getModelTypeNames.
public static Set<QName> getModelTypeNames(Expression expression) {
Set<QName> modelTypeNames = new HashSet<>();
if (expression.getResultTypeName() != null) {
modelTypeNames.add(expression.getResultTypeName());
} else {
TypeSpecifier resultTypeSpecifier = expression.getResultTypeSpecifier();
if (resultTypeSpecifier != null) {
Set<QName> specifierModelTypeNames = getModelTypeNames(resultTypeSpecifier);
modelTypeNames.addAll(specifierModelTypeNames);
} else {
// This is normal for something like a ConceptRef
LOG.debug("Could not resolve model type name for expression of type {}", expression.getClass().getSimpleName());
// throw new IllegalArgumentException("Could not resolve model type name for expression " + expression.getLocator());
}
}
return modelTypeNames;
}
use of org.hl7.elm_modelinfo.r1.TypeSpecifier in project quality-measure-and-cohort-service by Alvearie.
the class ModelUtils method getChoiceTypeNames.
public static Collection<String> getChoiceTypeNames(TypeInfo typeInfo) {
if (typeInfo != null && typeInfo.getBaseTypeSpecifier() != null && (typeInfo.getBaseTypeSpecifier() instanceof ChoiceTypeSpecifier)) {
List<String> choiceTypes = new ArrayList<>();
ChoiceTypeSpecifier choiceType = (ChoiceTypeSpecifier) typeInfo.getBaseTypeSpecifier();
for (TypeSpecifier typeSpecifier : choiceType.getChoice()) {
if (typeSpecifier instanceof NamedTypeSpecifier) {
String typeName = ((NamedTypeSpecifier) typeSpecifier).getName();
choiceTypes.add(typeName);
}
}
return choiceTypes;
} else {
return Collections.emptyList();
}
}
Aggregations