本文整理了Java中org.openmrs.Order.setPatient()
方法的一些代码示例,展示了Order.setPatient()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Order.setPatient()
方法的具体详情如下:
包路径:org.openmrs.Order
类名称:Order
方法名:setPatient
暂无
代码示例来源:origin: openmrs/openmrs-core
public OrderBuilder withPatient(Integer patientID) {
order.setPatient(patientService.getPatient(patientID));
return this;
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see org.openmrs.api.handler.SaveHandler#handle(org.openmrs.OpenmrsObject, org.openmrs.User,
* java.util.Date, java.lang.String)
*/
@Override
public void handle(Order order, User creator, Date dateCreated, String other) {
if (order.getPatient() == null && order.getEncounter() != null) {
order.setPatient(order.getEncounter().getPatient());
}
}
}
代码示例来源:origin: openmrs/openmrs-core
/**
* Creates a discontinuation order for this order, sets the previousOrder and action fields,
* note that the discontinuation order needs to be saved for the discontinuation to take effect
*
* @return the newly created order
* @since 1.10
* @should set all the relevant fields
*/
public Order cloneForDiscontinuing() {
Order newOrder = new Order();
newOrder.setCareSetting(getCareSetting());
newOrder.setConcept(getConcept());
newOrder.setAction(Action.DISCONTINUE);
newOrder.setPreviousOrder(this);
newOrder.setPatient(getPatient());
newOrder.setOrderType(getOrderType());
return newOrder;
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see OrderService#saveOrder(org.openmrs.Order, OrderContext)
*/
@Test
public void saveOrder_shouldNotSaveOrderIfOrderDoesntValidate() {
Order order = new Order();
order.setPatient(null);
order.setOrderer(null);
expectedException.expect(APIException.class);
expectedException.expectMessage("failed to validate with reason:");
orderService.saveOrder(order, null);
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see OrderValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailValidationIfDateActivatedAfterAutoExpireDate() {
Order order = new Order();
order.setConcept(Context.getConceptService().getConcept(88));
order.setPatient(Context.getPatientService().getPatient(2));
order.setOrderer(Context.getProviderService().getProvider(1));
Calendar cal = Calendar.getInstance();
cal.set(Calendar.DAY_OF_MONTH, cal.get(Calendar.DAY_OF_MONTH) - 1);
order.setDateActivated(new Date());
order.setAutoExpireDate(cal.getTime());
Errors errors = new BindException(order, "order");
new OrderValidator().validate(order, errors);
Assert.assertTrue(errors.hasFieldErrors("dateActivated"));
Assert.assertTrue(errors.hasFieldErrors("autoExpireDate"));
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @throws Exception
* @see OrderValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailValidationIfDateActivatedAfterDateStopped() throws Exception {
Order order = new Order();
order.setConcept(Context.getConceptService().getConcept(88));
order.setPatient(Context.getPatientService().getPatient(2));
order.setOrderer(Context.getProviderService().getProvider(1));
Calendar cal = Calendar.getInstance();
cal.set(Calendar.DAY_OF_MONTH, cal.get(Calendar.DAY_OF_MONTH) - 1);
order.setDateActivated(new Date());
OrderUtilTest.setDateStopped(order, cal.getTime());
Errors errors = new BindException(order, "order");
new OrderValidator().validate(order, errors);
Assert.assertTrue(errors.hasFieldErrors("dateActivated"));
Assert.assertTrue(errors.hasFieldErrors("dateStopped"));
}
代码示例来源: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
@Test
public void shouldAllowRetrospectiveDataEntryOfOrders() {
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));
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DAY_OF_WEEK, -1);
order.setDateActivated(cal.getTime());
orderService.saveOrder(order, null);
cal.add(Calendar.HOUR_OF_DAY, -1);
Date stopDate = cal.getTime();
Order dcOrder = orderService.discontinueOrder(order, "Testing", stopDate, order.getOrderer(), order.getEncounter());
Context.flushSession(); // ensures that order is flushed and that the drop milliseconds interceptor is called
assertEquals(DateUtil.truncateToSeconds(stopDate), order.getDateStopped());
assertEquals(DateUtil.truncateToSeconds(stopDate), dcOrder.getAutoExpireDate());
}
代码示例来源: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 OrderValidator#validate(Object, org.springframework.validation.Errors)
*/
@Test
public void validate_shouldFailValidationIfOrderTypejavaClassDoesNotMatchOrderclass() {
Order order = new DrugOrder();
order.setConcept(Context.getConceptService().getConcept(88));
order.setPatient(Context.getPatientService().getPatient(2));
order.setOrderer(Context.getProviderService().getProvider(1));
order.setOrderType(Context.getOrderService().getOrderTypeByName("Test order"));
Errors errors = new BindException(order, "order");
new OrderValidator().validate(order, errors);
Assert.assertTrue(errors.hasFieldErrors("orderType"));
Assert.assertTrue(Arrays.asList(errors.getFieldError("orderType").getCodes()).contains(
"Order.error.orderTypeClassMismatchesOrderClass"));
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see OrderValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailValidationIfActionIsNull() {
Order order = new Order();
order.setConcept(Context.getConceptService().getConcept(88));
order.setPatient(Context.getPatientService().getPatient(2));
order.setAction(null);
Errors errors = new BindException(order, "order");
new OrderValidator().validate(order, errors);
Assert.assertTrue(errors.hasFieldErrors("action"));
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see OrderService#saveOrder(org.openmrs.Order, OrderContext)
*/
@Test
public void saveOrder_shouldSetTheOrderNumberReturnedByTheConfiguredGenerator() {
GlobalProperty gp = new GlobalProperty(OpenmrsConstants.GP_ORDER_NUMBER_GENERATOR_BEAN_ID,
"orderEntry.OrderNumberGenerator");
Context.getAdministrationService().saveGlobalProperty(gp);
Order order = new TestOrder();
order.setPatient(patientService.getPatient(7));
order.setConcept(conceptService.getConcept(5497));
order.setOrderer(providerService.getProvider(1));
order.setCareSetting(orderService.getCareSetting(1));
order.setOrderType(orderService.getOrderType(2));
order.setEncounter(encounterService.getEncounter(3));
order.setDateActivated(new Date());
order = orderService.saveOrder(order, null);
assertTrue(order.getOrderNumber().startsWith(TimestampOrderNumberGenerator.ORDER_NUMBER_PREFIX));
}
代码示例来源: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,Errors)
*/
@Test
public void validate_shouldFailValidationIfUrgencyIsNull() {
Order order = new Order();
order.setConcept(Context.getConceptService().getConcept(88));
order.setPatient(Context.getPatientService().getPatient(2));
order.setUrgency(null);
Errors errors = new BindException(order, "order");
new OrderValidator().validate(order, errors);
Assert.assertTrue(errors.hasFieldErrors("urgency"));
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see OrderValidator#validate(Object, org.springframework.validation.Errors)
*/
@Test
public void validate_shouldFailValidationIfScheduledDateIsSetAndUrgencyIsNotSetAsON_SCHEDULED_DATE() {
Order order = new Order();
order.setConcept(Context.getConceptService().getConcept(88));
order.setPatient(Context.getPatientService().getPatient(2));
order.setOrderer(Context.getProviderService().getProvider(1));
order.setScheduledDate(new Date());
order.setUrgency(Order.Urgency.ROUTINE);
Errors errors = new BindException(order, "order");
new OrderValidator().validate(order, errors);
Assert.assertTrue(errors.hasFieldErrors("urgency"));
order.setScheduledDate(new Date());
order.setUrgency(Order.Urgency.ON_SCHEDULED_DATE);
errors = new BindException(order, "order");
new OrderValidator().validate(order, errors);
Assert.assertFalse(errors.hasFieldErrors("urgency"));
}
代码示例来源: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 OrderValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailValidationIfConceptIsNull() {
Order order = new Order();
order.setPatient(Context.getPatientService().getPatient(2));
order.setOrderer(Context.getProviderService().getProvider(1));
Errors errors = new BindException(order, "order");
new OrderValidator().validate(order, errors);
Assert.assertFalse(errors.hasFieldErrors("discontinued"));
Assert.assertTrue(errors.hasFieldErrors("concept"));
Assert.assertFalse(errors.hasFieldErrors("patient"));
Assert.assertFalse(errors.hasFieldErrors("orderer"));
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see OrderValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailValidationIfOrdererIsNull() {
Order order = new Order();
order.setConcept(Context.getConceptService().getConcept(88));
order.setPatient(Context.getPatientService().getPatient(2));
Errors errors = new BindException(order, "order");
new OrderValidator().validate(order, errors);
Assert.assertFalse(errors.hasFieldErrors("discontinued"));
Assert.assertFalse(errors.hasFieldErrors("concept"));
Assert.assertTrue(errors.hasFieldErrors("orderer"));
Assert.assertFalse(errors.hasFieldErrors("patient"));
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see OrderValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailValidationIfVoidedIsNull() {
Order order = new Order();
order.setVoided(null);
order.setConcept(Context.getConceptService().getConcept(88));
order.setPatient(Context.getPatientService().getPatient(2));
order.setOrderer(Context.getProviderService().getProvider(1));
Errors errors = new BindException(order, "order");
new OrderValidator().validate(order, errors);
Assert.assertFalse(errors.hasFieldErrors("discontinued"));
Assert.assertTrue(errors.hasFieldErrors("voided"));
Assert.assertFalse(errors.hasFieldErrors("concept"));
Assert.assertFalse(errors.hasFieldErrors("patient"));
Assert.assertFalse(errors.hasFieldErrors("orderer"));
}
内容来源于网络,如有侵权,请联系作者删除!