本文整理了Java中org.openmrs.Order.getDateActivated()
方法的一些代码示例,展示了Order.getDateActivated()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Order.getDateActivated()
方法的具体详情如下:
包路径:org.openmrs.Order
类名称:Order
方法名:getDateActivated
暂无
代码示例来源:origin: openmrs/openmrs-core
/**
* A convenience method to return start of the schedule for order.
*
* @since 1.10
* @should return scheduledDate if Urgency is Scheduled
* @should return dateActivated if Urgency is not Scheduled
*/
public Date getEffectiveStartDate() {
return this.urgency == Urgency.ON_SCHEDULED_DATE ? this.getScheduledDate() : this.getDateActivated();
}
代码示例来源:origin: openmrs/openmrs-core
private void ensureDateActivatedIsSet(Order order) {
if (order.getDateActivated() == null) {
order.setDateActivated(new Date());
}
}
代码示例来源:origin: openmrs/openmrs-core
private Order saveOrderInternal(Order order, OrderContext orderContext) {
if (order.getOrderId() == null) {
setProperty(order, "orderNumber", getOrderNumberGenerator().getNewOrderNumber(orderContext));
//DC orders should auto expire upon creating them
if (DISCONTINUE == order.getAction()) {
order.setAutoExpireDate(order.getDateActivated());
} else if (order.getAutoExpireDate() != null) {
Calendar cal = Calendar.getInstance();
cal.setTime(order.getAutoExpireDate());
int hours = cal.get(Calendar.HOUR_OF_DAY);
int minutes = cal.get(Calendar.MINUTE);
int seconds = cal.get(Calendar.SECOND);
cal.get(Calendar.MILLISECOND);
//roll autoExpireDate to end of day (23:59:59) if no time portion is specified
if (hours == 0 && minutes == 0 && seconds == 0) {
cal.set(Calendar.HOUR_OF_DAY, 23);
cal.set(Calendar.MINUTE, 59);
cal.set(Calendar.SECOND, 59);
// the OpenMRS database is only precise to the second
cal.set(Calendar.MILLISECOND, 0);
order.setAutoExpireDate(cal.getTime());
}
}
}
return dao.saveOrder(order);
}
代码示例来源:origin: openmrs/openmrs-core
private void validateDateActivated(Order order, Errors errors) {
Date dateActivated = order.getDateActivated();
if (dateActivated != null) {
if (dateActivated.after(new Date())) {
errors.rejectValue("dateActivated", "Order.error.dateActivatedInFuture");
return;
}
Date dateStopped = order.getDateStopped();
if (dateStopped != null && dateActivated.after(dateStopped)) {
errors.rejectValue("dateActivated", "Order.error.dateActivatedAfterDiscontinuedDate");
errors.rejectValue("dateStopped", "Order.error.dateActivatedAfterDiscontinuedDate");
}
Date autoExpireDate = order.getAutoExpireDate();
if (autoExpireDate != null && dateActivated.after(autoExpireDate)) {
errors.rejectValue("dateActivated", "Order.error.dateActivatedAfterAutoExpireDate");
errors.rejectValue("autoExpireDate", "Order.error.dateActivatedAfterAutoExpireDate");
}
Encounter encounter = order.getEncounter();
if (encounter != null && encounter.getEncounterDatetime() != null
&& encounter.getEncounterDatetime().after(dateActivated)) {
errors.rejectValue("dateActivated", "Order.error.encounterDatetimeAfterDateActivated");
}
}
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see org.openmrs.api.OrderService#unvoidOrder(org.openmrs.Order)
*/
@Override
public Order unvoidOrder(Order order) throws APIException {
Order previousOrder = order.getPreviousOrder();
if (previousOrder != null && isDiscontinueOrReviseOrder(order)) {
if (!previousOrder.isActive()) {
final String action = DISCONTINUE == order.getAction() ? "discontinuation" : "revision";
throw new CannotUnvoidOrderException(action);
}
stopOrder(previousOrder, aMomentBefore(order.getDateActivated()), false);
}
return saveOrderInternal(order, null);
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Order#isFuture(java.util.Date)
*/
@Test
public void isFuture_shouldReturnFalseIfDateActivatedIsNull() throws Exception {
Order order = new Order();
assertNull(order.getDateActivated());
assertFalse(order.isStarted(DateUtils.parseDate("2014-11-01 11:11:09", DATE_FORMAT)));
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Order#isStarted(java.util.Date)
*/
@Test
public void isStarted_shouldReturnFalseIfDateActivatedIsNull() throws Exception {
Order order = new Order();
assertNull(order.getDateActivated());
assertFalse(order.isStarted(DateUtils.parseDate("2014-11-01 11:11:11", DATE_FORMAT)));
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @throws ParseException
* @see OrderUtil#checkScheduleOverlap(org.openmrs.Order, org.openmrs.Order)
*/
@Test
public void checkScheduleOverlap_shouldReturnTrueIfBothOrdersStartAndEndOnSameDates() throws ParseException {
DateFormat df = new SimpleDateFormat("dd/MM/yyy");
Order order1 = new Order();
order1.setDateActivated(df.parse("05/08/2014"));
order1.setAutoExpireDate(df.parse("13/08/2014"));
Order order2 = new Order();
order2.setDateActivated(order1.getDateActivated());
order2.setDateActivated(order1.getAutoExpireDate());
assertTrue(OrderUtil.checkScheduleOverlap(order1, order2));
assertTrue(OrderUtil.checkScheduleOverlap(order2, order1));
}
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @throws ParseException
* @see OrderUtil#checkScheduleOverlap(org.openmrs.Order, org.openmrs.Order)
*/
@Test
public void checkScheduleOverlap_shouldReturnTrueIfOrder1StartsOnTheStopDateOfOrder2() throws ParseException {
DateFormat df = new SimpleDateFormat("dd/MM/yyy");
Order order1 = new Order();
order1.setDateActivated(df.parse("13/08/2014"));
Order order2 = new Order();
order2.setDateActivated(df.parse("05/08/2014"));
order2.setAutoExpireDate(order1.getDateActivated());
assertTrue(OrderUtil.checkScheduleOverlap(order1, order2));
assertTrue(OrderUtil.checkScheduleOverlap(order2, order1));
//Assuming order1 has an end date
order1.setAutoExpireDate(df.parse("15/08/2014"));
assertTrue(OrderUtil.checkScheduleOverlap(order1, order2));
assertTrue(OrderUtil.checkScheduleOverlap(order2, order1));
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Order#isActivated(Date)
*/
@Test
public void isActivated_shouldReturnFalseIfDateActivatedIsNull() throws Exception {
Order order = new Order();
assertNull(order.getDateActivated());
assertNull(order.getAutoExpireDate());
assertFalse(order.isActivated(DateUtils.parseDate("2014-11-01 11:11:10", DATE_FORMAT)));
}
代码示例来源:origin: openmrs/openmrs-core
@Test
public void shouldReviseAnOrder() {
Order originalOrder = orderService.getOrder(111);
assertTrue(OrderUtilTest.isActiveOrder(originalOrder, null));
final Patient patient = originalOrder.getPatient();
List<Order> originalActiveOrders = orderService.getActiveOrders(patient, null, null, null);
final int originalOrderCount = originalActiveOrders.size();
assertTrue(originalActiveOrders.contains(originalOrder));
Order revisedOrder = originalOrder.cloneForRevision();
revisedOrder.setInstructions("Take after a meal");
revisedOrder.setDateActivated(new Date());
revisedOrder.setOrderer(providerService.getProvider(1));
revisedOrder.setEncounter(encounterService.getEncounter(3));
orderService.saveOrder(revisedOrder, null);
List<Order> activeOrders = orderService.getActiveOrders(patient, null, null, null);
assertEquals(originalOrderCount, activeOrders.size());
assertEquals(revisedOrder.getDateActivated(), DateUtils.addSeconds(originalOrder.getDateStopped(), 1));
assertFalse(OrderUtilTest.isActiveOrder(originalOrder, null));
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Order#isActivated(Date)
*/
@Test
public void isActivated_shouldReturnFalseForAnOrderActivatedAfterTheCheckDate() throws Exception {
Order order = new Order();
order.setDateActivated(DateUtils.parseDate("2014-11-01 11:11:10", DATE_FORMAT));
assertNull(order.getDateStopped());
assertNull(order.getAutoExpireDate());
assertFalse(order.isActivated(DateUtils.addMonths(order.getDateActivated(), -2)));
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see OrderService#saveOrder(org.openmrs.Order, OrderContext)
*/
@Test
public void saveOrder_shouldSaveARevisedOrder() {
Order originalOrder = orderService.getOrder(111);
assertTrue(originalOrder.isActive());
final Patient patient = originalOrder.getPatient();
List<Order> originalActiveOrders = orderService.getActiveOrders(patient, null, null, null);
final int originalOrderCount = originalActiveOrders.size();
assertTrue(originalActiveOrders.contains(originalOrder));
Order revisedOrder = originalOrder.cloneForRevision();
revisedOrder.setEncounter(encounterService.getEncounter(5));
revisedOrder.setInstructions("Take after a meal");
revisedOrder.setDateActivated(new Date());
revisedOrder.setOrderer(providerService.getProvider(1));
revisedOrder.setEncounter(encounterService.getEncounter(3));
orderService.saveOrder(revisedOrder, null);
List<Order> activeOrders = orderService.getActiveOrders(patient, null, null, null);
assertEquals(originalOrderCount, activeOrders.size());
assertEquals(revisedOrder.getDateActivated(), DateUtils.addSeconds(originalOrder.getDateStopped(), 1));
assertFalse(originalOrder.isActive());
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Order#cloneForRevision()
*/
@Test
public void cloneForRevision_shouldSetTheRelevantFieldsForADCOrder() throws Exception {
Order order = new Order();
order.setAction(Order.Action.DISCONTINUE);
Date date = new Date();
order.setDateActivated(date);
order.setPreviousOrder(new Order());
order.setAutoExpireDate(date);
order.setAccessionNumber("some number");
OrderUtilTest.setDateStopped(order, date);
Order clone = order.cloneForRevision();
assertEquals(Order.Action.DISCONTINUE, clone.getAction());
assertEquals(order.getDateActivated(), clone.getDateActivated());
assertEquals(order.getPreviousOrder(), clone.getPreviousOrder());
assertNull(clone.getAutoExpireDate());
assertNull(clone.getDateStopped());
assertNull(clone.getAccessionNumber());
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @throws Exception
* @see DrugOrder#cloneForRevision()
*/
@Test
public void cloneForRevision_shouldSetTheRelevantFieldsForADCOrder() {
Order order = new DrugOrder();
order.setAction(Order.Action.DISCONTINUE);
Date date = new Date();
order.setDateActivated(date);
order.setAutoExpireDate(date);
order.setAccessionNumber("some number");
OrderUtilTest.setDateStopped(order, date);
order.setPreviousOrder(new Order());
Order clone = order.cloneForRevision();
assertEquals(Order.Action.DISCONTINUE, clone.getAction());
assertEquals(order.getDateActivated(), clone.getDateActivated());
assertEquals(order.getPreviousOrder(), clone.getPreviousOrder());
assertNull(clone.getAutoExpireDate());
assertNull(clone.getDateStopped());
assertNull(clone.getAccessionNumber());
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see TestOrder#cloneForRevision()
*/
@Test
public void cloneForRevision_shouldSetTheRelevantFieldsForADCOrder() {
Order order = new TestOrder();
order.setAction(Order.Action.DISCONTINUE);
Date date = new Date();
order.setDateActivated(date);
order.setAutoExpireDate(date);
order.setAccessionNumber("some number");
OrderUtilTest.setDateStopped(order, date);
order.setPreviousOrder(new Order());
Order clone = order.cloneForRevision();
assertEquals(Order.Action.DISCONTINUE, clone.getAction());
assertEquals(order.getDateActivated(), clone.getDateActivated());
assertEquals(order.getPreviousOrder(), clone.getPreviousOrder());
assertNull(clone.getAutoExpireDate());
assertNull(clone.getDateStopped());
assertNull(clone.getAccessionNumber());
}
}
代码示例来源:origin: openmrs/openmrs-core
@Test
public void saveRetrospectiveOrder_shouldDiscontinueOrderInRetrospectiveEntry() throws ParseException {
executeDataSet("org/openmrs/api/include/OrderServiceTest-ordersWithAutoExpireDate.xml");
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.S");
Date originalOrderDateActivated = dateFormat.parse("2008-11-19 09:24:10.0");
Date discontinuationOrderDate = DateUtils.addDays(originalOrderDateActivated, 2);
Order originalOrder = orderService.getOrder(201);
assertNull(originalOrder.getDateStopped());
assertEquals(dateFormat.parse("2008-11-23 09:24:09.0"), originalOrder.getAutoExpireDate());
assertFalse(originalOrder.isActive());
assertTrue(originalOrder.isActive(discontinuationOrderDate));
Order discontinueationOrder = originalOrder.cloneForDiscontinuing();
discontinueationOrder.setPreviousOrder(originalOrder);
discontinueationOrder.setEncounter(encounterService.getEncounter(17));
discontinueationOrder.setOrderer(providerService.getProvider(1));
discontinueationOrder.setDateActivated(discontinuationOrderDate);
orderService.saveRetrospectiveOrder(discontinueationOrder, null);
assertNotNull(originalOrder.getDateStopped());
assertEquals(discontinueationOrder.getAutoExpireDate(), discontinueationOrder.getDateActivated());
}
代码示例来源:origin: openmrs/openmrs-core
@Test
public void saveRetrospectiveOrder_shouldDiscontinueAndStopActiveOrderInRetrospectiveEntry() throws ParseException {
executeDataSet("org/openmrs/api/include/OrderServiceTest-ordersWithAutoExpireDate.xml");
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.S");
Date originalOrderDateActivated = dateFormat.parse("2008-11-19 09:24:10.0");
Date discontinuationOrderDate = DateUtils.addDays(originalOrderDateActivated, 2);
Order originalOrder = orderService.getOrder(202);
assertNull(originalOrder.getDateStopped());
assertEquals(dateFormat.parse("2008-11-23 09:24:09.0"), originalOrder.getAutoExpireDate());
assertFalse(originalOrder.isActive());
assertTrue(originalOrder.isActive(discontinuationOrderDate));
Order discontinuationOrder = originalOrder.cloneForDiscontinuing();
discontinuationOrder.setPreviousOrder(null);
discontinuationOrder.setEncounter(encounterService.getEncounter(17));
discontinuationOrder.setOrderer(providerService.getProvider(1));
discontinuationOrder.setDateActivated(discontinuationOrderDate);
orderService.saveRetrospectiveOrder(discontinuationOrder, null);
assertNotNull(originalOrder.getDateStopped());
assertEquals(discontinuationOrder.getAutoExpireDate(), discontinuationOrder.getDateActivated());
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @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);
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @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);
}
内容来源于网络,如有侵权,请联系作者删除!