Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
71.43% |
5 / 7 |
CRAP | |
95.65% |
44 / 46 |
PatientRepo | |
0.00% |
0 / 1 |
|
71.43% |
5 / 7 |
9 | |
95.65% |
44 / 46 |
getById | |
100.00% |
1 / 1 |
1 | |
100.00% |
3 / 3 |
|||
add | |
0.00% |
0 / 1 |
2.00 | |
93.75% |
15 / 16 |
|||
update | |
0.00% |
0 / 1 |
2.00 | |
94.44% |
17 / 18 |
|||
delete | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
updateMedecinTraitant | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
search | |
100.00% |
1 / 1 |
1 | |
100.00% |
3 / 3 |
|||
getAll | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
<?php | |
/** | |
* Created by PhpStorm. | |
* User: seekdasky | |
* Date: 02/12/15 | |
* Time: 12:36 | |
*/ | |
class PatientRepo | |
{ | |
public static function getById($id){ | |
//if(!StaticRepo::checkParam($id,'Integer')){print_r(is_int($id));} | |
$req = StaticRepo::getConnexion()->prepare('SELECT * FROM Patient WHERE Id = :id'); | |
$req->execute(['id' => $id]); | |
return StaticRepo::delNumeric( $req->fetch(), true ); | |
} | |
public static function add($civilite,$prenom,$nom,$adresse,$adresse2,$ville,$codePostal,$dateNaissance,$lieuNaissance,$numSecu,$medecinTraitant = null){ | |
$dateNaissance = strtotime($dateNaissance); | |
$dateNaissance = Date('o-m-d',$dateNaissance); | |
$req = StaticRepo::getConnexion()->prepare('INSERT INTO Patient VALUES (DEFAULT,:civilite,:nom,:prenom,:adresse,:adresse2,:ville,:codePostal,:dateNaissance,:lieuNaissance,:numSecu,:medecin)'); | |
$result = $req->execute(['civilite' => $civilite, | |
'nom' => $nom, | |
'prenom' => $prenom, | |
'adresse' => $adresse, | |
'adresse2' => $adresse2, | |
'ville' => $ville, | |
'codePostal' => $codePostal, | |
'dateNaissance' => $dateNaissance, | |
'lieuNaissance' => $lieuNaissance, | |
'numSecu' => $numSecu, | |
'medecin' => $medecinTraitant ]); | |
if($result){return StaticRepo::getConnexion()->lastInsertId();} | |
else{return false;} | |
} | |
public static function update($id,$civilite,$prenom,$nom,$adresse,$adresse2,$ville,$codePostal,$dateNaissance,$lieuNaissance,$numSecu,$medecinTraitant){ | |
$dateNaissance = strtotime($dateNaissance); | |
$dateNaissance = Date('o-m-d',$dateNaissance); | |
$req = StaticRepo::getConnexion()->prepare('UPDATE Patient SET Civilite=:civilite,Nom=:nom,Prenom=:prenom,Adresse=:adresse,Adresse2=:adresse2,Ville=:ville, | |
CodePostal=:codePostal,DateNaissance=:dateNaissance,LieuNaissance=:lieuNaissance,NumSecuriteSociale=:numSecu,MedecinTraitant=:medecin WHERE Id=:id;'); | |
$result = $req->execute(['civilite' => $civilite, | |
'nom' => $nom, | |
'prenom' => $prenom, | |
'adresse' => $adresse, | |
'adresse2' => $adresse2, | |
'ville' => $ville, | |
'codePostal' => $codePostal, | |
'dateNaissance' => $dateNaissance, | |
'lieuNaissance' => $lieuNaissance, | |
'numSecu' => $numSecu, | |
'medecin' => $medecinTraitant, | |
'id' => $id]); | |
if($result){return StaticRepo::getConnexion()->lastInsertId();} | |
else{return false;} | |
} | |
public static function delete($idPatient){ | |
//if(!StaticRepo::checkParam($idPatient,'Integer')){ printf($idPatient);return false;} | |
$req = StaticRepo::getConnexion()->prepare('DELETE FROM Patient WHERE Patient.Id = :id'); | |
return $req->execute(['id' => $idPatient]); | |
} | |
public static function updateMedecinTraitant($idPatient,$idMedecin){ | |
//if(!StaticRepo::checkParam($idPatient,'Integer') && !StaticRepo::checkParam($idMedecin,'Integer')){return false;} | |
$req = StaticRepo::getConnexion()->prepare('UPDATE Patient SET MedecinTraitant = :medecin WHERE Id = :id'); | |
return $req->execute(['medecin' => $idMedecin, 'id' => $idPatient]); | |
} | |
public static function search($nom,$prenom){ | |
$req = StaticRepo::getConnexion()->prepare('SELECT * FROM Patient WHERE Nom LIKE :nom AND Prenom LIKE :prenom'); | |
$req->execute(['nom' => $nom, 'prenom' => $prenom]); | |
return StaticRepo::delNumeric($req->fetchAll()); | |
} | |
public static function getAll(){ | |
$req = StaticRepo::getConnexion()->query('SELECT * FROM Patient ORDER BY nom, prenom ASC'); | |
return StaticRepo::delNumeric( $req->fetchAll() ); | |
} | |
} |