/** * @see DrugOrder#setAutoExpireDateBasedOnDuration() */ @Test public void setAutoExpireDateBasedOnDuration_shouldNotCalculateForDiscontinueAction() { DrugOrder drugOrder = new DrugOrder(); drugOrder.setAction(Order.Action.DISCONTINUE); Date expectedAutoExpireDate = new Date(); drugOrder.setAutoExpireDate(expectedAutoExpireDate); drugOrder.setAutoExpireDateBasedOnDuration(); assertEquals(expectedAutoExpireDate, drugOrder.getAutoExpireDate()); }
/** * @see org.openmrs.Order#cloneForDiscontinuing() * @should set all the relevant fields * @since 1.10 */ @Override public DrugOrder cloneForDiscontinuing() { DrugOrder newOrder = new DrugOrder(); newOrder.setCareSetting(getCareSetting()); newOrder.setConcept(getConcept()); newOrder.setAction(DISCONTINUE); newOrder.setPreviousOrder(this); newOrder.setPatient(getPatient()); newOrder.setDrug(getDrug()); newOrder.setOrderType(getOrderType()); newOrder.setDrugNonCoded(getDrugNonCoded()); return newOrder; }
/** * @see OrderServiceImpl#discontinueExistingOrdersIfNecessary() */ @Test(expected = AmbiguousOrderException.class) public void saveOrder_shouldThrowAmbiguousOrderExceptionIfDisconnectingMultipleActiveOrdersForTheGivenConcepts() { executeDataSet("org/openmrs/api/include/OrderServiceTest-discontinueAmbiguousOrderByConcept.xml"); DrugOrder order = new DrugOrder(); order.setAction(Order.Action.DISCONTINUE); order.setOrderReasonNonCoded("Discontinue this"); order.setConcept(conceptService.getConcept(88)); order.setEncounter(encounterService.getEncounter(7)); order.setPatient(patientService.getPatient(9)); order.setOrderer(providerService.getProvider(1)); order.setCareSetting(orderService.getCareSetting(1)); order = (DrugOrder) orderService.saveOrder(order, null); }
/** * @see OrderServiceImpl#discontinueExistingOrdersIfNecessary() */ @Test(expected = AmbiguousOrderException.class) public void saveOrder_shouldThrowAmbiguousOrderExceptionIfDisconnectingMultipleActiveDrugOrdersWithTheSameDrug() { executeDataSet("org/openmrs/api/include/OrderServiceTest-ambiguousDrugOrders.xml"); DrugOrder order = new DrugOrder(); order.setAction(Order.Action.DISCONTINUE); order.setOrderReasonNonCoded("Discontinue this"); order.setDrug(conceptService.getDrug(3)); order.setEncounter(encounterService.getEncounter(7)); order.setPatient(patientService.getPatient(9)); order.setOrderer(providerService.getProvider(1)); order.setCareSetting(orderService.getCareSetting(1)); order = (DrugOrder) orderService.saveOrder(order, null); }
orderToDiscontinue.setAction(Action.NEW); orderToDiscontinue.setPatient(Context.getPatientService().getPatient(7)); orderToDiscontinue.setConcept(Context.getConceptService().getConcept(5497));
/** * @see DrugOrderValidator#validate(Object, org.springframework.validation.Errors) */ @Test public void validate_shouldNotRequireAllFieldsForADiscontinuationOrder() { DrugOrder orderToDiscontinue = (DrugOrder) Context.getOrderService().getOrder(111); assertTrue(OrderUtilTest.isActiveOrder(orderToDiscontinue, null)); DrugOrder discontinuationOrder = new DrugOrder(); discontinuationOrder.setDosingType(null); discontinuationOrder.setCareSetting(orderToDiscontinue.getCareSetting()); discontinuationOrder.setConcept(orderToDiscontinue.getConcept()); discontinuationOrder.setAction(Order.Action.DISCONTINUE); discontinuationOrder.setPreviousOrder(orderToDiscontinue); discontinuationOrder.setPatient(orderToDiscontinue.getPatient()); discontinuationOrder.setDrug(orderToDiscontinue.getDrug()); discontinuationOrder.setOrderType(orderToDiscontinue.getOrderType()); discontinuationOrder.setOrderer(Context.getProviderService().getProvider(1)); discontinuationOrder.setEncounter(Context.getEncounterService().getEncounter(3)); Errors errors = new BindException(discontinuationOrder, "order"); new DrugOrderValidator().validate(discontinuationOrder, errors); Assert.assertFalse(errors.hasErrors()); }
order.setDrug(orderToDiscontinue.getDrug()); order.setOrderType(orderService.getOrderTypeByName("Drug order")); order.setAction(Order.Action.DISCONTINUE); order.setOrderReasonNonCoded("Discontinue this"); order.setPatient(orderToDiscontinue.getPatient());
order2.setDuration(20); order2.setDurationUnits(conceptService.getConcept(1001)); order2.setAction(Order.Action.REVISE); order2.setPreviousOrder(order); orderService.saveRetrospectiveOrder(order2, null);
order.setAction(Order.Action.DISCONTINUE); order.setOrderReasonNonCoded("Discontinue this"); order.setDrug(conceptService.getDrug(3));
public void saveOrder_shouldDiscontinueExistingActiveOrderIfNewOrderBeingSavedWithActionToDiscontinue() { DrugOrder order = new DrugOrder(); order.setAction(Order.Action.DISCONTINUE); order.setOrderReasonNonCoded("Discontinue this"); order.setDrug(conceptService.getDrug(3));
@Test public void getDisplayString_shouldNotFailForDcOrder() throws Exception { Drug drug = new Drug(); drug.setName("Aspirin"); DrugOrder order = new DrugOrder(); order.setAction(Order.Action.DISCONTINUE); order.setDrug(drug); String actual = DrugOrderSubclassHandler1_10.getDisplay(order); assertThat(actual, is("(DISCONTINUE) Aspirin")); } }