Gestión de Pacientes – Psicoterapia

Sistema de Gestión de Pacientes

Herramienta para psicoterapeutas

Registro de Pacientes
Lista de Pacientes
Registro de Sesión
Informes

Registro de Nuevo Paciente

Lista de Pacientes

Registro de Sesión

Generación de Informes

d(‘patientForm’).addEventListener(‘submit’, savePatient); document.getElementById(‘editPatientForm’).addEventListener(‘submit’, updatePatient); document.getElementById(‘patientSelect’).addEventListener(‘change’, handlePatientSelection); document.getElementById(‘reportPatientSelect’).addEventListener(‘change’, handleReportPatientSelection); document.getElementById(‘reportType’).addEventListener(‘change’, handleReportTypeChange); document.getElementById(‘saveSession’).addEventListener(‘click’, saveSession); document.getElementById(‘resetSession’).addEventListener(‘click’, resetSessionForm); document.getElementById(‘generateReport’).addEventListener(‘click’, generateReport); // Cargar datos iniciales refreshPatientsList(); populatePatientDropdowns(); }); // Funciones de navegación por pestañas function openTab(tabName) { let i, tabContent, tabLinks; tabContent = document.getElementsByClassName(«tab-content»); for (i = 0; i < tabContent.length; i++) { tabContent[i].classList.remove("active"); } tabLinks = document.getElementsByClassName("tab"); for (i = 0; i < tabLinks.length; i++) { tabLinks[i].classList.remove("active"); } document.getElementById(tabName).classList.add("active"); event.currentTarget.classList.add("active"); } // Funciones para pacientes function savePatient(e) { e.preventDefault(); const id = Date.now().toString(); const patient = { id: id, nombre: document.getElementById('nombre').value, fechaNacimiento: document.getElementById('fechaNacimiento').value, genero: document.getElementById('genero').value, telefono: document.getElementById('telefono').value, email: document.getElementById('email').value, direccion: document.getElementById('direccion').value, contactoEmergencia: document.getElementById('contactoEmergencia').value, motivoConsulta: document.getElementById('motivoConsulta').value, diagnostico: document.getElementById('diagnostico').value, antecedentesMedicos: document.getElementById('antecedentesMedicos').value, antecedentesFamiliares: document.getElementById('antecedentesFamiliares').value, medicacionActual: document.getElementById('medicacionActual').value, habitosEstiloVida: document.getElementById('habitosEstiloVida').value, objetivosTerapeuticos: document.getElementById('objetivosTerapeuticos').value, fechaRegistro: new Date().toISOString().split('T')[0] }; patients.push(patient); localStorage.setItem('patients', JSON.stringify(patients)); document.getElementById('patientForm').reset(); showAlert('Paciente guardado correctamente', 'success'); refreshPatientsList(); populatePatientDropdowns(); } function refreshPatientsList() { const patientsList = document.getElementById('patientsList'); patientsList.innerHTML = ''; if (patients.length === 0) { patientsList.innerHTML = '

No hay pacientes registrados.

‘; return; } patients.forEach(patient => { const card = document.createElement(‘div’); card.className = ‘patient-card’; card.innerHTML = `

${patient.nombre}

Teléfono: ${patient.telefono}

Diagnóstico: ${patient.diagnostico || ‘No especificado’}

Fecha de registro: ${patient.fechaRegistro}

`; patientsList.appendChild(card); }); } function populatePatientDropdowns() { const patientSelect = document.getElementById(‘patientSelect’); const reportPatientSelect = document.getElementById(‘reportPatientSelect’); // Limpiar opciones existentes excepto la primera patientSelect.innerHTML = ‘‘; reportPatientSelect.innerHTML = ‘‘; // Añadir pacientes patients.forEach(patient => { const option = document.createElement(‘option’); option.value = patient.id; option.textContent = patient.nombre; patientSelect.appendChild(option.cloneNode(true)); reportPatientSelect.appendChild(option); }); } function viewPatient(patientId) { const patient = patients.find(p => p.id === patientId); if (!patient) return; const patientDetails = document.getElementById(‘patientDetails’); const patientSessions = document.getElementById(‘patientSessions’); // Mostrar detalles del paciente patientDetails.innerHTML = `

Nombre: ${patient.nombre}

Fecha de Nacimiento: ${patient.fechaNacimiento}

Género: ${patient.genero}

Teléfono: ${patient.telefono}

Email: ${patient.email || ‘No especificado’}

Dirección: ${patient.direccion || ‘No especificada’}

Contacto de Emergencia: ${patient.contactoEmergencia || ‘No especificado’}

Motivo de Consulta: ${patient.motivoConsulta}

Diagnóstico: ${patient.diagnostico || ‘No especificado’}

Antecedentes Médicos: ${patient.antecedentesMedicos || ‘No especificados’}

Antecedentes Familiares: ${patient.antecedentesFamiliares || ‘No especificados’}

Medicación Actual: ${patient.medicacionActual || ‘No especificada’}

Hábitos y Estilo de Vida: ${patient.habitosEstiloVida || ‘No especificados’}

Objetivos Terapéuticos: ${patient.objetivosTerapeuticos}

Fecha de Registro: ${patient.fechaRegistro}

`; // Mostrar sesiones del paciente const patientSessionsList = sessions.filter(s => s.patientId === patientId); if (patientSessionsList.length === 0) { patientSessions.innerHTML = ‘

No hay sesiones registradas para este paciente.

‘; } else { patientSessions.innerHTML = »; patientSessionsList.forEach(session => { const sessionItem = document.createElement(‘div’); sessionItem.className = ‘session-item’; sessionItem.innerHTML = `
Sesión ${session.sessionNumber} – ${session.date}

Objetivos: ${session.objectives}

Progreso: ${session.progress}

`; patientSessions.appendChild(sessionItem); }); } currentPatientId = patientId; document.getElementById(‘patientModal’).style.display = ‘block’; } function closePatientModal() { document.getElementById(‘patientModal’).style.display = ‘none’; currentPatientId = null; } function editPatient() { const patient = patients.find(p => p.id === currentPatientId); if (!patient) return; // Llenar el formulario de edición document.getElementById(‘editPatientId’).value = patient.id; document.getElementById(‘editNombre’).value = patient.nombre; document.getElementById(‘editFechaNacimiento’).value = patient.fechaNacimiento; document.getElementById(‘editGenero’).value = patient.genero; document.getElementById(‘editTelefono’).value = patient.telefono; document.getElementById(‘editEmail’).value = patient.email || »; document.getElementById(‘editDireccion’).value = patient.direccion || »; document.getElementById(‘editContactoEmergencia’).value = patient.contactoEmergencia || »; document.getElementById(‘editMotivoConsulta’).value = patient.motivoConsulta; document.getElementById(‘editDiagnostico’).value = patient.diagnostico || »; document.getElementById(‘editAntecedentesMedicos’).value = patient.antecedentesMedicos || »; document.getElementById(‘editAntecedentesFamiliares’).value = patient.antecedentesFamiliares || »; document.getElementById(‘editMedicacionActual’).value = patient.medicacionActual || »; document.getElementById(‘editHabitosEstiloVida’).value = patient.habitosEstiloVida || »; document.getElementByI