Ejemplo n.º 1
0
  private boolean mayProceedPreview(String studyOid) throws Exception {
    boolean accessPermission = false;
    StudyBean study = getParentStudy(studyOid);
    StudyParameterValueDAO spvdao = new StudyParameterValueDAO(dataSource);

    StudyParameterValueBean pStatus =
        spvdao.findByHandleAndStudy(study.getId(), "participantPortal");
    participantPortalRegistrar = new ParticipantPortalRegistrar();
    String pManageStatus =
        participantPortalRegistrar.getRegistrationStatus(studyOid).toString(); // ACTIVE ,
    // PENDING ,
    // INACTIVE
    String participateStatus = pStatus.getValue().toString(); // enabled , disabled
    String studyStatus =
        study.getStatus().getName().toString(); // available , pending , frozen , locked
    logger.info(
        "pManageStatus: "
            + pManageStatus
            + "  participantStatus: "
            + participateStatus
            + "   studyStatus: "
            + studyStatus);
    if (participateStatus.equalsIgnoreCase("enabled")
        && (studyStatus.equalsIgnoreCase("available")
            || studyStatus.equalsIgnoreCase("pending")
            || studyStatus.equalsIgnoreCase("frozen")
            || studyStatus.equalsIgnoreCase("locked"))
        && (pManageStatus.equalsIgnoreCase("ACTIVE")
            || pManageStatus.equalsIgnoreCase("PENDING")
            || pManageStatus.equalsIgnoreCase("INACTIVE"))) {
      accessPermission = true;
    }
    return accessPermission;
  }
  public ArrayList findAllSubjectByStudy(StudyBean study) {
    this.setTypesExpected();
    ArrayList alist = new ArrayList();
    this.setTypeExpected(11, TypeNames.STRING); // ss.label
    this.setTypeExpected(12, TypeNames.STRING); // column_name
    this.setTypeExpected(13, TypeNames.INT); // subject_id

    HashMap variables = new HashMap();
    variables.put(new Integer(1), new Integer(study.getId()));
    variables.put(new Integer(2), new Integer(study.getId()));
    variables.put(new Integer(3), new Integer(study.getId()));

    alist = this.select(digester.getQuery("findAllSubjectByStudy"), variables);

    ArrayList al = new ArrayList();
    Iterator it = alist.iterator();
    while (it.hasNext()) {
      HashMap hm = (HashMap) it.next();
      DiscrepancyNoteBean eb = (DiscrepancyNoteBean) this.getEntityFromHashMap(hm);
      eb.setSubjectName((String) hm.get("label"));
      eb.setColumn((String) hm.get("column_name"));
      eb.setEntityId(((Integer) hm.get("subject_id")).intValue());
      al.add(eb);
    }
    return al;
  }
