@Test public void undoLastChange() { 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); regimenHistory.undoLastChange(); List<RegimenChange> changes = regimenHistory.getChanges(); Assert.assertEquals(3, changes.size()); EmrTestUtils.assertRegimenContainsDrugOrders(changes.get(2).getStarted(), order2, order3); Assert.assertFalse(order2.getDiscontinued()); Assert.assertNull(order2.getDiscontinuedDate()); Assert.assertNull(order2.getDiscontinuedBy()); Assert.assertNull(order2.getDiscontinuedReason()); Assert.assertNull(order2.getDiscontinuedReasonNonCoded()); }
public void undoLastChange() { RegimenChange lastChange = getLastChange(); if (lastChange == null) { return; } if (lastChange.getStarted() != null) { for (DrugOrder order : lastChange.getStarted().getDrugOrders()) { Context.getOrderService().voidOrder(order, "Undoing last regimen change"); } } if (lastChange.getStopped() != null) { for (DrugOrder order : lastChange.getStopped().getDrugOrders()) { order.setDiscontinued(false); order.setDiscontinuedDate(null); order.setDiscontinuedBy(null); order.setDiscontinuedReason(null); order.setDiscontinuedReasonNonCoded(null); Context.getOrderService().saveOrder(order); } } changes.remove(lastChange); }
RegimenChangeHistory { public void undoLastChange() { RegimenChange lastChange = getLastChange(); if (lastChange == null) { return; } if (lastChange.getStarted() != null) { for (DrugOrder order : lastChange.getStarted().getDrugOrders()) { Context.getOrderService().voidOrder(order, "Undoing last regimen change"); } } if (lastChange.getStopped() != null) { for (DrugOrder order : lastChange.getStopped().getDrugOrders()) { order.setDiscontinued(false); order.setDiscontinuedDate(null); order.setDiscontinuedBy(null); order.setDiscontinuedReason(null); order.setDiscontinuedReasonNonCoded(null); Context.getOrderService().saveOrder(order); } } changes.remove(lastChange); } }
RegimenChangeHistory { public void undoLastChange() { RegimenChange lastChange = getLastChange(); if (lastChange == null) { return; } if (lastChange.getStarted() != null) { for (DrugOrder order : lastChange.getStarted().getDrugOrders()) { Context.getOrderService().voidOrder(order, "Undoing last regimen change"); } } if (lastChange.getStopped() != null) { for (DrugOrder order : lastChange.getStopped().getDrugOrders()) { order.setDiscontinued(false); order.setDiscontinuedDate(null); order.setDiscontinuedBy(null); order.setDiscontinuedReason(null); order.setDiscontinuedReasonNonCoded(null); Context.getOrderService().saveOrder(order); } } changes.remove(lastChange); } protected  RegimenChangeHistory(Set<Concept> relevantDrugs, List<DrugOrder> allDrugOrders); }
RegimenChangeHistory { public void undoLastChange() { RegimenChange lastChange = getLastChange(); if (lastChange == null) { return; } if (lastChange.getStarted() != null) { for (DrugOrder order : lastChange.getStarted().getDrugOrders()) { Context.getOrderService().voidOrder(order, "Undoing last regimen change"); } } if (lastChange.getStopped() != null) { for (DrugOrder order : lastChange.getStopped().getDrugOrders()) { order.setDiscontinued(false); order.setDiscontinuedDate(null); order.setDiscontinuedBy(null); order.setDiscontinuedReason(null); order.setDiscontinuedReasonNonCoded(null); Context.getOrderService().saveOrder(order); } } changes.remove(lastChange); } 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); }
RegimenChangeHistory { public void undoLastChange() { RegimenChange lastChange = getLastChange(); if (lastChange == null) { return; } if (lastChange.getStarted() != null) { for (DrugOrder order : lastChange.getStarted().getDrugOrders()) { Context.getOrderService().voidOrder(order, "Undoing last regimen change"); } } if (lastChange.getStopped() != null) { for (DrugOrder order : lastChange.getStopped().getDrugOrders()) { order.setDiscontinued(false); order.setDiscontinuedDate(null); order.setDiscontinuedBy(null); order.setDiscontinuedReason(null); order.setDiscontinuedReasonNonCoded(null); Context.getOrderService().saveOrder(order); } } changes.remove(lastChange); } 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);  }