RegimenChangeHistory { public List<RegimenChange> getChanges() { return changes; } protected  RegimenChangeHistory(Set<Concept> relevantDrugs, List<DrugOrder> allDrugOrders); static RegimenChangeHistory forPatient(Patient patient, Concept medSet); void undoLastChange(); List<RegimenChange> getChanges(); RegimenChange getLastChange(); RegimenChange getLastChangeBeforeNow(); RegimenChange getLastChangeBeforeDate(Date date);  }
@Test public void constructor_shouldCreateRegimenHistory() throws Exception { List<DrugOrder> allDrugOrders = Arrays.asList(order1, order2, order3, order4); Set<Concept> relevantDrugs = new HashSet<Concept>(Arrays.asList(drug1, drug2, drug3)); RegimenChangeHistory regimenHistory = new RegimenChangeHistory(relevantDrugs, allDrugOrders); List<RegimenChange> changes = regimenHistory.getChanges(); Assert.assertEquals(4, changes.size()); Assert.assertEquals(t0, changes.get(0).getDate()); Assert.assertNull(changes.get(0).getStopped()); EmrTestUtils.assertRegimenContainsDrugOrders(changes.get(0).getStarted(), order1); Assert.assertEquals(t1, changes.get(1).getDate()); Assert.assertSame(changes.get(0).getStarted(), changes.get(1).getStopped()); EmrTestUtils.assertRegimenContainsDrugOrders(changes.get(1).getStarted(), order1, order2); Assert.assertEquals(t2, changes.get(2).getDate()); Assert.assertSame(changes.get(1).getStarted(), changes.get(2).getStopped()); EmrTestUtils.assertRegimenContainsDrugOrders(changes.get(2).getStarted(), order2, order3); Assert.assertEquals(1, changes.get(2).getChangeReasonsNonCoded().size()); Assert.assertEquals(t3, changes.get(3).getDate()); Assert.assertSame(changes.get(2).getStarted(), changes.get(3).getStopped()); EmrTestUtils.assertRegimenContainsDrugOrders(changes.get(3).getStarted(), order3); Assert.assertEquals(0, changes.get(3).getChangeReasons().size()); }