Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
50.00% covered (danger)
50.00%
1 / 2
CRAP
92.31% covered (success)
92.31%
24 / 26
StatsRepo
0.00% covered (danger)
0.00%
0 / 1
50.00% covered (danger)
50.00%
1 / 2
9.04
92.31% covered (success)
92.31%
24 / 26
 getAgePatient
0.00% covered (danger)
0.00%
0 / 1
8.04
91.30% covered (success)
91.30%
21 / 23
 getRDVStat
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
3 / 3
<?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];
        foreach($patients as $key=>$patient){
            $dateNaissance = strtotime($patient['DateNaissance']);
            $age = date('Y',time()-$dateNaissance);
            $patient['age'] = $age - 1970;
            switch($patient['Civilite']){
                case 'M':
                    if($patient['age']<25){
                        $homme['25-']++;
                    }elseif($patient['age']<50){
                        $homme['25-50']++;
                    }else{
                        $homme['50+']++;
                    }
                    break;
                case 'F':
                    if($patient['age']<25){
                        $femme['25-']++;
                    }elseif($patient['age']<50){
                        $femme['25-50']++;
                    }else{
                        $femme['50+']++;
                    }
                    break;
            }
        }
        return ['H'=>$homme,'F'=>$femme];
    }
    public static function getRDVStat($medecin){
        $req = StaticRepo::getConnexion()->prepare('SELECT count(*) NombreRDV FROM RDV WHERE Medecin_id = :medecin;');
        $req->execute(['medecin'=>$medecin]);
        return StaticRepo::delNumeric($req->fetch(),true);
    }
}