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 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 + ")"; }
ConstantExpression ce = (ConstantExpression) right; DataValue dv = null; if (!"null".equals(ce.getValue())) { dv = getDataValue(ce);
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);
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);
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) {
ConstantExpression constantExpression2 = (ConstantExpression) binaryExpression.getRight(); String path = variable.getPath(); String dvStr = constantExpression2.getValue(); ArchetypeElementVO archetypeElementVO = airl.getArchetypeManager().getArchetypeElements().getArchetypeElement(