Akira-Kurusu commited on
Commit
034df8d
·
verified ·
1 Parent(s): 4b66255

Update web/historial-consultas.html

Browse files
Files changed (1) hide show
  1. web/historial-consultas.html +56 -21
web/historial-consultas.html CHANGED
@@ -600,14 +600,33 @@
600
  console.log(`Viendo detalles de consulta: ${consultationId}`);
601
  currentConsultationId = consultationId;
602
 
603
- api.getConsultations(1, 100).then(function(response) {
604
- const consultation = (response.consultations || []).find(c => c.consultationID === consultationId);
605
- if (consultation) {
606
- renderConsultationModal(consultation, []);
607
- $('#consultationModal').modal('show');
 
 
 
 
 
 
 
608
  } else {
609
- showAlert('error', 'Consulta no encontrada');
 
 
 
 
 
610
  }
 
 
 
 
 
 
 
611
  });
612
  }
613
 
@@ -621,9 +640,9 @@
621
  new Date(consultation.consultationDate).toLocaleString('es-ES') : 'N/A';
622
 
623
  const confidence = consultation.confidence ?
624
- `${consultation.confidence.toFixed(1)}%` : 'N/A';
625
 
626
- // Calcular edad si hay fecha de nacimiento
627
  let age = 'N/A';
628
  if (consultation.birthDate) {
629
  try {
@@ -635,11 +654,13 @@
635
  age--;
636
  }
637
  age += ' años';
638
- } catch (e) {
639
- age = 'N/A';
640
- }
641
  }
642
 
 
 
 
 
643
  // Factores de riesgo
644
  let riskFactorsHtml = '';
645
  if (riskFactors && riskFactors.length > 0) {
@@ -647,9 +668,14 @@
647
  `<span class="badge badge-secondary mr-1 mb-1">${rf.name}</span>`
648
  ).join('');
649
  } else {
650
- riskFactorsHtml = '<span class="text-muted">No se han registrado factores de riesgo</span>';
651
  }
652
 
 
 
 
 
 
653
  const modalContent = `
654
  <div class="row">
655
  <div class="col-md-6">
@@ -659,7 +685,7 @@
659
  <table class="table table-sm">
660
  <tr>
661
  <td><strong>Nombre:</strong></td>
662
- <td>${consultation.patientName || consultation.patient_name || 'N/A'}</td>
663
  </tr>
664
  <tr>
665
  <td><strong>Edad:</strong></td>
@@ -667,7 +693,7 @@
667
  </tr>
668
  <tr>
669
  <td><strong>Género:</strong></td>
670
- <td>${consultation.gender || 'N/A'}</td>
671
  </tr>
672
  <tr>
673
  <td><strong>Tipo Diabetes:</strong></td>
@@ -693,16 +719,16 @@
693
  <td>${confidence}</td>
694
  </tr>
695
  <tr>
696
- <td><strong>Imagen:</strong></td>
697
- <td>${consultation.imagePath || 'N/A'}</td>
698
  </tr>
699
  </table>
700
  </div>
701
  </div>
702
 
703
- <div class="row mt-4">
704
  <div class="col-12">
705
- <div class="alert ${resultClass} d-flex align-items-center">
706
  <i class="fe ${resultIcon} fe-24 mr-3"></i>
707
  <div>
708
  <h6 class="mb-1">${resultText}</h6>
@@ -712,15 +738,24 @@
712
  </div>
713
  </div>
714
 
 
 
 
 
 
 
 
 
 
715
  ${consultation.notes ? `
716
- <div class="row">
717
  <div class="col-12">
718
  <h6 class="mb-2">
719
  <i class="fe fe-edit-2 mr-2"></i>Notas de la Consulta
720
  </h6>
721
  <div class="card bg-light">
722
- <div class="card-body">
723
- <p class="mb-0">${consultation.notes}</p>
724
  </div>
725
  </div>
726
  </div>
 
600
  console.log(`Viendo detalles de consulta: ${consultationId}`);
601
  currentConsultationId = consultationId;
602
 
