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

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

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

Order.getOrderId介绍

暂无

代码示例

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

@Override
public Integer getId() {
  return getOrderId();
}

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

private void failOnExistingOrder(Order order) {
  if (order.getOrderId() != null) {
    throw new UnchangeableObjectException("Order.cannot.edit.existing");
  }
}

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

@Override
public List<Object[]> getOrderFromDatabase(Order order, boolean isOrderADrugOrder) throws APIException {
  String sql = "SELECT patient_id, care_setting, concept_id FROM orders WHERE order_id = :orderId";
  
  if (isOrderADrugOrder) {
    sql = " SELECT o.patient_id, o.care_setting, o.concept_id, d.drug_inventory_id "
        + " FROM orders o, drug_order d WHERE o.order_id = d.order_id AND o.order_id = :orderId";
  }
  Query query = sessionFactory.getCurrentSession().createSQLQuery(sql);
  query.setParameter("orderId", order.getOrderId());
  
  //prevent hibernate from flushing before fetching the list
  query.setFlushMode(FlushMode.MANUAL);
  
  return query.list();
}

代码示例来源: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

/**
 * @see OrderService#getOrderHistoryByOrderNumber(String)
 */
@Test
public void getOrderHistoryByOrderNumber_shouldReturnAllOrderHistoryForGivenOrderNumber() {
  List<Order> orders = orderService.getOrderHistoryByOrderNumber("111");
  assertEquals(2, orders.size());
  assertEquals(111, orders.get(0).getOrderId().intValue());
  assertEquals(1, orders.get(1).getOrderId().intValue());
}

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

/**
 * @see OrderService#getOrderHistoryByConcept(Patient,Concept)
 */
@Test
public void getOrderHistoryByConcept_shouldReturnOrdersWithTheGivenConcept() {
  //We should have two orders with this concept.
  Concept concept = Context.getConceptService().getConcept(88);
  Patient patient = Context.getPatientService().getPatient(2);
  List<Order> orders = orderService.getOrderHistoryByConcept(patient, concept);
  
  //They must be sorted by dateActivated starting with the latest
  Assert.assertEquals(3, orders.size());
  Assert.assertEquals(444, orders.get(0).getOrderId().intValue());
  Assert.assertEquals(44, orders.get(1).getOrderId().intValue());
  Assert.assertEquals(4, orders.get(2).getOrderId().intValue());
  
  concept = Context.getConceptService().getConcept(792);
  orders = orderService.getOrderHistoryByConcept(patient, concept);
  
  //They must be sorted by dateActivated starting with the latest
  Assert.assertEquals(4, orders.size());
  Assert.assertEquals(3, orders.get(0).getOrderId().intValue());
  Assert.assertEquals(222, orders.get(1).getOrderId().intValue());
  Assert.assertEquals(22, orders.get(2).getOrderId().intValue());
  Assert.assertEquals(2, orders.get(3).getOrderId().intValue());
}

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

/**
 * @see OrderService#getOrderByUuid(String)
 */
@Test
public void getOrderByUuid_shouldFindObjectGivenValidUuid() {
  String uuid = "921de0a3-05c4-444a-be03-e01b4c4b9142";
  Order order = orderService.getOrderByUuid(uuid);
  Assert.assertEquals(1, (int) order.getOrderId());
}

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

/**
 * @see OrderService#getOrderByOrderNumber(String)
 */
@Test
public void getOrderByOrderNumber_shouldFindObjectGivenValidOrderNumber() {
  Order order = orderService.getOrderByOrderNumber("1");
  Assert.assertNotNull(order);
  Assert.assertEquals(1, (int) order.getOrderId());
}

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

/**
 * @see OrderService#getOrders(org.openmrs.Patient, org.openmrs.CareSetting,
 *      org.openmrs.OrderType, boolean)
 */
