Exemple #1
0
  /** TODO make this test use assert statements instead of printing to stdout */
  @Test
  public void shouldObservationRule() {
    LogicService logicService = Context.getLogicService();
    Cohort patients = new Cohort();
    Map<Integer, Result> result = null;

    patients.addMember(2);

    try {
      Result r = logicService.eval(2, new LogicCriteriaImpl("CD4 COUNT"));
      Assert.assertNotNull(r);
      Assert.assertEquals(0, r.size());

      result = logicService.eval(patients, new LogicCriteriaImpl("CD4 COUNT"));
      Assert.assertNotNull(result);

      result = logicService.eval(patients, new LogicCriteriaImpl("CD4 COUNT").lt(170));
      Assert.assertNotNull(result);

      result = logicService.eval(patients, new LogicCriteriaImpl("CD4 COUNT").gt(185));
      Assert.assertNotNull(result);

      result = logicService.eval(patients, new LogicCriteriaImpl("CD4 COUNT").equalTo(190));
      Assert.assertNotNull(result);

      Calendar cal = Calendar.getInstance();
      cal.set(2006, 3, 11);
      result =
          logicService.eval(patients, new LogicCriteriaImpl("CD4 COUNT").before(cal.getTime()));
      Assert.assertNotNull(result);

      result =
          logicService.eval(
              patients, new LogicCriteriaImpl("CD4 COUNT").lt(190).before(cal.getTime()));
      Assert.assertNotNull(result);

      result = logicService.eval(patients, new LogicCriteriaImpl("CD4 COUNT").after(cal.getTime()));
      Assert.assertNotNull(result);

      result = logicService.eval(patients, new LogicCriteriaImpl("CD4 COUNT").last());
      Assert.assertNotNull(result);

      result =
          logicService.eval(
              patients, new LogicCriteriaImpl("CD4 COUNT").last().before(cal.getTime()));
      Assert.assertNotNull(result);

      result = logicService.eval(patients, new LogicCriteriaImpl("CD4 COUNT").not().lt(150));
      Assert.assertNotNull(result);

      result = logicService.eval(patients, new LogicCriteriaImpl("CD4 COUNT").not().not().lt(150));
      Assert.assertNotNull(result);

      patients.addMember(2);
      patients.addMember(3);
      result = logicService.eval(patients, new LogicCriteriaImpl("CD4 COUNT").lt(200));
      Assert.assertNotNull(result);

      patients.addMember(39);
      result =
          logicService.eval(
              patients,
              new LogicCriteriaImpl("PROBLEM ADDED").contains("HUMAN IMMUNODEFICIENCY VIRUS"));
      Assert.assertNotNull(result);

      result = logicService.eval(patients, new LogicCriteriaImpl("CD4 COUNT"));
      Assert.assertNotNull(result);

      result =
          logicService.eval(
              patients, new LogicCriteriaImpl("CD4 COUNT").within(Duration.months(1)));
      Assert.assertNotNull(result);

    } catch (LogicException e) {
      log.error("testObservationRule: Error generated", e);
    }
  }