Akira-Kurusu commited on
Commit
8086a4e
·
verified ·
1 Parent(s): 8dc7910

Update web/diagnosis.html

Browse files
Files changed (1) hide show
  1. web/diagnosis.html +37 -0
web/diagnosis.html CHANGED
@@ -569,6 +569,43 @@
569
  // Inicializar aplicacion
570
  initializeDiagnosisApp();
571
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
572
  // FUNCION DE INICIALIZACION
573
  function initializeDiagnosisApp() {
574
  console.log('Inicializando aplicacion de diagnostico...');
 
569
  // Inicializar aplicacion
570
  initializeDiagnosisApp();
571
 
572
+ // Auto-seleccionar paciente si viene por URL (?patient=ID)
573
+ async function autoSelectPatientFromURL() {
574
+ const params = new URLSearchParams(window.location.search);
575
+ const patientId = params.get('patient');
576
+ if (!patientId) return;
577
+
578
+ const response = await api.getPatient(parseInt(patientId)).catch(() => null);
579
+ if (!response || !response.success) return;
580
+
581
+ const patientData = response.patient;
582
+ selectedPatient = patientData;
583
+
584
+ $('#patientSearch').val(patientData.name);
585
+ $('#patientResults').hide();
586
+
587
+ const age = patientData.birthDate
588
+ ? (moment ? moment().diff(moment(patientData.birthDate), 'years') : 'N/A')
589
+ : 'N/A';
590
+
591
+ $('#selectedPatientInfo').show();
592
+ $('#patientName').text(patientData.name);
593
+ $('#patientDetails').html(`
594
+ <strong>ID:</strong> ${patientData.patientID} |
595
+ <strong>Edad:</strong> ${age} años
596
+ ${patientData.diabetesType ? `| <strong>Diabetes:</strong> ${patientData.diabetesType}` : ''}
597
+ `);
598
+ $('#selectedPatientId').val(patientData.patientID);
599
+
600
+ enableSaveButton();
601
+ showAlert('info', `Paciente ${patientData.name} asociado al diagnóstico`);
602
+ }
603
+
604
+ // Esperar a que jQuery esté listo antes de autoseleccionar
605
+ $(document).ready(function() {
606
+ autoSelectPatientFromURL();
607
+ });
608
+
609
  // FUNCION DE INICIALIZACION
610
  function initializeDiagnosisApp() {
611
  console.log('Inicializando aplicacion de diagnostico...');