Search in sources :

Example 1 with Provider

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);
}
Also used : DrugOrder(org.openmrs.DrugOrder) TestOrder(org.openmrs.TestOrder) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) Order(org.openmrs.Order) Encounter(org.openmrs.Encounter) Date(java.util.Date) Provider(org.openmrs.Provider) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) OrderUtilTest(org.openmrs.order.OrderUtilTest) Test(org.junit.Test)

Example 2 with Provider

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);
}
Also used : DrugOrder(org.openmrs.DrugOrder) TestOrder(org.openmrs.TestOrder) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) Order(org.openmrs.Order) Encounter(org.openmrs.Encounter) Date(java.util.Date) Provider(org.openmrs.Provider) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) OrderUtilTest(org.openmrs.order.OrderUtilTest) Test(org.junit.Test)

Example 3 with Provider

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);
}
Also used : DrugOrder(org.openmrs.DrugOrder) TestOrder(org.openmrs.TestOrder) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) Order(org.openmrs.Order) Concept(org.openmrs.Concept) Encounter(org.openmrs.Encounter) Date(java.util.Date) Provider(org.openmrs.Provider) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) OrderUtilTest(org.openmrs.order.OrderUtilTest) Test(org.junit.Test)

Example 4 with Provider

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);
}
Also used : DrugOrder(org.openmrs.DrugOrder) TestOrder(org.openmrs.TestOrder) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) Order(org.openmrs.Order) Concept(org.openmrs.Concept) Encounter(org.openmrs.Encounter) Date(java.util.Date) Provider(org.openmrs.Provider) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) OrderUtilTest(org.openmrs.order.OrderUtilTest) Test(org.junit.Test)

Example 5 with Provider

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"));
}
Also used : Provider(org.openmrs.Provider) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Aggregations

Provider (org.openmrs.Provider)49 Test (org.junit.Test)40 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)33 Encounter (org.openmrs.Encounter)16 Date (java.util.Date)12 Person (org.openmrs.Person)10 Patient (org.openmrs.Patient)9 EncounterType (org.openmrs.EncounterType)8 EncounterRole (org.openmrs.EncounterRole)7 Location (org.openmrs.Location)7 PersonName (org.openmrs.PersonName)6 TestOrder (org.openmrs.TestOrder)5 Message (ca.uhn.hl7v2.model.Message)4 Matchers.containsInAnyOrder (org.hamcrest.Matchers.containsInAnyOrder)4 DrugOrder (org.openmrs.DrugOrder)4 Order (org.openmrs.Order)4 OrderUtilTest (org.openmrs.order.OrderUtilTest)4 Criteria (org.hibernate.Criteria)3 Concept (org.openmrs.Concept)3 User (org.openmrs.User)3