Ejemplo n.º 1
0
  private ISPYGPIntegrationQueryDTO createGPIntegrationQueryDTO(
      GpIntegrationForm gpQueryForm, HttpSession session) {

    ISPYGPIntegrationQueryDTO gpQueryDTO =
        (ISPYGPIntegrationQueryDTO)
            ApplicationFactory.newQueryDTO(QueryType.PROBESET_CLONEID_QUERY_FOR_HOA);
    gpQueryDTO.setQueryName(gpQueryForm.getAnalysisResultName());

    HashMap<String, UserList> patientLists = new HashMap<String, UserList>();
    HashMap<String, Set<TimepointType>> timepointLists = new HashMap<String, Set<TimepointType>>();
    UserListBeanHelper listHelper = new UserListBeanHelper(session);
    String groupTimepoint = null;
    String groupName = null;
    String timePointName = null;
    if (gpQueryForm.getSelectedGroups() != null && gpQueryForm.getSelectedGroups().length > 0) {
      for (int i = 0; i < gpQueryForm.getSelectedGroups().length; i++) {
        groupTimepoint = gpQueryForm.getSelectedGroups()[i];
        int index = groupTimepoint.lastIndexOf("---");
        groupName = groupTimepoint.substring(0, index);
        timePointName = groupTimepoint.substring(index + 3);
        UserList userList = listHelper.getUserList(groupName);
        patientLists.put(groupTimepoint, userList);
        String[] times = timePointName.split("-");
        String fixedTimepointString = null;
        Set<TimepointType> set = new HashSet<TimepointType>();
        for (String time : times) {
          TimepointType fixedTimepointBase; // timepoint for both queryDTOs
          fixedTimepointString = EnumHelper.getEnumTypeName(time, TimepointType.values());
          if (fixedTimepointString != null) {
            fixedTimepointBase = TimepointType.valueOf(fixedTimepointString);
            set.add(fixedTimepointBase);
          }
        }
        timepointLists.put(groupTimepoint, set);
      }
    }
    gpQueryDTO.setPatientLists(patientLists);
    gpQueryDTO.setTimepointLists(timepointLists);

    // UserListBeanHelper listHelper = new UserListBeanHelper(session);
    if (gpQueryForm.getGeneSetName() != null
        && (!gpQueryForm.getGeneSetName().equals("")
            && !gpQueryForm.getGeneSetName().equals("none"))) {
      geneIdentifierDECollection = listHelper.getGeneDEforList(gpQueryForm.getGeneSetName());
      if (geneIdentifierDECollection != null && !geneIdentifierDECollection.isEmpty()) {
        logger.debug("geneIdentifierDECollection was found");
        gpQueryDTO.setGeneIdentifierDEs(geneIdentifierDECollection);
        gpQueryDTO.setReportersName(gpQueryForm.getGeneSetName());
      } else {
        logger.debug("geneIdentifierDECollection could not be found");
      }
    }
    // Create arrayPlatfrom DEs
    if (gpQueryForm.getArrayPlatform() != "" || gpQueryForm.getArrayPlatform().length() != 0) {
      ArrayPlatformDE arrayPlatformDE = new ArrayPlatformDE(gpQueryForm.getArrayPlatform());
      gpQueryDTO.setArrayPlatformDE(arrayPlatformDE);
    }

    return gpQueryDTO;
  }
Ejemplo n.º 2
0
  /**
   * this custom ispy method queries ispy based on patient clinical status and creates more
   * predefined user lists based on this clinical data. At the time of this writing, only
   * non-timepoint dependent groups are tallied.
   *
   * @throws OperationNotSupportedException
   */
  public static UserListBean loadStatusGroups(UserListBean userListBean)
      throws OperationNotSupportedException {
    ClinicalDataService cqs = ClinicalDataServiceFactory.getInstance();
    ListManager listManager = new ListManager();

    /**
     * set up simple ISPYclinicalDataQueryDTO with the appropriate status group enums set in the
     * query to return back a list of PatientDIDs based soley on the status group.
     */

    /*
     * for each stage group, load the EnumSet, send the query, return a list,
     * set the list into a UserList and add it to the UserListBean.
     */
    List<ClinicalResponseType> crt = ClinicalResponseType.getDisplayValues();
    TimepointType[] timepoints = TimepointType.values();
    for (ClinicalResponseType clinicalResponse : crt) {
      for (TimepointType type : timepoints) {
        // no data for timepoint one right now
        if (type.equals(TimepointType.T1)) {
          continue;
        } else {
          ISPYclinicalDataQueryDTO cDTO = new ISPYclinicalDataQueryDTO();
          EnumSet<ClinicalResponseType> clinicalResponses =
              EnumSet.noneOf(ClinicalResponseType.class);
          EnumSet<TimepointType> tp = EnumSet.noneOf(TimepointType.class);
          clinicalResponses.add(clinicalResponse);
          tp.add(type);
          cDTO.setClinicalResponseValues(clinicalResponses);
          cDTO.setTimepointValues(tp);
          Set<String> clinicalResponsePatients = cqs.getPatientDIDs(cDTO);
          if (!clinicalResponsePatients.isEmpty()) {
            List<String> dids = new ArrayList<String>(clinicalResponsePatients);
            ISPYListValidator listValidator = new ISPYListValidator(ListType.PatientDID, dids);
            UserList myList =
                listManager.createList(
                    ListType.PatientDID,
                    clinicalResponse.toString()
                        + TimepointType.T1.toString()
                        + "_"
                        + type.toString(),
                    dids,
                    listValidator);

            if (!myList.getList().isEmpty()) {
              myList.setListOrigin(ListOrigin.Default);
              userListBean.addList(myList);
            }
          }
        }
      }
    }

    List<ClinicalStageType> cst = ClinicalStageType.getDisplayValues();
    for (ClinicalStageType clinicalStage : cst) {
      ISPYclinicalDataQueryDTO cDTO = new ISPYclinicalDataQueryDTO();
      EnumSet<ClinicalStageType> clinicalStages = EnumSet.noneOf(ClinicalStageType.class);
      clinicalStages.add(clinicalStage);
      cDTO.setClinicalStageValues(clinicalStages);
      Set<String> clinicalStagePatients = cqs.getPatientDIDs(cDTO);
      if (!clinicalStagePatients.isEmpty()) {
        List<String> dids = new ArrayList<String>(clinicalStagePatients);
        ISPYListValidator listValidator = new ISPYListValidator(ListType.PatientDID, dids);
        UserList myList =
            listManager.createList(
                ListType.PatientDID, clinicalStage.toString(), dids, listValidator);
        if (!myList.getList().isEmpty()) {
          myList.setListOrigin(ListOrigin.Default);
          userListBean.addList(myList);
        }
      }
    }

    List<ERstatusType> est = ERstatusType.getDisplayValues();
    for (ERstatusType erStatus : est) {
      ISPYclinicalDataQueryDTO cDTO = new ISPYclinicalDataQueryDTO();
      EnumSet<ERstatusType> erStatuses = EnumSet.noneOf(ERstatusType.class);
      erStatuses.add(erStatus);
      cDTO.setErStatusValues(erStatuses);
      Set<String> erStatusPatients = cqs.getPatientDIDs(cDTO);
      if (!erStatusPatients.isEmpty()) {
        List<String> dids = new ArrayList<String>(erStatusPatients);
        ISPYListValidator listValidator = new ISPYListValidator(ListType.PatientDID, dids);
        UserList myList =
            listManager.createList(ListType.PatientDID, erStatus.toString(), dids, listValidator);
        if (!myList.getList().isEmpty()) {
          myList.setListOrigin(ListOrigin.Default);
          userListBean.addList(myList);
        }
      }
    }

    List<HER2statusType> hest = HER2statusType.getDisplayValues();
    for (HER2statusType her2Status : hest) {
      ISPYclinicalDataQueryDTO cDTO = new ISPYclinicalDataQueryDTO();
      EnumSet<HER2statusType> her2Statuses = EnumSet.noneOf(HER2statusType.class);
      her2Statuses.add(her2Status);
      cDTO.setHer2StatusValues(her2Statuses);
      Set<String> her2StatusPatients = cqs.getPatientDIDs(cDTO);
      if (!her2StatusPatients.isEmpty()) {
        List<String> dids = new ArrayList<String>(her2StatusPatients);
        ISPYListValidator listValidator = new ISPYListValidator(ListType.PatientDID, dids);
        UserList myList =
            listManager.createList(ListType.PatientDID, her2Status.toString(), dids, listValidator);
        if (!myList.getList().isEmpty()) {
          myList.setListOrigin(ListOrigin.Default);
          userListBean.addList(myList);
        }
      }
    }

    List<PRstatusType> prst = PRstatusType.getDisplayValues();
    for (PRstatusType prStatus : prst) {
      ISPYclinicalDataQueryDTO cDTO = new ISPYclinicalDataQueryDTO();
      EnumSet<PRstatusType> prStatuses = EnumSet.noneOf(PRstatusType.class);
      prStatuses.add(prStatus);
      cDTO.setPrStatusValues(prStatuses);
      Set<String> prStatusPatients = cqs.getPatientDIDs(cDTO);
      if (!prStatusPatients.isEmpty()) {
        List<String> dids = new ArrayList<String>(prStatusPatients);
        ISPYListValidator listValidator = new ISPYListValidator(ListType.PatientDID, dids);
        UserList myList =
            listManager.createList(ListType.PatientDID, prStatus.toString(), dids, listValidator);
        if (!myList.getList().isEmpty()) {
          myList.setListOrigin(ListOrigin.Default);
          userListBean.addList(myList);
        }
      }
    }
    return userListBean;
  }