Case study · Medicus AI

Dynamic Medical
Report Builder

A standalone PHP microservice that turns raw patient data into a printable, branded PDF report — biomarker results, old-vs-new charts and personalised health tips — called as an API by the main React app.

Year2022 — 2023
RoleBuilt it end to end
TypeBackend microservice
Consumed byReact web app
01 — How it works

Data in.
Report out.

The React app never builds PDFs itself. It sends one JSON payload to the service and gets a finished document back — so the report logic lives in one place, and any app can call it.

01 · ClientReact app

Collects patient info, biomarker results, insights and tips.

02 · RequestJSON payload

One structured request to the service API.

03 · My servicePHP template

Builds the report as styled HTML with the patient's data and tips.

04 · My serviceChart.js

Draws old-vs-new comparisons for every biomarker.

05 · My servicewkhtmltopdf

Renders the page to a print-ready PDF and returns it.

02 — Input & output

What goes in,
what comes out.

A simplified version of the contract between the app and the service, next to the kind of page it produces.

POST /reportJSON
{
  "patient": { "name": "Demo Patient", "age": 42 },
  "biomarkers": [
    { "name": "Haemoglobin", "unit": "g/dL",
      "previous": 13.1, "current": 14.2,
      "status": "normal" },
    { "name": "Vitamin D", "unit": "ng/mL",
      "previous": 24, "current": 18,
      "status": "low" }
  ],
  "insights": [ "Vitamin D dropped since last test" ],
  "tips": [ "15 minutes of morning sun daily" ]
}
report.pdfA4 · print-ready
LAB REPORTDemo Clinic
14 Sep 2023
PatientDemo Patient
Age42
Compared toMar 2023
PreviousCurrent
Haemoglobin
Normal
Glucose
Watch
Cholesterol
Normal
Vitamin D
Low
Tip · Your vitamin D dropped since your last test. Try 15 minutes of morning sun daily and ask your doctor about a supplement.

Recreated with demo data — no real patient information.

03 — The tricky part

The PDF that
wouldn't download.

The reports looked right everywhere — but on some iPhones and some browsers, tapping "Download" simply did nothing.

The problem

Silent failure on mobile

Users on certain iPhones and browsers tapped Download and got nothing — no file, no error. Everywhere else, it worked fine.

The cause

The browser lost the click

The PDF takes a moment to generate. By the time it was ready, the browser no longer linked opening it to the user's tap — so it treated it like a popup and blocked it.

The fix

Open on tap, fill when ready

Wrote detection for the affected devices and browsers. On those, an empty window opens the instant the user taps, then receives the PDF once it's generated — downloads, and closes in a split second.

04 — My part

What I built.

The service was mine from the first endpoint to the final page layout.

Service

The microservice

Built the PHP service and the API the React app calls.

Template

The report design

Designed the dynamic HTML/CSS template that adapts to each patient's results.

Charts

The comparisons

Wired Chart.js into the template to show old vs. new values for each biomarker.

Accuracy

The rendering

Made sure complex health data lands in the PDF correctly — every value, every page.

PHPwkhtmltopdfChart.jsHTML / CSSJSON APIReact (consumer)