From 80b05b86db1ae3111a96f128a5ba6e41bffe8cd1 Mon Sep 17 00:00:00 2001 From: Lucas Mascaro Date: Wed, 9 Dec 2015 13:36:30 +0100 Subject: [PATCH] fin du repo RDV/Stats + tests+generation des RDV --- .gitignore | 1 + Docs/RDVExemple.json | 602 ++++++++++++++++++++++++++++ Docs/generateRDV | 9 + coverage/MedecinRepo.php.html | 67 +++- coverage/PatientRepo.php.html | 129 +++--- coverage/RDVRepo.php.html | 209 +++++----- coverage/StaticRepo.php.html | 397 ++++++++++++++++++ coverage/StatsRepo.php.html | 90 +++-- coverage/dashboard.html | 39 +- coverage/index.html | 154 +++---- coverage/repos/MedecinRepo.php.html | 336 ++++++++++++++++ coverage/repos/PatientRepo.php.html | 353 ++++++++++++++++ coverage/repos/RDVRepo.php.html | 376 +++++++++++++++++ coverage/repos/StatsRepo.php.html | 221 ++++++++++ coverage/repos/dashboard.html | 293 ++++++++++++++ coverage/repos/index.html | 204 ++++++++++ repositories/repos/PatientRepo.php | 4 +- repositories/repos/RDVRepo.php | 34 +- repositories/repos/StatsRepo.php | 37 +- test.php | 10 + test/MedecinRepoTest.php | 4 + test/PatientRepoTest.php | 4 + test/RDVRepoTest.php | 37 +- test/StaticRepoTest.php | 29 ++ test/StatsRepoTest.php | 17 + toBDD.php | 6 + 26 files changed, 3289 insertions(+), 373 deletions(-) create mode 100644 Docs/RDVExemple.json create mode 100644 Docs/generateRDV create mode 100644 coverage/StaticRepo.php.html create mode 100644 coverage/repos/MedecinRepo.php.html create mode 100644 coverage/repos/PatientRepo.php.html create mode 100644 coverage/repos/RDVRepo.php.html create mode 100644 coverage/repos/StatsRepo.php.html create mode 100644 coverage/repos/dashboard.html create mode 100644 coverage/repos/index.html create mode 100644 test.php create mode 100644 test/StaticRepoTest.php create mode 100644 test/StatsRepoTest.php diff --git a/.gitignore b/.gitignore index 83405db..1904248 100755 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +/test.php /.idea /.project /repositories/config.json diff --git a/Docs/RDVExemple.json b/Docs/RDVExemple.json new file mode 100644 index 0000000..a9f083e --- /dev/null +++ b/Docs/RDVExemple.json @@ -0,0 +1,602 @@ +[ + { + "DateRDV": "2015-06-08 11:33:43", + "Duree": 60, + "Patient_Id": 14, + "Medecin_Id": 60 + }, + { + "DateRDV": "2015-04-04 04:22:43", + "Duree": 60, + "Patient_Id": 9, + "Medecin_Id": 15 + }, + { + "DateRDV": "2015-02-08 06:05:29", + "Duree": 60, + "Patient_Id": 63, + "Medecin_Id": 2 + }, + { + "DateRDV": "2015-04-13 08:48:17", + "Duree": 30, + "Patient_Id": 3, + "Medecin_Id": 40 + }, + { + "DateRDV": "2015-10-23 08:01:11", + "Duree": 60, + "Patient_Id": 58, + "Medecin_Id": 74 + }, + { + "DateRDV": "2015-01-02 09:51:57", + "Duree": 30, + "Patient_Id": 33, + "Medecin_Id": 71 + }, + { + "DateRDV": "2015-09-17 11:06:44", + "Duree": 60, + "Patient_Id": 21, + "Medecin_Id": 69 + }, + { + "DateRDV": "2015-07-08 03:55:22", + "Duree": 30, + "Patient_Id": 18, + "Medecin_Id": 41 + }, + { + "DateRDV": "2015-10-18 03:25:50", + "Duree": 60, + "Patient_Id": 23, + "Medecin_Id": 70 + }, + { + "DateRDV": "2015-01-29 09:21:39", + "Duree": 30, + "Patient_Id": 82, + "Medecin_Id": 8 + }, + { + "DateRDV": "2015-08-23 02:57:06", + "Duree": 30, + "Patient_Id": 13, + "Medecin_Id": 25 + }, + { + "DateRDV": "2015-11-30 05:11:44", + "Duree": 60, + "Patient_Id": 20, + "Medecin_Id": 77 + }, + { + "DateRDV": "2015-06-28 09:08:39", + "Duree": 30, + "Patient_Id": 49, + "Medecin_Id": 82 + }, + { + "DateRDV": "2015-06-08 02:00:35", + "Duree": 30, + "Patient_Id": 93, + "Medecin_Id": 13 + }, + { + "DateRDV": "2015-03-01 02:39:30", + "Duree": 60, + "Patient_Id": 28, + "Medecin_Id": 26 + }, + { + "DateRDV": "2015-09-24 01:02:24", + "Duree": 30, + "Patient_Id": 56, + "Medecin_Id": 76 + }, + { + "DateRDV": "2015-09-06 11:13:48", + "Duree": 60, + "Patient_Id": 39, + "Medecin_Id": 97 + }, + { + "DateRDV": "2015-01-15 03:36:46", + "Duree": 30, + "Patient_Id": 46, + "Medecin_Id": 78 + }, + { + "DateRDV": "2015-06-26 09:04:07", + "Duree": 60, + "Patient_Id": 97, + "Medecin_Id": 55 + }, + { + "DateRDV": "2015-07-01 08:27:26", + "Duree": 60, + "Patient_Id": 22, + "Medecin_Id": 50 + }, + { + "DateRDV": "2015-02-08 11:50:46", + "Duree": 30, + "Patient_Id": 18, + "Medecin_Id": 34 + }, + { + "DateRDV": "2015-01-29 03:27:30", + "Duree": 60, + "Patient_Id": 14, + "Medecin_Id": 58 + }, + { + "DateRDV": "2015-03-16 01:57:19", + "Duree": 30, + "Patient_Id": 52, + "Medecin_Id": 4 + }, + { + "DateRDV": "2015-09-21 05:49:59", + "Duree": 30, + "Patient_Id": 11, + "Medecin_Id": 14 + }, + { + "DateRDV": "2015-08-09 03:58:24", + "Duree": 30, + "Patient_Id": 91, + "Medecin_Id": 29 + }, + { + "DateRDV": "2015-02-04 06:35:51", + "Duree": 30, + "Patient_Id": 29, + "Medecin_Id": 62 + }, + { + "DateRDV": "2015-11-04 09:18:35", + "Duree": 30, + "Patient_Id": 99, + "Medecin_Id": 87 + }, + { + "DateRDV": "2015-05-02 04:25:22", + "Duree": 30, + "Patient_Id": 2, + "Medecin_Id": 50 + }, + { + "DateRDV": "2015-11-29 02:33:10", + "Duree": 60, + "Patient_Id": 51, + "Medecin_Id": 89 + }, + { + "DateRDV": "2015-10-15 07:02:24", + "Duree": 60, + "Patient_Id": 10, + "Medecin_Id": 8 + }, + { + "DateRDV": "2015-04-23 08:57:53", + "Duree": 30, + "Patient_Id": 65, + "Medecin_Id": 35 + }, + { + "DateRDV": "2015-02-22 04:17:11", + "Duree": 60, + "Patient_Id": 35, + "Medecin_Id": 82 + }, + { + "DateRDV": "2015-04-04 07:48:57", + "Duree": 30, + "Patient_Id": 76, + "Medecin_Id": 53 + }, + { + "DateRDV": "2015-09-18 07:48:07", + "Duree": 30, + "Patient_Id": 94, + "Medecin_Id": 19 + }, + { + "DateRDV": "2015-02-15 07:25:06", + "Duree": 60, + "Patient_Id": 69, + "Medecin_Id": 44 + }, + { + "DateRDV": "2015-06-08 04:25:39", + "Duree": 60, + "Patient_Id": 15, + "Medecin_Id": 88 + }, + { + "DateRDV": "2015-11-24 01:33:30", + "Duree": 60, + "Patient_Id": 84, + "Medecin_Id": 20 + }, + { + "DateRDV": "2015-07-11 04:17:24", + "Duree": 60, + "Patient_Id": 30, + "Medecin_Id": 78 + }, + { + "DateRDV": "2015-08-12 10:59:53", + "Duree": 30, + "Patient_Id": 61, + "Medecin_Id": 95 + }, + { + "DateRDV": "2015-09-19 05:08:41", + "Duree": 30, + "Patient_Id": 11, + "Medecin_Id": 23 + }, + { + "DateRDV": "2015-09-29 07:56:16", + "Duree": 30, + "Patient_Id": 75, + "Medecin_Id": 86 + }, + { + "DateRDV": "2015-03-22 01:07:22", + "Duree": 30, + "Patient_Id": 83, + "Medecin_Id": 23 + }, + { + "DateRDV": "2015-06-11 06:05:41", + "Duree": 60, + "Patient_Id": 89, + "Medecin_Id": 20 + }, + { + "DateRDV": "2015-03-17 04:28:43", + "Duree": 60, + "Patient_Id": 77, + "Medecin_Id": 88 + }, + { + "DateRDV": "2015-11-27 06:14:03", + "Duree": 60, + "Patient_Id": 27, + "Medecin_Id": 54 + }, + { + "DateRDV": "2015-03-07 09:38:22", + "Duree": 60, + "Patient_Id": 2, + "Medecin_Id": 4 + }, + { + "DateRDV": "2015-02-02 01:45:32", + "Duree": 30, + "Patient_Id": 36, + "Medecin_Id": 60 + }, + { + "DateRDV": "2015-06-18 04:52:09", + "Duree": 60, + "Patient_Id": 69, + "Medecin_Id": 99 + }, + { + "DateRDV": "2015-06-24 11:53:34", + "Duree": 60, + "Patient_Id": 89, + "Medecin_Id": 40 + }, + { + "DateRDV": "2015-10-21 04:19:14", + "Duree": 60, + "Patient_Id": 85, + "Medecin_Id": 76 + }, + { + "DateRDV": "2015-04-14 09:14:08", + "Duree": 30, + "Patient_Id": 73, + "Medecin_Id": 48 + }, + { + "DateRDV": "2015-04-18 09:11:32", + "Duree": 30, + "Patient_Id": 90, + "Medecin_Id": 11 + }, + { + "DateRDV": "2015-08-23 02:03:16", + "Duree": 30, + "Patient_Id": 17, + "Medecin_Id": 57 + }, + { + "DateRDV": "2015-05-03 02:25:11", + "Duree": 30, + "Patient_Id": 21, + "Medecin_Id": 63 + }, + { + "DateRDV": "2015-08-07 09:12:44", + "Duree": 30, + "Patient_Id": 97, + "Medecin_Id": 92 + }, + { + "DateRDV": "2015-05-09 06:18:46", + "Duree": 30, + "Patient_Id": 21, + "Medecin_Id": 32 + }, + { + "DateRDV": "2015-09-10 10:26:08", + "Duree": 30, + "Patient_Id": 9, + "Medecin_Id": 6 + }, + { + "DateRDV": "2015-09-06 11:38:09", + "Duree": 30, + "Patient_Id": 26, + "Medecin_Id": 48 + }, + { + "DateRDV": "2015-07-22 04:18:29", + "Duree": 60, + "Patient_Id": 81, + "Medecin_Id": 90 + }, + { + "DateRDV": "2015-11-29 12:25:38", + "Duree": 60, + "Patient_Id": 91, + "Medecin_Id": 2 + }, + { + "DateRDV": "2015-07-22 05:27:02", + "Duree": 60, + "Patient_Id": 92, + "Medecin_Id": 27 + }, + { + "DateRDV": "2015-02-12 09:02:35", + "Duree": 30, + "Patient_Id": 50, + "Medecin_Id": 35 + }, + { + "DateRDV": "2015-11-07 04:16:19", + "Duree": 60, + "Patient_Id": 98, + "Medecin_Id": 35 + }, + { + "DateRDV": "2015-11-20 09:12:30", + "Duree": 60, + "Patient_Id": 22, + "Medecin_Id": 57 + }, + { + "DateRDV": "2015-11-13 09:09:55", + "Duree": 30, + "Patient_Id": 98, + "Medecin_Id": 69 + }, + { + "DateRDV": "2015-08-04 07:56:59", + "Duree": 30, + "Patient_Id": 88, + "Medecin_Id": 44 + }, + { + "DateRDV": "2015-07-15 07:32:15", + "Duree": 60, + "Patient_Id": 72, + "Medecin_Id": 59 + }, + { + "DateRDV": "2015-05-26 07:16:43", + "Duree": 60, + "Patient_Id": 22, + "Medecin_Id": 57 + }, + { + "DateRDV": "2015-03-08 05:21:56", + "Duree": 60, + "Patient_Id": 95, + "Medecin_Id": 19 + }, + { + "DateRDV": "2015-01-12 02:11:24", + "Duree": 30, + "Patient_Id": 51, + "Medecin_Id": 72 + }, + { + "DateRDV": "2015-11-29 08:22:29", + "Duree": 60, + "Patient_Id": 95, + "Medecin_Id": 56 + }, + { + "DateRDV": "2015-10-09 06:50:11", + "Duree": 60, + "Patient_Id": 53, + "Medecin_Id": 5 + }, + { + "DateRDV": "2015-01-09 04:59:41", + "Duree": 60, + "Patient_Id": 9, + "Medecin_Id": 44 + }, + { + "DateRDV": "2015-03-06 01:45:26", + "Duree": 30, + "Patient_Id": 50, + "Medecin_Id": 90 + }, + { + "DateRDV": "2015-08-20 07:20:01", + "Duree": 30, + "Patient_Id": 70, + "Medecin_Id": 60 + }, + { + "DateRDV": "2015-08-08 03:18:32", + "Duree": 60, + "Patient_Id": 34, + "Medecin_Id": 23 + }, + { + "DateRDV": "2015-07-07 05:49:03", + "Duree": 30, + "Patient_Id": 100, + "Medecin_Id": 97 + }, + { + "DateRDV": "2015-05-14 12:17:01", + "Duree": 60, + "Patient_Id": 37, + "Medecin_Id": 4 + }, + { + "DateRDV": "2015-05-26 02:31:26", + "Duree": 30, + "Patient_Id": 26, + "Medecin_Id": 92 + }, + { + "DateRDV": "2015-07-10 01:06:31", + "Duree": 30, + "Patient_Id": 37, + "Medecin_Id": 19 + }, + { + "DateRDV": "2015-02-12 06:48:08", + "Duree": 60, + "Patient_Id": 26, + "Medecin_Id": 36 + }, + { + "DateRDV": "2015-04-04 09:58:14", + "Duree": 60, + "Patient_Id": 56, + "Medecin_Id": 51 + }, + { + "DateRDV": "2015-09-09 11:00:38", + "Duree": 30, + "Patient_Id": 58, + "Medecin_Id": 60 + }, + { + "DateRDV": "2015-04-07 06:46:08", + "Duree": 60, + "Patient_Id": 6, + "Medecin_Id": 18 + }, + { + "DateRDV": "2015-12-07 04:20:04", + "Duree": 60, + "Patient_Id": 64, + "Medecin_Id": 6 + }, + { + "DateRDV": "2015-09-28 02:43:55", + "Duree": 60, + "Patient_Id": 57, + "Medecin_Id": 66 + }, + { + "DateRDV": "2015-08-26 12:20:03", + "Duree": 60, + "Patient_Id": 27, + "Medecin_Id": 36 + }, + { + "DateRDV": "2015-09-06 08:31:43", + "Duree": 30, + "Patient_Id": 71, + "Medecin_Id": 80 + }, + { + "DateRDV": "2015-04-21 08:18:20", + "Duree": 30, + "Patient_Id": 22, + "Medecin_Id": 30 + }, + { + "DateRDV": "2015-08-13 11:00:42", + "Duree": 30, + "Patient_Id": 10, + "Medecin_Id": 72 + }, + { + "DateRDV": "2015-05-18 01:40:59", + "Duree": 60, + "Patient_Id": 2, + "Medecin_Id": 78 + }, + { + "DateRDV": "2015-11-15 05:32:12", + "Duree": 60, + "Patient_Id": 94, + "Medecin_Id": 77 + }, + { + "DateRDV": "2015-02-27 03:23:52", + "Duree": 60, + "Patient_Id": 2, + "Medecin_Id": 71 + }, + { + "DateRDV": "2015-11-07 04:56:09", + "Duree": 30, + "Patient_Id": 96, + "Medecin_Id": 52 + }, + { + "DateRDV": "2015-07-20 10:32:31", + "Duree": 30, + "Patient_Id": 57, + "Medecin_Id": 38 + }, + { + "DateRDV": "2015-04-09 06:30:20", + "Duree": 30, + "Patient_Id": 91, + "Medecin_Id": 67 + }, + { + "DateRDV": "2015-10-20 04:25:11", + "Duree": 30, + "Patient_Id": 56, + "Medecin_Id": 98 + }, + { + "DateRDV": "2015-11-11 08:29:45", + "Duree": 30, + "Patient_Id": 88, + "Medecin_Id": 39 + }, + { + "DateRDV": "2015-10-21 07:55:43", + "Duree": 30, + "Patient_Id": 97, + "Medecin_Id": 6 + }, + { + "DateRDV": "2015-07-11 11:02:43", + "Duree": 60, + "Patient_Id": 7, + "Medecin_Id": 22 + } +] \ No newline at end of file diff --git a/Docs/generateRDV b/Docs/generateRDV new file mode 100644 index 0000000..ab1fc4b --- /dev/null +++ b/Docs/generateRDV @@ -0,0 +1,9 @@ +[ + '{{repeat(100)}}', + { + DateRDV: '{{date(new Date(2015, 0, 1), new Date(), "YYYY-MM-dd hh:mm:ss")}}', + Duree: '{{random(30,60)}}', + Patient_Id: '{{integer(1,100)}}', + Medecin_Id: '{{integer(1,100)}}' + } +] \ No newline at end of file diff --git a/coverage/MedecinRepo.php.html b/coverage/MedecinRepo.php.html index b484acc..efb0d03 100644 --- a/coverage/MedecinRepo.php.html +++ b/coverage/MedecinRepo.php.html @@ -51,22 +51,22 @@
0.00%
0 / 1
-
- 80.00% covered (warning) +
+ 83.33% covered (warning)
-
80.00%
-
4 / 5
+
83.33%
+
5 / 6
CRAP
-
- 94.74% covered (success) +
+ 95.24% covered (success)
-
94.74%
-
18 / 19
+
95.24%
+
20 / 21
@@ -80,22 +80,22 @@
0.00%
0 / 1
-
- 80.00% covered (warning) +
+ 83.33% covered (warning)
-
80.00%
-
4 / 5
- 6.01 +
83.33%
+
5 / 6
+ 7
-
- 94.74% covered (success) +
+ 95.24% covered (success)
-
94.74%
-
18 / 19
+
95.24%
+
20 / 21
@@ -203,6 +203,27 @@
4 / 4
+ +  getAll +
+
+ 100.00% covered (success) +
+
+ +
100.00%
+
1 / 1
+ 1 +
+
+ 100.00% covered (success) +
+
+ +
100.00%
+
2 / 2
+ + @@ -258,7 +279,15 @@         return StaticRepo::delNumeric($req->fetchAll());     } - } +     public static function getAll(){ + +         $req = StaticRepo::getConnexion()->query('SELECT * FROM Medecin ORDER BY nom, prenom ASC'); + +         return StaticRepo::delNumeric( $req->fetchAll() ); + +     } + + } @@ -271,7 +300,7 @@ Dead Code

- Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0RC7 and PHPUnit 5.1.0 at Tue Dec 8 8:28:46 UTC 2015. + Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.0 at Wed Dec 9 11:50:18 UTC 2015.

diff --git a/coverage/PatientRepo.php.html b/coverage/PatientRepo.php.html index d6cb59d..dce7f11 100644 --- a/coverage/PatientRepo.php.html +++ b/coverage/PatientRepo.php.html @@ -60,13 +60,13 @@
5 / 6
CRAP
-
- 96.67% covered (success) +
+ 96.43% covered (success)
-
96.67%
-
29 / 30
+
96.43%
+
27 / 28
@@ -89,34 +89,13 @@
5 / 6
7
-
- 96.67% covered (success) +
+ 96.43% covered (success)
-
96.67%
-
29 / 30
- - - -  __construct -
-
- 100.00% covered (success) -
-
- -
100.00%
-
1 / 1
- 1 -
-
- 100.00% covered (success) -
-
- -
100.00%
-
2 / 2
+
96.43%
+
27 / 28
@@ -200,11 +179,11 @@
100.00%
-
3 / 3
+
2 / 2
-  search +  search
100.00% covered (success) @@ -221,7 +200,28 @@
100.00%
-
4 / 4
+
3 / 3
+ + + +  getAll +
+
+ 100.00% covered (success) +
+
+ +
100.00%
+
1 / 1
+ 1 +
+
+ 100.00% covered (success) +
+
+ +
100.00%
+
2 / 2
@@ -239,25 +239,25 @@  */ class PatientRepo { -     private $connexion; +     // private $connexion; -     public function __construct(){ -         $this->connexion = StaticRepo::getConnexion(); -     } +     // public function __construct(){ +     //     StaticRepo::getConnexion() = StaticRepo::getConnexion(); +     // } -     public function getById($id){ -         $req = $this->connexion->prepare('SELECT * FROM Patient WHERE Id = :id'); +     public static function getById($id){ +         $req = StaticRepo::getConnexion()->prepare('SELECT * FROM Patient WHERE Id = :id');         $req->execute(['id' => $id]);         return StaticRepo::delNumeric( $req->fetch(), true );     } -     public function add($civilite,$prenom,$nom,$adresse,$adresse2,$ville,$codePostal,$dateNaissance,$lieuNaissance,$numSecu,$medecinTraitant = null){ +     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 = $this->connexion->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 (:civilite,:nom,:prenom,:adresse,:adresse2,:ville,:codePostal,:dateNaissance,:lieuNaissance,:numSecu,DEFAULT,:medecin)');         $result = $req->execute(['civilite' => $civilite,             'nom' => $nom,             'prenom' => $prenom, @@ -269,37 +269,42 @@             'lieuNaissance' => $lieuNaissance,             'numSecu' => $numSecu,             'medecin' => $medecinTraitant ]); -         if($result != false){return $this->connexion->lastInsertId();} +         if($result){return StaticRepo::getConnexion()->lastInsertId();}         else{return false;}     } -     public function delete($idPatient){ +     public static function delete($idPatient){ -         $req = $this->connexion->prepare('DELETE FROM Patient WHERE Id = :id'); +         $req = StaticRepo::getConnexion()->prepare('DELETE FROM Patient WHERE Patient.Id = :id');         return $req->execute(['id' => $idPatient]);     } -     public function updateMedecinTraitant($idPatient,$idMedecin){ +     public static 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()); - -     } - - } +         $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() ); + +     } + + } @@ -312,7 +317,7 @@ Dead Code

- Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0RC7 and PHPUnit 5.1.0 at Tue Dec 8 8:28:46 UTC 2015. + Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.0 at Wed Dec 9 11:50:18 UTC 2015.

diff --git a/coverage/RDVRepo.php.html b/coverage/RDVRepo.php.html index d80914d..af5d142 100644 --- a/coverage/RDVRepo.php.html +++ b/coverage/RDVRepo.php.html @@ -50,23 +50,23 @@
0.00%
0 / 1
-
-
- 33.33% covered (danger) +
+
+ 83.33% covered (warning)
-
33.33%
-
2 / 6
- CRAP -
-
- 46.43% covered (danger) +
83.33%
+
5 / 6
+ CRAP +
+
+ 96.30% covered (success)
-
46.43%
-
13 / 28
+
96.30%
+
26 / 27
@@ -79,23 +79,23 @@
0.00%
0 / 1
-
-
- 33.33% covered (danger) +
+
+ 83.33% covered (warning)
-
33.33%
-
2 / 6
- 14.53 -
-
- 46.43% covered (danger) +
83.33%
+
5 / 6
+ 7 +
+
+ 96.30% covered (success)
-
46.43%
-
13 / 28
+
96.30%
+
26 / 27
@@ -120,28 +120,28 @@ -  getByDate -
-
- 0.00% covered (danger) +  getByDate +
+
+ 100.00% covered (success)
-
0.00%
-
0 / 1
- 2 -
-
- 0.00% covered (danger) +
100.00%
+
1 / 1
+ 1 +
+
+ 100.00% covered (success)
-
0.00%
-
0 / 5
+
100.00%
+
4 / 4
-  delete +  delete
100.00% covered (success) @@ -162,7 +162,7 @@ -  add +  add
0.00% covered (danger) @@ -183,45 +183,45 @@ -  updateDateTime -
-
- 0.00% covered (danger) +  updateDateTime +
+
+ 100.00% covered (success)
-
0.00%
-
0 / 1
- 2 -
-
- 0.00% covered (danger) +
100.00%
+
1 / 1
+ 1 +
+
+ 100.00% covered (success)
-
0.00%
-
0 / 4
+
100.00%
+
4 / 4
-  getByPatientAndDate -
-
- 0.00% covered (danger) +  getByPatientAndDate +
+
+ 100.00% covered (success)
-
0.00%
-
0 / 1
- 2 -
-
- 0.00% covered (danger) +
100.00%
+
1 / 1
+ 1 +
+
+ 100.00% covered (success)
-
0.00%
-
0 / 5
+
100.00%
+
5 / 5
@@ -241,54 +241,53 @@ {         public static function getById($id){ -         $req = StaticRepo::getConnexion()->prepare('SELECT * FROM RDV WHERE Id = :id'); -         $req->execute(['id' => $id]); -         return StaticRepo::delNumeric( $req->fetch(), true ); +         $req = StaticRepo::getConnexion()->prepare('SELECT * FROM RDV WHERE RDV.id = :id'); +         $req->execute(['id' => $id]); +         return StaticRepo::delNumeric( $req->fetch(), true );     }     public static function getByDate($date){ -         $date = strtotime($date); -         $date = date('o-m-d',$date); -         $req = StaticRepo::getConnexion()->prepare('SELECT * FROM RDV WHERE DATE(FROM_UNIXTIME(DateRDV)) = :date'); -         $req->execute(['date' => $date]); -         return StaticRepo::delNumeric($req->fetchAll()); -     } - -     public static function delete($idRDV){ -         $req = StaticRepo::getConnexion()->prepare('DELETE FROM RDV WHERE Id = :id'); -         return $req->execute(['id' => $idRDV]); -     } - -     public static function add($date,$duree,$idPatient,$idMedecin){ -         $date = date('Y-m-d H:i:s',strtotime($date)); -         $duree = date('H:i:s',$duree*60); -         $req = StaticRepo::getConnexion()->prepare('INSERT INTO RDV VALUES (DEFAULT,:date,:duree,:patient,:medecin)'); -         $result = $req->execute(['date' => $date, -             'duree' => $duree, -             'patient' => $idPatient, -             'medecin' => $idMedecin]); - -         if($result != false){return StaticRepo::getConnexion()->lastInsertId();} -         else{return false;} -     } - -     public static function updateDateTime($idRDV,$dateTime){ -         $date = strtotime($dateTime); -         $req = StaticRepo::getConnexion()->prepare('UPDATE RDV SET DateRDV = :date WHERE id = :id'); -         return $req->execute(['date' => $date, -             'id' => $idRDV]); -     } - -     public static function getByPatientAndDate($idPatient,$date){ -         $date = strtotime($date); -         $req = StaticRepo::getConnexion()->prepare('SELECT * FROM RDV WHERE Patient_Id=:patient AND DateRDV=:date'); -         $req->execute(['patient' => $idPatient, -             'date' => $date]); -         return StaticRepo::delNumeric($req->fetchAll()); -     } - - } +         $date = date('Y-m-d',strtotime($date)); +         $req = StaticRepo::getConnexion()->prepare('SELECT * FROM RDV WHERE DATE(DateRDV) = :date ORDER BY DateRDV ASC'); +         $req->execute(['date' => $date]); +         return StaticRepo::delNumeric($req->fetchAll()); +     } + +     public static function delete($idRDV){ +         $req = StaticRepo::getConnexion()->prepare('DELETE FROM RDV WHERE RDV.id = :id'); +         return $req->execute(['id' => $idRDV]); +     } + +     public static function add($date,$duree,$idPatient,$idMedecin){ +         $date = date('Y-m-d H:i:s',strtotime($date)); +         $duree = date('H:i:s',$duree*60); +         $req = StaticRepo::getConnexion()->prepare('INSERT INTO RDV VALUES (DEFAULT,:date,:duree,:patient,:medecin)'); +         $result = $req->execute(['date' => $date, +             'duree' => $duree, +             'patient' => $idPatient, +             'medecin' => $idMedecin]); + +         if($result != false){return StaticRepo::getConnexion()->lastInsertId();} +         else{return false;} +     } + +     public static function updateDateTime($idRDV,$dateTime){ +         $date = date('Y-m-d H:i:s',strtotime($dateTime)); +         $req = StaticRepo::getConnexion()->prepare('UPDATE RDV SET DateRDV = :date WHERE id = :id'); +         return $req->execute(['date' => $date, +             'id' => $idRDV]); +     } + +     public static function getByPatientAndDate($idPatient,$date){ +         $date = date('Y-m-d',strtotime($date)); +         $req = StaticRepo::getConnexion()->prepare('SELECT * FROM RDV WHERE Patient_Id=:patient AND DATE(DateRDV)=:date'); +         $req->execute(['patient' => $idPatient, +             'date' => $date]); +         return StaticRepo::delNumeric($req->fetchAll()); +     } + + } @@ -301,7 +300,7 @@ Dead Code

- Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0RC7 and PHPUnit 5.1.0 at Tue Dec 8 8:28:46 UTC 2015. + Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.0 at Wed Dec 9 11:50:18 UTC 2015.

diff --git a/coverage/StaticRepo.php.html b/coverage/StaticRepo.php.html new file mode 100644 index 0000000..ff505c7 --- /dev/null +++ b/coverage/StaticRepo.php.html @@ -0,0 +1,397 @@ + + + + + Code Coverage for /home/seekdasky/git/projetphp/repositories/StaticRepo.php + + + + + + +
+
+
+
+ +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
+
+ 0.00% covered (danger) +
+
+
0.00%
0 / 1
+
+ 40.00% covered (danger) +
+
+
40.00%
2 / 5
CRAP
+
+ 58.06% covered (warning) +
+
+
58.06%
18 / 31
StaticRepo
+
+ 0.00% covered (danger) +
+
+
0.00%
0 / 1
+
+ 40.00% covered (danger) +
+
+
40.00%
2 / 5
62.01
+
+ 58.06% covered (warning) +
+
+
58.06%
18 / 31
 __construct
+
+ 0.00% covered (danger) +
+
+
0.00%
0 / 1
2
+
+ 0.00% covered (danger) +
+
+
0.00%
0 / 1
 getConnexion
