private void validateFieldsForOutpatientCareSettingType(DrugOrder order, Errors errors) { if (order.getAction() != Order.Action.DISCONTINUE && order.getCareSetting() != null && order.getCareSetting().getCareSettingType().equals(CareSetting.CareSettingType.OUTPATIENT)) { ValidationUtils.rejectIfEmpty(errors, "quantity", "DrugOrder.error.quantityIsNullForOutPatient"); ValidationUtils.rejectIfEmpty(errors, "numRefills", "DrugOrder.error.numRefillsIsNullForOutPatient"); } }
/** * @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; }
order.setEncounter(encounterService.getEncounter(6)); order.setOrderer(providerService.getProvider(1)); order.setCareSetting(existingOrder.getCareSetting()); order.setDosingType(FreeTextDosingInstructions.class); order.setDosingInstructions("2 for 10 days");
/** * @see DrugOrder#cloneForDiscontinuing() */ @Test public void cloneForDiscontinuing_shouldSetAllTheRelevantFields() { DrugOrder order = new DrugOrder(); order.setPatient(new Patient()); order.setCareSetting(new CareSetting()); Drug drug = new Drug(); drug.setConcept(new Concept()); order.setDrug(drug); order.setOrderType(new OrderType()); DrugOrder dcOrder = order.cloneForDiscontinuing(); assertEquals(order.getDrug(), dcOrder.getDrug()); assertEquals(order.getPatient(), dcOrder.getPatient()); assertEquals(order.getConcept(), dcOrder.getConcept()); assertEquals("should set previous order to anOrder", order, dcOrder.getPreviousOrder()); assertEquals("should set new order action to new", dcOrder.getAction(), Order.Action.DISCONTINUE); assertEquals(order.getCareSetting(), dcOrder.getCareSetting()); assertEquals(order.getOrderType(), dcOrder.getOrderType()); }
order.setEncounter(encounterService.getEncounter(17)); order.setOrderer(providerService.getProvider(1)); order.setCareSetting(duplicateOrder.getCareSetting()); order.setDateActivated(newOrderDateActivated); order.setDrug(duplicateOrder.getDrug());
@Override protected void matchStandardRegimenInExistingOrders(FormEntryContext context) { Map<RegimenSuggestion, List<DrugOrder>> map = RegimenUtil1_10.findStrongestStandardRegimenInDrugOrders( possibleRegimens, context.getRemainingExistingOrders()); if (map.size() == 1) { existingStandardRegimen = map.keySet().iterator().next(); for (DrugOrder dor : map.get(existingStandardRegimen)) { regDrugOrders.add(context.removeExistingDrugOrder(dor.getDrug())); regWidget.setInitialValue(existingStandardRegimen.getCodeName()); careSettingWidget.setInitialValue(dor.getCareSetting()); } discontinuedDateWidget.setInitialValue(getCommonDiscontinueDate(regDrugOrders)); Order discontinuationOrder = Context.getOrderService().getDiscontinuationOrder(regDrugOrders.get(0)); if (discontinuedReasonWidget != null && discontinuationOrder != null) discontinuedReasonWidget.setInitialValue(discontinuationOrder.getOrderReason().getConceptId()); } }
/** * @see OrderService#saveOrder(org.openmrs.Order, OrderContext) */ @Test public void saveOrder_shouldThrowAmbiguousOrderExceptionIfAnActiveDrugOrderForTheSameDrugFormulationExists() { executeDataSet("org/openmrs/api/include/OrderServiceTest-drugOrdersWithSameConceptAndDifferentFormAndStrength.xml"); final Patient patient = patientService.getPatient(2); //sanity check that we have an active order for the same concept DrugOrder existingOrder = (DrugOrder) orderService.getOrder(1000); assertTrue(existingOrder.isActive()); //New Drug order DrugOrder order = new DrugOrder(); order.setPatient(patient); order.setDrug(existingOrder.getDrug()); order.setEncounter(encounterService.getEncounter(6)); order.setOrderer(providerService.getProvider(1)); order.setCareSetting(existingOrder.getCareSetting()); order.setDosingType(FreeTextDosingInstructions.class); order.setDosingInstructions("2 for 5 days"); order.setQuantity(10.0); order.setQuantityUnits(conceptService.getConcept(51)); order.setNumRefills(2); expectedException.expect(AmbiguousOrderException.class); expectedException.expectMessage("Order.cannot.have.more.than.one"); orderService.saveOrder(order, null); }
/** * @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()); }
/** * @see OrderService#saveOrder(org.openmrs.Order, OrderContext) */ @Test public void saveOrder_shouldPassIfAnActiveDrugOrderForTheSameConceptAndCareSettingButDifferentFormulationExists() { executeDataSet("org/openmrs/api/include/OrderServiceTest-drugOrdersWithSameConceptAndDifferentFormAndStrength.xml"); final Patient patient = patientService.getPatient(2); //sanity check that we have an active order DrugOrder existingOrder = (DrugOrder) orderService.getOrder(1000); assertTrue(existingOrder.isActive()); //New Drug order DrugOrder order = new DrugOrder(); order.setPatient(patient); order.setConcept(existingOrder.getConcept()); order.setEncounter(encounterService.getEncounter(6)); order.setOrderer(providerService.getProvider(1)); order.setCareSetting(existingOrder.getCareSetting()); order.setDrug(conceptService.getDrug(3001)); order.setDosingType(FreeTextDosingInstructions.class); order.setDosingInstructions("2 for 5 days"); order.setQuantity(10.0); order.setQuantityUnits(conceptService.getConcept(51)); order.setNumRefills(2); Order savedDrugOrder = orderService.saveOrder(order, null); assertNotNull(orderService.getOrder(savedDrugOrder.getOrderId())); }
order.setConcept(orderToDiscontinue.getConcept()); order.setOrderer(orderToDiscontinue.getOrderer()); order.setCareSetting(orderToDiscontinue.getCareSetting()); order.setEncounter(encounterService.getEncounter(6)); order.setDateActivated(new Date());
/** * @see OrderService#saveOrder(org.openmrs.Order, OrderContext, org.openmrs.Order[]) */ @Test public void saveOrder_shouldPassIfAnKnownDrugOrderForTheSameDrugFormulationSpecified() { executeDataSet("org/openmrs/api/include/OrderServiceTest-drugOrdersWithSameConceptAndDifferentFormAndStrength.xml"); final Patient patient = patientService.getPatient(2); //sanity check that we have an active order for the same concept DrugOrder existingOrder = (DrugOrder) orderService.getOrder(1000); assertTrue(existingOrder.isActive()); //New Drug order DrugOrder order = new DrugOrder(); order.setPatient(patient); order.setDrug(existingOrder.getDrug()); order.setEncounter(encounterService.getEncounter(6)); order.setOrderer(providerService.getProvider(1)); order.setCareSetting(existingOrder.getCareSetting()); order.setDosingType(FreeTextDosingInstructions.class); order.setDosingInstructions("2 for 5 days"); order.setQuantity(10.0); order.setQuantityUnits(conceptService.getConcept(51)); order.setNumRefills(2); OrderContext orderContext = new OrderContext(); orderContext.setAttribute(OrderService.PARALLEL_ORDERS, new String[] { existingOrder.getUuid() }); orderService.saveOrder(order, orderContext); assertNotNull(orderService.getOrder(order.getOrderId())); }
secondOrder.setEncounter(encounterService.getEncounter(6)); secondOrder.setOrderer(providerService.getProvider(1)); secondOrder.setCareSetting(firstOrder.getCareSetting()); secondOrder.setDrug(conceptService.getDrug(3)); secondOrder.setDateActivated(new Date());
drugOrder.setEncounter(encounterService.getEncounter(6)); drugOrder.setOrderer(providerService.getProvider(1)); drugOrder.setCareSetting(duplicateOrder.getCareSetting()); drugOrder.setDrug(duplicateOrder.getDrug()); drugOrder.setDose(duplicateOrder.getDose());
careSettingWidget.setInitialValue(lastRevision.getCareSetting().getId());