Skip to content

Commit

Permalink
Merge pull request #1245 from pascagihozo/develop
Browse files Browse the repository at this point in the history
Landing Page and Immuno conclusion dropdown
  • Loading branch information
mozzy11 authored Aug 27, 2024
2 parents 24c4ac5 + 5f9bb92 commit 037e1bd
Show file tree
Hide file tree
Showing 27 changed files with 533 additions and 56 deletions.
8 changes: 7 additions & 1 deletion frontend/src/App.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React, { useState, useEffect } from "react";
import { BrowserRouter as Router, Route, Switch } from "react-router-dom";
import { confirmAlert } from "react-confirm-alert";
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";
import LandingPage from "./components/home/LandingPage";
import { Admin } from "./components";
import ResultSearch from "./components/resultPage/ResultSearch";
import UserSessionDetailsContext from "./UserSessionDetailsContext";
Expand Down Expand Up @@ -209,6 +210,11 @@ export default function App() {
<Layout onChangeLanguage={onChangeLanguage}>
<Switch>
<Route path="/login" exact component={() => <Login />} />
<Route
path="/landing"
exact
component={() => <LandingPage />}
/>
<SecureRoute
path="/"
exact
Expand Down
9 changes: 6 additions & 3 deletions frontend/src/components/home/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,12 @@ const HomeDashBoard: React.FC<DashBoardProps> = () => {
}, [selectedTile]);

useEffect(() => {
getFromOpenElisServer("/rest/user-test-sections", (fetchedTestSections) => {
fetchTestSections(fetchedTestSections);
});
getFromOpenElisServer(
"/rest/user-test-sections/ALL",
(fetchedTestSections) => {
fetchTestSections(fetchedTestSections);
},
);
return () => {
componentMounted.current = false;
};
Expand Down
194 changes: 194 additions & 0 deletions frontend/src/components/home/LandingPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
import React, { useState, useEffect, useContext } from "react";
import {
Grid,
Column,
TextInput,
Button,
Checkbox,
Tile,
Form,
} from "@carbon/react";
import { FormattedMessage, useIntl } from "react-intl";
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 [rememberChoice, setRememberChoice] = useState(false);
const [searchTerm, setSearchTerm] = useState("");
const { configurationProperties } =
useContext<ConfigurationContext>(ConfigurationContext);
const { userSessionDetails } = useContext<UserSessionDetailsContext>(
UserSessionDetailsContext,
);

interface UserSessionDetailsContext {
userSessionDetails: any;
}

interface ConfigurationContext {
configurationProperties: any;
}

useEffect(() => {
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);
});
}, []);

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);
};

const handleContinue = () => {
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;
}
};

const handlePostLabUbit = (status) => {};

return (
<Grid
fullWidth
className="landing-page"
style={{
minHeight: "100vh",
display: "flex",
justifyContent: "center",
alignItems: "center",
padding: "1rem",
backgroundColor: "#f0f4f8",
}}
>
<Column
lg={8}
md={6}
sm={4}
className="landing-page-column"
style={{
display: "flex",
justifyContent: "center",
alignItems: "center",
maxWidth: "500px",
width: "100%",
}}
>
<Tile
style={{
padding: "2rem",
textAlign: "center",
width: "100%",
maxWidth: "500px",
backgroundColor: "white",
borderRadius: "12px",
boxShadow: "0 4px 12px rgba(0, 0, 0, 0.1)",
}}
>
<h2>Welcome!</h2>
<p>Please select a unit to continue</p>
<Form>
<TextInput
id="department-search"
labelText="Search for a department"
value={searchTerm}
onChange={handleSearch}
light
/>
<div
className="department-list"
style={{
maxHeight: "400px",
overflowY: "auto",
marginTop: "1rem",
marginBottom: "1rem",
textAlign: "left",
border: "1px solid #e0e0e0",
borderRadius: "4px",
padding: "0.5rem",
backgroundColor: "#f9f9f9",
}}
>
{filteredDepartments?.map((dept) => (
<div
key={dept.id}
className={`department-item ${
selectedDepartment === dept.id ? "selected" : ""
}`}
style={{
padding: "0.75rem",
cursor: "pointer",
borderRadius: "4px",
marginBottom: "0.5rem",
backgroundColor:
selectedDepartment === dept.id ? "#c6c6c6" : "inherit",
borderColor:
selectedDepartment === dept.id
? "#0f62fe"
: "transparent",
transition: "background-color 0.3s, border-color 0.3s",
}}
onClick={() => handleDepartmentSelect(dept.id)}
>
{dept.value}
</div>
))}
</div>
{/* <Checkbox
id="remember-choice"
labelText="Remember my choice"
checked={rememberChoice}
onChange={(e) => setRememberChoice(e.target.checked)}
/> */}
<Button
onClick={handleContinue}
disabled={!selectedDepartment}
style={{ marginTop: "1rem", width: "100%", maxWidth: "100%" }}
>
Continue
</Button>
</Form>
</Tile>
</Column>
</Grid>
);
};

