Modification de patient ok
This commit is contained in:
parent
9bb13bca04
commit
d1e2b88cee
|
@ -95,7 +95,7 @@ $medecinsSearch = ( isset($_GET['medecins']) ) ? json_decode( customCompression(
|
|||
foreach($medecinsSearch as $MED){ if( isset($MED['Id']) && isset($MED['Civilite']) && isset($MED['Prenom']) && isset($MED['Nom']) ){
|
||||
echo '<tr>';
|
||||
// début modification
|
||||
echo "<td colspan=4><form class='updPatient' action='managers/' method='POST'>";
|
||||
echo "<td colspan=4><form class='updMedecin' action='managers/' method='POST'>";
|
||||
echo "<input type='hidden' name='Id' value='". $PAT['Id'] ."'>";
|
||||
echo "<input type='text' name='Civilite' value='". (($PAT['Civilite']=='M')?'Monsieur':'Madame') ."' readonly>";
|
||||
echo "<input type='text' name='Prenom' value='". $PAT['Prenom'] ."'>";
|
||||
|
|
99
Patients.php
99
Patients.php
|
@ -18,6 +18,10 @@ $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>
|
||||
|
@ -95,16 +99,14 @@ $patientsSearch = ( isset($_GET['patients']) ) ? json_decode( customCompression(
|
|||
|
||||
echo '<tr>';
|
||||
// début modification
|
||||
echo "<td colspan=5><form class='updPatient' action='managers/' method='POST'>";
|
||||
echo "<input type='hidden' name='Id' value='". $PAT['Id'] ."'>";
|
||||
echo "<input type='text' name='Civilite' value='". (($PAT['Civilite']=='M')?'Monsieur':'Madame') ."' readonly>";
|
||||
echo "<input type='text' name='Prenom' value='". $PAT['Prenom'] ."'>";
|
||||
echo "<input type='text' name='Nom' value='". strtoupper($PAT['Nom']) ."'>";
|
||||
echo "<input type='text' name='DateNaissance' value='". $PAT['DateNaissance'] ."'>";
|
||||
echo "<input type='text' name='NumSecuriteSociale' value='". $PAT['NumSecuriteSociale'] ."'>";
|
||||
echo "<input type='hidden' name='command' value='Patient:update'>";
|
||||
echo "<input type='hidden' name='id_patient' value='". $PAT['Id'] ."'>";
|
||||
echo "<input type='submit' value=''>";
|
||||
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
|
||||
|
||||
|
@ -128,6 +130,83 @@ $patientsSearch = ( isset($_GET['patients']) ) ? json_decode( customCompression(
|
|||
|
||||
|
||||
|
||||
<?php/*********************************/
|
||||
/* 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>
|
||||
|
||||
|
||||
|
||||
<?php/********************************/
|
||||
/* AJOUTER UN PATIENT */
|
||||
/*************************************/ ?>
|
||||
|
|
|
@ -785,16 +785,22 @@ input[type=radio]:checked + label:before{
|
|||
|
||||
/* Modification champ de recherche (patient/médecin/consultation) */
|
||||
|
||||
#CONTAINER > article .updPatient input[type=text],
|
||||
#CONTAINER > article .updPatient span,
|
||||
#CONTAINER > article .updMedecin input[type=text]{
|
||||
width: 6em;
|
||||
display: inline-block;
|
||||
width: 7em;
|
||||
padding: .1em;
|
||||
margin: 0 .2em;
|
||||
|
||||
border: 0;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
|
||||
#CONTAINER > article .updMedecin input[type=text]:hover{
|
||||
border-color: #cccccc;
|
||||
}
|
||||
|
||||
|
||||
#CONTAINER > article .updPatient input[type=submit],
|
||||
#CONTAINER > article .updMedecin input[type=submit]{
|
||||
|
|
|
@ -155,7 +155,7 @@ function displayFoundMedecins(foundMedecins){
|
|||
for( var i = 0 ; i < foundMedecins.length ; i++ ){
|
||||
content += '<tr>';
|
||||
// début modification
|
||||
content += "<td colspan=4><form class='updPatient' action='managers/' method='POST'>";
|
||||
content += "<td colspan=4><form class='updMedecin' action='managers/' method='POST'>";
|
||||
content += "<input type='hidden' name='Id' value='"+ foundMedecins[i].Id +"'>";
|
||||
content += "<input type='text' name='Civilite' value='"+ ((foundMedecins[i].Civilite=='M')?'Monsieur':'Madame') + "'>";
|
||||
content += "<input type='text' name='Prenom' value='"+ foundMedecins[i].Prenom + "'>";
|
||||
|
|
|
@ -234,16 +234,15 @@ function displayFoundPatients(foundPatients){
|
|||
for( var i = 0 ; i < foundPatients.length ; i++ ){
|
||||
content += '<tr>';
|
||||
// début modification
|
||||
content += "<td colspan=6><form class='updPatient' action='managers/' method='POST'>";
|
||||
content += "<input type='hidden' name='Id' value='"+ foundPatients[i].Id +"'>";
|
||||
content += "<input type='text' name='Civilite' value='"+ ((foundPatients[i].Civilite=='M')?'Monsieur':'Madame') + "'>";
|
||||
content += "<input type='text' name='Prenom' value='"+ foundPatients[i].Prenom + "'>";
|
||||
content += "<input type='text' name='Nom' value='"+ foundPatients[i].Nom.toUpperCase() + "'>";
|
||||
content += "<input type='text' name='DateNaissance' value='"+ foundPatients[i].DateNaissance + "'>";
|
||||
content += "<input type='text' name='NumSecuriteSociale' value='"+ foundPatients[i].NumSecuriteSociale + "'>";
|
||||
|
||||
content += "<input type='hidden' name='command' value='Patient:update'>";
|
||||
content += "<td colspan=5><form class='updPatient' action='#update_patient' method='POST'>";
|
||||
content += "<input type='hidden' name='update_id' value='"+ foundPatients[i].Id +"'>";
|
||||
content += "<span>"+ ((foundPatients[i].Civilite=='M')?'Monsieur':'Madame') + "</span>";
|
||||
content += "<span>"+ foundPatients[i].Prenom + "</span>";
|
||||
content += "<span>"+ foundPatients[i].Nom.toUpperCase() + "</span>";
|
||||
content += "<span>"+ foundPatients[i].DateNaissance + "</span>";
|
||||
content += "<span>"+ foundPatients[i].NumSecuriteSociale + "</span>";
|
||||
content += "<input type='submit' value=''>";
|
||||
|
||||
content += '</form></td>';
|
||||
// fin modification
|
||||
|
||||
|
|
|
@ -92,14 +92,34 @@ class Patient
|
|||
}
|
||||
|
||||
public function update($params){
|
||||
if(StaticRepo::checkParam($params['date_naissance'],'Date')){
|
||||
$params['num_secu'] = str_replace(' ','',$params['num_secu']);
|
||||
$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){
|
||||
if( isset($params['id_patient'])
|
||||
&& isset($params['civilite'])
|
||||
&& isset($params['prenom'])
|
||||
&& isset($params['nom'])
|
||||
&& isset($params['adresse'])
|
||||
&& isset($params['adresse2'])
|
||||
&& isset($params['ville'])
|
||||
&& isset($params['code_postal'])
|
||||
&& isset($params['date_naissance'])
|
||||
&& isset($params['lieu_naissance'])
|
||||
&& isset($params['num_secu'])
|
||||
&& isset($params['id_medecin']) ){
|
||||
|
||||
if( PatientRepo::update($params['id_patient'],
|
||||
$params['civilite'],
|
||||
strtolower($params['prenom']),
|
||||
strtoupper($params['nom']),
|
||||
$params['adresse'],
|
||||
$params['adresse2'],
|
||||
$params['ville'],
|
||||
$params['code_postal'],
|
||||
$params['date_naissance'],
|
||||
$params['lieu_naissance'],
|
||||
$params['num_secu'],
|
||||
$params['id_medecin']) !== FALSE ){
|
||||
|
||||
$_status = 'success';
|
||||
$_title = 'Modification effectuée!';
|
||||
$_status = 'success';
|
||||
$_title = 'Modification effectuée!';
|
||||
$_message = 'Le patient <strong>'.$params['prenom'].' '.$params['nom'].'</strong> a bien été modifié.';
|
||||
|
||||
if( !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' )
|
||||
|
@ -125,8 +145,8 @@ class Patient
|
|||
}
|
||||
}else{
|
||||
$_status = 'error';
|
||||
$_title = 'Erreur de modification!';
|
||||
$_message = 'Le format de la date est incorrect. Réessayez!';
|
||||
$_title = 'Erreur de paramètres!';
|
||||
$_message = 'Certains champs sont incorrects. 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 ]));
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
class PatientRepo
|
||||
{
|
||||
public static function getById($id){
|
||||
if(!StaticRepo::checkParam($id,'Integer')){return false;}
|
||||
if(!StaticRepo::checkParam($id,'Numeric')){return false;}
|
||||
|
||||
$req = StaticRepo::getConnexion()->prepare('SELECT * FROM Patient WHERE Id = :id');
|
||||
$req->execute(['id' => $id]);
|
||||
|
@ -71,42 +71,72 @@ class PatientRepo
|
|||
|
||||
}
|
||||
|
||||
public static function update($id,$civilite,$prenom,$nom,$adresse,$adresse2,$ville,$codePostal,$dateNaissance,$lieuNaissance,$numSecu,$medecinTraitant){
|
||||
public static function update(
|
||||
$id,
|
||||
$civilite,
|
||||
$prenom,
|
||||
$nom,
|
||||
$adresse,
|
||||
$adresse2,
|
||||
$ville,
|
||||
$codePostal,
|
||||
$dateNaissance,
|
||||
$lieuNaissance,
|
||||
$numSecu,
|
||||
$medecinTraitant ){
|
||||
|
||||
$correctTypes = StaticRepo::checkParam($civilite,'Civilite');
|
||||
$correctTypes = StaticRepo::checkParam($id, 'Numeric');
|
||||
$correctTypes = $correctTypes && StaticRepo::checkParam($civilite, 'Civilite');
|
||||
$correctTypes = $correctTypes && StaticRepo::checkParam($prenom,'String45');
|
||||
$correctTypes = $correctTypes && StaticRepo::checkParam($nom,'String45');
|
||||
$correctTypes = $correctTypes && StaticRepo::checkParam($adresse,'String255');
|
||||
$correctTypes = $correctTypes && ( $adresse2 == 'null' || $adresse2 === null || StaticRepo::checkParam($adresse2, 'String255') );
|
||||
$correctTypes = $correctTypes && ( $adresse2 == 'null' || $adresse2 == '' || $adresse2 === null || StaticRepo::checkParam($adresse2, 'String255') );
|
||||
$correctTypes = $correctTypes && StaticRepo::checkParam($ville,'String50');
|
||||
$correctTypes = $correctTypes && StaticRepo::checkParam($codePostal,'String');
|
||||
$correctTypes = $correctTypes && StaticRepo::checkParam($dateNaissance,'Date');
|
||||
$correctTypes = $correctTypes && StaticRepo::checkParam($lieuNaissance,'String50');
|
||||
$correctTypes = $correctTypes && ( $medecinTraitant == 'null' || $medecinTraitant === null ||StaticRepo::checkParam($medecinTraitant, 'Integer') );
|
||||
$correctTypes = $correctTypes && ( $medecinTraitant == 'null' || $medecinTraitant === null || StaticRepo::checkParam($medecinTraitant, 'Numeric') );
|
||||
if( !$correctTypes ) return false;
|
||||
|
||||
$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;');
|
||||
// on enlève les espaces du numéro de sécu
|
||||
$numSecu = str_replace(' ', '', $numSecu);
|
||||
// on met la date de naissance au bon format
|
||||
$dateNaissance = DateTime::createFromFormat('d/m/Y', $dateNaissance)->format('Y-m-d 00:00:00');
|
||||
exit();
|
||||
|
||||
$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]);
|
||||
':nom' => $nom,
|
||||
':prenom' => $prenom,
|
||||
':adresse' => $adresse,
|
||||
':adresse2' => $adresse2,
|
||||
':ville' => $ville,
|
||||
':codePostal' => $codePostal,
|
||||
':dateNaissance' => $dateNaissance,
|
||||
':lieuNaissance' => $lieuNaissance,
|
||||
':numSecu' => $numSecu,
|
||||
':medecin' => $medecinTraitant,
|
||||
':id' => $id]);
|
||||
//PDO renvoie un ID sous forme de char, on transtype
|
||||
$id = StaticRepo::getConnexion()->lastInsertId();
|
||||
|
||||
settype($id,'integer');
|
||||
if($result){return $id;}
|
||||
else{return false;}
|
||||
|
||||
if($result) return $id;
|
||||
else return false;
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue