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);
    }
  }
  /** find the Prior Therapy from List. */
  private PriorTherapy findPriorTherapy(
      PriorTherapy pt, DomainObjectImportOutcome<ExpeditedAdverseEventReport> outcome) {

    List<PriorTherapy> resultLst = priorTherapyDao.searchByExampleIgnoreCase(pt, false);
    if (resultLst == null || resultLst.isEmpty()) {
      outcome.addError("ER-SPT-1", "Matching prior therapy is not found for " + pt.getText());
      return null;
    }
    if (resultLst.size() > 1) {
      outcome.addError("ER-SPT-2", "Multiple matching prior therapies found for " + pt.getText());
      return null;
    }
    return resultLst.get(0);
  }
  private void migrateCourseAgent(
      CourseAgent caSrc,
      ExpeditedAdverseEventReport aeReportDest,
      DomainObjectImportOutcome<ExpeditedAdverseEventReport> outcome) {

    Study study = aeReportDest.getStudy();

    StudyAgent studyAgent = caSrc.getStudyAgent();
    if (studyAgent == null
        || ((studyAgent.getAgent() == null
                || StringUtils.isEmpty(studyAgent.getAgent().getNscNumber()))
            && StringUtils.isEmpty(studyAgent.getOtherAgent()))) {
      outcome.addWarning("ER-CA-1", "Study Agent is missing in the source");
      return;
    }

    StudyAgent realStudyAgent =
        studyAgent.getAgent() == null
            ? study.findStudyAgentByNscOrName(studyAgent.getOtherAgent())
            : study.findStudyAgentByNscOrName(studyAgent.getAgent().getNscNumber());
    if (realStudyAgent == null) {
      outcome.addWarning("ER-CA-2", "Given Agent is no longer associated to the study");
      return;
    }

    CourseAgent caDest = new CourseAgent();
    aeReportDest.getTreatmentInformation().addCourseAgent(caDest);

    // set the study agent
    caDest.setStudyAgent(realStudyAgent);

    caDest.setDose(caSrc.getDose());
    caDest.setAdministrationDelay(caSrc.getAdministrationDelay());
    caDest.setAdministrationDelayAmount(caSrc.getAdministrationDelayAmount());
    caDest.setAdministrationDelayUnits(caSrc.getAdministrationDelayUnits());
    caDest.setComments(caSrc.getComments());
    caDest.setAgentAdjustment(caSrc.getAgentAdjustment());
    caDest.setModifiedDose(caSrc.getModifiedDose());
    caDest.setLastAdministeredDate(caSrc.getLastAdministeredDate());
    caDest.setDurationAndSchedule(caSrc.getDurationAndSchedule());
    caDest.setFirstAdministeredDate(caSrc.getFirstAdministeredDate());
    caDest.setTotalDoseAdministeredThisCourse(caSrc.getTotalDoseAdministeredThisCourse());
    caDest.setFormulation(caSrc.getFormulation());
    caDest.setLotNumber(caSrc.getLotNumber());
  }
 /**
  * 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) {
    TreatmentInformation src = aeReportSrc.getTreatmentInformation();
    TreatmentInformation dest = aeReportDest.getTreatmentInformation();

    // Setting the Course Information from the reporting period.
    CourseDate adverseEventCourseDate = new CourseDate();
    adverseEventCourseDate.setDate(dest.getReport().getReportingPeriod().getStartDate());
    adverseEventCourseDate.setNumber(dest.getReport().getReportingPeriod().getCycleNumber());
    dest.setAdverseEventCourse(adverseEventCourseDate);

    if (aeReportDest.getAssignment().getStartDateOfFirstCourse() != null) {
      dest.setFirstCourseDate(aeReportDest.getAssignment().getStartDateOfFirstCourse());
    }
    dest.setTotalCourses(aeReportDest.getAssignment().getMaxCycleNumber());
    dest.setTreatmentAssignmentDescription(src.getTreatmentAssignmentDescription());
    dest.setInvestigationalAgentAdministered(src.getInvestigationalAgentAdministered());

    AdverseEventReportingPeriod reportingPeriod = aeReportDest.getReportingPeriod();
    if (src.getTreatmentAssignment() != null
        && !StringUtils.isEmpty(src.getTreatmentAssignment().getCode())) {
      // find the tac from study
      TreatmentAssignment treatmentAssignment =
          reportingPeriod
              .getStudy()
              .findActiveTreatmentAssignment(src.getTreatmentAssignment().getCode());
      if (treatmentAssignment == null) {
        outcome.addError(
            "WS_SAE_002",
            "Treatment assignment is no longer active " + src.getTreatmentAssignment().getCode(),
            src.getTreatmentAssignment().getCode());
        return;
      }
      dest.setTreatmentAssignment(treatmentAssignment);
      dest.setTreatmentDescription(reportingPeriod.getTreatmentAssignmentDescription());
    } else {
      // default it to what it is there in reporting period
      dest.setTreatmentAssignment(reportingPeriod.getTreatmentAssignment());
      dest.setTreatmentDescription(reportingPeriod.getTreatmentAssignmentDescription());
    }

    // migrate course agents
    for (CourseAgent caSrc : src.getCourseAgents()) {

      migrateCourseAgent(caSrc, aeReportDest, outcome);
    }
  }
Пример #6
0
 public void testMigrateWithNoTherapy() {
   migrator.migrate(xstreamStudy, dest, outcome);
   assertEquals(0, dest.getStudyTherapies().size());
   assertTrue("No errors should be there", outcome.getMessages().isEmpty());
 }