use of org.openmrs.Concept in project openmrs-core by openmrs.
the class OrderServiceTest method saveOrder_shouldPassForRevisionOrderIfAnActiveTestOrderForTheSameConceptAndCareSettingsExists.
/**
* settings exists
* @see OrderService#saveOrder(Order, OrderContext)
*/
@Test
@Ignore("Ignored because it fails after removal of deprecated methods TRUNK-4772")
public void saveOrder_shouldPassForRevisionOrderIfAnActiveTestOrderForTheSameConceptAndCareSettingsExists() {
final Patient patient = patientService.getPatient(2);
final Concept cd4Count = conceptService.getConcept(5497);
TestOrder activeOrder = new TestOrder();
activeOrder.setPatient(patient);
activeOrder.setConcept(cd4Count);
activeOrder.setEncounter(encounterService.getEncounter(6));
activeOrder.setOrderer(providerService.getProvider(1));
activeOrder.setCareSetting(orderService.getCareSetting(2));
activeOrder.setDateActivated(new Date());
activeOrder.setAutoExpireDate(DateUtils.addDays(new Date(), 10));
orderService.saveOrder(activeOrder, null);
// New order in future for same concept
TestOrder secondOrder = new TestOrder();
secondOrder.setPatient(activeOrder.getPatient());
secondOrder.setConcept(activeOrder.getConcept());
secondOrder.setEncounter(encounterService.getEncounter(6));
secondOrder.setOrderer(providerService.getProvider(1));
secondOrder.setCareSetting(activeOrder.getCareSetting());
secondOrder.setDateActivated(new Date());
secondOrder.setScheduledDate(DateUtils.addDays(activeOrder.getEffectiveStopDate(), 1));
secondOrder.setUrgency(Order.Urgency.ON_SCHEDULED_DATE);
orderService.saveOrder(secondOrder, null);
// Revise second order to have scheduled date overlapping with active order
TestOrder revision = secondOrder.cloneForRevision();
revision.setScheduledDate(DateUtils.addDays(activeOrder.getEffectiveStartDate(), 2));
revision.setEncounter(encounterService.getEncounter(6));
revision.setOrderer(providerService.getProvider(1));
Order savedSecondOrder = orderService.saveOrder(revision, null);
assertNotNull(orderService.getOrder(savedSecondOrder.getOrderId()));
}
use of org.openmrs.Concept in project openmrs-core by openmrs.
the class OrderServiceTest method saveOrder_shouldFailIfConceptInPreviousOrderDoesNotMatchThatOfTheRevisedOrder.
/**
* @see OrderService#saveOrder(org.openmrs.Order, OrderContext)
*/
@Test
public void saveOrder_shouldFailIfConceptInPreviousOrderDoesNotMatchThatOfTheRevisedOrder() {
Order previousOrder = orderService.getOrder(7);
Order order = previousOrder.cloneForRevision();
order.setDateActivated(new Date());
order.setOrderer(providerService.getProvider(1));
order.setEncounter(encounterService.getEncounter(6));
Concept newConcept = conceptService.getConcept(5089);
assertFalse(previousOrder.getConcept().equals(newConcept));
order.setConcept(newConcept);
expectedException.expect(EditedOrderDoesNotMatchPreviousException.class);
expectedException.expectMessage("The orderable of the previous order and the new one order don't match");
orderService.saveOrder(order, null);
}
use of org.openmrs.Concept in project openmrs-core by openmrs.
the class OrderServiceTest method getNonCodedDrugConcept_shouldReturnAConceptIfGPIsSet.
/**
* @see OrderService#getNonCodedDrugConcept()
*/
@Test
public void getNonCodedDrugConcept_shouldReturnAConceptIfGPIsSet() {
executeDataSet("org/openmrs/api/include/OrderServiceTest-nonCodedDrugs.xml");
Concept nonCodedDrugConcept = orderService.getNonCodedDrugConcept();
assertNotNull(nonCodedDrugConcept);
assertThat(nonCodedDrugConcept.getConceptId(), is(5584));
assertEquals(nonCodedDrugConcept.getName().getName(), "DRUG OTHER");
}
use of org.openmrs.Concept in project openmrs-core by openmrs.
the class OrderServiceTest method saveOrder_shouldSetOrderTypeOfTestOrderToTestOrderIfNotSetAndConceptNotMapped.
/**
* @see OrderService#saveOrder(org.openmrs.Order, OrderContext)
*/
@Test
public void saveOrder_shouldSetOrderTypeOfTestOrderToTestOrderIfNotSetAndConceptNotMapped() {
TestOrder testOrder = new TestOrder();
testOrder.setPatient(patientService.getPatient(7));
Concept unmappedConcept = conceptService.getConcept(113);
Assert.assertNull(orderService.getOrderTypeByConcept(unmappedConcept));
testOrder.setConcept(unmappedConcept);
testOrder.setOrderer(providerService.getProvider(1));
testOrder.setCareSetting(orderService.getCareSetting(1));
Encounter encounter = encounterService.getEncounter(3);
testOrder.setEncounter(encounter);
testOrder.setDateActivated(encounter.getEncounterDatetime());
testOrder.setClinicalHistory("Patient had a negative reaction to the test in the past");
testOrder.setFrequency(orderService.getOrderFrequency(3));
testOrder.setSpecimenSource(conceptService.getConcept(22));
testOrder.setNumberOfRepeats(3);
orderService.saveOrder(testOrder, null);
Assert.assertNotNull(testOrder.getOrderType());
Assert.assertEquals(orderService.getOrderTypeByUuid(OrderType.TEST_ORDER_TYPE_UUID), testOrder.getOrderType());
}
use of org.openmrs.Concept in project openmrs-core by openmrs.
the class OrderServiceTest method saveOrder_shouldFailIfAnActiveDrugOrderForTheSameConceptAndCareSettingExists.
/**
* @see OrderService#saveOrder(Order, OrderContext)
*/
@Test
public void saveOrder_shouldFailIfAnActiveDrugOrderForTheSameConceptAndCareSettingExists() {
final Patient patient = patientService.getPatient(2);
final Concept triomuneThirty = conceptService.getConcept(792);
// sanity check that we have an active order for the same concept
DrugOrder duplicateOrder = (DrugOrder) orderService.getOrder(3);
assertTrue(duplicateOrder.isActive());
assertEquals(triomuneThirty, duplicateOrder.getConcept());
DrugOrder drugOrder = new DrugOrder();
drugOrder.setPatient(patient);
drugOrder.setCareSetting(orderService.getCareSetting(1));
drugOrder.setConcept(triomuneThirty);
drugOrder.setEncounter(encounterService.getEncounter(6));
drugOrder.setOrderer(providerService.getProvider(1));
drugOrder.setCareSetting(duplicateOrder.getCareSetting());
drugOrder.setDrug(duplicateOrder.getDrug());
drugOrder.setDose(duplicateOrder.getDose());
drugOrder.setDoseUnits(duplicateOrder.getDoseUnits());
drugOrder.setRoute(duplicateOrder.getRoute());
drugOrder.setFrequency(duplicateOrder.getFrequency());
drugOrder.setQuantity(duplicateOrder.getQuantity());
drugOrder.setQuantityUnits(duplicateOrder.getQuantityUnits());
drugOrder.setNumRefills(duplicateOrder.getNumRefills());
expectedException.expect(AmbiguousOrderException.class);
expectedException.expectMessage("Order.cannot.have.more.than.one");
orderService.saveOrder(drugOrder, null);
}
Aggregations