org.openmrs.Order.setEncounter()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(14.9k)|赞(0)|评价(0)|浏览(131)

本文整理了Java中org.openmrs.Order.setEncounter()方法的一些代码示例,展示了Order.setEncounter()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Order.setEncounter()方法的具体详情如下:
包路径:org.openmrs.Order
类名称:Order
方法名:setEncounter

Order.setEncounter介绍

暂无

代码示例

代码示例来源:origin: openmrs/openmrs-core

/**
 * Add the given Order to the list of orders for this Encounter
 *
 * @param order
 * @should add order with null values
 * @should not fail with null obs passed to add order
 * @should set encounter attribute
 * @should add order to non null initial order set
 * @should add order to encounter when adding order to set returned from getOrders
 */
public void addOrder(Order order) {
  if (order != null) {
    order.setEncounter(this);
    getOrders().add(order);
  }
}

代码示例来源:origin: openmrs/openmrs-core

public OrderBuilder withEncounter(Integer encounterID) {
  order.setEncounter(encounterService.getEncounter(encounterID));
  return this;
}

代码示例来源:origin: openmrs/openmrs-core

/**
 * @see org.openmrs.api.OrderService#discontinueOrder(org.openmrs.Order, String, java.util.Date,
 *      org.openmrs.Provider, org.openmrs.Encounter)
 */
@Override
public Order discontinueOrder(Order orderToDiscontinue, String reasonNonCoded, Date discontinueDate, Provider orderer,
               Encounter encounter) {
  if (discontinueDate == null) {
    discontinueDate = aMomentBefore(new Date());
  }
  stopOrder(orderToDiscontinue, discontinueDate, false);
  Order newOrder = orderToDiscontinue.cloneForDiscontinuing();
  newOrder.setOrderReasonNonCoded(reasonNonCoded);
  newOrder.setOrderer(orderer);
  newOrder.setEncounter(encounter);
  newOrder.setDateActivated(discontinueDate);
  return saveOrderInternal(newOrder, null);
}

代码示例来源:origin: openmrs/openmrs-core

/**
 * @see org.openmrs.api.OrderService#discontinueOrder(org.openmrs.Order, org.openmrs.Concept,
 *      java.util.Date, org.openmrs.Provider, org.openmrs.Encounter)
 */
@Override
public Order discontinueOrder(Order orderToDiscontinue, Concept reasonCoded, Date discontinueDate, Provider orderer,
               Encounter encounter) {
  if (discontinueDate == null) {
    discontinueDate = aMomentBefore(new Date());
  }
  stopOrder(orderToDiscontinue, discontinueDate, false);
  Order newOrder = orderToDiscontinue.cloneForDiscontinuing();
  newOrder.setOrderReason(reasonCoded);
  newOrder.setOrderer(orderer);
  newOrder.setEncounter(encounter);
  newOrder.setDateActivated(discontinueDate);
  return saveOrderInternal(newOrder, null);
}

代码示例来源:origin: openmrs/openmrs-core

@Test
public void saveOrder_shouldNotRevisePreviousIfAlreadyStopped() throws ParseException {
  executeDataSet("org/openmrs/api/include/OrderServiceTest-ordersWithAutoExpireDate.xml");
  Order previousOrder = orderService.getOrder(203);
  Date dateActivated = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse("2008-10-19 13:00:00");
  Order order = previousOrder.cloneForRevision();
  
  order.setDateActivated(dateActivated);
  order.setOrderer(providerService.getProvider(1));
  order.setEncounter(encounterService.getEncounter(18));
  order.setPreviousOrder(previousOrder);
  
  expectedException.expect(CannotStopInactiveOrderException.class);
  expectedException.expectMessage(mss.getMessage("Order.cannot.discontinue.inactive"));
  orderService.saveRetrospectiveOrder(order, null);
}

代码示例来源:origin: openmrs/openmrs-core

/**
 * @throws ParseException
 * @see OrderService#saveOrder(org.openmrs.Order, OrderContext)
 */
@Test
public void saveOrder_shouldNotChangeTheAutoExpireDateIfItHasATimeComponent() throws ParseException {
  Order order = new TestOrder();
  order.setPatient(patientService.getPatient(2));
  order.setCareSetting(orderService.getCareSetting(2));
  order.setConcept(conceptService.getConcept(5089));
  order.setEncounter(encounterService.getEncounter(6));
  order.setOrderer(providerService.getProvider(1));
  order.setDateActivated(new Date());
  DateFormat dateformat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
  order.setDateActivated(dateformat.parse("14/08/2014 10:00:00"));
  Date autoExpireDate = dateformat.parse("18/08/2014 10:00:00");
  order.setAutoExpireDate(autoExpireDate);
  
  orderService.saveOrder(order, null);
  assertEquals(autoExpireDate, order.getAutoExpireDate());
}

代码示例来源:origin: openmrs/openmrs-core

/**
 * @see OrderService#saveOrder(org.openmrs.Order, OrderContext)
 */
