Source:
<code>public DrugOrder map(EncounterTransaction.DrugOrder drugOrder, Encounter encounter) { DrugOrder openMRSDrugOrder = createDrugOrder(drugOrder); openMRSDrugOrder.setCareSetting(getCareSettingFrom(drugOrder, openMRSDrugOrder)); openMRSDrugOrder.setDrug(getDrugFrom(drugOrder, openMRSDrugOrder)); openMRSDrugOrder.setConcept(openMRSDrugOrder.getDrug().getConcept()); openMRSDrugOrder.setEncounter(encounter); <START> openMRSDrugOrder.setOrderType(orderService.getOrderTypeByName(drugOrder.getOrderType())); <END> openMRSDrugOrder.setDateActivated(drugOrder.getDateActivated()); if (drugOrder.getScheduledDate() != null && drugOrder.getScheduledDate().after(new Date())) { openMRSDrugOrder.setScheduledDate(drugOrder.getScheduledDate()); openMRSDrugOrder.setUrgency(Order.Urgency.ON_SCHEDULED_DATE); } openMRSDrugOrder.setDuration(drugOrder.getDuration()); openMRSDrugOrder.setDurationUnits(conceptService.getConceptByName(drugOrder.getDurationUnits())); try { if (drugOrder.getDosingInstructionType() != null) { openMRSDrugOrder.setDosingType((Class<? extends DosingInstructions>) Context.loadClass(drugOrder.getDosingInstructionType())); } } catch (ClassNotFoundException e) { throw new APIException("Class not found for : DosingInstructionType " + drugOrder.getDosingInstructionType(), e); } dosingInstructionsMapper.map(drugOrder.getDosingInstructions(), openMRSDrugOrder); openMRSDrugOrder.setInstructions(drugOrder.getInstructions()); Provider provider = encounter.getEncounterProviders().iterator().next().getProvider(); openMRSDrugOrder.setOrderer(provider); return openMRSDrugOrder; }</code><technical_language>Ideally developer set order type inferred API based orderable</technical_language>

Target:
public DrugOrder map(EncounterTransaction.DrugOrder drugOrder, Encounter encounter) { DrugOrder openMRSDrugOrder = createDrugOrder(drugOrder); openMRSDrugOrder.setCareSetting(getCareSettingFrom(drugOrder, openMRSDrugOrder)); Drug drug = getDrugFrom(drugOrder, openMRSDrugOrder); if(drug == null) { throw new APIException("No such drug : " + drugOrder.getDrug().getName()); } openMRSDrugOrder.setDrug(drug); openMRSDrugOrder.setEncounter(encounter); openMRSDrugOrder.setDateActivated(drugOrder.getDateActivated()); if (drugOrder.getScheduledDate() != null && drugOrder.getScheduledDate().after(new Date())) { openMRSDrugOrder.setScheduledDate(drugOrder.getScheduledDate()); openMRSDrugOrder.setUrgency(Order.Urgency.ON_SCHEDULED_DATE); } openMRSDrugOrder.setDuration(drugOrder.getDuration()); openMRSDrugOrder.setDurationUnits(orderMetadataService.getDurationUnitsConceptByName(drugOrder.getDurationUnits())); try { if (drugOrder.getDosingInstructionType() != null) { openMRSDrugOrder.setDosingType((Class<? extends DosingInstructions>) Context.loadClass(drugOrder.getDosingInstructionType())); } } catch (ClassNotFoundException e) { throw new APIException("Class not found for : DosingInstructionType " + drugOrder.getDosingInstructionType(), e); } dosingInstructionsMapper.map(drugOrder.getDosingInstructions(), openMRSDrugOrder); openMRSDrugOrder.setInstructions(drugOrder.getInstructions()); Provider provider = encounter.getEncounterProviders().iterator().next().getProvider(); openMRSDrugOrder.setOrderer(provider); return openMRSDrugOrder; }