Skip to content

Commit 12cf905

Browse files
committed
auto-create recipients only for probands matching the massmail department
1 parent b7bb082 commit 12cf905

File tree

3 files changed

+25
-15
lines changed

3 files changed

+25
-15
lines changed

core/src/main/java/org/phoenixctms/ctsms/service/massmail/MassMailServiceImpl.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -828,17 +828,20 @@ protected long handlePrepareRecipients(AuthenticationVO auth, Long departmentId)
828828
count++;
829829
}
830830
} else {
831-
MassMailRecipientInVO newMassMailRecipient = new MassMailRecipientInVO();
832-
newMassMailRecipient.setMassMailId(massMail.getId());
833-
newMassMailRecipient.setProbandId(probandId);
834-
newMassMailRecipient.setToken(token);
835-
//try {
836-
ServiceUtil.addMassMailRecipient(newMassMailRecipient, now, user, this.getMassMailDao(), this.getProbandDao(), this.getTrialDao(),
837-
massMailRecipientDao,
838-
this.getJournalEntryDao());
839-
count++;
840-
//} catch (ServiceException e) {
841-
//}
831+
Proband proband = listEntry != null ? listEntry.getProband() : this.getProbandDao().load(probandId);
832+
if (massMail.getDepartment().equals(proband.getDepartment())) {
833+
MassMailRecipientInVO newMassMailRecipient = new MassMailRecipientInVO();
834+
newMassMailRecipient.setMassMailId(massMail.getId());
835+
newMassMailRecipient.setProbandId(probandId);
836+
newMassMailRecipient.setToken(token);
837+
//try {
838+
ServiceUtil.addMassMailRecipient(newMassMailRecipient, now, user, this.getMassMailDao(), this.getProbandDao(), this.getTrialDao(),
839+
massMailRecipientDao,
840+
this.getJournalEntryDao());
841+
count++;
842+
//} catch (ServiceException e) {
843+
//}
844+
}
842845
}
843846
} catch (ServiceException e) {
844847
}

core/src/main/java/org/phoenixctms/ctsms/service/trial/TrialServiceImpl.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,8 +530,11 @@ private ProbandListEntryOutVO addProbandListEntry(ProbandListEntryInVO newProban
530530
Iterator<MassMail> massMailsIt = this.getMassMailDao().findByTrialProbandListStatusTypeLocked(trial.getId(), statusType.getId(), new HashSet<Long>(), false, null)
531531
.iterator();
532532
while (massMailsIt.hasNext()) {
533-
ServiceUtil.addResetMassMailRecipient(massMailsIt.next(), proband, now, user, massMailDao, probandDao, trialDao,
534-
massMailRecipientDao, journalEntryDao);
533+
MassMail massMail = massMailsIt.next();
534+
if (massMail.getDepartment().equals(proband.getDepartment())) {
535+
ServiceUtil.addResetMassMailRecipient(massMail, proband, now, user, massMailDao, probandDao, trialDao,
536+
massMailRecipientDao, journalEntryDao);
537+
}
535538
}
536539
}
537540
}

core/src/main/java/org/phoenixctms/ctsms/util/ServiceUtil.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,12 @@ public static ProbandListStatusEntryOutVO addProbandListStatusEntry(ProbandListS
320320
.iterator();
321321
}
322322
while (massMailsIt.hasNext()) {
323-
addResetMassMailRecipient(massMailsIt.next(), listEntry.getProband(), now, user, massMailDao, probandDao, trialDao,
324-
massMailRecipientDao, journalEntryDao);
323+
MassMail massMail = massMailsIt.next();
324+
Proband proband = listEntry.getProband();
325+
if (massMail.getDepartment().equals(proband.getDepartment())) {
326+
addResetMassMailRecipient(massMail, proband, now, user, massMailDao, probandDao, trialDao,
327+
massMailRecipientDao, journalEntryDao);
328+
}
325329
}
326330
ProbandListStatusEntryOutVO result = probandListStatusEntryDao.toProbandListStatusEntryOutVO(probandListStatusEntry);
327331
if (logProband) {

0 commit comments

Comments
 (0)