Module:BiologicalAgeBiomarkers: Difference between revisions

no edit summary
No edit summary
No edit summary
 
(29 intermediate revisions by the same user not shown)
Line 1: Line 1:
local p = {}
local p = {}


-- Define biomarkers with their long form and system
local data = require('Module:BiologicalAgeBiomarkers/Data')
local biomarkers = {
{
system = "Cardiovascular System",
data = {
{key = "SBP", name = "Systolic Blood Pressure (SBP)"},
{key = "DBP", name = "Diastolic Blood Pressure (DBP)"},
{key = "PP", name = "Pulse Pressure"},
{key = "MAP", name = "Mean Arterial Pressure"},
{key = "Pulse", name = "Pulse"},
{key = "PWV", name = "Pulse Wave Velocity"},
{key = "HR", name = "Heart Rate"},
{key = "IMT", name = "Intima-Media Thickness"},
{key = "MinIMT", name = "Minimum Intima-Media Thickness"},
{key = "EDV", name = "End Diastolic Velocity"},
{key = "MVEAP", name = "Mitral Valve E/A Peak"},
{key = "MVEL_MVES_MVEA", name = "MVEL, MVES, MVEA"},
{key = "AI", name = "Atherosclerosis Index"},
{key = "NTproBNP", name = "NT-proBNP"},
{key = "CTnI", name = "Cardiac Troponin I"},
{key = "CPK", name = "Creatine Phosphokinase"},
{key = "Homocysteine", name = "Homocysteine"},
}
},


{
local biomarkers = data.biomarkers
system = "Respiratory System",
local rows = data.rows
data = {
local studies = data.studies
{key = "FVC", name = "Forced Vital Capacity (FVC)"},
{key = "FEV1", name = "Forced Expiratory Volume in 1 Second (FEV1)"},
{key = "VC", name = "Vital Capacity"},
{key = "MMFR", name = "Maximal Midexpiratory Flow Rate 75/25"},
{key = "VO2Max", name = "VO2 Max"},
{key = "CR", name = "Chest Radiography"},
}
},


{
function p.template(frame, name, arg)
system = "Nervous System",
return frame:expandTemplate({title = name, args = { arg }})
data = {
end
{key = "MMSE", name = "Mini-Mental State Examination (MMSE)"},
{key = "DST", name = "Digital Symbol Test"},
{key = "NM", name = "Numeric Memory"},
{key = "AM", name = "Associated Memory"},
{key = "TM", name = "Topological Memory"},
{key = "STM", name = "Short-Time Memory"},
{key = "Concentration", name = "Concentration"},
{key = "IMD", name = "Intellectuality - Mental Defect"},
{key = "TMT", name = "Trail Making Test"},
}
},
{
system = "Endocrine Metabolic System",
data = {
{key = "Glucose", name = "Glucose"},
{key = "HBA1C", name = "HBA1C"},
{key = "CPeptide", name = "C-peptide"},
{key = "Insulin", name = "Insulin"},
{key = "TG", name = "Triglyceride"},
{key = "TC", name = "Total Cholesterol (TC)"},
{key = "HDL", name = "High-Density Lipoprotein (HDL)"},
{key = "LDL", name = "Low-Density Lipoprotein (LDL)"},
{key = "ApoA1B", name = "Apolipoprotein A1 and B"},
{key = "TSH", name = "Thyroid-Stimulating Hormone (TSH)"},
{key = "Testosterone", name = "Testosterone"},
{key = "VitaminD", name = "Vitamin D"},
{key = "Calcium", name = "Calcium"},
{key = "Potassium", name = "Potassium"},
{key = "Sodium", name = "Sodium"},
{key = "InorganicPhosphorus", name = "Inorganic Phosphorus"},
{key = "Urea", name = "Urea"},
{key = "Creatinine", name = "Creatinine"},
{key = "eGFR", name = "Estimated Glomerular Filtration Rate (eGFR)"},
{key = "UricAcid", name = "Uric Acid"},
{key = "CystatinC", name = "Cystatin C"},
{key = "CreatinineClearance", name = "Creatinine Clearance"},
{key = "UrineSG", name = "Urine Specific Gravity"},
{key = "UrinepH", name = "Urine pH"},
}
},
{
system = "Digestive System",
data = {
{key = "ALT", name = "Alanine Aminotransferase (ALT)"},
{key = "AST", name = "Aspartate Aminotransferase (AST)"},
{key = "ALP", name = "Alkaline Phosphatase (ALP)"},
{key = "TotalProtein", name = "Total Protein"},
{key = "Albumin", name = "Albumin"},
{key = "AGRatio", name = "Albumin/Globulin Ratio (A/G)"},
{key = "TotalBilirubin", name = "Total Bilirubin"},
{key = "DirectBilirubin", name = "Direct Bilirubin"},
{key = "Amylase", name = "Amylase"},
{key = "LDH", name = "Lactate Dehydrogenase"},
{key = "Alpha2Globulin", name = "Alpha 2 Globulin"},
{key = "GGT", name = "Gamma Glutamyl Transpeptidase"},
}
},


{
function p.createCrossTable(frame)
system = "Hematologic System",
    for _, study in ipairs(studies) do
data = {
    local count = 0
{key = "RBC", name = "Red Blood Cell"},
for _ in pairs(study.biomarkers) do
{key = "RDW", name = "Red Blood Cell Volume Distribution Width"},
count = count + 1
{key = "Hematocrit", name = "Hematocrit"},
end
{key = "MCV", name = "Mean Corpuscular Volume"},
    study.count = count
{key = "MCH", name = "Mean Corpuscular Hemoglobin"},
end
{key = "MCHC", name = "Mean Corpuscular Hemoglobin Concentration"},
{key = "Hemoglobin", name = "Hemoglobin"},
{key = "WBC", name = "White Blood Cell"},
{key = "Granulocytes", name = "Granulocytes"},
{key = "Neutrophils", name = "Neutrophils"},
{key = "BasophilsEosinophils", name = "Basophils, Eosinophils"},
{key = "Lymphocytes", name = "Lymphocytes"},
{key = "Monocytes", name = "Monocytes"},
{key = "Platelet", name = "Platelet"},
{key = "MPV", name = "Mean Platelet Volume"},
{key = "PDW", name = "Platelet Distribution Width"},
{key = "ESR", name = "Erythrocyte Sedimentation Rate"},
{key = "DdimerFibrinogen", name = "D-dimer, Fibrinogen"},
{key = "Ferritin", name = "Ferritin"},
{key = "Transferrin", name = "Transferrin"},
}
},
{
system = "Sensory System",
data = {
{key = "VisualAcc", name = "Visual Accommodation"},
{key = "VisualReactTime", name = "Visual Reaction Time"},
{key = "VisualAcuity", name = "Visual Acuity"},
{key = "Hearing", name = "Hearing"},
{key = "Vibrotactile", name = "Vibrotactile"},
{key = "RetinalPhotos", name = "Retinal Photos"},
}
},
{
system = "Inflammatory System",
data = {
{key = "CRP", name = "C-Reactive Protein (CRP)"},
{key = "CMVOptDensity", name = "Cytomegalovirus Optical Density"},
{key = "IL6", name = "Interleukin-6"},
{key = "Pselectin", name = "P-selectin"},
}
},
{
system = "Motion Index",
data = {
{key = "GripStrength", name = "Grip Strength"},
{key = "VerticalJump", name = "Vertical Jump"},
{key = "TUGTest", name = "Timed Up and Go Test"},
{key = "ChairRiseTime", name = "Chair Rise Time"},
{key = "PhysicalActivityWeek", name = "1-Week Physical Activity"},
}
},
{
system = "Body Morphology Index",
data = {
{key = "WC", "Waist Circumference (WC)"},
{key = "WaistHipRatio", name = "Waist-to-Hip Ratio"},
{key = "WaistHeightRatio", name = "Waist-to-Height Ratio"},
{key = "BMI", name = "Body Mass Index (BMI)"},
{key = "Weight", name = "Weight"},
{key = "Height", name = "Height"},
{key = "BodyFat", name = "Body Fat"},
{key = "LeanBodyMass", name = "Lean Body Mass"},
{key = "SoftLeanMass", name = "Soft Lean Mass"},
}
},
{
system = "Genetic Index",
data = {
{key = "TelomereLength", name = "Terminal Telomere Restriction Fragment"},
}
},
}
local rows = {
{key = "method", name = "Biological Age Estimation Method"},
{key = "year", name = "Year"}
}
-- Incorporate data directly into studies identified by PMID
local studies = {
    {
    pmid = "12345",
        method = "MLR",
        year = "1995",
        biomarkers = { SBP = "x", DBP = "x", HDL = "x", LDL = "x" }
    },
    {
        pmid = "67890",
        method = "MLR",
        year = "1995",
        biomarkers = { SBP = "x", DBP = "x", HDL = "x", LDL = "x" }
    },
    {
        pmid = "13579",
        method = "MLR",
        year = "1995",
        biomarkers = { SBP = "x", DBP = "x", HDL = "x", LDL = "x" }
    }
}
function p.createCrossTable()
     -- Start of the wiki table
     -- Start of the wiki table
     local wikitable = '{| class="wikitable"\n!'
     local wikitable = '{| class="wikitable sortable"\n'
 
     local sep = ''
    -- Column headers: Biomarker and System
    wikitable = wikitable .. ' System !! Biomarker'
     for _, study in pairs(studies) do
        wikitable = wikitable .. ' !! '  .. study.pmid