Ejemplo n.º 3
0
  private UserAccountBean createUserAccount(
      UserAccountBean rootUserAccount, StudyBean studyBean, StudySubjectBean studySubjectBean)
      throws Exception {

    UserAccountBean createdUserAccountBean = new UserAccountBean();
    createdUserAccountBean.setName(getInputUsername(studyBean, studySubjectBean));
    createdUserAccountBean.setFirstName(INPUT_FIRST_NAME);
    createdUserAccountBean.setLastName(INPUT_LAST_NAME);
    createdUserAccountBean.setEmail(INPUT_EMAIL);
    createdUserAccountBean.setInstitutionalAffiliation(INPUT_INSTITUTION);
    createdUserAccountBean.setActiveStudyId(studyBean.getId());
    String passwordHash = UserAccountBean.LDAP_PASSWORD;
    createdUserAccountBean.setPasswd(passwordHash);
    createdUserAccountBean.setPasswdTimestamp(null);
    createdUserAccountBean.setLastVisitDate(null);
    createdUserAccountBean.setActiveStudyId(studyBean.getId());
    createdUserAccountBean.setStatus(Status.DELETED);
    createdUserAccountBean.setPasswdChallengeQuestion("");
    createdUserAccountBean.setPasswdChallengeAnswer("");
    createdUserAccountBean.setPhone("");
    createdUserAccountBean.setOwner(rootUserAccount);
    createdUserAccountBean.setRunWebservices(false);
    Role r = Role.RESEARCHASSISTANT2;
    createdUserAccountBean =
        addActiveStudyRole(createdUserAccountBean, studyBean.getId(), r, rootUserAccount);
    UserType type = UserType.get(2);
    createdUserAccountBean.addUserType(type);

    UserAccountDAO udao = new UserAccountDAO(dataSource);
    createdUserAccountBean = (UserAccountBean) udao.create(createdUserAccountBean);
    // authoritiesDao.saveOrUpdate(new AuthoritiesBean(createdUserAccountBean.getName()));
    return createdUserAccountBean;
  }
  /**
   * Updates the study bean with inputs from second section
   *
   * @param request
   * @return true if study type is Interventional, otherwise false
   */
  private boolean updateStudy2() {
    FormProcessor fp = new FormProcessor(request);
    StudyBean newStudy = (StudyBean) session.getAttribute("newStudy");
    // this is not fully supported yet, because the system will not handle
    // studies which are pending
    // or private...
    newStudy.setStatus(Status.get(fp.getInt("statusId")));

    newStudy.setProtocolDateVerification(fp.getDate(INPUT_VER_DATE));

    newStudy.setDatePlannedStart(fp.getDate(INPUT_START_DATE));

    if (StringUtil.isBlank(fp.getString(INPUT_END_DATE))) {
      newStudy.setDatePlannedEnd(null);
    } else {
      newStudy.setDatePlannedEnd(fp.getDate(INPUT_END_DATE));
    }

    newStudy.setPhase(fp.getString("phase"));

    if (fp.getInt("genetic") == 1) {
      newStudy.setGenetic(true);
    } else {
      newStudy.setGenetic(false);
    }

    session.setAttribute("newStudy", newStudy);

    String interventional = resadmin.getString("interventional");
    return interventional.equalsIgnoreCase(newStudy.getProtocolType());
  }
  private void confirmStudy6() throws Exception {
    FormProcessor fp = new FormProcessor(request);
    Validator v = new Validator(request);
    v.addValidation(
        "medlineIdentifier",
        Validator.LENGTH_NUMERIC_COMPARISON,
        NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO,
        255);
    v.addValidation(
        "url",
        Validator.LENGTH_NUMERIC_COMPARISON,
        NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO,
        255);
    v.addValidation(
        "urlDescription",
        Validator.LENGTH_NUMERIC_COMPARISON,
        NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO,
        255);

    errors = v.validate();

    StudyBean newStudy = (StudyBean) session.getAttribute("newStudy");
    newStudy.setMedlineIdentifier(fp.getString("medlineIdentifier"));
    newStudy.setResultsReference(fp.getBoolean("resultsReference"));
    newStudy.setUrl(fp.getString("url"));
    newStudy.setUrlDescription(fp.getString("urlDescription"));
    session.setAttribute("newStudy", newStudy);
    // request.setAttribute("interventions",session.getAttribute("interventions"));
    if (errors.isEmpty()) {
      forwardPage(Page.UPDATE_STUDY8);
    } else {
      request.setAttribute("formMessages", errors);
      forwardPage(Page.UPDATE_STUDY7);
    }
  }
  private void updateStudy3(boolean isInterventional, FormProcessor fp) {

    study.setPurpose(fp.getString("purpose"));
    ArrayList interventionArray = new ArrayList();
    if (isInterventional) {
      study.setAllocation(fp.getString("allocation"));
      study.setMasking(fp.getString("masking"));
      study.setControl(fp.getString("control"));
      study.setAssignment(fp.getString("assignment"));
      study.setEndpoint(fp.getString("endpoint"));

      StringBuffer interventions = new StringBuffer();

      for (int i = 0; i < 10; i++) {
        String type = fp.getString("interType" + i);
        String name = fp.getString("interName" + i);
        if (!StringUtil.isBlank(type) && !StringUtil.isBlank(name)) {
          InterventionBean ib =
              new InterventionBean(fp.getString("interType" + i), fp.getString("interName" + i));
          interventionArray.add(ib);
          interventions.append(ib.toString()).append(",");
        }
      }
      study.setInterventions(interventions.toString());

    } else { // type = observational
      study.setDuration(fp.getString("duration"));
      study.setSelection(fp.getString("selection"));
      study.setTiming(fp.getString("timing"));
    }
    request.setAttribute("interventions", interventionArray);
  }
  /**
   * Send email to the user, director and administrator
   *
   * @param request
   * @param response
   */
  private String sendEmail(UserAccountBean u, StudyUserRoleBean sub) throws Exception {

    StudyDAO sdao = new StudyDAO(sm.getDataSource());
    StudyBean study = (StudyBean) sdao.findByPK(sub.getStudyId());
    logger.info("Sending email...");
    String body =
        u.getFirstName()
            + " "
            + u.getLastName()
            + " ("
            + resword.getString("username")
            + ": "
            + u.getName()
            + ") "
            + respage.getString("has_been_granted_the_role")
            + " "
            + sub.getRoleName()
            + " "
            + respage.getString("in_the_study_site")
            + " "
            + study.getName()
            + ".";

    //        boolean emailSent = sendEmail(u.getEmail().trim(), respage.getString("set_user_role"),
    // body, false);
    //        if (emailSent) {
    //            sendEmail(ub.getEmail().trim(), respage.getString("set_user_role"), body, false);
    //            sendEmail(EmailEngine.getAdminEmail(), respage.getString("set_user_role"), body,
    // false);
    //        }
    return body;
  }
  private void validateStudy6(FormProcessor fp, Validator v) {
    v.addValidation(
        "medlineIdentifier",
        Validator.LENGTH_NUMERIC_COMPARISON,
        NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO,
        255);
    v.addValidation(
        "url",
        Validator.LENGTH_NUMERIC_COMPARISON,
        NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO,
        255);
    v.addValidation(
        "urlDescription",
        Validator.LENGTH_NUMERIC_COMPARISON,
        NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO,
        255);

    errors = v.validate();

    study.setMedlineIdentifier(fp.getString("medlineIdentifier"));
    study.setResultsReference(fp.getBoolean("resultsReference"));
    study.setUrl(fp.getString("url"));
    study.setUrlDescription(fp.getString("urlDescription"));
    // request.setAttribute("interventions",session.getAttribute(
    // "interventions"));
    if (!errors.isEmpty()) {
      request.setAttribute("formMessages", errors);
    }
  }