+
+ 100.00% covered (success) +
+
+
100.00%
1 / 1
3
+
+ 100.00% covered (success) +
+
+
100.00%
5 / 5
 testConnexion
+
+ 100.00% covered (success) +
+
+
100.00%
1 / 1
1
+
+ 100.00% covered (success) +
+
+
100.00%
1 / 1
 delNumeric
+
+ 0.00% covered (danger) +
+
+
0.00%
0 / 1
10.29
+
+ 85.71% covered (warning) +
+
+
85.71%
12 / 14
 checkParam
+
+ 0.00% covered (danger) +
+
+
0.00%
0 / 1
72
+
+ 0.00% covered (danger) +
+
+
0.00%
0 / 10
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
<?php
class StaticRepo{
    //contiens l'instance de la Connexion PDO
    private static $connexion;
    //contiens les informations de connexion a la BDD
    private static $config;
    private function __construct(){
    }
    /**
     * @return PDO instance de la connexion a la BDD
     */
    public static function getConnexion(){
        if(static::$config == null){
            static::$config = json_decode(file_get_contents(dirname(__FILE__).DIRECTORY_SEPARATOR.'config.json'),true);
        }
        if(static::$connexion == null){
            static::$connexion = new PDO('mysql:host='.static::$config['host'].';dbname='.static::$config['database'], static::$config['login'], static::$config['password']);
        }
        return static::$connexion;
    }
    /**
     * @return bool test de la Connexion
     */
    public static function testConnexion(){
        return static::getConnexion() instanceof PDO;
    }
    /* SUPPRIME LES VALEURS Ã€ CLÉS NUMÉRIQUES DANS UN FETCH D'UNE TABLE DE LA BDD
    *
    * @fetchData<Array>                 le résultat d'une $requeteSQL->fetchAll() / $requeteSQL->fetch()
    *
    * @return newFetchData<Array>       retourne le tableau donné en paramètre mais sans les valeurs Ã  clés numériques  
    *
    */
    public static function delNumeric($fetchData, $oneDimension=false){
    
    // cas où fetch renvoie FALSE
    if( $fetchData === false ) return false;
        /* [1] 2 dimensions
        ===============================================*/
        if( !$oneDimension ){
        // on supprime les doublons des entrées (indice numérique)
        for( $i = 0 ; $i < count($fetchData) ; $i++ ) // pour tout les utilisateurs
            foreach($fetchData[$i] as $col => $val){  // pour toutes les entrées
                
                if( !mb_detect_encoding($val, 'UTF-8') )
                    $fetchData[$i][$col] = utf8_encode($val);
                
                if( is_int($col) )                    // si l'indice est un entier
                    unset( $fetchData[$i][$col] );    // on le supprime
            }
        /* [2] 1 dimensions
        ===============================================*/
        }else{
            // on supprime les doublons des entrées (indice numérique)
            foreach($fetchData as $i=>$val){  // pour toutes les entrées
                
                if( !mb_detect_encoding($val, 'UTF-8') )
                    $fetchData[$i] = utf8_encode($val);
                if( is_int($i) )                    // si l'indice est un entier
                    unset( $fetchData[$i] );    // on le supprime
            }
        }
        return $fetchData;
    }
//     _      _____ ___ _   _ ___ ____  
//    / \    |  ___|_ _| \ | |_ _|  _ \ 
//   / _ \   | |_   | ||  \| || || |_) |
//  / ___ \  |  _|  | || |\  || ||  _ < 
// /_/   \_\ |_|   |___|_| \_|___|_| \_\
                                     
