@Test
  public void testConvertNetworkMetaAnalysis()
      throws Exception, InstantiationException, InvocationTargetException, NoSuchMethodException {
    Domain domain = new DomainImpl();
    ExampleData.initDefaultData(domain);
    String name = "CGI network meta-analysis";
    MetaAnalysisWithStudies ma = d_jaxbConverterTest.buildNetworkMetaAnalysis(name);

    List<Study> studies = new ArrayList<Study>();
    for (org.drugis.addis.entities.data.Study study : ma.d_studies) {
      Study studyEnt = JAXBConvertor.convertStudy(study, domain);
      domain.getStudies().add(studyEnt);
      studies.add(studyEnt);
    }

    TreatmentDefinition combi =
        TreatmentDefinition.createTrivial(
            Arrays.asList(ExampleData.buildDrugFluoxetine(), ExampleData.buildDrugSertraline()));
    TreatmentDefinition parox =
        TreatmentDefinition.createTrivial(ExampleData.buildDrugParoxetine());
    TreatmentDefinition sertr =
        TreatmentDefinition.createTrivial(ExampleData.buildDrugSertraline());
    SortedSet<TreatmentDefinition> alternatives = new TreeSet<TreatmentDefinition>();
    alternatives.add(combi);
    alternatives.add(parox);
    alternatives.add(sertr);
    Map<Study, Map<TreatmentDefinition, Arm>> armMap =
        new HashMap<Study, Map<TreatmentDefinition, Arm>>();
    Map<TreatmentDefinition, Arm> study1map = new HashMap<TreatmentDefinition, Arm>();
    study1map.put(combi, studies.get(0).getArms().get(0));
    study1map.put(sertr, studies.get(0).getArms().get(1));
    armMap.put(studies.get(0), study1map);
    Map<TreatmentDefinition, Arm> study2map = new HashMap<TreatmentDefinition, Arm>();
    study2map.put(parox, studies.get(1).getArms().get(0));
    study2map.put(sertr, studies.get(1).getArms().get(1));
    armMap.put(studies.get(1), study2map);
    Map<TreatmentDefinition, Arm> study3map = new HashMap<TreatmentDefinition, Arm>();
    study3map.put(sertr, studies.get(2).getArms().get(0));
    study3map.put(parox, studies.get(2).getArms().get(1));
    study3map.put(combi, studies.get(2).getArms().get(2));
    armMap.put(studies.get(2), study3map);

    Collections.sort(
        studies); // So the reading *by definition* puts the studies in their natural order
    NetworkMetaAnalysis expected =
        new NetworkMetaAnalysis(
            name,
            ExampleData.buildIndicationDepression(),
            ExampleData.buildEndpointCgi(),
            studies,
            alternatives,
            armMap);

    assertEntityEquals(expected, NetworkMetaAnalysisConverter.load(ma.d_nwma, domain));
    assertEquals(ma.d_nwma, NetworkMetaAnalysisConverter.save(expected));
  }
Exemple #2
0
  @Test
  public void testDependentsIncludeMetaStudies() throws Exception {
    ExampleData.initDefaultData(d_domain);
    List<Study> studies = new ArrayList<Study>();
    studies.add(ExampleData.buildStudyChouinard());
    studies.add(ExampleData.buildStudyDeWilde());
    RandomEffectsMetaAnalysis ma =
        ExampleData.buildRandomEffectsMetaAnalysis(
            "meta",
            ExampleData.buildEndpointHamd(),
            studies,
            TreatmentDefinition.createTrivial(ExampleData.buildDrugFluoxetine()),
            TreatmentDefinition.createTrivial(ExampleData.buildDrugParoxetine()));
    d_domain.getMetaAnalyses().add(ma);

    Set<Entity> deps = d_domain.getDependents(ExampleData.buildDrugFluoxetine());
    assertTrue(deps.contains(ma));
  }