68 lines
2.0 KiB
PHP
68 lines
2.0 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: seekdasky
|
|
* Date: 02/12/15
|
|
* Time: 12:36
|
|
*/
|
|
class PatientRepo
|
|
{
|
|
private $connexion;
|
|
|
|
public function __construct(){
|
|
$this->connexion = StaticRepo::getConnexion();
|
|
}
|
|
|
|
public function getById($id){
|
|
$req = $this->connexion->prepare('SELECT * FROM Patient WHERE Id = :id');
|
|
$req->execute(['id' => $id]);
|
|
return StaticRepo::delNumeric( $req->fetch(), true );
|
|
|
|
}
|
|
|
|
public function add($civilite,$prenom,$nom,$adresse,$ville,$codePostal,$dateNaissance,$lieuNaissance,$numSecu,$medecinTraitant = null){
|
|
|
|
$req = $this->connexion->prepare('INSERT INTO Patient VALUES (:civilite,:nom,:prenom,:adresse,:ville,:codePostal,:dateNaissance,:lieuNaissance,:numSecu,DEFAULT,:medecin)');
|
|
$result = $req->execute(['civilite' => $civilite,
|
|
'nom' => $nom,
|
|
'prenom' => $prenom,
|
|
'adresse' => $adresse,
|
|
'ville' => $ville,
|
|
'codePostal' => $codePostal,
|
|
'dateNaissance' => $dateNaissance,
|
|
'lieuNaissance' => $lieuNaissance,
|
|
'numSecu' => $numSecu,
|
|
'medecin' => $medecinTraitant ]);
|
|
if($result){return ['id' => $this->connexion->lastInsertId()];}
|
|
else{return false;}
|
|
|
|
}
|
|
|
|
public function delete($idPatient){
|
|
|
|
$req = $this->connexion->prepare('DELETE FROM Patient WHERE Id = :id');
|
|
return $req->execute(['id' => $idPatient]);
|
|
|
|
}
|
|
|
|
public function updateMedecinTraitant($idPatient,$idMedecin){
|
|
|
|
$req = $this->connexion->prepare('UPDATE Patient SET MedecinTraitant = :medecin WHERE Id = :id');
|
|
return $req->execute['medecin' => $idMedecin,
|
|
'id' => $idPatient]);
|
|
|
|
}
|
|
|
|
public function search($nom,$prenom){
|
|
|
|
$req = $this->connexion->prepare('SELECT * FROM Patient WHERE Nom LIKE :nom AND Prenom LIKE :prenom');
|
|
$req->execute(['nom' => $nom,
|
|
'prenom' => $prenom]);
|
|
|
|
return StaticRepo::delNumeric($req->fetchAll());
|
|
|
|
}
|
|
|
|
}
|