/** * @see OrderService#getOrderTypeByUuid(String) */ @Test public void getOrderTypeByUuid_shouldReturnNullIfNoOrderTypeObjectFoundWithGivenUuid() { assertNull(orderService.getOrderTypeByUuid("some random uuid")); }
/** * @see OrderService#getOrderTypeByUuid(String) */ @Test public void getOrderTypeByUuid_shouldFindOrderTypeObjectGivenValidUuid() { OrderType orderType = orderService.getOrderTypeByUuid("131168f4-15f5-102d-96e4-000c29c2a5d7"); assertEquals("Drug order", orderType.getName()); }
private boolean areDrugOrdersOfSameOrderableAndOverlappingSchedule(Order firstOrder, Order secondOrder) { return firstOrder.hasSameOrderableAs(secondOrder) && !OpenmrsUtil.nullSafeEquals(firstOrder.getPreviousOrder(), secondOrder) && OrderUtil.checkScheduleOverlap(firstOrder, secondOrder) && firstOrder.getOrderType().equals( Context.getOrderService().getOrderTypeByUuid(OrderType.DRUG_ORDER_TYPE_UUID)); }
private void ensureOrderTypeIsSet(Order order, OrderContext orderContext) { if (order.getOrderType() != null) { return; } OrderType orderType = null; if (orderContext != null) { orderType = orderContext.getOrderType(); } if (orderType == null) { orderType = getOrderTypeByConcept(order.getConcept()); } if (orderType == null && order instanceof DrugOrder) { orderType = Context.getOrderService().getOrderTypeByUuid(OrderType.DRUG_ORDER_TYPE_UUID); } if (orderType == null && order instanceof TestOrder) { orderType = Context.getOrderService().getOrderTypeByUuid(OrderType.TEST_ORDER_TYPE_UUID); } if (orderType == null) { throw new OrderEntryException("Order.type.cannot.determine"); } Order previousOrder = order.getPreviousOrder(); if (previousOrder != null && !orderType.equals(previousOrder.getOrderType())) { throw new OrderEntryException("Order.type.does.not.match"); } order.setOrderType(orderType); }
/** * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getByUniqueId(java.lang.String) */ @Override public OrderType getByUniqueId(String uniqueId) { return Context.getOrderService().getOrderTypeByUuid(uniqueId); }
/** * Fetches an orderType by uuid * * @see DelegatingCrudResource#getByUniqueId(java.lang.String) */ @Override public OrderType getByUniqueId(String uniqueId) { OrderType ot = Context.getOrderService().getOrderTypeByUuid(uniqueId); if (ot == null) { ot = Context.getOrderService().getOrderTypeByName(uniqueId); } return ot; }
@Override public OrderType newObject() { return Context.getOrderService().getOrderTypeByUuid(getUuidProperty()); }
/** * @see OrderService#saveOrder(org.openmrs.Order, OrderContext) */ @Test public void saveOrder_shouldSetOrderTypeOfTestOrderToTestOrderIfNotSetAndConceptNotMapped() { TestOrder testOrder = new TestOrder(); testOrder.setPatient(patientService.getPatient(7)); Concept unmappedConcept = conceptService.getConcept(113); Assert.assertNull(orderService.getOrderTypeByConcept(unmappedConcept)); testOrder.setConcept(unmappedConcept); testOrder.setOrderer(providerService.getProvider(1)); testOrder.setCareSetting(orderService.getCareSetting(1)); Encounter encounter = encounterService.getEncounter(3); testOrder.setEncounter(encounter); testOrder.setDateActivated(encounter.getEncounterDatetime()); testOrder.setClinicalHistory("Patient had a negative reaction to the test in the past"); testOrder.setFrequency(orderService.getOrderFrequency(3)); testOrder.setSpecimenSource(conceptService.getConcept(22)); testOrder.setNumberOfRepeats(3); orderService.saveOrder(testOrder, null); Assert.assertNotNull(testOrder.getOrderType()); Assert.assertEquals(orderService.getOrderTypeByUuid(OrderType.TEST_ORDER_TYPE_UUID), testOrder.getOrderType()); }
for (String orderTypeUuid : orderTypeUuids.split(",")) { if (!orderTypeUuid.trim().equalsIgnoreCase("")) { orderType = orderService.getOrderTypeByUuid(orderTypeUuid); if (orderType != null) { orderTypes.add(orderType);
@Test public void shouldPurgeAnOrderType() throws Exception { String uuid = "00e17510-aa09-11e3-a5e2-0800200c9a66"; assertNotNull(service.getOrderTypeByUuid(uuid)); MockHttpServletRequest req = request(RequestMethod.DELETE, getURI() + "/" + uuid); req.addParameter("purge", "true"); handle(req); assertNull(service.getOrderTypeByUuid(uuid)); }
Assert.assertEquals(orderService.getOrderTypeByUuid(OrderType.DRUG_ORDER_TYPE_UUID), drugOrder.getOrderType());
@Override public OrderSet save(OrderSet orderSet) { if (CollectionUtils.isNotEmpty(orderSet.getOrderSetMembers())) { for (OrderSetMember orderSetMember : orderSet.getOrderSetMembers()) { if (null != orderSetMember.getConcept() && StringUtils.isNotEmpty(orderSetMember.getConcept().getUuid())) { orderSetMember.setConcept(Context.getConceptService().getConceptByUuid( orderSetMember.getConcept().getUuid())); } if (null != orderSetMember.getOrderType() && StringUtils.isNotEmpty(orderSetMember.getOrderType().getUuid())) { orderSetMember.setOrderType(Context.getOrderService().getOrderTypeByUuid( orderSetMember.getOrderType().getUuid())); } } } return Context.getOrderSetService().saveOrderSet(orderSet); }
@Test public void shouldEditAnOrderType() throws Exception { final String newName = "Updated name"; SimpleObject conceptMapTypeType = new SimpleObject(); conceptMapTypeType.add("name", newName); String json = new ObjectMapper().writeValueAsString(conceptMapTypeType); MockHttpServletRequest req = request(RequestMethod.POST, getURI() + "/" + getUuid()); req.setContent(json.getBytes()); handle(req); assertEquals(newName, service.getOrderTypeByUuid(getUuid()).getName()); }
@Test public void shouldRetireAnOrderType() throws Exception { assertEquals(false, service.getOrderTypeByUuid(getUuid()).isRetired()); MockHttpServletRequest req = request(RequestMethod.DELETE, getURI() + "/" + getUuid()); req.addParameter("!purge", ""); final String reason = "none"; req.addParameter("reason", reason); handle(req); assertEquals(true, service.getOrderTypeByUuid(getUuid()).isRetired()); assertEquals(reason, service.getOrderTypeByUuid(getUuid()).getRetireReason()); } }
@Test public void shouldGetAnOrderTypeByUuid() throws Exception { SimpleObject result = deserialize(handle(newGetRequest(getURI() + "/" + getUuid()))); OrderType expectedOrderType = service.getOrderTypeByUuid(getUuid()); assertEquals(expectedOrderType.getUuid(), PropertyUtils.getProperty(result, "uuid")); assertEquals(expectedOrderType.getName(), PropertyUtils.getProperty(result, "name")); assertEquals(expectedOrderType.getJavaClassName(), PropertyUtils.getProperty(result, "javaClassName")); assertEquals(expectedOrderType.getDescription(), PropertyUtils.getProperty(result, "description")); assertEquals(expectedOrderType.isRetired(), PropertyUtils.getProperty(result, "retired")); assertNull(PropertyUtils.getProperty(result, "auditInfo")); }
dor.setDateChanged(new Date()); dor.setCreator(Context.getAuthenticatedUser()); dor.setOrderType(Context.getOrderService().getOrderTypeByUuid(DrugOrderSubmissionElement1_10.DRUG_ORDER_TYPE_UUID)); ret.add(dor);
drugOrder.setAutoExpireDate(calculateAutoExpireDate(orderTag.startDate, orderTag.orderDuration)); drugOrder.setVoided(false); drugOrder.setOrderType(Context.getOrderService().getOrderTypeByUuid(DRUG_ORDER_TYPE_UUID)); if (!StringUtils.isEmpty(orderTag.instructions)) drugOrder.setInstructions((String) orderTag.instructions);