Search in sources :

Example 1 with Population

use of org.obiba.mica.study.domain.Population in project mica2 by obiba.

the class Mica310Upgrade method setDefaultWeightForStudyPopulations.

private void setDefaultWeightForStudyPopulations(BaseStudy study) {
    int i = 0;
    for (Population population : study.getPopulations()) {
        population.setWeight(i++);
        setDefaultWeightForPopulationDataCollectionEvents(population);
    }
}
Also used : Population(org.obiba.mica.study.domain.Population)

Example 2 with Population

use of org.obiba.mica.study.domain.Population in project mica2 by obiba.

the class SpecificStudyReportGenerator method writeEachLine.

@Override
protected void writeEachLine(CSVWriter writer) {
    for (String studyId : studyIds) {
        BaseStudy publishedStudy = publishedStudyService.findById(studyId);
        if (publishedStudy != null) {
            List<String> publishedStudyDetails = generatePublishedStudyDetails(publishedStudy);
            Iterator<Population> populationIterator = publishedStudy.getPopulations().iterator();
            if (!populationIterator.hasNext()) {
                writer.writeNext(publishedStudyDetails.toArray(new String[publishedStudyDetails.size()]));
            }
            while (populationIterator.hasNext()) {
                List<String> buildingCompleteLine = new ArrayList<>(publishedStudyDetails);
                Population next = populationIterator.next();
                buildingCompleteLine.addAll(generatePopulationDetails(next));
                writer.writeNext(buildingCompleteLine.toArray(new String[buildingCompleteLine.size()]));
            }
        } else {
            BaseStudy draftStudy = studyService.findStudy(studyId);
            if (draftStudy != null) {
                List<String> lineOfDratStudy = generateDraftStudyDetails(draftStudy);
                writer.writeNext(lineOfDratStudy.toArray(new String[lineOfDratStudy.size()]));
            }
        }
    }
}
Also used : Population(org.obiba.mica.study.domain.Population) LocalizedString(org.obiba.mica.core.domain.LocalizedString) BaseStudy(org.obiba.mica.study.domain.BaseStudy)

Example 3 with Population

use of org.obiba.mica.study.domain.Population in project mica2 by obiba.

the class TestDataCollectionEventSort method test_partial_date_fields.

@Test
public void test_partial_date_fields() {
    Population population = createPopulation("Test Population", createEvent("A", 2010, null, 2020, null), createEvent("A", 1997, 1, 2000, null));
    DataCollectionEvent event = Iterables.get(population.getDataCollectionEvents(), 0);
    assertThat(event.getStart()).isEqualTo(of(1997, 1));
}
Also used : DataCollectionEvent(org.obiba.mica.study.domain.DataCollectionEvent) Population(org.obiba.mica.study.domain.Population) Test(org.junit.Test)

Example 4 with Population

use of org.obiba.mica.study.domain.Population in project mica2 by obiba.

the class TestDataCollectionEventSort method test_study_population_sort_with_duplicate_event_dates.

@Test
public void test_study_population_sort_with_duplicate_event_dates() {
    Study study = new Study();
    study.setId("01234567889");
    study.addPopulation(createPopulation("Population001", createEvent("A", 2010, 1, 2020, 12), createEvent("B", 2014, 1, 2035, 12), createEvent("C", 2010, 1, 2020, 12)));
    Population population = Iterables.get(study.getPopulations(), 0);
    SortedSet<DataCollectionEvent> events = population.getDataCollectionEvents();
    assertThat(events.size()).isEqualTo(3);
    assertThat(Iterables.get(events, 0).getStart()).isEqualTo(of(2010, 1));
    assertThat(Iterables.get(events, 1).getStart()).isEqualTo(of(2010, 1));
}
Also used : Study(org.obiba.mica.study.domain.Study) DataCollectionEvent(org.obiba.mica.study.domain.DataCollectionEvent) Population(org.obiba.mica.study.domain.Population) Test(org.junit.Test)

Example 5 with Population

use of org.obiba.mica.study.domain.Population in project mica2 by obiba.

the class TestDataCollectionEventSort method test_study_population_sort.

@Test
public void test_study_population_sort() {
    Study study = new Study();
    study.setId("01234567889");
    study.addPopulation(createPopulation("Population001", createEvent("A", 2010, 1, 2020, 12), createEvent("A", 2014, 1, 2035, 12)));
    study.addPopulation(createPopulation("Population001", createEvent("A", 1997, 8, 1998, 12), createEvent("A", 1996, 1, 2000, 12)));
    Population population = Iterables.get(study.getPopulations(), 0);
    DataCollectionEvent event = Iterables.get(population.getDataCollectionEvents(), 0);
    assertThat(event.getStart()).isEqualTo(of(1996, 1));
}
Also used : Study(org.obiba.mica.study.domain.Study) DataCollectionEvent(org.obiba.mica.study.domain.DataCollectionEvent) Population(org.obiba.mica.study.domain.Population) Test(org.junit.Test)

Aggregations

Population (org.obiba.mica.study.domain.Population)15 DataCollectionEvent (org.obiba.mica.study.domain.DataCollectionEvent)9 Test (org.junit.Test)7 Study (org.obiba.mica.study.domain.Study)5 BaseStudy (org.obiba.mica.study.domain.BaseStudy)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Collectors.toList (java.util.stream.Collectors.toList)2 NotNull (javax.validation.constraints.NotNull)2 StudyTable (org.obiba.mica.core.domain.StudyTable)2 Strings (com.google.common.base.Strings)1 ImmutableList (com.google.common.collect.ImmutableList)1 Lists (com.google.common.collect.Lists)1 Sets (com.google.common.collect.Sets)1 EventBus (com.google.common.eventbus.EventBus)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1