113 lines
4.1 KiB
HTML
113 lines
4.1 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="pt-BR">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<title>Editar Laudo</title>
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css" />
|
|
<link rel="stylesheet" href="../../assets/css/editar-laudo.css">
|
|
|
|
</head>
|
|
<body>
|
|
|
|
<h1>Editar Laudo</h1>
|
|
|
|
<div class="editor-toolbar">
|
|
<button onclick="execCmd('bold')"><i class="fa fa-bold"></i></button>
|
|
<button onclick="execCmd('italic')"><i class="fa fa-italic"></i></button>
|
|
<button onclick="execCmd('insertUnorderedList')"><i class="fa fa-list-ul"></i></button>
|
|
<button onclick="execCmd('justifyLeft')"><i class="fa fa-align-left"></i></button>
|
|
<button onclick="execCmd('justifyCenter')"><i class="fa fa-align-center"></i></button>
|
|
<button onclick="execCmd('justifyRight')"><i class="fa fa-align-right"></i></button>
|
|
</div>
|
|
|
|
<div id="laudo-conteudo" contenteditable="true"></div>
|
|
|
|
<div class="opcoes">
|
|
<label>Paciente: <input type="text" id="paciente"></label>
|
|
<label>Solicitante: <input type="text" id="solicitante"></label>
|
|
<label>Exame:
|
|
<select id="exame">
|
|
<option>Hemograma completo</option>
|
|
<option>Glicemia de jejum</option>
|
|
<option>Colesterol e triglicerídeos</option>
|
|
<option>Ureia e creatinina</option>
|
|
</select>
|
|
</label>
|
|
<label>Data do exame:
|
|
<input type="date" id="prazo" onchange="atualizarStatusPrazo()">
|
|
<span id="statusPrazo" class="status"></span>
|
|
</label>
|
|
<label>Hora:
|
|
<select id="hora"></select>
|
|
</label>
|
|
<label>Assinatura digital: <input type="checkbox" id="assinatura"></label><br>
|
|
|
|
<button class="btn-salvar" onclick="salvarEdicao() , window.location.href='Laudo.html'">Salvar Alterações</button>
|
|
<button class="btn-cancelar" onclick="window.location.href='Laudo.html'">Cancelar</button>
|
|
</div>
|
|
|
|
<script>
|
|
const params = new URLSearchParams(window.location.search);
|
|
const laudoId = params.get("id");
|
|
let laudos = JSON.parse(localStorage.getItem("laudos")) || [];
|
|
let laudo = laudos.find(l => l.id === laudoId);
|
|
|
|
if(!laudo) { alert("Laudo não encontrado!"); window.location.href = "Laudo.html"; }
|
|
|
|
document.getElementById("laudo-conteudo").innerHTML = laudo.conteudo;
|
|
document.getElementById("paciente").value = laudo.paciente;
|
|
document.getElementById("solicitante").value = laudo.solicitante;
|
|
document.getElementById("exame").value = laudo.exame;
|
|
document.getElementById("prazo").value = laudo.prazo;
|
|
document.getElementById("assinatura").checked = laudo.assinatura;
|
|
|
|
function execCmd(command){ document.execCommand(command, false, null); }
|
|
|
|
function preencherHoras() {
|
|
const selectHora = document.getElementById("hora");
|
|
selectHora.innerHTML = "";
|
|
for (let h=8; h<=22; h++){
|
|
["00","30"].forEach(min=>{
|
|
if(h===22 && min==="30") return;
|
|
const o = document.createElement("option");
|
|
o.value = `${String(h).padStart(2,"0")}:${min}`;
|
|
o.textContent = `${String(h).padStart(2,"0")}:${min}`;
|
|
selectHora.appendChild(o);
|
|
});
|
|
}
|
|
}
|
|
|
|
function atualizarStatusPrazo() {
|
|
const prazo = document.getElementById("prazo").value;
|
|
const statusEl = document.getElementById("statusPrazo");
|
|
if(!prazo){ statusEl.textContent="Sem prazo"; statusEl.className="status"; return; }
|
|
const hoje = new Date();
|
|
const dataPrazo = new Date(prazo+"T23:59:59");
|
|
if(dataPrazo>=hoje){ statusEl.textContent="Dentro do prazo"; statusEl.className="status ok"; }
|
|
else { statusEl.textContent="Vencido"; statusEl.className="status vencido"; }
|
|
}
|
|
|
|
function salvarEdicao(){
|
|
laudo.conteudo = document.getElementById("laudo-conteudo").innerHTML;
|
|
laudo.paciente = document.getElementById("paciente").value;
|
|
laudo.solicitante = document.getElementById("solicitante").value;
|
|
laudo.exame = document.getElementById("exame").value;
|
|
laudo.prazo = document.getElementById("prazo").value;
|
|
laudo.hora = document.getElementById("hora").value;
|
|
laudo.assinatura = document.getElementById("assinatura").checked;
|
|
|
|
localStorage.setItem("laudos", JSON.stringify(laudos));
|
|
alert("Laudo atualizado com sucesso!");
|
|
window.location.href="laudo.html";
|
|
}
|
|
|
|
window.onload = () => {
|
|
preencherHoras();
|
|
document.getElementById("hora").value = laudo.hora || "08:00";
|
|
atualizarStatusPrazo();
|
|
};
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|