use of org.hl7.fhir.r5.model.DataType in project clinical_quality_language by cqframework.
the class GenericOperator method instantiate.
public InstantiationResult instantiate(Signature callSignature, Map<TypeParameter, DataType> parameters, OperatorMap operatorMap, ConversionMap conversionMap, boolean allowPromotionAndDemotion) {
Map<TypeParameter, DataType> typeMap = new HashMap<>();
for (TypeParameter p : typeParameters) {
typeMap.put(p, null);
}
if (parameters != null) {
for (Map.Entry<TypeParameter, DataType> entry : parameters.entrySet()) {
typeMap.put(entry.getKey(), entry.getValue());
}
}
InstantiationContextImpl context = new InstantiationContextImpl(typeMap, operatorMap, conversionMap, allowPromotionAndDemotion);
Boolean instantiable = getSignature().isInstantiable(callSignature, context);
if (instantiable) {
Operator result = new Operator(getName(), getSignature().instantiate(context), getResultType().instantiate(context));
result.setAccessLevel(getAccessLevel());
result.setLibraryName(getLibraryName());
return new InstantiationResult(this, result, context.getConversionScore());
}
return new InstantiationResult(this, null, context.getConversionScore());
}
use of org.hl7.fhir.r5.model.DataType in project clinical_quality_language by cqframework.
the class OperatorEntry method expandChoices.
public List<Signature> expandChoices(Signature callSignature) {
ArrayList<Signature> signatures = new ArrayList<Signature>();
if (callSignature.containsChoices()) {
ArrayList<ArrayList<DataType>> operandList = new ArrayList<ArrayList<DataType>>();
for (DataType operand : callSignature.getOperandTypes()) {
ArrayList<DataType> list = new ArrayList<DataType>();
if (operand instanceof ChoiceType) {
for (DataType type : ((ChoiceType) operand).getTypes()) {
list.add(type);
}
} else {
list.add(operand);
}
operandList.add(list);
}
DataType[] result = new DataType[callSignature.getSize()];
collectSignatures(operandList, result, 0, signatures);
} else {
signatures.add(callSignature);
}
return signatures;
}
use of org.hl7.fhir.r5.model.DataType in project clinical_quality_language by cqframework.
the class TypeBuilder method dataTypeToQName.
public QName dataTypeToQName(DataType type) {
if (type instanceof NamedType) {
NamedType namedType = (NamedType) type;
ModelInfo modelInfo = mr.getModel(namedType.getNamespace()).getModelInfo();
return new QName(modelInfo.getTargetUrl() != null ? modelInfo.getTargetUrl() : modelInfo.getUrl(), namedType.getTarget() != null ? namedType.getTarget() : namedType.getSimpleName());
}
// ERROR:
throw new IllegalArgumentException("A named type is required in this context.");
}
use of org.hl7.fhir.r5.model.DataType in project clinical_quality_language by cqframework.
the class SystemLibraryHelper method add.
private static void add(CompiledLibrary systemLibrary, TypeBuilder tb, Operator operator) {
// In the case that an operator is added directly, manufacture a FunctionDef so it can be referred to in ELM Analysis
FunctionDef fd = new FunctionDef();
fd.setName(operator.getName());
int n = 0;
for (DataType dataType : operator.getSignature().getOperandTypes()) {
n++;
OperandDef od = new OperandDef().withName(String.format("param%d", n));
if (dataType instanceof NamedType) {
od.setOperandType(tb.dataTypeToQName(dataType));
} else {
od.setOperandTypeSpecifier(tb.dataTypeToTypeSpecifier(dataType));
}
od.setResultType(dataType);
fd.getOperand().add(od);
}
operator.setFunctionDef(fd);
systemLibrary.add(fd, operator);
}
use of org.hl7.fhir.r5.model.DataType in project cqf-ruler by DBCG.
the class JpaFhirRetrieveProvider method executeQuery.
protected List<IBaseResource> executeQuery(String dataType, SearchParameterMap map) {
// TODO: Once HAPI breaks this out from the server dependencies
// we can include it on its own.
ca.uhn.fhir.jpa.searchparam.SearchParameterMap hapiMap = ca.uhn.fhir.jpa.searchparam.SearchParameterMap.newSynchronous();
try {
Method[] methods = hapiMap.getClass().getDeclaredMethods();
List<Method> methodList = Arrays.asList(methods);
List<Method> puts = methodList.stream().filter(x -> x.getName().equals("put")).collect(Collectors.toList());
Method method = puts.get(0);
method.setAccessible(true);
for (Map.Entry<String, List<List<IQueryParameterType>>> entry : map.entrySet()) {
method.invoke(hapiMap, entry.getKey(), entry.getValue());
}
} catch (Exception e) {
logger.warn("Error converting search parameter map", e);
}
IBundleProvider bundleProvider = search(getClass(dataType), hapiMap, myRequestDetails);
if (bundleProvider.isEmpty()) {
return new ArrayList<>();
}
return bundleProvider.getAllResources();
}
Aggregations