Repository navigation
Expand file tree
/
Copy pathindex.php
More file actions
70 lines (53 loc) · 2.21 KB
/
Copy pathindex.php
File metadata and controls
70 lines (53 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
date_default_timezone_set('America/Sao_Paulo');
$loader = require __DIR__ . '/vendor/autoload.php';
use Consultorio\entidades\Pacientes;
use Consultorio\entidades\Prontuario;
use Consultorio\controlador\PacientesController;
use Consultorio\controlador\ProntuarioController;
$app = new \Slim\Slim();
$paciente = new PacientesController();
$prontuario = new ProntuarioController();
$app->get('/', function() {
echo json_encode([
"api" => "Consultorio REST",
"version" => "1.0.0",
"Desenvolvedor" => "Rafael Orlando Mendes"
]);
});
$app->get('/paciente(/(:id))', function($id = null) use ($paciente) {
echo json_encode($paciente->get($id));
});
$app->get('/pacienteconsulta(/)', function($id = null) use ($paciente) {
echo json_encode($paciente->getPaciConsult());
});
$app->post('/paciente(/)', function() use ($paciente, $app) {
$json = json_decode($app->request()->getBody());
echo json_encode($paciente->insert($json));
});
$app->put('/paciente/:id', function($id) use ($paciente, $app) {
$json = json_decode($app->request()->getBody());
echo json_encode($paciente->update($json));
});
$app->delete('/paciente/:id', function($id) use ($paciente) {
echo json_encode($paciente->delete($id));
});
$app->get('/prontuario(/(:id))', function($id = null) use ($prontuario) {
echo json_encode($prontuario->get($id));
});
$app->get('/consultaspacientes(/(:id))', function($id) use ($paciente) {
echo json_encode($paciente->getConsultas($id));
});
$app->post('/prontuario(/)', function() use ($prontuario, $app) {
$json = json_decode($app->request()->getBody());
echo json_encode($prontuario->insert($json));
});
$app->put('/prontuario/:id', function($id) use ($prontuario, $app) {
$json = json_decode($app->request()->getBody());
echo json_encode($prontuario->update($json));
});
$app->delete('/prontuario/:id', function($id) use ($prontuario) {
echo json_encode($prontuario->delete($id));
});
$app->run();
?>