/** * @verifies set the relevant fields for a DC order * @see TestOrder#cloneForRevision() */ @Test public void cloneForRevision_shouldSetTheRelevantFieldsForADCOrder() throws Exception { Order order = new TestOrder(); order.setAction(Order.Action.DISCONTINUE); Date date = new Date(); order.setDateActivated(date); order.setAutoExpireDate(date); order.setAccessionNumber("some number"); OrderUtilTest.setDateStopped(order, date); order.setPreviousOrder(new Order()); Order clone = order.cloneForRevision(); assertEquals(Order.Action.DISCONTINUE, clone.getAction()); assertEquals(order.getDateActivated(), clone.getDateActivated()); assertEquals(order.getPreviousOrder(), clone.getPreviousOrder()); assertNull(clone.getAutoExpireDate()); assertNull(clone.getDateStopped()); assertNull(clone.getAccessionNumber()); }
/** * @verifies not require all fields for a discontinuation order * @see DrugOrderValidator#validate(Object, org.springframework.validation.Errors) */ @Test public void validate_shouldNotRequireAllFieldsForADiscontinuationOrder() throws Exception { 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()); }
/** @see {@link OrderValidator#validate(Object,Errors)} */ @Test @Verifies( value = "should fail validation if dateActivated after dateStopped", method = "validate(Object,Errors)") public void validate_shouldFailValidationIfDateActivatedAfterDateStopped() throws Exception { Order order = new Order(); order.setConcept(Context.getConceptService().getConcept(88)); order.setPatient(Context.getPatientService().getPatient(2)); order.setOrderer(Context.getProviderService().getProvider(1)); Calendar cal = Calendar.getInstance(); cal.set(Calendar.DAY_OF_MONTH, cal.get(Calendar.DAY_OF_MONTH) - 1); order.setDateActivated(new Date()); OrderUtilTest.setDateStopped(order, cal.getTime()); Errors errors = new BindException(order, "order"); new OrderValidator().validate(order, errors); Assert.assertTrue(errors.hasFieldErrors("dateActivated")); Assert.assertTrue(errors.hasFieldErrors("dateStopped")); }