Example usage for org.apache.http.impl.cookie DateUtils formatDate

List of usage examples for org.apache.http.impl.cookie DateUtils formatDate

Introduction

In this page you can find the example usage for org.apache.http.impl.cookie DateUtils formatDate.

Prototype

public static String formatDate(final Date date, final String pattern) 

Source Link

Document

Formats the given date according to the specified pattern.

Usage

From source file:org.eqaula.glue.controller.accounting.LedgerHome.java

@Produces
@Named("ledger")//from ww  w .  jav  a  2s. c o  m
@Current
@TransactionAttribute
public Ledger load() {
    if (isIdDefined()) {
        wire();
    } else if (this.instance == null) {
        Date now = Calendar.getInstance().getTime();
        String code = DateUtils.formatDate(now, "dd.MM.yyyy." + getOrganization().getId());
        setInstance(ledgerService.retrivePosting(code, getOrganization()));
    }
    return getInstance();
}

From source file:org.eqaula.glue.controller.accounting.PostingHome.java

@Transactional
public Ledger getLedger() {

    if (ledger == null) {
        if (getLedgerId() == null) {
            //TODO check for a better code format
            Date now = Calendar.getInstance().getTime();
            String code = DateUtils.formatDate(now, "dd.MM.yyyy." + getOrganization().getId());
            ledger = ledgerService.retrivePosting(code, getOrganization());
        } else {/*from w  ww .  j av  a2  s .c o m*/
            ledger = ledgerService.find(getLedgerId());
        }
    }
    return ledger;
}

From source file:com.orange.labs.sample.entry.EntryRow.java

public void setExtraInfo(final OrangeCloudAPI.Entry entry) {

    // Add Date//  w w  w  . j a va 2  s .co  m
    String creationDate = DateUtils.formatDate(entry.creationDate, DateUtils.PATTERN_ASCTIME);
    mDateView.setText(creationDate);

    // Add size
    mExtraView.setText(entry.size);

    // ask thumbnail
    mApi.thumbnail(entry, new OrangeListener.Success<Bitmap>() {
        @Override
        public void onResponse(Bitmap response) {
            if (mEntry.equals(entry)) {
                mImageView.setImageBitmap(response);
            }
        }
    }, new OrangeListener.Error() {
        @Override
        public void onErrorResponse(OrangeAPIException error) {
            // do nothing !
        }
    });

}

From source file:android.webkit.cts.TestWebServer.java

private void setDateHeaders(HttpResponse response) {
    response.addHeader("Date", DateUtils.formatDate(new Date(), DateUtils.PATTERN_RFC1123));
}

From source file:com.ikanow.aleph2.storage_service_hdfs.services.TestMockHdfsStorageSystem.java

