@Test
 public void getAutoExpireDate_shouldInferAutoExpireDateForAKnownSNOMEDCTDurationUnit()
     throws Exception {
   DrugOrder drugOrder = new DrugOrder();
   drugOrder.setDateActivated(createDateTime("2014-07-01 10:00:00"));
   drugOrder.setDuration(30);
   drugOrder.setDurationUnits(createUnits(Duration.SNOMED_CT_SECONDS_CODE));
   Date autoExpireDate = new SimpleDosingInstructions().getAutoExpireDate(drugOrder);
   assertEquals(createDateTime("2014-07-01 10:00:29"), autoExpireDate);
 }
 @Test
 public void getAutoExpireDate_shouldInferAutoExpireDateForScheduledDrugOrder() throws Exception {
   DrugOrder drugOrder = new DrugOrder();
   drugOrder.setDateActivated(createDateTime("2014-07-01 00:00:00"));
   drugOrder.setScheduledDate(createDateTime("2014-07-05 00:00:00"));
   drugOrder.setUrgency(Order.Urgency.ON_SCHEDULED_DATE);
   drugOrder.setDuration(10);
   drugOrder.setDurationUnits(createUnits(Duration.SNOMED_CT_DAYS_CODE));
   Date autoExpireDate = new SimpleDosingInstructions().getAutoExpireDate(drugOrder);
   assertEquals(createDateTime("2014-07-14 23:59:59"), autoExpireDate);
 }
  @Test
  public void getAutoExpireDate_shouldNotInferAutoExpireDateWhenDurationUnitsDoesNotExist()
      throws Exception {
    DrugOrder drugOrder = new DrugOrder();
    drugOrder.setDateActivated(createDateTime("2014-07-01 10:00:00"));
    drugOrder.setDuration(1);
    drugOrder.setDurationUnits(null);

    Date autoExpireDate = new SimpleDosingInstructions().getAutoExpireDate(drugOrder);

    assertEquals(null, autoExpireDate);
  }
  @Test
  public void
      getAutoExpireDate_shouldNotInferAutoExpireDateWhenConceptMappingOfSourceSNOMEDCTDurationDoesNotExist()
          throws Exception {
    DrugOrder drugOrder = new DrugOrder();
    drugOrder.setDateActivated(createDateTime("2014-07-01 10:00:00"));
    drugOrder.setDuration(30);
    drugOrder.setDurationUnits(createUnits("Other.Source", Duration.SNOMED_CT_HOURS_CODE, null));

    Date autoExpireDate = new SimpleDosingInstructions().getAutoExpireDate(drugOrder);

    assertEquals(null, autoExpireDate);
  }
  @Test
  public void getAutoExpireDate_shouldNotInferAutoExpireDateWhenDrugOrderHasOneOrMoreRefill()
      throws Exception {
    DrugOrder drugOrder = new DrugOrder();
    drugOrder.setDateActivated(createDateTime("2014-07-01 10:00:00"));
    drugOrder.setDuration(30);
    drugOrder.setDurationUnits(createUnits(Duration.SNOMED_CT_SECONDS_CODE));
    drugOrder.setNumRefills(1);

    Date autoExpireDate = new SimpleDosingInstructions().getAutoExpireDate(drugOrder);

    assertEquals(null, autoExpireDate);
  }