private void addSimpleConditionsFromComplexExpressions(ExpressionItem expressionItem, Collection<BinaryExpression> simpleConditionsExpressionItems) { if (expressionItem instanceof BinaryExpression) { addSimpleConditionsFromExpressionItems(expressionItem, simpleConditionsExpressionItems); } else if (expressionItem instanceof Variable) { Variable variable = (Variable) expressionItem; simpleConditionsExpressionItems.add(new BinaryExpression(variable, new ConstantExpression("null"), OperatorKind.INEQUAL)); } }
public static DataValue getDataValue(ConstantExpression constantExpression) { if (constantExpression instanceof CodedTextConstant) { return ((CodedTextConstant) constantExpression).getCodedText(); } else if (constantExpression instanceof QuantityConstant) { return ((QuantityConstant) constantExpression).getQuantity(); } else if (constantExpression instanceof StringConstant) { return new DvText(((StringConstant) constantExpression).getString()); } else if (constantExpression instanceof OrdinalConstant) { return ((OrdinalConstant) constantExpression).getOrdinal(); } else if (constantExpression instanceof DateTimeConstant) { return new DvDateTime(constantExpression.getValue()); } else if ("true".equals(constantExpression.getValue()) || "false".equals(constantExpression.getValue())) { return new DvBoolean(constantExpression.getValue()); } else if (constantExpression.getValue().startsWith("openehr::")) { return DataValue.parseValue("DV_CODED_TEXT," + constantExpression.getValue()); } else if (isParsableInteger(constantExpression.getValue())) { int count = Integer.parseInt(constantExpression.getValue()); return new DvCount(count); } else { LoggerFactory.getLogger(GuideUtil.class).warn("Unknown data value for constant expression '{}'", constantExpression); return null; } }
private void addSimpleConditionsFromComplexExpressions(String guideId, ExpressionItem expressionItem, GraphNode graphNode) throws InternalErrorException { if (expressionItem instanceof BinaryExpression) { addExpressionNodes(guideId, expressionItem, graphNode); } else if (expressionItem instanceof Variable) { Variable variable = (Variable) expressionItem; BinaryExpression binaryExpression = new BinaryExpression(variable, new ConstantExpression("null"), OperatorKind.INEQUAL); addExpressionToNode(guideId, binaryExpression, graphNode); } }
private static String formatConstantValue( Map<String, ArchetypeElementVO> elementMap, ConstantExpression exp, ExpressionItem parentExpressionItem) { String value = exp.getValue(); if (value.contains(",")) { String units = StringUtils.substringAfter(value, ","); if (isUcumTime(units)) { OperatorKind operatorKind = getOperatorKind(parentExpressionItem); if (operatorKind == null) { throw new RuntimeException(format("Operator kind not defined in expression : %s", parentExpressionItem)); } if (hasLeftVariableName(parentExpressionItem)) { String temporalVariableName = getLeftVariableNameFromExpression(elementMap, parentExpressionItem); value = format("DVUtil.calculateDuration(\"%s\",%s,\"%s\")", value, temporalVariableName, operatorKind.getSymbol()); } else { value = format("DVUtil.calculateDuration(\"%s\",\"%s\")", value, operatorKind.getSymbol()); } } else { throw new IllegalArgumentException(format("Unknown time units in value '%s'", value)); } } else if (exp instanceof MathConstant) { if (Constant.E.equals(((MathConstant) exp).getConstant())) { value = "(double) " + Math.E; } } return "(" + value + ")"; }
public AssignmentExpression toAssignmentExpression() throws IllegalStateException { if (archetypeElementRuleLineElement.getValue() == null) { throw new IllegalStateException("No variable set"); } Variable var = new Variable( archetypeElementRuleLineElement.getValue().getValue(), null, null, OpenEHRConst.NULL_FLAVOR_ATTRIBUTE); DvCodedText nullValue = nullValueRuleLineElement.getValue(); if (nullValue == null) { throw new IllegalStateException("No null value set"); } String dataValueStr = nullValue.toString(); LoggerFactory.getLogger(SetElementAttributeActionRuleLine.class).debug("dataValueStr: " + dataValueStr); return new AssignmentExpression( var, new ConstantExpression(dataValueStr)); } }
ConstantExpression ce = (ConstantExpression) right; DataValue dv = null; if (!"null".equals(ce.getValue())) { dv = getDataValue(ce);
public static ConstantExpression convertToExpression(DataValue dv) { String dataValueStr = dv.serialise(); dataValueStr = dataValueStr.substring(dataValueStr.indexOf(",") + 1); if (dv instanceof DvCodedText) { DvCodedText dvCT = (DvCodedText) dv; return new CodedTextConstant(dvCT.getValue(), dvCT.getDefiningCode()); } else if (dv instanceof DvOrdinal) { DvOrdinal dvOrdinal = (DvOrdinal) dv; return new OrdinalConstant(dvOrdinal); } else if (dv instanceof DvText) { return new StringConstant(dataValueStr); } else if (dv instanceof DvDateTime) { return new DateTimeConstant(getDateTimeStrWithoutMillisAndTimezone(dataValueStr)); } else if (dv instanceof DvQuantity) { return new QuantityConstant((DvQuantity) dv); } else if (dv instanceof DvCount) { if (dataValueStr.trim().startsWith("-")) { dataValueStr = "(" + dataValueStr + ")"; } return new ConstantExpression(dataValueStr); } else { return new ConstantExpression(dataValueStr); } }
if (rightExpressionItem instanceof ConstantExpression) { ConstantExpression constantExpression = (ConstantExpression) rightExpressionItem; if (constantExpression instanceof StringConstant || !constantExpression.getValue().equals("null")) { dv1 = GuideUtil.getDataValue(constantExpression); if (assignmentExpressionItem instanceof ConstantExpression) { ConstantExpression constantExpression = (ConstantExpression) assignmentExpressionItem; if (constantExpression instanceof StringConstant || !constantExpression.getValue().equals("null")) { dv2 = GuideUtil.getDataValue((ConstantExpression) assignmentExpressionItem);
public ExpressionItem toExpressionItem() throws IllegalStateException { ArchetypeElementVO archetypeElementVO = getArchetypeElement(); if (archetypeElementVO != null) { String path = archetypeElementVO.getPath(); OperatorKind operatorKind = getExistenceOperatorRuleLineElement().getOperator(); if (operatorKind == null) { throw new IllegalStateException("No operator set"); } String name = getArchetypeManager().getArchetypeElements().getText(archetypeElementVO, getLanguage()); return new BinaryExpression( new Variable(null, name, path), new ConstantExpression(NULL_STR), operatorKind); } else { throw new IllegalStateException("Element instance not found for" + this.toString()); } }
String dvStr = ((ConstantExpression) expressionItemAux).getValue(); DataValue dv = parseDataValue(rmType, dvStr, archetypeElementVO); ArchetypeDataValueRuleLineElement archetypeDataValueRuleLineElement = sedvar.getArchetypeDataValueRuleLineElement(); ruleLines.add(sewnvrl); sewnvrl.getArchetypeElementRuleLineElement().setValue(gtCodeRuleLineElement); String dvStr = ((ConstantExpression) expressionItemAux).getValue(); DataValue dv = parseDataValue(OpenEHRDataValues.DV_CODED_TEXT, dvStr, null); sewnvrl.getNullValueRuleLineElement().setValue((DvCodedText) dv);
public ExpressionItem toExpressionItem() throws IllegalStateException { ArchetypeElementVO archetypeElementVO = getArchetypeElementRuleLineElement().getArchetypeElementVO(); if (archetypeElementVO != null) { String gtCode = getArchetypeElementRuleLineElement().getValue().getValue(); OperatorKind operatorKind = getExistenceOperatorRuleLineElement().getOperator(); if (operatorKind == null) { log.debug("No operator set"); return null; } String name = getArchetypeManager().getArchetypeElements().getText(archetypeElementVO, getLanguage()); return new BinaryExpression( new Variable(gtCode, null, name), new ConstantExpression(NULL_STR), operatorKind); } else { log.debug("Element instance not found for" + this.toString()); return null; } } }
if (binaryExpression.getRight() instanceof ConstantExpression) { ConstantExpression constantExpression = (ConstantExpression) binaryExpression.getRight(); String dvStr = constantExpression.getValue(); DataValue dv = null; ArchetypeElementVO archetypeElementVO = null; ecwnvc.getArchetypeElementRuleLineElement().setValue(gtCodeRuleLineElement); ConstantExpression constantExpression = (ConstantExpression) binaryExpression.getRight(); String dvStr = constantExpression.getValue(); DataValue dv = parseDataValue(OpenEHRDataValues.DV_CODED_TEXT, dvStr, null); if (dv instanceof DvCodedText) {
archetypeElementVO.getPath(), OpenEHRConst.NULL_FLAVOR_ATTRIBUTE), new ConstantExpression(dataValueStr), operatorKind); } else {
ConstantExpression constantExpression2 = (ConstantExpression) binaryExpression.getRight(); String path = variable.getPath(); String dvStr = constantExpression2.getValue(); ArchetypeElementVO archetypeElementVO = airl.getArchetypeManager().getArchetypeElements().getArchetypeElement(
{if (true) return new ConstantExpression(t.image);} throw new Error("Missing return statement in function");