@Test
public void saveOrder_shouldNotAllowRevisingAnExpiredOrder() {
  Order originalOrder = orderService.getOrder(6);
  assertNotNull(originalOrder.getAutoExpireDate());
  assertTrue(originalOrder.getAutoExpireDate().before(new Date()));
  Order revisedOrder = originalOrder.cloneForRevision();
  revisedOrder.setEncounter(encounterService.getEncounter(6));
  revisedOrder.setInstructions("Take after a meal");
  revisedOrder.setOrderer(providerService.getProvider(1));
  revisedOrder.setDateActivated(new Date());
  revisedOrder.setAutoExpireDate(new Date());
  expectedException.expect(CannotStopInactiveOrderException.class);
  expectedException.expectMessage(mss.getMessage("Order.cannot.discontinue.inactive"));
  orderService.saveOrder(revisedOrder, null);
}

代码示例来源:origin: openmrs/openmrs-core

@Test
public void shouldReviseAnOrderAndFlushSuccessfully() {
  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);
  Context.flushSession();
  
  List<Order> activeOrders = orderService.getActiveOrders(patient, null, null, null);
  assertEquals(originalOrderCount, activeOrders.size());
  assertFalse(OrderUtilTest.isActiveOrder(originalOrder, null));
}

代码示例来源: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 OrderService#saveOrder(org.openmrs.Order, OrderContext)
 */
@Test
public void saveOrder_shouldNotAllowRevisingAStoppedOrder() {
  Order originalOrder = orderService.getOrder(1);
  assertNotNull(originalOrder.getDateStopped());
  Order revisedOrder = originalOrder.cloneForRevision();
  revisedOrder.setEncounter(encounterService.getEncounter(4));
  revisedOrder.setInstructions("Take after a meal");
  revisedOrder.setOrderer(providerService.getProvider(1));
  revisedOrder.setDateActivated(new Date());
  expectedException.expect(CannotStopInactiveOrderException.class);
  expectedException.expectMessage(mss.getMessage("Order.cannot.discontinue.inactive"));
  orderService.saveOrder(revisedOrder, null);
}

代码示例来源:origin: openmrs/openmrs-core

/**
 * @see OrderService#saveOrder(org.openmrs.Order, OrderContext)
 */
@Test
public void saveOrder_shouldNotAllowRevisingAVoidedOrder() {
  Order originalOrder = orderService.getOrder(8);
  assertTrue(originalOrder.getVoided());
  Order revisedOrder = originalOrder.cloneForRevision();
  revisedOrder.setEncounter(encounterService.getEncounter(6));
  revisedOrder.setInstructions("Take after a meal");
  revisedOrder.setOrderer(providerService.getProvider(1));
  revisedOrder.setDateActivated(new Date());
  expectedException.expect(CannotStopInactiveOrderException.class);
  expectedException.expectMessage(mss.getMessage("Order.cannot.discontinue.inactive"));
  orderService.saveOrder(revisedOrder, null);
}

代码示例来源:origin: openmrs/openmrs-core

/**
 * @see OrderService#saveOrder(org.openmrs.Order, OrderContext)
 */
@Test
public void saveOrder_shouldFailIfOrderTypeIsNullAndNotMappedToTheConceptClass() {
  Order order = new Order();
  order.setPatient(patientService.getPatient(7));
  order.setConcept(conceptService.getConcept(9));
  order.setOrderer(providerService.getProvider(1));
  order.setCareSetting(orderService.getCareSetting(1));
  order.setEncounter(encounterService.getEncounter(3));
  order.setDateActivated(new Date());
  expectedException.expect(OrderEntryException.class);
  expectedException.expectMessage("Order.type.cannot.determine");
  orderService.saveOrder(order, null);
}

代码示例来源:origin: openmrs/openmrs-core

/**
 * @see OrderService#saveOrder(org.openmrs.Order, OrderContext)
 */
@Test
public void saveOrder_shouldNotAllowRevisingAnOrderWithNoPreviousOrder() {
  Order originalOrder = orderService.getOrder(111);
  assertTrue(originalOrder.isActive());
  Order revisedOrder = originalOrder.cloneForRevision();
  revisedOrder.setEncounter(encounterService.getEncounter(5));
  revisedOrder.setInstructions("Take after a meal");
  revisedOrder.setPreviousOrder(null);
  revisedOrder.setOrderer(providerService.getProvider(1));
  revisedOrder.setDateActivated(new Date());
  
  expectedException.expect(MissingRequiredPropertyException.class);
  expectedException.expectMessage(mss.getMessage("Order.previous.required"));
  orderService.saveOrder(revisedOrder, null);
}

代码示例来源:origin: openmrs/openmrs-core

/**
 * @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);
}

代码示例来源:origin: openmrs/openmrs-core

/**
 * @see OrderValidator#validate(Object,Errors)
 */
@Test
public void validate_shouldFailValidationIfEncounterIsNull() {
  Order order = new Order();
  order.setConcept(Context.getConceptService().getConcept(88));
  order.setPatient(Context.getPatientService().getPatient(2));
  order.setEncounter(null);
  
  Errors errors = new BindException(order, "order");
  new OrderValidator().validate(order, errors);
  
  Assert.assertTrue(errors.hasFieldErrors("encounter"));
}

代码示例来源:origin: openmrs/openmrs-core

/**
 * @see OrderValidator#validate(Object, org.springframework.validation.Errors)
 */
@Test
public void validate_shouldFailValidationIfDateActivatedIsBeforeEncountersEncounterDatetime() {
  Date encounterDate = new Date();
  Date orderDate = DateUtils.addDays(encounterDate, -1);
  Encounter encounter = Context.getEncounterService().getEncounter(3);
  encounter.setEncounterDatetime(encounterDate);
  Order order = new Order();
  order.setDateActivated(orderDate);
  order.setConcept(Context.getConceptService().getConcept(88));
  order.setPatient(Context.getPatientService().getPatient(2));
  order.setEncounter(encounter);
  order.setOrderer(Context.getProviderService().getProvider(1));
  Errors errors = new BindException(order, "order");
  new OrderValidator().validate(order, errors);
  
  Assert.assertTrue(errors.hasFieldErrors("dateActivated"));
}

代码示例来源:origin: openmrs/openmrs-core

/**
 * @see OrderValidator#validate(Object,Errors)
 */
@Test
public void validate_shouldFailValidationIfOrderAndEncounterHaveDifferentPatients() {
  Order order = new Order();
  order.setConcept(Context.getConceptService().getConcept(88));
  order.setPatient(Context.getPatientService().getPatient(2));
  order.setEncounter(Context.getEncounterService().getEncounter(3));
  order.setOrderer(Context.getProviderService().getProvider(1));
  Errors errors = new BindException(order, "order");
  new OrderValidator().validate(order, errors);
  
  Assert.assertTrue(errors.hasFieldErrors("encounter"));
}

代码示例来源:origin: openmrs/openmrs-core

/**
 * @see OrderService#saveOrder(org.openmrs.Order, OrderContext)
 */
@Test
public void saveOrder_shouldFailIfTheCareSettingOfThePreviousOrderDoesNotMatch() {
  Order order = orderService.getOrder(7);
  assertTrue(OrderUtilTest.isActiveOrder(order, null));
  Order discontinuationOrder = order.cloneForDiscontinuing();
  CareSetting careSetting = orderService.getCareSetting(2);
  assertNotEquals(discontinuationOrder.getCareSetting(), careSetting);
  discontinuationOrder.setCareSetting(careSetting);
  discontinuationOrder.setOrderer(Context.getProviderService().getProvider(1));
  discontinuationOrder.setEncounter(Context.getEncounterService().getEncounter(6));
  
  expectedException.expect(EditedOrderDoesNotMatchPreviousException.class);
  expectedException.expectMessage(mss.getMessage("Order.care.setting.doesnot.match"));
  orderService.saveOrder(discontinuationOrder, null);
}

代码示例来源:origin: openmrs/openmrs-core

/**
 * @see OrderService#saveOrder(org.openmrs.Order, OrderContext)
 */
@Test
public void saveOrder_shouldFailIfTheOrderTypeOfThePreviousOrderDoesNotMatch() {
  Order order = orderService.getOrder(7);
  assertTrue(OrderUtilTest.isActiveOrder(order, null));
  Order discontinuationOrder = order.cloneForDiscontinuing();
  OrderType orderType = orderService.getOrderType(7);
  assertNotEquals(discontinuationOrder.getOrderType(), orderType);
  assertTrue(OrderUtil.isType(discontinuationOrder.getOrderType(), orderType));
  discontinuationOrder.setOrderType(orderType);
  discontinuationOrder.setOrderer(Context.getProviderService().getProvider(1));
  discontinuationOrder.setEncounter(Context.getEncounterService().getEncounter(6));
  
  expectedException.expect(EditedOrderDoesNotMatchPreviousException.class);
  expectedException.expectMessage(mss.getMessage("Order.type.doesnot.match"));
  orderService.saveOrder(discontinuationOrder, null);
}

代码示例来源:origin: openmrs/openmrs-core

/**
 * @see OrderService#saveOrder(org.openmrs.Order, OrderContext)
 */
@Test
public void saveOrder_shouldPassIfAnActiveTestOrderForTheSameConceptAndCareSettingExists() {
  final Patient patient = patientService.getPatient(2);
  final Concept cd4Count = conceptService.getConcept(5497);
  //sanity check that we have an active order for the same concept
  TestOrder duplicateOrder = (TestOrder) orderService.getOrder(7);
  assertTrue(duplicateOrder.isActive());
  assertEquals(cd4Count, duplicateOrder.getConcept());
  
  Order order = new TestOrder();
  order.setPatient(patient);
  order.setCareSetting(orderService.getCareSetting(2));
  order.setConcept(cd4Count);
  order.setEncounter(encounterService.getEncounter(6));
  order.setOrderer(providerService.getProvider(1));
  order.setCareSetting(duplicateOrder.getCareSetting());
  
  Order savedOrder = orderService.saveOrder(order, null);
  
  assertNotNull(orderService.getOrder(savedOrder.getOrderId()));
}

相关文章