Search in sources :

Example 56 with Concept

use of org.openmrs.Concept 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 57 with Concept

use of org.openmrs.Concept 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 58 with Concept

use of org.openmrs.Concept in project openmrs-core by openmrs.

the class OrderServiceTest method getOrderHistoryByConcept_shouldReturnEmptyListForConceptWithoutOrders.

/**
 * @see OrderService#getOrderHistoryByConcept(Patient, Concept)
 */
@Test
public void getOrderHistoryByConcept_shouldReturnEmptyListForConceptWithoutOrders() {
    Concept concept = Context.getConceptService().getConcept(21);
    Patient patient = Context.getPatientService().getPatient(2);
    List<Order> orders = orderService.getOrderHistoryByConcept(patient, concept);
    Assert.assertEquals(0, orders.size());
}
Also used : Concept(org.openmrs.Concept) DrugOrder(org.openmrs.DrugOrder) TestOrder(org.openmrs.TestOrder) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) Order(org.openmrs.Order) Patient(org.openmrs.Patient) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) OrderUtilTest(org.openmrs.order.OrderUtilTest) Test(org.junit.Test)

Example 59 with Concept

use of org.openmrs.Concept in project openmrs-core by openmrs.

the class OrderServiceTest method saveOrder_shouldSetOrderTypeOfDrugOrderToDrugOrderIfNotSetAndConceptNotMapped.

/**
 * @see OrderService#saveOrder(org.openmrs.Order, OrderContext)
 */
@Test
public void saveOrder_shouldSetOrderTypeOfDrugOrderToDrugOrderIfNotSetAndConceptNotMapped() {
    Drug drug = conceptService.getDrug(2);
    Concept unmappedConcept = conceptService.getConcept(113);
    Assert.assertNull(orderService.getOrderTypeByConcept(unmappedConcept));
    drug.setConcept(unmappedConcept);
    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.setDateActivated(encounter.getEncounterDatetime());
    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(10);
    drugOrder.setOrderType(null);
    orderService.saveOrder(drugOrder, null);
    Assert.assertNotNull(drugOrder.getOrderType());
    Assert.assertEquals(orderService.getOrderTypeByUuid(OrderType.DRUG_ORDER_TYPE_UUID), drugOrder.getOrderType());
}
Also used : Drug(org.openmrs.Drug) Concept(org.openmrs.Concept) DrugOrder(org.openmrs.DrugOrder) Encounter(org.openmrs.Encounter) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) OrderUtilTest(org.openmrs.order.OrderUtilTest) Test(org.junit.Test)

Example 60 with Concept

use of org.openmrs.Concept in project openmrs-core by openmrs.

the class PatientServiceAllergyTest method setAllergies_shouldSaveTheAllergyListAndStatus.

/**
 * @see PatientService#setAllergies(Patient,Allergies)
 */
@Test
public void setAllergies_shouldSaveTheAllergyListAndStatus() {
    // get a patient without any allergies
    Patient patient = allergyService.getPatient(7);
    Allergies allergies = allergyService.getAllergies(patient);
    Assert.assertEquals(Allergies.UNKNOWN, allergies.getAllergyStatus());
    Assert.assertEquals(0, allergies.size());
    // save some allergies for this patient
    Allergen allergen = new Allergen(AllergenType.DRUG, new Concept(3), null);
    Concept severity = new Concept(4);
    Allergy allergy = new Allergy(patient, allergen, severity, "some comment", new ArrayList<>());
    AllergyReaction reaction = new AllergyReaction(allergy, new Concept(21), null);
    allergy.addReaction(reaction);
    allergies = new Allergies();
    allergies.add(allergy);
    allergyService.setAllergies(patient, allergies);
    // now the patient should have allergies and the correct allergy status
    allergies = allergyService.getAllergies(patient);
    Assert.assertEquals(Allergies.SEE_LIST, allergies.getAllergyStatus());
    Assert.assertEquals(1, allergies.size());
    Assert.assertEquals(1, allergies.get(0).getReactions().size());
}
Also used : Concept(org.openmrs.Concept) Allergy(org.openmrs.Allergy) Patient(org.openmrs.Patient) AllergyReaction(org.openmrs.AllergyReaction) Allergies(org.openmrs.Allergies) Allergen(org.openmrs.Allergen) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Aggregations

Concept (org.openmrs.Concept)294 Test (org.junit.Test)210 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)176 ConceptName (org.openmrs.ConceptName)62 OpenmrsMatchers.hasConcept (org.openmrs.test.OpenmrsMatchers.hasConcept)62 Obs (org.openmrs.Obs)49 Date (java.util.Date)48 Patient (org.openmrs.Patient)42 ConceptDescription (org.openmrs.ConceptDescription)33 Locale (java.util.Locale)32 ConceptDatatype (org.openmrs.ConceptDatatype)32 OrderUtilTest (org.openmrs.order.OrderUtilTest)29 ConceptClass (org.openmrs.ConceptClass)27 ArrayList (java.util.ArrayList)26 BindException (org.springframework.validation.BindException)26 DrugOrder (org.openmrs.DrugOrder)25 Encounter (org.openmrs.Encounter)25 Errors (org.springframework.validation.Errors)25 ConceptMapBuilder (org.openmrs.module.metadatadeploy.builder.ConceptMapBuilder)21 Location (org.openmrs.Location)19