Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: openmrs/openmrs-core
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 75a01e8c3d9f
Choose a base ref
...
head repository: openmrs/openmrs-core
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: da7fd735a562
Choose a head ref
  • 3 commits
  • 8 files changed
  • 1 contributor

Commits on Jan 16, 2014

  1. Follow up to fix mappings for numberOfRepeats and frequency fields fo…

    …r test orders - TRUNK-4137
    wluyima committed Jan 16, 2014
    Copy the full SHA
    ce2167b View commit details
  2. 1
    Copy the full SHA
    e0a3233 View commit details
  3. 8
    Copy the full SHA
    da7fd73 View commit details
11 changes: 11 additions & 0 deletions api/src/main/java/org/openmrs/api/OrderService.java
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@
import org.openmrs.Concept;
import org.openmrs.Encounter;
import org.openmrs.Order;
import org.openmrs.OrderFrequency;
import org.openmrs.Patient;
import org.openmrs.User;
import org.openmrs.annotation.Authorized;
@@ -211,4 +212,14 @@ public <Ord extends Order> List<Ord> getActiveOrders(Patient patient, Class<Ord>
* @since 1.10
*/
public CareSetting getCareSetting(Integer careSettingId);

/**
* Gets OrderFrequenecy that matches the specified orderFrequencyId
*
* @param orderFrequencyId the id to match against
* @return OrderFrequency
* @since 1.10
* @should return the order frequency that matched the specified id
*/
public OrderFrequency getOrderFrequency(Integer orderFrequencyId);
}
6 changes: 6 additions & 0 deletions api/src/main/java/org/openmrs/api/db/OrderDAO.java
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@
import org.openmrs.Concept;
import org.openmrs.Encounter;
import org.openmrs.Order;
import org.openmrs.OrderFrequency;
import org.openmrs.Patient;
import org.openmrs.User;

@@ -96,4 +97,9 @@ public <Ord extends Order> List<Ord> getActiveOrders(Patient patient, Class<Ord>
* @return the care setting type
*/
public CareSetting getCareSetting(Integer careSettingId);

/**
* @See OrderService#getOrderFrequency
*/
public OrderFrequency getOrderFrequency(Integer orderFrequencyId);
}
Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@
import org.openmrs.GlobalProperty;
import org.openmrs.Order;
import org.openmrs.Order.Action;
import org.openmrs.OrderFrequency;
import org.openmrs.Patient;
import org.openmrs.User;
import org.openmrs.api.APIException;
@@ -218,4 +219,12 @@ public <Ord extends Order> List<Ord> getActiveOrders(Patient patient, Class<Ord>
public CareSetting getCareSetting(Integer careSettingId) {
return (CareSetting) sessionFactory.getCurrentSession().get(CareSetting.class, careSettingId);
}

/**
* @See OrderDAO#getOrderFrequency
*/
@Override
public OrderFrequency getOrderFrequency(Integer orderFrequencyId) {
return (OrderFrequency) sessionFactory.getCurrentSession().get(OrderFrequency.class, orderFrequencyId);
}
}
9 changes: 9 additions & 0 deletions api/src/main/java/org/openmrs/api/impl/OrderServiceImpl.java
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@
import org.openmrs.Concept;
import org.openmrs.Encounter;
import org.openmrs.Order;
import org.openmrs.OrderFrequency;
import org.openmrs.Patient;
import org.openmrs.User;
import org.openmrs.api.APIException;
@@ -256,4 +257,12 @@ public <Ord extends Order> List<Ord> getActiveOrders(Patient patient, Class<Ord>
public CareSetting getCareSetting(Integer careSettingId) {
return dao.getCareSetting(careSettingId);
}

/**
* @see OrderService#getOrderFrequency(Integer)
*/
@Override
public OrderFrequency getOrderFrequency(Integer orderFrequencyId) {
return dao.getOrderFrequency(orderFrequencyId);
}
}
Original file line number Diff line number Diff line change
@@ -129,8 +129,8 @@
</type>
</property>
<property name="clinicalHistory" type="java.lang.String" column="clinical_history" length="65535" />
<property name="frequency" type="int" column="frequency"/>
<many-to-one name="numberOfRepeats" class="org.openmrs.OrderFrequency">
<property name="numberOfRepeats" type="int" column="number_of_repeats"/>
<many-to-one name="frequency" class="org.openmrs.OrderFrequency">
<column name="order_frequency"/>
</many-to-one>

