/** * @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; }
@Test public void saveOrder_shouldRevisePreviousNonCodedOrderIfItIsAlreadyExisting() { //We are trying to discontinue order id 584 in OrderServiceTest-nonCodedDrugs.xml executeDataSet("org/openmrs/api/include/OrderServiceTest-nonCodedDrugs.xml"); DrugOrder previousOrder = (DrugOrder) orderService.getOrder(584); DrugOrder order = previousOrder.cloneForRevision(); order.setDateActivated(new Date()); order.setOrderer(providerService.getProvider(1)); order.setEncounter(encounterService.getEncounter(6)); order.setAsNeeded(true); order.setPreviousOrder(previousOrder); DrugOrder saveOrder = (DrugOrder) orderService.saveOrder(order, null); Assert.assertTrue(saveOrder.getAsNeeded()); assertNotNull(orderService.getOrder(saveOrder.getOrderId())); }
/** * @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 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; }