congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
ArchetypeReference.getElementInstancesMap
Code IndexAdd Tabnine to your IDE (free)

How to use
getElementInstancesMap
method
in
se.cambio.cds.model.instance.ArchetypeReference

Best Java code snippets using se.cambio.cds.model.instance.ArchetypeReference.getElementInstancesMap (Showing top 20 results out of 315)

origin: org.gdl-lang.gdl-tools/cds-core

public static boolean containsAll(ArchetypeReference ar1, ArchetypeReference ar2) {
  return ar1.getElementInstancesMap().keySet().containsAll(ar2.getElementInstancesMap().keySet());
}
origin: org.gdl-lang.gdl-tools/cds-core

private List<PredicateGeneratedElementInstance> getPredicates(ArchetypeReference archetypeReference) {
  List<PredicateGeneratedElementInstance> predicates = new ArrayList<>();
  for (ElementInstance elementInstance : archetypeReference.getElementInstancesMap().values()) {
    if (elementInstance instanceof PredicateGeneratedElementInstance) {
      PredicateGeneratedElementInstance pgei = (PredicateGeneratedElementInstance) elementInstance;
      predicates.add(pgei);
    }
  }
  return predicates;
}
origin: org.gdl-lang.gdl-tools/cds-core

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;
}
origin: org.gdl-lang.gdl-tools/cds-core

public Set<ElementInstance> getAllElementInstancesByDomain(String idDomain) {
  Set<ElementInstance> elementInstances = new HashSet<>();
  for (ArchetypeReference archetypeReference : getAllArchetypeReferencesByDomain(idDomain)) {
    elementInstances.addAll(archetypeReference.getElementInstancesMap().values());
  }
  return elementInstances;
}
origin: org.gdl-lang.gdl-tools/cds-core

  @Override
  public ArchetypeReference deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
    ArchetypeReference archetypeReference = gson.fromJson(json, ArchetypeReference.class);
    for (ElementInstance elementInstance : archetypeReference.getElementInstancesMap().values()) {
      elementInstance.setArchetypeReference(archetypeReference);
    }
    return archetypeReference;
  }
}
origin: org.gdl-lang.gdl-tools/cds-core

  private int getNumPredicates(ArchetypeReference archetypeReference) {
    int count = 0;
    for (ElementInstance elementInstance : archetypeReference.getElementInstancesMap().values()) {
      if (elementInstance instanceof PredicateGeneratedElementInstance && elementInstance.getDataValue() != null) {
        count++;
      }
    }
    return count;
  }
}
origin: org.gdl-lang.gdl-tools/cds-core

public Collection<ElementInstance> getAllElementInstances() {
  Collection<ElementInstance> elementInstances = new ArrayList<>();
  for (ArchetypeReference ar : getAllArchetypeReferences()) {
    elementInstances.addAll(ar.getElementInstancesMap().values());
  }
  return elementInstances;
}
origin: org.gdl-lang.gdl-tools/cds-core

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);
        }
      }
    }
  }
}
origin: org.gdl-lang.gdl-tools/cds-core

  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();
  }
}
origin: org.gdl-lang.gdl-tools/cds-core

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);
}
origin: org.gdl-lang.gdl-tools/cds-core

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);
}
origin: org.gdl-lang.gdl-tools/cds-core

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;
  }
}
origin: org.gdl-lang.gdl-tools/gdl-graph

private Map<RuleReference, ElementInstance> generateElementInstanceByRuleReferenceMap() {
  Map<RuleReference, ElementInstance> allElementInstancesByRuleReference = new HashMap<>();
  for (Guide guide : guideMap.values()) {
    if (guide.getDefinition() != null) {
      for (ArchetypeBinding archetypeBinding : guide.getDefinition().getArchetypeBindings().values()) {
        ArchetypeReference archetypeReference =
            GuideUtil.getGeneratedArchetypeReference(archetypeBinding, guide.getId());
        for (ElementInstance elementInstance : archetypeReference.getElementInstancesMap().values()) {
          if (elementInstance instanceof GeneratedElementInstance) {
            GeneratedElementInstance generatedElementInstance = (GeneratedElementInstance) elementInstance;
            for (RuleReference ruleReference : generatedElementInstance.getRuleReferences()) {
              allElementInstancesByRuleReference.put(ruleReference, elementInstance);
            }
          }
        }
      }
    }
  }
  return allElementInstancesByRuleReference;
}
origin: org.gdl-lang.gdl-tools/cds-core

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() + "'!");
    }
  }
}
origin: org.gdl-lang.gdl-tools/cds-core

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);
}
origin: org.gdl-lang.gdl-tools/cds-core

boolean matchAndFill(GeneratedArchetypeReference ar1, ArchetypeReference ar2, Map<String, Guide> guideMap, Calendar date) {
  Collection<ElementInstance> emptyElementInstances = new ArrayList<ElementInstance>();
  boolean matches = matches(ar1, ar2, guideMap, date);
  if (!matches) {
    return false;
  } else {
    if (ar2 instanceof GeneratedArchetypeReference) {
      for (String idElement : ar1.getElementInstancesMap().keySet()) {
        ElementInstance ei1 = ar1.getElementInstancesMap().get(idElement);
        ElementInstance ei2 = ar2.getElementInstancesMap().get(idElement);
        if (!(ei1 instanceof PredicateGeneratedElementInstance) && ei2 == null) {
          ei2 = ei1.clone();
          emptyElementInstances.add(ei2);
        }
        if (ei1 instanceof GeneratedElementInstance && ei2 instanceof GeneratedElementInstance) {
          ((GeneratedElementInstance) ei2).getRuleReferences().addAll(((GeneratedElementInstance) ei1).getRuleReferences());
        }
      }
      for (ElementInstance elementInstance : emptyElementInstances) {
        elementInstance.setArchetypeReference(ar2);
      }
    }
  }
  return true;
}
origin: org.gdl-lang.gdl-tools/cds-core

private void filterIsA(
    PredicateGeneratedElementInstance predicate, Collection<ArchetypeReference> ehrArchetypeReferences, boolean negation) {
  final Set<ArchetypeReference> archetypeReferencesToRemove = new HashSet<>();
  final Set<CodePhrase> codePhrases = getCodePhrases(predicate);
  ElementInstance elementInstance;
  for (ArchetypeReference archetypeReference : ehrArchetypeReferences) {
    elementInstance = archetypeReference.getElementInstancesMap().get(predicate.getId());
    if (elementInstance != null && codePhrases != null) {
      CodePhrase codePhrase = getCodePhrase(elementInstance);
      try {
        if (codePhrase != null) {
          if ("local".equalsIgnoreCase(codePhrase.getTerminologyId().name())) {
            filterIsALocalTerminology(negation, archetypeReferencesToRemove, codePhrases, elementInstance, codePhrase);
          } else {
            filterIsAExternalTerminology(negation, archetypeReferencesToRemove, codePhrases, elementInstance, codePhrase);
          }
        } else {
          archetypeReferencesToRemove.add(elementInstance.getArchetypeReference());
        }
      } catch (Exception exception) {
        archetypeReferencesToRemove.add(elementInstance.getArchetypeReference());
        logger.warn("Filter isA ", exception);
      }
    }
  }
  ehrArchetypeReferences.removeAll(archetypeReferencesToRemove);
}
origin: org.gdl-lang.gdl-tools/cds-core

private static PredicateGeneratedElementInstance generateElementInstanceForPredicate(
    ArchetypeReference ar, OperatorKind op, String idElement, DataValue dv,
    Guide guide, DateTime dateTime, boolean resolvePredicates) {
  Collection<RuleReference> previousRuleReferences = new ArrayList<>();
  ElementInstance elementInstance = ar.getElementInstancesMap().get(idElement);
  if (elementInstance instanceof GeneratedElementInstance) {
    GeneratedElementInstance generatedElementInstance = (GeneratedElementInstance) elementInstance;
    previousRuleReferences.addAll(generatedElementInstance.getRuleReferences());
  }
  if (dv != null && guide != null && dateTime != null && resolvePredicates) {
    dv = ElementInstanceCollectionManager.resolvePredicate(dv, op, Collections.singleton(guide), dateTime.toCalendar(Locale.getDefault()));
  }
  PredicateGeneratedElementInstance predicateGeneratedElementInstance = new PredicateGeneratedElementInstanceBuilder()
      .setId(idElement)
      .setDataValue(dv)
      .setArchetypeReference(ar)
      .setOperatorKind(op)
      .createPredicateGeneratedElementInstance();
  predicateGeneratedElementInstance.getRuleReferences().addAll(previousRuleReferences);
  return predicateGeneratedElementInstance;
}
origin: org.gdl-lang.gdl-tools/cds-core

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;
  }
}
origin: org.gdl-lang.gdl-tools/cds-core

private static void compressQueryArchetypeReference(ArchetypeReference arPrev, ArchetypeReference arNew) {
  for (ElementInstance newEI : arNew.getElementInstancesMap().values()) {
    ElementInstance eiAux = arPrev.getElementInstancesMap().get(newEI.getId());
    if (eiAux == null) {
      cloneElementInstanceWithGTCodes(newEI, arPrev, false);
      if (newEI instanceof PredicateGeneratedElementInstance) {
        PredicateGeneratedElementInstance pgeiNew = (PredicateGeneratedElementInstance) newEI;
        ElementInstance prevEI = arPrev.getElementInstancesMap().get(pgeiNew.getId());
        if (prevEI instanceof PredicateGeneratedElementInstance) {
          PredicateGeneratedElementInstance pgeiPrev = (PredicateGeneratedElementInstance) prevEI;
se.cambio.cds.model.instanceArchetypeReferencegetElementInstancesMap

Popular methods of ArchetypeReference

  • getIdDomain
  • getIdTemplate
  • <init>
  • clone
  • getIdArchetype

Popular in Java

  • Parsing JSON documents to java classes using gson
  • putExtra (Intent)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • getSystemService (Context)
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • SocketException (java.net)
    This SocketException may be thrown during socket creation or setting options, and is the superclass
  • Charset (java.nio.charset)
    A charset is a named mapping between Unicode characters and byte sequences. Every Charset can decode
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • List (java.util)
    An ordered collection (also known as a sequence). The user of this interface has precise control ove
  • Stack (java.util)
    Stack is a Last-In/First-Out(LIFO) data structure which represents a stack of objects. It enables u
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now