63 changes: 63 additions & 0 deletions api/src/test/java/org/openmrs/OrderEntryTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/**
* The contents of this file are subject to the OpenMRS Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://license.openmrs.org
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
*
* Copyright (C) OpenMRS, LLC. All Rights Reserved.
*/
package org.openmrs;

import static org.junit.Assert.assertEquals;

import org.junit.Test;
import org.openmrs.api.ConceptService;
import org.openmrs.api.OrderService;
import org.openmrs.api.PatientService;
import org.openmrs.test.BaseContextSensitiveTest;
import org.springframework.beans.factory.annotation.Autowired;

/**
* Contains end to end tests for order entry operations i.g placing, discontinuing revising an order
*/
public class OrderEntryTest extends BaseContextSensitiveTest {

protected static final String ORDER_ENTRY_DATASET_XML = "org/openmrs/api/include/OrderEntryTest-other.xml";

@Autowired
private OrderService orderService;

@Autowired
private PatientService patientService;

@Autowired
private ConceptService conceptService;

@Test
public void shouldPlaceATestOrder() throws Exception {
executeDataSet(ORDER_ENTRY_DATASET_XML);
Patient patient = patientService.getPatient(2);
CareSetting careSetting = orderService.getCareSetting(1);
assertEquals(0, orderService.getActiveOrders(patient, TestOrder.class, careSetting, false).size());

//place test order, should call OrderService.placeOrder
TestOrder order = new TestOrder();
order.setPatient(patient);
order.setConcept(conceptService.getConcept(5497));
order.setCareSetting(careSetting);
order.setClinicalHistory("Patient had a negative reaction to the test in the past");
order.setLaterality(TestOrder.Laterality.BILATERAL);
order.setFrequency(orderService.getOrderFrequency(1));
order.setSpecimenSource(conceptService.getConcept(1000));
order.setNumberOfRepeats(3);

orderService.saveOrder(order);

assertEquals(1, orderService.getActiveOrders(patient, TestOrder.class, careSetting, false).size());
}
}
11 changes: 11 additions & 0 deletions api/src/test/java/org/openmrs/api/OrderServiceTest.java
Original file line number Diff line number Diff line change
@@ -260,4 +260,15 @@ private boolean isOrderActive(Order order) {
return order.getDateStopped() == null && order.getAutoExpireDate() == null
&& order.getAction() != Action.DISCONTINUE;
}

/**
* @verifies return the order frequency that matched the specified id
* @see OrderService#getOrderFrequency(Integer)
*/
@Test
public void getOrderFrequency_shouldReturnTheOrderFrequencyThatMatchedTheSpecifiedId() throws Exception {
Assert
.assertEquals("28090760-7c38-11e3-baa7-0800200c9a66", Context.getOrderService().getOrderFrequency(1)
.getUuid());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version='1.0' encoding='UTF-8'?>
<dataset>
<concept concept_id="1000" retired="false" datatype_id="4" class_id="11" is_set="0" creator="1" date_created="2005-01-01 00:00:00.0" uuid="857eba27-2b38-43e8-91a9-4dfe3956a32e" />
<concept concept_id="1001" retired="true" datatype_id="1" class_id="1" is_set="false" creator="1" date_created="2004-08-12 00:00:00.0" version="" uuid="8e02d1a0-7869-11e3-981f-0800200c9a76"/>
<concept_name concept_name_id="2000" concept_id="1000" name="Blood" locale="en" creator="1" date_created="2005-01-01 00:00:00.0" concept_name_type="FULLY_SPECIFIED" locale_preferred="1" voided="0" uuid="9edfd54f-b189-43dd-86e0-913591978e489" />
<concept_name concept_name_id="2001" concept_id="1001" name="Once" locale="en" creator="1" date_created="2008-08-15 13:52:53.0" concept_name_type="FULLY_SPECIFIED" locale_preferred="1" voided="0" uuid="93f24a00-7869-11e3-981f-0800200c9a67"/>
<order_frequency order_frequency_id="3000" concept_id="1001" creator="1" date_created="2008-08-15 13:52:53.0" retired="0" uuid="38090760-7c38-11e4-baa7-0800200c9a67" />

<global_property property="order.nextOrderNumberSeed" property_value="1" uuid="7ed7aeb4-0663-11e1-8c99-2b4f0c4f671b" />
</dataset>