Ejemplo n.º 9
0
  public String getInputUsername(StudyBean studyBean, StudySubjectBean studySubjectBean) {
    String inputUserName = null;
    if (studySubjectBean != null) {
      if (studyBean.getParentStudyId() > 0) studyBean = getStudy(studyBean.getParentStudyId());

      inputUserName = studyBean.getOid() + "." + studySubjectBean.getOid();
    }
    return inputUserName;
  }
Ejemplo n.º 10
0
 public MetadataUnit(DataSource ds, StudyBean study, int category) {
   super(ds, study, category);
   this.odmStudy = new OdmStudyBean();
   if (study.getParentStudyId() > 0) {
     this.parentStudy = (StudyBean) new StudyDAO(ds).findByPK(study.getParentStudyId());
   } else {
     this.parentStudy = new StudyBean();
   }
 }
  /** Finds all the studies */
  @Override
  public void processRequest() throws Exception {

    StudyDAO sdao = new StudyDAO(sm.getDataSource());
    ArrayList studies = (ArrayList) sdao.findAll();
    // find all parent studies
    ArrayList parents = (ArrayList) sdao.findAllParents();
    ArrayList displayStudies = new ArrayList();

    for (int i = 0; i < parents.size(); i++) {
      StudyBean parent = (StudyBean) parents.get(i);
      ArrayList children = (ArrayList) sdao.findAllByParent(parent.getId());
      DisplayStudyBean displayStudy = new DisplayStudyBean();
      displayStudy.setParent(parent);
      displayStudy.setChildren(children);
      displayStudies.add(displayStudy);
    }

    FormProcessor fp = new FormProcessor(request);
    EntityBeanTable table = fp.getEntityBeanTable();
    ArrayList allStudyRows = DisplayStudyRow.generateRowsFromBeans(displayStudies);

    String[] columns = {
      resword.getString("name"),
      resword.getString("unique_identifier"),
      resword.getString("OID"),
      resword.getString("principal_investigator"),
      resword.getString("facility_name"),
      resword.getString("date_created"),
      resword.getString("status"),
      resword.getString("actions")
    };
    table.setColumns(new ArrayList(Arrays.asList(columns)));
    table.hideColumnLink(2);
    table.hideColumnLink(6);
    table.setQuery("ListStudy", new HashMap());
    table.addLink(resword.getString("create_a_new_study"), "CreateStudy");
    table.setRows(allStudyRows);
    table.computeDisplay();

    request.setAttribute("table", table);
    // request.setAttribute("studies", studies);
    session.setAttribute("fromListSite", "no");

    resetPanel();
    panel.setStudyInfoShown(false);
    panel.setOrderedData(true);
    setToPanel(resword.getString("in_the_application"), "");
    if (parents.size() > 0) {
      setToPanel(resword.getString("studies"), new Integer(parents.size()).toString());
    }
    if (studies.size() > 0) {
      setToPanel(
          resword.getString("sites"), new Integer(studies.size() - parents.size()).toString());
    }
    forwardPage(Page.STUDY_LIST);
  }
Ejemplo n.º 12
0
 private StudyBean getParentStudy(String studyOid) {
   StudyBean study = getStudy(studyOid);
   if (study.getParentStudyId() == 0) {
     return study;
   } else {
     StudyBean parentStudy = (StudyBean) sdao.findByPK(study.getParentStudyId());
     return parentStudy;
   }
 }
  @SuppressWarnings("unchecked")
  @Override
  public void setDataAndLimitVariables(TableFacade tableFacade) {
    // initialize i18n
    resword = ResourceBundleProvider.getWordsBundle(getLocale());
    resformat = ResourceBundleProvider.getFormatBundle(getLocale());

    Limit limit = tableFacade.getLimit();
    ListSubjectFilter listSubjectFilter = getListSubjectFilter(limit);

    if (!limit.isComplete()) {
      int totalRows = getSubjectDao().getCountWithFilter(listSubjectFilter, getCurrentStudy());
      tableFacade.setTotalRows(totalRows);
    }

    ListSubjectSort listSubjectSort = getListSubjectSort(limit);
    int rowStart = limit.getRowSelect().getRowStart();
    int rowEnd = limit.getRowSelect().getRowEnd();

    Collection<SubjectBean> items =
        getSubjectDao()
            .getWithFilterAndSort(
                getCurrentStudy(), listSubjectFilter, listSubjectSort, rowStart, rowEnd);
    Collection<HashMap<Object, Object>> theItems = new ArrayList<HashMap<Object, Object>>();

    for (SubjectBean subject : items) {
      UserAccountBean owner = (UserAccountBean) getUserAccountDao().findByPK(subject.getOwnerId());
      UserAccountBean updater =
          subject.getUpdaterId() == 0
              ? null
              : (UserAccountBean) getUserAccountDao().findByPK(subject.getUpdaterId());
      HashMap<Object, Object> h = new HashMap<Object, Object>();
      String studySubjectIdAndStudy = "";
      List<StudySubjectBean> studySubjects =
          getStudySubjectDao().findAllBySubjectId(subject.getId());
      for (StudySubjectBean studySubjectBean : studySubjects) {
        StudyBean study = (StudyBean) getStudyDao().findByPK(studySubjectBean.getStudyId());
        studySubjectIdAndStudy += studySubjectIdAndStudy.length() == 0 ? "" : ",";
        studySubjectIdAndStudy += study.getIdentifier() + "-" + studySubjectBean.getLabel();
      }

      h.put("studySubjectIdAndStudy", studySubjectIdAndStudy);
      h.put("subject", subject);
      h.put("subject.uniqueIdentifier", subject.getUniqueIdentifier());
      h.put("subject.gender", subject.getGender());
      h.put("subject.createdDate", subject.getCreatedDate());
      h.put("subject.owner", owner);
      h.put("subject.updatedDate", subject.getUpdatedDate());
      h.put("subject.updater", updater);
      h.put("subject.status", subject.getStatus());

      theItems.add(h);
    }

    tableFacade.setItems(theItems);
  }
Ejemplo n.º 14
0
 public void collectOdmStudy() {
   StudyBean study = studyBase.getStudy();
   String studyOID = study.getOid();
   if (studyOID == null || studyOID.length() <= 0) {
     logger.info(
         "Constructed studyOID using study_id because oc_oid is missing from the table - study.");
     studyOID = "" + study.getId();
   }
   odmStudy.setOid(studyOID);
   collectGlobalVariables();
   collectBasicDefinitions();
   collectMetaDataVersion();
 }
 private ArrayList<StudyEventDefinitionBean> initDefinitions(StudyBean site) {
   ArrayList<StudyEventDefinitionBean> seds = new ArrayList<StudyEventDefinitionBean>();
   StudyEventDefinitionDAO sedDao = new StudyEventDefinitionDAO(sm.getDataSource());
   EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
   CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
   CRFDAO cdao = new CRFDAO(sm.getDataSource());
   StudyBean parentStudy =
       (StudyBean) new StudyDAO(sm.getDataSource()).findByPK(site.getParentStudyId());
   seds = sedDao.findAllByStudy(parentStudy);
   int start = 0;
   for (StudyEventDefinitionBean sed : seds) {
     int defId = sed.getId();
     ArrayList<EventDefinitionCRFBean> edcs =
         (ArrayList<EventDefinitionCRFBean>)
             edcdao.findAllByDefinitionAndSiteIdAndParentStudyId(
                 defId, site.getId(), parentStudy.getId());
     ArrayList<EventDefinitionCRFBean> defCrfs = new ArrayList<EventDefinitionCRFBean>();
     // sed.setCrfNum(edcs.size());
     for (EventDefinitionCRFBean edcBean : edcs) {
       int edcStatusId = edcBean.getStatus().getId();
       CRFBean crf = (CRFBean) cdao.findByPK(edcBean.getCrfId());
       int crfStatusId = crf.getStatusId();
       if (edcStatusId == 5 || edcStatusId == 7 || crfStatusId == 5 || crfStatusId == 7) {
       } else {
         ArrayList<CRFVersionBean> versions =
             (ArrayList<CRFVersionBean>) cvdao.findAllActiveByCRF(edcBean.getCrfId());
         edcBean.setVersions(versions);
         edcBean.setCrfName(crf.getName());
         CRFVersionBean defaultVersion =
             (CRFVersionBean) cvdao.findByPK(edcBean.getDefaultVersionId());
         edcBean.setDefaultVersionName(defaultVersion.getName());
         String sversionIds = edcBean.getSelectedVersionIds();
         ArrayList<Integer> idList = new ArrayList<Integer>();
         if (sversionIds.length() > 0) {
           String[] ids = sversionIds.split("\\,");
           for (String id : ids) {
             idList.add(Integer.valueOf(id));
           }
         }
         edcBean.setSelectedVersionIdList(idList);
         defCrfs.add(edcBean);
         ++start;
       }
     }
     logger.debug("definitionCrfs size=" + defCrfs.size() + " total size=" + edcs.size());
     sed.setCrfs(defCrfs);
     sed.setCrfNum(defCrfs.size());
   }
   return seds;
 }