    /* Vérifie le type d'une variable
    *
    * @variable<mixed>              la variable Ã  vérifier          
    * @dbtype<String>               le type correspondant Ã  la vérification
    *
    *
    * @return correct<Boolean>      TRUE si le type est bon / FALSE si le type ne match pas
    *
    */
    public static function checkParam($variable, $dbtype){
        /* [1] on vérifie que $dbtype est un String
        =============================================================*/
        if( !is_string($dbtype) ) return false;
        /* [2] Vérifications
        =============================================================*/
        $checker = true; // contiendra VRAI si la vérification s'avère correcte
        switch($dbtype){
            // [1] 'M' / 'F' 
            case 'Civilité':
                $checker = $checker && is_string($variable) && in_array(array('M', 'F'), $variable);
                break;
            // [2] Nom de patient 
            case 'Nom':
                $checker = $checker && is_string($variable) && in_array(array('M', 'F'), $variable);
                break;
            // [N] Type inconnu
            default: $checker = false; break;
        }
        /* [3] On retourne le résultat de la vérif
        =============================================================*/
        return $checker;
    }
}
?>
+ +
+ + + + + + diff --git a/coverage/StatsRepo.php.html b/coverage/StatsRepo.php.html index 0946151..1545de1 100644 --- a/coverage/StatsRepo.php.html +++ b/coverage/StatsRepo.php.html @@ -57,7 +57,7 @@
0.00%
-
0 / 2
+
0 / 1
CRAP
@@ -66,7 +66,7 @@
0.00%
-
0 / 3
+
0 / 30
@@ -86,8 +86,8 @@
0.00%
-
0 / 2
- 6 +
0 / 1
+ 72
0.00% covered (danger) @@ -95,11 +95,11 @@
0.00%
-
0 / 3
+
0 / 30
-  __construct +  getStats
0.00% covered (danger) @@ -108,7 +108,7 @@
0.00%
0 / 1
- 2 + 72
0.00% covered (danger) @@ -116,28 +116,7 @@
0.00%
-
0 / 2
- - - -  getStats -
-
- 0.00% covered (danger) -
-
- -
0.00%
-
0 / 1
- 2 -
-
- 0.00% covered (danger) -
-
- -
0.00%
-
0 / 1
+
0 / 30
@@ -155,18 +134,45 @@  */ class StatsRepo { -     private $connexion; - -     public function __construct(){ -         $this->connexion = StaticRepo::getConnexion(); -     } - -     public function getStats(){ - -     } - - - } + +     public static function getStats(){ +         $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]; +     } + + + } @@ -179,7 +185,7 @@ Dead Code

- Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0RC7 and PHPUnit 5.1.0 at Tue Dec 8 8:28:46 UTC 2015. + Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.0 at Wed Dec 9 11:50:18 UTC 2015.

