-
Notifications
You must be signed in to change notification settings - Fork 10
Fix logo and address not showing in Sticker #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
0d006e9
1aed602
6d6f03a
1fdce7f
c405768
f82dddc
bb58b1f
4a533f9
16233d6
317aef0
6427674
aa3aac8
85f8aa8
71ad294
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,9 @@ | |
| import java.io.File; | ||
| import java.io.IOException; | ||
| import java.io.OutputStream; | ||
| import java.net.URISyntaxException; | ||
| import java.net.URL; | ||
| import java.nio.file.Paths; | ||
| import java.util.Arrays; | ||
| import java.util.HashMap; | ||
| import java.util.List; | ||
|
|
@@ -46,6 +49,7 @@ | |
| import org.openmrs.module.reporting.report.renderer.RenderingException; | ||
| import org.openmrs.module.reporting.report.renderer.ReportDesignRenderer; | ||
| import org.openmrs.module.reporting.report.renderer.ReportRenderer; | ||
| import org.openmrs.util.OpenmrsClassLoader; | ||
| import org.springframework.stereotype.Component; | ||
| import org.w3c.dom.Document; | ||
| import org.w3c.dom.Element; | ||
|
|
@@ -239,16 +243,24 @@ private void configureHeader(Document doc, Element templatePIDElement) { | |
| } | ||
|
|
||
| private void configureLogo(Document doc, Element header, String logoUrlPath) { | ||
| String logoPath; | ||
| String logoPath = ""; | ||
| File logoFile = new File(logoUrlPath); | ||
| boolean isValidFile = logoFile.exists() && logoFile.canRead() && logoFile.isAbsolute(); | ||
|
|
||
| if (isValidFile) { | ||
| logoPath = logoFile.getAbsolutePath(); | ||
| } else { | ||
| throw new RenderingException("Logo file not found or not accessible: " + logoUrlPath); | ||
| try { | ||
| URL res = OpenmrsClassLoader.getInstance().getResource(logoUrlPath); | ||
jnsereko marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| if (res != null) { | ||
| logoPath = Paths.get(res.toURI()).toString(); | ||
| } | ||
| } | ||
| catch (URISyntaxException e) { | ||
| throw new RenderingException("Logo file not found or not accessible: " + logoUrlPath); | ||
| } | ||
| } | ||
|
|
||
| Element branding = doc.createElement("branding"); | ||
| Element image = doc.createElement("logo"); | ||
| image.setTextContent(logoPath); | ||
jnsereko marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
@@ -365,15 +377,16 @@ && shouldIncludeColumn("patientdocuments.patientIdSticker.fields.secondaryIdenti | |
|
|
||
| // Process address | ||
| if (shouldIncludeColumn("patientdocuments.patientIdSticker.fields.fulladdress")) { | ||
| Map<String, String> addressData = (Map<String, String>) patientData.get("preferredAddress"); | ||
| if (addressData != null) { | ||
| List<Map<String, String>> addressData = (List<Map<String, String>>) patientData.get("addresses"); | ||
| if (addressData != null && !addressData.isEmpty()) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this also related to the logo?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No! This ensures that the address data is pulled from the right variable in the Patient Data object. |
||
| Map<String, String> preferredAddress = addressData.get(0); | ||
| StringBuilder address = new StringBuilder(); | ||
| appendIfNotNull(address, addressData.get("address1")); | ||
| appendIfNotNull(address, addressData.get("address2")); | ||
| appendIfNotNull(address, addressData.get("cityVillage")); | ||
| appendIfNotNull(address, addressData.get("stateProvince")); | ||
| appendIfNotNull(address, addressData.get("country")); | ||
| appendIfNotNull(address, addressData.get("postalCode")); | ||
| appendIfNotNull(address, preferredAddress.get("address1")); | ||
| appendIfNotNull(address, preferredAddress.get("address2")); | ||
| appendIfNotNull(address, preferredAddress.get("cityVillage")); | ||
| appendIfNotNull(address, preferredAddress.get("stateProvince")); | ||
| appendIfNotNull(address, preferredAddress.get("country")); | ||
| appendIfNotNull(address, preferredAddress.get("postalCode")); | ||
|
|
||
| if (address.length() > 0) { | ||
| addField(doc, fields, addressKey, address.toString().trim()); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.