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);
}
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);
}
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());
}
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());
}
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());
}
Aggregations