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

Update report generation #615

Merged
merged 2 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
Loading