コード例 #1
0
ファイル: ValueRetrieverTest.java プロジェクト: jswesky/ASRCM
 /**
  * Constructs a {@link VariableEntry} with retrieved values from the given patient and asserts
  * that it contains the expected dynamic values.
  */
 private void verifyRetrievedValue(
     final Collection<? extends Variable> vars,
     final Patient patient,
     final Map<String, String> expectedValues) {
   final VariableEntry actualVariableEntry = VariableEntry.withRetrievedValues(vars, patient);
   assertEquals(expectedValues, actualVariableEntry.getDynamicValues());
 }
コード例 #2
0
ファイル: ValueRetrieverTest.java プロジェクト: jswesky/ASRCM
  /**
   * A simplification of the above {@link #verifyRetrievedValue(Collection, Patient, Map)} to
   * facilitate testing with a {@link RetrievedValue} object.
   */
  private void verifyRetrievedValue(
      final DiscreteNumericalVariable var,
      final Patient patient,
      final RetrievedValue retrievedValue) {
    final Collection<DiscreteNumericalVariable> vars = ImmutableSet.of(var);
    // Use VariableEntry to generate the expected dynamic values.
    final VariableEntry expected =
        new VariableEntry(vars)
            .putRetrievedValue(VariableEntry.makeNumericalInputName(var.getKey()), retrievedValue);

    verifyRetrievedValue(vars, patient, expected.getDynamicValues());
  }
コード例 #3
0
ファイル: ValueRetrieverTest.java プロジェクト: jswesky/ASRCM
  @Test
  public final void testWithRetrievedLabs() {
    final List<AbstractVariable> vars = new ArrayList<AbstractVariable>();
    final Patient patient = SampleCalculations.dummyPatientWithLabs(1);

    // Note that vars is empty at this point.
    final VariableEntry expected = new VariableEntry(vars);

    addAllLabs(expected, vars, patient);
    final VariableEntry entry = VariableEntry.withRetrievedValues(vars, patient);
    assertEquals(expected.getDynamicValues(), entry.getDynamicValues());
  }
コード例 #4
0
ファイル: ValueRetrieverTest.java プロジェクト: jswesky/ASRCM
  @Test
  public final void testCardiacAge() {
    final DiscreteNumericalVariable var = SampleModels.cardiacAgeVariable();
    final Patient patient = SampleCalculations.dummyPatientWithVitals(1);
    final Collection<DiscreteNumericalVariable> vars = ImmutableSet.of(var);
    // Use VariableEntry to generate the expected dynamic values.
    final VariableEntry expected =
        new VariableEntry(vars)
            .putDynamicValue(
                VariableEntry.makeNumericalInputName(var.getKey()),
                String.valueOf(patient.getAge()));

    verifyRetrievedValue(vars, patient, expected.getDynamicValues());
  }
コード例 #5
0
ファイル: ValueRetrieverTest.java プロジェクト: jswesky/ASRCM
  /**
   * This method adds all of the necessary information for the lab variables to the expected map so
   * the values can be compared later.
   *
   * @param expected [out] to populate expected dynamic values
   * @param vars [out] a list of AbstractVariables needed for the calculation
   * @param patient the patient for the current calculation
   */
  private void addAllLabs(
      final VariableEntry expected, final List<AbstractVariable> vars, final Patient patient) {
    for (final String key : LAB_MAP.keySet()) {
      // Warning: semantic coupling. Simluate what VariableEntry would do if we
      // constructed it using the variable list.
      expected.putDynamicValue(key, VariableEntry.SPECIAL_NUMERICAL);
      final ValueRetriever retriever = LAB_MAP.get(key);
      vars.add(makeDiscreteNumerical(key, retriever));
      final RetrievedValue labValue = patient.getLabs().get(VistaLabs.valueOf(retriever.name()));

      final String inputKey = VariableEntry.makeNumericalInputName(key);
      expected.putRetrievedValue(inputKey, labValue);
    }
  }