Word is better than Quarto?

NHS RPySOC 2025

13 November 2025

Hello 👋

The New Hospital Programme 🏥

  • The government is committed to building hospitals
  • How to meet needs/get good value for money?
  • Answer: we built a demand model

Reporting 📒

  • End-users get model outputs and we co-author a report
  • Requires automation/reproducibility
  • So use Quarto, right? Right?

Existing Word template 📑

Existing Word template 📑

It looks like you’ve accepted your fate.

An unofficial version of the Microsoft Office mascot Clippy, a paperclip with eyes.

Decision 🧐

  • Meet users where they are: in Word
  • Editability and flexibility trumps total automation
  • How can we maximise reproducibility?

Doing it

Process ✏️

  1. Record a request with a GitHub issue template.
  2. Tag model-run JSONs on Azure, update site-selections file.
  3. Read SharePoint template with {Microsoft365R}.
  4. Insert content with {officer}.
  5. Write timestamped folder with doc, results, log.
  6. Check output, return to recipient.

Issue template ✅

A screenshot previewing an issue template. There are checklist items explaining the steps to complete to generate a report. There are links to further information and guidance.

Generate a report 🖨️

In R:

populate_template(
  scheme_code = "XYZ",                 # create a report for this scheme
  site_codes = NULL,                   # NULL to fetch from Azure
  result_sets = get_nhp_result_sets(), # fetch results metadata from Azure
  run_stages = list(                   # list the tagged model runs
    primary = "final_report_ndg3",     # main data source for the report
    secondary = "final_report_ndg2"    # used as a comparator
  )
)

Generated report 📁️

Output file structure:

output/
└──YYYY-MM-DD-HHMMSS_scheme/
   ├──YYYY-MM-DD-HHMMSS_scheme.log                        # log of printed metadata
   ├──YYYY-MM-DD-HHMMSS_scheme_outputs-report_draft.docx  # populated report
   ├──figures/                                            # standalone PNG files
   └──values/                                             # CSVs of calculated values
    

Insert images with {officer} 👮

Screenshot of text in a Word document that contains a placeholder in square bracket that says 'insert figure 9.2'.
  1. Add unique target strings, e.g. [Insert Figure 9.2].
  2. Find/replace with cursor_reach() and body_add_img().

Insert values with {officer} 👮

Screenshot of text in a Word document that contains placeholders. Two placeholders are in square brackets and they say 'insert value' and then a number (55 and 56 in this case). The other placeholder is in curly brackets and says 'DOCPROPERTY item_54'.

  1. Add doc-property fields, e.g.

    { DOCPROPERTY item_54 }.

  2. Add custom doc properties.
  3. Update values programmatically with set_doc_properties().
  4. Refresh to insert values to fields.

Screenshot of the custom properties dialog in Microsoft Word. A number of custom properties are shown with names like 'item_01' and placeholder values like 'Insert Value 01' in square brackets.

Reflecting on it

Doing it right 💯

  • Github: ‘learn by doing’, challenge and improve things
  • Documentation/version history have saved us!
  • The repo is a springboard for parallel/future work

Flexibility 🤸

The repository and code continue to help with:

  • ad hoc work
  • upcoming ‘refresh’ reports
  • changes to inputs and back-end processes

Reflections 🪞

  • Challenge your thinking, be adaptable to user needs
  • Embrace agility and acknowledge fragility
  • ‘The power of friendship’ keeps things working

Actions 🎬

  1. Consider user needs.
  2. Collaborate with GitHub.
  3. Stay flexible.

Check out: