private boolean isMaxMin(ElementInstance elementInstance, ElementInstance maxElementInstance, boolean max) { int compare = DVUtil.compareDVs(elementInstance.getDataValue(), maxElementInstance.getDataValue()); if (max) { return compare >= 0; } else { return compare < 0; } }
private int getNumPredicates(ArchetypeReference archetypeReference) { int count = 0; for (ElementInstance elementInstance : archetypeReference.getElementInstancesMap().values()) { if (elementInstance instanceof PredicateGeneratedElementInstance && elementInstance.getDataValue() != null) { count++; } } return count; } }
public static boolean equalDV(boolean inPredicate, ElementInstance ei, DataValue dv2, boolean negated) { if (ei instanceof PredicateGeneratedElementInstance) { return inPredicate; } else { boolean result = DVUtil.equalDVs(ei.getDataValue(), dv2); if (negated) { return !result; } else { return result; } } }
public static boolean isEmpty(ArchetypeReference ar) { for (String idElement : ar.getElementInstancesMap().keySet()) { ElementInstance ei = ar.getElementInstancesMap().get(idElement); if (ei.getDataValue() != null) { return false; } } return true; }
private DateTime getDateTime(ElementInstance ei) { if (ei != null) { if (ei.getDataValue() instanceof DvDateTime) { DvDateTime dvDateTime = ((DvDateTime) ei.getDataValue()); if (dvDateTime.getDateTime() != null) { return dvDateTime.getDateTime(); } else { logger.warn("Element instance '" + ei.getId() + "' has no DVDateTime."); } } else { String dvType = ei.getDataValue() == null ? "null" : ei.getDataValue().getClass().getSimpleName(); logger.warn("Element instance '" + ei.getId() + "' data value is not DVDateTime, '" + dvType + "' found instead.)"); } } else { logger.debug("Element instance null"); } return null; }
public static DataValue createDV( ElementInstance elementInstance, String rmName, String attributeName, Object value) { DataValue dv = elementInstance.getDataValue(); if (dv == null) { dv = DataValueGenerator.getDummyDV(rmName); } return DataValueGenerator.createDV(dv, attributeName, value); }
public String toString() { StringBuilder sb = new StringBuilder(); sb.append("-----\n"); for (String idArchetype : getArchetypeReferenceMap().keySet()) { sb.append(idArchetype).append("\n"); for (String idDomain : getArchetypeReferenceMap(idArchetype).keySet()) { sb.append("-Domain=").append(idDomain).append("\n"); for (String idAux : getArchetypeReferenceMap(idArchetype, idDomain).keySet()) { sb.append("--idAux=").append(idAux).append("\n"); int index = 1; for (ArchetypeReference ar : getArchetypeReferences(idArchetype, idDomain, idAux)) { sb.append("---[").append(index).append("]\n"); for (String idElement : ar.getElementInstancesMap().keySet()) { sb.append("----").append(idElement).append(""); ElementInstance ei = ar.getElementInstancesMap().get(idElement); if (ei.getDataValue() != null) { sb.append(" (").append(ei.getDataValue().toString()).append(")"); } sb.append("\n"); } } } } } sb.append("-----\n"); return sb.toString(); } }
private static DataValue getResolveDataValueIfNeeded(Map<String, Guide> guideMap, Calendar date, ElementInstance ei, Set<String> guideIds) { DataValue dv = ei.getDataValue(); if (ei instanceof PredicateGeneratedElementInstance) { Set<String> localGuideIds = new HashSet<>(); PredicateGeneratedElementInstance pgei = ((PredicateGeneratedElementInstance) ei); for (RuleReference ruleReference : pgei.getRuleReferences()) { Guide guide = guideMap.get(ruleReference.getGuideId()); if (guide == null) { LoggerFactory.getLogger(ElementInstanceCollectionManager.class).warn("Null guideline for rule reference '" + ruleReference + "'"); } else { localGuideIds.add(guide.getId()); } } Collection<Guide> localGuides = new ArrayList<>(); for (String guideId : localGuideIds) { Guide guide = guideMap.get(guideId); localGuides.add(guide); } if (pgei.getOperatorKind().equals(OperatorKind.IS_A)) { dv = ei.getDataValue(); } else { dv = resolvePredicate(ei.getDataValue(), pgei.getOperatorKind(), localGuides, date); } guideIds.addAll(localGuideIds); } return dv; }
private void filterGreaterLessThanPredicate( String elementId, DataValue dv, Collection<ArchetypeReference> ehrArchetypeReferences, boolean greaterThan, Calendar date) { if (dv instanceof CurrentTimeExpressionDataValue) { OperatorKind operatorKind = greaterThan ? OperatorKind.GREATER_THAN_OR_EQUAL : OperatorKind.LESS_THAN_OR_EQUAL; dv = ElementInstanceCollectionManager.resolvePredicate(dv, operatorKind, null, date); if (dv == null) { LoggerFactory.getLogger(PredicateFilterManager.class).warn("No Data Value returned after resolving predicate!"); } } final Set<ArchetypeReference> archetypeReferencesToRemove = new HashSet<>(); for (ArchetypeReference archetypeReference : ehrArchetypeReferences) { ElementInstance elementInstance = archetypeReference.getElementInstancesMap().get(elementId); if (elementInstance != null) { if (elementInstance.getDataValue() != null) { int compare = DVUtil.compareDVs(dv, elementInstance.getDataValue()); if (compare != 0 && ((greaterThan && compare > 0) || (!greaterThan && compare < 0))) { archetypeReferencesToRemove.add(elementInstance.getArchetypeReference()); } } else { archetypeReferencesToRemove.add(elementInstance.getArchetypeReference()); } } } ehrArchetypeReferences.removeAll(archetypeReferencesToRemove); }
public static boolean isNotSubClassOf(boolean inPredicate, ElementInstance ei, DataValue... dataValues) { if (ei instanceof PredicateGeneratedElementInstance) { return true; } else { CodePhrase codePhrase = getCodePhrase(ei.getDataValue()); Set<CodePhrase> codePhrases = new HashSet<>(); for (DataValue dataValue : dataValues) { codePhrases.add(getCodePhrase(dataValue)); } if (codePhrase != null && !codePhrases.isEmpty()) { return !getTerminologyService().isSubclassOf(codePhrase, codePhrases); } else { return false; } } }
public static boolean isSubClassOf(boolean inPredicate, ElementInstance ei, DataValue... dataValues) { if (!inPredicate && ei instanceof PredicateGeneratedElementInstance) { return false; } else { CodePhrase codePhrase = getCodePhrase(ei.getDataValue()); Set<CodePhrase> codePhrases = new HashSet<>(); for (DataValue dataValue : dataValues) { codePhrases.add(getCodePhrase(dataValue)); } if (codePhrase != null && !codePhrases.isEmpty()) { return getTerminologyService().isSubclassOf(codePhrase, codePhrases); } else { return false; } } }
private void filterEquals( PredicateGeneratedElementInstance predicate, Collection<ArchetypeReference> ehrArchetypeReferences, boolean negation) { final Set<ArchetypeReference> archetypeReferencesToRemove = new HashSet<>(); for (ArchetypeReference archetypeReference : ehrArchetypeReferences) { ElementInstance elementInstance = archetypeReference.getElementInstancesMap().get(predicate.getId()); if (elementInstance != null) { DataValue dataValue = elementInstance.getDataValue(); if (dataValue != null) { boolean equals = dataValue.equals(predicate.getDataValue()); if ((!equals && !negation) || (equals && negation)) { archetypeReferencesToRemove.add(elementInstance.getArchetypeReference()); } } else { archetypeReferencesToRemove.add(elementInstance.getArchetypeReference()); } } } ehrArchetypeReferences.removeAll(archetypeReferencesToRemove); }
private void filterMaxMin(String elementId, Collection<ArchetypeReference> ehrArchetypeReferences, boolean max) { final Set<ArchetypeReference> archetypeReferencesToRemove = new HashSet<>(); ElementInstance maxElementInstance = null; for (ArchetypeReference archetypeReference : ehrArchetypeReferences) { ElementInstance elementInstance = archetypeReference.getElementInstancesMap().get(elementId); if (elementInstance != null) { if (elementInstance.getDataValue() != null) { if (maxElementInstance == null || isMaxMin(elementInstance, maxElementInstance, max)) { if (maxElementInstance != null) { archetypeReferencesToRemove.add(maxElementInstance.getArchetypeReference()); } maxElementInstance = elementInstance; } else { archetypeReferencesToRemove.add(elementInstance.getArchetypeReference()); } } else { archetypeReferencesToRemove.add(elementInstance.getArchetypeReference()); } } } ehrArchetypeReferences.removeAll(archetypeReferencesToRemove); }
private CodePhrase getCodePhrase(ElementInstance elementInstance) { DataValue dataValue = elementInstance.getDataValue(); if (dataValue instanceof DvCodedText) { return ((DvCodedText) dataValue).getDefiningCode(); } else if (dataValue instanceof DvOrdinal) { return ((DvOrdinal) dataValue).getSymbol().getDefiningCode(); } else { return null; } }
private DVGenericPanel getDVGenericForElement(ElementInstance elementInstance) { String idTemplate = elementInstance.getArchetypeReference().getIdTemplate(); String idElement = elementInstance.getId(); ArchetypeElementVO archetypeElement = archetypeManager.getArchetypeElements().getArchetypeElement( idTemplate, idElement); String rmType = archetypeElement.getType(); DVGenericPanel dvGenericPanel = dvPanelFactory.createDVPanel(idElement, idTemplate, rmType, true, true, false); if (dvGenericPanel != null) { dvGenericPanel.setDataValue(elementInstance.getDataValue()); } return dvGenericPanel; }
(PredicateGeneratedElementInstance) originalEI; DataValue dv = originalEI.getDataValue(); if (guideManager != null) { Collection<Guide> guides = getGuides(guideManager, predicateOriginalEI, dv);