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