Skip to content

Commit

Permalink
Merge pull request #615 from mozzy11/2.8
Browse files Browse the repository at this point in the history
Update report generation
  • Loading branch information
mozzy11 authored Nov 27, 2023
2 parents c0656ac + 0fa6ed3 commit 0c203de
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 54 deletions.
22 changes: 6 additions & 16 deletions frontend/src/components/cytology/CytologyCaseView.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { Launch, Subtract } from "@carbon/react/icons";
import {
getFromOpenElisServer,
postToOpenElisServerFullResponse,
postToOpenElisServerForPDF,
hasRole,
} from "../utils/Utils";
import UserSessionDetailsContext from "../../UserSessionDetailsContext";
Expand Down Expand Up @@ -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: <FormattedMessage id="notification.title" />,
message: "Succesfuly Generated Report",
});

var win = window.open();
win.document.write(
'<iframe src="' +
url +
'" frameborder="0" style="border:0; top:0px; left:0px; bottom:0px; right:0px; width:100%; height:100%;" allowfullscreen></iframe>',
);
} else {
setNotificationBody({
kind: NotificationKinds.error,
Expand Down Expand Up @@ -895,10 +885,10 @@ function CytologyCaseView() {
report: "PatientCytologyReport",
programSampleId: cytologySampleId,
};
postToOpenElisServerFullResponse(
postToOpenElisServerForPDF(
"/rest/ReportPrint",
JSON.stringify(form),
writeReport,
reportStatus,
);
}}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { Launch, Subtract } from "@carbon/react/icons";
import {
getFromOpenElisServer,
postToOpenElisServerFullResponse,
postToOpenElisServerForPDF,
hasRole,
} from "../utils/Utils";
import UserSessionDetailsContext from "../../UserSessionDetailsContext";
Expand Down Expand Up @@ -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: <FormattedMessage id="notification.title" />,
message: "Succesfuly Generated Report",
});

var win = window.open();
win.document.write(
'<iframe src="' +
url +
'" frameborder="0" style="border:0; top:0px; left:0px; bottom:0px; right:0px; width:100%; height:100%;" allowfullscreen></iframe>',
);
} else {
setNotificationBody({
kind: NotificationKinds.error,
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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
);
}}
>
Expand Down
22 changes: 6 additions & 16 deletions frontend/src/components/pathology/PathologyCaseView.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { Launch, Subtract } from "@carbon/react/icons";
import {
getFromOpenElisServer,
postToOpenElisServerFullResponse,
postToOpenElisServerForPDF,
hasRole
} from "../utils/Utils";
import UserSessionDetailsContext from "../../UserSessionDetailsContext";
Expand Down Expand Up @@ -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: <FormattedMessage id="notification.title" />,
message: "Succesfuly Generated Report",
});

var win = window.open();
win.document.write(
'<iframe src="' +
url +
'" frameborder="0" style="border:0; top:0px; left:0px; bottom:0px; right:0px; width:100%; height:100%;" allowfullscreen></iframe>',
);
} else {
setNotificationBody({
kind: NotificationKinds.error,
Expand Down Expand Up @@ -590,10 +580,10 @@ function PathologyCaseView() {
report: "PatientPathologyReport",
programSampleId: pathologySampleId,
};
postToOpenElisServerFullResponse(
postToOpenElisServerForPDF(
"/rest/ReportPrint",
JSON.stringify(form),
writeReport,
reportStatus,
);
}}
>
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/components/utils/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand All @@ -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";
Expand All @@ -151,6 +152,7 @@ export const postToOpenElisServerForPDF = (endPoint, payLoad) => {
document.body.removeChild(link);
})
.catch((error) => {
callback(false)
console.log(error);
});
};
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/languages/message_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/languages/message_fr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 0c203de

Please sign in to comment.