diff --git a/frontend/cypress/e2e/modifyOrder.cy.js b/frontend/cypress/e2e/modifyOrder.cy.js index 6df6bcd2ee..0b257b216a 100644 --- a/frontend/cypress/e2e/modifyOrder.cy.js +++ b/frontend/cypress/e2e/modifyOrder.cy.js @@ -102,7 +102,7 @@ describe("Modify Order search by patient ", function () { ); }); }); - + //TO DO needs fixing it("Should be able to search by respective patient ", function () { cy.wait(1000); modifyOrderPage.clickRespectivePatient(); diff --git a/frontend/cypress/pages/ModifyOrderPage.js b/frontend/cypress/pages/ModifyOrderPage.js index c1f6eda74c..7595866790 100644 --- a/frontend/cypress/pages/ModifyOrderPage.js +++ b/frontend/cypress/pages/ModifyOrderPage.js @@ -41,9 +41,9 @@ class ModifyOrderPage { clickRespectivePatient() { return cy - .get( - ":nth-child(2) > :nth-child(1) > .cds--radio-button-wrapper > .cds--radio-button__label > .cds--radio-button__appearance", - ) + .get("tbody tr") + .first() + .find(".cds--radio-button__appearance") .click(); } } diff --git a/frontend/src/components/addOrder/Index.js b/frontend/src/components/addOrder/Index.js index 7eca6c5a1c..ea10879042 100755 --- a/frontend/src/components/addOrder/Index.js +++ b/frontend/src/components/addOrder/Index.js @@ -45,6 +45,7 @@ const Index = () => { const [orderFormValues, setOrderFormValues] = useState(SampleOrderFormValues); const [samples, setSamples] = useState([sampleObject]); const [errors, setErrors] = useState([]); + const [isSubmitting, setIsSubmitting] = useState(false); let SampleTypes = []; let sampleTypeMap = {}; @@ -536,6 +537,7 @@ const Index = () => { }; const handlePost = (status) => { + setIsSubmitting(false); if (status === 200) { showAlertMessage( , @@ -562,6 +564,11 @@ const Index = () => { const handleSubmitOrderForm = (e) => { e.preventDefault(); + // Prevent multiple submissions. + if (isSubmitting) { + return; + } + setIsSubmitting(true); if ("years" in orderFormValues.patientProperties) { delete orderFormValues.patientProperties.years; } @@ -802,7 +809,9 @@ const Index = () => { 0 ? true : false} + disabled={ + isSubmitting || errors?.errors?.length > 0 ? true : false + } onClick={handleSubmitOrderForm} > diff --git a/frontend/src/components/admin/calculatedValue/CalculatedValueForm.tsx b/frontend/src/components/admin/calculatedValue/CalculatedValueForm.tsx index 8f423c4b2d..cb5f42e2e1 100644 --- a/frontend/src/components/admin/calculatedValue/CalculatedValueForm.tsx +++ b/frontend/src/components/admin/calculatedValue/CalculatedValueForm.tsx @@ -88,6 +88,7 @@ const CalculatedValue: React.FC = () => { const [sampleList, setSampleList] = useState([]); const [sampleTestList, setSampleTestList] = useState(TestListObj); const [loading, setLoading] = useState(true); + const [isSubmitting, setIsSubmitting] = useState(false); const { notificationVisible, setNotificationVisible, addNotification } = useContext(NotificationContext); const [mathFunctions, setMathFunctions] = useState([mathFunction]); @@ -342,6 +343,7 @@ const CalculatedValue: React.FC = () => { }; const handleCalculationSubmited = (status, index) => { + setIsSubmitting(false); setNotificationVisible(true); if (status == "200") { const element = document.getElementById( @@ -373,6 +375,10 @@ const CalculatedValue: React.FC = () => { const handleSubmit = (event: any, index: number) => { event.preventDefault(); + if (isSubmitting) { + return; + } + setIsSubmitting(true); let mathematicalOperation = ""; calculationList[index]["operations"].forEach( (operation, operationIndex) => { @@ -943,6 +949,7 @@ const CalculatedValue: React.FC = () => { type="submit" kind="primary" size="sm" + disabled={isSubmitting} > diff --git a/frontend/src/components/admin/reflexTests/ReflexRuleForm.js b/frontend/src/components/admin/reflexTests/ReflexRuleForm.js index 035ec8988c..d696a6b681 100644 --- a/frontend/src/components/admin/reflexTests/ReflexRuleForm.js +++ b/frontend/src/components/admin/reflexTests/ReflexRuleForm.js @@ -87,6 +87,7 @@ function ReflexRule() { }); //{field :{index :{field_index:[]}}} const [counter, setCounter] = useState(0); const [loading, setLoading] = useState(true); + const [isSubmitting, setIsSubmitting] = useState(false); const [errors, setErrors] = useState({}); const { notificationVisible, setNotificationVisible, addNotification } = useContext(NotificationContext); @@ -340,6 +341,7 @@ function ReflexRule() { }; const handleSubmited = (status, index) => { + setIsSubmitting(false); setNotificationVisible(true); if (status == "200") { const element = document.getElementById("submit_" + index); @@ -360,6 +362,10 @@ function ReflexRule() { const handleSubmit = (event, index) => { event.preventDefault(); + if (isSubmitting) { + return; + } + setIsSubmitting(true); console.debug(JSON.stringify(ruleList[index])); postToOpenElisServer( "/rest/reflexrule", @@ -737,7 +743,13 @@ function ReflexRule() { <> { + if (isSubmitting) { + return; + } + setIsSubmitting(true); let specimenAdequacy = null; if (pathologySampleInfo.specimenAdequacy) { specimenAdequacy = pathologySampleInfo.specimenAdequacy; @@ -418,6 +424,7 @@ function CytologyCaseView() { { e.preventDefault(); save(e); @@ -1705,6 +1712,7 @@ function CytologyCaseView() { { e.preventDefault(); save(e); diff --git a/frontend/src/components/immunohistochemistry/ImmunohistochemistryCaseView.js b/frontend/src/components/immunohistochemistry/ImmunohistochemistryCaseView.js index 2a878f7c66..1c924a8563 100644 --- a/frontend/src/components/immunohistochemistry/ImmunohistochemistryCaseView.js +++ b/frontend/src/components/immunohistochemistry/ImmunohistochemistryCaseView.js @@ -78,6 +78,7 @@ function ImmunohistochemistryCaseView() { const [pagination, setPagination] = useState(false); const [currentApiPage, setCurrentApiPage] = useState(null); const [totalApiPages, setTotalApiPages] = useState(null); + const [isSubmitting, setIsSubmitting] = useState(false); const [reportParams, setReportParams] = useState({ 0: { erPercent: "", @@ -108,6 +109,7 @@ function ImmunohistochemistryCaseView() { async function displayStatus(response) { var body = await response.json(); console.debug(body); + setIsSubmitting(false); var status = response.status; setNotificationVisible(true); if (status == "200") { @@ -875,6 +877,10 @@ function ImmunohistochemistryCaseView() { }); const save = () => { + if (isSubmitting) { + return; + } + setIsSubmitting(true); let submitValues = { assignedTechnicianId: immunohistochemistrySampleInfo.assignedTechnicianId, assignedPathologistId: @@ -1024,6 +1030,7 @@ function ImmunohistochemistryCaseView() { { e.preventDefault(); save(e); @@ -1633,6 +1640,7 @@ function ImmunohistochemistryCaseView() { { e.preventDefault(); save(e); diff --git a/frontend/src/components/layout/search/searchBar.css b/frontend/src/components/layout/search/searchBar.css index e202ea237d..6e9b048cc5 100644 --- a/frontend/src/components/layout/search/searchBar.css +++ b/frontend/src/components/layout/search/searchBar.css @@ -17,7 +17,6 @@ .search-input { width: 100%; position: relative; - } .search-bar-container:hover { @@ -52,11 +51,8 @@ cursor: pointer; } - /* Large screens (1208px and up) */ @media (min-width: 1208px) { - - .search-bar-container { width: 45%; margin-top: 0%; @@ -77,7 +73,7 @@ right: 130px; box-shadow: 0em 0.1em 0.5em #ccc; } - + .patientHead { overflow-y: auto; width: 600px; diff --git a/frontend/src/components/layout/search/searchBar.js b/frontend/src/components/layout/search/searchBar.js index a3223b6b28..e1db0c5216 100644 --- a/frontend/src/components/layout/search/searchBar.js +++ b/frontend/src/components/layout/search/searchBar.js @@ -148,4 +148,4 @@ const SearchBar = (props) => { ); }; -export default SearchBar; \ No newline at end of file +export default SearchBar; diff --git a/frontend/src/components/modifyOrder/ModifyOrder.js b/frontend/src/components/modifyOrder/ModifyOrder.js index 4ca33d6d8f..2cc3e2a2e0 100644 --- a/frontend/src/components/modifyOrder/ModifyOrder.js +++ b/frontend/src/components/modifyOrder/ModifyOrder.js @@ -53,6 +53,7 @@ const ModifyOrder = () => { const [orderFormValues, setOrderFormValues] = useState(ModifyOrderFormValues); const [samples, setSamples] = useState([sampleObject]); const [errors, setErrors] = useState([]); + const [isSubmitting, setIsSubmitting] = useState(false); useEffect(() => { componentMounted.current = true; @@ -110,6 +111,7 @@ const ModifyOrder = () => { }; const handlePost = (status) => { + setIsSubmitting(false); if (status === 200) { showAlertMessage( , @@ -124,6 +126,10 @@ const ModifyOrder = () => { }; const handleSubmitOrderForm = (e) => { e.preventDefault(); + if (isSubmitting) { + return; + } + setIsSubmitting(true); setPage(page + 1); orderFormValues.sampleOrderItems.modified = true; //remove display Lists rom the form @@ -337,7 +343,9 @@ const ModifyOrder = () => { kind="primary" className="forwardButton" onClick={handleSubmitOrderForm} - disabled={errors?.errors?.length > 0 ? true : false} + disabled={ + isSubmitting || errors?.errors?.length > 0 ? true : false + } > diff --git a/frontend/src/components/pathology/PathologyCaseView.js b/frontend/src/components/pathology/PathologyCaseView.js index 2a573fda2f..af659ed8b0 100644 --- a/frontend/src/components/pathology/PathologyCaseView.js +++ b/frontend/src/components/pathology/PathologyCaseView.js @@ -70,6 +70,7 @@ function PathologyCaseView() { const [pagination, setPagination] = useState(false); const [currentApiPage, setCurrentApiPage] = useState(null); const [totalApiPages, setTotalApiPages] = useState(null); + const [isSubmitting, setIsSubmitting] = useState(false); const [reportParams, setReportParams] = useState({ 0: { submited: false, @@ -80,6 +81,7 @@ function PathologyCaseView() { async function displayStatus(response) { var body = await response.json(); console.debug(body); + setIsSubmitting(false); var status = response.status; setNotificationVisible(true); if (status == "200") { @@ -145,6 +147,10 @@ function PathologyCaseView() { }); const save = (e) => { + if (isSubmitting) { + return; + } + setIsSubmitting(true); let submitValues = { assignedTechnicianId: pathologySampleInfo.assignedTechnicianId, assignedPathologistId: pathologySampleInfo.assignedPathologistId, @@ -375,6 +381,7 @@ function PathologyCaseView() { { e.preventDefault(); save(e); @@ -1267,6 +1274,7 @@ function PathologyCaseView() { { e.preventDefault(); save(e); diff --git a/frontend/src/components/patient/CreatePatientForm.js b/frontend/src/components/patient/CreatePatientForm.js index c7280ab03e..f9de1bd7ca 100644 --- a/frontend/src/components/patient/CreatePatientForm.js +++ b/frontend/src/components/patient/CreatePatientForm.js @@ -1,11 +1,7 @@ import React, { useState, useRef, useEffect, useContext } from "react"; import { FormattedMessage, injectIntl, useIntl } from "react-intl"; import "../Style.css"; -import { - getFromOpenElisServer, - getFromOpenElisServerSync, - postToOpenElisServer, -} from "../utils/Utils"; +import { getFromOpenElisServer, postToOpenElisServer } from "../utils/Utils"; import { nationalityList } from "../data/countries"; import format from "date-fns/format"; import { @@ -66,6 +62,9 @@ function CreatePatientForm(props) { const [subjectNo, setSubjectNo] = useState( props.selectedPatient.subjectNumber, ); + + const [isSubmitting, setIsSubmitting] = useState(false); + const handleNationalIdChange = (event) => { const newValue = event.target.value; setNationalId(newValue); @@ -144,8 +143,16 @@ function CreatePatientForm(props) { }; function handleYearsChange(e, values) { - setPatientDetails(values); - let years = e.target.value; + // Ensure years is not negative + const years = Math.max(0, Number(e.target.value)); + + // Update form values with the validated years + setPatientDetails({ + ...values, + // Update the specific field that contains years to ensure the form shows the corrected value + [e.target.name]: years, + }); + let dobFormatter = { ...dateOfBirthFormatter, years: years, @@ -154,8 +161,16 @@ function CreatePatientForm(props) { } function handleMonthsChange(e, values) { - setPatientDetails(values); - let months = e.target.value; + // Ensure months is not negative + const months = Math.max(0, Number(e.target.value)); + + // Update form values with the validated months + setPatientDetails({ + ...values, + // Update the specific field that contains months to ensure the form shows the corrected value + [e.target.name]: months, + }); + let dobFormatter = { ...dateOfBirthFormatter, months: months, @@ -164,8 +179,16 @@ function CreatePatientForm(props) { } function handleDaysChange(e, values) { - setPatientDetails(values); - let days = e.target.value; + // Ensure days is not negative + const days = Math.max(0, Number(e.target.value)); + + // Update form values with the validated days + setPatientDetails({ + ...values, + // Update the specific field that contains days to ensure the form shows the corrected value + [e.target.name]: days, + }); + let dobFormatter = { ...dateOfBirthFormatter, days: days, @@ -308,6 +331,13 @@ function CreatePatientForm(props) { }; const handleSubmit = async (values, { resetForm }) => { + // Prevent multiple submissions. + if (isSubmitting) { + return; + } + + setIsSubmitting(true); + if ("years" in values) { delete values.years; } @@ -335,6 +365,7 @@ function CreatePatientForm(props) { const handlePost = (status) => { setNotificationVisible(true); + setIsSubmitting(false); if (status === 200) { addNotification({ title: intl.formatMessage({ id: "notification.title" }), @@ -618,6 +649,7 @@ function CreatePatientForm(props) { })} id="years" type="number" + min="0" onChange={(e) => handleYearsChange(e, values)} placeholder={intl.formatMessage({ id: "patient.information.age", @@ -630,6 +662,7 @@ function CreatePatientForm(props) { name="months" labelText={intl.formatMessage({ id: "patient.age.months" })} type="number" + min="0" onChange={(e) => handleMonthsChange(e, values)} id="months" placeholder={intl.formatMessage({ @@ -642,6 +675,7 @@ function CreatePatientForm(props) { value={dateOfBirthFormatter.days} name="days" type="number" + min="0" onChange={(e) => handleDaysChange(e, values)} labelText={intl.formatMessage({ id: "patient.age.days" })} id="days" @@ -1007,7 +1041,7 @@ function CreatePatientForm(props) { {props.showActionsButton && ( <> - + @@ -1015,6 +1049,7 @@ function CreatePatientForm(props) { { resetForm({ values: CreatePatientFormValues }); setHealthDistricts([]); diff --git a/frontend/src/components/reports/common/ReportByDate.js b/frontend/src/components/reports/common/ReportByDate.js index 2c089446a2..0cd3c81d2d 100644 --- a/frontend/src/components/reports/common/ReportByDate.js +++ b/frontend/src/components/reports/common/ReportByDate.js @@ -15,7 +15,7 @@ import "../../Style.css"; import { AlertDialog } from "../../common/CustomNotification"; import CustomDatePicker from "../../common/CustomDatePicker"; import config from "../../../config.json"; -import { encodeDate } from "../../utils/Utils"; +import { encodeDate, Roles } from "../../utils/Utils"; import { getFromOpenElisServer } from "../../utils/Utils"; const ReportByDate = (props) => { const intl = useIntl(); @@ -122,7 +122,10 @@ const ReportByDate = (props) => { getFromOpenElisServer("/rest/panels", setTempData); break; case "activityReportByTestSection": - getFromOpenElisServer("/rest/test-sections", setTempData); + getFromOpenElisServer( + "/rest/user-test-sections/" + Roles.REPORTS, + setTempData, + ); break; default: break; diff --git a/frontend/src/components/reports/routine/ActivityReport.js b/frontend/src/components/reports/routine/ActivityReport.js deleted file mode 100644 index ee0c9cd9c1..0000000000 --- a/frontend/src/components/reports/routine/ActivityReport.js +++ /dev/null @@ -1,214 +0,0 @@ -import React, { useEffect, useState, useRef } from "react"; -import { FormattedMessage, useIntl } from "react-intl"; -import { - Form, - FormLabel, - Grid, - Column, - Section, - Button, - Loading, - Select, - SelectItem, - Row, -} from "@carbon/react"; -import CustomDatePicker from "../../common/CustomDatePicker"; -import { AlertDialog } from "../../common/CustomNotification"; -import TestSelectForm from "../../workplan/TestSelectForm"; -import TestSectionSelectForm from "../../workplan/TestSectionSelectForm"; -import PanelSelectForm from "../../workplan/PanelSelectForm"; -import "../../Style.css"; -import { getFromOpenElisServer } from "../../utils/Utils"; -import { encodeDate } from "../../utils/Utils"; -import config from "../../../config.json"; - -const ActivityReport = ({ report }) => { - const intl = useIntl(); - const [loading, setLoading] = useState(true); - const [notificationVisible, setNotificationVisible] = useState(false); - const [reportFormValues, setReportFormValues] = useState({ - startDate: null, - endDate: null, - value: null, - error: null, - }); - const [list, setList] = useState([]); - - const handleDatePickerChangeDate = (datePicker, date) => { - let updatedDate = encodeDate(date); - let obj = null; - switch (datePicker) { - case "startDate": - obj = { - ...reportFormValues, - startDate: updatedDate, - }; - break; - case "endDate": - obj = { - ...reportFormValues, - endDate: updatedDate, - }; - break; - default: - } - setReportFormValues(obj); - }; - - const handleSubmit = () => { - setLoading(true); - let reportType = ""; - let additionalParams = ""; - switch (selectedReportType) { - case "byTest": - reportType = "activityReportByTest"; - additionalParams = "report=activityReportByTest"; - break; - case "byPanel": - reportType = "activityReportByPanel"; - additionalParams = "report=activityReportByPanel"; - break; - case "byUnit": - reportType = "activityReportByTestSection"; - additionalParams = "report=activityReportByTestSection"; - break; - default: - break; - } - const baseParams = `${additionalParams}&type=indicator&report=${reportType}`; - const baseUrl = `${config.serverBaseUrl}/ReportPrint`; - const url = `${baseUrl}?${baseParams}&lowerDateRange=${reportFormValues.startDate}&upperDateRange=${reportFormValues.endDate}`; - window.open(url, "_blank"); - setLoading(false); - setNotificationVisible(true); - }; - - const setDataList = (data) => { - setList(data); - console.log("data: ", data); - setLoading(false); - }; - - useEffect(() => { - switch (report) { - case "activityReportByTest": - getFromOpenElisServer("/rest/test-list", setDataList); - console.log("list: ", list); - break; - case "activityReportByPanel": - getFromOpenElisServer("/rest/panels", setDataList); - break; - case "activityReportByTestSection": - getFromOpenElisServer("/rest/test-sections", setDataList); - break; - default: - break; - } - }, [report]); - - return ( - <> - - - - - - - - - - {notificationVisible && } - {loading && } - - - - - - - - - - - - - - handleDatePickerChangeDate("startDate", date) - } - /> - - handleDatePickerChangeDate("endDate", date) - } - /> - - - hihih - - - {list && list.length > 0 && ( - { - setReportFormValues({ - ...reportFormValues, - value: e.target.value, - }); - }} - > - - {list.map((statusOption) => ( - - ))} - - )} - - - - - - - - handleSubmit("activityReportByTest", "RoutineReport") - } - > - - - - - - - > - ); -}; - -export default ActivityReport; diff --git a/frontend/src/components/resultPage/SearchResultForm.js b/frontend/src/components/resultPage/SearchResultForm.js index 55db921aa6..455541136c 100644 --- a/frontend/src/components/resultPage/SearchResultForm.js +++ b/frontend/src/components/resultPage/SearchResultForm.js @@ -779,6 +779,7 @@ export function SearchResults(props) { const [validationState, setValidationState] = useState({}); const saveStatus = ""; const [referTest, setReferTest] = useState({}); + const [isSubmitting, setIsSubmitting] = useState(false); const componentMounted = useRef(false); @@ -1542,6 +1543,10 @@ export function SearchResults(props) { const handleSave = (values) => { console.debug("handleSave:" + values); + if (isSubmitting) { + return; + } + setIsSubmitting(true); values.status = saveStatus; var searchEndPoint = "/rest/ReactLogbookResultsUpdate"; props.results.testResult.forEach((result) => { @@ -1557,6 +1562,7 @@ export function SearchResults(props) { const setResponse = (resp) => { console.debug("setStatus" + JSON.stringify(resp)); + setIsSubmitting(false); if (resp) { addNotification({ title: intl.formatMessage({ id: "notification.title" }), @@ -1707,6 +1713,7 @@ export function SearchResults(props) { id="submit" onClick={handleSave} style={{ marginTop: "16px" }} + disabled={isSubmitting} > diff --git a/frontend/src/components/validation/Validation.js b/frontend/src/components/validation/Validation.js index cd7526fbb6..eb1190b237 100644 --- a/frontend/src/components/validation/Validation.js +++ b/frontend/src/components/validation/Validation.js @@ -35,6 +35,7 @@ const Validation = (props) => { const [page, setPage] = useState(1); const [pageSize, setPageSize] = useState(100); + const [isSubmitting, setIsSubmitting] = useState(false); useEffect(() => { componentMounted.current = true; @@ -114,6 +115,10 @@ const Validation = (props) => { ]; const handleSave = (values) => { + if (isSubmitting) { + return; + } + setIsSubmitting(true); postToOpenElisServer( "/rest/accessionValidationByRangeUpdate", JSON.stringify(props.results), @@ -123,6 +128,7 @@ const Validation = (props) => { const handleResponse = (status) => { let message = intl.formatMessage({ id: "validation.save.error" }); let kind = NotificationKinds.error; + setIsSubmitting(false); if (status == 200) { message = intl.formatMessage({ id: "validation.save.success" }); kind = NotificationKinds.success; @@ -464,6 +470,7 @@ const Validation = (props) => { onClick={() => handleSave(values)} id="submit" style={{ marginTop: "16px" }} + disabled={isSubmitting} > diff --git a/frontend/src/index.css b/frontend/src/index.css index 5aa3ee2f3b..3d6c7d3bef 100644 --- a/frontend/src/index.css +++ b/frontend/src/index.css @@ -71,7 +71,7 @@ code { .slide-over-panel { width: 25%; /* Use percentage for width on larger screens */ - /* max-width: 25%;*/ + /* max-width: 25%;*/ max-width: 50%; /* Use percentage for max-width on larger screens */ } diff --git a/pom.xml b/pom.xml index 03ab4c4f92..9f1628c75e 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,7 @@ 1 0 - 0 + 1 UTF-8 ${project.basedir}/liquibase/liquibase.properties 1.4.1 diff --git a/src/main/java/org/openelisglobal/common/controller/BaseController.java b/src/main/java/org/openelisglobal/common/controller/BaseController.java index 5c36541ba9..dfd7fc469f 100644 --- a/src/main/java/org/openelisglobal/common/controller/BaseController.java +++ b/src/main/java/org/openelisglobal/common/controller/BaseController.java @@ -13,10 +13,10 @@ import org.openelisglobal.common.form.BaseForm; import org.openelisglobal.common.log.LogEvent; import org.openelisglobal.common.util.ConfigurationProperties; +import org.openelisglobal.common.util.ControllerUtills; import org.openelisglobal.common.util.StringUtil; import org.openelisglobal.internationalization.MessageUtil; import org.openelisglobal.login.dao.UserModuleService; -import org.openelisglobal.login.valueholder.UserSessionData; import org.openelisglobal.view.PageBuilderService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -28,7 +28,7 @@ import org.springframework.web.servlet.support.RequestContextUtils; @Component -public abstract class BaseController implements IActionConstants { +public abstract class BaseController extends ControllerUtills implements IActionConstants { // Request being autowired appears to be threadsafe because of how Spring // handles autowiring, despite all controllers being singletons @@ -183,17 +183,6 @@ protected void setPageTitles(HttpServletRequest request, BaseForm form) { } } - protected String getSysUserId(HttpServletRequest request) { - UserSessionData usd = (UserSessionData) request.getSession().getAttribute(USER_SESSION_DATA); - if (usd == null) { - usd = (UserSessionData) request.getAttribute(USER_SESSION_DATA); - if (usd == null) { - return null; - } - } - return String.valueOf(usd.getSystemUserId()); - } - protected void setSuccessFlag(HttpServletRequest request, boolean success) { request.setAttribute(FWD_SUCCESS, success); } diff --git a/src/main/java/org/openelisglobal/common/rest/BaseRestController.java b/src/main/java/org/openelisglobal/common/rest/BaseRestController.java index 1309d9a5f1..2067d42e8e 100644 --- a/src/main/java/org/openelisglobal/common/rest/BaseRestController.java +++ b/src/main/java/org/openelisglobal/common/rest/BaseRestController.java @@ -1,21 +1,10 @@ package org.openelisglobal.common.rest; -import javax.servlet.http.HttpServletRequest; import org.openelisglobal.common.action.IActionConstants; -import org.openelisglobal.login.valueholder.UserSessionData; +import org.openelisglobal.common.util.ControllerUtills; import org.springframework.stereotype.Component; @Component -public class BaseRestController implements IActionConstants { +public class BaseRestController extends ControllerUtills implements IActionConstants { - protected String getSysUserId(HttpServletRequest request) { - UserSessionData usd = (UserSessionData) request.getSession().getAttribute(USER_SESSION_DATA); - if (usd == null) { - usd = (UserSessionData) request.getAttribute(USER_SESSION_DATA); - if (usd == null) { - return null; - } - } - return String.valueOf(usd.getSystemUserId()); - } -} +} \ No newline at end of file diff --git a/src/main/java/org/openelisglobal/common/util/ControllerUtills.java b/src/main/java/org/openelisglobal/common/util/ControllerUtills.java new file mode 100644 index 0000000000..1d10cb279a --- /dev/null +++ b/src/main/java/org/openelisglobal/common/util/ControllerUtills.java @@ -0,0 +1,19 @@ +package org.openelisglobal.common.util; + +import javax.servlet.http.HttpServletRequest; +import org.openelisglobal.common.action.IActionConstants; +import org.openelisglobal.login.valueholder.UserSessionData; + +public class ControllerUtills { + + protected String getSysUserId(HttpServletRequest request) { + UserSessionData usd = (UserSessionData) request.getSession().getAttribute(IActionConstants.USER_SESSION_DATA); + if (usd == null) { + usd = (UserSessionData) request.getAttribute(IActionConstants.USER_SESSION_DATA); + if (usd == null) { + return null; + } + } + return String.valueOf(usd.getSystemUserId()); + } +} diff --git a/src/main/java/org/openelisglobal/notifications/rest/NotificationRestController.java b/src/main/java/org/openelisglobal/notifications/rest/NotificationRestController.java index 2c8da886ef..01c1fef210 100644 --- a/src/main/java/org/openelisglobal/notifications/rest/NotificationRestController.java +++ b/src/main/java/org/openelisglobal/notifications/rest/NotificationRestController.java @@ -10,7 +10,7 @@ import nl.martijndwars.webpush.PushService; import org.apache.http.HttpResponse; import org.bouncycastle.jce.provider.BouncyCastleProvider; -import org.openelisglobal.login.valueholder.UserSessionData; +import org.openelisglobal.common.rest.BaseRestController; import org.openelisglobal.notifications.dao.NotificationDAO; import org.openelisglobal.notifications.dao.NotificationSubscriptionDAO; import org.openelisglobal.notifications.entity.Notification; @@ -31,12 +31,11 @@ @RequestMapping("/rest") @RestController -public class NotificationRestController { +public class NotificationRestController extends BaseRestController { private final NotificationDAO notificationDAO; private final SystemUserService systemUserService; private final NotificationSubscriptionDAO notificationSubscriptionDAO; - private static final String USER_SESSION_DATA = "userSessionData"; @Autowired private ConfigurableEnvironment env; @@ -210,15 +209,4 @@ public ResponseEntity> unsubscribe(HttpServletRequest request) { return ResponseEntity.ok().body("Unsubscribed successfully"); } - - protected String getSysUserId(HttpServletRequest request) { - UserSessionData usd = (UserSessionData) request.getSession().getAttribute(USER_SESSION_DATA); - if (usd == null) { - usd = (UserSessionData) request.getAttribute(USER_SESSION_DATA); - if (usd == null) { - return null; - } - } - return String.valueOf(usd.getSystemUserId()); - } } diff --git a/src/main/java/org/openelisglobal/qaevent/controller/rest/NonConformingEventsCorrectionActionRestController.java b/src/main/java/org/openelisglobal/qaevent/controller/rest/NonConformingEventsCorrectionActionRestController.java index b511a058e7..3767316fc9 100644 --- a/src/main/java/org/openelisglobal/qaevent/controller/rest/NonConformingEventsCorrectionActionRestController.java +++ b/src/main/java/org/openelisglobal/qaevent/controller/rest/NonConformingEventsCorrectionActionRestController.java @@ -7,8 +7,8 @@ import java.util.Map; import javax.servlet.http.HttpServletRequest; import org.apache.commons.validator.GenericValidator; +import org.openelisglobal.common.rest.BaseRestController; import org.openelisglobal.common.services.DisplayListService; -import org.openelisglobal.login.valueholder.UserSessionData; import org.openelisglobal.patient.action.bean.PatientSearch; import org.openelisglobal.qaevent.form.NonConformingEventForm; import org.openelisglobal.qaevent.service.NCEventService; @@ -26,12 +26,10 @@ @RestController @RequestMapping(value = "/rest") -public class NonConformingEventsCorrectionActionRestController { +public class NonConformingEventsCorrectionActionRestController extends BaseRestController { private NCEventService ncEventService = SpringContext.getBean(NCEventService.class); - private static final String USER_SESSION_DATA = "userSessionData"; - @Autowired private NonConformingEventWorker nonConformingEventWorker; @@ -90,15 +88,4 @@ public ResponseEntity> updateNCECorretiveActionForm(@RequestBody NonConforming return ResponseEntity.ok().body(Map.of("success", false)); } } - - protected String getSysUserId(HttpServletRequest request) { - UserSessionData usd = (UserSessionData) request.getSession().getAttribute(USER_SESSION_DATA); - if (usd == null) { - usd = (UserSessionData) request.getAttribute(USER_SESSION_DATA); - if (usd == null) { - return null; - } - } - return String.valueOf(usd.getSystemUserId()); - } } diff --git a/src/main/java/org/openelisglobal/qaevent/controller/rest/ReportNonConformEventsRestController.java b/src/main/java/org/openelisglobal/qaevent/controller/rest/ReportNonConformEventsRestController.java index 15152f6697..6fd6e4e798 100644 --- a/src/main/java/org/openelisglobal/qaevent/controller/rest/ReportNonConformEventsRestController.java +++ b/src/main/java/org/openelisglobal/qaevent/controller/rest/ReportNonConformEventsRestController.java @@ -5,12 +5,12 @@ import javax.servlet.http.HttpServletRequest; import org.openelisglobal.common.exception.LIMSInvalidConfigurationException; import org.openelisglobal.common.provider.query.PatientSearchResults; +import org.openelisglobal.common.rest.BaseRestController; import org.openelisglobal.common.rest.bean.NceSampleInfo; import org.openelisglobal.common.rest.bean.NceSampleItemInfo; import org.openelisglobal.common.services.DisplayListService; import org.openelisglobal.common.services.RequesterService; import org.openelisglobal.common.util.DateUtil; -import org.openelisglobal.login.valueholder.UserSessionData; import org.openelisglobal.qaevent.form.NonConformingEventForm; import org.openelisglobal.qaevent.service.NceCategoryService; import org.openelisglobal.qaevent.valueholder.NcEvent; @@ -33,7 +33,7 @@ import org.springframework.web.bind.annotation.RestController; @RestController -public class ReportNonConformEventsRestController { +public class ReportNonConformEventsRestController extends BaseRestController { private final SampleService sampleService; private final SampleItemService sampleItemService; @@ -42,8 +42,6 @@ public class ReportNonConformEventsRestController { private final NceCategoryService nceCategoryService; private final RequesterService requesterService; - private static final String USER_SESSION_DATA = "userSessionData"; - @Autowired private SystemUserService systemUserService; @@ -175,17 +173,6 @@ private NceSampleInfo addSample(Sample sample) { return sampleInfo; } - protected String getSysUserId(HttpServletRequest request) { - UserSessionData usd = (UserSessionData) request.getSession().getAttribute(USER_SESSION_DATA); - if (usd == null) { - usd = (UserSessionData) request.getAttribute(USER_SESSION_DATA); - if (usd == null) { - return null; - } - } - return String.valueOf(usd.getSystemUserId()); - } - private Sample getSampleForLabNumber(String labNumber) throws LIMSInvalidConfigurationException { return sampleService.getSampleByAccessionNumber(labNumber); } diff --git a/src/main/java/org/openelisglobal/qaevent/controller/rest/ViewNonConformEventsRestController.java b/src/main/java/org/openelisglobal/qaevent/controller/rest/ViewNonConformEventsRestController.java index abfd7bcb32..4f8f1ef3c2 100644 --- a/src/main/java/org/openelisglobal/qaevent/controller/rest/ViewNonConformEventsRestController.java +++ b/src/main/java/org/openelisglobal/qaevent/controller/rest/ViewNonConformEventsRestController.java @@ -5,9 +5,9 @@ import java.util.List; import java.util.Map; import javax.servlet.http.HttpServletRequest; +import org.openelisglobal.common.rest.BaseRestController; import org.openelisglobal.common.services.DisplayListService; import org.openelisglobal.common.util.DateUtil; -import org.openelisglobal.login.valueholder.UserSessionData; import org.openelisglobal.qaevent.form.NonConformingEventForm; import org.openelisglobal.qaevent.service.NCEventService; import org.openelisglobal.qaevent.service.NceCategoryService; @@ -29,7 +29,7 @@ import org.springframework.web.bind.annotation.RestController; @RestController -public class ViewNonConformEventsRestController { +public class ViewNonConformEventsRestController extends BaseRestController { @Autowired private NCEventService ncEventService; @@ -46,8 +46,6 @@ public class ViewNonConformEventsRestController { @Autowired private SampleItemService sampleItemService; - private static final String USER_SESSION_DATA = "userSessionData"; - private final NonConformingEventWorker nonConformingEventWorker; public ViewNonConformEventsRestController(NonConformingEventWorker nonConformingEventWorker) { @@ -120,15 +118,4 @@ public ResponseEntity> postReportNonConformingEvent(@RequestBody NonConforming .body("An error occurred while processing the request." + e); } } - - protected String getSysUserId(HttpServletRequest request) { - UserSessionData usd = (UserSessionData) request.getSession().getAttribute(USER_SESSION_DATA); - if (usd == null) { - usd = (UserSessionData) request.getAttribute(USER_SESSION_DATA); - if (usd == null) { - return null; - } - } - return String.valueOf(usd.getSystemUserId()); - } } diff --git a/src/main/java/org/openelisglobal/reports/action/implementation/reportBeans/CIRoutineColumnBuilder.java b/src/main/java/org/openelisglobal/reports/action/implementation/reportBeans/CIRoutineColumnBuilder.java index 2368849832..1867938a4b 100644 --- a/src/main/java/org/openelisglobal/reports/action/implementation/reportBeans/CIRoutineColumnBuilder.java +++ b/src/main/java/org/openelisglobal/reports/action/implementation/reportBeans/CIRoutineColumnBuilder.java @@ -120,6 +120,7 @@ protected void appendOtherDiseaseCrosstab(Date lowDate, Date highDate, SQLConsta protected void defineBasicColumns() { add("accession_number", "LABNO", NONE); + add("lab_unit", "LAB_UNIT", NONE); add("national_id", "IDENTIFIER", NONE); add("gender", "SEX", NONE); add("birth_date", "BIRTHDATE", DATE); diff --git a/src/main/java/org/openelisglobal/reports/action/implementation/reportBeans/CSVRoutineColumnBuilder.java b/src/main/java/org/openelisglobal/reports/action/implementation/reportBeans/CSVRoutineColumnBuilder.java index fa26b99612..a4884985ea 100644 --- a/src/main/java/org/openelisglobal/reports/action/implementation/reportBeans/CSVRoutineColumnBuilder.java +++ b/src/main/java/org/openelisglobal/reports/action/implementation/reportBeans/CSVRoutineColumnBuilder.java @@ -539,6 +539,7 @@ protected void appendResultCrosstab(java.sql.Date lowDate, java.sql.Date highDat + " join clinlims.sample AS s on s.id = si.samp_id \n" + " join clinlims.test_result AS tr on r.test_result_id = tr.id \n" + " join clinlims.test AS t on tr.test_id = t.id \n" + + " join clinlims.test_section ts on t.test_section_id = ts.id \n" + " left join sample_projects sp on si.samp_id = sp.samp_id \n" + "\n" + " WHERE sp.id IS NULL AND s.entered_date >= date(''" + formatDateForDatabaseSql(lowDate) + "'') AND s.entered_date <= date(''" + formatDateForDatabaseSql(highDate) + " '') " + "\n " @@ -631,7 +632,11 @@ protected void appendObservationHistoryCrosstab(java.sql.Date lowDate, java.sql. } protected void appendCrosstabPreamble(SQLConstant listName) { - query.append(", \n\n ( SELECT s.id AS samp_id, " + listName + ".* " + " FROM sample AS s LEFT JOIN \n "); + query.append(", \n\n ( SELECT s.id AS samp_id, " + " (SELECT ts.name FROM clinlims.test_section ts " + + " JOIN clinlims.test t ON t.test_section_id = ts.id " + + " JOIN clinlims.analysis a ON a.test_id = t.id " + + " WHERE a.sampitem_id = si.id LIMIT 1) as lab_unit, " + listName + ".* " + " FROM sample AS s " + + " LEFT JOIN sample_item si ON s.id = si.samp_id " + " LEFT JOIN \n "); } protected void appendCrosstabPostfix(java.sql.Date lowDate, java.sql.Date highDate, SQLConstant listName) { diff --git a/src/main/java/org/openelisglobal/sample/service/PatientManagementUpdate.java b/src/main/java/org/openelisglobal/sample/service/PatientManagementUpdate.java index ec39ca9e27..860cc34c8f 100644 --- a/src/main/java/org/openelisglobal/sample/service/PatientManagementUpdate.java +++ b/src/main/java/org/openelisglobal/sample/service/PatientManagementUpdate.java @@ -16,6 +16,7 @@ import org.openelisglobal.common.action.IActionConstants; import org.openelisglobal.common.exception.LIMSRuntimeException; import org.openelisglobal.common.log.LogEvent; +import org.openelisglobal.common.util.ControllerUtills; import org.openelisglobal.common.validator.BaseErrors; import org.openelisglobal.login.valueholder.UserSessionData; import org.openelisglobal.patient.action.IPatientUpdate; @@ -39,7 +40,7 @@ @Service @Scope("prototype") -public class PatientManagementUpdate implements IPatientUpdate { +public class PatientManagementUpdate extends ControllerUtills implements IPatientUpdate { private String currentUserId; protected Patient patient; @@ -78,11 +79,6 @@ public void initializeGlobalVariables() { } } - protected String getSysUserId(HttpServletRequest request) { - UserSessionData usd = (UserSessionData) request.getSession().getAttribute(IActionConstants.USER_SESSION_DATA); - return String.valueOf(usd.getSystemUserId()); - } - public void setSysUserIdFromRequest(HttpServletRequest request) { UserSessionData usd = (UserSessionData) request.getSession().getAttribute(IActionConstants.USER_SESSION_DATA); currentUserId = String.valueOf(usd.getSystemUserId());