@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));
  }
예제 #2
0
  private int createArmSelect(
      PanelBuilder builder,
      int row,
      final Study curStudy,
      TreatmentDefinition def,
      CellConstraints cc) {
    builder.addLabel(def.getLabel(), cc.xy(2, row));

    ListModel arms = d_pm.getArmsPerStudyPerDefinition(curStudy, def);

    final JComboBox drugBox =
        AuxComponentFactory.createBoundComboBox(
            arms, d_pm.getSelectedArmModel(curStudy, def), true);
    if (arms.getSize() == 1) drugBox.setEnabled(false);
    final JPanel drugAndDosePanel = new JPanel(new BorderLayout());

    builder.add(drugBox, cc.xy(4, row));
    drugBox.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            updateDrugAndDoseLabel(curStudy, drugBox, drugAndDosePanel);
          }
        });
    row = LayoutUtil.addRow(builder.getLayout(), row);
    updateDrugAndDoseLabel(curStudy, drugBox, drugAndDosePanel);
    builder.add(drugAndDosePanel, cc.xy(4, row));

    return LayoutUtil.addRow(builder.getLayout(), row);
  }
예제 #3
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));
  }