private ObservedAdverseEventProfile getObservedAdverseEventProfile( Integer termId, Integer tacId, Grade grade) { for (ObservedAdverseEventProfile observedAdverseEventProfile : observedAdverseEventProfiles) { boolean flag = (grade == null && observedAdverseEventProfile.getGrade() == null) || (grade != null && observedAdverseEventProfile.getGrade() != null && grade == observedAdverseEventProfile.getGrade()); if (flag && observedAdverseEventProfile.getTreatmentAssignment().getId().equals(tacId) && observedAdverseEventProfile.getTerm().getId().equals(termId)) { return observedAdverseEventProfile; } } return null; }
public void testGenerateSafetyAlerts() throws Exception { assertEquals(0, observedAdverseEventProfileDao.getAll().size()); safetyMonitoringService.generateSafetyAlerts(); observedAdverseEventProfiles = observedAdverseEventProfileDao.getAll(); for (ObservedAdverseEventProfile observedAdverseEventProfile : observedAdverseEventProfiles) { System.out.println(observedAdverseEventProfile); } assertEquals(6, observedAdverseEventProfiles.size()); ObservedAdverseEventProfile observedAdverseEventProfile = getObservedAdverseEventProfile(-1, -1, Grade.getByCode(1)); assertEquals(20.0, observedAdverseEventProfile.getExpectedFrequency()); assertEquals(0.0, observedAdverseEventProfile.getObservedFrequency()); assertEquals(0, observedAdverseEventProfile.getObservedNoOfAE().intValue()); assertEquals(5, observedAdverseEventProfile.getTotalNoOfRegistrations().intValue()); observedAdverseEventProfile = getObservedAdverseEventProfile(-1, -1, Grade.getByCode(2)); assertEquals(10.0, observedAdverseEventProfile.getExpectedFrequency()); assertEquals(0.0, observedAdverseEventProfile.getObservedFrequency()); assertEquals(0, observedAdverseEventProfile.getObservedNoOfAE().intValue()); assertEquals(5, observedAdverseEventProfile.getTotalNoOfRegistrations().intValue()); observedAdverseEventProfile = getObservedAdverseEventProfile(-1, -1, Grade.getByCode(3)); assertEquals("4.34", format(observedAdverseEventProfile.getExpectedFrequency())); assertEquals(0.0, observedAdverseEventProfile.getObservedFrequency()); assertEquals(0, observedAdverseEventProfile.getObservedNoOfAE().intValue()); assertEquals(5, observedAdverseEventProfile.getTotalNoOfRegistrations().intValue()); observedAdverseEventProfile = getObservedAdverseEventProfile(-1, -1, Grade.getByCode(4)); assertEquals("6.23", format(observedAdverseEventProfile.getExpectedFrequency())); assertEquals(0.0, observedAdverseEventProfile.getObservedFrequency()); assertEquals(0, observedAdverseEventProfile.getObservedNoOfAE().intValue()); assertEquals(5, observedAdverseEventProfile.getTotalNoOfRegistrations().intValue()); observedAdverseEventProfile = getObservedAdverseEventProfile(-1, -1, Grade.getByCode(5)); assertEquals("20.00", format(observedAdverseEventProfile.getExpectedFrequency())); assertEquals("40.00", format(observedAdverseEventProfile.getObservedFrequency())); assertEquals(2, observedAdverseEventProfile.getObservedNoOfAE().intValue()); assertEquals(5, observedAdverseEventProfile.getTotalNoOfRegistrations().intValue()); observedAdverseEventProfile = getObservedAdverseEventProfile(-1, -1, null); assertEquals("60.00", format(observedAdverseEventProfile.getExpectedFrequency())); assertEquals("40.00", format(observedAdverseEventProfile.getObservedFrequency())); assertEquals(2, observedAdverseEventProfile.getObservedNoOfAE().intValue()); assertEquals(5, observedAdverseEventProfile.getTotalNoOfRegistrations().intValue()); }