@Override public EncounterTransaction.DrugOrder mapDrugOrder(DrugOrder openMRSDrugOrder) { EncounterTransaction.DrugOrder drugOrder = new EncounterTransaction.DrugOrder(); drugOrder.setUuid(openMRSDrugOrder.getUuid()); if (openMRSDrugOrder.getCareSetting() != null) { drugOrder.setCareSetting( CareSettingType.valueOf( openMRSDrugOrder.getCareSetting().getCareSettingType().toString())); } drugOrder.setAction(openMRSDrugOrder.getAction().name()); drugOrder.setOrderType(openMRSDrugOrder.getOrderType().getName()); org.openmrs.Order previousOrder = openMRSDrugOrder.getPreviousOrder(); if (previousOrder != null && StringUtils.isNotBlank(previousOrder.getUuid())) { drugOrder.setPreviousOrderUuid(previousOrder.getUuid()); } EncounterTransaction.Drug encounterTransactionDrug = new DrugMapper1_11().map(openMRSDrugOrder.getDrug()); drugOrder.setDrug(encounterTransactionDrug); drugOrder.setDosingInstructionType(openMRSDrugOrder.getDosingType().getName()); drugOrder.setDuration(openMRSDrugOrder.getDuration()); drugOrder.setDurationUnits(getConceptName(openMRSDrugOrder.getDurationUnits())); drugOrder.setScheduledDate(openMRSDrugOrder.getScheduledDate()); drugOrder.setDateActivated(openMRSDrugOrder.getDateActivated()); drugOrder.setEffectiveStartDate(openMRSDrugOrder.getEffectiveStartDate()); drugOrder.setAutoExpireDate(openMRSDrugOrder.getAutoExpireDate()); drugOrder.setEffectiveStopDate(openMRSDrugOrder.getEffectiveStopDate()); drugOrder.setDateStopped(openMRSDrugOrder.getDateStopped()); EncounterTransaction.DosingInstructions dosingInstructions = new EncounterTransaction.DosingInstructions(); dosingInstructions.setDose(openMRSDrugOrder.getDose()); dosingInstructions.setDoseUnits(getConceptName(openMRSDrugOrder.getDoseUnits())); dosingInstructions.setRoute(getConceptName(openMRSDrugOrder.getRoute())); dosingInstructions.setAsNeeded(openMRSDrugOrder.getAsNeeded()); if (openMRSDrugOrder.getFrequency() != null) { dosingInstructions.setFrequency(openMRSDrugOrder.getFrequency().getName()); } if (openMRSDrugOrder.getQuantity() != null) { dosingInstructions.setQuantity(openMRSDrugOrder.getQuantity()); } dosingInstructions.setQuantityUnits(getConceptName(openMRSDrugOrder.getQuantityUnits())); dosingInstructions.setAdministrationInstructions(openMRSDrugOrder.getDosingInstructions()); drugOrder.setDosingInstructions(dosingInstructions); drugOrder.setInstructions(openMRSDrugOrder.getInstructions()); drugOrder.setCommentToFulfiller(openMRSDrugOrder.getCommentToFulfiller()); drugOrder.setVoided(openMRSDrugOrder.getVoided()); drugOrder.setVoidReason(openMRSDrugOrder.getVoidReason()); drugOrder.setOrderNumber(openMRSDrugOrder.getOrderNumber()); return drugOrder; }
/** * @verifies not require all fields for a discontinuation order * @see DrugOrderValidator#validate(Object, org.springframework.validation.Errors) */ @Test public void validate_shouldNotRequireAllFieldsForADiscontinuationOrder() throws Exception { DrugOrder orderToDiscontinue = (DrugOrder) Context.getOrderService().getOrder(111); assertTrue(OrderUtilTest.isActiveOrder(orderToDiscontinue, null)); DrugOrder discontinuationOrder = new DrugOrder(); discontinuationOrder.setDosingType(null); discontinuationOrder.setCareSetting(orderToDiscontinue.getCareSetting()); discontinuationOrder.setConcept(orderToDiscontinue.getConcept()); discontinuationOrder.setAction(Order.Action.DISCONTINUE); discontinuationOrder.setPreviousOrder(orderToDiscontinue); discontinuationOrder.setPatient(orderToDiscontinue.getPatient()); discontinuationOrder.setDrug(orderToDiscontinue.getDrug()); discontinuationOrder.setOrderType(orderToDiscontinue.getOrderType()); discontinuationOrder.setOrderer(Context.getProviderService().getProvider(1)); discontinuationOrder.setEncounter(Context.getEncounterService().getEncounter(3)); Errors errors = new BindException(discontinuationOrder, "order"); new DrugOrderValidator().validate(discontinuationOrder, errors); Assert.assertFalse(errors.hasErrors()); }