/** * Checks whether orderable of this drug order is same as other order * * @since 1.10 * @param otherOrder the other order to match on * @return true if the drugs match * @should return false if the other order is null * @should return false if the other order is not a drug order * @should return false if both drugs are null and the concepts are different * @should return false if the concepts match and only this has a drug * @should return false if the concepts match and only the other has a drug * @should return false if the concepts match and drugs are different and not null * @should return true if both drugs are null and the concepts match * @should return true if the drugs match */ @Override public boolean hasSameOrderableAs(Order otherOrder) { if (!super.hasSameOrderableAs(otherOrder)) { return false; } if (!(otherOrder instanceof DrugOrder)) { return false; } DrugOrder otherDrugOrder = (DrugOrder) otherOrder; if (isNonCodedDrug() || otherDrugOrder.isNonCodedDrug()) { return OpenmrsUtil.nullSafeEqualsIgnoreCase(this.getDrugNonCoded(), otherDrugOrder.getDrugNonCoded()); } return OpenmrsUtil.nullSafeEquals(this.getDrug(), otherDrugOrder.getDrug()); }
private void validateForRequireDrug(Errors errors, DrugOrder order) { //Reject if global property is set to specify a formulation for drug order boolean requireDrug = Context.getAdministrationService().getGlobalPropertyValue( OpenmrsConstants.GLOBAL_PROPERTY_DRUG_ORDER_REQUIRE_DRUG, false); OrderService orderService = Context.getOrderService(); if(requireDrug){ if(order.getConcept() != null && OpenmrsUtil.nullSafeEquals(orderService.getNonCodedDrugConcept(), order.getConcept())){ if(order.getDrug() == null && !order.isNonCodedDrug()){ errors.rejectValue("drugNonCoded", "DrugOrder.error.drugNonCodedIsRequired"); } else if(order.getDrug() != null){ errors.rejectValue("concept", "DrugOrder.error.onlyOneOfDrugOrNonCodedShouldBeSet"); } }else{ if(order.getDrug() == null && !order.isNonCodedDrug()){ errors.rejectValue("drug", "DrugOrder.error.drugIsRequired"); } else if(order.getDrug() != null && order.isNonCodedDrug()){ errors.rejectValue("concept", "DrugOrder.error.onlyOneOfDrugOrNonCodedShouldBeSet"); } } } }
@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()) + ")"; }
asOfDate); boolean isDrugOrderAndHasADrug = isDrugOrder(order) && (((DrugOrder) order).getDrug() != null || ((DrugOrder) order).isNonCodedDrug()); Order orderToBeDiscontinued = null; for (Order activeOrder : orders) {