projet-php/repositories/repos/StatsRepo.php

62 lines
1.7 KiB
PHP
Raw Permalink Normal View History

<?php
/**
* Created by PhpStorm.
* User: seekdasky
* Date: 02/12/15
* Time: 12:36
*/
class StatsRepo
{
public static function getAgePatient(){
$patients = PatientRepo::getAll();
$homme = ['25-'=>0,'25-50'=>0,'50+'=>0];
$femme = ['25-'=>0,'25-50'=>0,'50+'=>0];
$nbrHomme=0;
$nbrFemme=0;
foreach($patients as $key=>$patient){
$dateNaissance = strtotime($patient['DateNaissance']);
$age = date('Y',time()-$dateNaissance);
$patient['age'] = $age - 1970;
switch($patient['Civilite']){
case 'M':
$nbrHomme++;
if($patient['age']<25){
$homme['25-']++;
}elseif($patient['age']<50){
$homme['25-50']++;
}else{
$homme['50+']++;
}
break;
case 'F':
$nbrFemme++;
if($patient['age']<25){
$femme['25-']++;
}elseif($patient['age']<50){
$femme['25-50']++;
}else{
$femme['50+']++;
}
break;
}
}
return ['H'=>$homme,'F'=>$femme,'NbrH'=>$nbrHomme,'NbrF'=>$nbrFemme];
}
public static function getRDVStat($medecin){
$req = StaticRepo::getConnexion()->prepare('SELECT count(*) NombreRDV, sum((HOUR(Duree)*60)+MINUTE(Duree)) AS DureeTotale FROM RDV WHERE Medecin_id = :medecin;');
$req->execute(['medecin'=>$medecin]);
$returned = StaticRepo::delNumeric($req->fetch(),true);
return $returned;
}
}