From ccc1d7a5afd68c92ec988030cc2d951f482eb47a Mon Sep 17 00:00:00 2001 From: Mutesasira Moses Date: Mon, 27 Nov 2023 15:01:07 +0300 Subject: [PATCH 1/2] update report generation for programms --- .../components/cytology/CytologyCaseView.js | 22 +++++----------- .../ImmunohistochemistryCaseView.js | 26 ++++++------------- .../components/pathology/PathologyCaseView.js | 22 +++++----------- frontend/src/components/utils/Utils.js | 4 ++- 4 files changed, 23 insertions(+), 51 deletions(-) diff --git a/frontend/src/components/cytology/CytologyCaseView.js b/frontend/src/components/cytology/CytologyCaseView.js index 0884e2cfbd..11ee86f2a2 100644 --- a/frontend/src/components/cytology/CytologyCaseView.js +++ b/frontend/src/components/cytology/CytologyCaseView.js @@ -26,6 +26,7 @@ import { Launch, Subtract } from "@carbon/react/icons"; import { getFromOpenElisServer, postToOpenElisServerFullResponse, + postToOpenElisServerForPDF, hasRole, } from "../utils/Utils"; import UserSessionDetailsContext from "../../UserSessionDetailsContext"; @@ -165,26 +166,15 @@ function CytologyCaseView() { } } - async function writeReport(response) { - var report = await response.blob(); - const url = URL.createObjectURL(report); - setLoadingReport(false) - console.log(JSON.stringify(report)); - var status = response.status; + const reportStatus = (pdfGenerated) => { setNotificationVisible(true); - if (status == "200") { + setLoadingReport(false) + if (pdfGenerated) { setNotificationBody({ kind: NotificationKinds.success, title: , message: "Succesfuly Generated Report", }); - - var win = window.open(); - win.document.write( - '', - ); } else { setNotificationBody({ kind: NotificationKinds.error, @@ -895,10 +885,10 @@ function CytologyCaseView() { report: "PatientCytologyReport", programSampleId: cytologySampleId, }; - postToOpenElisServerFullResponse( + postToOpenElisServerForPDF( "/rest/ReportPrint", JSON.stringify(form), - writeReport, + reportStatus, ); }} > diff --git a/frontend/src/components/immunohistochemistry/ImmunohistochemistryCaseView.js b/frontend/src/components/immunohistochemistry/ImmunohistochemistryCaseView.js index fddcc332f7..d02a594ce0 100644 --- a/frontend/src/components/immunohistochemistry/ImmunohistochemistryCaseView.js +++ b/frontend/src/components/immunohistochemistry/ImmunohistochemistryCaseView.js @@ -26,6 +26,7 @@ import { Launch, Subtract } from "@carbon/react/icons"; import { getFromOpenElisServer, postToOpenElisServerFullResponse, + postToOpenElisServerForPDF, hasRole, } from "../utils/Utils"; import UserSessionDetailsContext from "../../UserSessionDetailsContext"; @@ -160,26 +161,15 @@ function ImmunohistochemistryCaseView() { } } - async function writeReport(response) { - var report = await response.blob(); - const url = URL.createObjectURL(report); - console.log(JSON.stringify(report)); - var status = response.status; + const reportStatus = (pdfGenerated) => { setNotificationVisible(true); setLoadingReport(false) - if (status == "200") { + if (pdfGenerated) { setNotificationBody({ kind: NotificationKinds.success, title: , message: "Succesfuly Generated Report", }); - - var win = window.open(); - win.document.write( - '', - ); } else { setNotificationBody({ kind: NotificationKinds.error, @@ -538,7 +528,7 @@ function ImmunohistochemistryCaseView() { var chrom = params[index].averageChrom; if(chrom){ var ratio = her2/chrom ; - params[index].ihcRatio = ratio; + params[index].ihcRatio = ratio.toFixed(2); if (ratio >= 2.0) { params[index].ihcScore = "AMPLIFICATION" }else{ @@ -572,7 +562,7 @@ function ImmunohistochemistryCaseView() { var chrom = e.target.value; if(her2){ var ratio = her2/chrom ; - params[index].ihcRatio = ratio; + params[index].ihcRatio = ratio.toFixed(2); if (ratio >= 2.0) { params[index].ihcScore = "AMPLIFICATION" }else{ @@ -1137,10 +1127,10 @@ function ImmunohistochemistryCaseView() { averageHer2: reportParams[index]?.averageHer2, numberOfcancerNuclei: reportParams[index]?.numberOfcancerNuclei, }; - postToOpenElisServerFullResponse( + postToOpenElisServerForPDF( "/rest/ReportPrint", - JSON.stringify(form), - writeReport, + JSON.stringify(form) , + reportStatus ); }} > diff --git a/frontend/src/components/pathology/PathologyCaseView.js b/frontend/src/components/pathology/PathologyCaseView.js index a58764b7dc..b9698a6e56 100644 --- a/frontend/src/components/pathology/PathologyCaseView.js +++ b/frontend/src/components/pathology/PathologyCaseView.js @@ -26,6 +26,7 @@ import { Launch, Subtract } from "@carbon/react/icons"; import { getFromOpenElisServer, postToOpenElisServerFullResponse, + postToOpenElisServerForPDF, hasRole } from "../utils/Utils"; import UserSessionDetailsContext from "../../UserSessionDetailsContext"; @@ -150,26 +151,15 @@ function PathologyCaseView() { } } - async function writeReport(response) { - var report = await response.blob(); - const url = URL.createObjectURL(report); - console.log(JSON.stringify(report)); - var status = response.status; - setLoadingReport(false); + const reportStatus = (pdfGenerated) => { setNotificationVisible(true); - if (status == "200") { + setLoadingReport(false) + if (pdfGenerated) { setNotificationBody({ kind: NotificationKinds.success, title: , message: "Succesfuly Generated Report", }); - - var win = window.open(); - win.document.write( - '', - ); } else { setNotificationBody({ kind: NotificationKinds.error, @@ -590,10 +580,10 @@ function PathologyCaseView() { report: "PatientPathologyReport", programSampleId: pathologySampleId, }; - postToOpenElisServerFullResponse( + postToOpenElisServerForPDF( "/rest/ReportPrint", JSON.stringify(form), - writeReport, + reportStatus, ); }} > diff --git a/frontend/src/components/utils/Utils.js b/frontend/src/components/utils/Utils.js index 6948eb7e9b..b317a57154 100644 --- a/frontend/src/components/utils/Utils.js +++ b/frontend/src/components/utils/Utils.js @@ -126,7 +126,7 @@ export const getFromOpenElisServerSync = (endPoint, callback) => { callback(JSON.parse(request.response)); }; -export const postToOpenElisServerForPDF = (endPoint, payLoad) => { +export const postToOpenElisServerForPDF = (endPoint, payLoad ,callback) => { fetch( config.serverBaseUrl + endPoint, @@ -143,6 +143,7 @@ export const postToOpenElisServerForPDF = (endPoint, payLoad) => { ) .then((response) => response.blob()) .then((blob) => { + callback(true) let link = document.createElement("a"); link.href = window.URL.createObjectURL(blob, { type: "application/pdf" }); link.target = "_blank"; @@ -151,6 +152,7 @@ export const postToOpenElisServerForPDF = (endPoint, payLoad) => { document.body.removeChild(link); }) .catch((error) => { + callback(false) console.log(error); }); }; From 0fa6ed3f0565825507035f2a88b223c33aee6996 Mon Sep 17 00:00:00 2001 From: Mutesasira Moses Date: Mon, 27 Nov 2023 15:04:40 +0300 Subject: [PATCH 2/2] fix typo in messages --- src/main/resources/languages/message_en.properties | 2 +- src/main/resources/languages/message_fr.properties | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/resources/languages/message_en.properties b/src/main/resources/languages/message_en.properties index ebdf4e1afd..f1ab11cc78 100644 --- a/src/main/resources/languages/message_en.properties +++ b/src/main/resources/languages/message_en.properties @@ -8217,7 +8217,7 @@ cytology.label.satisfactory = Satisfactory for evaluation cytology.label.unsatisfactory = Unsatisfactory for evaluation immunochemmistry.label.results = ImmunoHistoChemistry Results immunochemmistry.label.results.decription = In Presence of Adequate and appropriate controls ,ImmunoHistoChemical stains were perfomed. \ - The tumor cell howed the following staining profile + The tumor cell showed the following staining profile immunochemmistry.label.report = ImmunoHistoChemistry Report breastCancer.label.report = Breast Cancer Hormone Receptor Status Report dualInSitu.label.report = Dual In Situ Hybridisation (ISH) Report diff --git a/src/main/resources/languages/message_fr.properties b/src/main/resources/languages/message_fr.properties index 17dd9aa1e9..8d7d481137 100644 --- a/src/main/resources/languages/message_fr.properties +++ b/src/main/resources/languages/message_fr.properties @@ -7844,8 +7844,8 @@ cytology.label.negative= Négatif pour lésion intraépithéliale ou malignité cytology.label.satisfactory=Satisfaisant pour l'évaluation cytology.label.unsatisfactory=Insatisfaisant pour l'évaluation immunochemmistry.label.results = Résultats d'immunohistochimie -immunochemmistry.label.results.decription = En présence de contrôles adéquats et appropriés, des colorations immunohistochimiques ont été réalisées. \ - Le profil de coloration des cellules tumorales était le suivant +immunochemmistry.label.results.decription = En présence de contrôles adéquats et appropriés, des colorations immuno-histochimiques ont été réalisées. \ + Les cellules tumorales ont montré le profil de coloration suivant. immunochemmistry.label.report = Rapport d'immunohistochimie breastCancer.label.report = Rapport sur le statut des récepteurs hormonaux du cancer du sein dualInSitu.label.report = Rapport sur la double hybridation in situ (ISH)