diff --git a/frontend/src/components/pathology/PathologyCaseView.js b/frontend/src/components/pathology/PathologyCaseView.js index 15f81024da..a3df2fefb9 100644 --- a/frontend/src/components/pathology/PathologyCaseView.js +++ b/frontend/src/components/pathology/PathologyCaseView.js @@ -522,7 +522,7 @@ function PathologyCaseView() { }} /> - + @@ -546,7 +546,23 @@ function PathologyCaseView() { )} - + + + + +
           
diff --git a/frontend/src/languages/en.json b/frontend/src/languages/en.json index 718274a999..70966218d0 100644 --- a/frontend/src/languages/en.json +++ b/frontend/src/languages/en.json @@ -303,6 +303,7 @@ "label.button.remove.report": "Remove Report", "pathology.label.block.number": "Block number", "pathology.label.block.add.number": "Number of Blocks to add", - "pathology.label.slide.add.number": "Number of Slides to add" + "pathology.label.slide.add.number": "Number of Slides to add", + "button.label.genarateReport" : "Generate Report" } diff --git a/frontend/src/languages/fr.json b/frontend/src/languages/fr.json index 511384f256..3aa464e1c4 100644 --- a/frontend/src/languages/fr.json +++ b/frontend/src/languages/fr.json @@ -299,5 +299,6 @@ "label.button.remove.slide": "Supprimer la Diapositive", "label.button.remove.block": "Supprimer le Bloc", "label.button.remove.report": "Supprimer le Rapport", - "pathology.label.block.number": "Numéro du Bloc" + "pathology.label.block.number": "Numéro du Bloc" , + "button.label.genarateReport" : "Générer un rapport" } diff --git a/src/main/java/org/openelisglobal/program/service/PathologyDisplayService.java b/src/main/java/org/openelisglobal/program/service/PathologyDisplayService.java index 7c12cae078..bb5acf91dc 100644 --- a/src/main/java/org/openelisglobal/program/service/PathologyDisplayService.java +++ b/src/main/java/org/openelisglobal/program/service/PathologyDisplayService.java @@ -2,10 +2,13 @@ import org.openelisglobal.program.valueholder.pathology.PathologyCaseViewDisplayItem; import org.openelisglobal.program.valueholder.pathology.PathologyDisplayItem; +import org.openelisglobal.program.valueholder.pathology.PathologySample; public interface PathologyDisplayService { PathologyCaseViewDisplayItem convertToCaseDisplayItem(Integer pathologySampleId); PathologyDisplayItem convertToDisplayItem(Integer pathologySampleId); + + PathologySample getPathologySampleWithLoadedAtttributes(Integer pathologySampleId); } diff --git a/src/main/java/org/openelisglobal/program/service/PathologyDisplayServiceImpl.java b/src/main/java/org/openelisglobal/program/service/PathologyDisplayServiceImpl.java index 9f06193023..51e198d6d6 100644 --- a/src/main/java/org/openelisglobal/program/service/PathologyDisplayServiceImpl.java +++ b/src/main/java/org/openelisglobal/program/service/PathologyDisplayServiceImpl.java @@ -137,4 +137,14 @@ public PathologyCaseViewDisplayItem convertToCaseDisplayItem(Integer pathologySa return displayItem; } + @Override + @Transactional + public PathologySample getPathologySampleWithLoadedAtttributes(Integer pathologySampleId) { + PathologySample pathologySample = pathologySampleService.get(pathologySampleId); + pathologySample.getBlocks().size(); + pathologySample.getSlides().size(); + pathologySample.getConclusions().size(); + return pathologySample; + } + } diff --git a/src/main/java/org/openelisglobal/reports/action/implementation/PatientPathologyReport.java b/src/main/java/org/openelisglobal/reports/action/implementation/PatientPathologyReport.java new file mode 100644 index 0000000000..7dbf44f298 --- /dev/null +++ b/src/main/java/org/openelisglobal/reports/action/implementation/PatientPathologyReport.java @@ -0,0 +1,46 @@ +package org.openelisglobal.reports.action.implementation; + +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + +import org.openelisglobal.program.service.PathologyDisplayService; +import org.openelisglobal.program.valueholder.pathology.PathologyConclusion; +import org.openelisglobal.program.valueholder.pathology.PathologyConclusion.ConclusionType; +import org.openelisglobal.program.valueholder.pathology.PathologySample; +import org.openelisglobal.reports.form.ReportForm; +import org.openelisglobal.spring.util.SpringContext; + +public class PatientPathologyReport extends PatientProgramReport{ + protected PathologyDisplayService pathologyDisplayService = SpringContext.getBean(PathologyDisplayService.class); + + private PathologySample pathologySample; + + @Override + protected String getReportName() { + return "PatientPathologyReport"; + } + + @Override + protected void setAdditionalReportItems() { + data.setGrossExam(pathologySample.getGrossExam()); + data.setMicroExam(pathologySample.getMicroscopyExam()); + pathologySample.getConclusions().size(); + Optional conclusion = pathologySample.getConclusions().stream() + .filter(e -> e.getType() == ConclusionType.TEXT).findFirst(); + data.setTextConclusion(conclusion.get().getValue()); + + List codedConclusions = pathologySample.getConclusions().stream().filter(e -> e.getType() == ConclusionType.DICTIONARY) + .map(e -> dictionaryService.get(e.getValue()).getLocalizedName()) + .collect(Collectors.toList()); + String commaSeparatedString = String.join(", ", codedConclusions); + data.setCodedConclusion(commaSeparatedString); + } + + @Override + protected void innitializeSample(ReportForm form) { + pathologySample = pathologyDisplayService.getPathologySampleWithLoadedAtttributes(Integer.valueOf(form.getProgramSampleId())); + sample = pathologySample.getSample(); + } + +} diff --git a/src/main/java/org/openelisglobal/reports/action/implementation/PatientProgramReport.java b/src/main/java/org/openelisglobal/reports/action/implementation/PatientProgramReport.java new file mode 100644 index 0000000000..cae2a3b6cf --- /dev/null +++ b/src/main/java/org/openelisglobal/reports/action/implementation/PatientProgramReport.java @@ -0,0 +1,390 @@ +package org.openelisglobal.reports.action.implementation; + +import java.io.ByteArrayInputStream; +import java.sql.Date; +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Optional; +import java.util.Set; + +import javax.annotation.PostConstruct; + +import org.apache.commons.validator.GenericValidator; +import org.openelisglobal.address.service.AddressPartService; +import org.openelisglobal.address.service.PersonAddressService; +import org.openelisglobal.address.valueholder.AddressPart; +import org.openelisglobal.address.valueholder.PersonAddress; +import org.openelisglobal.analysis.service.AnalysisService; +import org.openelisglobal.analysis.valueholder.Analysis; +import org.openelisglobal.common.formfields.FormFields; +import org.openelisglobal.common.formfields.FormFields.Field; +import org.openelisglobal.common.services.TableIdService; +import org.openelisglobal.common.util.ConfigurationProperties; +import org.openelisglobal.common.util.ConfigurationProperties.Property; +import org.openelisglobal.common.util.DateUtil; +import org.openelisglobal.dictionary.service.DictionaryService; +import org.openelisglobal.image.service.ImageService; +import org.openelisglobal.image.valueholder.Image; +import org.openelisglobal.internationalization.MessageUtil; +import org.openelisglobal.localization.service.LocalizationService; +import org.openelisglobal.observationhistory.service.ObservationHistoryService; +import org.openelisglobal.observationhistory.service.ObservationHistoryServiceImpl.ObservationType; +import org.openelisglobal.organization.service.OrganizationService; +import org.openelisglobal.organization.valueholder.Organization; +import org.openelisglobal.patient.service.PatientService; +import org.openelisglobal.patient.service.PatientServiceImpl; +import org.openelisglobal.patient.valueholder.Patient; +import org.openelisglobal.patientidentity.valueholder.PatientIdentity; +import org.openelisglobal.person.service.PersonService; +import org.openelisglobal.person.valueholder.Person; +import org.openelisglobal.program.service.PathologyDisplayService; +import org.openelisglobal.program.service.PathologySampleService; +import org.openelisglobal.program.valueholder.pathology.PathologyConclusion; +import org.openelisglobal.program.valueholder.pathology.PathologyConclusion.ConclusionType; +import org.openelisglobal.program.valueholder.pathology.PathologySample; +import org.openelisglobal.program.valueholder.pathology.PathologyTechnique.TechniqueType; +import org.openelisglobal.provider.service.ProviderService; +import org.openelisglobal.provider.valueholder.Provider; +import org.openelisglobal.reports.action.implementation.reportBeans.ClinicalPatientData; +import org.openelisglobal.reports.action.implementation.reportBeans.ProgramSampleReportData; +import org.openelisglobal.reports.form.ReportForm; +import org.openelisglobal.result.valueholder.Result; +import org.openelisglobal.sample.service.SampleService; +import org.openelisglobal.sample.valueholder.Sample; +import org.openelisglobal.sample.valueholder.SampleAdditionalField.AdditionalFieldName; +import org.openelisglobal.samplehuman.service.SampleHumanService; +import org.openelisglobal.sampleitem.valueholder.SampleItem; +import org.openelisglobal.spring.util.SpringContext; +import org.openelisglobal.test.service.TestServiceImpl; + +import net.sf.jasperreports.engine.JRDataSource; +import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource; + +public abstract class PatientProgramReport extends Report implements IReportCreator { + private ImageService imageService = SpringContext.getBean(ImageService.class); + protected PathologySampleService pathologySerivice = SpringContext.getBean(PathologySampleService.class); + protected PatientService patientService = SpringContext.getBean(PatientService.class); + private static final String configName = ConfigurationProperties.getInstance().getPropertyValue(Property.configurationName); + protected SampleService sampleService = SpringContext.getBean(SampleService.class); + protected SampleHumanService sampleHumanService = SpringContext.getBean(SampleHumanService.class); + protected AddressPartService addressPartService = SpringContext.getBean(AddressPartService.class); + protected OrganizationService organizationService = SpringContext.getBean(OrganizationService.class); + protected DictionaryService dictionaryService = SpringContext.getBean(DictionaryService.class); + protected PersonAddressService addressService = SpringContext.getBean(PersonAddressService.class); + protected ProviderService providerService = SpringContext.getBean(ProviderService.class); + protected AnalysisService analysisService = SpringContext.getBean(AnalysisService.class); + private static String ADDRESS_DEPT_ID; + private static String ADDRESS_COMMUNE_ID; + protected String currentContactInfo = ""; + protected String currentSiteInfo = ""; + protected String STNumber = null; + protected String subjectNumber = null; + protected String healthRegion = null; + protected String healthDistrict = null; + protected String patientName = null; + protected String patientDOB = null; + protected String currentConclusion = null; + + protected String patientDept = null; + protected String patientCommune = null; + + protected Provider currentProvider; + protected Analysis currentAnalysis; + protected String reportReferralResultValue; + protected String completionDate; + protected Patient patient; + protected Sample sample ; + protected List reportItems; + protected List analyses; + protected ProgramSampleReportData data; + + abstract protected String getReportName(); + + abstract protected void setAdditionalReportItems(); + + abstract protected void innitializeSample(ReportForm form); + + @Override + protected String reportFileName() { + return getReportName(); + } + + protected String getHeaderName() { + return "CDIHeader.jasper"; + } + + @PostConstruct + private void initialize() { + List partList = addressPartService.getAll(); + for (AddressPart part : partList) { + if ("department".equals(part.getPartName())) { + ADDRESS_DEPT_ID = part.getId(); + } else if ("commune".equals(part.getPartName())) { + ADDRESS_COMMUNE_ID = part.getId(); + } + } + } + + @Override + public void initializeReport(ReportForm form) { + super.initializeReport(); + errorFound = false; + createReportParameters(); + innitializeSample(form); + currentAnalysis = analysisService.getAnalysesBySampleId(sample.getId()).get(0); + analyses = analysisService.getAnalysesBySampleId(sample.getId()); + initializeReportItems(); + findCompletionDate(); + findPatientFromSample(); + findContactInfo(); + findPatientInfo(); + createReportItems(); + } + + protected void createReportItems() { + reportItems.add(buildClinicalPatientData()); + } + @Override + public JRDataSource getReportDataSource() throws IllegalStateException { + if (!initialized) { + throw new IllegalStateException("initializeReport not called first"); + } + + return errorFound ? new JRBeanCollectionDataSource(errorMsgs) : new JRBeanCollectionDataSource(reportItems); + } + + @Override + protected void createReportParameters() { + super.createReportParameters(); + reportParameters.put("siteId", ConfigurationProperties.getInstance().getPropertyValue(Property.SiteCode)); + reportParameters.put("headerName", getHeaderName()); + reportParameters.put("billingNumberLabel", + SpringContext.getBean(LocalizationService.class).getLocalizedValueById(ConfigurationProperties + .getInstance().getPropertyValue(Property.BILLING_REFERENCE_NUMBER_LABEL))); + reportParameters.put("footerName", getFooterName()); + Optional labDirectorSignature = imageService.getImageBySiteInfoName("labDirectorSignature"); + reportParameters.put("useLabDirectorSignature", labDirectorSignature.isPresent()); + if (labDirectorSignature.isPresent()) { + reportParameters.put("labDirectorSignature", + new ByteArrayInputStream(labDirectorSignature.get().getImage())); + } + + reportParameters.put("labDirectorName", + ConfigurationProperties.getInstance().getPropertyValue(Property.LAB_DIRECTOR_NAME)); + reportParameters.put("labDirectorTitle", + ConfigurationProperties.getInstance().getPropertyValue(Property.LAB_DIRECTOR_TITLE)); + } + + private Object getFooterName() { + if (configName.equals("CI IPCI") || configName.equals("CI LNSP")) { + return "CILNSPFooter.jasper"; + } else { + return ""; + } + } + + protected void initializeReportItems() { + reportItems = new ArrayList<>(); + } + + private void findCompletionDate() { + Date date = sampleService.getCompletedDate(sample); + completionDate = date == null ? null : DateUtil.convertSqlDateToStringDate(date); + } + + protected void findPatientFromSample() { + patient = sampleHumanService.getPatientForSample(sample); + } + + private void findPatientInfo() { + if (patientService.getPerson(patient) == null) { + return; + } + + patientDept = ""; + patientCommune = ""; + if (ADDRESS_DEPT_ID != null) { + PersonAddress deptAddress = addressService + .getByPersonIdAndPartId(patientService.getPerson(patient).getId(), ADDRESS_DEPT_ID); + + if (deptAddress != null && !GenericValidator.isBlankOrNull(deptAddress.getValue())) { + patientDept = dictionaryService.getDictionaryById(deptAddress.getValue()).getDictEntry(); + } + } + + if (ADDRESS_COMMUNE_ID != null) { + PersonAddress deptAddress = addressService + .getByPersonIdAndPartId(patientService.getPerson(patient).getId(), ADDRESS_COMMUNE_ID); + + if (deptAddress != null) { + patientCommune = deptAddress.getValue(); + } + } + + } + + private void findContactInfo() { + currentContactInfo = ""; + currentSiteInfo = ""; + currentProvider = null; + +// sampleService.getOrganizationRequester(currentSample); + Organization referringOrg = sampleService.getOrganizationRequester(sample, + TableIdService.getInstance().REFERRING_ORG_TYPE_ID); + Organization referringDepartmentOrg = sampleService.getOrganizationRequester(sample, + TableIdService.getInstance().REFERRING_ORG_DEPARTMENT_TYPE_ID); + + currentSiteInfo += referringOrg == null ? "" : referringOrg.getOrganizationName(); + currentSiteInfo += "|" + (referringDepartmentOrg == null ? "" : referringDepartmentOrg.getOrganizationName()); + + Person person = sampleService.getPersonRequester(sample); + if (person != null) { + PersonService personService = SpringContext.getBean(PersonService.class); + currentContactInfo = personService.getLastFirstName(person); + currentProvider = providerService.getProviderByPerson(person); + } + + } + + protected ProgramSampleReportData buildClinicalPatientData() { + data = new ProgramSampleReportData(); + String testName = TestServiceImpl.getUserLocalizedTestName(analysisService.getTest(currentAnalysis));; + String sortOrder = ""; + String receivedDate = sampleService.getReceivedDateForDisplay(sample); + Timestamp orderDate = sampleService.getOrderedDate(sample); + String orderDateForDisplay = orderDate != null ? DateUtil.convertTimestampToStringDateAndConfiguredHourTime(orderDate) : ""; + + + if (FormFields.getInstance().useField(Field.SampleEntryUseReceptionHour)) { + receivedDate += " " + sampleService.getReceivedTimeForDisplay(sample); + } + ObservationHistoryService observationHistoryService = SpringContext.getBean(ObservationHistoryService.class); + data.setSampleType(analysisService.getTypeOfSample(currentAnalysis).getLocalizedName()); + Set sampleSet = new HashSet<>(); + analyses.forEach(analysis -> {sampleSet.add(analysis.getSampleItem());}); + setCollectionTime(sampleSet, data, true); + data.setContactInfo(currentContactInfo); + data.setSiteInfo(currentSiteInfo); + data.setReceivedDate(receivedDate); + data.setDob(getPatientDOB(patient)); + data.setAge(createReadableAge(data.getDob())); + data.setGender(patientService.getGender(patient)); + data.setNationalId(patientService.getNationalId(patient)); + setPatientName(data); + data.setDept(patientDept); + data.setCommune(patientCommune); + data.setStNumber(getLazyPatientIdentity(patient, STNumber, PatientServiceImpl.getPatientSTIdentity())); + data.setSubjectNumber( + getLazyPatientIdentity(patient, subjectNumber, PatientServiceImpl.getPatientSubjectIdentity())); + data.setHealthRegion(getLazyPatientIdentity(patient, healthRegion, + PatientServiceImpl.getPatientHealthRegionIdentity())); + data.setHealthDistrict(getLazyPatientIdentity(patient, healthDistrict, + PatientServiceImpl.getPatientHealthDistrictIdentity())); + + data.setLabOrderType(observationHistoryService.getValueForSample(ObservationType.PROGRAM, + sampleService.getId(sample))); + data.setTestName(testName); + data.setPatientSiteNumber(observationHistoryService.getValueForSample(ObservationType.REFERRERS_PATIENT_ID, + sampleService.getId(sample))); + data.setBillingNumber(observationHistoryService.getValueForSample(ObservationType.BILLING_REFERENCE_NUMBER, + sampleService.getId(sample))); + data.setOrderDate(orderDateForDisplay); + data.setSampleSortOrder(currentAnalysis.getSampleItem().getSortOrder()); + data.setSampleId(sampleService.getAccessionNumber(sample) + "-" + data.getSampleSortOrder()); + data.setAccessionNumber(sampleService.getAccessionNumber(sample) + "-" + data.getSampleSortOrder()); + + if (Boolean.valueOf(ConfigurationProperties.getInstance().getPropertyValue(Property.CONTACT_TRACING))) { + data.setContactTracingIndexName( + sampleService.getSampleAdditionalFieldForSample(sampleService.getId(sample), + AdditionalFieldName.CONTACT_TRACING_INDEX_NAME).getFieldValue()); + data.setContactTracingIndexRecordNumber( + sampleService.getSampleAdditionalFieldForSample(sampleService.getId(sample), + AdditionalFieldName.CONTACT_TRACING_INDEX_RECORD_NUMBER).getFieldValue()); + } + setAdditionalReportItems(); + return data; + } + + protected void setCollectionTime(Set sampleSet, ProgramSampleReportData data, + boolean addAccessionNumber) { + StringBuilder buffer = new StringBuilder(); + boolean firstItem = true; + for (SampleItem sampleItem : sampleSet) { + if (firstItem) { + firstItem = false; + } else { + buffer.append(", "); + } + + buffer.append(sampleItem.getTypeOfSample().getLocalizedName()); + if (addAccessionNumber) { + buffer.append(" "); + buffer.append(sampleItem.getSample().getAccessionNumber() + "-" + sampleItem.getSortOrder()); + } + if (sampleItem.getCollectionDate() == null) { + buffer.append(" -- "); + buffer.append(MessageUtil.getMessage("label.not.available")); + } else { + buffer.append(" "); + buffer.append( + DateUtil.convertTimestampToStringDateAndConfiguredHourTime(sampleItem.getCollectionDate())); + } + } + + String collectionTimes = buffer.toString(); + + data.setCollectionDateTime(collectionTimes); + + } + + private String createReadableAge(String dob) { + if (GenericValidator.isBlankOrNull(dob)) { + return ""; + } + + dob = dob.replaceAll(DateUtil.AMBIGUOUS_DATE_SEGMENT, "01"); + Date dobDate = DateUtil.convertStringDateToSqlDate(dob); + int months = DateUtil.getAgeInMonths(dobDate, DateUtil.getNowAsSqlDate()); + if (months > 35) { + return (months / 12) + " " + MessageUtil.getMessage("abbreviation.year.single"); + } else if (months > 0) { + return months + " " + MessageUtil.getMessage("abbreviation.month.single"); + } else { + int days = DateUtil.getAgeInDays(dobDate, DateUtil.getNowAsSqlDate()); + return days + " " + MessageUtil.getMessage("abbreviation.day.single"); + } + + } + + protected String getPatientDOB(Patient patient) { + if (patientDOB == null) { + patientDOB = patientService.getBirthdayForDisplay(patient); + } + + return patientDOB; + } + + protected void setPatientName(ProgramSampleReportData data) { + data.setPatientName(patientService.getLastFirstName(patient)); + data.setFirstName(patientService.getFirstName(patient)); + data.setLastName(patientService.getLastName(patient)); + } + + protected String getLazyPatientIdentity(Patient patient, String identity, String id) { + if (identity == null) { + identity = " "; + List identities = patientService.getIdentityList(patient); + for (PatientIdentity patientIdentity : identities) { + if (patientIdentity.getIdentityTypeId().equals(id)) { + identity = patientIdentity.getIdentityData(); + break; + } + } + } + + return identity; + } + +} diff --git a/src/main/java/org/openelisglobal/reports/action/implementation/ReportImplementationFactory.java b/src/main/java/org/openelisglobal/reports/action/implementation/ReportImplementationFactory.java index 035b9d615d..d32d3536f5 100644 --- a/src/main/java/org/openelisglobal/reports/action/implementation/ReportImplementationFactory.java +++ b/src/main/java/org/openelisglobal/reports/action/implementation/ReportImplementationFactory.java @@ -208,7 +208,6 @@ public static IReportCreator getReportCreator(String report) { } else if (report.equals("ForCIDashboard")) { return new ForCIDashboard(); } - else if (report.equals("CISampleRoutineExport")) { return new ExportRoutineByDate(); } else if (report.equals("referredOut")) { @@ -277,6 +276,8 @@ else if (report.equals("covidResultsReport")) { return new StatisticsReport(); } else if (report.equals("sampleRejectionReport")) { return new CSVSampleRejectionReport(); + }else if (report.equals("PatientPathologyReport")){ + return new PatientPathologyReport(); } } diff --git a/src/main/java/org/openelisglobal/reports/action/implementation/reportBeans/ProgramSampleReportData.java b/src/main/java/org/openelisglobal/reports/action/implementation/reportBeans/ProgramSampleReportData.java new file mode 100644 index 0000000000..78f5876351 --- /dev/null +++ b/src/main/java/org/openelisglobal/reports/action/implementation/reportBeans/ProgramSampleReportData.java @@ -0,0 +1,572 @@ +package org.openelisglobal.reports.action.implementation.reportBeans; + +public final class ProgramSampleReportData { + + private String patientName = ""; + + private String nationalId; + + private String gender; + + private String dob; + + private String age; + + private String stNumber; + + private String subjectNumber; + + private String contactInfo; + + private String siteInfo; + + private String testName; + + private String testRefRange; + + private String conclusion; + + private String finishDate; + + private String accessionNumber; + + private String receivedDate; + + private String testDate; + + private String referralSentDate; + + private String referralTestName; + + private String referralResult; + + private String referralResultReportDate; + + private String referralReason; + + private String referralRefRange; + + private String referralNote; + + private String firstName = ""; + + private String lastName = ""; + + private String dept; + + private String commune; + + private String healthDistrict = ""; + + private String healthRegion = ""; + + private int sectionSortOrder = 0; + + private int testSortOrder = 0; + + private String orderDate; + + private String patientSiteNumber; + + private boolean parentMarker = false; + + private String billingNumber; + + private String sampleType; + + private String sampleId; + + private String sampleSortOrder; + + private String analysisStatus; + + private String contactTracingIndexName; + + private String contactTracingIndexRecordNumber; + + private String completeFlag; + + private String orderFinishDate; + + private String collectionDateTime; + + private boolean correctedResult = false; + + private String labOrderType = ""; + + private String grossExam; + + private String microExam; + + private String codedConclusion; + + private String textConclusion; + + public ProgramSampleReportData() { + } + + public ProgramSampleReportData(ProgramSampleReportData data) { + patientName = data.getPatientName(); + nationalId = data.getNationalId(); + gender = data.getGender(); + dob = data.getDob(); + age = data.getAge(); + stNumber = data.getStNumber(); + subjectNumber = data.getSubjectNumber(); + contactInfo = data.getContactInfo(); + siteInfo = data.getSiteInfo(); + testName = data.getTestName(); + testRefRange = data.getTestRefRange(); + conclusion = data.getConclusion(); + finishDate = data.getFinishDate(); + accessionNumber = data.getAccessionNumber(); + receivedDate = data.getReceivedDate(); + testDate = data.getTestDate(); + referralSentDate = data.getReferralSentDate(); + referralTestName = data.getReferralTestName(); + referralResult = data.getReferralResult(); + referralResultReportDate = data.getReferralResultReportDate(); + referralReason = data.getReferralReason(); + referralRefRange = data.getReferralRefRange(); + referralNote = data.getReferralNote(); + firstName = data.getFirstName(); + lastName = data.getLastName(); + dept = data.getDept(); + commune = data.getCommune(); + healthDistrict = data.getHealthDistrict(); + healthRegion = data.getHealthRegion(); + sectionSortOrder = data.getSectionSortOrder(); + testSortOrder = data.getTestSortOrder(); + orderDate = data.getOrderDate(); + patientSiteNumber = data.getPatientSiteNumber(); + parentMarker = data.getParentMarker(); + billingNumber = data.getBillingNumber(); + sampleType = data.getSampleType(); + sampleId = data.getSampleId(); + sampleSortOrder = data.getSampleSortOrder(); + analysisStatus = data.getAnalysisStatus(); + completeFlag = data.getCompleteFlag(); + + orderFinishDate = data.getOrderFinishDate(); + + collectionDateTime = data.getCollectionDateTime(); + + correctedResult = data.getCorrectedResult(); + + labOrderType = data.getLabOrderType(); + + grossExam = data.getGrossExam(); + + microExam = data.getMicroExam(); + + codedConclusion = data.getCodedConclusion(); + + textConclusion = data.getTextConclusion(); + } + + public String getReferralRefRange() { + return referralRefRange; + } + + public void setReferralRefRange(String referralRefRange) { + this.referralRefRange = referralRefRange; + } + + public String getTestRefRange() { + return testRefRange; + } + + public void setTestRefRange(String testRefRange) { + this.testRefRange = testRefRange; + } + + public String getFinishDate() { + return finishDate; + } + + public void setFinishDate(String finishDate) { + this.finishDate = finishDate; + } + + public String getAccessionNumber() { + return accessionNumber; + } + + public void setAccessionNumber(String accessionNumber) { + this.accessionNumber = accessionNumber; + } + + public String getPatientName() { + return patientName; + } + + public void setPatientName(String patientName) { + this.patientName = patientName; + } + + public String getNationalId() { + return nationalId; + } + + public void setNationalId(String nationalId) { + this.nationalId = nationalId; + } + + public String getGender() { + return gender; + } + + public void setGender(String gender) { + this.gender = gender; + } + + public String getDob() { + return dob; + } + + public void setDob(String dob) { + this.dob = dob; + } + + public String getStNumber() { + return stNumber; + } + + public void setStNumber(String stNumber) { + this.stNumber = stNumber; + } + + public void setTestName(String testName) { + this.testName = testName; + } + + public String getTestName() { + return testName; + } + + public void setReceivedDate(String recievedDate) { + this.receivedDate = recievedDate; + } + + // in case of typo + public String getRecievedDate() { + return getReceivedDate(); + } + + public String getReceivedDate() { + return receivedDate; + } + + public void setConclusion(String conclusioned) { + conclusion = conclusioned; + } + + public String getConclusion() { + return conclusion; + } + + public void setContactInfo(String contactInfo) { + this.contactInfo = contactInfo; + } + + public String getContactInfo() { + return contactInfo; + } + + public void setSiteInfo(String siteInfo) { + this.siteInfo = siteInfo; + } + + public String getSiteInfo() { + return siteInfo; + } + + public void setTestDate(String testDate) { + this.testDate = testDate; + } + + public String getTestDate() { + return testDate; + } + + public String getReferralSentDate() { + return referralSentDate; + } + + public void setReferralSentDate(String referralSentDate) { + this.referralSentDate = referralSentDate; + } + + public String getReferralTestName() { + return referralTestName; + } + + public void setReferralTestName(String referralTestName) { + this.referralTestName = referralTestName; + } + + public String getReferralResult() { + return referralResult; + } + + public void setReferralResult(String referralResult) { + this.referralResult = referralResult; + } + + public void setReferralResultReportDate(String referralResultReportDate) { + this.referralResultReportDate = referralResultReportDate; + } + + public String getReferralResultReportDate() { + return referralResultReportDate; + } + + public void setReferralReason(String referralReason) { + this.referralReason = referralReason; + } + + public String getReferralReason() { + return referralReason; + } + + public String getReferralNote() { + return referralNote; + } + + public void setReferralNote(String referralNote) { + this.referralNote = referralNote; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getSampleSortOrder() { + return sampleSortOrder; + } + + public void setSampleSortOrder(String sampleSortOrder) { + this.sampleSortOrder = sampleSortOrder; + } + + public String getDept() { + return dept; + } + + public void setDept(String dept) { + this.dept = dept; + } + + public String getCommune() { + return commune; + } + + public void setCommune(String commune) { + this.commune = commune; + } + + public int getTestSortOrder() { + return testSortOrder; + } + + public void setTestSortOrder(int testSortOrder) { + this.testSortOrder = testSortOrder; + } + + public int getSectionSortOrder() { + return sectionSortOrder; + } + + public void setSectionSortOrder(int sectionSortOrder) { + this.sectionSortOrder = sectionSortOrder; + } + + public String getSubjectNumber() { + return subjectNumber; + } + + public void setSubjectNumber(String subjectNumber) { + this.subjectNumber = subjectNumber; + } + + public String getHealthDistrict() { + return healthDistrict; + } + + public void setHealthDistrict(String healthDistrict) { + this.healthDistrict = healthDistrict; + } + + public String getHealthRegion() { + return healthRegion; + } + + public void setHealthRegion(String healthRegion) { + this.healthRegion = healthRegion; + } + + public String getAge() { + return age; + } + + public void setAge(String age) { + this.age = age; + } + + public String getOrderDate() { + return orderDate; + } + + public void setOrderDate(String orderDate) { + this.orderDate = orderDate; + } + + public String getPatientSiteNumber() { + return patientSiteNumber; + } + + public void setPatientSiteNumber(String patientSiteNumber) { + this.patientSiteNumber = patientSiteNumber; + } + + public boolean getParentMarker() { + return parentMarker; + } + + public void setParentMarker(boolean isParentMarker) { + this.parentMarker = isParentMarker; + } + + public String getBillingNumber() { + return billingNumber; + } + + public void setBillingNumber(String billingNumber) { + this.billingNumber = billingNumber; + } + + public String getSampleType() { + return sampleType; + } + + public void setSampleType(String sampleType) { + this.sampleType = sampleType; + } + + public String getSampleId() { + return sampleId; + } + + public void setSampleId(String sampleId) { + this.sampleId = sampleId; + } + + public String getAnalysisStatus() { + return analysisStatus; + } + + public void setAnalysisStatus(String analysisStatus) { + this.analysisStatus = analysisStatus; + } + + public String getContactTracingIndexName() { + return contactTracingIndexName; + } + + public void setContactTracingIndexName(String contactTracingIndexName) { + this.contactTracingIndexName = contactTracingIndexName; + } + + public String getContactTracingIndexRecordNumber() { + return contactTracingIndexRecordNumber; + } + + public void setContactTracingIndexRecordNumber(String contactTracingIndexRecordNumber) { + this.contactTracingIndexRecordNumber = contactTracingIndexRecordNumber; + } + + public String getCompleteFlag() { + return completeFlag; + } + + public void setCompleteFlag(String completeFlag) { + this.completeFlag = completeFlag; + } + + public String getOrderFinishDate() { + return orderFinishDate; + } + + public void setOrderFinishDate(String orderFinishDate) { + this.orderFinishDate = orderFinishDate; + } + + public String getCollectionDateTime() { + return collectionDateTime; + } + + public void setCollectionDateTime(String collectionDateTime) { + this.collectionDateTime = collectionDateTime; + } + + public boolean getCorrectedResult() { + return correctedResult; + } + + public void setCorrectedResult(boolean correctedResult) { + this.correctedResult = correctedResult; + } + + public String getLabOrderType() { + return labOrderType; + } + + public void setLabOrderType(String labOrderType) { + this.labOrderType = labOrderType; + } + + public String getGrossExam() { + return grossExam; + } + + public void setGrossExam(String grossExam) { + this.grossExam = grossExam; + } + + public String getMicroExam() { + return microExam; + } + + public void setMicroExam(String microExam) { + this.microExam = microExam; + } + + public String getCodedConclusion() { + return codedConclusion; + } + + public void setCodedConclusion(String codedConclusion) { + this.codedConclusion = codedConclusion; + } + + public String getTextConclusion() { + return textConclusion; + } + + public void setTextConclusion(String textConclusion) { + this.textConclusion = textConclusion; + } + +} diff --git a/src/main/java/org/openelisglobal/reports/controller/rest/ReportRestController.java b/src/main/java/org/openelisglobal/reports/controller/rest/ReportRestController.java new file mode 100644 index 0000000000..102a7a242c --- /dev/null +++ b/src/main/java/org/openelisglobal/reports/controller/rest/ReportRestController.java @@ -0,0 +1,129 @@ +package org.openelisglobal.reports.controller.rest; + +import java.io.File; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.lang.reflect.InvocationTargetException; +import java.net.URLDecoder; +import java.sql.SQLException; +import java.text.ParseException; +import java.util.HashMap; + +import javax.servlet.ServletContext; +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import org.apache.commons.validator.GenericValidator; +import org.openelisglobal.common.exception.LIMSRuntimeException; +import org.openelisglobal.common.log.LogEvent; +import org.openelisglobal.common.rest.BaseRestController; +import org.openelisglobal.reports.action.implementation.IReportCreator; +import org.openelisglobal.reports.action.implementation.ReportImplementationFactory; +import org.openelisglobal.reports.form.ReportForm; +import org.openelisglobal.testreflex.action.bean.ReflexRule; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; + +import com.lowagie.text.DocumentException; + +import net.sf.jasperreports.engine.JRException; + +@Controller +@RequestMapping(value = "/rest/") +public class ReportRestController extends BaseRestController{ + + @Autowired + private ServletContext context; + + private static String reportPath = null; + private static String imagesPath = null; + + + @RequestMapping(value = "/ReportPrint", method = RequestMethod.GET) + public void showReportPrint(@RequestParam String report ,@RequestParam String programSampleId ,HttpServletRequest request, HttpServletResponse response) + throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { + + ReportForm form = new ReportForm(); + form.setReport(report); + form.setProgramSampleId(programSampleId); + LogEvent.logTrace("ReportController", "Log GET ", form.getReport()); + IReportCreator reportCreator = ReportImplementationFactory.getReportCreator(form.getReport()); + + if (reportCreator != null) { + reportCreator.setSystemUserId(getSysUserId(request)); + reportCreator.setRequestedReport(form.getReport()); + reportCreator.initializeReport(form); + reportCreator.setReportPath(getReportPath()); + + HashMap parameterMap = (HashMap) reportCreator.getReportParameters(); + parameterMap.put("SUBREPORT_DIR", getReportPath()); + parameterMap.put("imagesPath", getImagesPath()); + + try { + response.setContentType(reportCreator.getContentType()); + String responseHeaderName = reportCreator.getResponseHeaderName(); + String responseHeaderContent = reportCreator.getResponseHeaderContent(); + if (!GenericValidator.isBlankOrNull(responseHeaderName) + && !GenericValidator.isBlankOrNull(responseHeaderContent)) { + response.setHeader(responseHeaderName, responseHeaderContent); + } + + byte[] bytes = reportCreator.runReport(); + + response.setContentLength(bytes.length); + + ServletOutputStream servletOutputStream = response.getOutputStream(); + + servletOutputStream.write(bytes, 0, bytes.length); + servletOutputStream.flush(); + servletOutputStream.close(); + } catch (IOException | SQLException | JRException | DocumentException | ParseException e) { + LogEvent.logErrorStack(e); + LogEvent.logDebug(e); + } + } + + } + + + private String getReportPath() { + String reportPath = getReportPathValue(); + if (reportPath.endsWith(File.separator)) { + return reportPath; + } else { + return reportPath + File.separator; + } + } + + private String getReportPathValue() { + + if (reportPath == null) { + ClassLoader classLoader = getClass().getClassLoader(); + reportPath = classLoader.getResource("reports").getPath(); + try { + reportPath = URLDecoder.decode(reportPath, "UTF-8"); + } catch (UnsupportedEncodingException e) { + LogEvent.logDebug(e); + throw new LIMSRuntimeException(e); + } + } + return reportPath; + } + + public String getImagesPath() { + if (imagesPath == null) { + imagesPath = context.getRealPath("") + "static" + File.separator + "images" + File.separator; + try { + imagesPath = URLDecoder.decode(imagesPath, "UTF-8"); + } catch (UnsupportedEncodingException e) { + LogEvent.logDebug(e); + throw new LIMSRuntimeException(e); + } + } + return imagesPath; + } +} diff --git a/src/main/java/org/openelisglobal/reports/form/ReportForm.java b/src/main/java/org/openelisglobal/reports/form/ReportForm.java index c972f0c08b..b2c7be4b16 100644 --- a/src/main/java/org/openelisglobal/reports/form/ReportForm.java +++ b/src/main/java/org/openelisglobal/reports/form/ReportForm.java @@ -155,6 +155,8 @@ public enum ReceptionTime { private Boolean useStatisticsParams = false; + private String programSampleId; + // for display private List priorityList; @@ -619,4 +621,13 @@ public List getReceptionTime() { public void setReceptionTime(List receptionTime) { this.receptionTime = receptionTime; } + + public String getProgramSampleId() { + return programSampleId; + } + + public void setProgramSampleId(String programSampleId) { + this.programSampleId = programSampleId; + } + } diff --git a/src/main/resources/languages/message_en.properties b/src/main/resources/languages/message_en.properties index 9c31a48f9f..79a3b5d8c1 100644 --- a/src/main/resources/languages/message_en.properties +++ b/src/main/resources/languages/message_en.properties @@ -7808,3 +7808,8 @@ sample.entry.project.title.psc = PSC (?) sample.type.PSC = PSC error.out.side.critical.range = Value is outside of critical range. \ must be between 0-10 or above 95 +pathology.label.grossexam = Gross Exam +pathology.label.microexam = Microscopy Exam +pathology.label.conclusion = Conclusion +pathology.label.textconclusion = Text Conclusion +pathology.label.report = HistoPathology Report diff --git a/src/main/resources/languages/message_fr.properties b/src/main/resources/languages/message_fr.properties index 0240694827..5cf657740b 100644 --- a/src/main/resources/languages/message_fr.properties +++ b/src/main/resources/languages/message_fr.properties @@ -7304,3 +7304,8 @@ result.pathology.seereport = See Pathology Report sample.entry.project.title.psc = PSC sample.type.PSC = PSC +pathology.label.grossexam = Examen brut +pathology.label.microexam = Examen Macroscopique +pathology.label.conclusion = Conclusion +pathology.label.textconclusion = Conclusion Textuelle +pathology.label.report = Rapport d'histopathologie diff --git a/src/main/resources/reports/PatientPathologyReport.jasper b/src/main/resources/reports/PatientPathologyReport.jasper new file mode 100644 index 0000000000..b8e357eaff Binary files /dev/null and b/src/main/resources/reports/PatientPathologyReport.jasper differ diff --git a/src/main/resources/reports/PatientPathologyReport.jrxml b/src/main/resources/reports/PatientPathologyReport.jrxml new file mode 100644 index 0000000000..24a811027a --- /dev/null +++ b/src/main/resources/reports/PatientPathologyReport.jrxml @@ -0,0 +1,953 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <band height="2" splitType="Stretch"> + <line> + <reportElement key="line" x="0" y="-45" width="534" height="1" forecolor="#000000" uuid="d79c2f6c-c1be-408f-b5ad-1d81ab9a43bd"/> + <graphicElement> + <pen lineWidth="2.0" lineStyle="Solid"/> + </graphicElement> + </line> + </band> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + " + $R{pathology.label.grossexam} + ""]]> + + + + + + + + + + + + + + " + $R{pathology.label.microexam} + ""]]> + + + + + + + + + + + + + + " + $R{pathology.label.conclusion} + ""]]> + + + + + + + + + + + + + + " + $R{pathology.label.textconclusion}+ ""]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +