@Override
 public DosingInstructions getDosingInstructions(DrugOrder order) {
   if (!order.getDosingType().equals(this.getClass())) {
     throw new APIException(
         "Dosing type of drug order is mismatched. Expected:"
             + this.getClass()
             + " but received:"
             + order.getDosingType());
   }
   return new FlexibleDosingInstructions();
 }
  @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;
  }