private void setCohorts() throws SQLException, SessionExpiredException, RemoteException { hospitalIDToCohortMap = new HashMap<String, List<String>>(); Cohort[] cohorts = MedSavantClient.CohortManager.getCohorts( LoginController.getSessionID(), ProjectController.getInstance().getCurrentProjectID()); for (Cohort c : cohorts) { c.getId(); List<SimplePatient> patients = MedSavantClient.CohortManager.getIndividualsInCohort( LoginController.getSessionID(), ProjectController.getInstance().getCurrentProjectID(), c.getId()); for (SimplePatient p : patients) { List<String> cohortsForPatient; if (hospitalIDToCohortMap.containsKey(p.getHospitalId())) { cohortsForPatient = hospitalIDToCohortMap.get(p.getHospitalId()); } else { cohortsForPatient = new ArrayList<String>(); } cohortsForPatient.add(c.getName()); hospitalIDToCohortMap.put(p.getHospitalId(), cohortsForPatient); } } }
private void setIndividuals() throws SQLException, RemoteException { try { setCohorts(); List<Object[]> tmpIndividuals = MedSavantClient.PatientManager.getBasicPatientInfo( LoginController.getSessionID(), ProjectController.getInstance().getCurrentProjectID(), Integer.MAX_VALUE); List<Object[]> updatedIndividuals = new ArrayList<Object[]>(); for (Object[] row : tmpIndividuals) { row[INDEX_OF_GENDER] = ClientMiscUtils.genderToString((Integer) row[INDEX_OF_GENDER]); String s; Object o = row[INDEX_OF_AFFECTED]; if (o instanceof Boolean) { Boolean b = (Boolean) o; s = b ? "Yes" : "No"; } else if (o instanceof Integer) { Integer i = (Integer) o; s = (i > 0) ? "Yes" : "No"; } else { s = "Unknown"; } row[INDEX_OF_AFFECTED] = s; /*Boolean b = (Boolean) row[INDEX_OF_AFFECTED]; String s = b ? "Yes" : "No"; row[INDEX_OF_AFFECTED] = s;*/ List<String> cohorts = hospitalIDToCohortMap.get((String) row[INDEX_OF_HOSPITAL_ID]); String cohortString = ""; if (cohorts != null) { cohortString = StringUtils.join(cohorts.toArray(), ", "); } row = ArrayUtils.addAll(row, new String[] {cohortString}); updatedIndividuals.add(row); } individuals = updatedIndividuals; } catch (SessionExpiredException e) { MedSavantExceptionHandler.handleSessionExpiredException(e); } }