Skip to content

Commit

Permalink
Merge branch 'develop_3x' into fix-705-rewriting-patient-report-screen
Browse files Browse the repository at this point in the history
  • Loading branch information
adityadeshlahre committed Mar 5, 2024
2 parents bd929bd + b49adb5 commit 965cb6f
Show file tree
Hide file tree
Showing 9 changed files with 688 additions and 11 deletions.
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,20 @@ You can find more information on how to set up OpenELIS at our [docs page](http:
docker-compose -f build.docker-compose.yml up -d --build

#### Running docker compose With locally compiled/built Artifacts (ie the War file and React code) For Developers
1. Clone the Repository
1. Fork the [OpenELIS-Global Repository](https://github.com/I-TECH-UW/OpenELIS-Global-2.git) and clone the forked repo. The `username` below is the `username` of your Github profile.

git clone https://github.com/I-TECH-UW/OpenELIS-Global-2.git
git clone https://github.com/username/OpenELIS-Global-2.git

2. innitialize and build sub modules

cd OpenELIS-Global-2
git submodule update --init --recursive
cd OpenELIS-Global-2/dataexport
cd dataexport
mvn clean install -DskipTests

3. Build the War file

cd OpenELIS-Global-2
cd ..
mvn clean install -DskipTests

4. Start the containers to mount the locally compiled artifacts
Expand All @@ -52,3 +53,7 @@ You can find more information on how to set up OpenELIS at our [docs page](http:
| Legacy UI | https://localhost/api/OpenELIS-Global/  | admin: adminADMIN! |
| New React UI | https://localhost/ | admin: adminADMIN!

**Note:** If your browser indicates that the website is not secure after accessing any of these links, simply follow these steps:
1. Scroll down on the warning page.
2. Click on the "Advanced" button.
3. Finally, click on "Proceed to https://localhost" to access the development environment.
7 changes: 7 additions & 0 deletions frontend/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import ImmunohistochemistryCaseView from "./components/immunohistochemistry/Immu
import RoutedResultsViewer from "./components/patient/resultsViewer/results-viewer.tsx";
import EOrderPage from "./components/eOrder/Index";
import RoutineIndex from "./components/Reports/routine/Index.js";
import PrintBarcode from "./components/printBarcode/Index";

export default function App() {
let i18nConfig = {
Expand Down Expand Up @@ -286,6 +287,12 @@ export default function App() {
component={() => <EOrderPage />}
role="Reception"
/>
<SecureRoute
path="/PrintBarcode"
exact
component={() => <PrintBarcode />}
role="Reception"
/>
<SecureRoute
path="/PatientManagement"
exact
Expand Down
15 changes: 9 additions & 6 deletions frontend/src/components/layout/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,15 @@ function OEHeader(props) {
<SideNavMenuItem className="reduced-padding-nav-menu-item">
<span style={{ display: "flex", width: "100%" }}>
{!menuItem.menu.actionURL &&
hasActiveChildMenu(menuItem) &&
!hasActiveChildMenu(menuItem) &&
console.warn("menu entry has no action url and no child")}
{hasActiveChildMenu(menuItem) &&
{!hasActiveChildMenu(menuItem) &&
renderSingleNavButton(menuItem, index, level, path)}
{!menuItem.menu.actionURL &&
!hasActiveChildMenu(menuItem) &&
hasActiveChildMenu(menuItem) &&
renderSingleDropdownButton(menuItem, index, level, path)}
{menuItem.menu.actionURL &&
!hasActiveChildMenu(menuItem) &&
hasActiveChildMenu(menuItem) &&
renderDualNavDropdownButton(menuItem, index, level, path)}
</span>
</SideNavMenuItem>
Expand Down Expand Up @@ -197,10 +197,13 @@ function OEHeader(props) {
};

const hasActiveChildMenu = (menuItem) => {
if (menuItem.menu.elementId === "menu_reports_routine") {
console.log("reports");
}
return (
menuItem.childMenus.length < 1 &&
menuItem.childMenus.length >= 1 &&
menuItem.childMenus.some((element) => {
return element.isActive;
return element.menu.isActive;
})
);
};
Expand Down
277 changes: 277 additions & 0 deletions frontend/src/components/printBarcode/ExistingOrder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,277 @@
import { React, useState, useEffect, useRef, useContext } from "react";
import { FormattedMessage, useIntl, injectIntl } from "react-intl";
import {
Grid,
Column,
Form,
Button,
NumberInput,
DataTable,
TableContainer,
Table,
TableHead,
TableRow,
TableHeader,
TableBody,
TableCell,
} from "@carbon/react";
import CustomLabNumberInput from "../common/CustomLabNumberInput";
import { NotificationContext } from "../layout/Layout";
import { AlertDialog, NotificationKinds } from "../common/CustomNotification";
import { getFromOpenElisServer } from "../utils/Utils";

const ExistingOrder = () => {
const intl = useIntl();
const componentMounted = useRef(false);
const [accessionNumber, setAccessionNumber] = useState("");
const [orderLabels, setOrderLabels] = useState(1);
const [patientSearchResults, setPatientSearchResults] = useState(null);
const [orderResults, setOrderResults] = useState(null);
const [source, setSource] = useState("about:blank");
const [renderBarcode, setRenderBarcode] = useState(false);
const { notificationVisible, setNotificationVisible, addNotification } =
useContext(NotificationContext);
useEffect(() => {
componentMounted.current = true;
return () => {
componentMounted.current = false;
};
}, [accessionNumber]);
const fetchPatientData = (res) => {
if (componentMounted.current) {
let patientsResults = res.patientSearchResults;
if (patientsResults.length > 0) {
setPatientSearchResults(patientsResults[0]);
} else {
setPatientSearchResults(null);
addNotification({
title: intl.formatMessage({ id: "notification.title" }),
message: intl.formatMessage({ id: "patient.search.nopatient" }),
kind: NotificationKinds.warning,
});
setNotificationVisible(true);
}
}
};

const fetchOrderData = (res) => {
if (componentMounted.current) {
let orderResults = res.existingTests;
setOrderResults(orderResults);
}
};

const handleSearch = (e) => {
e.preventDefault();
getFromOpenElisServer(
`/rest/patient-search-results?labNumber=${accessionNumber}`,
fetchPatientData
);
getFromOpenElisServer(
`/rest/sample-edit?accessionNumber=${accessionNumber}`,
fetchOrderData
);
};

const printLabelSets = () => {
setSource(
`/LabelMakerServlet?labNo=${accessionNumber}&type=default&quantity=`
);
setRenderBarcode(true);
};

const printOrderLabels = () => {
setSource(
`/LabelMakerServlet?labNo=${accessionNumber}&type=order&quantity=${orderLabels}`
);
setRenderBarcode(true);
};

const printSpecimenLabels = (specimenAccessionNumber) => {
setSource(
`/LabelMakerServlet?labNo=${specimenAccessionNumber}&type=specimen&quantity=1`
);
setRenderBarcode(true);
};

return (
<>
{notificationVisible === true ? <AlertDialog /> : ""}
<div className="orderLegendBody">
<Form onSubmit={handleSearch}>
<Grid>
<Column lg={16}>
<h4>
<FormattedMessage id="sample.entry.search.barcode" />
</h4>
</Column>
<Column lg={4}>
<CustomLabNumberInput
placeholder={"Enter Lab No"}
id="labNumber"
name="labNumber"
value={accessionNumber}
onChange={(e, rawVal) => {
setOrderResults(null);
setAccessionNumber(rawVal ? rawVal : e?.target?.value);
}}
labelText={<FormattedMessage id="search.label.accession" />}
/>
</Column>
<Column lg={2}>
<Button type="submit">
<FormattedMessage id="label.button.submit" />
</Button>
</Column>
</Grid>
</Form>
{patientSearchResults !== null && orderResults !== null && (
<Grid>
<Column lg={4}>
<h4>
<FormattedMessage id="patient.label.name" />
</h4>
</Column>
<Column lg={4}>
<h4>
<FormattedMessage id="patient.dob" />
</h4>
</Column>
<Column lg={4}>
<h4>
<FormattedMessage id="patient.gender" />
</h4>
</Column>
<Column lg={4}>
<h4>
<FormattedMessage id="patient.natioanalid" />
</h4>
</Column>
<Column lg={4}>
{patientSearchResults.firstName +
" " +
patientSearchResults.lastName}
</Column>
<Column lg={4}>{patientSearchResults.birthdate}</Column>
<Column lg={4}>{patientSearchResults.gender}</Column>
<Column lg={4}>{patientSearchResults.nationalId}</Column>
</Grid>
)}
</div>
{patientSearchResults !== null && orderResults !== null && (
<div className="orderLegendBody">
<Grid>
<Column lg={16}>
<h4>
<FormattedMessage id="barcode.print.section.set" />
</h4>
</Column>
<Column lg={6}>
<FormattedMessage id="barcode.print.set.instruction" />
</Column>
<Column>
<Button onClick={printLabelSets}>
<FormattedMessage id="barcode.print.set.button" />
</Button>
</Column>
</Grid>
</div>
)}
{patientSearchResults !== null && orderResults !== null && (
<div className="orderLegendBody">
<DataTable
headers={[
{ key: "labelType", header: "Label Type" },
{ key: "accessionNumber", header: "Accession Number" },
{ key: "additionalInfo", header: "Additional Info" },
{ key: "numberToPrint", header: "Number to Print" },
{ key: "button", header: "" },
]}
rows={[
{
id: "row1",
labelType: "Order",
accessionNumber: accessionNumber,
additionalInfo: "",
numberToPrint: (
<NumberInput
min={1}
max={100}
defaultValue={1}
onChange={(_, state) => setOrderLabels(state.value)}
id="numberToPrint"
className="inputText"
/>
),
button: (
<Button onClick={printOrderLabels}>
<FormattedMessage id="barcode.print.individual.button" />
</Button>
),
},
...orderResults
.filter((result) => result.accessionNumber)
.map((result, index) => ({
id: `row${index + 2}`,
labelType: "Specimen",
accessionNumber: result.accessionNumber,
additionalInfo: result.sampleType,
numberToPrint: 1,
button: (
<Button
onClick={() =>
printSpecimenLabels(result.accessionNumber)
}
>
<FormattedMessage id="barcode.print.individual.button" />
</Button>
),
})),
]}
>
{({ rows, headers, getHeaderProps, getTableProps }) => (
<TableContainer>
<Table {...getTableProps()}>
<TableHead>
<TableRow>
{headers.map((header) => (
<TableHeader
key={header.key}
{...getHeaderProps({ header })}
>
{header.header}
</TableHeader>
))}
</TableRow>
</TableHead>
<TableBody>
{rows.map((row) => (
<TableRow key={row.id}>
{row.cells.map((cell) => (
<TableCell key={cell.id}>{cell.value}</TableCell>
))}
</TableRow>
))}
</TableBody>
</Table>
</TableContainer>
)}
</DataTable>
</div>
)}
{renderBarcode && (
<div className="orderLegendBody">
<Grid>
<Column lg={16}>
<h4>
<FormattedMessage id="barcode.header" />
</h4>
</Column>
</Grid>
<iframe src={source} width="100%" height="500px" />
</div>
)}
</>
);
};
export default injectIntl(ExistingOrder);
26 changes: 26 additions & 0 deletions frontend/src/components/printBarcode/Index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from "react";
import { FormattedMessage } from "react-intl";
import { Column, Grid, Heading, Section } from "@carbon/react";
import ExistingOrder from "./ExistingOrder";
import PrePrint from "./PrePrint";

const PrintBarcode = () => {
return (
<div>
<Grid fullWidth={true}>
<Column lg={12}>
<Section>
<Section>
<Heading>
<FormattedMessage id="barcode.print.title" />
</Heading>
</Section>
</Section>
</Column>
</Grid>
<PrePrint />
<ExistingOrder />
</div>
);
};
export default PrintBarcode;
Loading

0 comments on commit 965cb6f

Please sign in to comment.