diff --git a/frontend/cypress/e2e/result.cy.js b/frontend/cypress/e2e/result.cy.js index 9a4f4f3b9..c42053f53 100644 --- a/frontend/cypress/e2e/result.cy.js +++ b/frontend/cypress/e2e/result.cy.js @@ -209,7 +209,7 @@ describe("Result By Referred Out Tests", function () { // ); // }); }); -//commented due to UI changes + //commented due to UI changes // it("should select the respecting referred test and print the selected patient reports", function () { // result.selectRefferedTest(); // result.printReport(); diff --git a/frontend/cypress/e2e/validation.cy.js b/frontend/cypress/e2e/validation.cy.js index 4aecae333..3e0f947f6 100644 --- a/frontend/cypress/e2e/validation.cy.js +++ b/frontend/cypress/e2e/validation.cy.js @@ -67,6 +67,6 @@ describe("Validation By Range Of Order", function () { }); it("Should Save the results", function () { - validation.saveResults('Test Note'); + validation.saveResults("Test Note"); }); }); diff --git a/frontend/cypress/pages/HomePage.js b/frontend/cypress/pages/HomePage.js index 8b5e46a5a..dfedb13fc 100755 --- a/frontend/cypress/pages/HomePage.js +++ b/frontend/cypress/pages/HomePage.js @@ -105,7 +105,6 @@ class HomePage { return new NonConform(); } - goToResultsByUnit() { this.openNavigationMenu(); cy.get("#menu_results").click(); @@ -150,22 +149,22 @@ class HomePage { goToValidationByRoutine() { this.openNavigationMenu(); - cy.get('#menu_resultvalidation').click(); - cy.get('#menu_resultvalidation_routine ').click(); + cy.get("#menu_resultvalidation").click(); + cy.get("#menu_resultvalidation_routine ").click(); return new Validation(); } goToValidationByOrder() { this.openNavigationMenu(); cy.get("#menu_resultvalidation").click(); - cy.get('#menu_accession_validation ').click(); + cy.get("#menu_accession_validation ").click(); return new Validation(); } goToValidationByRangeOrder() { this.openNavigationMenu(); cy.get("#menu_resultvalidation").click(); - cy.get('#menu_accession_validation_range ').click(); + cy.get("#menu_accession_validation_range ").click(); return new Validation(); - } + } goToRoutineReports() { this.openNavigationMenu(); diff --git a/frontend/cypress/pages/ResultsPage.js b/frontend/cypress/pages/ResultsPage.js index cacab599a..75aa6a77c 100644 --- a/frontend/cypress/pages/ResultsPage.js +++ b/frontend/cypress/pages/ResultsPage.js @@ -38,8 +38,14 @@ class Result { } validatePatientResult(patient) { - cy.get('tbody > :nth-child(1) > :nth-child(2)').should("contain.text", patient.lastName); - cy.get('tbody > :nth-child(1) > :nth-child(3)').should("contain.text", patient.firstName); + cy.get("tbody > :nth-child(1) > :nth-child(2)").should( + "contain.text", + patient.lastName, + ); + cy.get("tbody > :nth-child(1) > :nth-child(3)").should( + "contain.text", + patient.firstName, + ); } referSample(index = 0, reason, institute) { diff --git a/frontend/cypress/pages/Validation.js b/frontend/cypress/pages/Validation.js index 5ffe48859..d6ed96eb8 100644 --- a/frontend/cypress/pages/Validation.js +++ b/frontend/cypress/pages/Validation.js @@ -1,28 +1,27 @@ class Validation { - checkForHeading() { - cy.get('section > h3').should("contain.text", "Validation"); - } - - selectTestUnit(unitType) { - cy.get('#unitType').select(unitType); - } + checkForHeading() { + cy.get("section > h3").should("contain.text", "Validation"); + } + + selectTestUnit(unitType) { + cy.get("#unitType").select(unitType); + } + + validateTestUnit(unitType) { + cy.get("#cell-testName-0 > .sampleInfo").should("contain.text", unitType); + } + + enterLabNumberAndSearch(labNo) { + cy.get("#accessionNumber").type(labNo); + cy.get(".cds--sm\\:col-span-4.cds--lg\\:col-span-16 > #submit").click(); + cy.get("#cell-sampleInfo-0 > .sampleInfo").should("contain.text", labNo); + } - validateTestUnit(unitType) { - cy.get('#cell-testName-0 > .sampleInfo').should("contain.text", unitType); - } - - enterLabNumberAndSearch(labNo) { - cy.get('#accessionNumber').type(labNo); - cy.get('.cds--sm\\:col-span-4.cds--lg\\:col-span-16 > #submit').click(); - cy.get('#cell-sampleInfo-0 > .sampleInfo').should("contain.text", labNo); - } - - saveResults(note) { - cy.get('#cell-save-0 > .cds--form-item > .cds--checkbox-label').click(); - cy.get('#resultList0\\.note').type(note); - cy.get(':nth-child(3) > #submit').click(); - } + saveResults(note) { + cy.get("#cell-save-0 > .cds--form-item > .cds--checkbox-label").click(); + cy.get("#resultList0\\.note").type(note); + cy.get(":nth-child(3) > #submit").click(); } - - export default Validation; - \ No newline at end of file +} + +export default Validation; diff --git a/frontend/src/components/admin/Admin.js b/frontend/src/components/admin/Admin.js index 541f29442..4738e7abc 100644 --- a/frontend/src/components/admin/Admin.js +++ b/frontend/src/components/admin/Admin.js @@ -29,6 +29,7 @@ import { Bullhorn, User, BatchJob, + Popup, } from "@carbon/icons-react"; import PathRoute from "../utils/PathRoute"; import CalculatedValue from "./calculatedValue/CalculatedValueForm"; @@ -54,6 +55,8 @@ import UserManagement from "./userManagement/UserManagement"; import UserAddModify from "./userManagement/UserAddModify"; import ManageMethod from "./testManagement/ManageMethod.js"; import BatchTestReassignmentAndCancelation from "./BatchTestReassignmentAndCancellation/BatchTestReassignmentAndCancelation.js"; +import TestNotificationConfigMenu from "./testNotificationConfigMenu/TestNotificationConfigMenu.js"; +import TestNotificationConfigEdit from "./testNotificationConfigMenu/TestNotificationConfigEdit.js"; function Admin() { const intl = useIntl(); @@ -188,6 +191,9 @@ function Admin() { defaultMessage={"Common Properties"} /> + + + @@ -325,6 +331,12 @@ function Admin() { id="sidenav.label.admin.formEntry.PrintedReportsconfig" /> + + + + + + diff --git a/frontend/src/components/admin/testNotificationConfigMenu/TestNotificationConfigEdit.js b/frontend/src/components/admin/testNotificationConfigMenu/TestNotificationConfigEdit.js new file mode 100644 index 000000000..f61a05a65 --- /dev/null +++ b/frontend/src/components/admin/testNotificationConfigMenu/TestNotificationConfigEdit.js @@ -0,0 +1,803 @@ +import React, { useContext, useState, useEffect, useRef } from "react"; +import { + Heading, + Button, + Loading, + Grid, + Column, + Section, + DataTable, + Table, + TableHead, + TableRow, + TableBody, + TableHeader, + TableCell, + TableSelectRow, + TableSelectAll, + TableContainer, + Pagination, + Search, + Modal, + TextInput, + Dropdown, + TextArea, + Checkbox, +} from "@carbon/react"; +import { + getFromOpenElisServer, + postToOpenElisServerFullResponse, + postToOpenElisServerJsonResponse, +} from "../../utils/Utils.js"; +import { + ConfigurationContext, + NotificationContext, +} from "../../layout/Layout.js"; +import { + AlertDialog, + NotificationKinds, +} from "../../common/CustomNotification.js"; +import { FormattedMessage, injectIntl, useIntl } from "react-intl"; +import PageBreadCrumb from "../../common/PageBreadCrumb.js"; +import { ArrowLeft, ArrowRight, Cost } from "@carbon/icons-react"; +import ActionPaginationButtonType from "../../common/ActionPaginationButtonType.js"; + +let breadcrumbs = [ + { label: "home.label", link: "/" }, + { label: "breadcrums.admin.managment", link: "/MasterListsPage" }, + { + label: "testnotificationconfig.browse.title", + link: "/MasterListsPage#testNotificationConfigMenu", + }, +]; + +function TestNotificationConfigEdit() { + const { notificationVisible, setNotificationVisible, addNotification } = + useContext(NotificationContext); + + const intl = useIntl(); + + const ID = (() => { + const hash = window.location.hash; + if (hash.includes("?")) { + const queryParams = hash.split("?")[1]; + const urlParams = new URLSearchParams(queryParams); + return urlParams.get("testId"); + } + return "0"; + })(); + + const componentMounted = useRef(false); + const [indMsg, setIndMsg] = useState("0"); + const [loading, setLoading] = useState(true); + const [saveButton, setSaveButton] = useState(false); + const [sysDefaultMsg, setSysDefaultMsg] = useState(true); + const [testNotificationConfigEditData, setTestNotificationConfigEditData] = + useState({}); + const [ + testNotificationConfigEditDataPost, + setTestNotificationConfigEditDataPost, + ] = useState({}); + const [testNamesList, setTestNamesList] = useState([]); + const [testName, setTestName] = useState(""); + const [testNotificationConfigMenuList, setTestNotificationConfigMenuList] = + useState([]); + + useEffect(() => { + if (testNotificationConfigEditData) { + setTestNotificationConfigEditDataPost( + (prevSetTestNotificationConfigDataPost) => ({ + ...prevSetTestNotificationConfigDataPost, + formName: testNotificationConfigEditData.formName, + formMethod: testNotificationConfigEditData.formMethod, + cancelAction: testNotificationConfigEditData.cancelAction, + submitOnCancel: testNotificationConfigEditData.submitOnCancel, + cancelMethod: testNotificationConfigEditData.cancelMethod, + config: testNotificationConfigEditData.config, + systemDefaultPayloadTemplate: + testNotificationConfigEditData.systemDefaultPayloadTemplate, + editSystemDefaultPayloadTemplate: + testNotificationConfigEditData.editSystemDefaultPayloadTemplate, + }), + ); + } + }, [testNotificationConfigEditData]); + + const handleMenuItems = (res) => { + if (res) { + setTestNotificationConfigEditData(res); + } + setLoading(false); + }; + + const handleTestNamesList = (res) => { + if (res) { + setTestNamesList(res); + } + setLoading(false); + }; + + useEffect(() => { + componentMounted.current = true; + getFromOpenElisServer( + `/rest/TestNotificationConfig?testId=${ID}`, + handleMenuItems, + ); + getFromOpenElisServer(`/rest/test-list`, handleTestNamesList); + return () => { + componentMounted.current = false; + }; + }, [ID]); + + useEffect(() => { + const testId = testNotificationConfigEditData?.config?.testId; + if (testNamesList && testId) { + const test = testNamesList.find((item) => item.id === testId); + if (test) { + setTestName(test.value); + } + } + }, [testNamesList, testNotificationConfigEditData]); + + function handleSubjectTemplateChange(e) { + setTestNotificationConfigEditDataPost((prev) => ({ + ...prev, + editSystemDefaultPayloadTemplate: true, + })); + setTestNotificationConfigEditDataPost((prev) => ({ + ...prev, + systemDefaultPayloadTemplate: { + ...prev.systemDefaultPayloadTemplate, + subjectTemplate: e.target.value, + }, + })); + } + + function handleMessageTemplateChange(e) { + setTestNotificationConfigEditDataPost((prev) => ({ + ...prev, + editSystemDefaultPayloadTemplate: true, + })); + setTestNotificationConfigEditDataPost((prev) => ({ + ...prev, + systemDefaultPayloadTemplate: { + ...prev.systemDefaultPayloadTemplate, + messageTemplate: e.target.value, + }, + })); + } + + const handleCheckboxChange = (e) => { + const { id, checked } = e.target; + + setTestNotificationConfigEditDataPost((prev) => { + const updatedConfig = { ...prev.config }; + + switch (id) { + case "providerEmail": + updatedConfig.providerEmail.active = checked; + break; + case "patientEmail": + updatedConfig.patientEmail.active = checked; + break; + case "patientSMS": + updatedConfig.patientSMS.active = checked; + break; + case "providerSMS": + updatedConfig.providerSMS.active = checked; + break; + default: + break; + } + + return { + ...prev, + config: updatedConfig, + }; + }); + }; + + function testNotificationConfigEditSavePostCall() { + setLoading(true); + postToOpenElisServerJsonResponse( + `/rest/TestNotificationConfig`, + JSON.stringify(testNotificationConfigEditDataPost), + (res) => { + testNotificationConfigEditSavePostCallBack(res); + }, + ); + } + + function testNotificationConfigEditSavePostCallBack(res) { + if (res) { + addNotification({ + title: intl.formatMessage({ + id: "notification.title", + }), + message: intl.formatMessage({ + id: "notification.user.post.save.success", + }), + kind: NotificationKinds.success, + }); + setNotificationVisible(true); + } else { + addNotification({ + kind: NotificationKinds.error, + title: intl.formatMessage({ id: "notification.title" }), + message: intl.formatMessage({ id: "server.error.msg" }), + }); + setNotificationVisible(true); + } + setLoading(false); + } + + return ( + <> + {notificationVisible === true ? : ""} + {loading && } +
+ + + +
+
+ + + +
+
+
+
+
+ + +
+
+ + {testName && } + +
+
+
+
+
+
+ {testNotificationConfigEditDataPost?.config && ( + + + + } + checked={ + testNotificationConfigEditDataPost.config.patientEmail + ?.active ?? false + } + onChange={handleCheckboxChange} + /> + + + + } + checked={ + testNotificationConfigEditDataPost.config.patientSMS + ?.active ?? false + } + onChange={handleCheckboxChange} + /> + + + + } + checked={ + testNotificationConfigEditDataPost.config.providerSMS + ?.active ?? false + } + onChange={handleCheckboxChange} + /> + + + + } + checked={ + testNotificationConfigEditDataPost.config.providerEmail + ?.active ?? false + } + onChange={handleCheckboxChange} + /> + + + )} +
+
+
+ + +
+
+ + + +
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+ + + +
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+
+
+ + +
+
+
+ + + +
+
+
+
+ + + +
+
+ + + + + + handleSubjectTemplateChange(e)} + /> + + +
+ + + + + +
+ + +