2015-12-10 09:47:30 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Created by PhpStorm.
|
|
|
|
* User: seekdasky
|
|
|
|
* Date: 10/12/15
|
|
|
|
* Time: 09:16
|
|
|
|
*/
|
|
|
|
class Patient
|
|
|
|
{
|
|
|
|
public function add($params){
|
2015-12-10 10:12:44 +00:00
|
|
|
$params['date_naissance'] = DateTime::createFromFormat('d/m/Y', $params['date_naissance']);
|
|
|
|
if(PatientRepo::add($params['civilite'],strtolower($params['prenom']),strtolower($params['nom']),$params['adresse'],$params['adresse2'],$params['ville'],$params['code_postal'],
|
2015-12-10 09:47:30 +00:00
|
|
|
$params['date_naissance']->format('Y-m-d'),$params['lieu_naissance'],$params['num_secu'],$params['medecin_traitant']) !==FALSE){
|
|
|
|
$response = new Response();
|
2015-12-10 10:12:44 +00:00
|
|
|
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Patients.php?type=creation");
|
2015-12-10 09:47:30 +00:00
|
|
|
$response->send();
|
|
|
|
}else{
|
|
|
|
$response = new Response(500);
|
2015-12-10 10:12:44 +00:00
|
|
|
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Patients.php?type=error");
|
2015-12-10 09:47:30 +00:00
|
|
|
$response->send();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function update($params){
|
2015-12-10 10:12:44 +00:00
|
|
|
$params['date_naissance'] = DateTime::createFromFormat('d/m/Y', $params['date_naissance']);
|
2015-12-10 09:47:30 +00:00
|
|
|
if(PatientRepo::update($params['id_patient'],$params['civilite'],strtolower($params['prenom']),strtolower($params['nom']),$params['adresse'],$params['adresse2'],$params['ville'],$params['cope_postal'],
|
|
|
|
$params['date_naissance']->format('Y-m-d'),$params['lieu_naissance'],$params['num_secu'],$params['medecin_traitant']) !==FALSE){
|
|
|
|
$response = new Response();
|
2015-12-10 10:12:44 +00:00
|
|
|
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Patients.php?type=creation");
|
2015-12-10 09:47:30 +00:00
|
|
|
$response->send();
|
|
|
|
}else{
|
|
|
|
$response = new Response(500);
|
2015-12-10 10:12:44 +00:00
|
|
|
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Patients.php?type=error");
|
2015-12-10 09:47:30 +00:00
|
|
|
$response->send();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function delete($params){
|
|
|
|
if(PatientRepo::delete($params['id_patient']) !==FALSE){
|
|
|
|
$response = new Response();
|
|
|
|
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Patients.php?type=supression");
|
|
|
|
$response->send();
|
|
|
|
}else{
|
|
|
|
$response = new Response(500);
|
|
|
|
$response->setHeader('Location',"http://".$_SERVER['HTTP_HOST']."/Patients.php?type=error");
|
|
|
|
$response->send();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|