Module:BiologicalAgeBiomarkers: Difference between revisions

    From Longevity Wiki
    No edit summary
    No edit summary
    Line 3: Line 3:
    -- Define biomarkers with their long form and system
    -- Define biomarkers with their long form and system
    local biomarkers = {
    local biomarkers = {
         SBP = {longForm = "Systolic Blood Pressure", system = "Cardiovascular System"},
         SBP = {name = "Systolic Blood Pressure (SBP)", system = "Cardiovascular System"},
         DBP = {longForm = "Diastolic Blood Pressure", system = "Cardiovascular System"},
         DBP = {name = "Diastolic Blood Pressure (DBP)", system = "Cardiovascular System"},
         HDL = {longForm = "High-Density Lipoprotein", system = "Endocrine Metabolic System"},
         HDL = {name = "High-Density Lipoprotein (HDL)", system = "Endocrine Metabolic System"},
         LDL = {longForm = "Low-Density Lipoprotein", system = "Endocrine Metabolic System"}
         LDL = {name = "Low-Density Lipoprotein (LDL)", system = "Endocrine Metabolic System"}
    }
    }


    Line 45: Line 45:


         -- Column headers: Biomarker and System
         -- Column headers: Biomarker and System
         wikitable = wikitable .. ' !! Biomarker !! System'
         wikitable = wikitable .. ' System !! Biomarker'
         for _, study in pairs(studies) do
         for _, study in pairs(studies) do
             wikitable = wikitable .. ' !! ' .. study.name
             wikitable = wikitable .. ' !! ' .. study.name
         end
         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.longForm .. ' || ' .. details.system
             wikitable = wikitable .. '\n|-\n| ' .. 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

    Revision as of 01:23, 19 February 2024

    Output the biological age biomarkers table.

    Data is stored in Module:BiologicalAgeBiomarkers/Data


    local p = {}
    
    -- Define biomarkers with their long form and system
    local biomarkers = {
        SBP = {name = "Systolic Blood Pressure (SBP)", system = "Cardiovascular System"},
        DBP = {name = "Diastolic Blood Pressure (DBP)", system = "Cardiovascular System"},
        HDL = {name = "High-Density Lipoprotein (HDL)", system = "Endocrine Metabolic System"},
        LDL = {name = "Low-Density Lipoprotein (LDL)", system = "Endocrine Metabolic System"}
    }
    
    -- Incorporate data directly into studies identified by PMID
    local studies = {
        PMID12345 = {
            name = "Study1",
            data = {
                SBP = "120 mmHg",
                DBP = "80 mmHg",
                HDL = "55 mg/dL",
                LDL = "100 mg/dL"
            }
        },
        PMID67890 = {
            name = "Study2",
            data = {
                SBP = "130 mmHg",
                DBP = "85 mmHg",
                HDL = "60 mg/dL",
                LDL = "105 mg/dL"
            }
        },
        PMID13579 = {
            name = "Study3",
            data = {
                SBP = "125 mmHg",
                DBP = "82 mmHg",
                HDL = "57 mg/dL",
                LDL = "102 mg/dL"
            }
        }
    }
    
    function p.createCrossTable()
        -- Start of the wiki table
        local wikitable = '{| class="wikitable"\n!'
    
        -- Column headers: Biomarker and System
        wikitable = wikitable .. ' System !! Biomarker'
        for _, study in pairs(studies) do
            wikitable = wikitable .. ' !! '  .. study.name
        end
    
        -- Generate rows for each biomarker
        for abbr, details in pairs(biomarkers) do
            wikitable = wikitable .. '\n|-\n| ' .. details.system .. ' || ' .. details.name
            for _, study in pairs(studies) do
                -- Retrieve data value for the current cell, using the nested structure
                local cellValue = study.data[abbr] or "-"
                wikitable = wikitable .. ' || ' .. cellValue
            end
        end
    
        -- End of the table
        wikitable = wikitable .. '\n|}'
    
        return wikitable
    end
    
    return p