PatientRepo.php |
-
- 96.43% covered (success)
+
+ 95.65% covered (success)
|
- 96.43% |
- 27 / 28 |
+ 95.65% |
+ 44 / 46 |
-
- 83.33% covered (warning)
+
+ 71.43% covered (warning)
|
- 83.33% |
- 5 / 6 |
+ 71.43% |
+ 5 / 7 |
diff --git a/src/Authentification.php b/managers/Authentification.class.php
similarity index 100%
rename from src/Authentification.php
rename to managers/Authentification.class.php
diff --git a/managers/Medecin.class.php b/managers/Medecin.class.php
new file mode 100644
index 0000000..c0d2285
--- /dev/null
+++ b/managers/Medecin.class.php
@@ -0,0 +1,35 @@
+setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Medecins.php?type=creation");
+ $response->send();
+ }else{
+ $response = new Response(500);
+ $response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Medecins.php?type=error");
+ $response->send();
+ }
+ }
+
+ public function delete($params){
+ if(MedecinRepo::delete($params['id_medecin']) !==FALSE){
+ $response = new Response();
+ $response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Medecins.php?type=supression");
+ $response->send();
+ }else{
+ $response = new Response(500);
+ $response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Medecins.php?type=error");
+ $response->send();
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/managers/Patient.class.php b/managers/Patient.class.php
new file mode 100644
index 0000000..c75dfe5
--- /dev/null
+++ b/managers/Patient.class.php
@@ -0,0 +1,51 @@
+format('Y-m-d'),$params['lieu_naissance'],$params['num_secu'],$params['medecin_traitant']) !==FALSE){
+ $response = new Response();
+ $response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/index.php?type=creation");
+ $response->send();
+ }else{
+ $response = new Response(500);
+ $response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/index.php?type=error");
+ $response->send();
+ }
+ }
+
+ public function update($params){
+ $params['date_naissance'] = DateTime::createFromFormat('d-m-Y', $params['date_naissance']);
+ if(PatientRepo::update($params['id_patient'],$params['civilite'],strtolower($params['prenom']),strtolower($params['nom']),$params['adresse'],$params['adresse2'],$params['ville'],$params['cope_postal'],
+ $params['date_naissance']->format('Y-m-d'),$params['lieu_naissance'],$params['num_secu'],$params['medecin_traitant']) !==FALSE){
+ $response = new Response();
+ $response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/index.php?type=creation");
+ $response->send();
+ }else{
+ $response = new Response(500);
+ $response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/index.php?type=error");
+ $response->send();
+ }
+ }
+
+ public function delete($params){
+ if(PatientRepo::delete($params['id_patient']) !==FALSE){
+ $response = new Response();
+ $response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Patients.php?type=supression");
+ $response->send();
+ }else{
+ $response = new Response(500);
+ $response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Patients.php?type=error");
+ $response->send();
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/managers/RDV.class.php b/managers/RDV.class.php
new file mode 100644
index 0000000..95ec47d
--- /dev/null
+++ b/managers/RDV.class.php
@@ -0,0 +1,49 @@
+format('Y-m-d').' '.$params['heure'].':00',$params['duree'],$params['id_patient'],$params['id_medecin']) !==FALSE){
+ $response = new Response();
+ $response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Consultation.php?type=creation");
+ $response->send();
+ }else{
+ $response = new Response(500);
+ $response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Consultation.php?type=error");
+ $response->send();
+ }
+ }
+
+ public function delete($params){
+ if(RDVRepo::delete($params['id_consultation']) !==FALSE){
+ $response = new Response();
+ $response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Consultation.php?type=supression");
+ $response->send();
+ }else{
+ $response = new Response(500);
+ $response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Consultation.php?type=error");
+ $response->send();
+ }
+ }
+
+ public function update($params){
+ $params['date'] = DateTime::createFromFormat('d-m-Y', $params['date']);
+ if(RDVRepo::updateDateTime($params['id_consultation'],$params['date']->format('Y-m-d').' '.$params['heure'].':00') !==FALSE){
+ $response = new Response();
+ $response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Consultation.php?type=maj");
+ $response->send();
+ }else{
+ $response = new Response(500);
+ $response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Consultation.php?type=error");
+ $response->send();
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/managers/Response.class.php b/managers/Response.class.php
index 7b63073..5e32c40 100644
--- a/managers/Response.class.php
+++ b/managers/Response.class.php
@@ -134,7 +134,7 @@ class Response{
/**
* Envoi les headers de la réponse (status et ceux potentiellement défnini par l'utilisateur)
*/
- public function sendHeader(){
+ private function sendHeader(){
//envoie le status de la requete (petit trick suivant l'architecture de PHP)
if (strpos(PHP_SAPI, 'cgi') === 0) {
header(sprintf('Status: %s', $this->Messages[$this->status]));
diff --git a/managers/config/managers.json b/managers/config/managers.json
index 1784fc1..407b7ab 100755
--- a/managers/config/managers.json
+++ b/managers/config/managers.json
@@ -1,98 +1,33 @@
{
- "Authentification": {
- "login":{"method": "authentification",
- "role": 3,
+ "Patient": {
+ "add":{"method": "add",
+ "role": 0,
"strict": false},
- "logout":{"method": "deconnection",
- "role": 3,
+ "delete":{"method": "delete",
+ "role": 0,
+ "strict": false},
+ "update":{"method": "update",
+ "role": 0,
"strict": false}
},
- "Eleves": {
- "listByGroup": {"method": "getByGroupe",
- "role": 2,
- "strict": false},
- "listAll": {"method": "getAll",
- "role": 2,
- "strict": false},
- "importFromExcel": {"method":"importFromFile",
- "role":1,
- "strict":true
- },
- "changeGroup": {"method":"changeGroup",
- "role":1,
- "strict":true
- },
- "search": {"method":"search",
- "role":2,
- "strict":false
- },
- "listByDiplome": {"method": "getByDiplome",
- "role": 2,
- "strict":false
- },
- "getByCorrecteurAndControle":{"method": "getElevesByControleAndCorrecteur",
- "role":1,
- "strict":false}
- },
- "Notes": {
- "insert": {"method": "insert",
- "role": 1,
- "strict": true},
- "listAllEleve": {"method": "getAllNoteEleve",
- "role": 3,
- "strict" : true},
- "listAllByModuleEleve": {"method": "getAllNoteModuleEleve",
- "role": 3,
- "strict" : true},
- "updateComment": {"method": "updateComment",
- "role": 1,
- "strict" : true},
- "updateNote": {"method": "updateNote",
- "role": 1,
- "strict" : true},
- "exportAll": {"method": "exportAllNotes",
- "role": 2,
- "strict" : false}
- },
-
- "MCC": {
- "importFromExcel": {"method": "importFromFile",
- "role": 1,
- "strict": true
- },
- "getUEByCode": {"method": "getUEByCode",
- "role": 3,
+ "RDV": {
+ "add": {"method": "add",
+ "role": 0,
"strict": false
},
- "getUEByDiplome": {"method": "getUEByDiplome",
- "role": 1,
- "strict": true
- },
- "getModuleByCode": {"method": "getModuleByCode",
- "role": 1,
- "strict": true
- },
- "getControleByCode": {"method": "getControleByCode",
- "role": 1,
- "strict": true
- },
- "getModuleByCodeUE": {"method": "getModuleByCodeUE",
- "role": 1,
- "strict": true
- },
- "getControleByCodeModule": {"method": "getControleByCodeModule",
- "role": 1,
- "strict": true
- }
+ "delete":{"method": "delete",
+ "role": 0,
+ "strict": false},
+ "updateDateTime":{"method": "update",
+ "role": 0,
+ "strict": false}
},
- "Prof":{"getByControle":{"method":"getByControle",
- "role" : 3,
- "strict": false
- },
- "setForCorrecteur":{"method":"setForControle",
- "role":1,
- "strict":true
- }
-
+ "Medecin":{
+ "add":{"method":"add",
+ "role":0,
+ "strict":false},
+ "delete":{"method": "delete",
+ "role": 0,
+ "strict": false}
}
}
diff --git a/src/config/users.json b/managers/config/users.json
similarity index 100%
rename from src/config/users.json
rename to managers/config/users.json
diff --git a/repositories/repos/PatientRepo.php b/repositories/repos/PatientRepo.php
index f68dda6..86e7c88 100755
--- a/repositories/repos/PatientRepo.php
+++ b/repositories/repos/PatientRepo.php
@@ -26,7 +26,7 @@ class PatientRepo
$dateNaissance = strtotime($dateNaissance);
$dateNaissance = Date('o-m-d',$dateNaissance);
- $req = StaticRepo::getConnexion()->prepare('INSERT INTO Patient VALUES (:civilite,:nom,:prenom,:adresse,:adresse2,:ville,:codePostal,:dateNaissance,:lieuNaissance,:numSecu,DEFAULT,:medecin)');
+ $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,
@@ -43,6 +43,29 @@ class PatientRepo
}
+ 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){
$req = StaticRepo::getConnexion()->prepare('DELETE FROM Patient WHERE Patient.Id = :id');
diff --git a/src/Response.php b/src/Response.php
deleted file mode 100755
index 23e3971..0000000
--- a/src/Response.php
+++ /dev/null
@@ -1,202 +0,0 @@
- '100 Continue',
- 101 => '101 Switching Protocols',
- //Successful 2xx
- 200 => '200 OK',
- 201 => '201 Created',
- 202 => '202 Accepted',
- 203 => '203 Non-Authoritative Information',
- 204 => '204 No Content',
- 205 => '205 Reset Content',
- 206 => '206 Partial Content',
- 226 => '226 IM Used',
- //Redirection 3xx
- 300 => '300 Multiple Choices',
- 301 => '301 Moved Permanently',
- 302 => '302 Found',
- 303 => '303 See Other',
- 304 => '304 Not Modified',
- 305 => '305 Use Proxy',
- 306 => '306 (Unused)',
- 307 => '307 Temporary Redirect',
- //Client Error 4xx
- 400 => '400 Bad Request',
- 401 => '401 Unauthorized',
- 402 => '402 Payment Required',
- 403 => '403 Forbidden',
- 404 => '404 Not Found',
- 405 => '405 Method Not Allowed',
- 406 => '406 Not Acceptable',
- 407 => '407 Proxy Authentication Required',
- 408 => '408 Request Timeout',
- 409 => '409 Conflict',
- 410 => '410 Gone',
- 411 => '411 Length Required',
- 412 => '412 Precondition Failed',
- 413 => '413 Request Entity Too Large',
- 414 => '414 Request-URI Too Long',
- 415 => '415 Unsupported Media Type',
- 416 => '416 Requested Range Not Satisfiable',
- 417 => '417 Expectation Failed',
- 418 => '418 I\'m a teapot',
- 422 => '422 Unprocessable Entity',
- 423 => '423 Locked',
- 426 => '426 Upgrade Required',
- 428 => '428 Precondition Required',
- 429 => '429 Too Many Requests',
- 431 => '431 Request Header Fields Too Large',
- //Server Error 5xx
- 500 => '500 Internal Server Error',
- 501 => '501 Not Implemented',
- 502 => '502 Bad Gateway',
- 503 => '503 Service Unavailable',
- 504 => '504 Gateway Timeout',
- 505 => '505 HTTP Version Not Supported',
- 506 => '506 Variant Also Negotiates',
- 510 => '510 Not Extended',
- 511 => '511 Network Authentication Required'
- );
-
- /**
- * Constructeur de la Response
- * @param int $status status HTTP de la réponse (404,200,500, etc)
- * @param bool|false $stream Si la réponse est un stream (avtive/désactive les méthodes send/stream()
- * @param string $type type HTTP des données de retour
- * @param bool|true $clearBuffer si activé, vide le buffer avant chaque envoi de donnée (a pour effet de ne pas afficher les echo/printf)
- */
- public function __construct($status = 200,$stream = false,$type = 'application/json', $clearBuffer = false)
- {
- $this->status = $status;
- array_push($this->headers,['Content-Type',$type]);
-
- $this->config['clearBuffer'] = $clearBuffer;
- $this->config['stream'] = $stream;
- }
-
- /** Ajoute du contenu a la réponse qui sera envoyé (par stream() ou par send() )
- * @param $content contenu a ajouter a la réponse
- */
- public function write($content){
- $this->response .= $content;
- }
-
- /** Envoie une partie de réponse au client (doit être récupéré en ajax, aucun intéret sinon), chaque bloc de donéne envoyé est séparé par
- * un délimiteur ("//Block//" par défaut).ATTENTION: stream() vide la réponse (si on write() puis stream(), la réponse qu'il restera dans l'objet sera vide)
- * @param string $content contenu a envoyer (optionnel car on peut utiliser la méthode write pour le faire)
- * @throws Exception si la réponse n'est pas un stream
- */
- public function stream($content="",$delimiter = "//Block//"){
- //vérification que la réponse est un stream
- if(!$this->config['stream']){
- throw new Exception("Stream d'une réponse synchrone");
- }
- //si les headers ne sont pas encore envoyés, on le fait
- if(!headers_sent()){
- $this->sendHeader();
- }
- //si demandé, on clear le buffer avant d'envoyer
- if($this->config['clearBuffer']){
- ob_end_clean();
- if($GLOBALS['compression']){
- ob_start("ob_gzhandler");
- }else{
- ob_start();
- }
- }
- //on envoi le contenu de response et la variable content
- if($this->response!=""){
- echo $delimiter.$this->response;
- }if($content != ""){
- echo $delimiter.$content;
- }
- ob_flush();flush();
- $this->response = '';
- }
-
- /**
- * Envoi les headers de la réponse (status et ceux potentiellement défnini par l'utilisateur)
- */
- public function sendHeader(){
- //envoie le status de la requete (petit trick suivant l'architecture de PHP)
- if (strpos(PHP_SAPI, 'cgi') === 0) {
- header(sprintf('Status: %s', $this->Messages[$this->status]));
- } else {
- header(sprintf('HTTP/1.1 %s', $this->Messages[$this->status]));
- }
- //les autres headers
- foreach($this->headers as $header){
- header(sprintf('%s: %s',$header[0],$header[1]));
- }
- }
-
- /**
- * Défini un header qui sera envoyé
- * @param $header Nom du header
- * @param $value Valeur du header
- */
- public function setHeader($header,$value){
- array_push($this->headers,[$header,$value]);
- }
-
- /** Envoi la réponse et ferme la communication
- * @throws Exception si la réponse est un stream
- */
- public function send(){
- //vérification que la réponse n'est pas un stream
- if($this->config['stream']){
- throw new Exception("Envoi synchrone d'une réponse stream");
- }
- //si les headers ne sont pas encore envoyés, on le fait
- if(!headers_sent()){
- $this->sendHeader();
- }
- //si demandé, on clear le buffer avant d'envoyer
- if($this->config['clearBuffer']){
- ob_end_clean();
- if($GLOBALS['compression']){
- ob_start("ob_gzhandler");
- }else{
- ob_start();
- }
- }
- //envoi de la réponse
- echo $this->response;
- //fermeture de la communication
- header('Connection: close');
- header('Content-Length: '.ob_get_length());
- ob_end_flush();
- ob_flush();
- flush();
- //permet au reste du script de s'executer même si la réponse a été envoyé et que l'utilisateur interromp le script (changement de page, etc...)
- ignore_user_abort(true);
- }
-
- /**
- * @param int $status status HTTP de la réponse (404,200,500, etc)
- * @param $content
- * @param string $type
- */
- public static function quickResponse($status,$content,$type = 'application/json'){
- $response = new Response($status,false,$type);
- $response->write($content);
- $response->send();
- }
-}
diff --git a/test/PatientRepoTest.php b/test/PatientRepoTest.php
index ca78a82..99b2259 100644
--- a/test/PatientRepoTest.php
+++ b/test/PatientRepoTest.php
@@ -43,4 +43,12 @@ class PatientRepoTest extends PHPUnit_Framework_TestCase
$this->assertEquals(count($this->repo->getAll()),100);
}
+ public function testUpdate(){
+ $id = PatientRepo::add('M','Lucas','Mascaro','3 rue des fleurs qui sentent bon',NULL,'Pimpous-Les-Bains','31524','1996-11-19','Toulouse','123456789876543', 69);
+ $this->assertEquals(0,PatientRepo::update($id,'F','Lucas','Mascaro','3 rue des fleurs qui sentent bon','lol','Pimpous-Les-Bains','31524','1996-11-19','Toulouse','123456789876543', 69));
+ $patient = PatientRepo::getById($id);
+ $this->assertEquals('F',$patient['Civilite']);
+ PatientRepo::delete($id);
+ }
+
}
From 922b046375035ecff9844985d17d87afeeff4726 Mon Sep 17 00:00:00 2001
From: Lucas Mascaro
Date: Thu, 10 Dec 2015 10:56:06 +0100
Subject: [PATCH 2/2] corrections
---
coverage/StaticRepo.php.html | 22 ++---
coverage/dashboard.html | 10 +-
coverage/index.html | 18 ++--
coverage/repos/MedecinRepo.php.html | 136 +++++++++++++++-------------
coverage/repos/PatientRepo.php.html | 2 +-
coverage/repos/RDVRepo.php.html | 2 +-
coverage/repos/StatsRepo.php.html | 2 +-
coverage/repos/dashboard.html | 10 +-
coverage/repos/index.html | 18 ++--
repositories/repos/MedecinRepo.php | 8 ++
repositories/repos/PatientRepo.php | 7 ++
test/RDVRepoTest.php | 4 +-
12 files changed, 130 insertions(+), 109 deletions(-)
diff --git a/coverage/StaticRepo.php.html b/coverage/StaticRepo.php.html
index 9462b25..6552234 100644
--- a/coverage/StaticRepo.php.html
+++ b/coverage/StaticRepo.php.html
@@ -291,24 +291,24 @@
| public static function checkParam($variable, $dbtype){ |
| |
| |
- | if( !is_string($dbtype) ) return false; |
+ | if( !is_string($dbtype) ) return false; |
| |
| |
| |
| |
- | $checker = true; |
- | $matches = []; |
+ | $checker = true; |
+ | $matches = []; |
| |
- | if(preg_match_all('/((?:[a-z][a-z]+))(\\d+)/is',$dbtype,$matches)){ |
+ | if(preg_match_all('/((?:[a-z][a-z]+))(\\d+)/is',$dbtype,$matches)){ |
| $dbtype = $matches[1][0]; |
| isset($matches[2][0])? $len = $matches[2][0] : $len = 8; |
| } |
| |
| switch($dbtype){ |
| |
- | case 'Civilite': |
- | $checker = $checker && is_string($variable) && in_array($variable,['M','F']); |
- | break; |
+ | case 'Civilite': |
+ | $checker = $checker && is_string($variable) && in_array($variable,['M','F']); |
+ | break; |
| |
| |
| case 'String': |
@@ -316,8 +316,8 @@
| break; |
| |
| case 'Integer': |
- | $checker = $checker && is_int($variable) && $variable<pow(2,32); |
- | break; |
+ | $checker = $checker && is_int($variable) && $variable<pow(2,32); |
+ | break; |
| |
| case 'SmallInteger': |
| $checker = $checker && is_int($variable) && $variable<pow(2,16); |
@@ -338,7 +338,7 @@
| |
| |
| |
- | return $checker; |
+ | return $checker; |
| |
| } |
| |
@@ -358,7 +358,7 @@
Dead Code
- Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.0 at Thu Dec 10 9:44:35 UTC 2015.
+ Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.0 at Thu Dec 10 9:54:17 UTC 2015.
diff --git a/coverage/dashboard.html b/coverage/dashboard.html
index 2ee1112..a474818 100644
--- a/coverage/dashboard.html
+++ b/coverage/dashboard.html
@@ -113,9 +113,9 @@
|