Skip to content

O3-5723: Improvements in printing feature#28

Open
druchniewicz wants to merge 3 commits into
openmrs:mainfrom
SolDevelo:O3-5723-2
Open

O3-5723: Improvements in printing feature#28
druchniewicz wants to merge 3 commits into
openmrs:mainfrom
SolDevelo:O3-5723-2

Conversation

@druchniewicz

Copy link
Copy Markdown
Contributor

What have been resolved?

  1. Repeated questions no longer duplicate their values.
    Forms that reuse the same concept across several sections previously printed the concatenation of every observation for that concept in each occurrence instead of single value.
  2. Special characters render correctly now.
    Characters outside the base Latin set were printed in wrong way e.g. >=18 was printed as #18 or arabic texts like النفسية الصح were printed as ##########
  3. Consistent date formatting across the whole document

@druchniewicz

Copy link
Copy Markdown
Contributor Author

@wikumChamith can you take a look? Next part of improvements after feedback gathered from end user.

private FopFactory buildFopFactory() throws Exception {
try (InputStream fopConfigStream = Helper.getInputStreamByResource(FOP_CONFIG_PATH)) {
if (fopConfigStream != null) {
URI fontBaseUri = OpenmrsClassLoader.getInstance().getResource(FONT_BASE_PATH).toURI();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we need an NPE guard here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, corrected

matched.add(obs);
}
}
return matched;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we need to return conceptObs here if matched is empty? Otherwise, there could be data loss.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right that data loss is a risk, but returning conceptObs unconditionally would re-introduce the exact bug this method fixes: when a concept is reused across several questions, an empty matched for one question means the data belongs to a sibling question, and returning all observations would print every section's value under each occurrence again. I scoped the fallback: on an empty match we now return conceptObs only when the concept is used by a single question, when the concept is shared by multiple questions, an empty result is expected and we return empty

Configuration cfg = new DefaultConfigurationBuilder().build(fopConfigStream);
return new FopFactoryBuilder(fontBaseUri).setConfiguration(cfg).build();
}
log.warn("FOP configuration '{}' not found on classpath; extended glyphs may not render correctly.", FOP_CONFIG_PATH);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only going to display a server-side log.warn that no clinician sees. Should this fail loudly rather than emit a silently corrupt PDF?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, corrected

@druchniewicz

Copy link
Copy Markdown
Contributor Author

@wikumChamith PR updated

@wikumChamith

Copy link
Copy Markdown
Member

@druchniewicz what do you think about the three new Sonar issues?

@sonarqubecloud

Copy link
Copy Markdown

@druchniewicz

druchniewicz commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

@druchniewicz what do you think about the three new Sonar issues?

@wikumChamith indeed right, I've fixed them. This new 1 issue is not related to changes from this PR. I could fix it by extracting all these little pieces of code into separate methods but honestly I don't think it's more readable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants