Attack Rate Calculation Epidemiology

Attack Rate Calculator

The attack rate is a measure used in epidemiology to describe the proportion of a population that becomes infected or develops a disease during a specific period, especially in relation to a known exposure. It is particularly useful for assessing the risk associated with a particular outbreak or exposure event. The formula is straightforward:

Attack Rate = (Number of cases in a population exposed to a risk factor) / (Total number of individuals exposed to the risk factor)

It is often expressed as a percentage.

function calculateAttackRate() { var exposedPopulation = parseFloat(document.getElementById("exposedPopulation").value); var casesExposed = parseFloat(document.getElementById("casesExposed").value); var resultDiv = document.getElementById("result"); resultDiv.innerHTML = ""; // Clear previous results if (isNaN(exposedPopulation) || isNaN(casesExposed)) { resultDiv.innerHTML = "Please enter valid numbers for all fields."; return; } if (exposedPopulation <= 0) { resultDiv.innerHTML = "Total exposed population must be greater than zero."; return; } if (casesExposed exposedPopulation) { resultDiv.innerHTML = "Number of cases cannot exceed the total exposed population."; return; } var attackRate = (casesExposed / exposedPopulation) * 100; resultDiv.innerHTML = "

Attack Rate:

" + attackRate.toFixed(2) + "%"; } .calculator-container { font-family: sans-serif; border: 1px solid #ccc; padding: 20px; border-radius: 8px; max-width: 500px; margin: 20px auto; background-color: #f9f9f9; } .calculator-container h2 { text-align: center; color: #333; margin-bottom: 15px; } .calculator-container p { line-height: 1.6; color: #555; margin-bottom: 15px; } .inputs { margin-bottom: 20px; } .inputs label { display: block; margin-bottom: 8px; font-weight: bold; color: #444; } .inputs input[type="number"] { width: calc(100% – 20px); padding: 10px; margin-bottom: 15px; border: 1px solid #ddd; border-radius: 4px; box-sizing: border-box; } .calculator-container button { display: block; width: 100%; padding: 12px 20px; background-color: #007bff; color: white; border: none; border-radius: 4px; font-size: 16px; cursor: pointer; transition: background-color 0.3s ease; } .calculator-container button:hover { background-color: #0056b3; } .result-container { margin-top: 25px; padding: 15px; background-color: #e9ecef; border: 1px solid #ced4da; border-radius: 4px; text-align: center; } .result-container h3 { margin-top: 0; color: #333; } .result-container p { font-size: 1.2em; font-weight: bold; color: #28a745; margin-bottom: 0; }

Leave a Comment