diff --git a/src/PagesMedico/DoctorRelatorioManager.jsx b/src/PagesMedico/DoctorRelatorioManager.jsx index 334de6b6..ce246021 100644 --- a/src/PagesMedico/DoctorRelatorioManager.jsx +++ b/src/PagesMedico/DoctorRelatorioManager.jsx @@ -3,16 +3,20 @@ import { Link } from 'react-router-dom'; import {useState, useEffect} from 'react' import { useAuth } from '../components/utils/AuthProvider'; import { GetPatientByID } from '../components/utils/Functions-Endpoints/Patient'; +import { useNavigate } from 'react-router-dom'; +import html2pdf from 'html2pdf.js'; const DoctorRelatorioManager = () => { + const navigate = useNavigate() const {getAuthorizationHeader} = useAuth(); let authHeader = getAuthorizationHeader() const [RelatoriosFiltrados, setRelatorios] = useState([]) const [PacientesComRelatorios, setPacientesComRelatorios] = useState([]) + const [showModal, setShowModal] = useState(false) + const [index, setIndex] = useState() useEffect( () => { - let pacientesDosRelatorios =[] - - + let pacientesDosRelatorios = [] + const ListarPacientes = async () => { for (let i = 0; i < RelatoriosFiltrados.length; i++) { let relatorio = RelatoriosFiltrados[i]; @@ -50,10 +54,78 @@ fetch("https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/reports?patient_id&statu .catch(error => console.log('error', error)); }, []) - + const BaixarPDFdoRelatorio = (nome_paciente) => { + const elemento = document.getElementById("folhaA4"); // tua div do relatório + const opt = { + margin: 0, + filename: `relatorio_${nome_paciente || "paciente"}.pdf`, + html2canvas: { scale: 2 }, + jsPDF: { unit: "mm", format: "a4", orientation: "portrait" }, + }; + + html2pdf().set(opt).from(elemento).save(); + } return (
+ {showModal && ( +
+
+
+
+
Relatório de {PacientesComRelatorios[index]?.full_name}
+ +
+
+
+ +
+

Clinica Rise up

+

Dr - CRM/SP 123456

+

Avenida - (79) 9 4444-4444

+
+ +
+

Paciente: {PacientesComRelatorios[index]?.full_name}

+

Data de nascimento: {PacientesComRelatorios[index]?.birth_date}

+ +

Data do exame: {}

+ +

Exame: {RelatoriosFiltrados[index]?.exam}

+ +

Diagnostico: {RelatoriosFiltrados[index]?.diagnosis}

+

Conclusão: {RelatoriosFiltrados[index]?.conclusion}

+
+ +
+

Dr {RelatoriosFiltrados[index]?.required_by}

+

Emitido em: 0

+
+ +
+
+
+ + + + +
+
+
+
+ )} + +

Lista de Relatórios

@@ -103,39 +175,59 @@ fetch("https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/reports?patient_id&statu - + + - {RelatoriosFiltrados.length > 0 ? ( RelatoriosFiltrados.map((relatorio, index) => ( - + - + diff --git a/src/PagesMedico/EditPageRelatorio.jsx b/src/PagesMedico/EditPageRelatorio.jsx new file mode 100644 index 00000000..831d8ad0 --- /dev/null +++ b/src/PagesMedico/EditPageRelatorio.jsx @@ -0,0 +1,65 @@ +import React, { useEffect, useState } from 'react' +import FormRelatorio from '../components/FormRelatorio' +import { useParams } from 'react-router-dom' +import API_KEY from '../components/utils/apiKeys' +import { useAuth } from '../components/utils/AuthProvider' +const EditPageRelatorio = () => { + const params = useParams() + const {getAuthorizationHeader} = useAuth() + let authHeader = getAuthorizationHeader() + const [DictInfo, setDictInfo] = useState({}) + + let RelatorioID = params.id + + const handleSave = (RelatorioInfos) => { + var myHeaders = new Headers(); + myHeaders.append("apikey", API_KEY); + myHeaders.append("Authorization", authHeader); + myHeaders.append("Content-Type", "application/json"); + + const raw = JSON.stringify({...RelatorioInfos, order_number:'REL-2025-4386'}) + + console.log(RelatorioInfos) + + var requestOptions = { + method: 'PATCH', + headers: myHeaders, + body: raw, + redirect: 'follow' + +}; + + fetch(`https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/reports?id=eq.${RelatorioID}`, requestOptions) + .then(response => response.text()) + .then(result => console.log(result)) + .catch(error => console.log('error', error)); + + } + + useEffect(() => { + var myHeaders = new Headers(); + myHeaders.append("apikey", API_KEY); + myHeaders.append("Authorization", authHeader); + + var requestOptions = { + method: 'GET', + headers: myHeaders, + redirect: 'follow' + }; + + fetch(`https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/reports?id=eq.${RelatorioID}`, requestOptions) + .then(response => response.json()) + .then(result => setDictInfo(result[0])) + .catch(error => console.log('error', error)); + }, []) + + console.log(RelatorioID) + + return ( +
+ +
+ ) +} + +export default EditPageRelatorio \ No newline at end of file diff --git a/src/PagesMedico/FormNovoRelatorio.jsx b/src/PagesMedico/FormNovoRelatorio.jsx index 29018f79..36917935 100644 --- a/src/PagesMedico/FormNovoRelatorio.jsx +++ b/src/PagesMedico/FormNovoRelatorio.jsx @@ -1,72 +1,24 @@ -import React from 'react' + import '../PagesMedico/styleMedico/FormNovoRelatorio.css' -import { useState } from 'react' -import { useNavigate } from 'react-router-dom' -import { useAuth } from '../components/utils/AuthProvider' -import { GetPatientByCPF } from '../components/utils/Functions-Endpoints/Patient' -import { FormatCPF } from '../components/utils/Formatar/Format' import API_KEY from '../components/utils/apiKeys' -import html2pdf from "html2pdf.js"; - - +import FormRelatorio from '../components/FormRelatorio' +import { useState } from 'react' +import { useAuth } from '../components/utils/AuthProvider' const FormNovoRelatorio = () => { - const {getAuthorizationHeader} = useAuth() - let authHeader = getAuthorizationHeader() - const navigate= useNavigate() - const [DictInfo, setDictInfo] = useState({}) - const [showModal, setShowModal] = useState(false) + const [DictInfo, setDictInfo] = useState({}) - const handleChange = (e) => { - const { name, value } = e.target; - console.log(name, value) + const {getAuthorizationHeader} = useAuth() + let authHeader = getAuthorizationHeader() - - if(name === 'paciente_cpf') { - const formattedCPF = FormatCPF(value); - setDictInfo((prev) => ({ ...prev, [name]: formattedCPF })); - - const fetchPatient = async () => { - const patientData = await GetPatientByCPF(formattedCPF, authHeader); - if (patientData) { - setDictInfo((prev) => ({ - ...prev, - paciente_cpf:value, - paciente_nome: patientData.full_name, - paciente_id: patientData.id - })); - } - - }; - if(formattedCPF.length === 14){ - fetchPatient(); - } - }else{ - setDictInfo((prev) => ({ ...prev, [name]: value })); - } - } - - const handleSubmit = (e) => { - e.preventDefault(); - console.log(DictInfo) - setShowModal(true) - - var myHeaders = new Headers(); + const handleSave = (data) => { + console.log("Relatório salvo:", data); + + var myHeaders = new Headers(); myHeaders.append("apikey", API_KEY); myHeaders.append("Authorization", authHeader); myHeaders.append("Content-Type", "application/json"); -var raw = JSON.stringify({ - "patient_id": DictInfo.paciente_id, - - "exam": DictInfo.exam, - "diagnosis": DictInfo.diagnosis, - "conclusion": DictInfo.conclusao, - "status": "draft", - "requested_by": DictInfo.requested_by, - - "hide_date": false, - "hide_signature": false, -}); +var raw = JSON.stringify({...data}); var requestOptions = { method: 'POST', @@ -79,130 +31,14 @@ fetch("https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/reports", requestOptions .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error)); - } + } - return ( -
- {showModal &&( -
-
-
-
-
Relatório criado com sucesso
- -
-
-

Você também pode baixa-lo agora em pdf

-
-
- - - -
-
-
-
- )} -

Criar novo relatório

- -
- -
-
- -
- - -
- -
- - -
- - -
- - -
- -
- - -
- - -
- - -
- + return ( +
+

Criar Novo Relatorio

+
- -
-
- - -
- -
- - -
-
- - - - -
- -

Modelo do relatório

-
- -
-

Clinica Rise up

-

Dr {DictInfo.requested_by} - CRM/SP 123456

-

Avenida - (79) 9 4444-4444

-
- -
-

Paciente: {DictInfo?.paciente_nome}

-

Data de nascimento:

- -

Data do exame: {DictInfo.data_exame}

- -

Exame: {DictInfo.exame}

- -

Diagnostico: {DictInfo.diagnostico}

- -

Conclusão: {DictInfo.conclusao}

- -
- -
-

Dr {DictInfo.requested_by}

-

Emitido em: 0

-
- -
- -
- ) + ) } export default FormNovoRelatorio \ No newline at end of file diff --git a/src/PagesMedico/styleMedico/FormNovoRelatorio.css b/src/PagesMedico/styleMedico/FormNovoRelatorio.css index 7d8a5ed9..a8fafa30 100644 --- a/src/PagesMedico/styleMedico/FormNovoRelatorio.css +++ b/src/PagesMedico/styleMedico/FormNovoRelatorio.css @@ -52,4 +52,4 @@ textarea{ .info-paciente{ font-weight: bold; -} \ No newline at end of file +} diff --git a/src/PagesMedico/styleMedico/geral.css b/src/PagesMedico/styleMedico/geral.css index 94918bd6..67785953 100644 --- a/src/PagesMedico/styleMedico/geral.css +++ b/src/PagesMedico/styleMedico/geral.css @@ -186,4 +186,26 @@ tbody tr:hover { td { padding: 12px; border-bottom: 1px solid var(--cor-borda); -} \ No newline at end of file +} + +.modal-tabela-relatorio{ + width: 70rem; +} + +.modal-dialog.modal-tabela-relatorio { + max-width: 900px; /* largura máxima da modal */ + width: 100%; /* ocupa até o limite */ + margin: 1.75rem auto; /* centraliza vertical e horizontalmente */ +} + +.modal-content { + height: auto; /* altura variável conforme o conteúdo */ + max-height: none; /* remove limite interno */ +} + +.modal-body { + max-height: 70vh; /* limite vertical — 80% da altura da tela */ + overflow-y: auto; /* ativa rolagem vertical */ + overflow-x: hidden; /* impede rolagem horizontal */ + padding: 20px; /* espaço interno mais agradável */ +} diff --git a/src/components/FormRelatorio.jsx b/src/components/FormRelatorio.jsx new file mode 100644 index 00000000..7c04a49c --- /dev/null +++ b/src/components/FormRelatorio.jsx @@ -0,0 +1,201 @@ +import React from 'react' +import '../PagesMedico/styleMedico/FormNovoRelatorio.css' +import { useState } from 'react' +import { useNavigate } from 'react-router-dom' +import { useAuth } from '../components/utils/AuthProvider' +import { GetPatientByCPF } from '../components/utils/Functions-Endpoints/Patient' +import { FormatCPF } from '../components/utils/Formatar/Format' +import html2pdf from 'html2pdf.js' + +const FormRelatorio = ({onSave, DictInfo, setDictInfo }) => { + const {getAuthorizationHeader} = useAuth() + let authHeader = getAuthorizationHeader() + const navigate= useNavigate() + + const [showModal, setShowModal] = useState(false) + + const BaixarPDFdoRelatorio = () => { + const elemento = document.getElementById("folhaA4"); // tua div do relatório + const opt = { + margin: 0, + filename: `relatorio_${DictInfo?.paciente_nome || "paciente"}.pdf`, + html2canvas: { scale: 2 }, + jsPDF: { unit: "mm", format: "a4", orientation: "portrait" }, + }; + + html2pdf().set(opt).from(elemento).save(); + } + + const handleChange = (e) => { + const { name, value } = e.target; + console.log(name, value) + if(name === 'paciente_cpf') { + const formattedCPF = FormatCPF(value); + setDictInfo((prev) => ({ ...prev, [name]: formattedCPF })); + + const fetchPatient = async () => { + const patientData = await GetPatientByCPF(formattedCPF, authHeader); + if (patientData) { + setDictInfo((prev) => ({ + ...prev, + paciente_cpf:value, + paciente_nome: patientData.full_name, + paciente_id: patientData.id + })); + } + + }; + if(formattedCPF.length === 14){ + fetchPatient(); + } + }else{ + setDictInfo((prev) => ({ ...prev, [name]: value })); + } + } + + const handleSubmit = (e) => { + e.preventDefault(); + console.log(DictInfo) + setShowModal(true) + + +onSave({ + "patient_id": DictInfo.paciente_id, + + "exam": DictInfo.exam, + "diagnosis": DictInfo.diagnosis, + "conclusion": DictInfo.conclusao, + "status": "draft", + "requested_by": DictInfo.requested_by, + + "hide_date": false, + "hide_signature": false, +}); + + } + + return ( +
+ {showModal &&( +
+
+
+
+
Relatório criado com sucesso
+ +
+
+

Você também pode baixa-lo agora em pdf

+
+
+ + + +
+
+
+
+ )} + + +
+ +
+
+ +
+ + +
+ +
+ + +
+ + +
+ + +
+ +
+ + +
+ + +
+ + +
+ +
+ +
+
+ + +
+ +
+ + +
+
+ + + + +
+ +

Modelo do relatório

+
+ +
+

Clinica Rise up

+

Dr {DictInfo.requested_by} - CRM/SP 123456

+

Avenida - (79) 9 4444-4444

+
+ +
+

Paciente: {DictInfo?.paciente_nome}

+

Data de nascimento:

+ +

Data do exame: {DictInfo.data_exam}

+ +

Exame: {DictInfo.exam}

+ +

Diagnostico: {DictInfo.diagnostico}

+ +

Conclusão: {DictInfo.conclusao}

+ +
+ +
+

Dr {DictInfo.requested_by}

+

Emitido em: 0

+
+ +
+ +
+ ) +} + +export default FormRelatorio \ No newline at end of file diff --git a/src/perfis/Perfil_medico/PerfilMedico.jsx b/src/perfis/Perfil_medico/PerfilMedico.jsx index f34b0b7f..b1b95462 100644 --- a/src/perfis/Perfil_medico/PerfilMedico.jsx +++ b/src/perfis/Perfil_medico/PerfilMedico.jsx @@ -8,6 +8,7 @@ import Agendamento from "../../PagesMedico/Agendamento"; import Chat from "../../PagesMedico/Chat"; import DoctorItems from "../../data/sidebar-items-medico.json"; import FormNovoRelatorio from "../../PagesMedico/FormNovoRelatorio"; +import EditPageRelatorio from "../../PagesMedico/EditPageRelatorio"; // ...existing code... function PerfilMedico() { @@ -19,6 +20,7 @@ function PerfilMedico() { } /> } /> + } /> } /> } /> } />
Paciente CPF ExameAções
{relatorio.order_number}{PacientesComRelatorios[index]?.full_name} {PacientesComRelatorios[index]?.cpf} {relatorio.exam}{relatorio.create_at} -
- +