public Bundle getProjectPatientBundle(AccessToken token) throws FhirServerException {
   ProjectPatientMap p =
       getProjectPatientMap(
           token.getResourceUserId(),
           token.getI2b2Token(),
           token.getI2b2Url(),
           token.getI2b2Domain(),
           token.getI2b2Project());
   String bundleXml = p.getPatientBundle();
   Bundle b = null;
   try {
     b = JAXBUtil.fromXml(bundleXml, Bundle.class);
   } catch (JAXBException e) {
     logger.error(e.getMessage(), e);
   }
   return b;
 }
  private void fetchPatientList(
      String i2b2User, String i2b2Token, String i2b2Url, String i2b2Domain, String projectId)
      throws FhirServerException {
    status.markProcessing(projectId);
    try {
      logger.trace("fetching all Patients for project:" + projectId);
      String i2b2Xml = null;
      Bundle b = new Bundle();
      ArrayList<String> list = null;

      if (serverConfigs.GetString(ConfigParameter.patientFetchMin) != null
          && serverConfigs.GetString(ConfigParameter.patientFetchMin).equals("true")) {
        logger.debug("min call");
        i2b2Xml = I2b2Util.getAllPatientsMin(i2b2User, i2b2Token, i2b2Url, i2b2Domain, projectId);

        list = I2b2Util.getAllPatientsAsList(i2b2Xml);

        for (String id : list) {
          Patient p = new Patient();
          p = (Patient) FhirUtil.setId(p, id);
          BundleEntry be = new BundleEntry();
          be.setResource(FhirUtil.getResourceContainer(p));
          b.getEntry().add(be);
        }

      } else {
        logger.debug("max call");
        i2b2Xml = I2b2Util.getAllPatients(i2b2User, i2b2Token, i2b2Url, i2b2Domain, projectId);
        list = I2b2Util.getAllPatientsAsList(i2b2Xml);
        b = I2b2Util.getAllPatientsAsFhirBundle(i2b2Xml);
      }

      String bundleXml = JAXBUtil.toXml(b);
      service.put(projectId, list, bundleXml);
    } catch (Exception e) {
      logger.error(e.getMessage(), e);
      throw new FhirServerException("Could not fetch patient list from i2b2 server");
    }
    status.markComplete(projectId);
  }