Skip to content

Commit

Permalink
Merge pull request #638 from mozzy11/2.8
Browse files Browse the repository at this point in the history
Generated reports should be saved by default
  • Loading branch information
mozzy11 authored Dec 7, 2023
2 parents c5f5941 + 20a2939 commit d26493d
Show file tree
Hide file tree
Showing 6 changed files with 178 additions and 85 deletions.
84 changes: 58 additions & 26 deletions frontend/src/components/cytology/CytologyCaseView.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ function CytologyCaseView() {
const [reportParams, setReportParams] = useState({
0: {
submited: false,
}});
reportLink: "",
},
});

const handleConfirm = () => {
var diagnosis = { ...pathologySampleInfo.diagnosis };
Expand Down Expand Up @@ -183,7 +185,7 @@ function CytologyCaseView() {
}
}

const reportStatus = (pdfGenerated, index) => {
const reportStatus = async (pdfGenerated, blob, index) => {
setNotificationVisible(true);
setLoadingReport(false);
if (pdfGenerated) {
Expand All @@ -197,7 +199,18 @@ function CytologyCaseView() {
params[index] = {};
}
params[index].submited = true;
params[index].reportLink = window.URL.createObjectURL(blob, {
type: "application/pdf",
});
setReportParams(params);

var newReports = [...pathologySampleInfo.reports];
let encodedFile = await toBase64(blob);
newReports[index].base64Image = encodedFile;
setPathologySampleInfo({
...pathologySampleInfo,
reports: newReports,
});
} else {
setNotificationBody({
kind: NotificationKinds.error,
Expand Down Expand Up @@ -868,7 +881,7 @@ function CytologyCaseView() {
iconDescription="file upload"
multiple={false}
accept={["image/jpeg", "image/png", "application/pdf"]}
disabled={false}
disabled={reportParams[index]?.submited}
name=""
buttonKind="primary"
size="lg"
Expand Down Expand Up @@ -899,30 +912,49 @@ function CytologyCaseView() {
}
</h6>
</Column>
<Column lg={2} md={1} sm={2}>
{pathologySampleInfo.reports[index].image && (
<>
<Button
onClick={() => {
var win = window.open();
win.document.write(
'<iframe src="' +
report.fileType +
";base64," +
report.image +
'" frameborder="0" style="border:0; top:0px; left:0px; bottom:0px; right:0px; width:100%; height:100%;" allowfullscreen></iframe>',
);
}}
>
<Launch />{" "}
<FormattedMessage id="pathology.label.view" />
</Button>
</>
)}
</Column>

{pathologySampleInfo.reports[index].image && (
<>
{!reportParams[index]?.submited && (
<Column lg={2} md={1} sm={2}>
<Button
onClick={() => {
var win = window.open();
win.document.write(
'<iframe src="' +
report.fileType +
";base64," +
report.image +
'" frameborder="0" style="border:0; top:0px; left:0px; bottom:0px; right:0px; width:100%; height:100%;" allowfullscreen></iframe>',
);
}}
>
<Launch />{" "}
<FormattedMessage id="pathology.label.view" />
</Button>
</Column>
)}
</>
)}

{reportParams[index]?.submited && (
<Column lg={2} md={1} sm={2}>
<Button
onClick={() => {
window.open(
reportParams[index]?.reportLink,
"_blank",
);
}}
>
<Launch />{" "}
<FormattedMessage id="pathology.label.view" />
</Button>
</Column>
)}
<Column lg={3} md={2} sm={2}>
<Button
disabled={reportParams[index]?.submited}
disabled={reportParams[index]?.submited}
id={"generate_report_" + index}
onClick={(e) => {
setLoadingReport(true);
Expand All @@ -933,7 +965,7 @@ function CytologyCaseView() {
postToOpenElisServerForPDF(
"/rest/ReportPrint",
JSON.stringify(form),
(e) => reportStatus(e, index),
(e, blob) => reportStatus(e, blob, index),
);
}}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ function ImmunohistochemistryCaseView() {
numberOfcancerNuclei: "",
toggled: false,
submited: false,
reportLink: "",
},
});

Expand Down Expand Up @@ -167,7 +168,7 @@ function ImmunohistochemistryCaseView() {
}
}

const reportStatus = (pdfGenerated, index) => {
const reportStatus = async (pdfGenerated, blob, index) => {
setNotificationVisible(true);
setLoadingReport(false);
if (pdfGenerated) {
Expand All @@ -182,7 +183,19 @@ function ImmunohistochemistryCaseView() {
}
params[index].submited = true;
params[index].toggled = false;
params[index].reportLink = window.URL.createObjectURL(blob, {
type: "application/pdf",
});
setReportParams(params);

var newReports = [...immunohistochemistrySampleInfo.reports];
let encodedFile = await toBase64(blob);
newReports[index].base64Image = encodedFile;

setImmunohistochemistrySampleInfo({
...immunohistochemistrySampleInfo,
reports: newReports,
});
} else {
setNotificationBody({
kind: NotificationKinds.error,
Expand Down Expand Up @@ -247,7 +260,6 @@ function ImmunohistochemistryCaseView() {
id={"erIntensity_" + index}
name="status"
labelText=""

value={reportParams[index]?.erIntensity}
onChange={(e) => {
var params = { ...reportParams };
Expand Down Expand Up @@ -509,7 +521,7 @@ function ImmunohistochemistryCaseView() {
<FormattedMessage id="immunohistochemistry.label.molecularType" />
</Column>
<Column lg={13} md={8} sm={4}>
<Select
<Select
id={"molecularSubType_" + index}
name="molecularSubType"
labelText=""
Expand Down Expand Up @@ -1128,7 +1140,7 @@ function ImmunohistochemistryCaseView() {
"image/png",
"application/pdf",
]}
disabled={false}
disabled={reportParams[index]?.submited}
name=""
buttonKind="primary"
size="lg"
Expand Down Expand Up @@ -1161,31 +1173,49 @@ function ImmunohistochemistryCaseView() {
}
</h6>
</Column>
<Column lg={2} md={1} sm={2}>
{immunohistochemistrySampleInfo.reports[index]
.image && (
<>
<Button
onClick={() => {
var win = window.open();
win.document.write(
'<iframe src="' +
report.fileType +
";base64," +
report.image +
'" frameborder="0" style="border:0; top:0px; left:0px; bottom:0px; right:0px; width:100%; height:100%;" allowfullscreen></iframe>',
);
}}
>
<Launch />{" "}
<FormattedMessage id="pathology.label.view" />
</Button>
</>
)}
</Column>

{immunohistochemistrySampleInfo.reports[index].image && (
<>
{!reportParams[index]?.submited && (
<Column lg={2} md={1} sm={2}>
<Button
onClick={() => {
var win = window.open();
win.document.write(
'<iframe src="' +
report.fileType +
";base64," +
report.image +
'" frameborder="0" style="border:0; top:0px; left:0px; bottom:0px; right:0px; width:100%; height:100%;" allowfullscreen></iframe>',
);
}}
>
<Launch />{" "}
<FormattedMessage id="pathology.label.view" />
</Button>
</Column>
)}
</>
)}
{reportParams[index]?.submited && (
<Column lg={2} md={1} sm={2}>
<Button
onClick={() => {
window.open(
reportParams[index]?.reportLink,
"_blank")

}}
>
<Launch />{" "}
<FormattedMessage id="pathology.label.view" />
</Button>
</Column>
)}

<Column lg={3} md={2} sm={2}>
<Button
disabled={reportParams[index]?.submited}
disabled={reportParams[index]?.submited}
onClick={(e) => {
setLoadingReport(true);
const form = {
Expand Down Expand Up @@ -1215,7 +1245,7 @@ function ImmunohistochemistryCaseView() {
postToOpenElisServerForPDF(
"/rest/ReportPrint",
JSON.stringify(form),
(e) => reportStatus(e, index),
(e, blob) => reportStatus(e, blob, index),
);
}}
>
Expand Down
Loading

0 comments on commit d26493d

Please sign in to comment.