export default LandingPage;
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
InlineLoading,
Toggle,
TextArea,
FilterableMultiSelect,
} from "@carbon/react";
import { Launch, Subtract } from "@carbon/react/icons";
import {
Expand Down Expand Up @@ -57,6 +58,9 @@ function ImmunohistochemistryCaseView() {
const { userSessionDetails } = useContext(UserSessionDetailsContext);
const [immunohistochemistrySampleInfo, setImmunohistochemistrySampleInfo] =
useState({ labNumber: "" });

const [conclusions, setConclusions] = useState([]);

const [statuses, setStatuses] = useState([]);
const [reportTypes, setReportTypes] = useState([]);
const [technicianUsers, setTechnicianUsers] = useState([]);
Expand All @@ -83,6 +87,7 @@ function ImmunohistochemistryCaseView() {
diagnosis: "",
molecularSubType: "",
conclusion: "",
codedConclusions: [],
ihcScore: "",
ihcRatio: "",
averageChrom: "",
Expand Down Expand Up @@ -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":
Expand Down Expand Up @@ -650,8 +669,57 @@ function ImmunohistochemistryCaseView() {
<>
<Column lg={16} md={8} sm={4}>
<Grid fullWidth={true} className="gridBoundary">
<Column lg={16} md={8} sm={4}>
<Grid fullWidth={true} className="gridBoundary">
<Column lg={3} md={8} sm={4}>
<FormattedMessage id="pathology.label.conclusion" />
</Column>
<Column lg={4} md={8} sm={4}>
<FilterableMultiSelect
id="conclusion"
titleText=""
items={conclusions}
itemToString={(item) => (item ? item.value : "")}
initialSelectedItems={
reportParams[index]?.codedConclusions
}
onChange={(changes) => {
var params = { ...reportParams };
if (!params[index]) {
params[index] = {};
}
params[index].codedConclusions =
changes.selectedItems;
setReportParams(params);
}}
selectionFeedback="top-after-reopen"
/>
</Column>
<Column lg={8} md={8} sm={4}>
{reportParams[index] &&
reportParams[index]?.codedConclusions.map(
(conclusion, conclusionIndex) => (
<Tag
key={conclusionIndex}
filter
onClose={() => {
var params = { ...reportParams };
params[index]["codedConclusions"].splice(
conclusionIndex,
1,
);
setReportParams(params);
}}
>
{conclusion.value}
</Tag>
),
)}
</Column>
</Grid>
</Column>
<Column lg={3} md={8} sm={4}>
<FormattedMessage id="pathology.label.conclusion" />
<FormattedMessage id="pathology.label.textconclusion" />
</Column>
<Column lg={13} md={8} sm={4}>
<TextArea
Expand Down Expand Up @@ -1156,6 +1224,11 @@ function ImmunohistochemistryCaseView() {
averageHer2: reportParams[index]?.averageHer2,
numberOfcancerNuclei:
reportParams[index]?.numberOfcancerNuclei,
codedConclusions: reportParams[
index
]?.codedConclusions.map(
(conclusion) => conclusion.id,
),
};
postToOpenElisServerForPDF(
"/rest/ReportPrint",
Expand Down
10 changes: 10 additions & 0 deletions frontend/src/components/layout/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
Notification,
Search,
UserAvatarFilledAlt,
LocationFilled,
} from "@carbon/icons-react";
import { Select, SelectItem } from "@carbon/react";
import React, {
Expand Down Expand Up @@ -522,6 +523,15 @@ function OEHeader(props) {
{userSessionDetails.firstName}{" "}
{userSessionDetails.lastName}
</li>
{userSessionDetails.loginLabUnit && (
<li className="userDetails">
<LocationFilled
size={18}
style={{ marginRight: "4px" }}
/>
{userSessionDetails.loginLabUnit}{" "}
</li>
)}
<li
className="userDetails clickableUserDetails"
onClick={logout}
Expand Down
Loading

0 comments on commit 037e1bd

Please sign in to comment.