Example #1
0
 @Test
 public final void testHeight() {
   final DiscreteNumericalVariable heightVar =
       makeDiscreteNumerical("height", ValueRetriever.HEIGHT);
   final Patient patient = SampleCalculations.dummyPatientWithVitals(1);
   verifyRetrievedValue(heightVar, patient, patient.getHeight());
 }
Example #2
0
 @Test
 public final void testWeight6MonthsAgo() {
   final DiscreteNumericalVariable weight6MonthsAgoVar =
       makeDiscreteNumerical("weight6MonthsAgo", ValueRetriever.WEIGHT_6_MONTHS_AGO);
   final Patient patient = SampleCalculations.dummyPatientWithVitals(1);
   verifyRetrievedValue(weight6MonthsAgoVar, patient, patient.getWeight6MonthsAgo());
 }
Example #3
0
  @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());
  }
Example #4
0
  /**
   * 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);
    }
  }
Example #5
0
 @Test
 public final void testBmi() {
   final DiscreteNumericalVariable bmiVar = makeDiscreteNumerical("bmi", ValueRetriever.BMI);
   final Patient patient = SampleCalculations.dummyPatientWithVitals(1);
   verifyRetrievedValue(bmiVar, patient, patient.getBmi());
 }