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', '19/11/1996', 'Toulouse', '123456789876543', 69)); $patient = PatientRepo::getById($id); $this->assertEquals('F', $patient['Civilite']); PatientRepo::delete($id); }
public static function getAgePatient() { $patients = PatientRepo::getAll(); $homme = ['25-' => 0, '25-50' => 0, '50+' => 0]; $femme = ['25-' => 0, '25-50' => 0, '50+' => 0]; $nbrHomme = 0; $nbrFemme = 0; foreach ($patients as $key => $patient) { $dateNaissance = strtotime($patient['DateNaissance']); $age = date('Y', time() - $dateNaissance); $patient['age'] = $age - 1970; switch ($patient['Civilite']) { case 'M': $nbrHomme++; if ($patient['age'] < 25) { $homme['25-']++; } elseif ($patient['age'] < 50) { $homme['25-50']++; } else { $homme['50+']++; } break; case 'F': $nbrFemme++; if ($patient['age'] < 25) { $femme['25-']++; } elseif ($patient['age'] < 50) { $femme['25-50']++; } else { $femme['50+']++; } break; } } return ['H' => $homme, 'F' => $femme, 'NbrH' => $nbrHomme, 'NbrF' => $nbrFemme]; }
echo "<option value='*'>Tous les patients:</option>"; foreach (PatientRepo::getAll() as $PATIENT) { if ($PATIENT['Id'] == $patientOpt) { // selection par défaut echo "<option value='" . $PATIENT['Id'] . "' data-medecin='" . $PATIENT['MedecinTraitant'] . "' selected>" . $PATIENT['Nom'] . " " . $PATIENT['Prenom'] . "</option>"; } else { // sinon echo "<option value='" . $PATIENT['Id'] . "' data-medecin='" . $PATIENT['MedecinTraitant'] . "'>" . $PATIENT['Nom'] . " " . $PATIENT['Prenom'] . "</option>"; } } ?> </select><br> </form> <form action='managers/' method='POST'> <?php if ($patientOpt != null && ($PATIENT = PatientRepo::getById($patientOpt))) { echo "<input type='hidden' name='id_patient' value='" . $PATIENT['Id'] . "'>"; echo "<input type='text' id='crPrenom' name='prenom' placeholder='Prénom' value='" . $PATIENT['Prenom'] . "' required><br>"; echo "<input type='text' id='crNom' name='nom' placeholder='NOM' value='" . $PATIENT['Nom'] . "' required><br>"; // homme selectionné if ($PATIENT['Civilite'] == 'M') { echo "<input type='radio' name='civilite' value='M' id='civ1' class='crCiv' checked><label for='civ1'>Homme</label><br>"; echo "<input type='radio' name='civilite' value='F' id='civ2' class='crCiv'><label for='civ2'>Femme</label><br>"; // femme selectionnée } else { echo "<input type='radio' name='civilite' value='M' id='civ1' class='crCiv'><label for='civ1'>Homme</label><br>"; echo "<input type='radio' name='civilite' value='F' id='civ2' class='crCiv' checked><label for='civ2'>Femme</label><br>"; } echo "<input type='text' id='crAdr' name='adresse' placeholder='Adresse' value='" . $PATIENT['Adresse'] . "' required><br>"; echo "<input type='text' id='crAdr2' name='adresse2' placeholder='Complément adresse' value='" . $PATIENT['Adresse2'] . "'><br>"; echo "<input type='text' id='crCP' name='code_postal' placeholder='09000' value='" . $PATIENT['CodePostal'] . "' required><span class='info'>Code postal</span><br>";
public function delete($params) { if (PatientRepo::delete($params['id_patient']) !== FALSE) { $_status = 'success'; $_title = 'Patient supprimé!'; $_message = 'Le patient a bien été supprimé de la base de données!'; if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') { Response::quickResponse(200, json_encode(['status' => $_status, 'title' => $_title, 'message' => $_message])); } else { $response = new Response(); $response->setHeader('Location', 'http://' . $_SERVER['HTTP_HOST'] . '/Patients.php?status=' . $_status . '&title=' . $_title . '&message=' . $_message); $response->send(); } } else { $_status = 'error'; $_title = 'Erreur de suppression!'; $_message = 'Erreur lors de la suppression. Réessayez!'; if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') { Response::quickResponse(200, json_encode(['status' => $_status, 'title' => $_title, 'message' => $_message])); } else { $response = new Response(); $response->setHeader('Location', 'http://' . $_SERVER['HTTP_HOST'] . '/Patients.php?status=' . $_status . '&title=' . $_title . '&message=' . $_message); $response->send(); } } }
</article> <!-- /*************************************/ --> <!-- /* SAISIR UN RENDEZ-VOUS */ --> <!-- /*************************************/ --> <article data-title="Saisir un rendez-vous"> <form method='POST' action='managers/'> <div> <select id='newRDVPatient' name='id_patient'> <option value='*'>Patient:</option> <?php foreach (PatientRepo::getAll() as $PATIENT) { echo "<option value='" . $PATIENT['Id'] . "' data-medecin='" . $PATIENT['MedecinTraitant'] . "'>" . $PATIENT['Nom'] . " " . $PATIENT['Prenom'] . "</option>"; } ?> </select> </div><div> <select id='newRDVMedecin' name='id_medecin'> <option value='*'>Medecins:</option> <?php foreach (MedecinRepo::getAll() as $MEDECIN) { echo "<option value='" . $MEDECIN['Id'] . "'>" . $MEDECIN['Nom'] . " " . $MEDECIN['Prenom'] . "</option>"; } ?> </select><span class='associated'>Médecin traitant du patient.</span> </div><br>
public function getSVG($params) { // conversion du mois if (preg_match('/^(\\d{2})\\/(\\d{4})$/', $params['mois'], $m)) { $mois = $m[2] . '-' . $m[1]; } else { $mois = '2015-12'; } // constantes et début <SVG> $days = ['Mon' => 0, 'Tue' => 1, 'Wed' => 2, 'Thu' => 3, 'Fri' => 4, 'Sat' => 5, 'Sun' => 6]; $svgCalendar = "<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n <!-- Created with PHP Maggle !!LAUUUULEU!! -->\n\n <svg\n xmlns:svg='http://www.w3.org/2000/svg'\n xmlns='http://www.w3.org/2000/svg'\n xmlns:xlink='http://www.w3.org/1999/xlink'\n version='1.1'\n width='80%'\n height='auto'\n viewbox='0 0 7700 7000'\n id='svg2'>\n <metadata\n id='metadata7'>\n <rdf:RDF>\n <cc:Work\n rdf:about='>\n <dc:format>image/svg+xml</dc:format>\n <dc:type\n rdf:resource='http://purl.org/dc/dcmitype/StillImage' />\n <dc:title>Calendar</dc:title>\n </cc:Work>\n </rdf:RDF>\n </metadata>\n "; $current = strtotime($mois); //on range les rendez-vous dans un tableau avec leur jour comme clé $RDVTemp = RDVRepo::getByMonth($current); $RDVs = []; foreach ($RDVTemp as $rdv) { if (!isset($RDVs[date('j', strtotime($rdv['DateRDV']))])) { $RDVs[date('j', strtotime($rdv['DateRDV']))] = []; } array_push($RDVs[date('j', strtotime($rdv['DateRDV']))], $rdv); } foreach (range(1, date('t', strtotime($params['mois']))) as $day) { //génération du SVG de la journée //selon si on a une date sur un ou deux chiffres, on adapte $date = strftime("%B %Y", $current); if ($day >= 10) { $xDate = 1500; } else { $xDate = 1000; } //fond général + affichage de la date $svgCalendar .= '<g class="Day_' . $day . '"> <!-- Case du jour --> <rect width="7700" height="7000" x="0" y="0" class="backgroundDay_' . $day . '" style="fill:#fff;fill-opacity:1;stroke:none" /> <!-- Numéro du jour --> <text x="300" y="1000" class="TextDay_' . $day . '" xml:space="preserve" style="font-size:750px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sawasdee;-inkscape-font-specification:Sawasdee"> <tspan x="300" y="1000" class="TextSpanDay_' . $day . '">' . $day . ' </tspan> </text> <!-- Texte du jour --> <text x="' . $xDate . '" y="1000" class="TextMonthDay_' . $day . '" xml:space="preserve" style="font-size:400px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sawasdee;-inkscape-font-specification:Sawasdee"><tspan x="' . $xDate . '" y="1000" class="TextSpanMonthDay_' . $day . '">' . $date . ' </tspan> </text> '; //on défini le tableau si jamais if (!isset($RDVs[$day])) { $RDVs[$day] = []; } //on parcours les consultations du jour pour les afficher foreach ($RDVs[$day] as $key => $rdv) { $patient = PatientRepo::getById(intval($rdv['Patient_Id'])); $medecin = MedecinRepo::getById(intval($rdv['Medecin_id'])); //couleur suivant le nombre de consultation $color = $key % 2 == 0 ? 'f9f9f9' : 'ececec'; //du svg blablabla $yConsult = 1500 + 700 * $key; $svgCalendar .= '<g class="ConsultationGroupDay' . $day . 'Consult' . $key . '" data-patient="' . $rdv['Patient_Id'] . '" data-medecin="' . $rdv['Medecin_id'] . '"> <rect width="7000" height="700" x="300" y="' . $yConsult . '" class="ConsultationBackgroundDay' . $day . 'Consult' . $key . '" style="fill:#' . $color . ';fill-opacity:1;stroke:none" /> <text x="400" y="' . $yConsult . '" class="ConsultationTextHourDay' . $day . 'Consult' . $key . '" xml:space="preserve" style="font-size:400px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sawasdee;-inkscape-font-specification:Sawasdee"><tspan x="400" y="' . ($yConsult + 500) . '" class="ConsultationTextSpanHourDay' . $day . 'Consult' . $key . '">' . date('G:i', strtotime($rdv['DateRDV'])) . '</tspan></text> <g id="g5136"> <text x="6100" y="' . ($yConsult + 500) . '" id="text5084" xml:space="preserve" style="font-size:400px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#999999;fill-opacity:1;stroke:none;font-family:Sawasdee;-inkscape-font-specification:Sawasdee"><tspan x="6100" y="' . ($yConsult + 500) . '" id="tspan5086">' . $rdv['Minute'] . 'mn</tspan></text> <g id="g5224"> <text x="2500" y="' . ($yConsult + 270) . '" id="text5072" xml:space="preserve" style="font-size:250px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#4d4d4d;fill-opacity:1;stroke:none;font-family:Sawasdee;-inkscape-font-specification:Sawasdee"><tspan x="2500" y="' . ($yConsult + 270) . '" id="tspan5074">' . $medecin['Prenom'] . '</tspan></text> <text x="3800" y="' . ($yConsult + 270) . '" id="text5186" xml:space="preserve" style="font-size:250px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sawasdee;-inkscape-font-specification:Sawasdee"><tspan x="3800" y="' . ($yConsult + 270) . '" id="tspan5188" style="font-size:250;fill:#4d4d4d;fill-opacity:1">' . $medecin['Nom'] . '</tspan></text> </g> <g id="g5230"> <text x="2500" y="' . ($yConsult + 600) . '" id="text5080" xml:space="preserve" style="font-size:250px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#4d4d4d;fill-opacity:1;stroke:none;font-family:Sawasdee;-inkscape-font-specification:Sawasdee"><tspan x="2500" y="' . ($yConsult + 600) . '" id="tspan5082">' . $patient['Prenom'] . '</tspan></text> <text x="3800" y="' . ($yConsult + 600) . '" id="text5194" xml:space="preserve" style="font-size:250px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#4d4d4d;fill-opacity:1;stroke:none;font-family:Sawasdee;-inkscape-font-specification:Sawasdee"><tspan x="3800" y="' . ($yConsult + 600) . '" id="tspan5196">' . $patient['Nom'] . '</tspan></text> </g> </g>'; } $svgCalendar .= '</g></g>'; } //on met u fond (sinon on voit les consultation en arrière plan) $svgCalendar .= '</g></g><g class="Calendar">'; $svgCalendar .= '<rect width="7700" height="6000" x="0" y="0" class="BackgroundCalendar" style="fill:#fff";fill-opacity:1;stroke:none" />'; //position x;y de base des jours du calendrier $x = 1100 * $days[date('D', $current)]; $y = 0; //initialisation de variables $cal = []; $week = []; //obligé de séparer la génération des consultation et du calendrier pour organiser le svg foreach (range(1, date('t', strtotime($params['mois']))) as $day) { //génération du svg du calendrier $day = date('D', $current); $day_nbr = date('d', $current); $week[$days[$day]] = date('d', $current); $current = strtotime("+1 day", $current); if ($y / 1100 % 2 == 0) { if ($days[$day] % 2 == 0) { $color = 'f0f0f0'; } else { $color = 'fff'; } $svgCalendar .= '<rect width="1000" height="1000" ry="90" x="' . $x . '" y="' . $y . '" class="day_' . $days[$day] . '" style="fill:#' . $color . ';fill-opacity:1;stroke:none" />'; } else { if ($days[$day] % 2 != 0) { $color = 'f0f0f0'; } else { $color = 'fff'; } $svgCalendar .= '<rect width="1000" height="1000" ry="90" x="' . $x . '" y="' . $y . '" class="day_' . $days[$day] . '" style="fill:#' . $color . ';fill-opacity:1;stroke:none" />'; } $svgCalendar .= '<text x="' . ($x - 700) . '" y="' . ($y + 1100 - 700) . '" class="Textday_' . $days[$day] . '" xml:space="preserve" style="font-size:400px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;font-family:Sawasdee;-inkscape-font-specification:Sawasdee"><tspan x="' . ($x + 260) . '" y="' . ($y + 1100 - 470) . '" class="TextDay_' . $days[$day] . '">' . $day_nbr . '</tspan></text>'; $x += 1100; if ($days[$day] == 6) { $i = 0; array_push($cal, $week); $week = []; $y += 1100; $x = 0; } } $svgCalendar .= '</g>'; echo $svgCalendar; }
<?php /** * Created by PhpStorm. * User: seekdasky * Date: 03/12/15 * Time: 11:52 */ 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']); }