603
+ // Mostrar loading en el modal mientras carga
604
+ $('#consultationModalBody').html(`
605
+ <div class="text-center py-4">
606
+ <div class="spinner-border text-primary" role="status"></div>
607
+ <p class="text-muted mt-2">Cargando detalles...</p>
608
+ </div>
609
+ `);
610
+ $('#consultationModal').modal('show');
611
+
612
+ api.getConsultation(consultationId).then(function(response) {
613
+ if (response && response.success) {
614
+ renderConsultationModal(response.consultation, response.consultation.riskFactors || []);
615
  } else {
616
+ $('#consultationModalBody').html(`
617
+ <div class="alert alert-danger">
618
+ <i class="fe fe-alert-circle mr-2"></i>
619
+ ${response?.message || 'No se pudo cargar la consulta.'}
620
+ </div>
621
+ `);
622
  }
623
+ }).catch(function() {
624
+ $('#consultationModalBody').html(`
625
+ <div class="alert alert-danger">
626
+ <i class="fe fe-alert-circle mr-2"></i>
627
+ Error de conexión al cargar la consulta.
628
+ </div>
629
+ `);
630
  });
631
  }
632
 
 
640
  new Date(consultation.consultationDate).toLocaleString('es-ES') : 'N/A';
641
 
642
  const confidence = consultation.confidence ?
643
+ `${parseFloat(consultation.confidence).toFixed(1)}%` : 'N/A';
644
 
645
+ // Calcular edad
646
  let age = 'N/A';
647
  if (consultation.birthDate) {
648
  try {
 
654
  age--;
655
  }
656
  age += ' años';
657
+ } catch (e) { age = 'N/A'; }
 
 
658
  }
659
 
660
+ // Género legible
661
+ const genderMap = { 'M': 'Masculino', 'F': 'Femenino' };
662
+ const genderText = genderMap[consultation.gender] || consultation.gender || 'N/A';
663
+
664
  // Factores de riesgo
665
  let riskFactorsHtml = '';
666
  if (riskFactors && riskFactors.length > 0) {
 
668
  `<span class="badge badge-secondary mr-1 mb-1">${rf.name}</span>`
669
  ).join('');
670
  } else {
671
+ riskFactorsHtml = '<span class="text-muted small">Sin factores de riesgo registrados</span>';
672
  }
673
 
674
+ // Badge del doctor que registró la consulta
675
+ const doctorBadge = consultation.doctorName
676
+ ? `<span class="badge badge-info ml-1">${consultation.doctorName}</span>`
677
+ : '';
678
+
679
  const modalContent = `
680
  <div class="row">
681
  <div class="col-md-6">
 
685
  <table class="table table-sm">
686
  <tr>
687
  <td><strong>Nombre:</strong></td>
688
+ <td>${consultation.patientName || 'N/A'}</td>
689
  </tr>
690
  <tr>
691
  <td><strong>Edad:</strong></td>
 
693
  </tr>
694
  <tr>
695
  <td><strong>Género:</strong></td>
696
+ <td>${genderText}</td>
697
  </tr>
698
  <tr>
699
  <td><strong>Tipo Diabetes:</strong></td>
 
719
  <td>${confidence}</td>
720
  </tr>
721
  <tr>
722
+ <td><strong>Doctor:</strong></td>
723
+ <td>${doctorBadge || 'N/A'}</td>
724
  </tr>
725
  </table>
726
  </div>
727
  </div>
728
 
729
+ <div class="row mt-3">
730
  <div class="col-12">
731
+ <div class="alert ${resultClass} d-flex align-items-center mb-0">
732
  <i class="fe ${resultIcon} fe-24 mr-3"></i>
733
  <div>
734
  <h6 class="mb-1">${resultText}</h6>
 
738
  </div>
739
  </div>
740
 
741
+ <div class="row mt-3">
742
+ <div class="col-12">
743
+ <h6 class="mb-2">
744
+ <i class="fe fe-shield mr-2"></i>Factores de Riesgo del Paciente
745
+ </h6>
746
+ <div>${riskFactorsHtml}</div>
747
+ </div>
748
+ </div>
749
+
750
  ${consultation.notes ? `
751
+ <div class="row mt-3">
752
  <div class="col-12">
753
  <h6 class="mb-2">
754
  <i class="fe fe-edit-2 mr-2"></i>Notas de la Consulta
755
  </h6>
756
  <div class="card bg-light">
757
+ <div class="card-body py-2">
758
+ <p class="mb-0 small">${consultation.notes}</p>
759
  </div>
760
  </div>
761
  </div>