use of org.openmrs.OrderFrequency in project openmrs-core by openmrs.
the class OrderServiceTest method purgeOrderFrequency_shouldNotAllowDeletingAnOrderFrequencyThatIsInUse.
/**
* @see OrderService#purgeOrderFrequency(OrderFrequency)
*/
@Test
public void purgeOrderFrequency_shouldNotAllowDeletingAnOrderFrequencyThatIsInUse() {
OrderFrequency orderFrequency = orderService.getOrderFrequency(1);
assertNotNull(orderFrequency);
expectedException.expect(CannotDeleteObjectInUseException.class);
expectedException.expectMessage(mss.getMessage("Order.frequency.cannot.delete"));
orderService.purgeOrderFrequency(orderFrequency);
}
use of org.openmrs.OrderFrequency in project openmrs-core by openmrs.
the class OrderServiceTest method purgeOrderFrequency_shouldDeleteGivenOrderFrequency.
@Test
public void purgeOrderFrequency_shouldDeleteGivenOrderFrequency() {
OrderFrequency orderFrequency = orderService.getOrderFrequency(3);
assertNotNull(orderFrequency);
orderService.purgeOrderFrequency(orderFrequency);
orderFrequency = orderService.getOrderFrequency(3);
Assert.assertNull(orderFrequency);
// Should reduce the existing number of order frequencies.
assertEquals(2, orderService.getOrderFrequencies(true).size());
}
use of org.openmrs.OrderFrequency in project openmrs-core by openmrs.
the class OrderServiceTest method unretireOrderFrequency_shouldUnretireGivenOrderFrequency.
@Test
public void unretireOrderFrequency_shouldUnretireGivenOrderFrequency() {
executeDataSet("org/openmrs/api/include/OrderServiceTest-otherOrderFrequencies.xml");
OrderFrequency orderFrequency = orderService.getOrderFrequency(103);
assertNotNull(orderFrequency);
assertTrue(orderFrequency.getRetired());
assertNotNull(orderFrequency.getRetireReason());
assertNotNull(orderFrequency.getDateRetired());
orderService.unretireOrderFrequency(orderFrequency);
orderFrequency = orderService.getOrderFrequency(103);
assertNotNull(orderFrequency);
assertFalse(orderFrequency.getRetired());
assertNull(orderFrequency.getRetireReason());
assertNull(orderFrequency.getDateRetired());
// Should not change the number of order frequencies.
assertEquals(7, orderService.getOrderFrequencies(true).size());
}
use of org.openmrs.OrderFrequency in project openmrs-core by openmrs.
the class OrderServiceTest method getOrderFrequencies_shouldReturnUniqueFrequencies.
/**
* @see OrderService#getOrderFrequencies(String, java.util.Locale, boolean, boolean)
*/
@Test
public void getOrderFrequencies_shouldReturnUniqueFrequencies() {
executeDataSet("org/openmrs/api/include/OrderServiceTest-otherOrderFrequencies.xml");
final String searchPhrase = "once";
final Locale locale = Locale.ENGLISH;
List<OrderFrequency> orderFrequencies = orderService.getOrderFrequencies(searchPhrase, locale, true, false);
assertEquals(1, orderFrequencies.size());
final OrderFrequency expectedOrderFrequency = orderService.getOrderFrequency(100);
assertEquals(expectedOrderFrequency, orderFrequencies.get(0));
// Add a new name to the frequency concept so that our search phrase matches on 2
// concept names for the same frequency concept
Concept frequencyConcept = expectedOrderFrequency.getConcept();
final String newConceptName = searchPhrase + " A Day";
frequencyConcept.addName(new ConceptName(newConceptName, locale));
frequencyConcept.addDescription(new ConceptDescription("some description", null));
conceptService.saveConcept(frequencyConcept);
orderFrequencies = orderService.getOrderFrequencies(searchPhrase, locale, true, false);
assertEquals(1, orderFrequencies.size());
assertEquals(expectedOrderFrequency, orderFrequencies.get(0));
}
Aggregations