diff --git a/coverage/dashboard.html b/coverage/dashboard.html index 29d38dd..734991a 100644 --- a/coverage/dashboard.html +++ b/coverage/dashboard.html @@ -2,7 +2,7 @@ - Dashboard for /home/seekdasky/git/projetphp/repositories/repos + Dashboard for /home/seekdasky/git/projetphp/repositories @@ -18,7 +18,7 @@
@@ -58,8 +58,7 @@ - StatsRepo0% - RDVRepo46% + StaticRepo58% @@ -76,7 +75,7 @@ - RDVRepo14 + StaticRepo62 @@ -114,13 +113,12 @@ - getByDate0% - updateDateTime0% - getByPatientAndDate0% - __construct0% - getStats0% - add83% - add88% + __construct0% + checkParam0% + add83% + delNumeric85% + getAll85% + add88% @@ -137,8 +135,11 @@ - add2 - add2 + checkParam72 + delNumeric10 + getAll4 + add2 + add2 @@ -148,7 +149,7 @@
@@ -169,7 +170,7 @@ $(document).ready(function() { .yAxis.tickFormat(d3.format('d')); d3.select('#classCoverageDistribution svg') - .datum(getCoverageDistributionData([1,0,0,0,0,1,0,0,0,0,2,0], "Class Coverage")) + .datum(getCoverageDistributionData([0,0,0,0,0,0,1,0,0,0,4,0], "Class Coverage")) .transition().duration(500).call(chart); nv.utils.windowResize(chart.update); @@ -187,7 +188,7 @@ $(document).ready(function() { .yAxis.tickFormat(d3.format('d')); d3.select('#methodCoverageDistribution svg') - .datum(getCoverageDistributionData([5,0,0,0,0,0,0,0,0,2,1,11], "Method Coverage")) + .datum(getCoverageDistributionData([2,0,0,0,0,0,0,0,0,4,2,17], "Method Coverage")) .transition().duration(500).call(chart); nv.utils.windowResize(chart.update); @@ -237,7 +238,7 @@ $(document).ready(function() { chart.yAxis.axisLabel('Cyclomatic Complexity'); d3.select('#classComplexity svg') - .datum(getComplexityData([[94.736842105263,6,"MedecinRepo<\/a>"],[96.666666666667,7,"PatientRepo<\/a>"],[46.428571428571,7,"RDVRepo<\/a>"],[0,2,"StatsRepo<\/a>"]], 'Class Complexity')) + .datum(getComplexityData([[58.064516129032,23,"StaticRepo<\/a>"],[95.238095238095,7,"MedecinRepo<\/a>"],[96.428571428571,7,"PatientRepo<\/a>"],[92.682926829268,11,"RDVRepo<\/a>"],[91.304347826087,8,"StatsRepo<\/a>"]], 'Class Complexity')) .transition() .duration(500) .call(chart); @@ -261,7 +262,7 @@ $(document).ready(function() { chart.yAxis.axisLabel('Method Complexity'); d3.select('#methodComplexity svg') - .datum(getComplexityData([[100,1,"MedecinRepo::getById<\/a>"],[83.333333333333,2,"MedecinRepo::add<\/a>"],[100,1,"MedecinRepo::delete<\/a>"],[100,1,"MedecinRepo::search<\/a>"],[100,1,"MedecinRepo::getPatients<\/a>"],[100,1,"PatientRepo::__construct<\/a>"],[100,1,"PatientRepo::getById<\/a>"],[93.75,2,"PatientRepo::add<\/a>"],[100,1,"PatientRepo::delete<\/a>"],[100,1,"PatientRepo::updateMedecinTraitant<\/a>"],[100,1,"PatientRepo::search<\/a>"],[100,1,"RDVRepo::getById<\/a>"],[0,1,"RDVRepo::getByDate<\/a>"],[100,1,"RDVRepo::delete<\/a>"],[88.888888888889,2,"RDVRepo::add<\/a>"],[0,1,"RDVRepo::updateDateTime<\/a>"],[0,1,"RDVRepo::getByPatientAndDate<\/a>"],[0,1,"StatsRepo::__construct<\/a>"],[0,1,"StatsRepo::getStats<\/a>"]], 'Method Complexity')) + .datum(getComplexityData([[0,1,"StaticRepo::__construct<\/a>"],[100,3,"StaticRepo::getConnexion<\/a>"],[100,1,"StaticRepo::testConnexion<\/a>"],[85.714285714286,10,"StaticRepo::delNumeric<\/a>"],[0,8,"StaticRepo::checkParam<\/a>"],[100,1,"MedecinRepo::getById<\/a>"],[83.333333333333,2,"MedecinRepo::add<\/a>"],[100,1,"MedecinRepo::delete<\/a>"],[100,1,"MedecinRepo::search<\/a>"],[100,1,"MedecinRepo::getPatients<\/a>"],[100,1,"MedecinRepo::getAll<\/a>"],[100,1,"PatientRepo::getById<\/a>"],[93.75,2,"PatientRepo::add<\/a>"],[100,1,"PatientRepo::delete<\/a>"],[100,1,"PatientRepo::updateMedecinTraitant<\/a>"],[100,1,"PatientRepo::search<\/a>"],[100,1,"PatientRepo::getAll<\/a>"],[100,1,"RDVRepo::getById<\/a>"],[100,1,"RDVRepo::getByDate<\/a>"],[100,1,"RDVRepo::delete<\/a>"],[88.888888888889,2,"RDVRepo::add<\/a>"],[100,1,"RDVRepo::updateDateTime<\/a>"],[100,1,"RDVRepo::getByPatientAndDate<\/a>"],[85.714285714286,4,"RDVRepo::getAll<\/a>"],[91.304347826087,8,"StatsRepo::getAgePatient<\/a>"]], 'Method Complexity')) .transition() .duration(500) .call(chart); diff --git a/coverage/index.html b/coverage/index.html index 5521669..09a644a 100644 --- a/coverage/index.html +++ b/coverage/index.html @@ -2,7 +2,7 @@ - Code Coverage for /home/seekdasky/git/projetphp/repositories/repos + Code Coverage for /home/seekdasky/git/projetphp/repositories @@ -17,7 +17,7 @@
@@ -42,6 +42,42 @@ Total +
+
+ 86.11% covered (warning) +
+
+ +
86.11%
+
124 / 144
+
+
+ 68.00% covered (warning) +
+
+ +
68.00%
+
17 / 25
+
+
+ 0.00% covered (danger) +
+
+ +
0.00%
+
0 / 5
+ + + + repos +
+
+ 93.81% covered (success) +
+
+ +
93.81%
+
106 / 113
75.00% covered (warning) @@ -49,15 +85,7 @@
75.00%
-
60 / 80
-
-
- 57.89% covered (warning) -
-
- -
57.89%
-
11 / 19
+
15 / 20
0.00% covered (danger) @@ -69,107 +97,23 @@ - MedecinRepo.php -
-
- 94.74% covered (success) -
-
- -
94.74%
-
18 / 19
+ StaticRepo.php
-
- 80.00% covered (warning) +
+ 58.06% covered (warning)
-
80.00%
-
4 / 5
+
58.06%
+
18 / 31
-
- 0.00% covered (danger) +
+ 40.00% covered (danger)
-
0.00%
-
0 / 1
- - - - PatientRepo.php -
-
- 96.67% covered (success) -
-
- -
96.67%
-
29 / 30
-
-
- 83.33% covered (warning) -
-
- -
83.33%
-
5 / 6
-
-
- 0.00% covered (danger) -
-
- -
0.00%
-
0 / 1
- - - - RDVRepo.php -
-
- 46.43% covered (danger) -
-
- -
46.43%
-
13 / 28
-
-
- 33.33% covered (danger) -
-
- -
33.33%
-
2 / 6
-
-
- 0.00% covered (danger) -
-
- -
0.00%
-
0 / 1
- - - - StatsRepo.php -
-
- 0.00% covered (danger) -
-
- -
0.00%
-
0 / 3
-
-
- 0.00% covered (danger) -
-
- -
0.00%
-
0 / 2
+
40.00%
+
2 / 5
0.00% covered (danger) @@ -192,7 +136,7 @@ High: 90% to 100%

- Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0RC7 and PHPUnit 5.1.0 at Tue Dec 8 8:28:46 UTC 2015. + Generated by PHP_CodeCoverage 3.0.2 using PHP 7.0.0 and PHPUnit 5.1.0 at Wed Dec 9 12:35:41 UTC 2015.

diff --git a/coverage/repos/MedecinRepo.php.html b/coverage/repos/MedecinRepo.php.html new file mode 100644 index 0000000..292e2ec --- /dev/null +++ b/coverage/repos/MedecinRepo.php.html @@ -0,0 +1,336 @@ + + + + + Code Coverage for /home/seekdasky/git/projetphp/repositories/repos/MedecinRepo.php + + + + + + +
+
+
+
+ +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
+
+ 0.00% covered (danger) +
+
+
0.00%
0 / 1
+
+ 83.33% covered (warning) +
+
+
83.33%
5 / 6
CRAP
+
+ 95.24% covered (success) +
+
+
95.24%
20 / 21
MedecinRepo
+
+ 0.00% covered (danger) +
+
+
0.00%
0 / 1
+
+ 83.33% covered (warning) +
+
+
83.33%
5 / 6
7
+
+ 95.24% covered (success) +
+
+
95.24%
20 / 21
 getById
+
+ 100.00% covered (success) +
+
+
100.00%
1 / 1
1
+
+ 100.00% covered (success) +
+
+
100.00%
3 / 3
 add
+
+ 0.00% covered (danger) +
+
+
0.00%
0 / 1
2.02
+
+ 83.33% covered (warning) +
+
+
83.33%
5 / 6
 delete
+
+ 100.00% covered (success) +
+
+
100.00%
1 / 1
1
+
+ 100.00% covered (success) +
+
+
100.00%
2 / 2
 search
+
+ 100.00% covered (success) +
+
+
100.00%
1 / 1
1
+
+ 100.00% covered (success) +
+
+
100.00%
4 / 4
 getPatients
+
+ 100.00% covered (success) +
+
+
100.00%
1 / 1
1
+
+ 100.00% covered (success) +
+
+
100.00%
4 / 4
 getAll
+
+ 100.00% covered (success) +
+
+
100.00%
1 / 1
1
+
+ 100.00% covered (success) +
+
+
100.00%
2 / 2
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
<?php
/**
 * Created by PhpStorm.
 * User: seekdasky
 * Date: 02/12/15
 * Time: 12:36
 */
class MedecinRepo
{
    public static function getById($id){
        $req = StaticRepo::getConnexion()->prepare('SELECT * FROM Medecin WHERE Id = :id');
        $req->execute(['id' => $id]);
        return StaticRepo::delNumeric( $req->fetch(), true );
    }
    public static function add($civilite,$prenom,$nom){
        $req = StaticRepo::getConnexion()->prepare('INSERT INTO Medecin VALUES (DEFAULT,:civilite,:prenom,:nom)');
        $result = $req->execute(['civilite' => $civilite,
            'nom' => $nom,
            'prenom' => $prenom]);
        if($result != false){return StaticRepo::getConnexion()->lastInsertId();}
        else{return false;}
    }
    public static function delete($idMedecin){
        $req = StaticRepo::getConnexion()->prepare('DELETE FROM Medecin WHERE Id = :id');
        return $req->execute(['id' => $idMedecin]);
    }
    public static function search($nom,$prenom){
        $req = StaticRepo::getConnexion()->prepare('SELECT * FROM Medecin WHERE Nom LIKE :nom AND Prenom LIKE :prenom');
        $req->execute(['nom' => $nom,
            'prenom' => $prenom]);
        return StaticRepo::delNumeric($req->fetchAll());
    }
    public static function getPatients($idMedecin){
        $req = StaticRepo::getConnexion()->prepare('SELECT Patient.* FROM Patient,Medecin
                    WHERE Medecin.Id = :id
                    AND Medecin.Id = Patient.MedecinTraitant');
        $req->execute(['id' => $idMedecin]);
        return StaticRepo::delNumeric($req->fetchAll());
    }
    public static function getAll(){
        $req = StaticRepo::getConnexion()->query('SELECT * FROM Medecin ORDER BY nom, prenom ASC');
        return StaticRepo::delNumeric( $req->fetchAll() );
    }
}
+ +
+ + + + + + diff --git a/coverage/repos/PatientRepo.php.html b/coverage/repos/PatientRepo.php.html new file mode 100644 index 0000000..b0e437c --- /dev/null +++ b/coverage/repos/PatientRepo.php.html @@ -0,0 +1,353 @@ + + + + + Code Coverage for /home/seekdasky/git/projetphp/repositories/repos/PatientRepo.php + + + + + + +
+
+
+
+ +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
+
+ 0.00% covered (danger) +
+
+
0.00%
0 / 1
+
+ 83.33% covered (warning) +
+
+
83.33%
5 / 6
CRAP
+
+ 96.43% covered (success) +
+
+
96.43%
27 / 28
PatientRepo
+
+ 0.00% covered (danger) +
+
+
0.00%
0 / 1
+
+ 83.33% covered (warning) +
+
+
83.33%
5 / 6
7
+
+ 96.43% covered (success) +
+
+
96.43%
27 / 28
 getById
+
+ 100.00% covered (success) +
+
+
100.00%
1 / 1
1
+
+ 100.00% covered (success) +
+
+
100.00%
3 / 3
 add
+
+ 0.00% covered (danger) +
+
+
0.00%
0 / 1
2.00
+
+ 93.75% covered (success) +
+
+
93.75%
15 / 16
 delete
+
+ 100.00% covered (success) +
+
+
100.00%
1 / 1
1
+
+ 100.00% covered (success) +
+
+
100.00%
2 / 2
 updateMedecinTraitant
+
+ 100.00% covered (success) +
+
+
100.00%
1 / 1
1
+
+ 100.00% covered (success) +
+
+
100.00%
2 / 2
 search
+
+ 100.00% covered (success) +
+
+
100.00%
1 / 1
1
+
+ 100.00% covered (success) +
+
+
100.00%
3 / 3
 getAll
+
+ 100.00% covered (success) +
+
+
100.00%
1 / 1
1
+
+ 100.00% covered (success) +
+
+
100.00%
2 / 2
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
<?php
/**
 * Created by PhpStorm.
 * User: seekdasky
 * Date: 02/12/15
 * Time: 12:36
 */
class PatientRepo
{
    // private $connexion;
    // public function __construct(){
    //     StaticRepo::getConnexion() = StaticRepo::getConnexion();
    // }
    public static function getById($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 (:civilite,:nom,:prenom,:adresse,:adresse2,:ville,:codePostal,:dateNaissance,:lieuNaissance,:numSecu,DEFAULT,: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 delete($idPatient){
        $req = StaticRepo::getConnexion()->prepare('DELETE FROM Patient WHERE Patient.Id = :id');
        return $req->execute(['id' => $idPatient]);
    }
    public static function updateMedecinTraitant($idPatient,$idMedecin){
        $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() );
    }
}
+ +
+ + + + + + diff --git a/coverage/repos/RDVRepo.php.html b/coverage/repos/RDVRepo.php.html new file mode 100644 index 0000000..18797f6 --- /dev/null +++ b/coverage/repos/RDVRepo.php.html @@ -0,0 +1,376 @@ + + + + + Code Coverage for /home/seekdasky/git/projetphp/repositories/repos/RDVRepo.php + + + + + + +
+
+
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
+
+ 0.00% covered (danger) +
+
+
0.00%
0 / 1
+
+ 71.43% covered (warning) +
+
+
71.43%
5 / 7
CRAP
+
+ 92.68% covered (success) +
+
+
92.68%
38 / 41
RDVRepo
+
+ 0.00% covered (danger) +
+
+
0.00%
0 / 1
+
+ 71.43% covered (warning) +
+
+
71.43%
5 / 7
11.05
+
+ 92.68% covered (success) +
+
+
92.68%
38 / 41
 getById
+
+ 100.00% covered (success) +
+
+
100.00%
1 / 1
1
+
+ 100.00% covered (success) +
+
+
100.00%
3 / 3
 getByDate
+
+ 100.00% covered (success) +
+
+
100.00%
1 / 1
1
+
+ 100.00% covered (success) +
+
+
100.00%
4 / 4
 delete
+
+ 100.00% covered (success) +
+
+
100.00%
1 / 1
1
+
+ 100.00% covered (success) +
+
+
100.00%
2 / 2
 add
+
+ 0.00% covered (danger) +
+
+
0.00%
0 / 1
2.01
+
+ 88.89% covered (warning) +
+
+
88.89%
8 / 9
 updateDateTime
+
+ 100.00% covered (success) +
+
+
100.00%
1 / 1
1
+
+ 100.00% covered (success) +
+
+
100.00%
4 / 4
 getByPatientAndDate
+
+ 100.00% covered (success) +
+
+
100.00%
1 / 1
1
+
+ 100.00% covered (success) +
+
+
100.00%
5 / 5
 getAll
+
+ 0.00% covered (danger) +
+
+
0.00%
0 / 1
4.05
+
+ 85.71% covered (warning) +
+
+
85.71%
12 / 14
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
<?php
/**
 * Created by PhpStorm.
 * User: seekdasky
 * Date: 02/12/15
 * Time: 12:36
 */
class RDVRepo
{
   
    public static function getById($id){
        $req = StaticRepo::getConnexion()->prepare('SELECT * FROM RDV WHERE RDV.id = :id');
        $req->execute(['id' => $id]);
        return StaticRepo::delNumeric( $req->fetch(), true );
    }
    public static function getByDate($date){
        $date = date('Y-m-d',strtotime($date));
        $req = StaticRepo::getConnexion()->prepare('SELECT * FROM RDV WHERE DATE(DateRDV) = :date ORDER BY DateRDV ASC');
        $req->execute(['date' => $date]);
        return StaticRepo::delNumeric($req->fetchAll());
    }
    public static function delete($idRDV){
        $req = StaticRepo::getConnexion()->prepare('DELETE FROM RDV WHERE RDV.id = :id');
        return $req->execute(['id' => $idRDV]);
    }
    public static function add($date,$duree,$idPatient,$idMedecin){
        $date = date('Y-m-d H:i:s',strtotime($date));
        $duree = date('H:i:s',$duree*60);
        $req = StaticRepo::getConnexion()->prepare('INSERT INTO RDV VALUES (DEFAULT,:date,:duree,:patient,:medecin)');
        $result = $req->execute(['date' => $date,
            'duree' => $duree,
            'patient' => $idPatient,
            'medecin' => $idMedecin]);
        if($result != false){return StaticRepo::getConnexion()->lastInsertId();}
        else{return false;}
    }
    public static function updateDateTime($idRDV,$dateTime){
        $date = date('Y-m-d H:i:s',strtotime($dateTime));
        $req = StaticRepo::getConnexion()->prepare('UPDATE RDV SET DateRDV = :date WHERE id = :id');
        return $req->execute(['date' => $date,
            'id' => $idRDV]);
    }
    public static function getByPatientAndDate($idPatient,$date){
        $date = date('Y-m-d',strtotime($date));
        $req = StaticRepo::getConnexion()->prepare('SELECT * FROM RDV WHERE Patient_Id=:patient AND DATE(DateRDV)=:date');
        $req->execute(['patient' => $idPatient,
            'date' => $date]);
        return StaticRepo::delNumeric($req->fetchAll());
    }
    public static function getAll($date = 0){
        $dateTime = date('Y-m-d',time());
        switch($date){
            case -1:
                $req = StaticRepo::getConnexion()->prepare('SELECT * FROM RDV WHERE DATE(DateRDV) <= :date ORDER BY DateRDV ASC');
                $req->execute(['date' => $dateTime]);
                break;
            case 0:
                $req = StaticRepo::getConnexion()->prepare('SELECT * FROM RDV ORDER BY DateRDV ASC');
                $req->execute();
                break;
            case 1:
                $req = StaticRepo::getConnexion()->prepare('SELECT * FROM RDV WHERE DATE(DateRDV) >= :date ORDER BY DateRDV ASC');
                $req->execute(['date' => $dateTime]);
                break;
        }
        return StaticRepo::delNumeric($req->fetchAll());
    }
}
+ +
+ + + + + + diff --git a/coverage/repos/StatsRepo.php.html b/coverage/repos/StatsRepo.php.html new file mode 100644 index 0000000..348fd47 --- /dev/null +++ b/coverage/repos/StatsRepo.php.html @@ -0,0 +1,221 @@ + + + + + Code Coverage for /home/seekdasky/git/projetphp/repositories/repos/StatsRepo.php + + + + + + +
+
+
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
+
+ 0.00% covered (danger) +
+
+
0.00%
0 / 1
+
+ 0.00% covered (danger) +
+
+
0.00%
0 / 1
CRAP
+
+ 91.30% covered (success) +
+
+
91.30%
21 / 23
StatsRepo
+
+ 0.00% covered (danger) +
+
+
0.00%
0 / 1
+
+ 0.00% covered (danger) +
+
+
0.00%
0 / 1
8.04
+
+ 91.30% covered (success) +
+
+
91.30%
21 / 23
 getAgePatient
+
+ 0.00% covered (danger) +
+
+
0.00%
0 / 1
8.04
+
+ 91.30% covered (success) +
+
+
91.30%
21 / 23
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
<?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];
    }
}
+ +
+ + + + + + diff --git a/coverage/repos/dashboard.html b/coverage/repos/dashboard.html new file mode 100644 index 0000000..f918d13 --- /dev/null +++ b/coverage/repos/dashboard.html @@ -0,0 +1,293 @@ + + + + + Dashboard for /home/seekdasky/git/projetphp/repositories/repos + + + + + + + +
+
+
+ +
+
+
+
+
+
+

Classes

+
+
+
+
+

Coverage Distribution

+
+ +
+
+
+

Complexity

+
+ +
+
+
+
+
+

Insufficient Coverage

+
+ + + + + + + + + + +
ClassCoverage
+
+
+
+

Project Risks

+
+ + + + + + + + + + +
ClassCRAP
+
+
+
+
+
+

Methods

+
+
+
+
+

Coverage Distribution

+
+ +
+
+
+

Complexity

+
+ +
+
+
+
+
+

Insufficient Coverage

+
+ + + + + + + + + + + + + +
MethodCoverage
add83%
getAll85%
add88%
+
+
+
+

Project Risks

+
+ + + + + + + + + + + + + +
MethodCRAP
getAll4
add2
add2
+
+
+
+ +
+ + + + + + + + diff --git a/coverage/repos/index.html b/coverage/repos/index.html new file mode 100644 index 0000000..8306ad9 --- /dev/null +++ b/coverage/repos/index.html @@ -0,0 +1,204 @@ + + + + + Code Coverage for /home/seekdasky/git/projetphp/repositories/repos + + + + + + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 
Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
+
+ 93.81% covered (success) +
+
+
93.81%
106 / 113
+
+ 75.00% covered (warning) +
+
+
75.00%
15 / 20
+
+ 0.00% covered (danger) +
+
+
0.00%
0 / 4
MedecinRepo.php
+
+ 95.24% covered (success) +
+
+
95.24%
20 / 21
+
+ 83.33% covered (warning) +
+
+
83.33%
5 / 6
+
+ 0.00% covered (danger) +
+
+
0.00%
0 / 1
PatientRepo.php
+
+ 96.43% covered (success) +
+
+
96.43%
27 / 28
+
+ 83.33% covered (warning) +
+
+
83.33%
5 / 6
+
+ 0.00% covered (danger) +
+
+
0.00%
0 / 1
RDVRepo.php
+
+ 92.68% covered (success) +
+
+
92.68%
38 / 41
+
+ 71.43% covered (warning) +
+
+
71.43%
5 / 7
+
+ 0.00% covered (danger) +
+
+
0.00%
0 / 1
StatsRepo.php
+
+ 91.30% covered (success) +
+
+
91.30%
21 / 23
+
+ 0.00% covered (danger) +
+
+
0.00%
0 / 1
+
+ 0.00% covered (danger) +
+
+
0.00%
0 / 1
+ +
+ + + + + diff --git a/repositories/repos/PatientRepo.php b/repositories/repos/PatientRepo.php index f947092..f68dda6 100755 --- a/repositories/repos/PatientRepo.php +++ b/repositories/repos/PatientRepo.php @@ -38,14 +38,14 @@ class PatientRepo 'lieuNaissance' => $lieuNaissance, 'numSecu' => $numSecu, 'medecin' => $medecinTraitant ]); - if($result){return ['id' => StaticRepo::getConnexion()->lastInsertId()];} + if($result){return StaticRepo::getConnexion()->lastInsertId();} else{return false;} } public static function delete($idPatient){ - $req = StaticRepo::getConnexion()->prepare('DELETE FROM Patient WHERE Id = :id'); + $req = StaticRepo::getConnexion()->prepare('DELETE FROM Patient WHERE Patient.Id = :id'); return $req->execute(['id' => $idPatient]); } diff --git a/repositories/repos/RDVRepo.php b/repositories/repos/RDVRepo.php index 64d0d0e..3174f4b 100755 --- a/repositories/repos/RDVRepo.php +++ b/repositories/repos/RDVRepo.php @@ -10,22 +10,21 @@ class RDVRepo { public static function getById($id){ - $req = StaticRepo::getConnexion()->prepare('SELECT * FROM RDV WHERE Id = :id'); + $req = StaticRepo::getConnexion()->prepare('SELECT * FROM RDV WHERE RDV.id = :id'); $req->execute(['id' => $id]); return StaticRepo::delNumeric( $req->fetch(), true ); } public static function getByDate($date){ - $date = strtotime($date); - $date = date('o-m-d',$date); - $req = StaticRepo::getConnexion()->prepare('SELECT * FROM RDV WHERE DATE(FROM_UNIXTIME(DateRDV)) = :date'); + $date = date('Y-m-d',strtotime($date)); + $req = StaticRepo::getConnexion()->prepare('SELECT * FROM RDV WHERE DATE(DateRDV) = :date ORDER BY DateRDV ASC'); $req->execute(['date' => $date]); return StaticRepo::delNumeric($req->fetchAll()); } public static function delete($idRDV){ - $req = StaticRepo::getConnexion()->prepare('DELETE FROM RDV WHERE Id = :id'); + $req = StaticRepo::getConnexion()->prepare('DELETE FROM RDV WHERE RDV.id = :id'); return $req->execute(['id' => $idRDV]); } @@ -43,18 +42,37 @@ class RDVRepo } public static function updateDateTime($idRDV,$dateTime){ - $date = strtotime($dateTime); + $date = date('Y-m-d H:i:s',strtotime($dateTime)); $req = StaticRepo::getConnexion()->prepare('UPDATE RDV SET DateRDV = :date WHERE id = :id'); return $req->execute(['date' => $date, 'id' => $idRDV]); } public static function getByPatientAndDate($idPatient,$date){ - $date = strtotime($date); - $req = StaticRepo::getConnexion()->prepare('SELECT * FROM RDV WHERE Patient_Id=:patient AND DateRDV=:date'); + $date = date('Y-m-d',strtotime($date)); + $req = StaticRepo::getConnexion()->prepare('SELECT * FROM RDV WHERE Patient_Id=:patient AND DATE(DateRDV)=:date'); $req->execute(['patient' => $idPatient, 'date' => $date]); return StaticRepo::delNumeric($req->fetchAll()); } + public static function getAll($date = 0){ + $dateTime = date('Y-m-d',time()); + switch($date){ + case -1: + $req = StaticRepo::getConnexion()->prepare('SELECT * FROM RDV WHERE DATE(DateRDV) <= :date ORDER BY DateRDV ASC'); + $req->execute(['date' => $dateTime]); + break; + case 0: + $req = StaticRepo::getConnexion()->prepare('SELECT * FROM RDV ORDER BY DateRDV ASC'); + $req->execute(); + break; + case 1: + $req = StaticRepo::getConnexion()->prepare('SELECT * FROM RDV WHERE DATE(DateRDV) >= :date ORDER BY DateRDV ASC'); + $req->execute(['date' => $dateTime]); + break; + } + return StaticRepo::delNumeric($req->fetchAll()); + } + } diff --git a/repositories/repos/StatsRepo.php b/repositories/repos/StatsRepo.php index f7072dc..395952c 100755 --- a/repositories/repos/StatsRepo.php +++ b/repositories/repos/StatsRepo.php @@ -8,14 +8,41 @@ */ class StatsRepo { - private $connexion; - public function __construct(){ - $this->connexion = StaticRepo::getConnexion(); - } + public static function getAgePatient(){ + $patients = PatientRepo::getAll(); - public function getStats(){ + $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]; } diff --git a/test.php b/test.php new file mode 100644 index 0000000..30c4dd3 --- /dev/null +++ b/test.php @@ -0,0 +1,10 @@ +assertEquals($this->repo->getById(1)['Nom'],'HUFF'); } + public function testGetAll(){ + $this->assertEquals(count($this->repo->getAll()),100); + } + } diff --git a/test/PatientRepoTest.php b/test/PatientRepoTest.php index 3b13520..ca78a82 100644 --- a/test/PatientRepoTest.php +++ b/test/PatientRepoTest.php @@ -39,4 +39,8 @@ class PatientRepoTest extends PHPUnit_Framework_TestCase $this->assertEquals($this->repo->getById(2)['MedecinTraitant'],$id); } + public function testGetAll(){ + $this->assertEquals(count($this->repo->getAll()),100); + } + } diff --git a/test/RDVRepoTest.php b/test/RDVRepoTest.php index f831d30..a4e5d03 100644 --- a/test/RDVRepoTest.php +++ b/test/RDVRepoTest.php @@ -9,7 +9,6 @@ class RDVRepoTest extends PHPUnit_Framework_TestCase { private $repo; - private $id; public function __construct() { @@ -24,15 +23,41 @@ class RDVRepoTest extends PHPUnit_Framework_TestCase $id = $this->repo->add(date('Y-m-d H:i:s',time()),30,2,1); $this->assertNotNull($id); $this->assertNotFalse($id); - $this->id = $id; + $this->assertTrue($this->repo->delete($id)); } public function testGetById(){ - $result = $this->repo->getById($this->id); - $this->assertEquals($this->id,$result['id']); + $result = $this->repo->getById(1); + $this->assertEquals(1,$result['Id']); } - public function testDelete(){ - $this->assertTrue($this->repo->delete($this->id)); + public function testUpdateTime(){ + $date = date('Y-m-d H:i:s',time()); + $this->assertTrue($this->repo->updateDateTime(1,$date)); + $result = $this->repo->getById(1); + $this->assertEquals($date,$result['DateRDV']); } + + public function testGetByDate(){ + $date = date('Y-m-d H:i:s',time()); + $this->assertTrue($this->repo->updateDateTime(1,$date)); + $result = $this->repo->getByDate($date = date('Y-m-d',strtotime($date))); + $this->assertTrue(isset($result[0])); + $this->assertEquals($result[0]['Id'],1); + } + + public function testGetByPAtientAndDate(){ + $date = '2015-12-20 13:33:00'; + $this->assertTrue($this->repo->updateDateTime(85,$date)); + $result = $this->repo->getByPatientAndDate(14,date('Y-m-d',strtotime($date))); + $this->assertTrue(isset($result[0])); + $this->assertEquals($result[0]['Id'],85); + } + + public function testGetAll(){ + $this->assertEquals(count($this->repo->getAll(-1)),99); + $this->assertEquals(count($this->repo->getAll(0)),100); + $this->assertEquals(count($this->repo->getAll(1)),2); + } + } diff --git a/test/StaticRepoTest.php b/test/StaticRepoTest.php new file mode 100644 index 0000000..0827875 --- /dev/null +++ b/test/StaticRepoTest.php @@ -0,0 +1,29 @@ +assertTrue(StaticRepo::getConnexion() instanceof PDO); + } + + public function testTestConnexion(){ + $this->assertTrue(StaticRepo::testConnexion()); + } + + public function testDelNumericOneDimension(){ + $array = [0=>'kjbk','kughk'=>'kjbk',1=>'aze','azert'=>'aza']; + $this->assertEquals(StaticRepo::delNumeric($array,true),['kughk'=>'kjbk','azert'=>'aza']); + } + + public function testDelNumericTwoDimension(){ + $array = [0=>[0=>'kjbk','kughk'=>'kjbk',1=>'aze','azert'=>'aze'],1=>[0=>'kjbk','kughk'=>'kjbk',1=>'aze','azert'=>'aza']]; + $this->assertEquals(StaticRepo::delNumeric($array),[0=>['kughk'=>'kjbk','azert'=>'aze'],1=>['kughk'=>'kjbk','azert'=>'aza']]); + } + +} diff --git a/test/StatsRepoTest.php b/test/StatsRepoTest.php new file mode 100644 index 0000000..a747f76 --- /dev/null +++ b/test/StatsRepoTest.php @@ -0,0 +1,17 @@ +['25-'=>31,'25-50'=>2,'50+'=>16],'F'=>['25-'=>36,'25-50'=>6,'50+'=>9]]; + + $this->assertEquals(StatsRepo::getAgePatient(),$array); + } + +} diff --git a/toBDD.php b/toBDD.php index bd225aa..3b3cc6d 100644 --- a/toBDD.php +++ b/toBDD.php @@ -10,15 +10,21 @@ require_once('autoloader.php'); $jsonP = json_decode(file_get_contents('Docs/PatientExemple.json'),true); $jsonM = json_decode(file_get_contents('Docs/MedecinExemple.json'),true); +$jsonR = json_decode(file_get_contents('Docs/RDVExemple.json'),true); var_dump(StaticRepo::testConnexion()); $repo = new PatientRepo(); $repoM = new MedecinRepo(); + foreach($jsonM as $patient) { $repoM->add($patient['Civilite'], $patient['Prenom'], $patient['Nom']); } foreach($jsonP as $patient){ $repo->add($patient['Civilite'],$patient['Prenom'],$patient['Nom'],$patient['Adresse'],NULL,$patient['Ville'],$patient['CodePostal'],$patient['DateNaissance'],$patient['LieuNaissance'],$patient['NumSecuriteSociale'],$patient['MedecinTraitant']); +} + +foreach($jsonR as $rdv){ + RDVRepo::add($rdv['DateRDV'],$rdv['Duree'],$rdv['Patient_Id'],$rdv['Medecin_Id']); } \ No newline at end of file