コード例 #1
0
 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");
 }
コード例 #2
0
  /**
   * This method creates a List of DisplaySectionBeans, returning them in the order that the
   * sections appear in a CRF. This List is "lazily" initialized the first time it is requested.
   *
   * @return A List of DisplaySectionBeans.
   * @see org.akaza.openclinica.control.managestudy.PrintCRFServlet
   * @see org.akaza.openclinica.control.managestudy.PrintDataEntryServlet
   */
  public List<DisplaySectionBean> getDisplaySectionBeans() {
    FormBeanUtil formBeanUtil;
    ViewPersistanceHandler persistanceHandler;
    ArrayList<SectionBean> allCrfSections;
    // DAO classes for getting item definitions
    SectionDAO sectionDao;
    CRFVersionDAO crfVersionDao;

    if (displaySectionBeans == null) {
      displaySectionBeans = new ArrayList<DisplaySectionBean>();
      formBeanUtil = new FormBeanUtil();
      if (hasStoredData) persistanceHandler = new ViewPersistanceHandler();

      // We need a CRF version id to populate the form display
      if (this.crfVersionId == 0) {
        return displaySectionBeans;
      }

      sectionDao = new SectionDAO(dataSource);
      allCrfSections = (ArrayList) sectionDao.findByVersionId(this.crfVersionId);

      // for the purposes of null values, try to obtain a valid
      // eventCrfDefinition id
      EventDefinitionCRFBean eventDefBean = null;
      EventCRFBean eventCRFBean = new EventCRFBean();
      if (eventCRFId > 0) {
        EventCRFDAO ecdao = new EventCRFDAO(dataSource);
        eventCRFBean = (EventCRFBean) ecdao.findByPK(eventCRFId);
        StudyEventDAO sedao = new StudyEventDAO(dataSource);
        StudyEventBean studyEvent = (StudyEventBean) sedao.findByPK(eventCRFBean.getStudyEventId());

        EventDefinitionCRFDAO eventDefinitionCRFDAO = new EventDefinitionCRFDAO(dataSource);
        StudyDAO sdao = new StudyDAO(dataSource);
        StudyBean study = sdao.findByStudySubjectId(eventCRFBean.getStudySubjectId());
        eventDefBean =
            eventDefinitionCRFDAO.findByStudyEventIdAndCRFVersionId(
                study, studyEvent.getId(), this.crfVersionId);
      }
      eventDefBean = eventDefBean == null ? new EventDefinitionCRFBean() : eventDefBean;
      // Create an array or List of DisplaySectionBeans representing each
      // section
      // for printing
      DisplaySectionBean displaySectionBean;
      for (SectionBean sectionBean : allCrfSections) {
        displaySectionBean =
            formBeanUtil.createDisplaySectionBWithFormGroups(
                sectionBean.getId(),
                this.crfVersionId,
                dataSource,
                eventDefBean.getId(),
                eventCRFBean,
                context);
        displaySectionBeans.add(displaySectionBean);
      }
    }
    return displaySectionBeans;
  }
コード例 #3
0
  // note that this step sets us up both for
  // displaying the data on the form again, in the event of an error
  // and sending the data to the database, in the event of no error
  //
  // we have to do this after adding the validations, so that we don't
  // overwrite the value the item data bean had from initial data entry
  // before the validator stores it as part of the Matches Initial Data Entry
  // Value validation
  // dib = loadFormValue(dib);
  // return dib;
  // }
  // should be from the db, we check here for a difference
  @Override
  protected List<DisplayItemGroupBean> validateDisplayItemGroupBean(
      DiscrepancyValidator v,
      DisplayItemGroupBean digb,
      List<DisplayItemGroupBean> digbs,
      List<DisplayItemGroupBean> formGroups,
      HttpServletRequest request,
      HttpServletResponse response) {
    EventDefinitionCRFBean edcb = (EventDefinitionCRFBean) request.getAttribute(EVENT_DEF_CRF_BEAN);
    HttpSession session = request.getSession();
    logger.info("===got this far");
    EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);

    int keyId = ecb.getId();
    Integer validationCount = (Integer) session.getAttribute(COUNT_VALIDATE + keyId);

    formGroups = loadFormValueForItemGroup(digb, digbs, formGroups, edcb.getId(), request);
    logger.info(
        "found formgroups size for "
            + digb.getGroupMetaBean().getName()
            + ": "
            + formGroups.size()
            + " compare to db groups size: "
            + digbs.size());

    String inputName = "";
    for (int i = 0; i < formGroups.size(); i++) {
      DisplayItemGroupBean displayGroup = formGroups.get(i);

      List<DisplayItemBean> items = displayGroup.getItems();
      int order = displayGroup.getOrdinal();
      if (displayGroup.isAuto() && displayGroup.getFormInputOrdinal() > 0) {
        order = displayGroup.getFormInputOrdinal();
      }
      for (DisplayItemBean displayItem : items) {
        if (displayGroup.isAuto()) {
          inputName = getGroupItemInputName(displayGroup, order, displayItem);
        } else {
          inputName = getGroupItemManualInputName(displayGroup, order, displayItem);
        }
        validateDisplayItemBean(v, displayItem, inputName, request);
      }

      if (validationCount == null || validationCount.intValue() == 0) {
        if (i == 0 && formGroups.size() != digbs.size()) {
          v.addValidation(inputName + "group", Validator.DIFFERENT_NUMBER_OF_GROUPS_IN_DDE);
          // TODO internationalize this string, tbh
          v.setErrorMessage(
              "There are additional values here that were not present in the initial data entry. You have entered a different number of groups"
                  + " for the item groups containing "
                  + inputName);
        }
      }
    }

    return formGroups;
  }