end
wikitable = wikitable .. '\n'


     for i, row in ipairs(rows) do
     for i, row in ipairs(rows) do
         wikitable = wikitable .. '|-\n'
         wikitable = wikitable .. sep
         wikitable = wikitable .. '| ' .. row.name .. ' || ' .. ''
        sep = '|-\n'
         wikitable = wikitable .. '! colspan="3" | ' .. row.name .. '\n'
         for _, study in ipairs(studies) do
         for _, study in ipairs(studies) do
             local cellValue = study[row.key] or ""
             local cellValue = study[row.key] or ""
wikitable = wikitable .. ' || ' .. cellValue
            if (row.rotate) then
cellValue =  p.template(frame, "VerticalText", cellValue)
else
end
wikitable = wikitable .. '! ' .. cellValue .. '\n'
         end
         end
wikitable = wikitable .. '\n'
end
end
    -- Column headers: Biomarker and System
    wikitable = wikitable .. '|-\n'
    wikitable = wikitable .. '! System !! Biomarker !! Count '
    for _, study in pairs(studies) do
        wikitable = wikitable .. ' !! ' .. p.template(frame, "pmid", study.pmid)
end
wikitable = wikitable .. '\n'


     -- Generate rows for each biomarker
     -- Generate rows for each biomarker
Line 236: Line 51:
        wikitable = wikitable .. '|-\n'
        wikitable = wikitable .. '|-\n'
        wikitable = wikitable .. '| '  .. system.system .. ' || ' .. bm.name
        wikitable = wikitable .. '| '  .. system.system .. ' || ' .. bm.name
       
        local count = 0
        for _, study in ipairs(studies) do
        if study.biomarkers[bm.key] ~= nil then
    count = count + 1
        end
end
        wikitable = wikitable .. string.format(' || %d', count)
       
        for _, study in ipairs(studies) do
        for _, study in ipairs(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.biomarkers[bm.key] or ""
            local cellValue = study.biomarkers[bm.key] or ""
            wikitable = wikitable .. ' || ' .. cellValue
        if cellValue == "x" then
        cellValue = 'style="background-color:gray; color: transparent;" | ' .. cellValue
        elseif cellValue ~= "" then
        cellValue = 'style="background-color:gray;" | ' .. cellValue
            end
            wikitable = wikitable .. ' || ' .. cellValue
        end
        end
wikitable = wikitable .. '\n'
wikitable = wikitable .. '\n'