Help, I need to get latest vitals and age to use them on a custom document template

I am doing a document template that is a custom report, it gets data from many LBF forms, some DEM and HIS fields as well.
But I don’t know how to get patient’s latest vital (weight and BMI).

Any advise? I believe I have to update download_template.php (/interface/patient_file/download_template.php), maybe add some additional substitutions on doSubs for example {PatientAge}{VIT:latestWeight} {VIT:BMI}.
I know PatientAge can be calculated based on todays date and DOB, maybe we can record patientAge in vitals, that way we can track vitals as a timeseries related to its patient.
There is another code that may help (here it is calculated patientAge) interface/forms/vitals/report.php this may help to solve this need, but I don’t know how to?

OpenEMR Version
I’m using OpenEMR version 7.0.1

I’m using: Chrome

Operating System
I’m using: Ubuntu 22.04

Did you search the forum for similar questions? Yes!

Did you check the logs?
Was there anything pertinent in them?
Please paste them here (surround with three backticks (```) for readability.
You can also turn on User Debugging under Administration->Globals->Logging User Debugging Options=>All