mohd-faraz

_blogs

// blogs / 20260522.md

Dev Log: May 22 Wrap-up

2026-05-22
#word-generation#java#frontend-engineering#bug-fixing#ux

Overview

Today was largely a split between battling Word document parsing logic and doing some much-needed cleanup on our multidisciplinary team (MDT) workflow board. It's one of those days where you spend a lot of time looking at nested HTML structures and wondering why Word rendering has to be so temperamental.

What I Worked On

Making our Word document generator less fragile

Our HTML-to-Word report generator has been a bit of a pain point lately, especially when dealing with complex billing or clinical tables. I had to tackle two specific layout bugs that were messing up the generated reports.

First, the table parser was completely ignoring <thead> elements. It was only looking for immediate child rows or <tbody> blocks, meaning headers on more structured HTML tables were just... vanishing. I updated the row extractor to explicitly parse and sequence both headers and body rows correctly.

Second—and more annoying—was how it handled text formatting inside individual table cells. The parser was treating every single inline tag (like <span> or <b>) as a block-level element. This meant a simple text snippet like "Total: $50.00" was rendering as:
Total:
$50.00

To fix this, I rewrote the cell content parsing logic to differentiate between block elements (like divs and paragraphs) and inline-only text elements. If a cell contains only inline elements, we now bundle them into a single paragraph with multiple text runs so they stay on the same line. If there are actual block elements—like an address formatted with multiple divs—we still split them into distinct paragraphs. It's a small change that makes a massive visual difference.

Cleaning up the clinical board workflow

In the afternoon, I jumped over to the MDT board worklist to polish a few UX and permission issues:

  • Hiding the "Add" button on cancelled requests: I noticed that when users clicked over to the cancelled requests tab, the "Add" action button was still sitting there. There is absolutely no reason to add a new record directly into a cancelled queue, so I updated the frontend decorator to dynamically strip the button when that tab is active.
  • Fixing role naming mismatch: We had a slight mismatch where an admin role was being identified as "Facility Admin" instead of the actual scoped role, "MDT Admin". I updated the backend decorator constants to align with the correct permission group.

Query tuning for templates

Finally, I had to update one of our template form layout configurations. The form was pulling value sets using an old query that didn't handle pagination or flat data formatting well. I swapped it over to a much more stable paginated flat query, which should keep those dynamic forms loading quickly even as our dataset grows.

Wrapping Up

It feels good to have those Word rendering quirks sorted out. Tomorrow, I'll probably spend some time monitoring the document generation logs to make sure my table parser updates aren't causing any unexpected layout regressions in other reports.