@Test
public void getOrders_shouldGetTheOrdersThatMatchAllTheArguments() {
  Patient patient = patientService.getPatient(2);
  CareSetting outPatient = orderService.getCareSetting(1);
  OrderType testOrderType = orderService.getOrderType(2);
  List<Order> testOrders = orderService.getOrders(patient, outPatient, testOrderType, false);
  assertEquals(3, testOrders.size());
  TestUtil.containsId(testOrders, 6);
  TestUtil.containsId(testOrders, 7);
  TestUtil.containsId(testOrders, 9);
  
  OrderType drugOrderType = orderService.getOrderType(1);
  List<Order> drugOrders = orderService.getOrders(patient, outPatient, drugOrderType, false);
  assertEquals(5, drugOrders.size());
  TestUtil.containsId(drugOrders, 2);
  TestUtil.containsId(drugOrders, 3);
  TestUtil.containsId(drugOrders, 44);
  TestUtil.containsId(drugOrders, 444);
  TestUtil.containsId(drugOrders, 5);
  
  CareSetting inPatient = orderService.getCareSetting(2);
  List<Order> inPatientDrugOrders = orderService.getOrders(patient, inPatient, drugOrderType, false);
  assertEquals(222, inPatientDrugOrders.get(0).getOrderId().intValue());
}

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

if (o.getOrderId() == null) {
  Context.getOrderService().saveOrder(o, null);

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

@Test
public void saveOrder_shouldDiscontinuePreviousNonCodedOrderIfItIsNotAlreadyDiscontinued() {
  //We are trying to discontinue order id 584 in OrderServiceTest-nonCodedDrugs.xml
  executeDataSet("org/openmrs/api/include/OrderServiceTest-nonCodedDrugs.xml");
  DrugOrder previousOrder = (DrugOrder) orderService.getOrder(584);
  DrugOrder drugOrder = previousOrder.cloneForDiscontinuing();
  drugOrder.setPreviousOrder(previousOrder);
  drugOrder.setDateActivated(new Date());
  drugOrder.setOrderer(previousOrder.getOrderer());
  drugOrder.setEncounter(previousOrder.getEncounter());
  
  Order saveOrder = orderService.saveOrder(drugOrder, null);
  Assert.assertNotNull("previous order should be discontinued", previousOrder.getDateStopped());
  assertNotNull(orderService.getOrder(saveOrder.getOrderId()));
}

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

/**
 * @see ObsService#purgeObs(Obs,boolean)
 */
@Test
public void purgeObs_shouldNotDeleteReferencedOrdersWhenPurgingObs() {
  
  executeDataSet(INITIAL_OBS_XML);
  ObsService obsService = Context.getObsService();
  final OrderService orderService = Context.getOrderService();
  
  final int orderReferencingObsId = 4;
  final Obs obs = obsService.getObs(orderReferencingObsId);
  
  final Order order = obs.getOrder();
  final Integer referencedOrderId = order.getOrderId();
  
  Context.getObsService().purgeObs(obs, false);
  
  Assert.assertNull(obsService.getObs(orderReferencingObsId));
  Assert.assertNotNull(orderService.getOrder(referencedOrderId));
}

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

/**
   * @see {@link HibernateOrderDAO#saveOrderGroup(OrderGroup)}
   * @throws Exception
   */
  @Test
  public void saveOrderGroup_shouldSaveOrderGroup() {
    OrderGroup newOrderGroup = new OrderGroup();
    
    final Order order = new OrderBuilder().withAction(Order.Action.NEW).withPatient(7).withConcept(1000)
        .withCareSetting(1).withOrderer(1).withEncounter(3).withDateActivated(new Date()).withOrderType(17)
        .withUrgency(Order.Urgency.ON_SCHEDULED_DATE).withScheduledDate(new Date()).build();
    
    newOrderGroup.setOrders(new ArrayList<Order>() {
      
      {
        add(order);
      }
    });
    
    OrderGroup savedOrderGroup = dao.saveOrderGroup(newOrderGroup);
    assertNotNull("OrderGroup gets saved", savedOrderGroup.getOrderGroupId());
    
    for (Order savedOrder : savedOrderGroup.getOrders()) {
      assertNull("Order is not saved as a part of Order Group", savedOrder.getOrderId());
    }
    
  }
}

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

/**
 * This test ensures that the getter for previous order field returns objects of the actual sub
 * types for subclasses instead proxies that are instances of Order
 * 
 * @throws Exception
 */
