diff --git a/frontend/src/components/resultPage/SearchResultForm.js b/frontend/src/components/resultPage/SearchResultForm.js index cb800a2370..28ca4121b3 100644 --- a/frontend/src/components/resultPage/SearchResultForm.js +++ b/frontend/src/components/resultPage/SearchResultForm.js @@ -59,7 +59,10 @@ export function SearchResultForm(props) { const [searchFormValues, setSearchFormValues] = useState( SearchResultFormValues, ); - + const [nextPage, setNextPage] = useState(null); + const [previousPage, setPreviousPage] = useState(null); + const [pagination, setPagination] = useState(false); + const [url, setUrl] = useState(""); const componentMounted = useRef(false); const setResultsWithId = (results) => { @@ -70,6 +73,22 @@ export function SearchResultForm(props) { } props.setResults?.(results); setLoading(false); + if (results.paging) { + var { totalPages, currentPage } = results.paging; + if (totalPages > 1) { + setPagination(true); + if (parseInt(currentPage) < parseInt(totalPages)) { + setNextPage(parseInt(currentPage) + 1); + } else { + setNextPage(null); + } + if (parseInt(currentPage) > 1) { + setPreviousPage(parseInt(currentPage) - 1); + } else { + setPreviousPage(null); + } + } + } } else { props.setResults?.({ testResult: [] }); setNotificationBody({ @@ -84,7 +103,20 @@ export function SearchResultForm(props) { const handleAdvancedSearch = () => {}; + const loadNextResultsPage = () => { + setLoading(true); + getFromOpenElisServer(url + "&page=" + nextPage, setResultsWithId); + }; + + const loadPreviousResultsPage = () => { + setLoading(true); + getFromOpenElisServer(url + "&page=" + previousPage, setResultsWithId); + }; + const getSelectedPatient = (patient) => { + setNextPage(null); + setPreviousPage(null); + setPagination(false); setPatient(patient); }; useEffect(() => { @@ -127,10 +159,15 @@ export function SearchResultForm(props) { searchBy.doRange + "&finished=" + true; + setUrl(searchEndPoint); + getFromOpenElisServer(searchEndPoint, setResultsWithId); }; const handleSubmit = (values) => { + setNextPage(null); + setPreviousPage(null); + setPagination(false); querySearch(values); }; @@ -157,6 +194,9 @@ export function SearchResultForm(props) { }; const submitOnSelect = (e) => { + setNextPage(null); + setPreviousPage(null); + setPagination(false); var values = { unitType: e.target.value }; handleSubmit(values); }; @@ -192,6 +232,9 @@ export function SearchResultForm(props) { setSearchFormValues(searchValues); querySearch(searchValues); } + setNextPage(null); + setPreviousPage(null); + setPagination(false); }, [searchBy]); return ( @@ -434,6 +477,35 @@ export function SearchResultForm(props) { )} + + <> + {pagination && ( + + + + + + + + + + + )} + ); } @@ -1046,8 +1118,8 @@ export function SearchResults(props) { nonconforming diff --git a/frontend/src/components/validation/SearchForm.js b/frontend/src/components/validation/SearchForm.js index e71c4f2064..6614ed9540 100644 --- a/frontend/src/components/validation/SearchForm.js +++ b/frontend/src/components/validation/SearchForm.js @@ -34,10 +34,31 @@ const SearchForm = (props) => { const [testSections, setTestSections] = useState([]); const [testDate, setTestDate] = useState(""); const [isLoading, setIsLoading] = useState(false); + const [nextPage, setNextPage] = useState(null); + const [previousPage, setPreviousPage] = useState(null); + const [pagination, setPagination] = useState(false); + const [url, setUrl] = useState(""); + const validationResults = (data) => { if (data) { setSearchResults(data); setIsLoading(false); + if (data.paging) { + var { totalPages, currentPage } = data.paging; + if (totalPages > 1) { + setPagination(true); + if (parseInt(currentPage) < parseInt(totalPages)) { + setNextPage(parseInt(currentPage) + 1); + } else { + setNextPage(null); + } + if (parseInt(currentPage) > 1) { + setPreviousPage(parseInt(currentPage) - 1); + } else { + setPreviousPage(null); + } + } + } if (data.resultList.length > 0) { const newResultsList = data.resultList.map((data, id) => { let tempData = { ...data }; @@ -70,6 +91,9 @@ const SearchForm = (props) => { }, [searchResults]); const handleSubmit = (values) => { + setNextPage(null); + setPreviousPage(null); + setPagination(false); setIsLoading(true); var accessionNumber = values.accessionNumber ? values.accessionNumber : ""; var unitType = values.unitType ? values.unitType : ""; @@ -84,16 +108,29 @@ const SearchForm = (props) => { date + "&doRange=" + doRange; - + setUrl(searchEndPoint); getFromOpenElisServer(searchEndPoint, validationResults); }; const handleChange = () => {}; + + const loadNextResultsPage = () => { + setIsLoading(true); + getFromOpenElisServer(url + "&page=" + nextPage, validationResults); + }; + + const loadPreviousResultsPage = () => { + setIsLoading(true); + getFromOpenElisServer(url + "&page=" + previousPage, validationResults); + }; const fetchTestSections = (response) => { setTestSections(response); }; const submitOnSelect = (e) => { + setNextPage(null); + setPreviousPage(null); + setPagination(false); var values = { unitType: e.target.value }; handleSubmit(values); }; @@ -111,6 +148,9 @@ const SearchForm = (props) => { setDoRagnge(false); } getFromOpenElisServer("/rest/user-test-sections", fetchTestSections); + setNextPage(null); + setPreviousPage(null); + setPagination(false); }, []); return ( <> @@ -236,6 +276,35 @@ const SearchForm = (props) => { )} + +<> + {pagination && ( + + + + + + + + + + + )} + ); }; diff --git a/src/main/java/org/openelisglobal/analysis/daoimpl/AnalysisDAOImpl.java b/src/main/java/org/openelisglobal/analysis/daoimpl/AnalysisDAOImpl.java index 1fe20cbd44..da523ca828 100644 --- a/src/main/java/org/openelisglobal/analysis/daoimpl/AnalysisDAOImpl.java +++ b/src/main/java/org/openelisglobal/analysis/daoimpl/AnalysisDAOImpl.java @@ -36,7 +36,7 @@ import org.openelisglobal.common.daoimpl.BaseDAOImpl; import org.openelisglobal.common.exception.LIMSRuntimeException; import org.openelisglobal.common.log.LogEvent; -import org.openelisglobal.common.paging.PagingProperties; +//import org.openelisglobal.common.paging.PagingProperties; import org.openelisglobal.common.services.IStatusService; import org.openelisglobal.common.services.StatusService.AnalysisStatus; import org.openelisglobal.common.util.StringUtil; @@ -216,7 +216,7 @@ public List getPageAnalysisByTestSectionAndStatus(String testSectionId query.setParameter("testSectionId", Integer.parseInt(testSectionId)); query.setParameterList("statusIdList", statusIdList); - query.setMaxResults(SpringContext.getBean(PagingProperties.class).getValidationPageSize()); + // query.setMaxResults(SpringContext.getBean(PagingProperties.class).getValidationPageSize()); return query.list(); } catch (RuntimeException e) { @@ -241,7 +241,7 @@ public List getPageAnalysisAtAccessionNumberAndStatus(String accession query.setParameter("accessionNumber", accessionNumber); query.setParameterList("statusIdList", statusIdList); - query.setMaxResults(SpringContext.getBean(PagingProperties.class).getValidationPageSize()); + //query.setMaxResults(SpringContext.getBean(PagingProperties.class).getValidationPageSize()); return query.list(); } catch (RuntimeException e) { @@ -1256,7 +1256,7 @@ public List getPageAnalysisByTestSectionAndStatus(String testSectionId query.setParameter("testSectionId", Integer.parseInt(testSectionId)); query.setParameterList("analysisStatusList", analysisStatusList); query.setParameterList("sampleStatusList", sampleStatusList); - query.setMaxResults(SpringContext.getBean(PagingProperties.class).getResultsPageSize()); + // query.setMaxResults(SpringContext.getBean(PagingProperties.class).getResultsPageSize()); List analysisList = query.list(); @@ -1537,7 +1537,7 @@ public List getPageAnalysisByStatusFromAccession(List analysi query.setParameter("accessionNumber", accessionNumber); query.setParameterList("analysisStatusList", analysisStatusList); query.setParameterList("sampleStatusList", sampleStatusList); - query.setMaxResults(SpringContext.getBean(PagingProperties.class).getResultsPageSize()); + //query.setMaxResults(SpringContext.getBean(PagingProperties.class).getResultsPageSize()); List analysisList = query.list(); @@ -1595,7 +1595,7 @@ public List getPageAnalysisByStatusFromAccession(List analysi } query.setParameterList("analysisStatusList", analysisStatusList); query.setParameterList("sampleStatusList", sampleStatusList); - query.setMaxResults(SpringContext.getBean(PagingProperties.class).getResultsPageSize()); + //query.setMaxResults(SpringContext.getBean(PagingProperties.class).getResultsPageSize()); List analysisList = query.list(); diff --git a/src/main/java/org/openelisglobal/common/paging/PagingUtility.java b/src/main/java/org/openelisglobal/common/paging/PagingUtility.java index 494921e127..5a2212f3de 100644 --- a/src/main/java/org/openelisglobal/common/paging/PagingUtility.java +++ b/src/main/java/org/openelisglobal/common/paging/PagingUtility.java @@ -51,7 +51,7 @@ public void setDatabaseResults(HttpSession session, E items, IPageDivider div public E getPage(int page, HttpSession session) { if (page > 0) { List pagedResults = (List) session.getAttribute(IActionConstants.RESULTS_SESSION_CACHE); - + totalPages = pagedResults.size(); if (pagedResults != null && pagedResults.size() >= page) { return pagedResults.get(page - 1); } diff --git a/src/main/java/org/openelisglobal/result/action/util/ResultsPaging.java b/src/main/java/org/openelisglobal/result/action/util/ResultsPaging.java index 29556db605..e6e924b84e 100644 --- a/src/main/java/org/openelisglobal/result/action/util/ResultsPaging.java +++ b/src/main/java/org/openelisglobal/result/action/util/ResultsPaging.java @@ -55,9 +55,9 @@ public void page(HttpServletRequest request, ResultsPagingForm form, int newPage throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { request.getSession().setAttribute(IActionConstants.SAVE_DISABLED, IActionConstants.FALSE); - List clientTests = form.getTestResult(); - PagingBean bean = form.getPaging(); - paging.updatePagedResults(request.getSession(), clientTests, bean, pagingHelper); + //List clientTests = form.getTestResult(); + //PagingBean bean = form.getPaging(); + //paging.updatePagedResults(request.getSession(), clientTests, bean, pagingHelper); if (newPage < 0) { newPage = 0; diff --git a/src/main/java/org/openelisglobal/result/controller/rest/LogbookResultsRestController.java b/src/main/java/org/openelisglobal/result/controller/rest/LogbookResultsRestController.java index e7930d0141..b9b4be0214 100644 --- a/src/main/java/org/openelisglobal/result/controller/rest/LogbookResultsRestController.java +++ b/src/main/java/org/openelisglobal/result/controller/rest/LogbookResultsRestController.java @@ -222,27 +222,6 @@ public LogbookResultsForm showReactLogbookResults(@RequestParam(required = false } - @GetMapping(value = "ReactRangeResults", produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - public LogbookResultsForm showReactLogbookResultsByRange(@RequestParam String labNumber, - @RequestParam String upperRangeAccessionNumber,@RequestParam boolean doRange, @RequestParam boolean finished, - @Validated(LogbookResults.class) @ModelAttribute("form") LogbookResultsForm form, BindingResult result) - throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { - - LogbookResultsForm newForm = new LogbookResultsForm(); - if (!(result.hasFieldErrors("type") || result.hasFieldErrors("accessionNumber"))) { - newForm.setType(form.getType()); - newForm.setAccessionNumber(form.getAccessionNumber()); - - String currentDate = getCurrentDate(); - newForm.setCurrentDate(currentDate); - } - newForm.setDisplayTestSections(false); - newForm.setSearchByRange(true); - - return getLogbookResults(request, newForm,null, labNumber,"",upperRangeAccessionNumber, doRange, finished); - } - private LogbookResultsForm getLogbookResults(HttpServletRequest request, LogbookResultsForm form,StatusResultsForm statusResultsForm, String labNumber,String patientPK,String upperRangeAccessionNumber, boolean doRange, boolean finished) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { diff --git a/src/main/java/org/openelisglobal/resultvalidation/action/util/ResultValidationPaging.java b/src/main/java/org/openelisglobal/resultvalidation/action/util/ResultValidationPaging.java index 087498f23a..44746d1ffe 100644 --- a/src/main/java/org/openelisglobal/resultvalidation/action/util/ResultValidationPaging.java +++ b/src/main/java/org/openelisglobal/resultvalidation/action/util/ResultValidationPaging.java @@ -56,11 +56,11 @@ public void page(HttpServletRequest request, ValidationPagingForm form, int newP throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { request.getSession().setAttribute(IActionConstants.SAVE_DISABLED, IActionConstants.FALSE); - List clientAnalysis = form.getResultList(); - PagingBean bean = form.getPaging(); + // List clientAnalysis = form.getResultList(); + // PagingBean bean = form.getPaging(); String testSectionId = form.getTestSectionId(); - paging.updatePagedResults(request.getSession(), clientAnalysis, bean, pagingHelper); + // paging.updatePagedResults(request.getSession(), clientAnalysis, bean, pagingHelper); if (newPage < 0) { newPage = 0;