コード例 #4
0
  @Override
  protected List<DisplayItemGroupBean> validateDisplayItemGroupBean(
      DiscrepancyValidator v,
      DisplayItemGroupBean digb,
      List<DisplayItemGroupBean> digbs,
      List<DisplayItemGroupBean> formGroups,
      RuleValidator rv,
      HashMap<String, ArrayList<String>> groupOrdinalPLusItemOid,
      HttpServletRequest request,
      HttpServletResponse response) {
    EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
    EventDefinitionCRFBean edcb = (EventDefinitionCRFBean) request.getAttribute(EVENT_DEF_CRF_BEAN);
    // logger.info("===got this far");
    int keyId = ecb.getId();
    Integer validationCount = (Integer) request.getSession().getAttribute(COUNT_VALIDATE + keyId);

    formGroups = loadFormValueForItemGroup(digb, digbs, formGroups, edcb.getId(), request);
    logger.info(
        "found formgroups size for "
            + digb.getGroupMetaBean().getName()
            + ": "
            + formGroups.size()
            + " compare to db groups size: "
            + digbs.size());

    String inputName = "";
    for (int i = 0; i < formGroups.size(); i++) {
      DisplayItemGroupBean displayGroup = formGroups.get(i);

      List<DisplayItemBean> items = displayGroup.getItems();
      int order = displayGroup.getOrdinal();
      if (displayGroup.isAuto() && displayGroup.getFormInputOrdinal() > 0) {
        order = displayGroup.getFormInputOrdinal();
      }
      for (DisplayItemBean displayItem : items) {
        if (displayGroup.isAuto()) {
          inputName = getGroupItemInputName(displayGroup, order, displayItem);
        } else {
          inputName = getGroupItemManualInputName(displayGroup, order, displayItem);
        }
        if (displayItem.getMetadata().isShowItem()
            || getItemMetadataService()
                .isShown(displayItem.getItem().getId(), ecb, displayItem.getData())) {
          // add the validation
          if (groupOrdinalPLusItemOid.containsKey(displayItem.getItem().getOid())
              || groupOrdinalPLusItemOid.containsKey(
                  String.valueOf(order + 1) + displayItem.getItem().getOid())) {
            System.out.println(
                "IN : " + String.valueOf(order + 1) + displayItem.getItem().getOid());
            validateDisplayItemBean(
                v,
                displayItem,
                inputName,
                rv,
                groupOrdinalPLusItemOid,
                true,
                groupOrdinalPLusItemOid.get(
                    String.valueOf(order + 1) + displayItem.getItem().getOid()),
                request);
          } else {
            validateDisplayItemBean(
                v, displayItem, inputName, rv, groupOrdinalPLusItemOid, false, null, request);
          }
        } else {
          System.out.println("OUT : " + String.valueOf(order + 1) + displayItem.getItem().getOid());
        }
        // validateDisplayItemBean(v, displayItem, inputName);
      }
    }
    return formGroups;
  }
