90 lines
3.2 KiB
PHP
90 lines
3.2 KiB
PHP
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Disease Diagnosis</title>
|
|
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
|
|
</head>
|
|
<body>
|
|
<div class="container mt-5">
|
|
<h2>Disease Diagnosis</h2>
|
|
<form method="post" action="">
|
|
<div class="form-group">
|
|
<label for="fever">Symptom A</label>
|
|
<select name="fever" id="fever" class="form-control">
|
|
<option value="1">Yes</option>
|
|
<option value="0.5">Maybe</option>
|
|
<option value="0">No</option>
|
|
</select>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="cough">Symptom B</label>
|
|
<select name="cough" id="cough" class="form-control">
|
|
<option value="1">Yes</option>
|
|
<option value="0.5">Maybe</option>
|
|
<option value="0">No</option>
|
|
</select>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="soreThroat">Symptom C</label>
|
|
<select name="soreThroat" id="soreThroat" class="form-control">
|
|
<option value="1">Yes</option>
|
|
<option value="0.5">Maybe</option>
|
|
<option value="0">No</option>
|
|
</select>
|
|
</div>
|
|
<button type="submit" class="btn btn-primary">Calculate CF</button>
|
|
<br>
|
|
<a href="index.php">Back To Dashboard</a>
|
|
</form>
|
|
|
|
<?php
|
|
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
|
// Function to calculate CF
|
|
function calculateCF($symptomValues, $rules) {
|
|
$combinedCF = 0;
|
|
foreach ($rules as $rule) {
|
|
$cfRule = $rule['cf'];
|
|
foreach ($rule['symptoms'] as $symptom => $weight) {
|
|
$cfRule *= $symptomValues[$symptom] * $weight;
|
|
}
|
|
$combinedCF = $combinedCF + $cfRule * (1 - $combinedCF);
|
|
}
|
|
return $combinedCF;
|
|
}
|
|
|
|
// Get symptom values from the form
|
|
$symptomValues = [
|
|
'fever' => (float)$_POST['fever'],
|
|
'cough' => (float)$_POST['cough'],
|
|
'soreThroat' => (float)$_POST['soreThroat'],
|
|
];
|
|
|
|
// Define the rules for DiseaseA
|
|
$rules = [
|
|
[
|
|
'symptoms' => [
|
|
'fever' => 1,
|
|
'cough' => 1,
|
|
],
|
|
'cf' => 0.8,
|
|
],
|
|
[
|
|
'symptoms' => [
|
|
'fever' => 1,
|
|
'soreThroat' => 1,
|
|
],
|
|
'cf' => 0.6,
|
|
],
|
|
];
|
|
|
|
// Calculate CF for DiseaseA
|
|
$cfDiseaseA = calculateCF($symptomValues, $rules);
|
|
echo "<div class='alert alert-info mt-3'>Certainty Factor for Disease X: " . $cfDiseaseA . "</div>";
|
|
}
|
|
?>
|
|
</div>
|
|
</body>
|
|
</html>
|