<?php
namespace App\Services\Health;
class GenCardioLipids
{
protected $params;
protected $sex;
protected $age;
protected $sysBloodPresure;
protected $treatmentForHypertension;
protected $smoking;
protected $diabetes;
protected $hDL;
protected $totalCholesterol;
public function __construct(
ParametersInterface $params,
int $sex,
int $age,
int $sysBloodPresure,
bool $treatmentForHypertension,
bool $smoking,
bool $diabetes,
int $hDL,
int $totalCholesterol
) {
$this->params = $params;
$this->sex = $sex;
$this->age = $age;
$this->sysBloodPresure = $sysBloodPresure;
$this->treatmentForHypertension = $treatmentForHypertension;
$this->smoking = $smoking;
$this->diabetes = $diabetes;
$this->hDL = $hDL;
$this->totalCholesterol = $totalCholesterol;
}
public function generateCvdRiskPredictionUsingLipids()
{
$sex = $this->sex;
$age = log($this->age);
$sbp = log($this->sysBloodPresure);
$tcl = log($this->totalCholesterol);
$hdl = log($this->hDL);
$trtbp = $this->treatmentForHypertension ? 1 : 0;
$smoke = $this->smoking ? 1 : 0;
$diab = $this->diabetes ? 1 : 0;
$sumBetaX_No_SBP_Trt = $age * $this->params->getAGE() + $sbp * $this->params->getSBPNOTRT() + $tcl * $this->params->getTCL() + $hdl * $this->params->getHDL() + $smoke * $this->params->getSMOKE() + $diab * $this->params->getDIAB();
$sumBetaX_SBP_With_Trt = $age * $this->params->getAGE() + $sbp * $this->params->getSBPTRT() + $tcl * $this->params->getTCL() + $hdl * $this->params->getHDL() + $smoke * $this->params->getSMOKE() + $diab * $this->params->getDIAB();
$riskScore_No_SBP_Trt = 1 - pow(0.88936, exp($sumBetaX_No_SBP_Trt - 23.9802));
$riskScore_With_SBP_Trt = 1 - pow(0.88936, exp($sumBetaX_SBP_With_Trt - 23.9802));
$sumBetaX_No_SBP_Trt_OPTIMAL = $this->params->getAGE() * $age + $this->params->getSBPNOTRT() * log(110) + $this->params->getTCL() * log(160) + $this->params->getHDL() * log(60);
$sumBetaX_No_SBP_Trt_NORMAL = $this->params->getAGE() * $age + $this->params->getSBPNOTRT() * log(125) + $this->params->getTCL() * log(180) + $this->params->getHDL() * log(45);
$optimalRisk = 1 - pow(0.88936, exp($sumBetaX_No_SBP_Trt_OPTIMAL - 23.9802));
$normalRisk = 1 - pow(0.88936, exp($sumBetaX_No_SBP_Trt_NORMAL - 23.9802));
$riskScore_No_SBP_Trt = $riskScore_No_SBP_Trt * 100;
$riskScore_With_SBP_Trt = $riskScore_With_SBP_Trt * 100;
$sumBetaX_No_SBP_Trt_OPTIMAL = $sumBetaX_No_SBP_Trt_OPTIMAL * 100;
$sumBetaX_No_SBP_Trt_NORMAL = $sumBetaX_No_SBP_Trt_NORMAL * 100;
$optimalRisk = $optimalRisk * 100;
$normalRisk = $normalRisk * 100;
return compact(
'sumBetaX_No_SBP_Trt',
'sumBetaX_SBP_With_Trt',
'riskScore_No_SBP_Trt',
'riskScore_With_SBP_Trt',
'sumBetaX_No_SBP_Trt_OPTIMAL',
'sumBetaX_No_SBP_Trt_NORMAL',
'optimalRisk',
'normalRisk'
);
}
}