public static String getDescription(ArchetypeReference ar) { if (ar != null) { return ar.getIdArchetype(); } else { return "*UNKNOWN*"; } }
public static String getName(ArchetypeReference ar) { if (ar != null) { return ar.getIdArchetype(); } else { return "*UNKNOWN*"; } }
private Collection<ArchetypeReference> getEhrDataForArchetype(Collection<ArchetypeReference> ehrArchetypeReferences, String idArchetype) { Collection<ArchetypeReference> archetypeReferences = new ArrayList<>(); for (ArchetypeReference archetypeReference : ehrArchetypeReferences) { if (idArchetype.equals(archetypeReference.getIdArchetype())) { archetypeReferences.add(archetypeReference); } } return archetypeReferences; }
private void addEventTimeElements(Collection<ArchetypeReference> queryARs) { for (ArchetypeReference archetypeReference : queryARs) { String eventTimePath = dateTimeARFinder.getEventTimePath(archetypeReference.getIdArchetype()); if (eventTimePath != null) { String eventTimeElementId = archetypeReference.getIdArchetype() + eventTimePath; if (!archetypeReference.getElementInstancesMap().containsKey(eventTimeElementId)) { log.info("Adding event path '" + eventTimeElementId + "' for archetype '" + archetypeReference.getIdArchetype() + "'!"); new GeneratedElementInstance(eventTimeElementId, null, archetypeReference, null, OpenEHRConstUI.NULL_FLAVOUR_CODE_NO_INFO); } } else { log.warn("Could not find event path for archetype '" + archetypeReference.getIdArchetype() + "'!"); } } }
public static String getDescription(ArchetypeInstantiationRuleLine airl) { if (airl != null) { ArchetypeReference ar = airl.getArchetypeReference(); if (ar != null) { return ar.getIdArchetype(); } } return "*UNKNOWN*"; }
private static Map<String, ArchetypeReference> getCompressedQueryArchetypeReferencesMap(Collection<ArchetypeReference> generatedArchetypeReferences) { final Map<String, ArchetypeReference> archetypeReferencesMap = new HashMap<>(); for (ArchetypeReference arNew : generatedArchetypeReferences) { GeneratedArchetypeReference gar = (GeneratedArchetypeReference) arNew; ArchetypeReference arPrev = archetypeReferencesMap.get(arNew.getIdArchetype()); if (arPrev != null) { compressQueryArchetypeReference(arPrev, arNew); } else { arNew = getCleanArchetypeReferenceWithElements(gar); archetypeReferencesMap.put(arNew.getIdArchetype(), arNew); } } return archetypeReferencesMap; }
public String getIdArchetype() { return getArchetypeReference().getIdArchetype(); }
public DateTime getDateTime(ArchetypeReference ar) { String dvDateTimePath = getEventTimePath(ar.getIdArchetype()); if (dvDateTimePath != null) { ElementInstance ei = ar.getElementInstancesMap().get(ar.getIdArchetype() + dvDateTimePath); return getDateTime(ei); } else { return null; } }
public Set<ArchetypeReference> filterEHRData(DateTime startDateTime, DateTime endDateTime, Collection<ArchetypeReference> ehrData) { Set<ArchetypeReference> ehrDataAux = new HashSet<>(); for (ArchetypeReference archetypeReference : ehrData) { boolean useAR = true; DateTime dateTime = dateTimeARFinder.getDateTime(archetypeReference); if (dateTime == null || endDateTime != null && dateTime.isAfter(endDateTime) || startDateTime != null && dateTime.isBefore(startDateTime)) { useAR = false; if (dateTime == null) { LoggerFactory.getLogger(EhrDataFilterManager.class).warn("Date time for Archetype Reference " + archetypeReference.getIdArchetype() + " is null!"); } } if (useAR) { ehrDataAux.add(archetypeReference); } } return ehrDataAux; } }
public Set<ArchetypeReference> filterEHRData(String ehrId, DateTime ehrDate, Collection<ArchetypeReference> ehrData) { Set<ArchetypeReference> ehrIdARs = new HashSet<>(); if (ehrData == null) { LoggerFactory.getLogger(EhrDataFilterManager.class).warn("No ehrData found for ehrId '" + ehrId + "'"); } else { for (ArchetypeReference archetypeReference : ehrData) { //If using time series comparison filter elements outside the range boolean useAR = true; if (ehrDate != null) { DateTime dateTime = dateTimeARFinder.getDateTime(archetypeReference); if (dateTime == null) { LoggerFactory.getLogger(EhrDataFilterManager.class).debug("Date time for ehrId " + ehrId + " with AR " + archetypeReference.getIdArchetype() + " is null!"); } if (dateTime != null && dateTime.isAfter(ehrDate)) { useAR = false; DateFormat df = DateFormat.getDateTimeInstance(); LoggerFactory.getLogger(EhrDataFilterManager.class).debug(df.format(dateTime.toDate()) + " after " + df.format(ehrDate.toDate())); } } if (useAR) { ehrIdARs.add(archetypeReference); } } } return ehrIdARs; }
public static String getName(ArchetypeInstantiationRuleLine airl, boolean withPredicate) { if (airl != null) { ArchetypeReference ar = airl.getArchetypeReference(); if (ar != null) { String name = ar.getIdArchetype(); if (withPredicate) { String predicateDesc = getShortPredicateDescription(airl); if (!predicateDesc.isEmpty()) { name = name + " (" + predicateDesc + ")"; } } return name; } } LoggerFactory.getLogger(ArchetypeReference.class).warn("Unknown name for AR '" + airl + "'"); return "*UNKNOWN*"; }
private static String getArchetypeImageName(ArchetypeReference ar) { String archetypeImageName = null; if (ar != null) { archetypeImageName = OpenEHRConstUI.getIconName(Archetypes.getEntryType(ar.getIdArchetype())); } return archetypeImageName; }
public void filterByPredicates( Collection<ArchetypeReference> definitionArchetypeReferences, Collection<ArchetypeReference> ehrArchetypeReferences, Calendar date) { boolean filterActive = true; repeatedArchetypeReferencesFilter.filter(definitionArchetypeReferences); Set<ArchetypeReference> archetypeReferences = new HashSet<>(); for (ArchetypeReference archetypeReference : definitionArchetypeReferences) { Collection<ArchetypeReference> ehrDataForArchetype = getEhrDataForArchetype(ehrArchetypeReferences, archetypeReference.getIdArchetype()); Collection<ArchetypeReference> filteredEhrData = getFilteredEhrData(archetypeReference, date, ehrDataForArchetype); if (filteredEhrData.size() == ehrArchetypeReferences.size()) { filterActive = false; break; } archetypeReferences.addAll(filteredEhrData); } if (filterActive) { ehrArchetypeReferences.clear(); ehrArchetypeReferences.addAll(archetypeReferences); } }
public Set<ArchetypeReference> getArchetypeReferences(ArchetypeReference archetypeReference) { String idDomain = archetypeReference.getIdDomain() != null ? archetypeReference.getIdDomain() : EMPTY_CODE; String idAux = null; if (Domains.CDS_ID.equals(idDomain)) { idAux = archetypeReference.getIdTemplate(); } if (idAux == null) { idAux = EMPTY_CODE; } return getArchetypeReferences(archetypeReference.getIdArchetype(), idDomain, idAux); }
private static void checkForMissingPathsInEHR( ElementInstanceCollection ehrEIC, ElementInstanceCollection generatedEIC) { Map<String, ArchetypeReference> compressedARsMap = getCompressedQueryArchetypeReferencesMap(generatedEIC.getAllArchetypeReferences()); for (ArchetypeReference ar : ehrEIC.getAllArchetypeReferences()) { ArchetypeReference compressedAR = compressedARsMap.get(ar.getIdArchetype()); if (compressedAR != null) { for (String elementId : compressedAR.getElementInstancesMap().keySet()) { if (!ar.getElementInstancesMap().containsKey(elementId)) { new ElementInstance(elementId, null, ar, null, OpenEHRConstUI.NULL_FLAVOUR_CODE_NO_INFO); } } } } }
public boolean matches(GeneratedArchetypeReference ar1, ArchetypeReference ar2, Map<String, Guide> guideMap, Calendar date) { if (!ar1.getIdArchetype().equals(ar2.getIdArchetype())) { return false; } else { for (String idElement : ar1.getElementInstancesMap().keySet()) { ElementInstance ei1 = ar1.getElementInstancesMap().get(idElement); ElementInstance ei2 = ar2.getElementInstancesMap().get(idElement); if (ei1 instanceof PredicateGeneratedElementInstance) { if (ei2 != null) { OperatorKind operatorKind = ((PredicateGeneratedElementInstance) ei1).getOperatorKind(); Set<String> guideIds = new HashSet<>(); DataValue dv = getResolveDataValueIfNeeded(guideMap, date, ei1, guideIds); DataValue dv2 = getResolveDataValueIfNeeded(guideMap, date, ei2, guideIds); Collection<Guide> guides = getGuides(guideMap, guideIds); if (!matches(dv, dv2, operatorKind, guides)) { return false; } } else { return false; } } } return true; } }
@Override public AssignmentExpression toAssignmentExpression() throws IllegalStateException { ArchetypeReference archetypeReference = getArchetypeReference(); if (archetypeReference != null) { String name = archetypeReference.getIdArchetype(); Variable var = new Variable( cdsEntryRuleLineElement.getValue().getValue(), null, name, CreateInstanceExpression.FUNCTION_CREATE_NAME); List<AssignmentExpression> assignmentExpressions = new ArrayList<>(); if (!getChildrenRuleLines().getRuleLines().isEmpty()) { for (RuleLine childRuleLine : getChildrenRuleLines().getRuleLines()) { AssignmentExpressionRuleLine assignmentExpressionRuleLine = (AssignmentExpressionRuleLine) childRuleLine; assignmentExpressions.add(assignmentExpressionRuleLine.toAssignmentExpression()); } } else { log.debug("No assignment rules on create instance action rule"); return null; } return new CreateInstanceExpression( var, assignmentExpressions); } else { log.debug("No archetype reference set on create instance action rule"); return null; } }
@Override public String getLabelText(String lang) { if (getValue() != null) { String idArchetype = getValue().getIdArchetype(); ArchetypeDTO archetypeVO = getArchetypeManager().getArchetypes().getCMElement(idArchetype); if (archetypeVO != null) { return archetypeVO.getId(); } else { log.error("Archetype not found! (" + idArchetype + ")"); return ""; } } else { return super.getLabelText(lang); } }
public static String getHTMLTooltip(ArchetypeInstantiationRuleLine airl) { ArchetypeReference ar = airl.getArchetypeReference(); if (ar != null) { String archetypeImageName = OpenEHRConstUI.getIconName(Archetypes.getEntryType(ar.getIdArchetype())); String archetypeName = getName(airl, false); return "<html><table width=500>" + "<tr><td><b>" + OpenEHRLanguageManager.getMessage("Archetype") + ": </b>" + OpenEHRImageUtil.getImgHTMLTag(archetypeImageName) + " " + archetypeName + "</td></tr>" + "<tr><td><b>" + OpenEHRLanguageManager.getMessage("Description") + ": </b>" + getDescription(airl) + "</td></tr>" + getHTMLPredicate(airl) + "</table></html>"; } else { return "*UNKNOWN*"; } } }