Akira-Kurusu commited on
Commit
f48831d
·
verified ·
1 Parent(s): 2175ae8

Update web/diagnosis.html

Browse files
Files changed (1) hide show
  1. web/diagnosis.html +108 -2
web/diagnosis.html CHANGED
@@ -465,6 +465,32 @@
465
  </main>
466
  </div>
467
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
468
  <script src="js/jquery.min.js"></script>
469
  <script src="js/popper.min.js"></script>
470
  <script src="js/moment.min.js"></script>
@@ -504,6 +530,40 @@
504
 
505
  updateLastUpdate();
506
  setInterval(updateLastUpdate, 60000);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
507
  }
508
 
509
  // AUTENTICACION
@@ -1026,13 +1086,18 @@
1026
  .html('<i class="fe fe-save fe-16 mr-2"></i>Guardar Consulta');
1027
 
1028
  if (response && response.success) {
1029
- showAlert('success', 'Consulta guardada correctamente');
1030
  console.log('Consulta guardada exitosamente:', response);
 
1031
  } else {
1032
  const errorMsg = response?.message || 'Error al guardar la consulta';
1033
- showAlert('error', errorMsg);
1034
  console.error('Error guardando consulta:', response);
 
1035
  }
 
 
 
 
 
1036
  });
1037
  }
1038
 
@@ -1247,6 +1312,47 @@ if (false) { /* removed */ }
1247
  }, 5000);
1248
  }
1249
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1250
  // === FUNCIONES GLOBALES ===
1251
  window.downloadGradCAMImage = function(zoneNumber) {
1252
  if (!window.currentGradCAMData) {
 
465
  </main>
466
  </div>
467
 
468
+ <!-- Modal de Confirmación de Consulta -->
469
+ <div class="modal fade" id="consultationResultModal" tabindex="-1" role="dialog" aria-labelledby="consultationResultModalLabel" aria-hidden="true">
470
+ <div class="modal-dialog modal-dialog-centered" role="document">
471
+ <div class="modal-content" style="border-radius: 12px; overflow: hidden;">
472
+ <div class="modal-header" id="consultationResultHeader">
473
+ <h5 class="modal-title" id="consultationResultModalLabel">
474
+ <i id="consultationResultIcon" class="fe mr-2"></i>
475
+ <span id="consultationResultTitle"></span>
476
+ </h5>
477
+ <button type="button" class="close" data-dismiss="modal" aria-label="Close">
478
+ <span aria-hidden="true">&times;</span>
479
+ </button>
480
+ </div>
481
+ <div class="modal-body text-center py-4">
482
+ <div id="consultationResultBody"></div>
483
+ </div>
484
+ <div class="modal-footer justify-content-center">
485
+ <button type="button" class="btn" id="consultationResultCloseBtn" data-dismiss="modal">Cerrar</button>
486
+ <a href="historial-consultas.html" class="btn btn-outline-primary" id="consultationResultViewBtn" style="display:none;">
487
+ <i class="fe fe-list fe-16 mr-1"></i>Ver Historial
488
+ </a>
489
+ </div>
490
+ </div>
491
+ </div>
492
+ </div>
493
+
494
  <script src="js/jquery.min.js"></script>
495
  <script src="js/popper.min.js"></script>
496
  <script src="js/moment.min.js"></script>
 
530
 
531
  updateLastUpdate();
532
  setInterval(updateLastUpdate, 60000);
533
+
534
+ // Autocompletar paciente si viene desde patients.html
535
+ const urlParams = new URLSearchParams(window.location.search);
536
+ const patientIdFromUrl = urlParams.get('patient');
537
+ if (patientIdFromUrl) {
538
+ autoSelectPatientById(parseInt(patientIdFromUrl));
539
+ }
540
+ }
541
+
542
+ // AUTOSELECCIONAR PACIENTE POR ID (desde URL)
543
+ function autoSelectPatientById(patientId) {
544
+ api.getPatient(patientId).then(function(response) {
545
+ if (response && response.success && response.patient) {
546
+ const patient = response.patient;
547
+ selectedPatient = patient;
548
+
549
+ const age = patient.birthDate ? (moment ? moment().diff(moment(patient.birthDate), 'years') : 'N/A') : 'N/A';
550
+ $('#patientSearch').val(patient.name);
551
+ $('#selectedPatientInfo').show();
552
+ $('#patientName').text(patient.name);
553
+ $('#patientDetails').html(`
554
+ <strong>ID:</strong> ${patient.patientID} |
555
+ <strong>Edad:</strong> ${age} años
556
+ ${patient.diabetesType ? '| <strong>Diabetes:</strong> ' + patient.diabetesType : ''}
557
+ `);
558
+ $('#selectedPatientId').val(patient.patientID);
559
+ enableSaveButton();
560
+ console.log('Paciente autoseleccionado:', patient.name);
561
+ } else {
562
+ console.warn('No se pudo cargar el paciente con ID:', patientId);
563
+ }
564
+ }).catch(function(err) {
565
+ console.error('Error cargando paciente por ID:', err);
566
+ });
567
  }
568
 
569
  // AUTENTICACION
 
1086
  .html('<i class="fe fe-save fe-16 mr-2"></i>Guardar Consulta');
1087
 
1088
  if (response && response.success) {
 
1089
  console.log('Consulta guardada exitosamente:', response);
1090
+ showConsultationResultModal(true, selectedPatient.name);
1091
  } else {
1092
  const errorMsg = response?.message || 'Error al guardar la consulta';
 
1093
  console.error('Error guardando consulta:', response);
1094
+ showConsultationResultModal(false, null, errorMsg);
1095
  }
1096
+ }).catch(function(err) {
1097
+ $('#saveConsultationBtn').prop('disabled', false)
1098
+ .html('<i class="fe fe-save fe-16 mr-2"></i>Guardar Consulta');
1099
+ console.error('Error de red al guardar consulta:', err);
1100
+ showConsultationResultModal(false, null, 'No se pudo conectar con el servidor. Intenta nuevamente.');
1101
  });
1102
  }
1103
 
 
1312
  }, 5000);
1313
  }
1314
 
1315
+ function showConsultationResultModal(success, patientName, errorMessage) {
1316
+ const header = $('#consultationResultHeader');
1317
+ const icon = $('#consultationResultIcon');
1318
+ const title = $('#consultationResultTitle');
1319
+ const body = $('#consultationResultBody');
1320
+ const closeBtn = $('#consultationResultCloseBtn');
1321
+ const viewBtn = $('#consultationResultViewBtn');
1322
+
1323
+ if (success) {
1324
+ header.removeClass('bg-danger text-white').addClass('bg-success text-white');
1325
+ icon.removeClass().addClass('fe fe-check-circle mr-2');
1326
+ title.text('Consulta Guardada Exitosamente');
1327
+ body.html(`
1328
+ <div style="font-size: 4rem; color: #28a745; margin-bottom: 1rem;">
1329
+ <i class="fe fe-check-circle"></i>
1330
+ </div>
1331
+ <h5 class="text-success mb-2">¡Consulta registrada!</h5>
1332
+ <p class="text-muted mb-0">
1333
+ La consulta del paciente <strong>${patientName}</strong> fue guardada correctamente en el sistema.
1334
+ </p>
1335
+ `);
1336
+ closeBtn.removeClass('btn-danger').addClass('btn-success').text('Continuar');
1337
+ viewBtn.show();
1338
+ } else {
1339
+ header.removeClass('bg-success text-white').addClass('bg-danger text-white');
1340
+ icon.removeClass().addClass('fe fe-x-circle mr-2');
1341
+ title.text('No se pudo guardar la consulta');
1342
+ body.html(`
1343
+ <div style="font-size: 4rem; color: #dc3545; margin-bottom: 1rem;">
1344
+ <i class="fe fe-x-circle"></i>
1345
+ </div>
1346
+ <h5 class="text-danger mb-2">Error al guardar</h5>
1347
+ <p class="text-muted mb-0">${errorMessage || 'Ocurrió un error inesperado. Por favor intenta nuevamente.'}</p>
1348
+ `);
1349
+ closeBtn.removeClass('btn-success').addClass('btn-danger').text('Cerrar');
1350
+ viewBtn.hide();
1351
+ }
1352
+
1353
+ $('#consultationResultModal').modal('show');
1354
+ }
1355
+
1356
  // === FUNCIONES GLOBALES ===
1357
  window.downloadGradCAMImage = function(zoneNumber) {
1358
  if (!window.currentGradCAMData) {