projet-php/Patients.php

261 lines
12 KiB
PHP
Executable File

<?php session_start();
require('autoloader.php');
if(!Authentification::checkUser(0)){
header("Location: http://".$_SERVER['HTTP_HOST']."/index.php");
die();
};
function customCompression($input, $compression){
if( $compression ) return strtr(base64_encode(addslashes(gzcompress(serialize($input),9))), '+/=', '-_,');
else return unserialize(gzuncompress(stripslashes(base64_decode(strtr($input, '-_,', '+/=')))));
}
/* REPONSE DU MANAGER */
$managerStatus = (isset($_GET['status'])) ? $_GET['status'] : null;
$managerTitle = (isset($_GET['title'])) ? $_GET['title'] : 'Oups!';
$managerMessage = (isset($_GET['message'])) ? $_GET['message'] : 'Erreur interne!';
// on récupère la liste des médecins si donnée
$patientsSearch = ( isset($_GET['patients']) ) ? json_decode( customCompression($_GET['patients'], false) , true) : [];
/* MODIFICATION DE PATIENT */
$patientOpt = (isset($_POST['update_id'])) ? $_POST['update_id'] : null;
?>
<!DOCTYPE html>
<html>
<head>
<title>Gestion des patients</title>
<meta charset='utf-8'/>
<meta name='description' value='Site de test'/>
<meta name='author' value='{xdrm} & SeekDaSky'/>
<link rel='stylesheet' href='css/font.css'/>
<link rel='stylesheet' href='css/animations.css'/>
<link rel='stylesheet' href='css/global.css'/>
<link rel='stylesheet' href='css/purple.theme.css'/>
<link rel='stylesheet' href='css/responsive.css'/>
<script type='text/javascript' src='js/lib/API.js'></script>
<script type='text/javascript' src='js/lib/adjust.js'></script>
<script type='text/javascript' src='js/lib/input-checker.js'></script>
</head>
<body>
<!-- BARRE DE NOTIFICATIONS -->
<div id='NOTIFBAR' class='<?php echo ($managerStatus!=null) ? 'active '.$managerStatus : $managerStatus; ?>'>
<div></div>
<div>
<h3><?php echo $managerTitle; ?></h3>
<p><?php echo $managerMessage; ?></p>
<a href='?patients=<?php echo customCompression( json_encode($patientsSearch), true ); ?>'><input type='button' value='Fermer'></a>
</div>
</div>
<!-- WRAPPER DE LA PAGE -->
<div id='WRAPPER'>
<!-- MENU DE LA PAGE -->
<nav id='MENU'>
<a href='Dashboard.php' id='ICON'></a>
<div>
<a href='Dashboard.php' id='dashboard'>Tableau de bord</a>
<a href='Consultations.php' id='consultations'>Consultations</a>
<a href='Medecins.php' id='medecin'>Gestion des médecins</a>
<a href='Patients.php' id='patient' class='active'>Gestion des patients</a>
</div>
</nav>
<!-- CONTAINER DE LA PAGE -->
<section id='CONTAINER'>
<!-- FIL D'ARIANE -->
<div id='BREADCRUMB'><a href='Dashboard.php'>Accueil</a> <a href='Patients.php'>Gestion des Patients</a></a> </div>
<!-- /*************************************/ -->
<!-- /* CONSULTER LES PATIENTS */ -->
<!-- /*************************************/ -->
<article data-title="Rechercher un patient">
<form method='POST' action='managers/'>
<br><h4>Recherche par nom et/ou prénom:</h4>
<input type='text' id='srPrenom' name='prenom' placeholder='Prénom' value=''><br>
<input type='text' id='srNom' name='nom' placeholder='NOM' value=''><br>
<br>
<input type='hidden' name='command' value='Patient:search'>
<input type='submit' id='sbCherche' value='Lancer la recherche'>
</form><br>
<h3>Résultats:</h3><br>
<table id='searchResultPatient'><tbody>
<?php
// pour chaque médecin
foreach($patientsSearch as $PAT){ if( isset($PAT['Id']) && isset($PAT['Civilite']) && isset($PAT['Prenom']) && isset($PAT['Nom']) && isset($PAT['DateNaissance']) && isset($PAT['NumSecuriteSociale'])){
echo '<tr>';
// début modification
echo "<td colspan=5><form class='updPatient' action='#update_patient' method='POST'>";
echo "<input type='hidden' name='update_id' value='". $PAT['Id'] ."'>";
echo "<span>". (($PAT['Civilite']=='M')?'Monsieur':'Madame') ."</span>";
echo "<span>". $PAT['Prenom'] ."</span>";
echo "<span>". strtoupper($PAT['Nom']) ."</span>";
echo "<span>". $PAT['DateNaissance'] ."</span>";
echo "<span>". $PAT['NumSecuriteSociale'] ."</span>";
echo "<input type='submit' value=''>";
echo '</form></td>';
// fin modification
// début suppression
echo "<td><form class='delPatient' action='managers/' method='POST'>";
echo "<input type='hidden' name='command' value='Patient:delete'>";
echo "<input type='hidden' name='id_patient' value='".$PAT['Id']."'>";
echo "<input type='submit' value=''>";
echo '</form></td>';
// fin suppression
echo '</tr>';
}}
?>
</tbody></table>
</article>
<!-- /**************************************/ -->
<!-- /* MODIFIER UN PATIENT */ -->
<!-- /**************************************/ -->
<article data-title="Modifier un patient" id='update_patient'>
<!--
+ Civilite ('M' ou 'F')
+ prenom
+ nom
+ adresse
+ adresse2
+ code_postal
+ ville
+ date_naissance
+ lieu_naissance
+ num_secu
+ medecin_traitant
-->
<form method='POST' action='#update_patient'>
<br><h4>Modification d'un patient</h4>
<select id='csPatient' name='update_id' onchange='this.parentNode.submit();'>
<?php
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>";
echo "<input type='text' id='crVille' name='ville' placeholder='Ville' value='".$PATIENT['Ville']."' required><br>";
echo "<input type='text' id='crDN' name='date_naissance' placeholder='jj/mm/aaaa' value='".date('d/m/Y', strtotime($PATIENT['DateNaissance']))."' required><span class='info'>Date de naissance</span><br>";
echo "<input type='text' id='crLN' name='lieu_naissance' placeholder='Ville de naissance' value='".$PATIENT['LieuNaissance']."' required><br>";
echo "<input type='text' id='crSecu' name='num_secu' placeholder='1 99 19 99 999 999 99' value='".$PATIENT['NumSecuriteSociale']."' required><span class='info'>Numéro de sécurité sociale</span><br>";
echo "<span>Choix du médecin traitant (optionnel)</span><br>";
echo "<select id='crMedecin' name='id_medecin'>";
echo "<option value='.'>Médecins traitants</option>";
foreach(MedecinRepo::getAll() as $MEDECIN)
if( $PATIENT['MedecinTraitant'] == $MEDECIN['Id'] ) // selectionné
echo "<option value='".$MEDECIN['Id']."' selected>".$MEDECIN['Nom']." ".$MEDECIN['Prenom']."</option>";
else
echo "<option value='".$MEDECIN['Id']."'>".$MEDECIN['Nom']." ".$MEDECIN['Prenom']."</option>";
echo "</select><br>";
}
?>
<input type='hidden' name='command' value='Patient:update'>
<input type='submit' id='sbModifier' value='Modifier le patient'>
</form>
</article>
<!-- /*************************************/ -->
<!-- /* AJOUTER UN PATIENT */ -->
<!-- /*************************************/ -->
<article data-title="Ajouter un patient">
<form method='POST' action='managers/'>
<!--
+ Civilite ('M' ou 'F')
+ prenom
+ nom
+ adresse
+ adresse2
+ code_postal
+ ville
+ date_naissance
+ lieu_naissance
+ num_secu
+ medecin_traitant
-->
<br><h4>Ajout d'un nouveau patient</h4>
<input type='text' id='crPrenom' name='prenom' placeholder='Prénom' value='' required><br>
<input type='text' id='crNom' name='nom' placeholder='NOM' value='' required><br>
<input type='radio' name='civilite' value='M' id='civ1' class='crCiv' checked><label for='civ1'>Homme</label><br>
<input type='radio' name='civilite' value='F' id='civ2' class='crCiv'><label for='civ2'>Femme</label><br>
<input type='text' id='crAdr' name='adresse' placeholder='Adresse' value='' required><br>
<input type='text' id='crAdr2' name='adresse2' placeholder='Complément adresse' value=''><br>
<input type='text' id='crCP' name='code_postal' placeholder='09000' value='' required><span class='info'>Code postal</span><br>
<input type='text' id='crVille' name='ville' placeholder='Ville' value='' required><br>
<input type='text' id='crDN' name='date_naissance' placeholder='jj/mm/aaaa' value='' required><span class='info'>Date de naissance</span><br>
<input type='text' id='crLN' name='lieu_naissance' placeholder='Ville de naissance' value='' required><br>
<input type='text' id='crSecu' name='num_secu' placeholder='1 99 19 99 999 999 99' value='' required><span class='info'>Numéro de sécurité sociale</span><br>
<span>Choix du médecin traitant (optionnel)</span><br>
<select id='crMedecin' name='id_medecin'><?php
echo "<option value='.'>Médecins traitants</option>";
foreach(MedecinRepo::getAll() as $MEDECIN)
echo "<option value='".$MEDECIN['Id']."'>".$MEDECIN['Nom']." ".$MEDECIN['Prenom']."</option>";
?></select>
<br>
<input type='hidden' name='command' value='Patient:add'>
<input type='submit' id='sbCreer' value='Créer le patient'>
</form>
</article>
</section>
</div>
<script type='text/javascript' src='js/patients.js'></script>
</body>
</html>