From b9a5981932b357456504b224aea73446e19835e7 Mon Sep 17 00:00:00 2001 From: pascagihozo Date: Thu, 22 Aug 2024 14:11:04 +0400 Subject: [PATCH 1/9] select lab-translation --- frontend/src/languages/en.json | 1 + frontend/src/languages/fr.json | 1 + 2 files changed, 2 insertions(+) diff --git a/frontend/src/languages/en.json b/frontend/src/languages/en.json index a36765f8f..2a1c89e0a 100644 --- a/frontend/src/languages/en.json +++ b/frontend/src/languages/en.json @@ -194,6 +194,7 @@ "header.label.version": "Version:", "header.label.logout": "Logout", "header.label.selectlocale": "Select Locale", + "header.label.changeLab": "Select Lab", "banner.menu.home": "Home", "banner.menu.help": "Help", "banner.menu.reports": "Reports", diff --git a/frontend/src/languages/fr.json b/frontend/src/languages/fr.json index f15957610..d0abc4093 100644 --- a/frontend/src/languages/fr.json +++ b/frontend/src/languages/fr.json @@ -204,6 +204,7 @@ "header.label.version": "Version:", "header.label.logout": "Déconnexion", "header.label.selectlocale": "Sélectionner la Langue", + "header.label.selectLab": "Sélectionner la Lab", "header.label.ARV": "ARV-initial", "header.label.followup": "ARV-suivi", "header.label.intialFollowup": "ARV -->Suivi initial-VL", From 4f18a87c086060236d5470589a02422a5c4e35ca Mon Sep 17 00:00:00 2001 From: pascagihozo Date: Thu, 22 Aug 2024 17:27:59 +0400 Subject: [PATCH 2/9] pathology-conclusions-dropdown --- .../ImmunohistochemistryCaseView.js | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/frontend/src/components/immunohistochemistry/ImmunohistochemistryCaseView.js b/frontend/src/components/immunohistochemistry/ImmunohistochemistryCaseView.js index 68c0f8eb0..5241dd331 100644 --- a/frontend/src/components/immunohistochemistry/ImmunohistochemistryCaseView.js +++ b/frontend/src/components/immunohistochemistry/ImmunohistochemistryCaseView.js @@ -19,6 +19,7 @@ import { InlineLoading, Toggle, TextArea, + FilterableMultiSelect, } from "@carbon/react"; import { Launch, Subtract } from "@carbon/react/icons"; import { @@ -57,6 +58,10 @@ function ImmunohistochemistryCaseView() { const { userSessionDetails } = useContext(UserSessionDetailsContext); const [immunohistochemistrySampleInfo, setImmunohistochemistrySampleInfo] = useState({ labNumber: "" }); + + const [pathologySampleInfo, setPathologySampleInfo] = useState({}); + const [conclusions, setConclusions] = useState([]); + const [statuses, setStatuses] = useState([]); const [reportTypes, setReportTypes] = useState([]); const [technicianUsers, setTechnicianUsers] = useState([]); @@ -174,6 +179,20 @@ function ImmunohistochemistryCaseView() { params[index]["toggled"] = e; setReportParams(params); }; + + useEffect(() => { + componentMounted.current = true; + + getFromOpenElisServer( + "/rest/displayList/PATHOLOGIST_CONCLUSIONS", + setConclusions, + ); + + return () => { + componentMounted.current = false; + }; + }, []); + const createReportParams = (reportType, index) => { switch (reportType) { case "BREAST_CANCER_HORMONE_RECEPTOR": @@ -650,6 +669,46 @@ function ImmunohistochemistryCaseView() { <> + + + + + } + items={conclusions} + itemToString={(item) => (item ? item.value : "")} + initialSelectedItems={pathologySampleInfo.conclusions} + onChange={(changes) => { + setPathologySampleInfo({ + ...pathologySampleInfo, + conclusions: changes.selectedItems, + }); + }} + selectionFeedback="top-after-reopen" + /> + + + {pathologySampleInfo.conclusions && + pathologySampleInfo.conclusions.map( + (conclusion, index) => ( + { + var info = { ...pathologySampleInfo }; + info["conclusions"].splice(index, 1); + setPathologySampleInfo(info); + }} + > + {conclusion.value} + + ), + )} + + + From a718db7e4804efcb980d9be88326805e465f57df Mon Sep 17 00:00:00 2001 From: pascagihozo Date: Thu, 22 Aug 2024 17:38:37 +0400 Subject: [PATCH 3/9] new landingpage to allow user to select lab at landingpage --- frontend/src/App.js | 28 +++- frontend/src/components/home/LandingPage.tsx | 164 +++++++++++++++++++ frontend/src/components/layout/Header.js | 2 +- 3 files changed, 190 insertions(+), 4 deletions(-) create mode 100644 frontend/src/components/home/LandingPage.tsx diff --git a/frontend/src/App.js b/frontend/src/App.js index eff531cd8..ea9ce740a 100644 --- a/frontend/src/App.js +++ b/frontend/src/App.js @@ -1,10 +1,16 @@ import React, { useState, useEffect } from "react"; -import { BrowserRouter as Router, Route, Switch } from "react-router-dom"; -import { confirmAlert } from "react-confirm-alert"; +import { + BrowserRouter as Router, + Route, + Switch, + Redirect, +} from "react-router-dom"; import { IntlProvider } from "react-intl"; import Layout from "./components/layout/Layout"; import Home from "./components/Home"; import Login from "./components/Login"; +import LandingPage from "./components/home/LandingPage"; +import HomeDashBoard from "./components/home/Dashboard"; import { Admin } from "./components"; import ResultSearch from "./components/resultPage/ResultSearch"; import UserSessionDetailsContext from "./UserSessionDetailsContext"; @@ -88,6 +94,7 @@ export default function App() { ); } } catch (error) { + console.log(er); console.error(error); if (counter === 10) { const options = { @@ -209,10 +216,25 @@ export default function App() { } /> + } + /> + } + /> } + component={() => { + if (!userSessionDetails.unitSelected) { + return ; + } + return ; + }} role="" /> { + const intl = useIntl(); + const [departments, setDepartments] = useState([]); + const [filteredDepartments, setFilteredDepartments] = useState([]); + const [selectedDepartment, setSelectedDepartment] = useState(""); + const [selectedLabUnits, setSelectedLabUnits] = useState([]); + const [rememberChoice, setRememberChoice] = useState(false); + const [searchTerm, setSearchTerm] = useState(""); + + useEffect(() => { + getFromOpenElisServer("/rest/user-test-sections", (response) => { + setDepartments(response); + setFilteredDepartments(response); + }); + }, []); + + const handleSearch = (event) => { + const term = event.target.value.toLowerCase(); + setSearchTerm(term); + setFilteredDepartments( + departments.filter((dept) => + dept.value.toLowerCase().includes(term) + ) + ); + }; + + const handleDepartmentSelect = (departmentId) => { + setSelectedDepartment(departmentId); + setSelectedLabUnits([]); + }; + + + const handleContinue = () => { + if (rememberChoice) { + if (selectedDepartment) { + localStorage.setItem("selectedDepartment", selectedDepartment); + } else if (selectedLabUnits.length > 0) { + localStorage.setItem( + "selectedLabUnits", + JSON.stringify(selectedLabUnits) + ); + } + } + window.location.href = "/dashboard"; + }; + + return ( + + + +

Welcome!

+

Please select a unit to continue

+
+ +
+ {filteredDepartments.map((dept) => ( +
handleDepartmentSelect(dept.id)} + > + {dept.value} +
+ ))} +
+ setRememberChoice(e.target.checked)} + /> + + +
+
+
+ ); +}; + +export default LandingPage; diff --git a/frontend/src/components/layout/Header.js b/frontend/src/components/layout/Header.js index f4e080bb1..0a0bdbc01 100644 --- a/frontend/src/components/layout/Header.js +++ b/frontend/src/components/layout/Header.js @@ -434,7 +434,7 @@ function OEHeader(props) { isCollapsible={true} /> )} - +
{configurationProperties?.BANNER_TEXT}
From 4e00b36b57c190473323d676c0ff91f4e41ec9a1 Mon Sep 17 00:00:00 2001 From: mozzy11 Date: Mon, 26 Aug 2024 23:02:13 +0300 Subject: [PATCH 4/9] Fix landing page --- frontend/src/App.js | 20 +---- frontend/src/components/home/Dashboard.tsx | 9 ++- frontend/src/components/home/LandingPage.tsx | 80 +++++++++++++------ frontend/src/components/layout/Header.js | 12 ++- .../reports/routine/StatisticsReport.js | 11 ++- .../components/resultPage/SearchResultForm.js | 22 ++--- .../resultsReferredOut/ReferredOutTests.js | 21 ++--- .../src/components/security/SecureRoute.js | 9 +++ frontend/src/components/utils/Utils.js | 11 +++ .../src/components/validation/SearchForm.js | 4 +- .../workplan/TestSectionSelectForm.js | 29 ++++--- frontend/src/languages/en.json | 2 +- frontend/src/languages/fr.json | 2 +- .../common/rest/DisplayListController.java | 19 ++++- .../common/util/ConfigurationProperties.java | 3 +- .../util/DefaultConfigurationProperties.java | 2 + .../login/bean/UserSession.java | 9 +++ .../login/controller/LoginPageController.java | 30 +++++++ .../login/valueholder/UserSessionData.java | 9 +++ .../systemuser/service/UserService.java | 2 + .../systemuser/service/UserServiceImpl.java | 61 +++++++++++++- src/main/resources/liquibase/2.8.x.x/base.xml | 2 +- .../liquibase/2.8.x.x/landing_page_config.xml | 26 ++++++ 23 files changed, 300 insertions(+), 95 deletions(-) create mode 100644 src/main/resources/liquibase/2.8.x.x/landing_page_config.xml diff --git a/frontend/src/App.js b/frontend/src/App.js index ea9ce740a..31a10d845 100644 --- a/frontend/src/App.js +++ b/frontend/src/App.js @@ -1,16 +1,10 @@ import React, { useState, useEffect } from "react"; -import { - BrowserRouter as Router, - Route, - Switch, - Redirect, -} from "react-router-dom"; +import { BrowserRouter as Router, Route, Switch } from "react-router-dom"; import { IntlProvider } from "react-intl"; import Layout from "./components/layout/Layout"; import Home from "./components/Home"; import Login from "./components/Login"; import LandingPage from "./components/home/LandingPage"; -import HomeDashBoard from "./components/home/Dashboard"; import { Admin } from "./components"; import ResultSearch from "./components/resultPage/ResultSearch"; import UserSessionDetailsContext from "./UserSessionDetailsContext"; @@ -221,20 +215,10 @@ export default function App() { exact component={() => } /> - } - /> { - if (!userSessionDetails.unitSelected) { - return ; - } - return ; - }} + component={() => } role="" /> = () => { }, [selectedTile]); useEffect(() => { - getFromOpenElisServer("/rest/user-test-sections", (fetchedTestSections) => { - fetchTestSections(fetchedTestSections); - }); + getFromOpenElisServer( + "/rest/user-test-sections/ALL", + (fetchedTestSections) => { + fetchTestSections(fetchedTestSections); + }, + ); return () => { componentMounted.current = false; }; diff --git a/frontend/src/components/home/LandingPage.tsx b/frontend/src/components/home/LandingPage.tsx index fd4f71a88..ceefe6c0b 100644 --- a/frontend/src/components/home/LandingPage.tsx +++ b/frontend/src/components/home/LandingPage.tsx @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from "react"; +import React, { useState, useEffect, useContext } from "react"; import { Grid, Column, @@ -9,19 +9,44 @@ import { Form, } from "@carbon/react"; import { FormattedMessage, useIntl } from "react-intl"; -import { getFromOpenElisServer } from "../utils/Utils"; +import { getFromOpenElisServer, postToOpenElisServer } from "../utils/Utils"; +import { ConfigurationContext } from "../layout/Layout"; +import UserSessionDetailsContext from "../../UserSessionDetailsContext"; const LandingPage: React.FC = () => { const intl = useIntl(); const [departments, setDepartments] = useState([]); const [filteredDepartments, setFilteredDepartments] = useState([]); const [selectedDepartment, setSelectedDepartment] = useState(""); - const [selectedLabUnits, setSelectedLabUnits] = useState([]); const [rememberChoice, setRememberChoice] = useState(false); const [searchTerm, setSearchTerm] = useState(""); + const { configurationProperties } = + useContext(ConfigurationContext); + const { userSessionDetails } = useContext( + UserSessionDetailsContext, + ); + + interface UserSessionDetailsContext { + userSessionDetails: any; + } + + interface ConfigurationContext { + configurationProperties: any; + } useEffect(() => { - getFromOpenElisServer("/rest/user-test-sections", (response) => { + if ( + configurationProperties.REQUIRE_LAB_UNIT_AT_LOGIN === "false" || + userSessionDetails.loginLabUnit + ) { + const refererUrl = document.referrer; + if (refererUrl.endsWith("/landing")) { + window.location.href = "/"; + } else { + window.location.href = refererUrl; + } + } + getFromOpenElisServer("/rest/user-test-sections/ALL", (response) => { setDepartments(response); setFilteredDepartments(response); }); @@ -31,32 +56,35 @@ const LandingPage: React.FC = () => { const term = event.target.value.toLowerCase(); setSearchTerm(term); setFilteredDepartments( - departments.filter((dept) => - dept.value.toLowerCase().includes(term) - ) + departments.filter((dept) => dept.value.toLowerCase().includes(term)), ); }; const handleDepartmentSelect = (departmentId) => { setSelectedDepartment(departmentId); - setSelectedLabUnits([]); }; - const handleContinue = () => { - if (rememberChoice) { - if (selectedDepartment) { - localStorage.setItem("selectedDepartment", selectedDepartment); - } else if (selectedLabUnits.length > 0) { - localStorage.setItem( - "selectedLabUnits", - JSON.stringify(selectedLabUnits) - ); - } + if (selectedDepartment) { + // if(rememberChoice){ + // localStorage.setItem("selectedDepartment", selectedDepartment); + // } + postToOpenElisServer( + "/rest/setUserLoginLabUnit/" + selectedDepartment, + {}, + handlePostLabUbit, + ); + } + const refererUrl = document.referrer; + if (refererUrl.endsWith("/landing")) { + window.location.href = "/"; + } else { + window.location.href = refererUrl; } - window.location.href = "/dashboard"; }; + const handlePostLabUbit = (status) => {}; + return ( { backgroundColor: "#f9f9f9", }} > - {filteredDepartments.map((dept) => ( + {filteredDepartments?.map((dept) => (
{ backgroundColor: selectedDepartment === dept.id ? "#c6c6c6" : "inherit", borderColor: - selectedDepartment === dept.id ? "#0f62fe" : "transparent", + selectedDepartment === dept.id + ? "#0f62fe" + : "transparent", transition: "background-color 0.3s, border-color 0.3s", }} onClick={() => handleDepartmentSelect(dept.id)} @@ -141,16 +171,16 @@ const LandingPage: React.FC = () => {
))}
- setRememberChoice(e.target.checked)} - /> + /> */} diff --git a/frontend/src/components/layout/Header.js b/frontend/src/components/layout/Header.js index 0a0bdbc01..070cea2ea 100644 --- a/frontend/src/components/layout/Header.js +++ b/frontend/src/components/layout/Header.js @@ -7,6 +7,7 @@ import { Notification, Search, UserAvatarFilledAlt, + LocationFilled, } from "@carbon/icons-react"; import { Select, SelectItem } from "@carbon/react"; import React, { @@ -434,7 +435,7 @@ function OEHeader(props) { isCollapsible={true} /> )} - +
{configurationProperties?.BANNER_TEXT}
@@ -522,6 +523,15 @@ function OEHeader(props) { {userSessionDetails.firstName}{" "} {userSessionDetails.lastName} + {userSessionDetails.loginLabUnit && ( +
  • + + {userSessionDetails.loginLabUnit}{" "} +
  • + )}
  • { const [notificationVisible, setNotificationVisible] = useState(false); useEffect(() => { - getFromOpenElisServer("/rest/user-test-sections", (fetchedTestSections) => { - setLabUnits(fetchedTestSections); - }); + getFromOpenElisServer( + "/rest/user-test-sections/" + Roles.REPORTS, + (fetchedTestSections) => { + setLabUnits(fetchedTestSections); + }, + ); getFromOpenElisServer("/rest/priorities", (fetchedPriorities) => { setPriorities(fetchedPriorities); }); diff --git a/frontend/src/components/resultPage/SearchResultForm.js b/frontend/src/components/resultPage/SearchResultForm.js index ab9ae9287..3ad8f6aea 100644 --- a/frontend/src/components/resultPage/SearchResultForm.js +++ b/frontend/src/components/resultPage/SearchResultForm.js @@ -5,6 +5,7 @@ import { getFromOpenElisServer, postToOpenElisServerJsonResponse, convertAlphaNumLabNumForDisplay, + Roles, } from "../utils/Utils"; import { Form, @@ -312,15 +313,18 @@ export function SearchResultForm(props) { "testSectionId", ); testSectionId = testSectionId ? testSectionId : ""; - getFromOpenElisServer("/rest/user-test-sections", (fetchedTestSections) => { - let testSection = fetchedTestSections.find( - (testSection) => testSection.id === testSectionId, - ); - let testSectionLabel = testSection ? testSection.value : ""; - setDefaultTestSectionId(testSectionId); - setDefaultTestSectionLabel(testSectionLabel); - fetchTestSections(fetchedTestSections); - }); + getFromOpenElisServer( + "/rest/user-test-sections/" + Roles.RESULTS, + (fetchedTestSections) => { + let testSection = fetchedTestSections.find( + (testSection) => testSection.id === testSectionId, + ); + let testSectionLabel = testSection ? testSection.value : ""; + setDefaultTestSectionId(testSectionId); + setDefaultTestSectionLabel(testSectionLabel); + fetchTestSections(fetchedTestSections); + }, + ); if (testSectionId) { let values = { unitType: testSectionId }; querySearch(values); diff --git a/frontend/src/components/resultPage/resultsReferredOut/ReferredOutTests.js b/frontend/src/components/resultPage/resultsReferredOut/ReferredOutTests.js index e9c57b5f6..1c93eb62e 100644 --- a/frontend/src/components/resultPage/resultsReferredOut/ReferredOutTests.js +++ b/frontend/src/components/resultPage/resultsReferredOut/ReferredOutTests.js @@ -1,7 +1,7 @@ import React, { useContext, useState, useRef, useEffect } from "react"; import { FormattedMessage, injectIntl, useIntl } from "react-intl"; import "../../Style.css"; -import { encodeDate, getFromOpenElisServer } from "../../utils/Utils"; +import { encodeDate, getFromOpenElisServer, Roles } from "../../utils/Utils"; import { Form, Dropdown, @@ -239,14 +239,17 @@ function ReferredOutTests(props) { "testSectionId", ); testSectionId = testSectionId ? testSectionId : ""; - getFromOpenElisServer("/rest/user-test-sections", (fetchedTestSections) => { - let testSection = fetchedTestSections.find( - (testSection) => testSection.id === testSectionId, - ); - let testSectionLabel = testSection ? testSection.value : ""; - setTestNames(testSectionLabel); - fetchTestSections(fetchedTestSections); - }); + getFromOpenElisServer( + "/rest/user-test-sections/" + Roles.RESULTS, + (fetchedTestSections) => { + let testSection = fetchedTestSections.find( + (testSection) => testSection.id === testSectionId, + ); + let testSectionLabel = testSection ? testSection.value : ""; + setTestNames(testSectionLabel); + fetchTestSections(fetchedTestSections); + }, + ); }, []); useEffect(() => { diff --git a/frontend/src/components/security/SecureRoute.js b/frontend/src/components/security/SecureRoute.js index 1425765ba..6636dd25d 100644 --- a/frontend/src/components/security/SecureRoute.js +++ b/frontend/src/components/security/SecureRoute.js @@ -1,5 +1,6 @@ import React, { useState, useContext, useEffect, useRef } from "react"; import UserSessionDetailsContext from "../../UserSessionDetailsContext"; +import { ConfigurationContext } from "../layout/Layout"; import { Route } from "react-router-dom"; import { useIdleTimer } from "react-idle-timer"; import { confirmAlert } from "react-confirm-alert"; @@ -26,12 +27,20 @@ function SecureRoute(props) { logout, } = useContext(UserSessionDetailsContext); + const { configurationProperties } = useContext(ConfigurationContext); + useEffect(() => { setLoading(!errorLoadingSessionDetails && isCheckingLogin()); if (userSessionDetails.authenticated) { console.info("Authenticated"); if (hasPermission(userSessionDetails)) { console.info("Access Allowed"); + if ( + configurationProperties.REQUIRE_LAB_UNIT_AT_LOGIN === "true" && + !userSessionDetails.loginLabUnit + ) { + window.location.href = "/landing"; + } } else { const options = { title: intl.formatMessage({ id: "accessDenied.title" }), diff --git a/frontend/src/components/utils/Utils.js b/frontend/src/components/utils/Utils.js index e69b63cee..a35812d50 100644 --- a/frontend/src/components/utils/Utils.js +++ b/frontend/src/components/utils/Utils.js @@ -356,3 +356,14 @@ export function urlBase64ToUint8Array(base64String) { } return outputArray; } + +export const Roles = { + GLOBAL_ADMIN: "Global Administrator", + USER_ACCOUNT_ADMIN: "User Account Administrator", + AUDIT_TRAIL: "Audit Trail", + RECEPTION: "Reception", + RESULTS: "Results", + VALIDATION: "Validation", + REPORTS: "Reports", + PATHOLOGIST: "Pathologist", +}; diff --git a/frontend/src/components/validation/SearchForm.js b/frontend/src/components/validation/SearchForm.js index 28a605572..176dd91e2 100644 --- a/frontend/src/components/validation/SearchForm.js +++ b/frontend/src/components/validation/SearchForm.js @@ -18,7 +18,7 @@ import CustomLabNumberInput from "../common/CustomLabNumberInput"; import { FormattedMessage, useIntl } from "react-intl"; import { Formik, Field } from "formik"; import ValidationSearchFormValues from "../formModel/innitialValues/ValidationSearchFormValues"; -import { getFromOpenElisServer } from "../utils/Utils"; +import { getFromOpenElisServer, Roles } from "../utils/Utils"; import { NotificationContext } from "../layout/Layout"; import { NotificationKinds } from "../common/CustomNotification"; import { format } from "date-fns"; @@ -191,7 +191,7 @@ const SearchForm = (props) => { ); testSectionId = testSectionId ? testSectionId : ""; getFromOpenElisServer( - "/rest/user-test-sections", + "/rest/user-test-sections/" + Roles.VALIDATION, (fetchedTestSections) => { let testSection = fetchedTestSections.find( (testSection) => testSection.id === testSectionId, diff --git a/frontend/src/components/workplan/TestSectionSelectForm.js b/frontend/src/components/workplan/TestSectionSelectForm.js index b9117a3bd..1bf2e06b4 100644 --- a/frontend/src/components/workplan/TestSectionSelectForm.js +++ b/frontend/src/components/workplan/TestSectionSelectForm.js @@ -2,7 +2,7 @@ import React, { useEffect, useRef, useState } from "react"; import { Column, Grid, Select, SelectItem } from "@carbon/react"; import { FormattedMessage, injectIntl, useIntl } from "react-intl"; import "../Style.css"; -import { getFromOpenElisServer } from "../utils/Utils"; +import { getFromOpenElisServer, Roles } from "../utils/Utils"; function TestSectionSelectForm(props) { const mounted = useRef(false); @@ -28,18 +28,21 @@ function TestSectionSelectForm(props) { "testSectionId", ); testSectionId = testSectionId ? testSectionId : ""; - getFromOpenElisServer("/rest/user-test-sections", (fetchedTestSections) => { - let testSection = fetchedTestSections.find( - (testSection) => testSection.id === testSectionId, - ); - let testSectionLabel = testSection - ? testSection.value - : intl.formatMessage({ id: "input.placeholder.selectTestSection" }); - setDefaultTestSectionId(testSectionId); - setDefaultTestSectionLabel(testSectionLabel); - props.value(testSectionId, testSectionLabel); - getTestUnits(fetchedTestSections); - }); + getFromOpenElisServer( + "/rest/user-test-sections/" + Roles.RESULTS, + (fetchedTestSections) => { + let testSection = fetchedTestSections.find( + (testSection) => testSection.id === testSectionId, + ); + let testSectionLabel = testSection + ? testSection.value + : intl.formatMessage({ id: "input.placeholder.selectTestSection" }); + setDefaultTestSectionId(testSectionId); + setDefaultTestSectionLabel(testSectionLabel); + props.value(testSectionId, testSectionLabel); + getTestUnits(fetchedTestSections); + }, + ); return () => { mounted.current = false; }; diff --git a/frontend/src/languages/en.json b/frontend/src/languages/en.json index baeab01c9..2dc47150e 100644 --- a/frontend/src/languages/en.json +++ b/frontend/src/languages/en.json @@ -44,7 +44,7 @@ "patient.label.info": "Patient Information", "breadcrumb.home": "Home", "admin.legacy": "Legacy Admin", - "admin.formEntryConfig": "Form Configurations", + "admin.formEntryConfig": "General Configurations", "admin.page.configuration.formEntryConfigMenu.name": "Name", "admin.page.configuration.formEntryConfigMenu.description": "Description", "admin.page.configuration.formEntryConfigMenu.select": "Select", diff --git a/frontend/src/languages/fr.json b/frontend/src/languages/fr.json index f69bc428a..daee73d56 100644 --- a/frontend/src/languages/fr.json +++ b/frontend/src/languages/fr.json @@ -49,7 +49,7 @@ "patient.label.info": "Informations sur les patients", "breadcrumb.home": "Domicile", "admin.legacy": "Précédent Admin", - "admin.formEntryConfig": "Configurations de formulaire", + "admin.formEntryConfig": "Configurations générales", "admin.page.configuration.formEntryConfigMenu.name": "Nom", "admin.page.configuration.formEntryConfigMenu.description": "Description", "admin.page.configuration.formEntryConfigMenu.select": "Sélectionner", diff --git a/src/main/java/org/openelisglobal/common/rest/DisplayListController.java b/src/main/java/org/openelisglobal/common/rest/DisplayListController.java index 8e832c979..3b2b4248d 100644 --- a/src/main/java/org/openelisglobal/common/rest/DisplayListController.java +++ b/src/main/java/org/openelisglobal/common/rest/DisplayListController.java @@ -39,6 +39,7 @@ import org.openelisglobal.provider.valueholder.Provider; import org.openelisglobal.reports.action.implementation.ExportTrendsByDate; import org.openelisglobal.role.service.RoleService; +import org.openelisglobal.role.valueholder.Role; import org.openelisglobal.siteinformation.service.SiteInformationService; import org.openelisglobal.siteinformation.valueholder.SiteInformation; import org.openelisglobal.spring.util.SpringContext; @@ -363,6 +364,8 @@ private Map getOpenConfigurationProperties() { ConfigurationProperties.getInstance().getPropertyValue(Property.NEXT_VISIT_DATE_ON_WORKPLAN)); configs.put(Property.configurationName.toString(), ConfigurationProperties.getInstance().getPropertyValue(Property.configurationName)); + configs.put(Property.REQUIRE_LAB_UNIT_AT_LOGIN.toString(), + ConfigurationProperties.getInstance().getPropertyValue(Property.REQUIRE_LAB_UNIT_AT_LOGIN)); return configs; } @@ -408,11 +411,19 @@ private List createTestSectionsList() { return DisplayListService.getInstance().getList(ListType.TEST_SECTION_ACTIVE); } - @GetMapping(value = "user-test-sections", produces = MediaType.APPLICATION_JSON_VALUE) + @GetMapping(value = "user-test-sections/{roleName}", produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody - private List createUserTestSectionsList(HttpServletRequest request) { - String resultsRoleId = roleService.getRoleByName(Constants.ROLE_RESULTS).getId(); - return userService.getUserTestSections(getSysUserId(request), resultsRoleId); + private List createUserTestSectionsList(HttpServletRequest request, @PathVariable String roleName) { + if (roleName.equals("ALL")) { + return userService.getAllUserTestSections(getSysUserId(request)); + } else { + Role role = roleService.getRoleByName(roleName); + if (role == null) { + return new ArrayList<>(); + } + String resultsRoleId = role.getId(); + return userService.getUserTestSections(getSysUserId(request), resultsRoleId); + } } @GetMapping(value = "analysis-status-types", produces = MediaType.APPLICATION_JSON_VALUE) diff --git a/src/main/java/org/openelisglobal/common/util/ConfigurationProperties.java b/src/main/java/org/openelisglobal/common/util/ConfigurationProperties.java index 400d81c58..b4c9d6b6d 100644 --- a/src/main/java/org/openelisglobal/common/util/ConfigurationProperties.java +++ b/src/main/java/org/openelisglobal/common/util/ConfigurationProperties.java @@ -195,7 +195,8 @@ public enum Property { PATIENT_RESULTS_SMTP_PASSWORD("patientresultssmtp.password"), // PATIENT_RESULTS_SMTP_ADDRESS("patientresultssmtp.uri"), // PATIENT_RESULTS_SMTP_ENABLED("patientresultssmtp.enabled"), // - CONTACT_TRACING("contactTracingEnabled"); // + CONTACT_TRACING("contactTracingEnabled"), // + REQUIRE_LAB_UNIT_AT_LOGIN("requireLabUnitAtLogin"); private String name; diff --git a/src/main/java/org/openelisglobal/common/util/DefaultConfigurationProperties.java b/src/main/java/org/openelisglobal/common/util/DefaultConfigurationProperties.java index 65255ffa8..7e6e9c648 100644 --- a/src/main/java/org/openelisglobal/common/util/DefaultConfigurationProperties.java +++ b/src/main/java/org/openelisglobal/common/util/DefaultConfigurationProperties.java @@ -212,6 +212,8 @@ public class DefaultConfigurationProperties extends ConfigurationProperties { ""); setDBPropertyMappingAndDefault(Property.USE_ALPHANUM_ACCESSION_PREFIX, Property.USE_ALPHANUM_ACCESSION_PREFIX.getName(), "false"); + setDBPropertyMappingAndDefault(Property.REQUIRE_LAB_UNIT_AT_LOGIN, Property.REQUIRE_LAB_UNIT_AT_LOGIN.getName(), + "false"); } private void setDBPropertyMappingAndDefault(Property property, String dbName, String defaultValue) { diff --git a/src/main/java/org/openelisglobal/login/bean/UserSession.java b/src/main/java/org/openelisglobal/login/bean/UserSession.java index 8127fd367..bc52f29ae 100644 --- a/src/main/java/org/openelisglobal/login/bean/UserSession.java +++ b/src/main/java/org/openelisglobal/login/bean/UserSession.java @@ -15,6 +15,7 @@ public class UserSession { private Set roles; private Map> userLabRolesMap; private String CSRF; + private String loginLabUnit; public Boolean getAuthenticated() { return authenticated; @@ -87,4 +88,12 @@ public Map> getUserLabRolesMap() { public void setUserLabRolesMap(Map> userLabRolesMap) { this.userLabRolesMap = userLabRolesMap; } + + public String getLoginLabUnit() { + return loginLabUnit; + } + + public void setLoginLabUnit(String loginLabUnit) { + this.loginLabUnit = loginLabUnit; + } } diff --git a/src/main/java/org/openelisglobal/login/controller/LoginPageController.java b/src/main/java/org/openelisglobal/login/controller/LoginPageController.java index cc0d175b2..1cdc396d1 100644 --- a/src/main/java/org/openelisglobal/login/controller/LoginPageController.java +++ b/src/main/java/org/openelisglobal/login/controller/LoginPageController.java @@ -9,16 +9,21 @@ import java.util.Set; import java.util.stream.Collectors; import javax.servlet.http.HttpServletRequest; +import org.openelisglobal.common.action.IActionConstants; import org.openelisglobal.common.constants.Constants; import org.openelisglobal.common.controller.BaseController; +import org.openelisglobal.common.util.ConfigurationProperties; +import org.openelisglobal.common.util.ConfigurationProperties.Property; import org.openelisglobal.localization.service.LocalizationService; import org.openelisglobal.login.bean.UserSession; import org.openelisglobal.login.form.LoginForm; +import org.openelisglobal.login.valueholder.UserSessionData; import org.openelisglobal.role.service.RoleService; import org.openelisglobal.systemuser.service.SystemUserService; import org.openelisglobal.systemuser.service.UserService; import org.openelisglobal.systemuser.valueholder.SystemUser; import org.openelisglobal.test.service.TestSectionService; +import org.openelisglobal.test.valueholder.TestSection; import org.openelisglobal.userrole.service.UserRoleService; import org.openelisglobal.userrole.valueholder.LabUnitRoleMap; import org.openelisglobal.userrole.valueholder.UserLabUnitRoles; @@ -34,6 +39,8 @@ import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.InitBinder; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; @@ -126,16 +133,39 @@ public UserSession getSesssionDetails(HttpServletRequest request, CsrfToken toke session.setFirstName(user.getFirstName()); session.setLastName(user.getLastName()); session.setCSRF(token.getToken()); + UserSessionData usd = (UserSessionData) request.getSession().getAttribute(USER_SESSION_DATA); + if (usd.getLoginLabUnit() != 0) { + TestSection testSection = testSectionService.getTestSectionById(String.valueOf(usd.getLoginLabUnit())); + if (testSection != null) { + session.setLoginLabUnit(testSection.getLocalizedName()); + } + } setLabunitRolesForExistingUser(session); Set roles = new HashSet<>(); for (String roleId : userRoleService.getRoleIdsForUser(user.getId())) { roles.add(roleService.getRoleById(roleId).getName().trim()); } session.setRoles(roles); + } return session; } + @PostMapping(value = "/rest/setUserLoginLabUnit/{labUnitId}", produces = MediaType.APPLICATION_JSON_VALUE) + @ResponseBody + public void setUserLoginLabUnit(@PathVariable String labUnitId) { + if (ConfigurationProperties.getInstance().getPropertyValue(Property.REQUIRE_LAB_UNIT_AT_LOGIN).equals("true")) { + UserSessionData usd = (UserSessionData) request.getSession().getAttribute(USER_SESSION_DATA); + Integer loginLabUnit = Integer.valueOf(labUnitId); + TestSection testSection = testSectionService.getTestSectionById(labUnitId); + if (testSection != null) { + usd.setLoginLabUnit(loginLabUnit); + } + request.setAttribute(IActionConstants.USER_SESSION_DATA, usd); + request.getSession().setAttribute(IActionConstants.USER_SESSION_DATA, usd); + } + } + private void setLabunitRolesForExistingUser(UserSession session) { UserLabUnitRoles roles = userService.getUserLabUnitRoles(session.getUserId()); if (roles != null) { diff --git a/src/main/java/org/openelisglobal/login/valueholder/UserSessionData.java b/src/main/java/org/openelisglobal/login/valueholder/UserSessionData.java index b3b7aac6f..2df86b644 100644 --- a/src/main/java/org/openelisglobal/login/valueholder/UserSessionData.java +++ b/src/main/java/org/openelisglobal/login/valueholder/UserSessionData.java @@ -28,6 +28,7 @@ public class UserSessionData implements Serializable { private int systemUserId; private String loginName; private boolean isAdmin; + private int loginLabUnit; public void setElisUserName(String elisUserName) { this.elisUserName = elisUserName; @@ -68,4 +69,12 @@ public boolean isAdmin() { public void setAdmin(boolean isAdmin) { this.isAdmin = isAdmin; } + + public int getLoginLabUnit() { + return loginLabUnit; + } + + public void setLoginLabUnit(int loginLabUnit) { + this.loginLabUnit = loginLabUnit; + } } diff --git a/src/main/java/org/openelisglobal/systemuser/service/UserService.java b/src/main/java/org/openelisglobal/systemuser/service/UserService.java index 62b8ccc62..44cbef5e1 100644 --- a/src/main/java/org/openelisglobal/systemuser/service/UserService.java +++ b/src/main/java/org/openelisglobal/systemuser/service/UserService.java @@ -25,6 +25,8 @@ void saveUserLabUnitRoles(SystemUser systemUser, Map> select List getUserTestSections(String systemUserId, String userRole); + List getAllUserTestSections(String systemUserId); + List getUserSampleTypes(String systemUserId, String userRole); List getAllDisplayUserTestsByLabUnit(String SystemUserId, String roleName); diff --git a/src/main/java/org/openelisglobal/systemuser/service/UserServiceImpl.java b/src/main/java/org/openelisglobal/systemuser/service/UserServiceImpl.java index 771d00f9b..bba5a1e9a 100644 --- a/src/main/java/org/openelisglobal/systemuser/service/UserServiceImpl.java +++ b/src/main/java/org/openelisglobal/systemuser/service/UserServiceImpl.java @@ -6,14 +6,18 @@ import java.util.Map; import java.util.Set; import java.util.stream.Collectors; +import javax.servlet.http.HttpSession; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.openelisglobal.analysis.valueholder.Analysis; import org.openelisglobal.common.services.DisplayListService; import org.openelisglobal.common.services.DisplayListService.ListType; +import org.openelisglobal.common.util.ConfigurationProperties; +import org.openelisglobal.common.util.ConfigurationProperties.Property; import org.openelisglobal.common.util.IdValuePair; import org.openelisglobal.login.service.LoginUserService; import org.openelisglobal.login.valueholder.LoginUser; +import org.openelisglobal.login.valueholder.UserSessionData; import org.openelisglobal.program.service.ProgramService; import org.openelisglobal.resultvalidation.bean.AnalysisItem; import org.openelisglobal.role.service.RoleService; @@ -53,6 +57,8 @@ public class UserServiceImpl implements UserService { private TestService testService; @Autowired private TestSectionService testSectionService; + @Autowired + private HttpSession session; @Override @Transactional @@ -156,13 +162,61 @@ private void updateUserRoles(List selectedRoles, SystemUser systemUser, @Override public List getUserTestSections(String systemUserId, String roleId) { + List userTestSections = new ArrayList(); + Boolean requireLabUnitAtLogin = ConfigurationProperties.getInstance() + .getPropertyValue(Property.REQUIRE_LAB_UNIT_AT_LOGIN).equals("true"); + UserSessionData usd = (UserSessionData) session.getAttribute("userSessionData"); + TestSection logintestSection = null; + if (requireLabUnitAtLogin) { + if (usd.getLoginLabUnit() != 0) { + logintestSection = testSectionService.getTestSectionById(String.valueOf(usd.getLoginLabUnit())); + } + + } + List userLabUnits = new ArrayList<>(); UserLabUnitRoles userLabRoles = getUserLabUnitRoles(systemUserId); if (userLabRoles != null) { - userLabRoles.getLabUnitRoleMap().forEach(roles -> { - if (roles.getRoles().contains(roleId)) { - userLabUnits.add(roles.getLabUnit()); + for (LabUnitRoleMap labRole : userLabRoles.getLabUnitRoleMap()) { + if (labRole.getRoles().contains(roleId)) { + if (requireLabUnitAtLogin) { + if (logintestSection != null) { + if (labRole.getLabUnit().equals(logintestSection.getId())) { + userLabUnits.add(labRole.getLabUnit()); + } + } + } else { + userLabUnits.add(labRole.getLabUnit()); + } } + } + ; + } + List allTestSections = DisplayListService.getInstance().getList(ListType.TEST_SECTION_ACTIVE); + if (userLabUnits.contains(UnifiedSystemUserController.ALL_LAB_UNITS)) { + if (requireLabUnitAtLogin) { + if (logintestSection != null) { + userTestSections + .add(new IdValuePair(logintestSection.getId(), logintestSection.getLocalizedName())); + } + } else { + userTestSections = allTestSections; + } + } else { + userTestSections = allTestSections.stream() + .filter(testSection -> userLabUnits.contains(testSection.getId())).collect(Collectors.toList()); + } + + return userTestSections; + } + + @Override + public List getAllUserTestSections(String systemUserId) { + List userLabUnits = new ArrayList<>(); + UserLabUnitRoles userLabRoles = getUserLabUnitRoles(systemUserId); + if (userLabRoles != null) { + userLabRoles.getLabUnitRoleMap().forEach(roles -> { + userLabUnits.add(roles.getLabUnit()); }); } List allTestSections = DisplayListService.getInstance().getList(ListType.TEST_SECTION_ACTIVE); @@ -343,4 +397,5 @@ public List getUserPrograms(String systemUserId, String userRole) { || testUnitIds.contains(programService.get(p.getId()).getTestSection().getId())) .collect(Collectors.toList()); } + } diff --git a/src/main/resources/liquibase/2.8.x.x/base.xml b/src/main/resources/liquibase/2.8.x.x/base.xml index 2a96ccf4b..bc8fd6bb3 100644 --- a/src/main/resources/liquibase/2.8.x.x/base.xml +++ b/src/main/resources/liquibase/2.8.x.x/base.xml @@ -22,5 +22,5 @@ - + diff --git a/src/main/resources/liquibase/2.8.x.x/landing_page_config.xml b/src/main/resources/liquibase/2.8.x.x/landing_page_config.xml new file mode 100644 index 000000000..f9f874029 --- /dev/null +++ b/src/main/resources/liquibase/2.8.x.x/landing_page_config.xml @@ -0,0 +1,26 @@ + + + + + + + select count(*) from clinlims.site_information where name = 'requireLabUnitAtLogin'; + + add Config to require Lab Unit At Login + + + + + + + + + + + + + From 75cfe2209781e0d11b89b82ec9a27266a559b90f Mon Sep 17 00:00:00 2001 From: mozzy11 Date: Tue, 27 Aug 2024 05:46:40 +0300 Subject: [PATCH 5/9] fix Login Lab unit filter --- .../common/rest/DisplayListController.java | 2 +- .../systemuser/service/UserService.java | 2 - .../systemuser/service/UserServiceImpl.java | 48 +++++-------------- 3 files changed, 12 insertions(+), 40 deletions(-) diff --git a/src/main/java/org/openelisglobal/common/rest/DisplayListController.java b/src/main/java/org/openelisglobal/common/rest/DisplayListController.java index 3b2b4248d..074e70e52 100644 --- a/src/main/java/org/openelisglobal/common/rest/DisplayListController.java +++ b/src/main/java/org/openelisglobal/common/rest/DisplayListController.java @@ -415,7 +415,7 @@ private List createTestSectionsList() { @ResponseBody private List createUserTestSectionsList(HttpServletRequest request, @PathVariable String roleName) { if (roleName.equals("ALL")) { - return userService.getAllUserTestSections(getSysUserId(request)); + return userService.getUserTestSections(getSysUserId(request), null); } else { Role role = roleService.getRoleByName(roleName); if (role == null) { diff --git a/src/main/java/org/openelisglobal/systemuser/service/UserService.java b/src/main/java/org/openelisglobal/systemuser/service/UserService.java index 44cbef5e1..62b8ccc62 100644 --- a/src/main/java/org/openelisglobal/systemuser/service/UserService.java +++ b/src/main/java/org/openelisglobal/systemuser/service/UserService.java @@ -25,8 +25,6 @@ void saveUserLabUnitRoles(SystemUser systemUser, Map> select List getUserTestSections(String systemUserId, String userRole); - List getAllUserTestSections(String systemUserId); - List getUserSampleTypes(String systemUserId, String userRole); List getAllDisplayUserTestsByLabUnit(String SystemUserId, String roleName); diff --git a/src/main/java/org/openelisglobal/systemuser/service/UserServiceImpl.java b/src/main/java/org/openelisglobal/systemuser/service/UserServiceImpl.java index bba5a1e9a..6bd7aa211 100644 --- a/src/main/java/org/openelisglobal/systemuser/service/UserServiceImpl.java +++ b/src/main/java/org/openelisglobal/systemuser/service/UserServiceImpl.java @@ -170,60 +170,34 @@ public List getUserTestSections(String systemUserId, String roleId) if (requireLabUnitAtLogin) { if (usd.getLoginLabUnit() != 0) { logintestSection = testSectionService.getTestSectionById(String.valueOf(usd.getLoginLabUnit())); - } - - } - - List userLabUnits = new ArrayList<>(); - UserLabUnitRoles userLabRoles = getUserLabUnitRoles(systemUserId); - if (userLabRoles != null) { - for (LabUnitRoleMap labRole : userLabRoles.getLabUnitRoleMap()) { - if (labRole.getRoles().contains(roleId)) { - if (requireLabUnitAtLogin) { - if (logintestSection != null) { - if (labRole.getLabUnit().equals(logintestSection.getId())) { - userLabUnits.add(labRole.getLabUnit()); - } - } - } else { - userLabUnits.add(labRole.getLabUnit()); - } - } - } - ; - } - List allTestSections = DisplayListService.getInstance().getList(ListType.TEST_SECTION_ACTIVE); - if (userLabUnits.contains(UnifiedSystemUserController.ALL_LAB_UNITS)) { - if (requireLabUnitAtLogin) { if (logintestSection != null) { userTestSections .add(new IdValuePair(logintestSection.getId(), logintestSection.getLocalizedName())); + return userTestSections; } - } else { - userTestSections = allTestSections; } - } else { - userTestSections = allTestSections.stream() - .filter(testSection -> userLabUnits.contains(testSection.getId())).collect(Collectors.toList()); - } - return userTestSections; - } + } - @Override - public List getAllUserTestSections(String systemUserId) { List userLabUnits = new ArrayList<>(); UserLabUnitRoles userLabRoles = getUserLabUnitRoles(systemUserId); if (userLabRoles != null) { userLabRoles.getLabUnitRoleMap().forEach(roles -> { - userLabUnits.add(roles.getLabUnit()); + if (roleId == null) { + userLabUnits.add(roles.getLabUnit()); + } else { + if (roles.getRoles().contains(roleId)) { + userLabUnits.add(roles.getLabUnit()); + } + } + }); } List allTestSections = DisplayListService.getInstance().getList(ListType.TEST_SECTION_ACTIVE); if (userLabUnits.contains(UnifiedSystemUserController.ALL_LAB_UNITS)) { return allTestSections; } else { - List userTestSections = allTestSections.stream() + userTestSections = allTestSections.stream() .filter(testSection -> userLabUnits.contains(testSection.getId())).collect(Collectors.toList()); return userTestSections; } From 2bc1fefe01b092e931d382ac096700d3fa1eda85 Mon Sep 17 00:00:00 2001 From: mozzy11 Date: Tue, 27 Aug 2024 05:52:38 +0300 Subject: [PATCH 6/9] fix CI build --- frontend/src/App.js | 1 - 1 file changed, 1 deletion(-) diff --git a/frontend/src/App.js b/frontend/src/App.js index 31a10d845..f12a33c48 100644 --- a/frontend/src/App.js +++ b/frontend/src/App.js @@ -88,7 +88,6 @@ export default function App() { ); } } catch (error) { - console.log(er); console.error(error); if (counter === 10) { const options = { From eb4a17d29a5d9b00d4c599bb3b915c87c5f93d63 Mon Sep 17 00:00:00 2001 From: mozzy11 Date: Tue, 27 Aug 2024 05:57:47 +0300 Subject: [PATCH 7/9] fix CI build --- frontend/src/App.js | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/src/App.js b/frontend/src/App.js index f12a33c48..fb4752152 100644 --- a/frontend/src/App.js +++ b/frontend/src/App.js @@ -1,6 +1,7 @@ import React, { useState, useEffect } from "react"; import { BrowserRouter as Router, Route, Switch } from "react-router-dom"; import { IntlProvider } from "react-intl"; +import { confirmAlert } from "react-confirm-alert"; import Layout from "./components/layout/Layout"; import Home from "./components/Home"; import Login from "./components/Login"; From d09a123e7bf0cda035f6b2dbbeaaf1bca047b7be Mon Sep 17 00:00:00 2001 From: mozzy11 Date: Tue, 27 Aug 2024 08:22:03 +0300 Subject: [PATCH 8/9] Add coded conclusions to IHC report --- .../ImmunohistochemistryCaseView.js | 46 +++++++++++------- .../PatientImmunoChemistryReport.java | 6 +++ .../reports/form/ReportForm.java | 11 +++++ .../PatientImmunoChemistryReport.jasper | Bin 60768 -> 63216 bytes .../PatientImmunoChemistryReport.jrxml | 30 ++++++++++-- 5 files changed, 71 insertions(+), 22 deletions(-) diff --git a/frontend/src/components/immunohistochemistry/ImmunohistochemistryCaseView.js b/frontend/src/components/immunohistochemistry/ImmunohistochemistryCaseView.js index 5241dd331..30edca6e4 100644 --- a/frontend/src/components/immunohistochemistry/ImmunohistochemistryCaseView.js +++ b/frontend/src/components/immunohistochemistry/ImmunohistochemistryCaseView.js @@ -59,7 +59,6 @@ function ImmunohistochemistryCaseView() { const [immunohistochemistrySampleInfo, setImmunohistochemistrySampleInfo] = useState({ labNumber: "" }); - const [pathologySampleInfo, setPathologySampleInfo] = useState({}); const [conclusions, setConclusions] = useState([]); const [statuses, setStatuses] = useState([]); @@ -88,6 +87,7 @@ function ImmunohistochemistryCaseView() { diagnosis: "", molecularSubType: "", conclusion: "", + codedConclusions: [], ihcScore: "", ihcRatio: "", averageChrom: "", @@ -671,35 +671,44 @@ function ImmunohistochemistryCaseView() { + + + - } + titleText="" items={conclusions} itemToString={(item) => (item ? item.value : "")} - initialSelectedItems={pathologySampleInfo.conclusions} + initialSelectedItems={ + reportParams[index]?.codedConclusions + } onChange={(changes) => { - setPathologySampleInfo({ - ...pathologySampleInfo, - conclusions: changes.selectedItems, - }); + var params = { ...reportParams }; + if (!params[index]) { + params[index] = {}; + } + params[index].codedConclusions = + changes.selectedItems; + setReportParams(params); }} selectionFeedback="top-after-reopen" /> - - {pathologySampleInfo.conclusions && - pathologySampleInfo.conclusions.map( - (conclusion, index) => ( + + {reportParams[index] && + reportParams[index]?.codedConclusions.map( + (conclusion, conclusionIndex) => ( { - var info = { ...pathologySampleInfo }; - info["conclusions"].splice(index, 1); - setPathologySampleInfo(info); + var params = { ...reportParams }; + params[index]["codedConclusions"].splice( + conclusionIndex, + 1, + ); + setReportParams(params); }} > {conclusion.value} @@ -710,7 +719,7 @@ function ImmunohistochemistryCaseView() { - +