Ejemplo n.º 16
0
  public SimpleTrigger generateImportTrigger(
      FormProcessor fp,
      UserAccountBean userAccount,
      StudyBean study,
      Date startDateTime,
      String locale) {

    String jobName = fp.getString(JOB_NAME);

    String email = fp.getString(EMAIL);
    String jobDesc = fp.getString(JOB_DESC);
    String directory = fp.getString(DIRECTORY);

    // what kinds of periods do we have? hourly, daily, weekly?
    long interval = 0;
    int hours = fp.getInt("hours");
    int minutes = fp.getInt("minutes");
    if (hours > 0) {
      long hoursInt = hours * 3600000;
      interval = interval + hoursInt;
    }
    if (minutes > 0) {
      long minutesInt = minutes * 60000;
      interval = interval + minutesInt;
    }
    SimpleTrigger trigger = new SimpleTrigger(jobName, IMPORT_TRIGGER, 64000, interval);
    trigger.setDescription(jobDesc);
    // set just the start date
    trigger.setStartTime(startDateTime);
    trigger.setName(jobName); // + datasetId);
    trigger.setGroup(IMPORT_TRIGGER); // + datasetId);
    trigger.setMisfireInstruction(
        SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_EXISTING_COUNT);
    // set job data map
    JobDataMap jobDataMap = new JobDataMap();

    jobDataMap.put(EMAIL, email);
    jobDataMap.put(USER_ID, userAccount.getId());
    jobDataMap.put(STUDY_NAME, study.getName());
    jobDataMap.put(STUDY_OID, study.getOid());
    jobDataMap.put(DIRECTORY, directory);
    jobDataMap.put(ExampleSpringJob.LOCALE, locale);
    jobDataMap.put("hours", hours);
    jobDataMap.put("minutes", minutes);

    trigger.setJobDataMap(jobDataMap);
    trigger.setVolatility(false);
    return trigger;
  }
 public ArrayList findAllByStudyAndParent(StudyBean study, int parentId) {
   HashMap variables = new HashMap();
   variables.put(new Integer(1), new Integer(parentId));
   variables.put(new Integer(2), new Integer(study.getId()));
   variables.put(new Integer(3), new Integer(study.getId()));
   return this.executeFindAllQuery("findAllByStudyAndParent", variables);
 }
 private void submitSiteEventDefinitions(StudyBean site) {
   FormProcessor fp = new FormProcessor(request);
   ArrayList<StudyEventDefinitionBean> seds = new ArrayList<StudyEventDefinitionBean>();
   CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
   seds = (ArrayList<StudyEventDefinitionBean>) session.getAttribute("definitions");
   HashMap<String, Boolean> changes = (HashMap<String, Boolean>) session.getAttribute("changed");
   for (StudyEventDefinitionBean sed : seds) {
     EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
     ArrayList<EventDefinitionCRFBean> edcs = sed.getCrfs();
     for (EventDefinitionCRFBean edcBean : edcs) {
       int edcStatusId = edcBean.getStatus().getId();
       if (edcStatusId == 5 || edcStatusId == 7) {
       } else {
         boolean changed = changes.get(sed.getId() + "-" + edcBean.getId());
         if (changed) {
           edcBean.setParentId(edcBean.getId());
           edcBean.setStudyId(site.getId());
           edcBean.setUpdater(ub);
           edcBean.setUpdatedDate(new Date());
           logger.debug("create for the site");
           edcdao.create(edcBean);
         }
       }
     }
   }
   session.removeAttribute("definitions");
   session.removeAttribute("changed");
   session.removeAttribute("sdvOptions");
 }
  private void createDiscrepancyNoteBean(
      String description,
      String detailedNotes,
      int itemDataId,
      StudyBean studyBean,
      UserAccountBean ub,
      DiscrepancyNoteBean parentDiscrepancyNote) {
    DiscrepancyNoteBean dnb = new DiscrepancyNoteBean();
    dnb.setEntityId(itemDataId); // this is needed for DN Map object
    dnb.setStudyId(studyBean.getId());
    dnb.setEntityType(DiscrepancyNoteBean.ITEM_DATA);
    dnb.setDescription(description);
    dnb.setDetailedNotes(detailedNotes);
    dnb.setDiscrepancyNoteTypeId(
        parentDiscrepancyNote.getDiscrepancyNoteTypeId()); // set to parent DN Type Id
    dnb.setResolutionStatusId(4); // set to closed
    dnb.setColumn("value"); // this is needed for DN Map object
    dnb.setAssignedUserId(ub.getId());
    dnb.setOwner(ub);
    dnb.setParentDnId(parentDiscrepancyNote.getId());
    dnb.setActivated(false);
    dnb = (DiscrepancyNoteBean) getDnDao().create(dnb); // create child DN
    getDnDao().createMapping(dnb); // create DN mapping

    DiscrepancyNoteBean itemParentNote =
        (DiscrepancyNoteBean) getDnDao().findByPK(dnb.getParentDnId());
    itemParentNote.setResolutionStatusId(ResolutionStatus.CLOSED.getId());
    itemParentNote.setAssignedUserId(ub.getId());
    getDnDao().update(itemParentNote); // update parent DN
    getDnDao().updateAssignedUser(itemParentNote); // update parent DN assigned user
  }
  /**
   * Constructs study bean from request-first section
   *
   * @param request
   * @return
   */
  private StudyBean createStudyBean() {
    FormProcessor fp = new FormProcessor(request);
    StudyBean newStudy = (StudyBean) session.getAttribute("newStudy");
    newStudy.setName(fp.getString("name"));
    newStudy.setOfficialTitle(fp.getString("officialTitle"));
    newStudy.setIdentifier(fp.getString("uniqueProId"));
    newStudy.setSecondaryIdentifier(fp.getString("secondProId"));
    newStudy.setPrincipalInvestigator(fp.getString("prinInvestigator"));

    newStudy.setSummary(fp.getString("description"));
    newStudy.setProtocolDescription(fp.getString("protocolDescription"));

    newStudy.setSponsor(fp.getString("sponsor"));
    newStudy.setCollaborators(fp.getString("collaborators"));

    return newStudy;
  }
  @RequestMapping(method = RequestMethod.POST)
  public String processSubmit(
      @ModelAttribute("studyModuleStatus") StudyModuleStatus studyModuleStatus,
      BindingResult result,
      SessionStatus status,
      HttpServletRequest request) {
    StudyBean currentStudy = (StudyBean) request.getSession().getAttribute("study");
    studyModuleStatusDao.saveOrUpdate(studyModuleStatus);
    status.setComplete();

    currentStudy.setStatus(Status.get(studyModuleStatus.getStudyStatus()));
    if (currentStudy.getParentStudyId() > 0) {
      studyDao.updateStudyStatus(currentStudy);
    } else {
      studyDao.updateStudyStatus(currentStudy);
    }

    return "redirect:studymodule";
  }
  public void testRewardForDining() {
    initializeLocale();
    // create a new dining of 100.00 charged to credit card '1234123412341234' by merchant
    // '123457890' as test input
    StudyBean studyBean = new StudyBean();
    studyBean.setIdentifier("default-study");

    SubjectBean subjectBean = new SubjectBean();
    subjectBean.setUniqueIdentifier("krikor");

    // Dining dining = Dining.createDining("100.00", "1234123412341234", "1234567890");

    // call the 'rewardNetwork' to test its rewardAccountFor(Dining) method
    // RewardConfirmation confirmation = rewardNetwork.rewardAccountFor(dining);
    String result = rewardNetwork.createSubject(subjectBean, studyBean, null);

    System.out.println(result);
    assertNotNull(result);
  }
  /**
   * Validates the forth section of study and save it into study bean
   *
   * @param request
   * @param response
   * @throws Exception
   */
  private void confirmStudy4() throws Exception {
    FormProcessor fp = new FormProcessor(request);
    Validator v = new Validator(request);
    v.addValidation(
        "conditions",
        Validator.LENGTH_NUMERIC_COMPARISON,
        NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO,
        500);
    v.addValidation(
        "keywords",
        Validator.LENGTH_NUMERIC_COMPARISON,
        NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO,
        255);
    v.addValidation(
        "eligibility",
        Validator.LENGTH_NUMERIC_COMPARISON,
        NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO,
        500);
    errors = v.validate();
    if (fp.getInt("expectedTotalEnrollment") <= 0) {
      Validator.addError(
          errors,
          "expectedTotalEnrollment",
          respage.getString("expected_total_enrollment_must_be_a_positive_number"));
    }

    StudyBean newStudy = (StudyBean) session.getAttribute("newStudy");
    newStudy.setConditions(fp.getString("conditions"));
    newStudy.setKeywords(fp.getString("keywords"));
    newStudy.setEligibility(fp.getString("eligibility"));
    newStudy.setGender(fp.getString("gender"));

    newStudy.setAgeMax(fp.getString("ageMax"));
    newStudy.setAgeMin(fp.getString("ageMin"));
    newStudy.setHealthyVolunteerAccepted(fp.getBoolean("healthyVolunteerAccepted"));
    newStudy.setExpectedTotalEnrollment(fp.getInt("expectedTotalEnrollment"));
    session.setAttribute("newStudy", newStudy);
    request.setAttribute("facRecruitStatusMap", CreateStudyServlet.facRecruitStatusMap);
    if (errors.isEmpty()) {
      forwardPage(Page.UPDATE_STUDY6);
    } else {
      request.setAttribute("formMessages", errors);
      forwardPage(Page.UPDATE_STUDY5);
    }
  }
 private StudySubjectBean createStudySubject(
     SubjectBean subject, StudyBean studyBean, Date enrollmentDate, String secondaryId) {
   StudySubjectBean studySubject = new StudySubjectBean();
   studySubject.setSecondaryLabel(secondaryId);
   studySubject.setOwner(getUserAccount());
   studySubject.setEnrollmentDate(enrollmentDate);
   studySubject.setLabel(subject.getLabel());
   subject.setLabel(null);
   studySubject.setSubjectId(subject.getId());
   studySubject.setStudyId(studyBean.getId());
   studySubject.setStatus(Status.AVAILABLE);
   return studySubject;
 }
  private void updateInterviewerForSites(
      StudyBean studyBean,
      List<StudyBean> sites,
      StudyParameterValueDAO studyParameterValueDAO,
      String parameterType) {

    StudyParameterValueBean studyParameterValueBean = new StudyParameterValueBean();

    if ("interviewerNameEditable".equalsIgnoreCase(parameterType)) {
      studyParameterValueBean.setParameter("interviewerNameEditable");
      studyParameterValueBean.setValue(
          studyBean.getStudyParameterConfig().getInterviewerNameEditable());
    } else {
      studyParameterValueBean.setParameter("interviewerDateEditable");
      studyParameterValueBean.setValue(
          studyBean.getStudyParameterConfig().getInterviewDateEditable());
    }
    for (StudyBean siteBean : sites) {
      studyParameterValueBean.setStudyId(siteBean.getId());
      updateParameter(studyParameterValueDAO, studyParameterValueBean);
    }
  }
