Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User Lab Permissions Filtering Bug #1371

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e2fbeb4
Implemented CSV report feature on Patient Status Report, added endpoi…
pascagihozo Sep 16, 2024
4e5c6ab
updating the endpoint on frontend
pascagihozo Sep 16, 2024
a08eaba
Formatted code on both frontend and backend
pascagihozo Sep 17, 2024
a698712
Merge branch 'develop' into develop
mozzy11 Sep 17, 2024
26fb7c5
Merge branch 'develop' into develop
mozzy11 Sep 23, 2024
30ba23d
fix CSV patient status report
mozzy11 Sep 24, 2024
430abd7
apply formatter
mozzy11 Sep 24, 2024
73ac5c8
remove unused code
mozzy11 Sep 24, 2024
1bf698f
Merge branch 'I-TECH-UW:develop' into develop
pascagihozo Oct 15, 2024
c04bc4c
Merge branch 'I-TECH-UW:develop' into develop
pascagihozo Oct 18, 2024
674bc08
Merge branch 'I-TECH-UW:develop' into develop
pascagihozo Nov 13, 2024
94f6ede
Merge branch 'I-TECH-UW:develop' into develop
pascagihozo Nov 21, 2024
792306e
Merge branch 'I-TECH-UW:develop' into develop
pascagihozo Nov 26, 2024
2514c84
Merge branch 'I-TECH-UW:develop' into develop
pascagihozo Dec 18, 2024
624b9b5
Merge branch 'I-TECH-UW:develop' into develop
pascagihozo Dec 19, 2024
314b78a
Merge branch 'I-TECH-UW:develop' into develop
pascagihozo Dec 23, 2024
61baf2a
Merge branch 'I-TECH-UW:develop' into develop
pascagihozo Dec 24, 2024
5df7b92
feat: filter test sections based on user's lab unit selection
Jan 5, 2025
d48dde0
formatting the frontend
Jan 6, 2025
9569a7c
mapping user labroles on frontend
Jan 6, 2025
aa11af0
code formatting
Jan 6, 2025
def188c
Merge branch 'develop' into activityReportPerm
mozzy11 Jan 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"prettier": "^3.3.2",
"prettier": "^3.4.2",
"sass": "^1.57.1"
}
}
9 changes: 5 additions & 4 deletions frontend/src/components/admin/program/ProgramManagement.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,11 @@ function ProgramManagement() {
useEffect(() => {
componentMounted.current = true;
getFromOpenElisServer("/rest/displayList/PROGRAM", fetchPrograms);
getFromOpenElisServer(
"/rest/displayList/TEST_SECTION_ACTIVE",
fetchTestSections,
);
// getFromOpenElisServer(
// "/rest/displayList/TEST_SECTION_ACTIVE",
// fetchTestSections,
// );
getFromOpenElisServer("/rest/user-test-sections/ALL", fetchTestSections);

return () => {
componentMounted.current = false;
Expand Down
6 changes: 1 addition & 5 deletions frontend/src/components/layout/search/searchBar.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
.search-input {
width: 100%;
position: relative;

}

.search-bar-container:hover {
Expand Down Expand Up @@ -52,11 +51,8 @@
cursor: pointer;
}


/* Large screens (1208px and up) */
@media (min-width: 1208px) {


.search-bar-container {
width: 45%;
margin-top: 0%;
Expand All @@ -77,7 +73,7 @@
right: 130px;
box-shadow: 0em 0.1em 0.5em #ccc;
}

.patientHead {
overflow-y: auto;
width: 600px;
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/layout/search/searchBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,4 @@ const SearchBar = (props) => {
);
};

export default SearchBar;
export default SearchBar;
10 changes: 10 additions & 0 deletions frontend/src/components/reports/Routine.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ export const RoutineReportsMenu = {
},
],
},
{
title: <FormattedMessage id="sidenav.label.statusreport.csv" />,
icon: IbmWatsonDiscovery,
SideNavMenuItem: [
{
link: "/RoutineReport?type=patient&report=CSVPatientStatusReport",
label: <FormattedMessage id="sidenav.label.statusreport.csv" />,
},
],
},
{
title: <FormattedMessage id="sidenav.title.aggregatereport" />,
icon: Microscope,
Expand Down
62 changes: 45 additions & 17 deletions frontend/src/components/reports/routine/ActivityReport.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState, useRef } from "react";
import React, { useEffect, useState, useRef, useContext } from "react";
import { FormattedMessage, useIntl } from "react-intl";
import {
Form,
Expand All @@ -21,11 +21,14 @@ import "../../Style.css";
import { getFromOpenElisServer } from "../../utils/Utils";
import { encodeDate } from "../../utils/Utils";
import config from "../../../config.json";
import { ConfigurationContext } from "../layout/Layout";
import UserSessionDetailsContext from "../../UserSessionDetailsContext";

const ActivityReport = ({ report }) => {
const intl = useIntl();
const [loading, setLoading] = useState(true);
const [notificationVisible, setNotificationVisible] = useState(false);
const { userSessionDetails } = useContext(UserSessionDetailsContext);
const [reportFormValues, setReportFormValues] = useState({
startDate: null,
endDate: null,
Expand Down Expand Up @@ -59,16 +62,18 @@ const ActivityReport = ({ report }) => {
setLoading(true);
let reportType = "";
let additionalParams = "";
switch (selectedReportType) {
case "byTest":
switch (
report // Changed from selectedReportType to report
) {
case "activityReportByTest":
reportType = "activityReportByTest";
additionalParams = "report=activityReportByTest";
break;
case "byPanel":
case "activityReportByPanel":
reportType = "activityReportByPanel";
additionalParams = "report=activityReportByPanel";
break;
case "byUnit":
case "activityReportByTestSection":
reportType = "activityReportByTestSection";
additionalParams = "report=activityReportByTestSection";
break;
Expand All @@ -77,34 +82,56 @@ const ActivityReport = ({ report }) => {
}
const baseParams = `${additionalParams}&type=indicator&report=${reportType}`;
const baseUrl = `${config.serverBaseUrl}/ReportPrint`;
const url = `${baseUrl}?${baseParams}&lowerDateRange=${reportFormValues.startDate}&upperDateRange=${reportFormValues.endDate}`;
const url = `${baseUrl}?${baseParams}&lowerDateRange=${reportFormValues.startDate}&upperDateRange=${reportFormValues.endDate}&value=${reportFormValues.value}`;
window.open(url, "_blank");
setLoading(false);
setNotificationVisible(true);
};

const setDataList = (data) => {
setList(data);
console.log("data: ", data);
console.log("Raw API data: ", data);

if (
report === "activityReportByTestSection" &&
userSessionDetails?.userLabRolesMap
) {
// Get departments where user has Reports role
const authorizedDepartments = Object.entries(
userSessionDetails.userLabRolesMap,
)
.filter(([dept, roles]) => roles.includes("Reports"))
.map(([dept]) => dept);

console.log("Authorized departments: ", authorizedDepartments);

// Filter data to only show authorized departments
const filteredData = data.filter((item) =>
authorizedDepartments.includes(item.value),
);

console.log("Filtered data: ", filteredData);
setList(filteredData);
} else {
setList(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);
getFromOpenElisServer("/rest/user-test-sections/ALL", setDataList);
break;
default:
break;
}
}, [report]);
}, [report, userSessionDetails]); // Added userSessionDetails to dependencies

return (
<>
Expand All @@ -127,7 +154,7 @@ const ActivityReport = ({ report }) => {
<Section>
<br />
<h5>
<FormattedMessage id="select date Range" />
<FormattedMessage id="select.date.range" />
</h5>
</Section>
<div className="inlineDiv">
Expand Down Expand Up @@ -159,9 +186,7 @@ const ActivityReport = ({ report }) => {
/>
</div>
</Column>
<div className="inlineDiv">hihih</div>
<Row></Row>
<Column log={15}>
<Column lg={10}>
{list && list.length > 0 && (
<Select
id="type"
Expand Down Expand Up @@ -194,8 +219,11 @@ const ActivityReport = ({ report }) => {
<br />
<Button
type="button"
onClick={() =>
handleSubmit("activityReportByTest", "RoutineReport")
onClick={handleSubmit}
disabled={
!reportFormValues.value ||
!reportFormValues.startDate ||
!reportFormValues.endDate
}
>
<FormattedMessage
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/components/reports/routine/Index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ export const RoutineReports = (props) => {
id={"openreports.patientTestStatus"}
/>
)}

{type === "patient" && report === "CSVPatientStatusReport" && (
<PatientStatusReport
report={"CSVPatientStatusReport"}
id={"sidenav.label.statusreport.csv"}
/>
)}
{type === "patient" && report === "referredOut" && <ReferredOut />}

{type === "patient" && report === "haitiNonConformityBySectionReason" && (
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/index.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
sans-serif;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto",
"Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans",
"Helvetica Neue", sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
Expand Down Expand Up @@ -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 */
}
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"label.button.confirmAction": "Confirm Action",
"label.button.confirmTitle": "Are You Sure ?",
"label.button.generatePrintableVersion": "Generate Printable Version",
"label.button.generateCSVVersion": "Generate CSV Version",
"label.button.viewReport": "View Report",
"label.routine.Reports": "Routine Reports",
"label.audittrail.Reports": "Audit Trail Reports",
Expand All @@ -37,7 +38,7 @@
"login.msg.password": "Password",
"login.msg.username.missing": "A username is required",
"login.msg.password.missing": "A password is required",
"login.notice.message": "Notice: Access to this service is for authorized personnel only. If you do not have the expressed authorization of the administrator, you must exit now. This organization prohibits unauthorized access, disclosure, duplication, modification, diversion, destruction, loss, misuse, or theft of its information.",
"login.notice.message": "xxNotice: Access to this service is for authorized personnel only. If you do not have the expressed authorization of the administrator, you must exit now. This organization prohibits unauthorized access, disclosure, duplication, modification, diversion, destruction, loss, misuse, or theft of its information.",
"message.noPluginFound": "No plugins Found",
"error.invalidcredentials": "Username or Password are incorrect",
"patient.label.modify": "Add Or Modify Patient",
Expand Down Expand Up @@ -298,6 +299,7 @@
"sidenav.label.admin.Listplugin": "List Plugins",
"sidenav.title.statusreport": "Patient Status Report",
"sidenav.label.statusreport": "Patient Status Report",
"sidenav.label.statusreport.csv": "Patient Status CSV Report",
"sidenav.title.aggregatereport": "Aggregate Reports",
"sidenav.label.statisticsreport": "Statistics Report",
"sideNav.title.rejectionreport": "Rejection Report",
Expand Down Expand Up @@ -491,6 +493,7 @@
"dashboard.rejected.orders.subtitle": "Rejected By Lab Today",
"dashboard.unprints.results.label": "UnPrinted Results",
"dashboard.unprints.results.subtitle.label": "UnPrinted Results Today",
"landingpage.welcome": "Welcome",
"label.electronic.orders": "Electronic Orders",
"patient.dob": "Date of Birth",
"patient.male": "Male",
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/languages/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@
"sidenav.label.admin.pluginFile": "Fichiers de plugin",
"sidenav.title.statusreport": "Rapport sur l'état du patient",
"sidenav.label.statusreport": "Rapport sur l'état du patient",
"sidenav.label.statusreport.csv": "CSV Rapport sur l'état du patient",
"sidenav.title.aggregatereport": "Rapports globaux",
"sidenav.label.statisticsreport": "Rapport Statistiques",
"sidenav.label.testsummary": "Résumé de tous les tests",
Expand Down Expand Up @@ -471,6 +472,7 @@
"dashboard.rejected.orders.subtitle": "Rejeté par le laboratoire aujourd'hui",
"dashboard.unprints.results.label": "Résultats non imprimés",
"dashboard.unprints.results.subtitle.label": "Résultats non imprimés aujourd'hui",
"landingpage.welcome": "Bienvenue!",
"label.electronic.orders": "Commandes électroniques",
"patient.dob": "Date de naissance",
"patient.male": "Mâle",
Expand Down
15 changes: 15 additions & 0 deletions node_modules/.package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions node_modules/react/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading