use of org.openmrs.Provider in project openmrs-core by openmrs.
the class OrderServiceTest method discontinueOrder_shouldPassForAnActiveOrderWhichIsScheduledAndNotStartedAsOfDiscontinueDate.
/**
* @see OrderService#discontinueOrder(Order,String,Date,Provider,Encounter)
*/
@Test
public void discontinueOrder_shouldPassForAnActiveOrderWhichIsScheduledAndNotStartedAsOfDiscontinueDate() {
Order order = new Order();
order.setAction(Action.NEW);
order.setPatient(Context.getPatientService().getPatient(7));
order.setConcept(Context.getConceptService().getConcept(5497));
order.setCareSetting(orderService.getCareSetting(1));
order.setOrderer(orderService.getOrder(1).getOrderer());
order.setEncounter(encounterService.getEncounter(3));
order.setEncounter(encounterService.getEncounter(3));
order.setOrderType(orderService.getOrderType(17));
order.setDateActivated(new Date());
order.setScheduledDate(DateUtils.addMonths(new Date(), 2));
order.setUrgency(Order.Urgency.ON_SCHEDULED_DATE);
order = orderService.saveOrder(order, null);
assertTrue(OrderUtilTest.isActiveOrder(order, null));
assertFalse(order.isStarted());
Encounter encounter = encounterService.getEncounter(3);
Provider orderer = providerService.getProvider(1);
Date discontinueDate = new Date();
String discontinueReasonNonCoded = "Test if I can discontinue this";
Order discontinueOrder = orderService.discontinueOrder(order, discontinueReasonNonCoded, discontinueDate, orderer, encounter);
Assert.assertEquals(order.getDateStopped(), discontinueDate);
Assert.assertNotNull(discontinueOrder);
Assert.assertNotNull(discontinueOrder.getId());
Assert.assertEquals(discontinueOrder.getDateActivated(), discontinueOrder.getAutoExpireDate());
Assert.assertEquals(discontinueOrder.getAction(), Action.DISCONTINUE);
Assert.assertEquals(discontinueOrder.getOrderReasonNonCoded(), discontinueReasonNonCoded);
Assert.assertEquals(discontinueOrder.getPreviousOrder(), order);
}
use of org.openmrs.Provider in project openmrs-core by openmrs.
the class OrderServiceTest method discontinueOrder_shouldPopulateCorrectAttributesOnTheDiscontinueAndDiscontinuedOrders.
/**
* @see OrderService#discontinueOrder(org.openmrs.Order, String, java.util.Date,
* org.openmrs.Provider, org.openmrs.Encounter)
*/
@Test
public void discontinueOrder_shouldPopulateCorrectAttributesOnTheDiscontinueAndDiscontinuedOrders() {
Order order = orderService.getOrderByOrderNumber("111");
Encounter encounter = encounterService.getEncounter(3);
Provider orderer = providerService.getProvider(1);
assertTrue(OrderUtilTest.isActiveOrder(order, null));
Date discontinueDate = new Date();
String discontinueReasonNonCoded = "Test if I can discontinue this";
Order discontinueOrder = orderService.discontinueOrder(order, discontinueReasonNonCoded, discontinueDate, orderer, encounter);
Assert.assertEquals(order.getDateStopped(), discontinueDate);
Assert.assertNotNull(discontinueOrder);
Assert.assertNotNull(discontinueOrder.getId());
Assert.assertEquals(discontinueOrder.getDateActivated(), discontinueOrder.getAutoExpireDate());
Assert.assertEquals(discontinueOrder.getAction(), Action.DISCONTINUE);
Assert.assertEquals(discontinueOrder.getOrderReasonNonCoded(), discontinueReasonNonCoded);
Assert.assertEquals(discontinueOrder.getPreviousOrder(), order);
}
use of org.openmrs.Provider in project openmrs-core by openmrs.
the class OrderServiceTest method discontinueOrder_shouldPassForAnActiveOrderWhichIsScheduledAndNotStartedAsOfDiscontinueDateWithParamConcept.
/**
* @see OrderService#discontinueOrder(Order,Concept,Date,Provider,Encounter)
*/
@Test
public void discontinueOrder_shouldPassForAnActiveOrderWhichIsScheduledAndNotStartedAsOfDiscontinueDateWithParamConcept() {
Order order = new Order();
order.setAction(Action.NEW);
order.setPatient(Context.getPatientService().getPatient(7));
order.setConcept(Context.getConceptService().getConcept(5497));
order.setCareSetting(orderService.getCareSetting(1));
order.setOrderer(orderService.getOrder(1).getOrderer());
order.setEncounter(encounterService.getEncounter(3));
order.setEncounter(encounterService.getEncounter(3));
order.setOrderType(orderService.getOrderType(17));
order.setDateActivated(new Date());
order.setScheduledDate(DateUtils.addMonths(new Date(), 2));
order.setUrgency(Order.Urgency.ON_SCHEDULED_DATE);
order = orderService.saveOrder(order, null);
assertTrue(OrderUtilTest.isActiveOrder(order, null));
assertFalse(order.isStarted());
Encounter encounter = encounterService.getEncounter(3);
Provider orderer = providerService.getProvider(1);
Date discontinueDate = new Date();
Concept concept = Context.getConceptService().getConcept(1);
Order discontinueOrder = orderService.discontinueOrder(order, concept, discontinueDate, orderer, encounter);
Assert.assertEquals(order.getDateStopped(), discontinueDate);
Assert.assertNotNull(discontinueOrder);
Assert.assertNotNull(discontinueOrder.getId());
Assert.assertEquals(discontinueOrder.getDateActivated(), discontinueOrder.getAutoExpireDate());
Assert.assertEquals(discontinueOrder.getAction(), Action.DISCONTINUE);
Assert.assertEquals(discontinueOrder.getOrderReason(), concept);
Assert.assertEquals(discontinueOrder.getPreviousOrder(), order);
}
use of org.openmrs.Provider in project openmrs-core by openmrs.
the class OrderServiceTest method discontinueOrder_shouldSetCorrectAttributesOnTheDiscontinueAndDiscontinuedOrders.
/**
* @see OrderService#discontinueOrder(org.openmrs.Order, org.openmrs.Concept, java.util.Date,
* org.openmrs.Provider, org.openmrs.Encounter)
*/
@Test
public void discontinueOrder_shouldSetCorrectAttributesOnTheDiscontinueAndDiscontinuedOrders() {
executeDataSet("org/openmrs/api/include/OrderServiceTest-discontinueReason.xml");
Order order = orderService.getOrderByOrderNumber("111");
Encounter encounter = encounterService.getEncounter(3);
Provider orderer = providerService.getProvider(1);
Date discontinueDate = new Date();
Concept concept = Context.getConceptService().getConcept(1);
Order discontinueOrder = orderService.discontinueOrder(order, concept, discontinueDate, orderer, encounter);
Assert.assertEquals(order.getDateStopped(), discontinueDate);
Assert.assertNotNull(discontinueOrder);
Assert.assertNotNull(discontinueOrder.getId());
Assert.assertEquals(discontinueOrder.getDateActivated(), discontinueOrder.getAutoExpireDate());
Assert.assertEquals(discontinueOrder.getAction(), Action.DISCONTINUE);
Assert.assertEquals(discontinueOrder.getOrderReason(), concept);
Assert.assertEquals(discontinueOrder.getPreviousOrder(), order);
}
use of org.openmrs.Provider in project openmrs-core by openmrs.
the class ProviderValidatorTest method validate_shouldAcceptADuplicateIdentifierForANewProviderWhichIsNotRetired.
/**
* @see ProviderValidator#validate(Object, Errors)
*/
@Test
public void validate_shouldAcceptADuplicateIdentifierForANewProviderWhichIsNotRetired() {
Provider duplicateProvider = providerService.getProvider(1);
Assert.assertFalse(duplicateProvider.getRetired());
Provider provider = new Provider();
provider.setIdentifier(duplicateProvider.getIdentifier());
providerValidator.validate(provider, errors);
Assert.assertFalse(errors.hasFieldErrors("identifier"));
}
Aggregations