Skip to content
Open
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
6 changes: 6 additions & 0 deletions api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@
</exclusions>
</dependency>

<dependency>
<groupId>com.github.librepdf</groupId>
<artifactId>openpdf</artifactId>
<version>${openpdfVersion}</version>
</dependency>

<dependency>
<groupId>net.sf.barcode4j</groupId>
<artifactId>barcode4j-fop-ext</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ public class PatientDocumentsConstants {

public static final String COMPONENT_REPORTMANAGER_PATIENT_ID_STICKER = MODULE_ARTIFACT_ID + "." + PATIENT_ID_STICKER_ID;

public static final String VISIT_SUMMARY_REPORT_ID = "visitSummary";

public static final String COMPONENT_REPORTMANAGER_VISIT_SUMMARY = MODULE_ARTIFACT_ID + "." + VISIT_SUMMARY_REPORT_ID;

public static final String VISIT_SUMMARY_REPORT_UUID = "4fb1f692-7ead-4257-bbe1-97fac0295171";

/**
* The path to the style sheet for Patient History reports.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under
* the terms of the Healthcare Disclaimer located at http://openmrs.org/license.
*
* Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS
* graphic logo is a trademark of OpenMRS Inc.
*/
package org.openmrs.module.patientdocuments.library;

import org.openmrs.module.reporting.common.Localized;
import org.openmrs.module.reporting.dataset.definition.BaseDataSetDefinition;
import org.openmrs.module.reporting.evaluation.parameter.Parameter;

/**
* A dataset definition for the Visit Summary Report.
* This class serves as a placeholder for visit-related data such as vitals, diagnoses, and medications.
*/
@Localized("patientdocuments.visitSummaryDataSetDefinition")
public class VisitSummaryDataSetDefinition extends BaseDataSetDefinition {

private static final long serialVersionUID = 1L;

/**
* Default Constructor
*/
public VisitSummaryDataSetDefinition() {
super();
addParameter(new Parameter("visitUuid", "Visit UUID", String.class));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/**
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under
* the terms of the Healthcare Disclaimer located at http://openmrs.org/license.
*
* Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS
* graphic logo is a trademark of OpenMRS Inc.
*/
package org.openmrs.module.patientdocuments.renderer;

import java.io.IOException;
import java.io.OutputStream;

import org.openmrs.annotation.Handler;
import org.openmrs.module.reporting.common.Localized;
import org.openmrs.module.reporting.report.ReportData;
import org.openmrs.module.reporting.report.ReportRequest;
import org.openmrs.module.reporting.report.renderer.RenderingException;
import org.openmrs.module.reporting.report.renderer.ReportDesignRenderer;
import org.springframework.stereotype.Component;

import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfWriter;

/**
* ReportRenderer that renders the Visit Summary Report to a PDF format using OpenPDF.
* This skeleton generates a simple PDF and is designed to allow future section-based rendering.
*/
@Component
@Handler
@Localized("patientdocuments.visitSummaryPdfRenderer")
public class VisitSummaryPdfRenderer extends ReportDesignRenderer {

@Override
public String getFilename(ReportRequest request) {
return getFilenameBase(request) + ".pdf";
}

@Override
public String getRenderedContentType(ReportRequest request) {
return "application/pdf";
}

@Override
public void render(ReportData results, String argument, OutputStream out) throws IOException, RenderingException {

// Attempt to extract the visitUuid from parameters
String visitUuid = (String) results.getContext().getParameterValue("visitUuid");
if (visitUuid == null) {
visitUuid = "N/A";
}

Document document = new Document();
try {
PdfWriter.getInstance(document, out);
document.open();

// Initial skeleton output
document.add(new Paragraph("Visit Summary Report"));
document.add(new Paragraph("Visit UUID: " + visitUuid));

// TODO: Future logic for rendering sections (Vitals, Diagnoses, Medications, etc.)
// Section: Vitals
// Section: Diagnoses
// Section: Medications
// Section: Lab Results

document.close();
}
catch (DocumentException e) {
throw new RenderingException("Error generating Visit Summary PDF", e);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/**
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under
* the terms of the Healthcare Disclaimer located at http://openmrs.org/license.
*
* Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS
* graphic logo is a trademark of OpenMRS Inc.
*/
package org.openmrs.module.patientdocuments.reports;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.openmrs.module.patientdocuments.common.PatientDocumentsConstants;
import org.openmrs.module.patientdocuments.library.VisitSummaryDataSetDefinition;
import org.openmrs.module.patientdocuments.renderer.VisitSummaryPdfRenderer;
import org.openmrs.module.reporting.evaluation.parameter.Parameter;
import org.openmrs.module.reporting.report.ReportDesign;
import org.openmrs.module.reporting.report.definition.ReportDefinition;
import org.openmrs.module.reporting.report.manager.BaseReportManager;
import org.springframework.stereotype.Component;

/**
* Manager class for the Visit Summary Report.
* Defines the report structure, parameters, and links it to the appropriate dataset and renderer.
*/
@Component(PatientDocumentsConstants.COMPONENT_REPORTMANAGER_VISIT_SUMMARY)
public class VisitSummaryReportManager extends BaseReportManager {

public static final String REPORT_DEFINITION_NAME = "Visit Summary Report";

public static final String DATASET_KEY_VISIT_SUMMARY = "visitSummaryFields";

@Override
public String getVersion() {
return "1.1.0-SNAPSHOT";
}

@Override
public String getUuid() {
return PatientDocumentsConstants.VISIT_SUMMARY_REPORT_UUID;
}

@Override
public String getName() {
return REPORT_DEFINITION_NAME;
}

@Override
public String getDescription() {
return "A report summarizing a patient visit, including vitals, diagnoses, and medications.";
}

@Override
public List<Parameter> getParameters() {
List<Parameter> params = new ArrayList<>();
params.add(new Parameter("visitUuid", "Visit UUID", String.class));
return params;
}

@Override
public ReportDefinition constructReportDefinition() {
ReportDefinition reportDef = new ReportDefinition();
reportDef.setUuid(this.getUuid());
reportDef.setName(this.getName());
reportDef.setDescription(this.getDescription());
reportDef.setParameters(this.getParameters());

// Link the VisitSummaryDataSetDefinition
VisitSummaryDataSetDefinition dsd = new VisitSummaryDataSetDefinition();
Map<String, Object> parameterMappings = new HashMap<>();
parameterMappings.put("visitUuid", "${visitUuid}");
reportDef.addDataSetDefinition(DATASET_KEY_VISIT_SUMMARY, dsd, parameterMappings);

return reportDef;
}

@Override
public List<ReportDesign> constructReportDesigns(ReportDefinition reportDefinition) {
ReportDesign reportDesign = new ReportDesign();
reportDesign.setName("Visit Summary PDF");
reportDesign.setUuid("d3b07384-8f1d-4f1e-9e7c-87dcb46a5b98");
reportDesign.setReportDefinition(reportDefinition);
reportDesign.setRendererType(VisitSummaryPdfRenderer.class);
return Arrays.asList(reportDesign);
}
}
2 changes: 2 additions & 0 deletions api/src/main/resources/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ ${project.parent.artifactId}.patientIdSticker.fields.gender=Gender
${project.parent.artifactId}.patientIdSticker.fields.fulladdress=Address
${project.parent.artifactId}.patientIdStickerDataSetDefinition=Patient Identifier Sticker Data Set Definition
${project.parent.artifactId}.patientIdStickerXmlReportRenderer=Patient Identifier Sticker XML Report Renderer
${project.parent.artifactId}.visitSummaryDataSetDefinition=Visit Summary Data Set Definition
${project.parent.artifactId}.visitSummaryPdfRenderer=Visit Summary PDF Renderer
6 changes: 0 additions & 6 deletions omod/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.librepdf</groupId>
<artifactId>openpdf</artifactId>
<version>${openpdfVersion}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
Expand Down