private String getArchetypeKey(ArchetypeBinding archetypeBinding) { return archetypeBinding.getDomain() + "|" + archetypeBinding.getArchetypeId() + archetypeBinding.getTemplateId(); }
public static Map<String, String> getGtCodeElementIdMap(Guide guide, String domainId) { Map<String, String> gtCodeElementIdMap = new HashMap<>(); if (guide.getDefinition() == null || guide.getDefinition().getArchetypeBindings() == null) { return gtCodeElementIdMap; } for (ArchetypeBinding archetypeBinding : guide.getDefinition().getArchetypeBindings().values()) { if (domainId == null || archetypeBinding.getDomain() == null || domainId.equals(archetypeBinding.getDomain())) { for (ElementBinding elementBinding : archetypeBinding.getElements().values()) { gtCodeElementIdMap.put(elementBinding.getId(), archetypeBinding.getArchetypeId() + elementBinding.getPath()); } } } return gtCodeElementIdMap; } }
if (right instanceof ConstantExpression) { String idElement = archetypeBinding.getArchetypeId() + path; ConstantExpression ce = (ConstantExpression) right; DataValue dv = null; String attribute = path.substring(path.lastIndexOf("/value/") + 7, path.length()); path = path.substring(0, path.length() - attribute.length() - 7); String idElement = archetypeBinding.getArchetypeId() + path; DataValue dv = new CurrentTimeExpressionDataValue(right, attribute); generateElementInstanceForPredicate(ar, be.getOperator(), idElement, dv, guide, dateTime, resolvePredicates);
private static void generatePredicateElementsForUnaryExpression( ArchetypeBinding archetypeBinding, ArchetypeReference ar, Guide guide, DateTime dateTime, boolean resolvePredicates, UnaryExpression expressionItem) { UnaryExpression ue = expressionItem; OperatorKind op = ue.getOperator(); ExpressionItem operand = ue.getOperand(); if (operand instanceof Variable) { String idElement = archetypeBinding.getArchetypeId() + ((Variable) operand).getPath(); DataValue dv = null; generateElementInstanceForPredicate(ar, op, idElement, dv, guide, dateTime, resolvePredicates); //TODO No rule references added (no gt codes) } }
private static GeneratedArchetypeReference getGeneratedArchetypeReference( ArchetypeBinding archetypeBinding, String guideId, Guide guide, DateTime dateTime, boolean resolvePredicates) { GeneratedArchetypeReference ar = new GeneratedArchetypeReference( archetypeBinding.getDomain(), archetypeBinding.getArchetypeId(), archetypeBinding.getTemplateId()); if (archetypeBinding.getElements() != null) { for (ElementBinding elementBinding : archetypeBinding.getElements().values()) { String idElement = archetypeBinding.getArchetypeId() + elementBinding.getPath(); GeneratedElementInstance gei = new GeneratedElementInstance( idElement, null, ar, null, NULL_FLAVOUR_CODE_NO_INFO); gei.getRuleReferences().add(new RuleReference(guideId, elementBinding.getId())); } } generatePredicateElements(archetypeBinding, ar, guideId, guide, dateTime, resolvePredicates); return ar; }
private void generateArchetypeNodes(Guide guide) { for (ArchetypeBinding archetypeBinding : guide.getDefinition().getArchetypeBindings().values()) { String archetypeKey = getArchetypeKey(archetypeBinding); String label = archetypeBinding.getDomain() + " | " + archetypeBinding.getArchetypeId(); Color archetypeBindingColor = getArchetypeNodeColor(archetypeBinding); GraphNode archetypeNode = new GraphNodeBuilder() .setLabel(label) .setShape(GraphNode.Shape.RECTANGLE) .setFillColor(archetypeBindingColor) .createGraphNode(); getArchetypeNodesMap().put(archetypeKey, archetypeNode); } }
private void generateGtCodeMapForArchetypeBinding(ArchetypeBinding archetypeBinding) throws InternalErrorException { ArchetypeInstantiationRuleLine airl = new ArchetypeInstantiationRuleLine(); airl.setReadableGuide(readableGuide); airl.setGTCode(archetypeBinding.getId()); ArchetypeReference ar = new ArchetypeReference( archetypeBinding.getDomain(), archetypeBinding.getArchetypeId(), archetypeBinding.getTemplateId()); airl.setArchetypeReference(ar); gtCodeElementMap.put(archetypeBinding.getId(), airl); if (archetypeBinding.getElements() != null) { for (ElementBinding elementBinding : archetypeBinding.getElements().values()) { generateGTCodeMapForElementBinding(archetypeBinding, airl, elementBinding); } } }
private void generateGTCodeMapForElementBinding( ArchetypeBinding archetypeBinding, ArchetypeInstantiationRuleLine airl, ElementBinding elementBinding) { ArchetypeElementInstantiationRuleLine aeirl = new ArchetypeElementInstantiationRuleLine(airl); aeirl.setReadableGuide(readableGuide); aeirl.setGTCode(elementBinding.getId()); if ("/event/time".equals(elementBinding.getPath())) { elementBinding.setPath(OpenEHRRMUtil.EVENT_TIME_PATH); } String elementId = archetypeBinding.getArchetypeId() + elementBinding.getPath(); ArchetypeElementVO archetypeElementVO = archetypeManager.getArchetypeElements().getArchetypeElement( archetypeBinding.getTemplateId(), elementId); if (archetypeElementVO == null) { throw new RuntimeException( "Element '" + elementId + (archetypeBinding.getTemplateId() != null ? " (" + archetypeBinding.getTemplateId() + ")" : "") + "' not found!"); } aeirl.setArchetypeElementVO(archetypeElementVO); gtCodeElementMap.put(elementBinding.getId(), aeirl); } }
airl.getArchetypeManager().getArchetypeElements().getArchetypeElement( archetypeBinding.getTemplateId(), archetypeBinding.getArchetypeId() + path); if (archetypeElementVO == null) { throw new RuntimeException( "Element '" + archetypeBinding.getArchetypeId() + path + (archetypeBinding.getTemplateId() != null ? " (" + archetypeBinding.getTemplateId() + ")" : "") + "' not found!"); airl.getArchetypeManager().getArchetypeElements().getArchetypeElement( archetypeBinding.getTemplateId(), archetypeBinding.getArchetypeId() + path); if (archetypeElementVO == null) { throw new RuntimeException( "Element '" + archetypeBinding.getArchetypeId() + path + (archetypeBinding.getTemplateId() != null ? " (" + archetypeBinding.getTemplateId() + ")" : "") + "' not found!"); airl.getArchetypeManager().getArchetypeElements().getArchetypeElement( archetypeBinding.getTemplateId(), archetypeBinding.getArchetypeId() + path); if (archetypeElementVO == null) { throw new RuntimeException( "Element '" + archetypeBinding.getArchetypeId() + path + (archetypeBinding.getTemplateId() != null ? " (" + archetypeBinding.getTemplateId() + ")" : "") + "' not found!");