コード例 #5
0
  private ArrayList<StudyEventDefinitionBean> createSiteEventDefinitions(StudyBean site) {
    FormProcessor fp = new FormProcessor(request);
    ArrayList<StudyEventDefinitionBean> seds = new ArrayList<StudyEventDefinitionBean>();
    StudyBean parentStudy =
        (StudyBean) new StudyDAO(sm.getDataSource()).findByPK(site.getParentStudyId());
    seds = (ArrayList<StudyEventDefinitionBean>) session.getAttribute("definitions");
    if (seds == null || seds.size() <= 0) {
      StudyEventDefinitionDAO sedDao = new StudyEventDefinitionDAO(sm.getDataSource());
      seds = sedDao.findAllByStudy(parentStudy);
    }
    CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
    HashMap<String, Boolean> changes = new HashMap<String, Boolean>();
    for (StudyEventDefinitionBean sed : seds) {
      EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
      ArrayList<EventDefinitionCRFBean> edcs = sed.getCrfs();
      int start = 0;
      for (EventDefinitionCRFBean edcBean : edcs) {
        int edcStatusId = edcBean.getStatus().getId();
        if (edcStatusId == 5 || edcStatusId == 7) {
        } else {
          String order = start + "-" + edcBean.getId();
          int defaultVersionId = fp.getInt("defaultVersionId" + order);
          String requiredCRF = fp.getString("requiredCRF" + order);
          String doubleEntry = fp.getString("doubleEntry" + order);
          String electronicSignature = fp.getString("electronicSignature" + order);
          String hideCRF = fp.getString("hideCRF" + order);
          int sdvId = fp.getInt("sdvOption" + order);
          ArrayList<String> selectedVersionIdList = fp.getStringArray("versionSelection" + order);
          int selectedVersionIdListSize = selectedVersionIdList.size();
          String selectedVersionIds = "";
          if (selectedVersionIdListSize > 0) {
            for (String id : selectedVersionIdList) {
              selectedVersionIds += id + ",";
            }
            selectedVersionIds = selectedVersionIds.substring(0, selectedVersionIds.length() - 1);
          }

          boolean changed = false;
          boolean isRequired =
              !StringUtil.isBlank(requiredCRF) && "yes".equalsIgnoreCase(requiredCRF.trim())
                  ? true
                  : false;
          boolean isDouble =
              !StringUtil.isBlank(doubleEntry) && "yes".equalsIgnoreCase(doubleEntry.trim())
                  ? true
                  : false;
          boolean hasPassword =
              !StringUtil.isBlank(electronicSignature)
                      && "yes".equalsIgnoreCase(electronicSignature.trim())
                  ? true
                  : false;
          boolean isHide =
              !StringUtil.isBlank(hideCRF) && "yes".equalsIgnoreCase(hideCRF.trim()) ? true : false;
          if (edcBean.getParentId() > 0) {
            int dbDefaultVersionId = edcBean.getDefaultVersionId();
            if (defaultVersionId != dbDefaultVersionId) {
              changed = true;
              CRFVersionBean defaultVersion = (CRFVersionBean) cvdao.findByPK(defaultVersionId);
              edcBean.setDefaultVersionId(defaultVersionId);
              edcBean.setDefaultVersionName(defaultVersion.getName());
            }
            if (isRequired != edcBean.isRequiredCRF()) {
              changed = true;
              edcBean.setRequiredCRF(isRequired);
            }
            if (isDouble != edcBean.isDoubleEntry()) {
              changed = true;
              edcBean.setDoubleEntry(isDouble);
            }
            if (hasPassword != edcBean.isElectronicSignature()) {
              changed = true;
              edcBean.setElectronicSignature(hasPassword);
            }
            if (isHide != edcBean.isHideCrf()) {
              changed = true;
              edcBean.setHideCrf(isHide);
            }
            if (!StringUtil.isBlank(selectedVersionIds)
                && !selectedVersionIds.equals(edcBean.getSelectedVersionIds())) {
              changed = true;
              String[] ids = selectedVersionIds.split(",");
              ArrayList<Integer> idList = new ArrayList<Integer>();
              for (String id : ids) {
                idList.add(Integer.valueOf(id));
              }
              edcBean.setSelectedVersionIdList(idList);
              edcBean.setSelectedVersionIds(selectedVersionIds);
            }
            if (sdvId > 0 && sdvId != edcBean.getSourceDataVerification().getCode()) {
              changed = true;
              edcBean.setSourceDataVerification(SourceDataVerification.getByCode(sdvId));
            }
          } else {
            // only if definition-crf has been modified, will it be
            // saved for the site
            int defaultId = defaultVersionId > 0 ? defaultVersionId : edcBean.getDefaultVersionId();
            if (defaultId == defaultVersionId) {
              if (isRequired == edcBean.isRequiredCRF()) {
                if (isDouble == edcBean.isDoubleEntry()) {
                  if (hasPassword == edcBean.isElectronicSignature()) {
                    if (isHide == edcBean.isHideCrf()) {
                      if (selectedVersionIdListSize > 0) {
                        if (selectedVersionIdListSize == edcBean.getVersions().size()) {
                          if (sdvId > 0) {
                            if (sdvId != edcBean.getSourceDataVerification().getCode()) {
                              changed = true;
                              edcBean.setSourceDataVerification(
                                  SourceDataVerification.getByCode(sdvId));
                            }
                          }
                        } else {
                          changed = true;
                          String[] ids = selectedVersionIds.split(",");
                          ArrayList<Integer> idList = new ArrayList<Integer>();
                          for (String id : ids) {
                            idList.add(Integer.valueOf(id));
                          }
                          edcBean.setSelectedVersionIdList(idList);
                          edcBean.setSelectedVersionIds(selectedVersionIds);
                        }
                      }
                    } else {
                      changed = true;
                      edcBean.setHideCrf(isHide);
                    }
                  } else {
                    changed = true;
                    edcBean.setElectronicSignature(hasPassword);
                  }
                } else {
                  changed = true;
                  edcBean.setDoubleEntry(isDouble);
                }
              } else {
                changed = true;
                edcBean.setRequiredCRF(isRequired);
              }
            } else {
              changed = true;
              CRFVersionBean defaultVersion = (CRFVersionBean) cvdao.findByPK(defaultVersionId);
              edcBean.setDefaultVersionId(defaultVersionId);
              edcBean.setDefaultVersionName(defaultVersion.getName());
            }
          }
          changes.put(sed.getId() + "-" + edcBean.getId(), changed);
          ++start;
        }
      }
    }
    session.setAttribute("changed", changes);
    return seds;
  }