public DrugOrderBuilder withNumRefills(Integer numRefills) { drugOrder.setNumRefills(numRefills); return this; }
@Test public void getAutoExpireDate_shouldNotInferAutoExpireDateWhenDrugOrderHasOneOrMoreRefill() throws ParseException { DrugOrder drugOrder = new DrugOrder(); drugOrder.setDateActivated(createDateTime("2014-07-01 10:00:00")); drugOrder.setDuration(30); drugOrder.setDurationUnits(createUnits(Duration.SNOMED_CT_SECONDS_CODE)); drugOrder.setNumRefills(1); Date autoExpireDate = new SimpleDosingInstructions().getAutoExpireDate(drugOrder); assertEquals(null, autoExpireDate); }
/** * @see DrugOrderValidator#validate(Object, org.springframework.validation.Errors) */ @Test public void validate_shouldFailValidationIfNumberOfRefillsIsNullForOutpatientCareSetting() { DrugOrder OutpatientOrder = new DrugOrder(); OutpatientOrder.setCareSetting(Context.getOrderService().getCareSetting(1)); OutpatientOrder.setNumRefills(null); Errors OutpatientOrderErrors = new BindException(OutpatientOrder, "order"); new DrugOrderValidator().validate(OutpatientOrder, OutpatientOrderErrors); Assert.assertTrue(OutpatientOrderErrors.hasFieldErrors("numRefills")); DrugOrder inPatientOrder = new DrugOrder(); inPatientOrder.setCareSetting(Context.getOrderService().getCareSetting(2)); inPatientOrder.setNumRefills(null); Errors InpatientOrderErrors = new BindException(inPatientOrder, "order"); new DrugOrderValidator().validate(inPatientOrder, InpatientOrderErrors); Assert.assertFalse(InpatientOrderErrors.hasFieldErrors("numRefills")); }
order.setQuantity(2.00); order.setQuantityUnits(Context.getConceptService().getConcept(51)); order.setNumRefills(10);
order.setQuantity(2.00); order.setQuantityUnits(Context.getConceptService().getConcept(51)); order.setNumRefills(10);
order.setQuantity(2.00); order.setQuantityUnits(Context.getConceptService().getConcept(51)); order.setNumRefills(10);
@Test public void saveOrder_shouldSetAutoExpireDateForReviseOrderWithSimpleDosingInstructions() { executeDataSet("org/openmrs/api/include/OrderServiceTest-drugOrderAutoExpireDate.xml"); DrugOrder originalOrder = (DrugOrder) orderService.getOrder(111); assertTrue(originalOrder.isActive()); DrugOrder revisedOrder = originalOrder.cloneForRevision(); revisedOrder.setOrderer(originalOrder.getOrderer()); revisedOrder.setEncounter(originalOrder.getEncounter()); revisedOrder.setNumRefills(0); revisedOrder.setAutoExpireDate(null); revisedOrder.setDuration(10); revisedOrder.setDurationUnits(conceptService.getConcept(1001)); orderService.saveOrder(revisedOrder, null); assertNotNull(revisedOrder.getAutoExpireDate()); }
order.setQuantity(2.00); order.setQuantityUnits(Context.getConceptService().getConcept(51)); order.setNumRefills(10);
order.setQuantity(10.0); order.setQuantityUnits(conceptService.getConcept(51)); order.setNumRefills(2); order.setUrgency(Order.Urgency.ON_SCHEDULED_DATE);
order.setFrequency(orderService.getOrderFrequency(3000)); order.setRoute(conceptService.getConcept(22)); order.setNumRefills(10);
/** * @see org.openmrs.Order#copyHelper(Order) */ protected DrugOrder copyHelper(DrugOrder target) { super.copyHelper(target); target.setDose(getDose()); target.setDoseUnits(getDoseUnits()); target.setFrequency(getFrequency()); target.setAsNeeded(getAsNeeded()); target.setAsNeededCondition(getAsNeededCondition()); target.setQuantity(getQuantity()); target.setQuantityUnits(getQuantityUnits()); target.setDrug(getDrug()); target.setDosingType(getDosingType()); target.setDosingInstructions(getDosingInstructions()); target.setDuration(getDuration()); target.setDurationUnits(getDurationUnits()); target.setNumRefills(getNumRefills()); target.setRoute(getRoute()); target.setBrandName(getBrandName()); target.setDispenseAsWritten(getDispenseAsWritten()); target.setDrugNonCoded(getDrugNonCoded()); return target; }
/** * @see Order#cloneForRevisionHelper(Order) */ protected DrugOrder cloneForRevisionHelper(DrugOrder target) { super.cloneForRevisionHelper(target); target.setDose(getDose()); target.setDoseUnits(getDoseUnits()); target.setFrequency(getFrequency()); target.setAsNeeded(getAsNeeded()); target.setAsNeededCondition(getAsNeededCondition()); target.setQuantity(getQuantity()); target.setQuantityUnits(getQuantityUnits()); target.setDrug(getDrug()); target.setDosingType(getDosingType()); target.setDosingInstructions(getDosingInstructions()); target.setDuration(getDuration()); target.setDurationUnits(getDurationUnits()); target.setRoute(getRoute()); target.setNumRefills(getNumRefills()); target.setBrandName(getBrandName()); target.setDispenseAsWritten(getDispenseAsWritten()); target.setDrugNonCoded(getDrugNonCoded()); return target; }
order.setQuantity(duplicateOrder.getQuantity()); order.setQuantityUnits(duplicateOrder.getQuantityUnits()); order.setNumRefills(duplicateOrder.getNumRefills());
/** * @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 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())); }
/** * @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())); }
order.setQuantity(orderToDiscontinue.getQuantity()); order.setQuantityUnits(orderToDiscontinue.getQuantityUnits()); order.setNumRefills(orderToDiscontinue.getNumRefills());
drugOrder.setQuantity(duplicateOrder.getQuantity()); drugOrder.setQuantityUnits(duplicateOrder.getQuantityUnits()); drugOrder.setNumRefills(duplicateOrder.getNumRefills());
@Test public void saveOrder_shouldSetAutoExpireDateOfDrugOrderIfAutoExpireDateIsNotSet() throws ParseException { executeDataSet("org/openmrs/api/include/OrderServiceTest-drugOrderAutoExpireDate.xml"); Drug drug = conceptService.getDrug(3000); DrugOrder drugOrder = new DrugOrder(); Encounter encounter = encounterService.getEncounter(3); drugOrder.setEncounter(encounter); drugOrder.setPatient(patientService.getPatient(7)); drugOrder.setCareSetting(orderService.getCareSetting(1)); drugOrder.setOrderer(Context.getProviderService().getProvider(1)); drugOrder.setDrug(drug); drugOrder.setDosingType(SimpleDosingInstructions.class); drugOrder.setDose(300.0); drugOrder.setDoseUnits(conceptService.getConcept(50)); drugOrder.setQuantity(20.0); drugOrder.setQuantityUnits(conceptService.getConcept(51)); drugOrder.setFrequency(orderService.getOrderFrequency(3)); drugOrder.setRoute(conceptService.getConcept(22)); drugOrder.setNumRefills(0); drugOrder.setOrderType(null); drugOrder.setDateActivated(TestUtil.createDateTime("2014-08-03")); drugOrder.setDuration(20);// 20 days drugOrder.setDurationUnits(conceptService.getConcept(1001)); Order savedOrder = orderService.saveOrder(drugOrder, null); Order loadedOrder = orderService.getOrder(savedOrder.getId()); Assert.assertEquals(TestUtil.createDateTime("2014-08-22 23:59:59"), loadedOrder.getAutoExpireDate()); }
drugOrder.setFrequency(orderService.getOrderFrequency(3)); drugOrder.setRoute(conceptService.getConcept(22)); drugOrder.setNumRefills(10); drugOrder.setOrderType(null);