Skip to content

Instantly share code, notes, and snippets.

@devloe
Created July 20, 2017 10:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devloe/3dc5711ab15d20598818ddfcb5f5f625 to your computer and use it in GitHub Desktop.
Save devloe/3dc5711ab15d20598818ddfcb5f5f625 to your computer and use it in GitHub Desktop.
<?php
class CardioRisk {
public static function calculateFemale($age, $cholesterol, $hdl_c, $systolic, $diastolic, $db, $smoker) {
$total_points = 0;
// Edad
if($age > 30 && $age < 34) {
$total_points += -9;
}
if($age > 35 && $age < 39) {
$total_points += -4;
}
if($age > 40 && $age < 44) {
$total_points += 0;
}
if($age > 45 && $age < 49) {
$total_points += 3;
}
if($age > 50 && $age < 54) {
$total_points += 6;
}
if($age > 55 && $age < 59) {
$total_points += 7;
}
if($age > 60 && $age < 64) {
$total_points += 8;
}
if($age > 65 && $age < 69) {
$total_points += 8;
}
if($age > 70 && $age < 74) {
$total_points += 8;
}
/*if($ldl_c < 100) {
$total_points += -2;
}
if($ldl_c > 100 && $age < 159) {
$total_points += 0;
}
if($ldl_c > 160 && $age < 190) {
$total_points += 2;
}
if($ldl_c >= 190) {
$total_points += 2;
}*/
// total cholesterol
if($cholesterol < 160) {
$total_points += -2;
}
if($cholesterol > 160 && $cholesterol < 199) {
$total_points += 0;
}
if($cholesterol > 200 && $cholesterol < 239) {
$total_points += 1;
}
if($cholesterol > 240 && $cholesterol < 279) {
$total_points += 1;
}
if($cholesterol >= 280) {
$total_points += 3;
}
if($hdl_c < 35) {
$total_points += 5;
}
if($hdl_c > 35 && $hdl_c < 44) {
$total_points += 2;
}
if($hdl_c > 45 && $hdl_c < 49) {
$total_points += 1;
}
if($hdl_c >= 60) {
$total_points += -2;
}
// Presión arterial (mm Hg)
if($systolic > 130 && $systolic < 139 && $diastolic > 85 && $diastolic < 89) {
$total_points += -3;
}
if($systolic > 140 && $systolic < 159 && $diastolic > 90 && $diastolic < 99) {
$total_points += 2;
}
if($systolic >= 160 && $diastolic >= 100) {
$total_points += 3;
}
// Diabetic
if($db) {
$total_points += 4;
}
// Smoker
if($smoker) {
$total_points += 2;
}
return $total_points;
}
public static function calculateMale($age, $cholesterol, $hdl_c, $systolic, $diastolic, $db, $smoker) {
$total_points = 0;
if($age > 30 && $age < 34) {
$total_points += -1;
}
if($age > 35 && $age < 39) {
$total_points += 0;
}
if($age > 40 && $age < 44) {
$total_points += 1;
}
if($age > 45 && $age < 49) {
$total_points += 2;
}
if($age > 50 && $age < 54) {
$total_points += 3;
}
if($age > 55 && $age < 59) {
$total_points += 4;
}
if($age > 60 && $age < 64) {
$total_points += 5;
}
if($age > 65 && $age < 69) {
$total_points += 6;
}
if($age > 70 && $age < 74) {
$total_points += 7;
}
/*if($ldl_c < 100) {
$total_points += -3;
}
if($ldl_c > 100 && $age < 159) {
$total_points += 0;
}
if($ldl_c > 160 && $age < 190) {
$total_points += 1;
}
if($ldl_c >= 190) {
$total_points += 2;
}*/
if($cholesterol < 160) {
$total_points += -3;
}
if($cholesterol > 160 && $cholesterol < 199) {
$total_points += 0;
}
if($cholesterol > 200 && $cholesterol < 239) {
$total_points += 1;
}
if($cholesterol > 240 && $cholesterol < 279) {
$total_points += 2;
}
if($cholesterol >= 280) {
$total_points += 3;
}
if($hdl_c < 35) {
$total_points += 2;
}
if($hdl_c > 35 && $hdl_c < 44) {
$total_points += 1;
}
if($hdl_c > 45 && $hdl_c < 59) {
$total_points += 0;
}
if($hdl_c >= 60) {
$total_points += -2;
}
if($systolic > 130 && $systolic < 139 && $diastolic > 85 && $diastolic < 89) {
$total_points += 1;
}
if($systolic > 140 && $systolic < 159 && $diastolic > 90 && $diastolic < 99) {
$total_points += 2;
}
if($systolic >= 160 && $diastolic >= 100) {
$total_points += 3;
}
if($db) {
$total_points += 2;
}
if($smoker) {
$total_points += 2;
}
return $total_points;
}
public static function resultMale($point) {
$value = 0;
if($point < -3) {
$value = 1;
}
if($point == -2 || $point == -1) {
$value = 2;
}
if($point == 0) {
$value = 3;
}
if($point == 1 || $point == 2) {
$value = 4;
}
if($point == 3) {
$value = 6;
}
if($point == 4) {
$value = 7;
}
if($point == 5) {
$value = 9;
}
if($point == 6) {
$value = 11;
}
if($point == 7) {
$value = 14;
}
if($point == 8) {
$value = 18;
}
if($point == 9) {
$value = 22;
}
if($point == 10) {
$value = 27;
}
if($point == 11) {
$value = 33;
}
if($point == 12) {
$value = 40;
}
if($point == 13) {
$value = 47;
}
if($point >= 14) {
$value = 56;
}
return $value;
}
public static function resultFemale($point) {
$value = 0;
if($point < -2) {
$value = 1;
}
if($point == -1 || $point == 0 || $point == 1) {
$value = 2;
}
if($point == 2 || $point == 3) {
$value = 3;
}
if($point == 4) {
$value = 4;
}
if($point == 5) {
$value = 5;
}
if($point == 6) {
$value = 6;
}
if($point == 7) {
$value = 7;
}
if($point == 8) {
$value = 8;
}
if($point == 9) {
$value = 9;
}
if($point == 10) {
$value = 11;
}
if($point == 11) {
$value = 13;
}
if($point == 12) {
$value = 15;
}
if($point == 13) {
$value = 17;
}
if($point == 14) {
$value = 20;
}
if($point == 15) {
$value = 24;
}
if($point == 16) {
$value = 27;
}
if($point >= 17) {
$value = 32;
}
return $value;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment