123 lines
4.2 KiB
HTML

<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8" />
<title>Novo 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/novo-laudo.css">
</head>
<body>
<h1>Novo 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>
<button onclick="insertCampo('[[NOME]]')">Nome</button>
<button onclick="insertCampo('[[IDADE]]')">Idade</button>
<button onclick="insertCampo('[[CID]]')">CID</button>
</div>
<div id="laudo-conteudo" contenteditable="true"></div>
<div class="opcoes">
<label>Paciente: <input type="text" id="paciente" placeholder="Nome do paciente"></label>
<label>Solicitante: <input type="text" id="solicitante" placeholder="Médico solicitante"></label>
<label>Exame:
<select id="exame">
<optgroup label="Sangue">
<option>Hemograma completo</option>
<option>Glicemia de jejum</option>
<option>Colesterol e triglicerídeos</option>
<option>Ureia e creatinina</option>
<option>TGO/AST</option>
<option>TGP/ALT</option>
<option>TSH</option>
<option>T4 livre</option>
<option>Dosagem hormonal</option>
</optgroup>
<optgroup label="Urina">
<option>Exame de urina tipo 1</option>
<option>Urocultura</option>
<option>Exame de urina de 24 horas</option>
</optgroup>
</select>
</label>
<label>Data do exame:
<input type="date" id="prazo">
</label>
<label>Hora:
<select id="hora"></select>
</label>
<label>Assinatura digital: <input type="checkbox" id="assinatura"></label><br>
<button class="btn-salvar" onclick="salvarLaudo() , window.location.href='Laudo.html' ">Salvar</button>
<button class="btn-cancelar" onclick="window.location.href='laudo.html'">Cancelar</button>
</div>
<script>
function execCmd(command) { document.execCommand(command, false, null); }
function insertCampo(texto) {
const selection = window.getSelection();
if (!selection.rangeCount) return;
const range = selection.getRangeAt(0);
range.deleteContents();
range.insertNode(document.createTextNode(texto));
}
// Preencher horas 08:00 a 22:00
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 salvarLaudo() {
const conteudo = document.getElementById("laudo-conteudo").innerHTML;
const paciente = document.getElementById("paciente").value;
const solicitante = document.getElementById("solicitante").value;
const exame = document.getElementById("exame").value;
const prazo = document.getElementById("prazo").value;
const hora = document.getElementById("hora").value;
if (!paciente || !solicitante || !prazo) { alert("Preencha paciente, solicitante e prazo!"); return; }
const laudos = JSON.parse(localStorage.getItem("laudos")) || [];
const novoLaudo = {
id: Date.now().toString(),
pedido: "PED" + Math.floor(Math.random()*10000),
data: new Date().toISOString().split("T")[0],
prazo,
hora,
paciente,
solicitante,
exame,
status: "Dentro do prazo",
conteudo,
assinatura: document.getElementById("assinatura").checked
};
laudos.push(novoLaudo);
localStorage.setItem("laudos", JSON.stringify(laudos));
alert("Laudo salvo com sucesso!");
window.location.href = "laudo.html";
}
window.onload = () => { preencherHoras(); };
</script>
</body>
</html>