IsHypertensionDetectedRule implements IRule { @Override public boolean apply(SafeMap reportFields) { return ((IntegerUtil.tryParse(reportFields.get(BP_DIASTOLIC), 0) >= BP_DIASTOLIC_THRESHOLD_VALUE) || (IntegerUtil.tryParse(reportFields.get(BP_SYSTOLIC), 0) >= BP_SYSTOLIC_THRESHOLD_VALUE)); }  @Override boolean apply(SafeMap reportFields);  }
@Test public void shouldReturnTrueWhenHyperTensionDetected() { Map<String, String> reportFields = create("id", "mother id 1") .put("bpSystolic","140") .put("bpDiastolic", "90") .map(); assertTrue(isHypertensionDetectedRule.apply(new SafeMap(reportFields))); reportFields = create("id", "mother id 1") .put("bpSystolic","145") .put("bpDiastolic", "70") .map(); assertTrue(isHypertensionDetectedRule.apply(new SafeMap(reportFields))); reportFields = create("id", "mother id 1") .put("bpSystolic","120") .put("bpDiastolic", "90") .map(); assertTrue(isHypertensionDetectedRule.apply(new SafeMap(reportFields))); }
@Test public void shouldReturnFalseWhenHyperTensionDetected() { Map<String, String> reportFields = create("id", "mother id 1") .put("bpSystolic", "125") .put("bpDiastolic", "80") .map(); assertFalse(isHypertensionDetectedRule.apply(new SafeMap(reportFields))); }