Skip to content

Commit

Permalink
Atualização da API
Browse files Browse the repository at this point in the history
A API agora busca os ECGs de hoje
  • Loading branch information
tibetteixeira committed Jun 6, 2019
1 parent 9195559 commit b1e7c99
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
7 changes: 7 additions & 0 deletions APIMysql/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ function isTheseParametersAvailable($params) {
$response['message'] = 'Diagnósticos listados com sucesso';
$response['diagnostic'] = $op->getDiagnosticList($_POST['cpf']);
break;

case 'diagnosticEcgList':
isTheseParametersAvailable(array('ecgId'));
$response['error'] = false;
$response['message'] = 'Diagnósticos carregado com sucesso';
$response['diagnosticEcg'] = $op->getDiagnosticEcgList($_POST['ecgId']);
break;
}

} else {
Expand Down
31 changes: 31 additions & 0 deletions APIMysql/DbOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,37 @@ function getDiagnosticList($cpf) {

return $diagnosticos;
}

function getDiagnosticEcgList($ecgId) {
try {
$stmt = $this->pdo->prepare("SELECT d_diagnostico_id, d_crm, d_ecg_id,
d_descricao, d_data_hora_diagnostico, m_nome
FROM ecg
INNER JOIN diagnostico on (d_ecg_id = e_ecg_id)
INNER JOIN medico on (d_crm = m_crm)
WHERE e_ecg_id = ?
ORDER BY d_data_hora_diagnostico DESC
LIMIT 1");
$stmt->bindValue(1, $ecgId);
$stmt->execute();

$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
$diagnosticoEcg = array();
foreach ($result as $field) {
$diagnosticoEcg['diagnostico_id'] = $field['d_diagnostico_id'];
$diagnosticoEcg['ecg_id'] = $field['d_ecg_id'];
$diagnosticoEcg['crm'] = $field['d_crm'];
$diagnosticoEcg['descricao'] = $field['d_descricao'];
$diagnosticoEcg['data_hora_diagnostico'] = $field['d_data_hora_diagnostico'];
$diagnosticoEcg['nome'] = $field['m_nome'];
}

} catch(PDOException $e) {
print "Erro: " . $e->getMessage();
}

return $diagnosticoEcg;
}

}

Expand Down

0 comments on commit b1e7c99

Please sign in to comment.