Compare commits
No commits in common. "a54b119e243ffad8eeb543300ae48f075baa9ea8" and "a502bbdffe574a14ee2e4d001cecd131ce215c4a" have entirely different histories.
a54b119e24
...
a502bbdffe
@ -1,7 +1,7 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import InputMask from "react-input-mask";
|
||||
|
||||
|
||||
function PatientForm({ onSave, onCancel,formData, setFormData }) {
|
||||
function PatientForm({ onSave, onCancel, PatientDict }) {
|
||||
|
||||
const FormatTelefones = (valor) => {
|
||||
const digits = String(valor).replace(/\D/g, '').slice(0, 11);
|
||||
@ -12,50 +12,6 @@ function PatientForm({ onSave, onCancel,formData, setFormData }) {
|
||||
.replace(/(\d{4})(\d{4})/, '$1-$2')
|
||||
}
|
||||
|
||||
const ReceberRespostaAPIdoCPF = async (cpf) =>{
|
||||
var myHeaders = new Headers();
|
||||
myHeaders.append("Authorization", "Bearer <token>");
|
||||
myHeaders.append("Content-Type", "application/json");
|
||||
|
||||
var raw = JSON.stringify({
|
||||
"cpf": cpf
|
||||
});
|
||||
|
||||
var requestOptions = {
|
||||
method: 'POST',
|
||||
headers: myHeaders,
|
||||
body: raw,
|
||||
redirect: 'follow'
|
||||
};
|
||||
|
||||
const response = await fetch("https://mock.apidog.com/m1/1053378-0-default/pacientes/validar-cpf", requestOptions)
|
||||
const result = await response.json()
|
||||
|
||||
return result.data
|
||||
|
||||
|
||||
}
|
||||
|
||||
const ValidarCPF = async (cpf) => {
|
||||
let aviso
|
||||
let Erro = false
|
||||
|
||||
const resutadoAPI = await ReceberRespostaAPIdoCPF(cpf)
|
||||
|
||||
const valido = resutadoAPI.valido
|
||||
const ExisteNoBancoDeDados = resutadoAPI.existe
|
||||
|
||||
if(valido === false){
|
||||
aviso = 'CPF inválido'
|
||||
Erro = true
|
||||
}
|
||||
else if(ExisteNoBancoDeDados === true){
|
||||
aviso = 'O CPF informado já está presente no sistema'
|
||||
Erro = true
|
||||
}
|
||||
return [Erro,aviso]
|
||||
}
|
||||
|
||||
const FormatCPF = (valor) => {
|
||||
const digits = String(valor).replace(/\D/g, '').slice(0, 11);
|
||||
return digits
|
||||
@ -64,6 +20,60 @@ function PatientForm({ onSave, onCancel,formData, setFormData }) {
|
||||
.replace(/(\d{3})(\d{1,2})$/, '$1-$2');
|
||||
}
|
||||
|
||||
const [formData, setFormData] = useState({
|
||||
foto: null,
|
||||
nome: PatientDict.nome,
|
||||
nomeSocial: PatientDict.nome_social,
|
||||
dataNascimento: PatientDict.data_nascimento,
|
||||
genero: PatientDict.sexo,
|
||||
cpf: PatientDict.cpf,
|
||||
profissao: PatientDict.profissao ,
|
||||
nomeMae: PatientDict.nome_mae,
|
||||
profissaoMae: PatientDict.profissao_mae,
|
||||
nomePai: PatientDict.nome_pai,
|
||||
nomeResponsavel: '',
|
||||
cpfResponsavel: '',
|
||||
nomeConjuge: '',
|
||||
outroId: '',
|
||||
cep: '',
|
||||
cidade: PatientDict.cidade,
|
||||
estado: PatientDict.estado,
|
||||
bairro: PatientDict.bairro,
|
||||
rua: PatientDict.logradouro,
|
||||
numero: '',
|
||||
complemento: '',
|
||||
email: PatientDict.email,
|
||||
telefone1: PatientDict.celular,
|
||||
telefone2: '',
|
||||
telefone3: '',
|
||||
observacoes: '',
|
||||
rg: '',
|
||||
documentoTipo: '',
|
||||
numeroDocumento: '',
|
||||
etniaRaca: '',
|
||||
naturalidade: '',
|
||||
nacionalidade: '',
|
||||
estadoCivil: '',
|
||||
rnConvenio: false,
|
||||
|
||||
// INFORMAÇÕES MÉDICAS
|
||||
tipoSanguineo: '',
|
||||
peso: '',
|
||||
altura: '',
|
||||
imc: '',
|
||||
alergias: '',
|
||||
|
||||
// INFORMAÇÕES DE CONVÊNIO
|
||||
convenio: '',
|
||||
plano: '',
|
||||
numeroMatricula: '',
|
||||
validadeCarteira: '',
|
||||
validadeIndeterminada: false,
|
||||
pacienteVip: false,
|
||||
|
||||
// ANEXO
|
||||
anexos: null,
|
||||
});
|
||||
|
||||
// Estado para armazenar a URL da foto do avatar
|
||||
const [avatarUrl, setAvatarUrl] = useState(null);
|
||||
@ -98,19 +108,9 @@ function PatientForm({ onSave, onCancel,formData, setFormData }) {
|
||||
}, [formData.peso, formData.altura]);
|
||||
|
||||
|
||||
const [enderecoData, setEnderecoData] = useState({})
|
||||
useEffect(() => {setEnderecoData(formData.endereco || {}); console.log(enderecoData)}, [formData.endereco])
|
||||
|
||||
const [contato, setContato] = useState({})
|
||||
|
||||
useEffect(() => {setContato(formData.contato || {})}, [formData.contato])
|
||||
|
||||
|
||||
const handleChange = (e) => {
|
||||
const { name, value, type, checked, files } = e.target;
|
||||
|
||||
console.log(enderecoData)
|
||||
|
||||
|
||||
if (type === 'checkbox') {
|
||||
setFormData({ ...formData, [name]: checked });
|
||||
} else if (type === 'file') {
|
||||
@ -125,24 +125,19 @@ function PatientForm({ onSave, onCancel,formData, setFormData }) {
|
||||
reader.readAsDataURL(files[0]);
|
||||
} else if (name === 'foto' && !files[0]) {
|
||||
setAvatarUrl(null); // Limpa o avatar se nenhum arquivo for selecionado
|
||||
}}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
setFormData({ ...formData, [name]: value });
|
||||
}
|
||||
|
||||
if (name.includes('cpf')) {
|
||||
let cpfFormatado = FormatCPF(value);
|
||||
setFormData(prev => ({ ...prev, [name]: cpfFormatado }));
|
||||
|
||||
} else if (name.includes('telefone')) {
|
||||
let telefoneFormatado = FormatTelefones(value);
|
||||
setContato(prev => ({ ...prev, [name]: telefoneFormatado }));
|
||||
setFormData(prev => ({ ...prev, [name]: telefoneFormatado }));
|
||||
}
|
||||
|
||||
if (name === 'email') {
|
||||
setContato(prev => ({ ...prev, email: value }));
|
||||
}else if(name.includes('endereco')) {
|
||||
setEnderecoData(prev => ({ ...prev, [name.split('.')[1]]: value }));
|
||||
}else{
|
||||
setFormData({ ...formData, [name]: value });}
|
||||
};
|
||||
|
||||
const handleCepBlur = async () => {
|
||||
@ -168,32 +163,28 @@ function PatientForm({ onSave, onCancel,formData, setFormData }) {
|
||||
}
|
||||
};
|
||||
|
||||
const handleSubmit = async () => {
|
||||
if (!formData.nome || !formData.cpf || !formData.sexo || !formData.data_nascimento){
|
||||
alert('Por favor, preencha Nome ,CPF, Gênero e data de nascimento.');
|
||||
const handleSubmit = () => {
|
||||
if (!formData.nome || !formData.cpf || !formData.genero || !formData.dataNascimento){
|
||||
alert('Por favor, preencha Nome ,CPF, Gênero e data de nascimento.');
|
||||
return;
|
||||
}
|
||||
const CPFinvalido = await ValidarCPF(formData.cpf)
|
||||
console.log(CPFinvalido)
|
||||
if(CPFinvalido[0] === true){
|
||||
alert(CPFinvalido[1])
|
||||
return}
|
||||
|
||||
onSave({
|
||||
...formData,
|
||||
endereco: {
|
||||
cep: enderecoData.cep,
|
||||
cidade: enderecoData.cidade,
|
||||
estado: enderecoData.estado,
|
||||
bairro: enderecoData.bairro,
|
||||
logradouro: enderecoData.logradouro,
|
||||
numero: enderecoData.numero,
|
||||
complemento: enderecoData.complemento,
|
||||
cep: formData.cep,
|
||||
cidade: formData.cidade,
|
||||
estado: formData.estado,
|
||||
bairro: formData.bairro,
|
||||
logradouro: formData.rua,
|
||||
numero: formData.numero,
|
||||
complemento: formData.complemento,
|
||||
},
|
||||
contato: {
|
||||
email: contato.email,
|
||||
telefone1: contato.telefone1,
|
||||
telefone2: contato.telefone2,
|
||||
telefone3: contato.telefone3,
|
||||
email: formData.email,
|
||||
telefone1: formData.telefone1,
|
||||
telefone2: formData.telefone2,
|
||||
telefone3: formData.telefone3,
|
||||
},
|
||||
infoMedicas: {
|
||||
tipoSanguineo: formData.tipoSanguineo,
|
||||
@ -274,15 +265,15 @@ function PatientForm({ onSave, onCancel,formData, setFormData }) {
|
||||
</div>
|
||||
<div className="col-md-6 mb-3">
|
||||
<label style={{ fontSize: '1.1rem' }}>Nome social:</label>
|
||||
<input type="text" className="form-control" name="nome_social" value={formData.nome_social} onChange={handleChange} style={{ fontSize: '1.1rem' }} />
|
||||
<input type="text" className="form-control" name="nomeSocial" value={formData.nomeSocial} onChange={handleChange} style={{ fontSize: '1.1rem' }} />
|
||||
</div>
|
||||
<div className="col-md-6 mb-3">
|
||||
<label style={{ fontSize: '1.1rem' }}>Data de nascimento: *</label>
|
||||
<input type="date" className="form-control" name="data_nascimento" value={formData.data_nascimento} onChange={handleChange} style={{ fontSize: '1.1rem' }} />
|
||||
<input type="date" className="form-control" name="dataNascimento" value={formData.dataNascimento} onChange={handleChange} style={{ fontSize: '1.1rem' }} />
|
||||
</div>
|
||||
<div className="col-md-6 mb-3">
|
||||
<label style={{ fontSize: '1.1rem' }}>Gênero: *</label>
|
||||
<select className="form-control" name="sexo" value={formData.sexo} onChange={handleChange} style={{ fontSize: '1.1rem' }}>
|
||||
<select className="form-control" name="genero" value={formData.genero} onChange={handleChange} style={{ fontSize: '1.1rem' }}>
|
||||
<option value="">Selecione</option>
|
||||
<option value="Masculino">Masculino</option>
|
||||
<option value="Feminino">Feminino</option>
|
||||
@ -303,12 +294,11 @@ function PatientForm({ onSave, onCancel,formData, setFormData }) {
|
||||
<option value="">Selecione</option>
|
||||
<option value="CNH">CNH</option>
|
||||
<option value="Passaporte">Passaporte</option>
|
||||
<option value="carteira de trabalho">Carteira de Trabalho</option>
|
||||
</select>
|
||||
</div>
|
||||
<div className="col-md-6 mb-3">
|
||||
<label style={{ fontSize: '1.1rem' }}>Número do documento:</label>
|
||||
<input type="text" className="form-control" name="numero_documento" value={formData.numero_documento} onChange={handleChange} style={{ fontSize: '1.1rem' }} />
|
||||
<input type="text" className="form-control" name="numeroDocumento" value={formData.numeroDocumento} onChange={handleChange} style={{ fontSize: '1.1rem' }} />
|
||||
</div>
|
||||
<div className="col-md-6 mb-3">
|
||||
<label style={{ fontSize: '1.1rem' }}>Etnia e Raça:</label>
|
||||
@ -335,7 +325,7 @@ function PatientForm({ onSave, onCancel,formData, setFormData }) {
|
||||
</div>
|
||||
<div className="col-md-6 mb-3">
|
||||
<label style={{ fontSize: '1.1rem' }}>Estado civil:</label>
|
||||
<select className="form-control" name="estado_civil" value={formData.estado_civil} onChange={handleChange} style={{ fontSize: '1.1rem' }}>
|
||||
<select className="form-control" name="estadoCivil" value={formData.estadoCivil} onChange={handleChange} style={{ fontSize: '1.1rem' }}>
|
||||
<option value="">Selecione</option>
|
||||
<option value="Solteiro">Solteiro(a)</option>
|
||||
<option value="Casado">Casado(a)</option>
|
||||
@ -345,31 +335,31 @@ function PatientForm({ onSave, onCancel,formData, setFormData }) {
|
||||
</div>
|
||||
<div className="col-md-6 mb-3">
|
||||
<label style={{ fontSize: '1.1rem' }}>Nome da Mãe:</label>
|
||||
<input type="text" className="form-control" name="nomeMae" value={formData.nome_mae} onChange={handleChange} style={{ fontSize: '1.1rem' }} />
|
||||
<input type="text" className="form-control" name="nomeMae" value={formData.nomeMae} onChange={handleChange} style={{ fontSize: '1.1rem' }} />
|
||||
</div>
|
||||
<div className="col-md-6 mb-3">
|
||||
<label style={{ fontSize: '1.1rem' }}>Profissão da mãe:</label>
|
||||
<input type="text" className="form-control" name="profissaoMae" value={formData.profissao_mae} onChange={handleChange} style={{ fontSize: '1.1rem' }} />
|
||||
<input type="text" className="form-control" name="profissaoMae" value={formData.profissaoMae} onChange={handleChange} style={{ fontSize: '1.1rem' }} />
|
||||
</div>
|
||||
<div className="col-md-6 mb-3">
|
||||
<label style={{ fontSize: '1.1rem' }}>Nome do Pai:</label>
|
||||
<input type="text" className="form-control" name="nomePai" value={formData.nome_pai} onChange={handleChange} style={{ fontSize: '1.1rem' }} />
|
||||
<input type="text" className="form-control" name="nomePai" value={formData.nomePai} onChange={handleChange} style={{ fontSize: '1.1rem' }} />
|
||||
</div>
|
||||
<div className="col-md-6 mb-3">
|
||||
<label style={{ fontSize: '1.1rem' }}>Profissão do pai:</label>
|
||||
<input type="text" className="form-control" name="profissaoPai" value={formData.profissao_pai} onChange={handleChange} style={{ fontSize: '1.1rem' }} />
|
||||
<input type="text" className="form-control" name="profissaoPai" value={formData.profissaoPai} onChange={handleChange} style={{ fontSize: '1.1rem' }} />
|
||||
</div>
|
||||
<div className="col-md-6 mb-3">
|
||||
<label style={{ fontSize: '1.1rem' }}>Nome do responsável:</label>
|
||||
<input type="text" className="form-control" name="nomeResponsavel" value={formData.nome_responsavel} onChange={handleChange} style={{ fontSize: '1.1rem' }} />
|
||||
<input type="text" className="form-control" name="nomeResponsavel" value={formData.nomeResponsavel} onChange={handleChange} style={{ fontSize: '1.1rem' }} />
|
||||
</div>
|
||||
<div className="col-md-6 mb-3">
|
||||
<label style={{ fontSize: '1.1rem' }}>CPF do responsável:</label>
|
||||
<input type="text" className="form-control" name="cpfResponsavel" value={formData.cpf_responsavel} onChange={handleChange} style={{ fontSize: '1.1rem' }} />
|
||||
<input type="text" className="form-control" name="cpfResponsavel" value={formData.cpfResponsavel} onChange={handleChange} style={{ fontSize: '1.1rem' }} />
|
||||
</div>
|
||||
<div className="col-md-6 mb-3">
|
||||
<label style={{ fontSize: '1.1rem' }}>Nome do esposo(a):</label>
|
||||
<input type="text" className="form-control" name="nomeConjuge" value={formData.nome_conjuge} onChange={handleChange} style={{ fontSize: '1.1rem' }} />
|
||||
<input type="text" className="form-control" name="nomeConjuge" value={formData.nomeConjuge} onChange={handleChange} style={{ fontSize: '1.1rem' }} />
|
||||
</div>
|
||||
<div className="col-md-6 mb-3">
|
||||
<label style={{ fontSize: '1.1rem' }}>Identificador de outro sistema:</label>
|
||||
@ -511,31 +501,31 @@ function PatientForm({ onSave, onCancel,formData, setFormData }) {
|
||||
<div className="row mt-3">
|
||||
<div className="col-md-4 mb-3">
|
||||
<label style={{ fontSize: '1.1rem' }}>CEP:</label>
|
||||
<input type="text" className="form-control" name="endereco.cep" value={enderecoData.cep} onChange={handleChange} onBlur={handleCepBlur} style={{ fontSize: '1.1rem' }} />
|
||||
<input type="text" className="form-control" name="cep" value={formData.cep} onChange={handleChange} onBlur={handleCepBlur} style={{ fontSize: '1.1rem' }} />
|
||||
</div>
|
||||
<div className="col-md-8 mb-3">
|
||||
<label style={{ fontSize: '1.1rem' }}>Rua:</label>
|
||||
<input type="text" className="form-control" name="endereco.logradouro" value={enderecoData.logradouro} onChange={handleChange} style={{ fontSize: '1.1rem' }} />
|
||||
<input type="text" className="form-control" name="rua" value={formData.rua} onChange={handleChange} style={{ fontSize: '1.1rem' }} />
|
||||
</div>
|
||||
<div className="col-md-6 mb-3">
|
||||
<label style={{ fontSize: '1.1rem' }}>Bairro:</label>
|
||||
<input type="text" className="form-control" name="endereco.bairro" value={enderecoData.bairro} onChange={handleChange} style={{ fontSize: '1.1rem' }} />
|
||||
<input type="text" className="form-control" name="bairro" value={formData.bairro} onChange={handleChange} style={{ fontSize: '1.1rem' }} />
|
||||
</div>
|
||||
<div className="col-md-4 mb-3">
|
||||
<label style={{ fontSize: '1.1rem' }}>Cidade:</label>
|
||||
<input type="text" className="form-control" name="endereco.cidade" value={enderecoData.cidade} onChange={handleChange} style={{ fontSize: '1.1rem' }} />
|
||||
<input type="text" className="form-control" name="cidade" value={formData.cidade} onChange={handleChange} style={{ fontSize: '1.1rem' }} />
|
||||
</div>
|
||||
<div className="col-md-2 mb-3">
|
||||
<label style={{ fontSize: '1.1rem' }}>Estado:</label>
|
||||
<input type="text" className="form-control" name="endereco.estado" value={enderecoData.estado} onChange={handleChange} style={{ fontSize: '1.1rem' }} />
|
||||
<input type="text" className="form-control" name="estado" value={formData.estado} onChange={handleChange} style={{ fontSize: '1.1rem' }} />
|
||||
</div>
|
||||
<div className="col-md-4 mb-3">
|
||||
<label style={{ fontSize: '1.1rem' }}>Número:</label>
|
||||
<input type="text" className="form-control" name="endereco.numero" value={enderecoData.numero} onChange={handleChange} style={{ fontSize: '1.1rem' }} />
|
||||
<input type="text" className="form-control" name="numero" value={formData.numero} onChange={handleChange} style={{ fontSize: '1.1rem' }} />
|
||||
</div>
|
||||
<div className="col-md-8 mb-3">
|
||||
<label style={{ fontSize: '1.1rem' }}>Complemento:</label>
|
||||
<input type="text" className="form-control" name="endereco.complemento" value={enderecoData.complemento} onChange={handleChange} style={{ fontSize: '1.1rem' }} />
|
||||
<input type="text" className="form-control" name="complemento" value={formData.complemento} onChange={handleChange} style={{ fontSize: '1.1rem' }} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -552,20 +542,20 @@ function PatientForm({ onSave, onCancel,formData, setFormData }) {
|
||||
<div className={`collapse${collapsedSections.contato ? ' show' : ''}`}>
|
||||
<div className="row mt-3">
|
||||
<div className="col-md-6 mb-3">
|
||||
<label style={{ fontSize: '1.1rem' }}>Email:</label>
|
||||
<input type="email" className="form-control" name="email" value={contato.email || ''} onChange={handleChange} style={{ fontSize: '1.1rem' }} />
|
||||
<label style={{ fontSize: '1.1rem' }}>Email: *</label>
|
||||
<input type="email" className="form-control" name="email" value={formData.email} onChange={handleChange} style={{ fontSize: '1.1rem' }} />
|
||||
</div>
|
||||
<div className="col-md-6 mb-3">
|
||||
<label style={{ fontSize: '1.1rem' }}>Telefone:</label>
|
||||
<input type="text" className="form-control" name="telefone1" value={contato.telefone1 || ''} onChange={handleChange} style={{ fontSize: '1.1rem' }} />
|
||||
<label style={{ fontSize: '1.1rem' }}>Telefone: *</label>
|
||||
<input type="text" className="form-control" name="telefone1" value={formData.telefone1} onChange={handleChange} style={{ fontSize: '1.1rem' }} />
|
||||
</div>
|
||||
<div className="col-md-6 mb-3">
|
||||
<label style={{ fontSize: '1.1rem' }}>Telefone 2:</label>
|
||||
<input type="text" className="form-control" name="telefone2" value={contato.telefone2 || ''} onChange={handleChange} style={{ fontSize: '1.1rem' }} />
|
||||
<input type="text" className="form-control" name="telefone2" value={formData.telefone2} onChange={handleChange} style={{ fontSize: '1.1rem' }} />
|
||||
</div>
|
||||
<div className="col-md-6 mb-3">
|
||||
<label style={{ fontSize: '1.1rem' }}>Telefone 3:</label>
|
||||
<input type="text" className="form-control" name="telefone3" value={contato.telefone3 || ''} onChange={handleChange} style={{ fontSize: '1.1rem' }} />
|
||||
<input type="text" className="form-control" name="telefone3" value={formData.telefone3} onChange={handleChange} style={{ fontSize: '1.1rem' }} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -2,40 +2,28 @@ import React, { useEffect, useState } from "react";
|
||||
import avatarPlaceholder from '../assets/images/avatar_placeholder.png';
|
||||
|
||||
const Details = ({ patientID, setCurrentPage }) => {
|
||||
const [paciente, setPaciente] = useState({});
|
||||
const [paciente, setPaciente] = useState(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (!patientID) return;
|
||||
|
||||
fetch(`https://mock.apidog.com/m1/1053378-0-default/pacientes/${patientID}`)
|
||||
.then(res => res.json())
|
||||
|
||||
.then(result => {setPaciente(result.data); console.log(result.data)})
|
||||
.then(data => setPaciente(data))
|
||||
.catch(err => console.error("Erro ao buscar paciente:", err));
|
||||
}, [patientID]);
|
||||
|
||||
|
||||
if (!paciente) return <p style={{ textAlign: "center" }}>Carregando...</p>;
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
<div>
|
||||
<button className="btn btn-success me-2" onClick={() => setCurrentPage("table")}>
|
||||
<i className="bi bi-chevron-left"></i> Voltar
|
||||
</button>
|
||||
|
||||
<button className="btn btn-light" onClick={() => setCurrentPage("edit-page-paciente")}>
|
||||
<i className="bi bi-pencil-square"></i> Editar
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<br/>
|
||||
{/* ------------------ HEADER ------------------ */}
|
||||
<div className="card p-3">
|
||||
<h3 className="mb-3 text-center">MediConnect</h3>
|
||||
<hr />
|
||||
<div className="d-flex justify-content-between align-items-center mb-3">
|
||||
|
||||
<button className="btn btn-success me-2" onClick={() => setCurrentPage("table")}>
|
||||
<i className="bi bi-chevron-left"></i> Voltar
|
||||
</button>
|
||||
<div className="d-flex mb-3">
|
||||
<div className="avatar avatar-lg">
|
||||
<img src={avatarPlaceholder} alt="" />
|
||||
@ -45,7 +33,9 @@ const Details = ({ patientID, setCurrentPage }) => {
|
||||
<p>{paciente.cpf || "CPF"}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button className="btn btn-light" onClick={() => setCurrentPage("edit-page-paciente")}>
|
||||
<i className="bi bi-pencil-square"></i> Editar
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -60,11 +50,11 @@ const Details = ({ patientID, setCurrentPage }) => {
|
||||
</div>
|
||||
<div className="col-md-6 mb-3">
|
||||
<label>Nome social:</label>
|
||||
<p>{paciente.nome_social || "-"}</p>
|
||||
<p>{paciente.nomeSocial || "-"}</p>
|
||||
</div>
|
||||
<div className="col-md-6 mb-3">
|
||||
<label>Data de nascimento:</label>
|
||||
<p>{paciente.data_nascimento || "-"}</p>
|
||||
<p>{paciente.dataNascimento || "-"}</p>
|
||||
</div>
|
||||
<div className="col-md-6 mb-3">
|
||||
<label>Gênero:</label>
|
||||
@ -72,11 +62,11 @@ const Details = ({ patientID, setCurrentPage }) => {
|
||||
</div>
|
||||
<div className="col-md-6 mb-3">
|
||||
<label>Outro documento:</label>
|
||||
<p>{paciente.outros_documentos?.tipo || "-"}</p>
|
||||
<p>{paciente.documento || "-"}</p>
|
||||
</div>
|
||||
<div className="col-md-6 mb-3">
|
||||
<label>Número do documento:</label>
|
||||
<p>{paciente.outros_documentos?.numero || "-"}</p>
|
||||
<p>{paciente.numeroDocumento || "-"}</p>
|
||||
</div>
|
||||
<div className="col-md-6 mb-3">
|
||||
<label>CPF:</label>
|
||||
@ -88,31 +78,31 @@ const Details = ({ patientID, setCurrentPage }) => {
|
||||
</div>
|
||||
<div className="col-md-6 mb-3">
|
||||
<label>Nome da Mãe:</label>
|
||||
<p>{paciente.nome_mae || "-"}</p>
|
||||
<p>{paciente.nomeMae || "-"}</p>
|
||||
</div>
|
||||
<div className="col-md-6 mb-3">
|
||||
<label>Profissão da mãe:</label>
|
||||
<p>{paciente.profissao_mae || "-"}</p>
|
||||
<p>{paciente.profissaoMae || "-"}</p>
|
||||
</div>
|
||||
<div className="col-md-6 mb-3">
|
||||
<label>Nome do Pai:</label>
|
||||
<p>{paciente.nome_pai || "-"}</p>
|
||||
<p>{paciente.nomePai || "-"}</p>
|
||||
</div>
|
||||
<div className="col-md-6 mb-3">
|
||||
<label>Profissão do pai:</label>
|
||||
<p>{paciente.profissao_pai || "-"}</p>
|
||||
<p>{paciente.profissaoPai || "-"}</p>
|
||||
</div>
|
||||
<div className="col-md-6 mb-3">
|
||||
<label>Nome do responsável:</label>
|
||||
<p>{paciente.nome_responsavel || "-"}</p>
|
||||
<p>{paciente.nomeResponsavel || "-"}</p>
|
||||
</div>
|
||||
<div className="col-md-6 mb-3">
|
||||
<label>CPF do responsável:</label>
|
||||
<p>{paciente.cpf_responsavel || "-"}</p>
|
||||
<p>{paciente.cpfResponsavel || "-"}</p>
|
||||
</div>
|
||||
<div className="col-md-6 mb-3">
|
||||
<label>Nome do esposo(a):</label>
|
||||
<p>{paciente.nome_conjuge || "-"}</p>
|
||||
<p>{paciente.nomeConjuge || "-"}</p>
|
||||
</div>
|
||||
<div className="col-md-6 mb-3">
|
||||
<label>Identificador de outro sistema:</label>
|
||||
@ -128,31 +118,31 @@ const Details = ({ patientID, setCurrentPage }) => {
|
||||
<div className="row">
|
||||
<div className="col-md-4 mb-3">
|
||||
<label>CEP:</label>
|
||||
<p>{paciente.endereco?.cep || "-"}</p>
|
||||
<p>{paciente.cep || "-"}</p>
|
||||
</div>
|
||||
<div className="col-md-8 mb-3">
|
||||
<label>Rua:</label>
|
||||
<p>{paciente.endereco?.logradouro || "-"}</p>
|
||||
<p>{paciente.rua || "-"}</p>
|
||||
</div>
|
||||
<div className="col-md-4 mb-3">
|
||||
<label>Bairro:</label>
|
||||
<p>{paciente.endereco?.bairro || "-"}</p>
|
||||
<p>{paciente.bairro || "-"}</p>
|
||||
</div>
|
||||
<div className="col-md-4 mb-3">
|
||||
<label>Cidade:</label>
|
||||
<p>{paciente.endereco?.cidade || "-"}</p>
|
||||
<p>{paciente.cidade || "-"}</p>
|
||||
</div>
|
||||
<div className="col-md-2 mb-3">
|
||||
<label>Estado:</label>
|
||||
<p>{paciente.endereco?.estado || "-"}</p>
|
||||
<p>{paciente.estado || "-"}</p>
|
||||
</div>
|
||||
<div className="col-md-4 mb-3">
|
||||
<label>Número:</label>
|
||||
<p>{paciente.endereco?.numero || "-"}</p>
|
||||
<p>{paciente.numero || "-"}</p>
|
||||
</div>
|
||||
<div className="col-md-8 mb-3">
|
||||
<label>Complemento:</label>
|
||||
<p>{paciente.endereco?.complemento || "-"}</p>
|
||||
<p>{paciente.complemento || "-"}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -164,19 +154,19 @@ const Details = ({ patientID, setCurrentPage }) => {
|
||||
<div className="row">
|
||||
<div className="col-md-6 mb-3">
|
||||
<label>Email:</label>
|
||||
<p>{paciente.contato?.email || "-"}</p>
|
||||
<p>{paciente.email || "-"}</p>
|
||||
</div>
|
||||
<div className="col-md-6 mb-3">
|
||||
<label>Telefone:</label>
|
||||
<p>{paciente.contato?.telefone1 || "-"}</p>
|
||||
<p>{paciente.telefone1 || "-"}</p>
|
||||
</div>
|
||||
<div className="col-md-6 mb-3">
|
||||
<label>Telefone 2:</label>
|
||||
<p>{paciente.contato?.telefone2 || "-"}</p>
|
||||
<p>{paciente.telefone2 || "-"}</p>
|
||||
</div>
|
||||
<div className="col-md-6 mb-3">
|
||||
<label>Telefone 3:</label>
|
||||
<p>{paciente.contato?.telefone3 || "-"}</p>
|
||||
<label>Celular:</label>
|
||||
<p>{paciente.telefone3 || "-"}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -19,32 +19,13 @@ useEffect(() => {
|
||||
fetch(`https://mock.apidog.com/m1/1053378-0-default/pacientes/${id}`, requestOptions)
|
||||
.then(response => response.json())
|
||||
.then(result => result.data)
|
||||
.then(data => setPatientPUT(data))
|
||||
.then(data => console.log(data))
|
||||
.catch(error => console.log('error', error));
|
||||
|
||||
}, [])
|
||||
const HandlePutPatient = () => {
|
||||
|
||||
const HandlePutPatient = () => {
|
||||
alert(`Atualizando paciente "${PatientToPUT.nome}" com sucesso`)
|
||||
var myHeaders = new Headers();
|
||||
myHeaders.append("Authorization", "Bearer <token>");
|
||||
myHeaders.append("Content-Type", "application/json");
|
||||
|
||||
var raw = JSON.stringify(PatientToPUT)
|
||||
|
||||
console.log(PatientToPUT)
|
||||
|
||||
var requestOptions = {
|
||||
method: 'PUT',
|
||||
headers: myHeaders,
|
||||
body: raw,
|
||||
redirect: 'follow'
|
||||
};
|
||||
|
||||
fetch("https://mock.apidog.com/m1/1053378-0-default/pacientes/", requestOptions)
|
||||
.then(response => response.text())
|
||||
.then(result => console.log('ATUALIZADO COM SUCESSO',result))
|
||||
.catch(error => console.log('error', error));
|
||||
console.log('paciente atualizado')
|
||||
|
||||
}
|
||||
|
||||
@ -60,9 +41,8 @@ fetch("https://mock.apidog.com/m1/1053378-0-default/pacientes/", requestOptions)
|
||||
<PatientForm
|
||||
onSave={HandlePutPatient}
|
||||
onCancel={console.log('Não atualizar')}
|
||||
|
||||
formData={PatientToPUT}
|
||||
setFormData={setPatientPUT}
|
||||
PatientDict={PatientToPUT}
|
||||
|
||||
/>
|
||||
|
||||
</div>
|
||||
|
||||
@ -8,7 +8,7 @@ function FormLayout( ) {
|
||||
// Este estado vai controlar qual "tela" mostrar: 'list' (lista) ou 'form' (formulário)
|
||||
const [view, setView] = useState('form');
|
||||
|
||||
const [formData, setFormData] = useState({})
|
||||
|
||||
var myHeaders = new Headers();
|
||||
myHeaders.append("Content-Type", "application/json");
|
||||
|
||||
@ -55,8 +55,8 @@ function FormLayout( ) {
|
||||
<PatientForm
|
||||
onSave={handleSavePatient}
|
||||
onCancel={() => setView('list')}
|
||||
formData={formData}
|
||||
setFormData={setFormData}
|
||||
PatientDict={{}}
|
||||
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@ -6,71 +6,8 @@ function TablePaciente({ setCurrentPage, setPatientID }) {
|
||||
const [pacientes, setPacientes] = useState([]);
|
||||
const [search, setSearch] = useState("");
|
||||
|
||||
|
||||
const GetAnexos = async (id) => {
|
||||
var myHeaders = new Headers();
|
||||
myHeaders.append("Authorization", "Bearer <token>");
|
||||
|
||||
var requestOptions = {
|
||||
method: 'GET',
|
||||
headers: myHeaders,
|
||||
redirect: 'follow'
|
||||
};
|
||||
try {
|
||||
const response = await fetch(`https://mock.apidog.com/m1/1053378-0-default/pacientes/${id}/anexos`, requestOptions);
|
||||
const result = await response.json();
|
||||
|
||||
return result.data; // agora retorna corretamente
|
||||
} catch (error) {
|
||||
console.log('error', error);
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
const DeleteAnexo = async (patientID) => {
|
||||
|
||||
|
||||
const RespostaGetAnexos = await GetAnexos(patientID)
|
||||
|
||||
for(let i = 0; i < RespostaGetAnexos.length; i++){
|
||||
|
||||
const idAnexo = RespostaGetAnexos[i].id;
|
||||
|
||||
console.log('anexos',RespostaGetAnexos)
|
||||
|
||||
|
||||
var myHeaders = new Headers();
|
||||
myHeaders.append("Authorization", "Bearer <token>");
|
||||
|
||||
var requestOptions = {
|
||||
method: 'DELETE',
|
||||
headers: myHeaders,
|
||||
redirect: 'follow'
|
||||
};
|
||||
|
||||
fetch(`https://mock.apidog.com/m1/1053378-0-default/pacientes/${patientID}/anexos/${idAnexo}`, requestOptions)
|
||||
.then(response => response.text())
|
||||
.then(result => console.log('anexo excluido com sucesso',result))
|
||||
.catch(error => console.log('error', error));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Função para excluir paciente
|
||||
const deletePatient = async (id) => {
|
||||
|
||||
DeleteAnexo(id)
|
||||
|
||||
|
||||
|
||||
|
||||
const requestOptionsDelete = { method: "DELETE", redirect: "follow" };
|
||||
|
||||
if (!window.confirm("Tem certeza que deseja excluir este paciente?")) return;
|
||||
@ -94,10 +31,16 @@ function TablePaciente({ setCurrentPage, setPatientID }) {
|
||||
if(value === 'editar'){
|
||||
setCurrentPage('edit-page-paciente')
|
||||
setPatientID(id);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (value === "excluir") {
|
||||
deletePatient(id);
|
||||
console.log(`Excluir ${id}`);
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user