Module:BiologicalAgeBiomarkers: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 140: Line 140:


local rows = {
local rows = {
method = "Biological Age Estimation Method",
{key = "method", name = "Biological Age Estimation Method"},
year = "Year"
{key = "year", name = "Year"}
}
}


Line 193: Line 193:
wikitable = wikitable .. '\n'
wikitable = wikitable .. '\n'


     for key, name in pairs(rows) do
     for i, row in ipairs(rows) do
         wikitable = wikitable .. '|-\n'
         wikitable = wikitable .. '|-\n'
         wikitable = wikitable .. '| ' .. name .. ' || ' .. ''
         wikitable = wikitable .. '| ' .. row.name .. ' || ' .. ''
         for _, study in pairs(studies) do
         for _, study in pairs(studies) do
             local cellValue = study[key] or ""
             local cellValue = study[row.key] or ""
wikitable = wikitable .. ' || ' .. cellValue
wikitable = wikitable .. ' || ' .. cellValue
         end
         end
Line 204: Line 204:


     -- Generate rows for each biomarker
     -- Generate rows for each biomarker
     for i, details in ipairs(biomarkers) do
     for i, bm in ipairs(biomarkers) do
         wikitable = wikitable .. '|-\n'
         wikitable = wikitable .. '|-\n'
         wikitable = wikitable .. '| '  .. details.system .. ' || ' .. details.name
         wikitable = wikitable .. '| '  .. bm.system .. ' || ' .. bm.name
         for _, study in pairs(studies) do
         for _, study in pairs(studies) do
             -- Retrieve data value for the current cell, using the nested structure
             -- Retrieve data value for the current cell, using the nested structure
             local cellValue = study.data[details.key] or ""
             local cellValue = study.data[bm.key] or ""
             wikitable = wikitable .. ' || ' .. cellValue
             wikitable = wikitable .. ' || ' .. cellValue
         end
         end