Esempio n. 1
0
 @Test
 public void testAddParticipatingSitesNull() {
   assertTrue(validTrial.getParticipatingSites().isEmpty());
   validTrial.addParticipatingSite(null);
   validTrial.addParticipatingSite(null);
   assertEquals(0, validTrial.getParticipatingSites().size());
   assertValid(validTrial);
 }
Esempio n. 2
0
  @Test
  public void testStrataNamesAndIdsStrataTrialSite() {

    TrialSite site1 = new TrialSite();
    site1.setId(1);
    site1.setName("site1");

    TrialSite site2 = new TrialSite();
    site2.setId(2);
    site2.setName("site2");

    TrialSite site3 = new TrialSite();
    site3.setId(3);
    site3.setName("site3");

    TrialSite site4 = new TrialSite();
    site4.setId(4);
    site4.setName("site4");

    validTrial.addParticipatingSite(site1);
    validTrial.addParticipatingSite(site2);
    validTrial.addParticipatingSite(site3);
    validTrial.addParticipatingSite(site4);

    validTrial.setStratifyTrialSite(true);

    Pair<List<String>, List<String>> pair = validTrial.getAllStrataIdsAndNames();

    assertEquals(4, pair.first().size());
    assertEquals(4, pair.last().size());

    Collections.sort(pair.first());
    assertEquals("1__", pair.first().get(0));
    assertEquals("2__", pair.first().get(1));
    assertEquals("3__", pair.first().get(2));
    assertEquals("4__", pair.first().get(3));

    Collections.sort(pair.last());
    assertEquals("site1", pair.last().get(0));
    assertEquals("site2", pair.last().get(1));
    assertEquals("site3", pair.last().get(2));
    assertEquals("site4", pair.last().get(3));
  }
Esempio n. 3
0
 @Test
 public void testAddParticipatingSitesCorrect() {
   assertTrue(validTrial.getParticipatingSites().isEmpty());
   TrialSite[] validValues = {
     factory.getTrialSite(),
     factory.getTrialSite(),
     factory.getTrialSite(),
     factory.getTrialSite(),
     factory.getTrialSite()
   };
   for (int i = 0; i < validValues.length; i++) {
     validTrial.addParticipatingSite(validValues[i]);
     assertEquals(i + 1, validTrial.getParticipatingSites().size());
     assertTrue(validTrial.getParticipatingSites().contains(validValues[i]));
     assertValid(validTrial);
   }
 }
Esempio n. 4
0
  @Test
  public void testStrataNamesAndIdsStrataCriterionsTrialSite() {

    TrialSite site1 = new TrialSite();
    site1.setId(1);
    site1.setName("site1");

    TrialSite site2 = new TrialSite();
    site2.setId(2);
    site2.setName("site2");

    validTrial.addParticipatingSite(site1);
    validTrial.addParticipatingSite(site2);

    validTrial.setStratifyTrialSite(true);

    DichotomousCriterion criterion1 = new DichotomousCriterion();
    criterion1.setId(1);
    criterion1.setName("criterion1");
    criterion1.setOption1("option1");
    criterion1.setOption2("option2");
    try {
      DichotomousConstraint d1 = new DichotomousConstraint(Arrays.asList(new String[] {"option1"}));
      d1.setId(1);
      criterion1.addStrata(d1);
      DichotomousConstraint d2 = new DichotomousConstraint(Arrays.asList(new String[] {"option2"}));
      d2.setId(2);
      criterion1.addStrata(d2);
    } catch (ContraintViolatedException e) {
      fail();
    }
    DichotomousCriterion criterion2 = new DichotomousCriterion();
    criterion2.setId(2);
    criterion2.setName("criterion2");
    criterion2.setOption1("option1");
    criterion2.setOption2("option2");
    try {
      DichotomousConstraint d1 = new DichotomousConstraint(Arrays.asList(new String[] {"option1"}));
      d1.setId(1);
      criterion2.addStrata(d1);
      DichotomousConstraint d2 = new DichotomousConstraint(Arrays.asList(new String[] {"option2"}));
      d2.setId(2);
      criterion2.addStrata(d2);
    } catch (ContraintViolatedException e) {
      fail();
    }
    validTrial.addCriterion(criterion1);
    validTrial.addCriterion(criterion2);

    Pair<List<String>, List<String>> pair = validTrial.getAllStrataIdsAndNames();

    assertEquals(8, pair.first().size());
    assertEquals(8, pair.last().size());

    Collections.sort(pair.first());
    assertEquals("1__1_1;2_1;", pair.first().get(0));
    assertEquals("1__1_1;2_2;", pair.first().get(1));
    assertEquals("1__1_2;2_1;", pair.first().get(2));
    assertEquals("1__1_2;2_2;", pair.first().get(3));
    assertEquals("2__1_1;2_1;", pair.first().get(4));
    assertEquals("2__1_1;2_2;", pair.first().get(5));
    assertEquals("2__1_2;2_1;", pair.first().get(6));
    assertEquals("2__1_2;2_2;", pair.first().get(7));

    Collections.sort(pair.last());
    assertEquals("site1 | criterion1_option1;criterion2_option1;", pair.last().get(0));
    assertEquals("site1 | criterion1_option1;criterion2_option2;", pair.last().get(1));
    assertEquals("site1 | criterion1_option2;criterion2_option1;", pair.last().get(2));
    assertEquals("site1 | criterion1_option2;criterion2_option2;", pair.last().get(3));
    assertEquals("site2 | criterion1_option1;criterion2_option1;", pair.last().get(4));
    assertEquals("site2 | criterion1_option1;criterion2_option2;", pair.last().get(5));
    assertEquals("site2 | criterion1_option2;criterion2_option1;", pair.last().get(6));
    assertEquals("site2 | criterion1_option2;criterion2_option2;", pair.last().get(7));
  }
Esempio n. 5
0
  private void randomizeInValidTrialTwoTrialSites31()
      throws IllegalArgumentException, TrialStateException {
    authenticatAsAdmin();
    Person cp1 = new Person();
    cp1.setFirstname("Contact");
    cp1.setSurname("Person");
    cp1.setEmail("*****@*****.**");
    cp1.setPhone("1234567");
    cp1.setSex(Gender.MALE);
    TrialSite trialSite1 = new TrialSite();
    trialSite1.setCity("Heidelberg");
    trialSite1.setCountry("Germany");
    trialSite1.setName("NCT");
    trialSite1.setPostcode("69120");
    trialSite1.setStreet("INF");
    trialSite1.setPassword("1$heidelberg");
    trialSite1.setContactPerson(cp1);
    trialSiteService.create(trialSite1);

    Person cp2 = new Person();
    cp2.setFirstname("Contact");
    cp2.setSurname("Person");
    cp2.setEmail("*****@*****.**");
    cp2.setPhone("1234567");
    cp2.setSex(Gender.MALE);
    TrialSite trialSite2 = new TrialSite();
    trialSite2.setCity("Heidelberg");
    trialSite2.setCountry("Germany");
    trialSite2.setName("NCT2");
    trialSite2.setPostcode("69120");
    trialSite2.setStreet("INF");
    trialSite2.setPassword("1$heidelberg");
    trialSite2.setContactPerson(cp2);
    trialSiteService.create(trialSite2);

    validTrial.addParticipatingSite(trialSite1);
    validTrial.addParticipatingSite(trialSite2);
    validTrial.setStartDate(new GregorianCalendar(2009, 0, 1));
    validTrial.setEndDate(new GregorianCalendar(2009, 11, 1));

    authenticatAsPrincipalInvestigator();
    int blocksize = 4;
    int randomizations = 120;
    TreatmentArm arm1 = new TreatmentArm();
    arm1.setPlannedSubjects(randomizations / 2);
    arm1.setName("arm1");
    arm1.setTrial(validTrial);
    TreatmentArm arm2 = new TreatmentArm();
    arm2.setPlannedSubjects(randomizations / 2);
    arm2.setName("arm2");
    arm2.setTrial(validTrial);
    List<TreatmentArm> arms = new ArrayList<TreatmentArm>();
    arms.add(arm1);
    arms.add(arm2);

    trialService.create(validTrial);
    validTrial.setTreatmentArms(arms);
    BlockRandomizationConfig config = new BlockRandomizationConfig();
    config.setMaximum(blocksize);
    config.setMinimum(blocksize);
    validTrial.setRandomizationConfiguration(config);
    trialService.update(validTrial);
    assertTrue(validTrial.getId() > 0);
    assertEquals(2, validTrial.getTreatmentArms().size());
    Iterator<TrialSite> it = validTrial.getParticipatingSites().iterator();
    TrialSite site1 = it.next();
    TrialSite site2 = it.next();
    authenticatAsInvestigator();
    for (int i = 0; i < randomizations; i++) {
      TrialSubject subject = new TrialSubject();
      subject.setIdentification("identification" + i);
      if (i < 90) {
        subject.setTrialSite(site1);
      } else {
        subject.setTrialSite(site2);
      }
      trialService.randomize(validTrial, subject);
      subject.setCreatedAt(new GregorianCalendar(2009, i % 12, 1));
      sessionFactory.getCurrentSession().update(subject);
      if ((i % blocksize) == (blocksize - 1)) {
        assertEquals(
            validTrial.getTreatmentArms().get(0).getSubjects().size(),
            validTrial.getTreatmentArms().get(1).getSubjects().size());
      }

      int diff =
          validTrial.getTreatmentArms().get(0).getSubjects().size()
              - validTrial.getTreatmentArms().get(1).getSubjects().size();
      assertTrue((blocksize / 2) >= diff && (-1) * (blocksize / 2) <= diff);
    }

    Trial dbTrial = trialService.getObject(validTrial.getId());
    assertNotNull(dbTrial);
    assertEquals(validTrial.getName(), dbTrial.getName());
    assertEquals(2, dbTrial.getTreatmentArms().size());
    assertEquals(
        randomizations,
        dbTrial.getTreatmentArms().get(0).getSubjects().size()
            + dbTrial.getTreatmentArms().get(1).getSubjects().size());
    assertEquals(randomizations / 2, dbTrial.getTreatmentArms().get(0).getSubjects().size());
    assertEquals(randomizations / 2, dbTrial.getTreatmentArms().get(1).getSubjects().size());
  }