Module:BiologicalAgeBiomarkers: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 7: Line 7:
     HDL = {name = "High-Density Lipoprotein (HDL)", system = "Endocrine Metabolic System"},
     HDL = {name = "High-Density Lipoprotein (HDL)", system = "Endocrine Metabolic System"},
     LDL = {name = "Low-Density Lipoprotein (LDL)", system = "Endocrine Metabolic System"}
     LDL = {name = "Low-Density Lipoprotein (LDL)", system = "Endocrine Metabolic System"}
}
local rows = {
method = "Biological Age Estimation Method",
year = "Year"
}
}


Line 12: Line 17:
local studies = {
local studies = {
     PMID12345 = {
     PMID12345 = {
    pmid = 12345,
         name = "Study1",
         name = "Study1",
        method = "MLR",
        year = "1995",
         data = {
         data = {
             SBP = "120 mmHg",
             SBP = "x",
             DBP = "80 mmHg",
             DBP = "x",
             HDL = "55 mg/dL",
             HDL = "x",
             LDL = "100 mg/dL"
             LDL = "x"
         }
         }
     },
     },
     PMID67890 = {
     PMID67890 = {
         name = "Study2",
         name = 67890,
        method = "MLR",
        year = "1995",
         data = {
         data = {
             SBP = "130 mmHg",
             SBP = "x",
             DBP = "85 mmHg",
             DBP = "x",
             HDL = "60 mg/dL",
             HDL = "x",
             LDL = "105 mg/dL"
             LDL = "x"
         }
         }
     },
     },
     PMID13579 = {
     PMID13579 = {
         name = "Study3",
         pmid = 13579,
        method = "MLR",
        year = "1995",
         data = {
         data = {
             SBP = "125 mmHg",
             SBP = "x",
             DBP = "82 mmHg",
             DBP = "x",
             HDL = "57 mg/dL",
             HDL = "x",
             LDL = "102 mg/dL"
             LDL = "x"
         }
         }
     }
     }
Line 47: Line 59:
     wikitable = wikitable .. ' System !! Biomarker'
     wikitable = wikitable .. ' System !! Biomarker'
     for _, study in pairs(studies) do
     for _, study in pairs(studies) do
         wikitable = wikitable .. ' !! '  .. study.name
         wikitable = wikitable .. ' !! '  .. study.pmid
    end
end
wikitable = wikitable .. '\n'
 
    for key, name in pairs(rows) do
        wikitable = wikitable .. '|-\n'
        wikitable = wikitable .. '| ' .. name .. ' || ' .. ''
        for _, study in pairs(studies) do
            local cellValue = study[key] or ""
wikitable = wikitable .. ' || ' .. cellValue
        end
wikitable = wikitable .. '\n'
end


     -- Generate rows for each biomarker
     -- Generate rows for each biomarker
     for abbr, details in pairs(biomarkers) do
     for abbr, details in pairs(biomarkers) do
         wikitable = wikitable .. '\n|-\n| ' .. details.system .. ' || ' .. details.name
         wikitable = wikitable .. '|-\n'
        wikitable = wikitable .. details.system .. ' || ' .. details.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[abbr] or "-"
             local cellValue = study.data[abbr] or ""
             wikitable = wikitable .. ' || ' .. cellValue
             wikitable = wikitable .. ' || ' .. cellValue
         end
         end
wikitable = wikitable .. '\n'
     end
     end