2023-03-24 17:25:43 -03:00
|
|
|
<?php
|
|
|
|
require_once 'clases/respuestas.class.php';
|
|
|
|
require_once 'clases/pacientes.class.php';
|
|
|
|
|
|
|
|
$_respuestas = new respuestas;
|
|
|
|
$_pacientes = new pacientes;
|
|
|
|
|
|
|
|
header('Content-Type: application/json; charset=utf-8');
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] == "GET"){
|
2023-03-24 18:32:35 -03:00
|
|
|
|
2023-03-24 17:25:43 -03:00
|
|
|
if (isset($_GET["page"])){
|
|
|
|
$pagina = $_GET["page"];
|
|
|
|
$lista_pacientes = $_pacientes->listaPacientes($pagina);
|
|
|
|
echo json_encode($lista_pacientes);
|
2023-03-24 18:32:35 -03:00
|
|
|
http_response_code(200);
|
2023-03-24 17:25:43 -03:00
|
|
|
} else if (isset($_GET["id"])){
|
|
|
|
$pacienteid = $_GET["id"];
|
|
|
|
$datos_paciente = $_pacientes->obtenerPaciente($pacienteid);
|
|
|
|
echo json_encode($datos_paciente);
|
2023-03-24 18:32:35 -03:00
|
|
|
http_response_code(200);
|
2023-03-24 17:25:43 -03:00
|
|
|
}
|
2023-03-24 18:32:35 -03:00
|
|
|
|
2023-03-24 17:25:43 -03:00
|
|
|
} else if ($_SERVER['REQUEST_METHOD'] == "POST"){
|
2023-03-24 18:32:35 -03:00
|
|
|
// recepción de datos
|
|
|
|
$postBody = file_get_contents("php://input");
|
|
|
|
// envio de datos al manejador
|
|
|
|
$datosArray = $_pacientes->post($postBody);
|
|
|
|
// devolucion de respuesta
|
|
|
|
if(isset($datosArray["result"]["error_id"])){
|
|
|
|
$responseCode = $datosArray["result"]["error_id"];
|
|
|
|
http_response_code($responseCode);
|
|
|
|
}else{
|
|
|
|
http_response_code(200);
|
|
|
|
}
|
|
|
|
echo json_encode($datosArray);
|
2023-03-24 17:25:43 -03:00
|
|
|
|
|
|
|
} else if ($_SERVER['REQUEST_METHOD'] == "PUT"){
|
|
|
|
echo "hola PUT";
|
|
|
|
|
|
|
|
} else if ($_SERVER['REQUEST_METHOD'] == "DELETE"){
|
|
|
|
echo "hola DELETE";
|
|
|
|
|
|
|
|
} else {
|
|
|
|
$datosArray = $_respuestas->error_405();
|
|
|
|
echo json_encode($datosArray);
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|