Skip to content

Commit

Permalink
Merge pull request #572 from mozzy11/2.8
Browse files Browse the repository at this point in the history
update HistoChemistry report
  • Loading branch information
mozzy11 authored Oct 24, 2023
2 parents 227a02a + 75a33c0 commit d1fee0f
Show file tree
Hide file tree
Showing 8 changed files with 211 additions and 57 deletions.
48 changes: 43 additions & 5 deletions frontend/src/components/cytology/CytologyCaseView.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
Loading,
RadioButtonGroup,
RadioButton,
InlineLoading
} from "@carbon/react";
import { Launch, Subtract } from "@carbon/react/icons";
import {
Expand Down Expand Up @@ -135,6 +136,7 @@ function CytologyCaseView() {
const [technicianUsers, setTechnicianUsers] = useState([]);
const [pathologistUsers, setPathologistUsers] = useState([]);
const [loading, setLoading] = useState(true);
const [loadingReport, setLoadingReport] = useState(false);
const [reportTypes, setReportTypes] = useState([]);
const intl = useIntl();
const [slidesToAdd, setSlidesToAdd] = useState(1);
Expand Down Expand Up @@ -163,6 +165,36 @@ 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;
setNotificationVisible(true);
if (status == "200") {
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,
title: <FormattedMessage id="notification.title" />,
message: "Error while Generating Report",
});
}
}


const toBase64 = (file) =>
new Promise((resolve, reject) => {
const reader = new FileReader();
Expand Down Expand Up @@ -768,6 +800,7 @@ function CytologyCaseView() {
{" "}
<FormattedMessage id="immunohistochemistry.label.reports" />
</h5>
{loadingReport && <InlineLoading />}
<div> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div>
</Column>
{pathologySampleInfo.reports &&
Expand Down Expand Up @@ -851,12 +884,17 @@ function CytologyCaseView() {
</Column>
<Column lg={3} md={2} sm={2}>
<Button
id ={"generate_report_"+index}
onClick={(e) => {
window.open(
config.serverBaseUrl +
"/rest/ReportPrint?report=PatientCytologyReport&programSampleId=" +
cytologySampleId,
"_blank",
setLoadingReport(true);
const form = {
report: "PatientCytologyReport",
programSampleId: cytologySampleId,
};
postToOpenElisServerFullResponse(
"/rest/ReportPrint",
JSON.stringify(form),
writeReport,
);
}}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
BreadcrumbItem,
Stack,
Loading,
InlineLoading
} from "@carbon/react";
import { Launch, Subtract } from "@carbon/react/icons";
import {
Expand Down Expand Up @@ -107,6 +108,7 @@ function ImmunohistochemistryCaseView() {
const [results, setResults] = useState({ testResult: [] });
const [loading, setLoading] = useState(true);
const [resultsLoading, setResultsLoading] = useState(true);
const [loadingReport, setLoadingReport] = useState(false);
const intl = useIntl();
async function displayStatus(response) {
var body = await response.json();
Expand All @@ -132,6 +134,36 @@ 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;
setNotificationVisible(true);
setLoadingReport(false)
if (status == "200") {
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,
title: <FormattedMessage id="notification.title" />,
message: "Error while Generating Report",
});
}
}


const setResultsWithId = (results) => {
if (results) {
var i = 0;
Expand Down Expand Up @@ -499,6 +531,7 @@ function ImmunohistochemistryCaseView() {
{" "}
<FormattedMessage id="immunohistochemistry.label.reports" />
</h5>
{loadingReport && <InlineLoading />}
</Column>
<Column lg={16} md={8} sm={4}>
<div> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div>
Expand Down Expand Up @@ -592,14 +625,18 @@ function ImmunohistochemistryCaseView() {
<Column lg={3} md={2} sm={2}>
<Button
onClick={(e) => {
window.open(
config.serverBaseUrl +
"/rest/ReportPrint?report=PatientImmunoChemistryReport&programSampleId=" +
immunohistochemistrySampleId,
"_blank",
setLoadingReport(true);
const form = {
report: "PatientImmunoChemistryReport",
programSampleId: immunohistochemistrySampleId,
};
postToOpenElisServerFullResponse(
"/rest/ReportPrint",
JSON.stringify(form),
writeReport,
);
}}
>
>
{" "}
<FormattedMessage id="button.label.genarateReport" />
</Button>
Expand Down
48 changes: 42 additions & 6 deletions frontend/src/components/pathology/PathologyCaseView.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ import {
Breadcrumb,
BreadcrumbItem,
Loading,
InlineLoading,
Row,
} from "@carbon/react";
import { Launch, Subtract } from "@carbon/react/icons";
import {
getFromOpenElisServer,
postToOpenElisServerFullResponse,
hasRole,
hasRole
} from "../utils/Utils";
import UserSessionDetailsContext from "../../UserSessionDetailsContext";
import { NotificationContext } from "../layout/Layout";
Expand Down Expand Up @@ -122,6 +123,7 @@ function PathologyCaseView() {
const [loading, setLoading] = useState(true);
const [blocksToAdd, setBlocksToAdd] = useState(1);
const [slidesToAdd, setSlidesToAdd] = useState(1);
const [loadingReport, setLoadingReport] = useState(false);


async function displayStatus(response) {
Expand All @@ -148,6 +150,35 @@ 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);
setNotificationVisible(true);
if (status == "200") {
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,
title: <FormattedMessage id="notification.title" />,
message: "Error while Generating Report",
});
}
}

const toBase64 = (file) =>
new Promise((resolve, reject) => {
const reader = new FileReader();
Expand Down Expand Up @@ -468,6 +499,7 @@ function PathologyCaseView() {
{" "}
<FormattedMessage id="immunohistochemistry.label.reports" />
</h5>
{loadingReport && <InlineLoading />}
<div> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div>
</Column>

Expand Down Expand Up @@ -549,11 +581,15 @@ function PathologyCaseView() {
<Column lg={3} md={2} sm={2}>
<Button
onClick={(e) => {
window.open(
config.serverBaseUrl +
"/rest/ReportPrint?report=PatientPathologyReport&programSampleId=" +
pathologySampleId,
"_blank",
setLoadingReport(true);
const form = {
report: "PatientPathologyReport",
programSampleId: pathologySampleId,
};
postToOpenElisServerFullResponse(
"/rest/ReportPrint",
JSON.stringify(form),
writeReport,
);
}}
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package org.openelisglobal.reports.action.implementation;

import org.openelisglobal.program.service.ImmunohistochemistrySampleService;
import org.openelisglobal.program.service.PathologyDisplayService;
import org.openelisglobal.program.valueholder.immunohistochemistry.ImmunohistochemistrySample;
import org.openelisglobal.program.valueholder.pathology.PathologyConclusion;
import org.openelisglobal.program.valueholder.pathology.PathologySample;
import org.openelisglobal.program.valueholder.pathology.PathologyConclusion.ConclusionType;
import org.openelisglobal.reports.action.implementation.reportBeans.ProgramSampleReportData;
import org.openelisglobal.reports.form.ReportForm;
import org.openelisglobal.result.service.ResultService;
Expand All @@ -16,6 +20,7 @@
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;

import org.apache.commons.validator.GenericValidator;
Expand All @@ -27,7 +32,7 @@
public class PatientImmunoChemistryReport extends PatientProgramReport{

protected ImmunohistochemistrySampleService immunohistochemistrySampleService = SpringContext.getBean(ImmunohistochemistrySampleService.class);

protected PathologyDisplayService pathologyDisplayService = SpringContext.getBean(PathologyDisplayService.class);
private ImmunohistochemistrySample immunohistochemistrySample;


Expand Down Expand Up @@ -71,6 +76,13 @@ protected void setAdditionalReportItems() {
resultsData.add(resultData);
});
data.setResults(resultsData);

if(immunohistochemistrySample.getPathologySample() != null){
PathologySample pathologySample = pathologyDisplayService.getPathologySampleWithLoadedAtttributes(immunohistochemistrySample.getPathologySample().getId());
Optional<PathologyConclusion> conclusion = pathologySample.getConclusions().stream()
.filter(e -> e.getType() == ConclusionType.TEXT).findFirst();
data.setTextConclusion(conclusion.get().getValue());
}
}

@Override
Expand Down
Loading

0 comments on commit d1fee0f

Please sign in to comment.