Skip to content

Commit

Permalink
TRUNK-5375: New Core 2.1 Cohort module significantly slows down Cohor…
Browse files Browse the repository at this point in the history
…t manipulation
  • Loading branch information
mogoodrich committed Mar 22, 2018
1 parent 73fb6cf commit 0d57bdf
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions api/src/main/java/org/openmrs/Cohort.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
*/
package org.openmrs;

import org.apache.commons.lang3.StringUtils;

import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.Set;
import java.util.TreeSet;
import java.util.stream.Collectors;

import org.apache.commons.lang3.StringUtils;

/**
* This class represents a list of patientIds.
*/
Expand Down Expand Up @@ -160,7 +160,7 @@ public boolean addMember(Integer memberId) {
* @since 2.1.0
*/
public boolean addMembership(CohortMembership cohortMembership) {
if (cohortMembership != null && !this.contains(cohortMembership.getPatientId())) {
if (cohortMembership != null) {
cohortMembership.setCohort(this);
return getMemberships().add(cohortMembership);
}
Expand Down Expand Up @@ -338,11 +338,8 @@ public Set<Integer> getMemberIds() {
@Deprecated
public void setMemberIds(Set<Integer> memberIds) {
if (getMemberships().size() == 0) {
Date startDate = new Date();
for (Integer id : memberIds) {
CohortMembership membership = new CohortMembership(id, startDate);
membership.setCohort(this);
getMemberships().add(membership);
addMembership(new CohortMembership(id));
}
}
else {
Expand Down

0 comments on commit 0d57bdf

Please sign in to comment.