Skip to content

Commit

Permalink
Merge pull request #571 from mozzy11/2.8
Browse files Browse the repository at this point in the history
add IHC report
  • Loading branch information
mozzy11 authored Oct 23, 2023
2 parents 5a31630 + 0d92f07 commit 227a02a
Show file tree
Hide file tree
Showing 14 changed files with 1,343 additions and 9 deletions.
3 changes: 1 addition & 2 deletions frontend/src/components/cytology/CytologyCaseView.js
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,6 @@ function CytologyCaseView() {
</>
)}
</Column>
<Column lg={1} md={2} sm={2}/>
<Column lg={3} md={2} sm={2}>
<Button
onClick={(e) => {
Expand All @@ -865,7 +864,7 @@ function CytologyCaseView() {
<FormattedMessage id="button.label.genarateReport" />
</Button>
</Column>
<Column lg={3} md={2} sm={2}/>
<Column lg={4} md={2} sm={2}/>
<Column lg={16} md={8} sm={4}>
<div> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div>
</Column>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ function ImmunohistochemistryCaseView() {
</IconButton>
</Column>

<Column lg={3} md={1} sm={2}>
<Column lg={2} md={1} sm={2}>
<FileUploader
style={{ marginTop: "-30px" }}
buttonLabel={
Expand Down Expand Up @@ -560,7 +560,7 @@ function ImmunohistochemistryCaseView() {
}}
/>
</Column>
<Column lg={4}>
<Column lg={2}>
{
reportTypes.filter(
(type) => type.id === report.reportType,
Expand Down Expand Up @@ -589,7 +589,22 @@ function ImmunohistochemistryCaseView() {
</>
)}
</Column>
<Column lg={3} md={5} sm={3} />
<Column lg={3} md={2} sm={2}>
<Button
onClick={(e) => {
window.open(
config.serverBaseUrl +
"/rest/ReportPrint?report=PatientImmunoChemistryReport&programSampleId=" +
immunohistochemistrySampleId,
"_blank",
);
}}
>
{" "}
<FormattedMessage id="button.label.genarateReport" />
</Button>
</Column>
<Column lg={5} md={2} sm={2}/>
<Column lg={16} md={8} sm={4}>
<div> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div>
</Column>
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/components/pathology/PathologyCaseView.js
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,6 @@ function PathologyCaseView() {
</>
)}
</Column>
<Column lg={1} md={2} sm={2}/>
<Column lg={3} md={2} sm={2}>
<Button
onClick={(e) => {
Expand All @@ -562,7 +561,7 @@ function PathologyCaseView() {
<FormattedMessage id="button.label.genarateReport" />
</Button>
</Column>
<Column lg={3} md={2} sm={2}/>
<Column lg={4} md={2} sm={2}/>
<Column lg={16} md={8} sm={4}>
<div> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div>
</Column>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
package org.openelisglobal.reports.action.implementation;

import org.openelisglobal.program.service.ImmunohistochemistrySampleService;
import org.openelisglobal.program.valueholder.immunohistochemistry.ImmunohistochemistrySample;
import org.openelisglobal.reports.action.implementation.reportBeans.ProgramSampleReportData;
import org.openelisglobal.reports.form.ReportForm;
import org.openelisglobal.result.service.ResultService;
import org.openelisglobal.result.valueholder.Result;
import org.openelisglobal.spring.util.SpringContext;
import org.openelisglobal.test.service.TestServiceImpl;
import org.openelisglobal.typeoftestresult.service.TypeOfTestResultServiceImpl;


import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.apache.commons.validator.GenericValidator;
import org.openelisglobal.analysis.valueholder.Analysis;
import org.openelisglobal.common.services.IStatusService;
import org.openelisglobal.common.services.StatusService.AnalysisStatus;
import org.openelisglobal.dictionary.valueholder.Dictionary;

public class PatientImmunoChemistryReport extends PatientProgramReport{

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

private ImmunohistochemistrySample immunohistochemistrySample;


private static Set<Integer> analysisStatusIds;

static {
analysisStatusIds = new HashSet<>();
analysisStatusIds.add(Integer
.parseInt(SpringContext.getBean(IStatusService.class).getStatusID(AnalysisStatus.BiologistRejected)));
analysisStatusIds.add(
Integer.parseInt(SpringContext.getBean(IStatusService.class).getStatusID(AnalysisStatus.Finalized)));
analysisStatusIds.add(Integer.parseInt(
SpringContext.getBean(IStatusService.class).getStatusID(AnalysisStatus.NonConforming_depricated)));
analysisStatusIds.add(
Integer.parseInt(SpringContext.getBean(IStatusService.class).getStatusID(AnalysisStatus.NotStarted)));
analysisStatusIds.add(Integer
.parseInt(SpringContext.getBean(IStatusService.class).getStatusID(AnalysisStatus.TechnicalAcceptance)));
analysisStatusIds.add(
Integer.parseInt(SpringContext.getBean(IStatusService.class).getStatusID(AnalysisStatus.Canceled)));
analysisStatusIds.add(Integer
.parseInt(SpringContext.getBean(IStatusService.class).getStatusID(AnalysisStatus.TechnicalRejected)));

}

@Override
protected String getReportName() {
return "PatientImmunoChemistryReport";
}

@Override
protected void setAdditionalReportItems() {
List<Analysis> analyses = analysisService.getAnalysesBySampleIdAndStatusId(sampleService.getId(sample) ,analysisStatusIds);

List<ProgramSampleReportData.Result> resultsData = new ArrayList<>();
analyses.forEach(analysis -> {
ProgramSampleReportData.Result resultData = new ProgramSampleReportData.Result();
resultData.setTest(TestServiceImpl.getUserLocalizedReportingTestName(analysis.getTest()));
List<Result> resultList = analysisService.getResults(analysis);
setAppropriateResults(resultList ,resultData);
resultData.setUom(getUnitOfMeasure(analysis.getTest()));
resultsData.add(resultData);
});
data.setResults(resultsData);
}

@Override
protected void innitializeSample(ReportForm form) {
immunohistochemistrySample = immunohistochemistrySampleService.get(Integer.valueOf(form.getProgramSampleId()));
sample = immunohistochemistrySample.getSample();
}

private void setAppropriateResults(List<Result> resultList ,ProgramSampleReportData.Result resultData) {
String reportResult = "";
if (!resultList.isEmpty()) {

// If only one result just get it and get out
if (resultList.size() == 1) {
Result result = resultList.get(0);
if (TypeOfTestResultServiceImpl.ResultType.isDictionaryVariant(result.getResultType())) {
Dictionary dictionary = new Dictionary();
dictionary.setId(result.getValue());
dictionaryService.getData(dictionary);


if (result.getAnalyte() != null && "Conclusion".equals(result.getAnalyte().getAnalyteName())) {
currentConclusion = dictionary.getId() != null ? dictionary.getLocalizedName() : "";
} else {
reportResult = dictionary.getId() != null ? dictionary.getLocalizedName() : "";
}
} else {
ResultService resultResultService = SpringContext.getBean(ResultService.class);
reportResult = resultResultService.getResultValue(result, true);

}
} else {
// If multiple results it can be a quantified result, multiple
// results with quantified other results or it can be a
// conclusion
ResultService resultResultService = SpringContext.getBean(ResultService.class);
Result result = resultList.get(0);

if (TypeOfTestResultServiceImpl.ResultType.DICTIONARY
.matches(resultResultService.getTestType(result))) {
// data.setAbnormalResult(resultResultService.isAbnormalDictionaryResult(result));
List<Result> dictionaryResults = new ArrayList<>();
Result quantification = null;
for (Result sibResult : resultList) {
if (TypeOfTestResultServiceImpl.ResultType.DICTIONARY.matches(sibResult.getResultType())) {
dictionaryResults.add(sibResult);
} else if (TypeOfTestResultServiceImpl.ResultType.ALPHA.matches(sibResult.getResultType())
&& sibResult.getParentResult() != null) {
quantification = sibResult;
}
}

Dictionary dictionary = new Dictionary();
for (Result sibResult : dictionaryResults) {
dictionary.setId(sibResult.getValue());
dictionaryService.getData(dictionary);
if (sibResult.getAnalyte() != null
&& "Conclusion".equals(sibResult.getAnalyte().getAnalyteName())) {
currentConclusion = dictionary.getId() != null ? dictionary.getLocalizedName() : "";
} else {
reportResult = dictionary.getId() != null ? dictionary.getLocalizedName() : "";
if (quantification != null
&& quantification.getParentResult().getId().equals(sibResult.getId())) {
reportResult += ": " + quantification.getValue(true);
}
}
}
} else if (TypeOfTestResultServiceImpl.ResultType
.isMultiSelectVariant(resultResultService.getTestType(result))) {
Dictionary dictionary = new Dictionary();
StringBuilder multiResult = new StringBuilder();

Collections.sort(resultList, new Comparator<Result>() {
@Override
public int compare(Result o1, Result o2) {
if (o1.getGrouping() == o2.getGrouping()) {
return Integer.parseInt(o1.getId()) - Integer.parseInt(o2.getId());
} else {
return o1.getGrouping() - o2.getGrouping();
}
}
});

Result quantifiedResult = null;
for (Result subResult : resultList) {
if (TypeOfTestResultServiceImpl.ResultType.ALPHA.matches(subResult.getResultType())) {
quantifiedResult = subResult;
resultList.remove(subResult);
break;
}
}
int currentGrouping = resultList.get(0).getGrouping();
for (Result subResult : resultList) {
if (subResult.getGrouping() != currentGrouping) {
currentGrouping = subResult.getGrouping();
multiResult.append("-------\n");
}
dictionary.setId(subResult.getValue());
dictionaryService.getData(dictionary);

if (dictionary.getId() != null) {
multiResult.append(dictionary.getLocalizedName());
if (quantifiedResult != null
&& quantifiedResult.getParentResult().getId().equals(subResult.getId())
&& !GenericValidator.isBlankOrNull(quantifiedResult.getValue())) {
multiResult.append(": ");
multiResult.append(quantifiedResult.getValue(true));
}
multiResult.append("\n");
}
}

if (multiResult.length() > 1) {
// remove last "\n"
multiResult.setLength(multiResult.length() - 1);
}

reportResult = multiResult.toString();
}
}
}
resultData.setResult(reportResult);

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
public class PatientPathologyReport extends PatientProgramReport{
protected PathologyDisplayService pathologyDisplayService = SpringContext.getBean(PathologyDisplayService.class);

private PathologySample pathologySample;
private PathologySample pathologySample;

@Override
protected String getReportName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
import org.openelisglobal.sampleitem.valueholder.SampleItem;
import org.openelisglobal.spring.util.SpringContext;
import org.openelisglobal.test.service.TestServiceImpl;
import org.openelisglobal.test.valueholder.Test;

import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
Expand Down Expand Up @@ -372,6 +373,10 @@ protected void setPatientName(ProgramSampleReportData data) {
data.setLastName(patientService.getLastName(patient));
}

protected String getUnitOfMeasure(Test test) {
return (test != null && test.getUnitOfMeasure() != null) ? test.getUnitOfMeasure().getName() : "";
}

protected String getLazyPatientIdentity(Patient patient, String identity, String id) {
if (identity == null) {
identity = " ";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,8 @@ else if (report.equals("covidResultsReport")) {
}
else if(report.equals("PatientCytologyReport")){
return new PatientCytologyReport();
}else if(report.equals("PatientImmunoChemistryReport")){
return new PatientImmunoChemistryReport();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ public final class ProgramSampleReportData {

private List<String> otherDiagnoses;

//ImmunoHistoChemistry data
private List<Result> results;

public ProgramSampleReportData() {
}

Expand Down Expand Up @@ -642,4 +645,46 @@ public List<String> getOtherDiagnoses() {
public void setOtherDiagnoses(List<String> otherDiagnoses) {
this.otherDiagnoses = otherDiagnoses;
}

public List<Result> getResults() {
return results;
}

public void setResults(List<Result> results) {
this.results = results;
}

public static class Result {

private String result;

private String test;

private String uom;

public String getResult() {
return result;
}

public void setResult(String result) {
this.result = result;
}

public String getTest() {
return test;
}

public void setTest(String test) {
this.test = test;
}

public String getUom() {
return uom;
}

public void setUom(String uom) {
this.uom = uom;
}

}
}
4 changes: 4 additions & 0 deletions src/main/resources/languages/message_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7826,5 +7826,9 @@ cytology.label.papsmear = PAP SMEAR REPORT
cytology.label.negative = Negative For Intraepithelial Lesion or Malignancy
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
immunochemmistry.label.report = ImmunoHistoChemistry Report


6 changes: 5 additions & 1 deletion src/main/resources/languages/message_fr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7322,6 +7322,10 @@ cytology.label.organisms = Organismes
cytology.label.otherResult = Autre résultat de diagnostic
cytology.label.diagnosis = Diagnostic/Impression
cytology.label.papsmear = Rapport du frottis de PAP
cytology.label.negative=Négatif pour lésion intraépithéliale ou malignité
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.report = Rapport d'immunohistochimie
Binary file not shown.
Loading

0 comments on commit 227a02a

Please sign in to comment.