@Test
public void test_ageOut() throws IOException, InterruptedException, ExecutionException {
    // 0) Setup/*from  w  w w. j  a v  a  2 s .com*/
    final String temp_dir = System.getProperty("java.io.tmpdir") + File.separator;

    final GlobalPropertiesBean globals = BeanTemplateUtils.build(GlobalPropertiesBean.class)
            .with(GlobalPropertiesBean::local_yarn_config_dir, temp_dir)
            .with(GlobalPropertiesBean::distributed_root_dir, temp_dir)
            .with(GlobalPropertiesBean::local_root_dir, temp_dir)
            .with(GlobalPropertiesBean::distributed_root_dir, temp_dir).done().get();

    final MockHdfsStorageService storage_service = new MockHdfsStorageService(globals);

    // 1) Set up bucket (code taken from management_db_service)
    final DataBucketBean bucket = BeanTemplateUtils.build(DataBucketBean.class)
            .with(DataBucketBean::full_name, "/test/age/out/bucket")
            .with(DataBucketBean::data_schema, BeanTemplateUtils.build(DataSchemaBean.class)
                    .with(DataSchemaBean::storage_schema, BeanTemplateUtils.build(StorageSchemaBean.class)
                            .with(StorageSchemaBean::raw,
                                    BeanTemplateUtils.build(StorageSchemaBean.StorageSubSchemaBean.class)
                                            .with(StorageSchemaBean.StorageSubSchemaBean::exist_age_max,
                                                    "9 days")
                                            .done().get())
                            .with(StorageSchemaBean::json,
                                    BeanTemplateUtils.build(StorageSchemaBean.StorageSubSchemaBean.class)
                                            .with(StorageSchemaBean.StorageSubSchemaBean::exist_age_max,
                                                    "6 days")
                                            .done().get())
                            .with(StorageSchemaBean::processed,
                                    BeanTemplateUtils.build(StorageSchemaBean.StorageSubSchemaBean.class)
                                            .with(StorageSchemaBean.StorageSubSchemaBean::exist_age_max,
                                                    "1 week")
                                            .done().get())
                            .done().get())
                    .done().get())
            .done().get();

    FileUtils.deleteDirectory(new File(System.getProperty("java.io.tmpdir") + File.separator + "/data/"
            + File.separator + bucket.full_name()));
    setup_bucket(storage_service, bucket, Arrays.asList("$sec_test"));
    final String bucket_path = System.getProperty("java.io.tmpdir") + File.separator + "/data/" + File.separator
            + bucket.full_name();
    assertTrue("The file path has been created", new File(bucket_path + "/managed_bucket").exists());

    final long now = new Date().getTime();
    IntStream.range(4, 10).boxed().map(i -> now - (i * 1000L * 3600L * 24L))
            .forEach(Lambdas.wrap_consumer_u(n -> {
                final String pattern = TimeUtils.getTimeBasedSuffix(TimeUtils.getTimePeriod("1 day").success(),
                        Optional.empty());
                final String dir = DateUtils.formatDate(new Date(n), pattern);

                FileUtils.forceMkdir(
                        new File(bucket_path + "/" + IStorageService.STORED_DATA_SUFFIX_RAW + "/" + dir));
                FileUtils.forceMkdir(
                        new File(bucket_path + "/" + IStorageService.STORED_DATA_SUFFIX_JSON + "/" + dir));
                FileUtils.forceMkdir(
                        new File(bucket_path + "/" + IStorageService.STORED_DATA_SUFFIX_PROCESSED + "/" + dir));
                FileUtils.forceMkdir(new File(bucket_path + "/"
                        + IStorageService.STORED_DATA_SUFFIX_PROCESSED_SECONDARY + "/sec_test/" + dir)); // (mini test for secondary)
            }));

    // (7 cos includes root)
    assertEquals(7,
            FileUtils.listFilesAndDirs(new File(bucket_path + "/" + IStorageService.STORED_DATA_SUFFIX_RAW),
                    DirectoryFileFilter.DIRECTORY, TrueFileFilter.INSTANCE).size());
    assertEquals(7,
            FileUtils.listFilesAndDirs(new File(bucket_path + "/" + IStorageService.STORED_DATA_SUFFIX_JSON),
                    DirectoryFileFilter.DIRECTORY, TrueFileFilter.INSTANCE).size());
    assertEquals(7,
            FileUtils.listFilesAndDirs(
                    new File(bucket_path + "/" + IStorageService.STORED_DATA_SUFFIX_PROCESSED),
                    DirectoryFileFilter.DIRECTORY, TrueFileFilter.INSTANCE).size());
    assertEquals(7,
            FileUtils.listFilesAndDirs(new File(
                    bucket_path + "/" + IStorageService.STORED_DATA_SUFFIX_PROCESSED_SECONDARY + "/sec_test/"),
                    DirectoryFileFilter.DIRECTORY, TrueFileFilter.INSTANCE).size());

    // 1) Normal run:

    CompletableFuture<BasicMessageBean> cf = storage_service.getDataService().get().handleAgeOutRequest(bucket);

    BasicMessageBean res = cf.get();

    assertEquals(true, res.success());
    assertTrue("sensible message: " + res.message(), res.message().contains("raw: deleted 1 "));
    assertTrue("sensible message: " + res.message(), res.message().contains("json: deleted 4 "));
    assertTrue("sensible message: " + res.message(), res.message().contains("processed: deleted 3 "));

    assertTrue("Message marked as loggable: " + res.details(),
            Optional.ofNullable(res.details()).filter(m -> m.containsKey("loggable")).isPresent());

    System.out.println("Return from to delete: " + res.message());

    //(+1 including root)
    assertEquals(6,
            FileUtils.listFilesAndDirs(new File(bucket_path + "/" + IStorageService.STORED_DATA_SUFFIX_RAW),
                    DirectoryFileFilter.DIRECTORY, TrueFileFilter.INSTANCE).size());
    assertEquals(3,
            FileUtils.listFilesAndDirs(new File(bucket_path + "/" + IStorageService.STORED_DATA_SUFFIX_JSON),
                    DirectoryFileFilter.DIRECTORY, TrueFileFilter.INSTANCE).size());
    assertEquals(4,
            FileUtils.listFilesAndDirs(
                    new File(bucket_path + "/" + IStorageService.STORED_DATA_SUFFIX_PROCESSED),
                    DirectoryFileFilter.DIRECTORY, TrueFileFilter.INSTANCE).size());
    assertEquals(4,
            FileUtils.listFilesAndDirs(new File(
                    bucket_path + "/" + IStorageService.STORED_DATA_SUFFIX_PROCESSED_SECONDARY + "/sec_test/"),
                    DirectoryFileFilter.DIRECTORY, TrueFileFilter.INSTANCE).size());

    // 2) Run it again, returns success but not loggable:

    CompletableFuture<BasicMessageBean> cf2 = storage_service.getDataService().get()
            .handleAgeOutRequest(bucket);

    BasicMessageBean res2 = cf2.get();

    assertEquals(true, res2.success());
    assertTrue("sensible message: " + res2.message(), res2.message().contains("raw: deleted 0 "));
    assertTrue("sensible message: " + res2.message(), res2.message().contains("json: deleted 0 "));
    assertTrue("sensible message: " + res2.message(), res2.message().contains("processed: deleted 0 "));
    assertTrue("Message _not_ marked as loggable: " + res2.details(),
            !Optional.ofNullable(res2.details()).map(m -> m.get("loggable")).isPresent());

    // 3) No temporal settings

    final DataBucketBean bucket3 = BeanTemplateUtils.build(DataBucketBean.class)
            .with("full_name", "/test/handle/age/out/delete/not/temporal")
            .with(DataBucketBean::data_schema, BeanTemplateUtils.build(DataSchemaBean.class).done().get())
            .done().get();

    CompletableFuture<BasicMessageBean> cf3 = storage_service.getDataService().get()
            .handleAgeOutRequest(bucket3);
    BasicMessageBean res3 = cf3.get();
    // no temporal settings => returns success
    assertEquals(true, res3.success());

    // 4) Unparseable temporal settings (in theory won't validate but we can test here)

    final DataBucketBean bucket4 = BeanTemplateUtils.build(DataBucketBean.class)
            .with("full_name", "/test/handle/age/out/delete/temporal/malformed")
            .with(DataBucketBean::data_schema,
                    BeanTemplateUtils.build(DataSchemaBean.class).with(DataSchemaBean::storage_schema,
                            BeanTemplateUtils.build(StorageSchemaBean.class).with(StorageSchemaBean::json,
                                    BeanTemplateUtils.build(StorageSchemaBean.StorageSubSchemaBean.class)
                                            .with(StorageSchemaBean.StorageSubSchemaBean::exist_age_max,
                                                    "bananas")
                                            .done().get())
                                    .done().get())
                            .done().get())
            .done().get();

    CompletableFuture<BasicMessageBean> cf4 = storage_service.getDataService().get()
            .handleAgeOutRequest(bucket4);
    BasicMessageBean res4 = cf4.get();
    // no temporal settings => returns success
    assertEquals(false, res4.success());

}

From source file:com.ikanow.aleph2.storage_service_hdfs.services.HfdsDataWriteService.java

/** Gets the time based suffix, or IStorageService.NO_TIME_SUFFIX if it's not temporal
 * @param bucket//from w  w w . j  ava 2s. c o m
 * @param stage
 * @return
 */
public static String getSuffix(final Date now, final DataBucketBean bucket,
        final IStorageService.StorageStage stage) {
    return Optionals.of(() -> bucket.data_schema().storage_schema())
            .map(store -> getStorageSubSchema(store, stage)).map(ss -> ss.grouping_time_period())
            .<String>map(period -> TimeUtils.getTimePeriod(period)
                    .map(d -> TimeUtils.getTimeBasedSuffix(d, Optional.empty()))
                    .validation(fail -> null, success -> DateUtils.formatDate(now, success)))
            .orElse(IStorageService.NO_TIME_SUFFIX);
}

From source file:android.webkit.cts.CtsTestServer.java

private void setDateHeaders(HttpResponse response) {
    long time = System.currentTimeMillis();
    synchronized (this) {
        if (mDocValidity != 0) {
            String expires = DateUtils.formatDate(new Date(time + mDocValidity), DateUtils.PATTERN_RFC1123);
            response.addHeader("Expires", expires);
        }/*w  ww . j av a2  s  . co m*/
        if (mDocAge != 0) {
            String modified = DateUtils.formatDate(new Date(time - mDocAge), DateUtils.PATTERN_RFC1123);
            response.addHeader("Last-Modified", modified);
        }
    }
    response.addHeader("Date", DateUtils.formatDate(new Date(), DateUtils.PATTERN_RFC1123));
}

From source file:oscar.dms.actions.DmsInboxManageAction.java

public ActionForward prepareForContentPage(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) {//w ww .  j av  a2s.co  m
    HttpSession session = request.getSession();
    try {
        if (session.getAttribute("userrole") == null)
            response.sendRedirect("../logout.jsp");
    } catch (Exception e) {
        logger.error("Error", e);
    }

    // can't use userrole from session, because it changes if provider A search for provider B's documents

    // oscar.oscarMDS.data.MDSResultsData mDSData = new oscar.oscarMDS.data.MDSResultsData();
    CommonLabResultData comLab = new CommonLabResultData();
    // String providerNo = request.getParameter("providerNo");
    String providerNo = (String) session.getAttribute("user");
    String searchProviderNo = request.getParameter("searchProviderNo");
    String ackStatus = request.getParameter("status");
    String demographicNo = request.getParameter("demographicNo"); // used when searching for labs by patient instead of provider
    String scannedDocStatus = request.getParameter("scannedDocument");
    Integer page = 0;
    try {
        page = Integer.parseInt(request.getParameter("page"));
        if (page > 0) {
            page--;
        }
    } catch (NumberFormatException nfe) {
        page = 0;
    }
    Integer pageSize = 20;
    try {
        String tmp = request.getParameter("pageSize");
        pageSize = Integer.parseInt(tmp);
    } catch (NumberFormatException nfe) {
        pageSize = 20;
    }
    scannedDocStatus = "I";

    String startDateStr = request.getParameter("startDate");
    String endDateStr = request.getParameter("endDate");

    String view = request.getParameter("view");
    if (view == null || "".equals(view)) {
        view = "all";
    }

    boolean mixLabsAndDocs = "normal".equals(view) || "all".equals(view);

    Date startDate = null;
    Date endDate = null;

    try {
        if (startDateStr != null && startDateStr.length() > 0) {
            startDateStr = startDateStr.trim();
            startDate = UtilDateUtilities.StringToDate(startDateStr);
        }
        if (endDateStr != null && endDateStr.length() > 0) {
            endDateStr = endDateStr.trim();
            endDate = UtilDateUtilities.StringToDate(endDateStr);
        }
    } catch (Exception e) {
        startDate = null;
        endDate = null;
    }

    Boolean isAbnormal = null;
    if ("abnormal".equals(view))
        isAbnormal = new Boolean(true);
    if ("normal".equals(view))
        isAbnormal = new Boolean(false);

    if (ackStatus == null) {
        ackStatus = "N";
    } // default to new labs only
    if (providerNo == null) {
        providerNo = "";
    }
    if (searchProviderNo == null) {
        searchProviderNo = providerNo;
    }
    String roleName = "";
    List<SecUserRole> roles = secUserRoleDao.getUserRoles(searchProviderNo);
    for (SecUserRole r : roles) {
        if (r != null) {
            if (roleName.length() == 0) {
                roleName = r.getRoleName();

            } else {
                roleName += "," + r.getRoleName();
            }
        }
    }
    roleName += "," + searchProviderNo;
    // mDSData.populateMDSResultsData2(searchProviderNo, demographicNo, request.getParameter("fname"), request.getParameter("lname"), request.getParameter("hnum"), ackStatus);
    // HashMap<String,String> docQueue=comLab.getDocumentQueueLinks();
    List<QueueDocumentLink> qd = queueDocumentLinkDAO.getQueueDocLinks();
    HashMap<String, String> docQueue = new HashMap();
    for (QueueDocumentLink qdl : qd) {
        Integer i = qdl.getDocId();
        Integer n = qdl.getQueueId();
        docQueue.put(i.toString(), n.toString());
    }

    InboxResultsDao inboxResultsDao = (InboxResultsDao) SpringUtils.getBean("inboxResultsDao");
    String patientFirstName = request.getParameter("fname");
    String patientLastName = request.getParameter("lname");
    String patientHealthNumber = request.getParameter("hnum");

    ArrayList<LabResultData> labdocs = new ArrayList<LabResultData>();

    if (!"labs".equals(view) && !"abnormal".equals(view)) {
        labdocs = inboxResultsDao.populateDocumentResultsData(searchProviderNo, demographicNo, patientFirstName,
                patientLastName, patientHealthNumber, ackStatus, true, page, pageSize, mixLabsAndDocs,
                isAbnormal);
    }
    if (!"documents".equals(view)) {
        labdocs.addAll(comLab.populateLabResultsData(searchProviderNo, demographicNo, patientFirstName,
                patientLastName, patientHealthNumber, ackStatus, scannedDocStatus, true, page, pageSize,
                mixLabsAndDocs, isAbnormal));
    }

    labdocs = (ArrayList<LabResultData>) filterLabDocsForSuperSite(labdocs, providerNo);

    ArrayList<LabResultData> validlabdocs = new ArrayList<LabResultData>();

    DocumentResultsDao documentResultsDao = (DocumentResultsDao) SpringUtils.getBean("documentResultsDao");
    // check privilege for documents only
    for (LabResultData data : labdocs) {
        if (data.isDocument()) {
            String docid = data.getSegmentID();

            String queueid = docQueue.get(docid);
            if (queueid != null) {
                queueid = queueid.trim();

                int queueIdInt = Integer.parseInt(queueid);

                // if doc sent to default queue and no valid provider, do NOT include it
                if (queueIdInt == Queue.DEFAULT_QUEUE_ID && !documentResultsDao.isSentToValidProvider(docid)
                        && isSegmentIDUnique(validlabdocs, data)) {
                    // validlabdocs.add(data);
                }
                // if doc sent to default queue && valid provider, check if it's sent to this provider, if yes include it
                else if (queueIdInt == Queue.DEFAULT_QUEUE_ID && documentResultsDao.isSentToValidProvider(docid)
                        && documentResultsDao.isSentToProvider(docid, searchProviderNo)
                        && isSegmentIDUnique(validlabdocs, data)) {
                    validlabdocs.add(data);
                }
                // if doc setn to non-default queue and valid provider, check if provider is in the queue or equal to the provider
                else if (queueIdInt != Queue.DEFAULT_QUEUE_ID
                        && documentResultsDao.isSentToValidProvider(docid)) {
                    Vector vec = OscarRoleObjectPrivilege.getPrivilegeProp("_queue." + queueid);
                    if (OscarRoleObjectPrivilege.checkPrivilege(roleName, (Properties) vec.get(0),
                            (Vector) vec.get(1))
                            || documentResultsDao.isSentToProvider(docid, searchProviderNo)) {
                        // labs is in provider's queue,do nothing
                        if (isSegmentIDUnique(validlabdocs, data)) {
                            validlabdocs.add(data);
                        }
                    }
                }
                // if doc sent to non default queue and no valid provider, check if provider is in the non default queue
                else if (!queueid.equals(Queue.DEFAULT_QUEUE_ID)
                        && !documentResultsDao.isSentToValidProvider(docid)) {
                    Vector vec = OscarRoleObjectPrivilege.getPrivilegeProp("_queue." + queueid);
                    if (OscarRoleObjectPrivilege.checkPrivilege(roleName, (Properties) vec.get(0),
                            (Vector) vec.get(1))) {
                        // labs is in provider's queue,do nothing
                        if (isSegmentIDUnique(validlabdocs, data)) {
                            validlabdocs.add(data);
                        }

                    }
                }
            }
        } else {// add lab
            if (isSegmentIDUnique(validlabdocs, data)) {
                validlabdocs.add(data);
            }
        }
    }

    // Find the oldest lab returned in labdocs, use that as the limit date for the HRM query
    Date oldestLab = null;
    Date newestLab = null;
    if (request.getParameter("newestDate") != null) {
        try {
            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            newestLab = formatter.parse(request.getParameter("newestDate"));
        } catch (Exception e) {
            logger.error("Couldn't parse date + " + request.getParameter("newestDate"), e);
        }
    }

    for (LabResultData result : labdocs) {
        if (result != null && result.getDateObj() != null) {
            if (oldestLab == null || oldestLab.compareTo(result.getDateObj()) > 0)
                oldestLab = result.getDateObj();
            if (request.getParameter("newestDate") != null
                    && (newestLab == null || newestLab.compareTo(result.getDateObj()) < 0))
                newestLab = result.getDateObj();
        }
    }

    HRMResultsData hrmResult = new HRMResultsData();

    Collection<LabResultData> hrmDocuments = hrmResult.populateHRMdocumentsResultsData(searchProviderNo,
            ackStatus, newestLab, oldestLab);
    if (oldestLab == null) {
        for (LabResultData hrmDocument : hrmDocuments) {
            if (oldestLab == null
                    || (hrmDocument.getDateObj() != null && oldestLab.compareTo(hrmDocument.getDateObj()) > 0))
                oldestLab = hrmDocument.getDateObj();
        }
    }

    //labdocs is already filtered for super site access.. not just filter hrmDocuments
    hrmDocuments = filterLabDocsForSuperSite(hrmDocuments, providerNo);

    labdocs.addAll(hrmDocuments);
    Collections.sort(labdocs);

    HashMap<String, LabResultData> labMap = new HashMap<String, LabResultData>();
    LinkedHashMap<String, ArrayList<String>> accessionMap = new LinkedHashMap<String, ArrayList<String>>();

    int accessionNumCount = 0;
    for (LabResultData result : labdocs) {
        if (startDate != null && startDate.after(result.getDateObj())) {
            continue;
        }

        if (endDate != null && endDate.before(result.getDateObj())) {
            continue;
        }

        String segmentId = result.getSegmentID();
        if (result.isDocument())
            segmentId += "d";
        else if (result.isHRM())
            segmentId += "h";

        labMap.put(segmentId, result);
        ArrayList<String> labNums = new ArrayList<String>();

        if (result.accessionNumber == null || result.accessionNumber.equals("")) {
            labNums.add(segmentId);
            accessionNumCount++;
            accessionMap.put("noAccessionNum" + accessionNumCount + result.labType, labNums);
        } else if (!accessionMap.containsKey(result.accessionNumber + result.labType)) {
            labNums.add(segmentId);
            accessionMap.put(result.accessionNumber + result.labType, labNums);

            // Different MDS Labs may have the same accession Number if they are seperated
            // by two years. So accession numbers are limited to matching only if their
            // labs are within one year of eachother
        } else {
            labNums = accessionMap.get(result.accessionNumber + result.labType);
            boolean matchFlag = false;
            for (int j = 0; j < labNums.size(); j++) {
                LabResultData matchingResult = labMap.get(labNums.get(j));

                Date dateA = result.getDateObj();
                Date dateB = matchingResult.getDateObj();
                int monthsBetween = 0;
                if (dateA == null || dateB == null) {
                    monthsBetween = 5;
                } else if (dateA.before(dateB)) {
                    monthsBetween = UtilDateUtilities.getNumMonths(dateA, dateB);
                } else {
                    monthsBetween = UtilDateUtilities.getNumMonths(dateB, dateA);
                }

                if (monthsBetween < 4) {
                    matchFlag = true;
                    break;
                }
            }
            if (!matchFlag) {
                labNums.add(segmentId);
                accessionMap.put(result.accessionNumber + result.labType, labNums);
            }
        }
    }

    labdocs.clear();

    for (ArrayList<String> labNums : accessionMap.values()) {
        // must sort through in reverse to keep the labs in the correct order
        for (int j = labNums.size() - 1; j >= 0; j--) {
            labdocs.add(labMap.get(labNums.get(j)));
        }
    }
    logger.debug("labdocs.size()=" + labdocs.size());

    /* find all data for the index.jsp page */
    Hashtable patientDocs = new Hashtable();
    Hashtable patientIdNames = new Hashtable();
    String patientIdNamesStr = "";
    Hashtable docStatus = new Hashtable();
    Hashtable docType = new Hashtable();
    Hashtable<String, List<String>> ab_NormalDoc = new Hashtable();

    for (int i = 0; i < labdocs.size(); i++) {
        LabResultData data = labdocs.get(i);

        List<String> segIDs = new ArrayList<String>();
        String labPatientId = data.getLabPatientId();
        if (labPatientId == null || labPatientId.equals("-1"))
            labPatientId = "-1";

        if (data.isAbnormal()) {
            List<String> abns = ab_NormalDoc.get("abnormal");
            if (abns == null) {
                abns = new ArrayList<String>();
                abns.add(data.getSegmentID());
            } else {
                abns.add(data.getSegmentID());
            }
            ab_NormalDoc.put("abnormal", abns);
        } else {
            List<String> ns = ab_NormalDoc.get("normal");
            if (ns == null) {
                ns = new ArrayList<String>();
                ns.add(data.getSegmentID());
            } else {
                ns.add(data.getSegmentID());
            }
            ab_NormalDoc.put("normal", ns);
        }
        if (patientDocs.containsKey(labPatientId)) {

            segIDs = (List) patientDocs.get(labPatientId);
            segIDs.add(data.getSegmentID());
            patientDocs.put(labPatientId, segIDs);
        } else {
            segIDs.add(data.getSegmentID());
            patientDocs.put(labPatientId, segIDs);
            patientIdNames.put(labPatientId, data.patientName);
            patientIdNamesStr += ";" + labPatientId + "=" + data.patientName;
        }
        docStatus.put(data.getSegmentID(), data.getAcknowledgedStatus());
        docType.put(data.getSegmentID(), data.labType);
    }

    Integer totalDocs = 0;
    Integer totalHL7 = 0;
    Hashtable<String, List<String>> typeDocLab = new Hashtable();
    Enumeration keys = docType.keys();
    while (keys.hasMoreElements()) {
        String keyDocLabId = ((String) keys.nextElement());
        String valType = (String) docType.get(keyDocLabId);

        if (valType.equalsIgnoreCase("DOC")) {
            if (typeDocLab.containsKey("DOC")) {
                List<String> docids = typeDocLab.get("DOC");
                docids.add(keyDocLabId);// add doc id to list
                typeDocLab.put("DOC", docids);
            } else {
                List<String> docids = new ArrayList<String>();
                docids.add(keyDocLabId);
                typeDocLab.put("DOC", docids);
            }
            totalDocs++;
        } else if (valType.equalsIgnoreCase("HL7")) {
            if (typeDocLab.containsKey("HL7")) {
                List<String> hl7ids = typeDocLab.get("HL7");
                hl7ids.add(keyDocLabId);
                typeDocLab.put("HL7", hl7ids);
            } else {
                List<String> hl7ids = new ArrayList<String>();
                hl7ids.add(keyDocLabId);
                typeDocLab.put("HL7", hl7ids);
            }
            totalHL7++;
        }
    }

    Hashtable patientNumDoc = new Hashtable();
    Enumeration patientIds = patientDocs.keys();
    String patientIdStr = "";
    Integer totalNumDocs = 0;
    while (patientIds.hasMoreElements()) {
        String key = (String) patientIds.nextElement();
        patientIdStr += key;
        patientIdStr += ",";
        List<String> val = (List<String>) patientDocs.get(key);
        Integer numDoc = val.size();
        patientNumDoc.put(key, numDoc);
        totalNumDocs += numDoc;
    }

    List<String> normals = ab_NormalDoc.get("normal");
    List<String> abnormals = ab_NormalDoc.get("abnormal");

    logger.debug("labdocs.size()=" + labdocs.size());

    // set attributes
    request.setAttribute("pageNum", page);
    request.setAttribute("docType", docType);
    request.setAttribute("patientDocs", patientDocs);
    request.setAttribute("providerNo", providerNo);
    request.setAttribute("searchProviderNo", searchProviderNo);
    request.setAttribute("patientIdNames", patientIdNames);
    request.setAttribute("docStatus", docStatus);
    request.setAttribute("patientIdStr", patientIdStr);
    request.setAttribute("typeDocLab", typeDocLab);
    request.setAttribute("demographicNo", demographicNo);
    request.setAttribute("ackStatus", ackStatus);
    request.setAttribute("labdocs", labdocs);
    request.setAttribute("patientNumDoc", patientNumDoc);
    request.setAttribute("totalDocs", totalDocs);
    request.setAttribute("totalHL7", totalHL7);
    request.setAttribute("normals", normals);
    request.setAttribute("abnormals", abnormals);
    request.setAttribute("totalNumDocs", totalNumDocs);
    request.setAttribute("patientIdNamesStr", patientIdNamesStr);
    request.setAttribute("oldestLab",
            oldestLab != null ? DateUtils.formatDate(oldestLab, "yyyy-MM-dd HH:mm:ss") : null);

    return mapping.findForward("dms_page");
}