@Test
public void shouldNotReturnAProxyForPreviousOrder() {
  Order dcOrder = orderService.getOrder(22);
  Order previousOrder = dcOrder.getPreviousOrder();
  assertNotNull(previousOrder);
  
  Order testOrder = orderService.getOrder(7);
  Order dcTestOrder = orderService.discontinueOrder(testOrder, "Testing", null, testOrder.getOrderer(), testOrder
      .getEncounter());
  Context.flushSession();
  Context.clearSession();
  dcTestOrder = orderService.getOrder(dcTestOrder.getOrderId()).getPreviousOrder();
}

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

/**
 * @see OrderService#saveOrder(Order, OrderContext)
 */
@Test
public void saveOrder_shouldPassIfAnActiveDrugOrderForTheSameConceptAndDifferentDrugNonCodedExists() {
  executeDataSet("org/openmrs/api/include/OrderServiceTest-nonCodedDrugs.xml");
  final Concept nonCodedConcept = orderService.getNonCodedDrugConcept();
  //sanity check that we have an active order for the same concept
  DrugOrder duplicateOrder = (DrugOrder) orderService.getOrder(584);
  assertTrue(duplicateOrder.isActive());
  assertEquals(nonCodedConcept, duplicateOrder.getConcept());
  
  DrugOrder drugOrder = duplicateOrder.copy();
  drugOrder.setDrugNonCoded("non coded drug paracetemol");
  
  Order savedOrder = orderService.saveOrder(drugOrder, null);
  assertNotNull(orderService.getOrder(savedOrder.getOrderId()));
}

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

@Test
public void saveOrderWithScheduledDate_shouldAddANewOrderWithScheduledDateToTheDatabase() {
  Date scheduledDate = new Date();
  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.setDateActivated(new Date());
  order.setScheduledDate(scheduledDate);
  order.setUrgency(Order.Urgency.ON_SCHEDULED_DATE);
  order.setEncounter(encounterService.getEncounter(3));
  order.setOrderType(orderService.getOrderType(17));
  order = orderService.saveOrder(order, null);
  Order newOrder = orderService.getOrder(order.getOrderId());
  assertNotNull(order);
  assertEquals(DateUtil.truncateToSeconds(scheduledDate), order.getScheduledDate());
  assertNotNull(newOrder);
  assertEquals(DateUtil.truncateToSeconds(scheduledDate), newOrder.getScheduledDate());
}

代码示例来源: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()));
}

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

assertNotNull(orderService.getOrder(savedSecondOrder.getOrderId()));

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

assertNotNull(orderService.getOrder(savedRevisionOrder.getOrderId()));

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

/**
 * @see OrderService#saveOrder(org.openmrs.Order, OrderContext)
 */
@Test
public void saveOrder_shouldPassIfAnActiveDrugOrderForTheSameConceptAndCareSettingButDifferentFormulationExists()
{
  executeDataSet("org/openmrs/api/include/OrderServiceTest-drugOrdersWithSameConceptAndDifferentFormAndStrength.xml");
  final Patient patient = patientService.getPatient(2);
  //sanity check that we have an active order
  DrugOrder existingOrder = (DrugOrder) orderService.getOrder(1000);
  assertTrue(existingOrder.isActive());
  //New Drug order
  DrugOrder order = new DrugOrder();
  order.setPatient(patient);
  order.setConcept(existingOrder.getConcept());
  order.setEncounter(encounterService.getEncounter(6));
  order.setOrderer(providerService.getProvider(1));
  order.setCareSetting(existingOrder.getCareSetting());
  order.setDrug(conceptService.getDrug(3001));
  order.setDosingType(FreeTextDosingInstructions.class);
  order.setDosingInstructions("2 for 5 days");
  order.setQuantity(10.0);
  order.setQuantityUnits(conceptService.getConcept(51));
  order.setNumRefills(2);
  
  Order savedDrugOrder = orderService.saveOrder(order, null);
  
  assertNotNull(orderService.getOrder(savedDrugOrder.getOrderId()));
}

相关文章