/**
  * Validate SAEREportPriorTherapy Dates.
  *
  * @param saeReportPriorTherapy
  * @param outcome
  */
 private void validateSAEREportPriorTherapyDates(
     SAEReportPriorTherapy saeReportPriorTherapy,
     DomainObjectImportOutcome<ExpeditedAdverseEventReport> outcome) {
   if (saeReportPriorTherapy.getStartDate() != null
       && saeReportPriorTherapy.getEndDate() != null) {
     if (saeReportPriorTherapy
         .getStartDate()
         .toDate()
         .after(saeReportPriorTherapy.getEndDate().toDate())) {
       outcome.addError(
           "PAT_PTY1_ERR", "Report PriorTherapy 'end date' cannot be before 'start date'' ");
     }
   }
 }
  public void migrate(
      ExpeditedAdverseEventReport aeReportSrc,
      ExpeditedAdverseEventReport aeReportDest,
      DomainObjectImportOutcome<ExpeditedAdverseEventReport> outcome) {

    List<SAEReportPriorTherapy> srcSAEReportPriorTherapys =
        aeReportSrc.getSaeReportPriorTherapies();

    if (srcSAEReportPriorTherapys == null || srcSAEReportPriorTherapys.isEmpty()) {
      outcome.addWarning("WR-SPT-1", "Input doesn't contain any SAEReportPriorTherapy Values.");
      return;
    }

    // Copy the SAEReportPriorTherapys Information from Source to Destination.
    for (SAEReportPriorTherapy spt : srcSAEReportPriorTherapys) {
      PriorTherapy pt = findPriorTherapy(spt.getPriorTherapy(), outcome);
      if (outcome.hasErrors()) {
        return;
      }
      validateSAEREportPriorTherapyDates(spt, outcome);
      SAEReportPriorTherapy destSAEReportPriorTherapy = new SAEReportPriorTherapy();
      destSAEReportPriorTherapy.setPriorTherapy(pt);
      destSAEReportPriorTherapy.setReport(aeReportDest);
      copyProperties(spt, destSAEReportPriorTherapy);

      for (PriorTherapyAgent pta : spt.getPriorTherapyAgents()) {
        PriorTherapyAgent priorTherapyAgent =
            migratePriorTherapyAgent(pta, destSAEReportPriorTherapy);
        destSAEReportPriorTherapy.addPriorTherapyAgent(priorTherapyAgent);
      }

      aeReportDest.addSaeReportPriorTherapies(destSAEReportPriorTherapy);
    }
  }
 /**
  * Copy the Details from the UserInput.
  *
  * @param src
  * @param dest
  */
 private void copyProperties(SAEReportPriorTherapy src, SAEReportPriorTherapy dest) {
   dest.setEndDate(src.getEndDate());
   dest.setStartDate(src.getStartDate());
   dest.setOther(src.getOther());
 }