@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()) + ")"; }
private void validatePairedFields(DrugOrder order, Errors errors) { if (order.getDose() != null) { ValidationUtils.rejectIfEmpty(errors, "doseUnits", "DrugOrder.error.doseUnitsRequiredWithDose"); } if (order.getQuantity() != null) { ValidationUtils.rejectIfEmpty(errors, "quantityUnits", "DrugOrder.error.quantityUnitsRequiredWithQuantity"); } if (order.getDuration() != null) { ValidationUtils.rejectIfEmpty(errors, "durationUnits", "DrugOrder.error.durationUnitsRequiredWithDuration"); } }
/** * @see DosingInstructions#getDosingInstructions(DrugOrder) */ @Override public DosingInstructions getDosingInstructions(DrugOrder order) { if (!order.getDosingType().equals(this.getClass())) { throw new APIException("DrugOrder.error.dosingTypeIsMismatched", new Object[] { this.getClass().getName(), order.getDosingType() }); } SimpleDosingInstructions simpleDosingInstructions = new SimpleDosingInstructions(); simpleDosingInstructions.setDose(order.getDose()); simpleDosingInstructions.setDoseUnits(order.getDoseUnits()); simpleDosingInstructions.setRoute(order.getRoute()); simpleDosingInstructions.setFrequency(order.getFrequency()); simpleDosingInstructions.setDuration(order.getDuration()); simpleDosingInstructions.setDurationUnits(order.getDurationUnits()); simpleDosingInstructions.setAsNeeded(order.getAsNeeded()); simpleDosingInstructions.setAsNeededCondition(order.getAsNeededCondition()); simpleDosingInstructions.setAdministrationInstructions(order.getDosingInstructions()); return simpleDosingInstructions; }
/** * Gets a user-friendly display representation of the delegate * * @param o * @return */ @PropertyGetter("display") public static String getDisplay(DrugOrder delegate) { StringBuilder ret = new StringBuilder(); ret.append(delegate.getDrug() != null ? delegate.getDrug().getName() : "[no drug]"); ret.append(": "); ret.append(delegate.getDose()).append(" ").append(delegate.getUnits()); // TODO dates, etc return ret.toString(); } }
/** * @see org.openmrs.Order#copyHelper(Order) */ protected DrugOrder copyHelper(DrugOrder target) { super.copyHelper(target); target.setDose(getDose()); target.setDoseUnits(getDoseUnits()); target.setFrequency(getFrequency()); target.setAsNeeded(getAsNeeded()); target.setAsNeededCondition(getAsNeededCondition()); target.setQuantity(getQuantity()); target.setQuantityUnits(getQuantityUnits()); target.setDrug(getDrug()); target.setDosingType(getDosingType()); target.setDosingInstructions(getDosingInstructions()); target.setDuration(getDuration()); target.setDurationUnits(getDurationUnits()); target.setNumRefills(getNumRefills()); target.setRoute(getRoute()); target.setBrandName(getBrandName()); target.setDispenseAsWritten(getDispenseAsWritten()); target.setDrugNonCoded(getDrugNonCoded()); return target; }
@Test public void shouldUpdateDrugOrder() throws Exception { SimpleObject content = new SimpleObject(); content.add("dose", "500"); MockHttpServletRequest req = newPostRequest(getURI() + "/" + DRUG_ORDER_UUID, content); handle(req); DrugOrder order = (DrugOrder) service.getOrderByUuid(DRUG_ORDER_UUID); Assert.assertEquals(Double.valueOf("500"), order.getDose()); }
/** * @see Order#cloneForRevisionHelper(Order) */ protected DrugOrder cloneForRevisionHelper(DrugOrder target) { super.cloneForRevisionHelper(target); target.setDose(getDose()); target.setDoseUnits(getDoseUnits()); target.setFrequency(getFrequency()); target.setAsNeeded(getAsNeeded()); target.setAsNeededCondition(getAsNeededCondition()); target.setQuantity(getQuantity()); target.setQuantityUnits(getQuantityUnits()); target.setDrug(getDrug()); target.setDosingType(getDosingType()); target.setDosingInstructions(getDosingInstructions()); target.setDuration(getDuration()); target.setDurationUnits(getDurationUnits()); target.setRoute(getRoute()); target.setNumRefills(getNumRefills()); target.setBrandName(getBrandName()); target.setDispenseAsWritten(getDispenseAsWritten()); target.setDrugNonCoded(getDrugNonCoded()); return target; }
/** * See RESTWS-418 - Allow REST POST requests to accept un-updatable properties if they haven't * been updated */ @Test public void shouldAllowYouToPostANonUpdatablePropertyWithAnUnchangedValue() throws Exception { MockHttpServletRequest get = request(RequestMethod.GET, getURI() + "/" + DRUG_ORDER_UUID); SimpleObject drugOrder = deserialize(handle(get)); // doing this will no longer be allowed in OpenMRS 1.10, but it's fine as a test case against 1.8 code drugOrder.put("dose", "500"); MockHttpServletRequest post = newPostRequest(getURI() + "/" + DRUG_ORDER_UUID, drugOrder); handle(post); DrugOrder updatedOrder = (DrugOrder) service.getOrderByUuid(DRUG_ORDER_UUID); assertThat(updatedOrder.getDose(), is(500d)); }
order.setDateActivated(newOrderDateActivated); order.setDrug(duplicateOrder.getDrug()); order.setDose(duplicateOrder.getDose()); order.setDoseUnits(duplicateOrder.getDoseUnits()); order.setRoute(duplicateOrder.getRoute());
doseWidget.setInitialValue(drugOrder.getDose()); frequencyWidget.setInitialValue(parseFrequencyDays(drugOrder.getFrequency())); frequencyWeekWidget.setInitialValue(parseFrequencyWeek(drugOrder.getFrequency()));
order.setDateActivated(new Date()); order.setDosingType(SimpleDosingInstructions.class); order.setDose(orderToDiscontinue.getDose()); order.setDoseUnits(orderToDiscontinue.getDoseUnits()); order.setRoute(orderToDiscontinue.getRoute());
drugOrder.setCareSetting(duplicateOrder.getCareSetting()); drugOrder.setDrug(duplicateOrder.getDrug()); drugOrder.setDose(duplicateOrder.getDose()); drugOrder.setDoseUnits(duplicateOrder.getDoseUnits()); drugOrder.setRoute(duplicateOrder.getRoute());
doseWidget.setInitialValue(lastRevision.getDose());