/** * Sets autoExpireDate based on duration. * * @should delegate calculation to dosingInstructions * @should not calculate for discontinue action * @should not calculate if autoExpireDate already set */ public void setAutoExpireDateBasedOnDuration() { if (DISCONTINUE != getAction() && getAutoExpireDate() == null) { setAutoExpireDate(getDosingInstructionsInstance().getAutoExpireDate(this)); } }
private void validateFieldsForOutpatientCareSettingType(DrugOrder order, Errors errors) { if (order.getAction() != Order.Action.DISCONTINUE && order.getCareSetting() != null && order.getCareSetting().getCareSettingType().equals(CareSetting.CareSettingType.OUTPATIENT)) { ValidationUtils.rejectIfEmpty(errors, "quantity", "DrugOrder.error.quantityIsNullForOutPatient"); ValidationUtils.rejectIfEmpty(errors, "numRefills", "DrugOrder.error.numRefillsIsNullForOutPatient"); } }
@Override public String toString() { String prefix = DISCONTINUE == getAction() ? "DC " : ""; return prefix + "DrugOrder(" + getDose() + getDoseUnits() + " of " + (isNonCodedDrug() ? getDrugNonCoded() : (getDrug() != null ? getDrug().getName() : "[no drug]")) + " from " + getDateActivated() + " to " + (isDiscontinuedRightNow() ? getDateStopped() : getAutoExpireDate()) + ")"; }
if (order.getAction() != Order.Action.DISCONTINUE) { ValidationUtils.rejectIfEmpty(errors, "dosingType", "error.null"); errors.rejectValue("concept", "error.concept"); if (order.getAction() != Order.Action.DISCONTINUE && order.getDosingType() != null) { DosingInstructions dosingInstructions = order.getDosingInstructionsInstance(); dosingInstructions.validate(order, errors);
/** * @see OrderResource1_10#getDisplayString(org.openmrs.Order) */ @PropertyGetter("display") public static String getDisplay(DrugOrder delegate) { StringBuilder ret = new StringBuilder(); ret.append("(" + delegate.getAction() + ") "); if (delegate.getDrug() != null) { ret.append(delegate.getDrug().getName()); } else { ret.append(delegate.getConcept().getDisplayString()); } if (Order.Action.DISCONTINUE != delegate.getAction() && delegate.getDosingType() != null && delegate.getDosingInstructionsInstance() != null) { String dosingInstructionsAsString = delegate.getDosingInstructionsInstance().getDosingInstructionsAsString( Context.getLocale()); ret.append(": "); ret.append(dosingInstructionsAsString); } return ret.toString(); } }
/** * @see DrugOrder#cloneForDiscontinuing() */ @Test public void cloneForDiscontinuing_shouldSetAllTheRelevantFields() { DrugOrder order = new DrugOrder(); order.setPatient(new Patient()); order.setCareSetting(new CareSetting()); Drug drug = new Drug(); drug.setConcept(new Concept()); order.setDrug(drug); order.setOrderType(new OrderType()); DrugOrder dcOrder = order.cloneForDiscontinuing(); assertEquals(order.getDrug(), dcOrder.getDrug()); assertEquals(order.getPatient(), dcOrder.getPatient()); assertEquals(order.getConcept(), dcOrder.getConcept()); assertEquals("should set previous order to anOrder", order, dcOrder.getPreviousOrder()); assertEquals("should set new order action to new", dcOrder.getAction(), Order.Action.DISCONTINUE); assertEquals(order.getCareSetting(), dcOrder.getCareSetting()); assertEquals(order.getOrderType(), dcOrder.getOrderType()); }
DrugOrder discontinuationOrder = null; if (!existingOrder.getAction().equals(Action.DISCONTINUE)) {
if (!existingOrder.getAction().equals(Action.DISCONTINUE)) { lastRevision = drugOrder;