Пример #1
0
  @Test
  public final void testGetTermSummaries() {
    /* Setup */
    final RiskModel riskModel = createRiskModel("Thoracic 30-day Mortality");
    final float constant = 0.34f;
    riskModel.setConstantTerm(new ConstantTerm(constant));
    final EditRiskModel editRiskModel = EditRiskModel.fromRiskModel(riskModel, fModelService);
    // Constant first, then the Rules and then the rest
    final ImmutableList<ModelTermSummary> expectedSummaries =
        ImmutableList.of(
            new ModelTermSummary("Constant", "", constant),
            new ModelTermSummary(fTestRule.getDisplayName(), "Rule", 6.0f),
            new ModelTermSummary("Age", "Numerical", 2.0f),
            new ModelTermSummary("Functional Status = Independent", "Multi-Select", 3.0f),
            new ModelTermSummary("Functional Status = Partially dependent", "Multi-Select", 3.0f),
            new ModelTermSummary("Functional Status = Totally dependent", "Multi-Select", 3.0f),
            new ModelTermSummary("Procedure", "Procedure (RVU Multiplier)", 1.0f),
            new ModelTermSummary("White Blood Count = WNL", "Discrete Numerical", 4.0f),
            new ModelTermSummary("White Blood Count = >11.0", "Discrete Numerical", 4.0f),
            new ModelTermSummary("White Blood Count is Normal", "Checkbox", 5.0f));

    /* Behavior */
    ImmutableList<ModelTermSummary> actualSummaries =
        editRiskModel.makeTermSummaries(fModelService);

    /* Verification */
    assertEquals(expectedSummaries, actualSummaries);
  }
Пример #2
0
  @Test
  public final void testApplyChanges() throws InvalidIdentifierException {
    final RiskModel riskModel = createRiskModel("Thoracic 30-day Mortality");
    final EditRiskModel editRiskModel = EditRiskModel.fromRiskModel(riskModel, fModelService);
    final ImmutableList<EditModelTerm> newTerms =
        ImmutableList.of(
            EditModelTerm.forConstant(0.23f),
            EditModelTerm.forVariable("dnr", 12.3f),
            EditModelTerm.forRule(SampleModels.ageAndFsRule().getDisplayName(), 0.5f));
    final HashSet<ModelTerm> expectedTerms = new HashSet<>();
    for (final EditModelTerm newTerm : newTerms) {
      expectedTerms.add(newTerm.build(fModelService));
    }

    editRiskModel.setModelName("NewModelName");
    editRiskModel.getTerms().clear();
    editRiskModel.getTerms().addAll(newTerms);

    assertEquals("NewModelName", editRiskModel.getModelName());
    assertEquals(DisplayNameConditions.DISPLAY_NAME_MAX, editRiskModel.getMaxDisplayNameLength());

    editRiskModel.applyChanges(riskModel, fModelService);

    assertEquals("NewModelName", riskModel.getDisplayName());
    assertEquals(expectedTerms, riskModel.getTerms());
  }