projet-php/managers/Patient.class.php

44 lines
1.9 KiB
PHP
Executable File

<?php
/**
* Created by PhpStorm.
* User: seekdasky
* Date: 10/12/15
* Time: 09:16
*/
class Patient
{
public function add($params){
$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'],
$params['date_naissance']->format('Y-m-d'),$params['lieu_naissance'],$params['num_secu'],$params['medecin_traitant']) !== FALSE){
Response::quickResponse(200, json_encode([
'status' => 'success',
'title' => 'Création enregistrée!',
'message' => 'Le patient '.$params['prenom'].' '.$params['nom'].' a bien été créé.'
]));
}else{
Response::quickResponse(200, json_encode([ 'status' => 'error' ]));
}
}
public function update($params){
$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){
Response::quickResponse(200, json_encode(['status'=>'success']));
}else{
Response::quickResponse(200, json_encode(['status'=>'error']));
}
}
public function delete($params){
if(PatientRepo::delete($params['id_patient']) !==FALSE){
Response::quickResponse(200, json_encode(['status'=>'success']));
}else{
Response::quickResponse(200, json_encode(['status'=>'error']));
}
}
}