Ejemplo n.º 26
0
 public StudySubjectBean createStudySubjectBean(
     StudyBean sBean, SubjectBean subjectBean, UserAccountBean uBean) {
   StudySubjectBean ssBean = new StudySubjectBean();
   subjectBean.setGender('\0'); // setting null character
   ssBean.setStudyId(sBean.getId());
   ssBean.setSubjectId(subjectBean.getId());
   ssBean.setStatus(Status.AVAILABLE);
   ssBean.setOwner(uBean);
   ssBean.setEnrollmentDate(new Date());
   int nextLabel = getStudySubjectDao().findTheGreatestLabel() + 1;
   ssBean.setLabel(Integer.toString(nextLabel));
   StudySubjectDAO ssdao = new StudySubjectDAO(dataSource);
   ssBean = (StudySubjectBean) ssdao.create(ssBean, false);
   return ssBean;
 }
  public ArrayList findAllParentsByStudy(StudyBean study) {
    HashMap variables = new HashMap();
    variables.put(new Integer(1), new Integer(study.getId()));
    variables.put(new Integer(2), new Integer(study.getId()));
    ArrayList notes = executeFindAllQuery("findAllParentsByStudy", variables);

    if (fetchMapping) {
      for (int i = 0; i < notes.size(); i++) {
        DiscrepancyNoteBean dnb = (DiscrepancyNoteBean) notes.get(i);
        dnb = findSingleMapping(dnb);
        notes.set(i, dnb);
      }
    }

    return notes;
  }
  public static DiscrepancyNoteBean createDiscrepancyNote(
      ItemBean itemBean,
      String message,
      EventCRFBean eventCrfBean,
      DisplayItemBean displayItemBean,
      Integer parentId,
      UserAccountBean uab,
      DataSource ds,
      StudyBean study) {
    // DisplayItemBean displayItemBean) {
    DiscrepancyNoteBean note = new DiscrepancyNoteBean();
    StudySubjectDAO ssdao = new StudySubjectDAO(ds);
    note.setDescription(message);
    note.setDetailedNotes("Failed Validation Check");
    note.setOwner(uab);
    note.setCreatedDate(new Date());
    note.setResolutionStatusId(ResolutionStatus.OPEN.getId());
    note.setDiscrepancyNoteTypeId(DiscrepancyNoteType.FAILEDVAL.getId());
    if (parentId != null) {
      note.setParentDnId(parentId);
    }

    note.setField(itemBean.getName());
    note.setStudyId(study.getId());
    note.setEntityName(itemBean.getName());
    note.setEntityType("ItemData");
    note.setEntityValue(displayItemBean.getData().getValue());

    note.setEventName(eventCrfBean.getName());
    note.setEventStart(eventCrfBean.getCreatedDate());
    note.setCrfName(displayItemBean.getEventDefinitionCRF().getCrfName());

    StudySubjectBean ss = (StudySubjectBean) ssdao.findByPK(eventCrfBean.getStudySubjectId());
    note.setSubjectName(ss.getName());

    note.setEntityId(displayItemBean.getData().getId());
    note.setColumn("value");

    DiscrepancyNoteDAO dndao = new DiscrepancyNoteDAO(ds);
    note = (DiscrepancyNoteBean) dndao.create(note);
    // so that the below method works, need to set the entity above
    // System.out.println("trying to create mapping with " + note.getId() + " " + note.getEntityId()
    // + " " + note.getColumn() + " " + note.getEntityType());
    dndao.createMapping(note);
    // System.out.println("just created mapping");
    return note;
  }
 /**
  * Parses the intetventions of a study and divides it into different type and name pairs type and
  * name are separated by '/', and interventions are separated by ',' examples:
  * type1/name1,type2/name2,type3/name3,
  *
  * @param sb
  * @return
  */
 private ArrayList parseInterventions(StudyBean sb) {
   ArrayList inters = new ArrayList();
   String interventions = sb.getInterventions();
   try {
     if (!StringUtil.isBlank(interventions)) {
       StringTokenizer st = new StringTokenizer(interventions, ",");
       while (st.hasMoreTokens()) {
         String s = st.nextToken();
         StringTokenizer st1 = new StringTokenizer(s, "/");
         String type = st1.nextToken();
         String name = st1.nextToken();
         InterventionBean ib = new InterventionBean(type, name);
         inters.add(ib);
       }
     }
   } catch (NoSuchElementException nse) {
     return new ArrayList();
   }
   return inters;
 }
  private void validateStudy4(FormProcessor fp, Validator v) {

    v.addValidation(
        "conditions",
        Validator.LENGTH_NUMERIC_COMPARISON,
        NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO,
        500);
    v.addValidation(
        "keywords",
        Validator.LENGTH_NUMERIC_COMPARISON,
        NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO,
        255);
    v.addValidation(
        "eligibility",
        Validator.LENGTH_NUMERIC_COMPARISON,
        NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO,
        500);
    errors = v.validate();
    if (fp.getInt("expectedTotalEnrollment") <= 0) {
      Validator.addError(
          errors,
          "expectedTotalEnrollment",
          respage.getString("expected_total_enrollment_must_be_a_positive_number"));
    }

    study.setConditions(fp.getString("conditions"));
    study.setKeywords(fp.getString("keywords"));
    study.setEligibility(fp.getString("eligibility"));
    study.setGender(fp.getString("gender"));

    study.setAgeMax(fp.getString("ageMax"));
    study.setAgeMin(fp.getString("ageMin"));
    study.setHealthyVolunteerAccepted(fp.getBoolean("healthyVolunteerAccepted"));
    study.setExpectedTotalEnrollment(fp.getInt("expectedTotalEnrollment"));
    request.setAttribute("facRecruitStatusMap", CreateStudyServlet.facRecruitStatusMap);
  }