Fix internacion lookup, persistence and fallback patient resolution
This commit is contained in:
+44
-8
@@ -131,12 +131,30 @@ function AppContent() {
|
||||
/>
|
||||
);
|
||||
case 'historiaclinica': {
|
||||
const internacionId = store.currentInternacionId || '';
|
||||
const internacionId = store.currentInternacionId || sessionStorage.getItem('hospital_current_internacion_id') || '';
|
||||
const internacion = store.getInternacionById(internacionId);
|
||||
const paciente = internacion ? store.getPacienteById(internacion.pacienteId) : undefined;
|
||||
if (!internacion || !paciente) {
|
||||
const paciente = internacion
|
||||
? (store.getPacienteById(internacion.pacienteId) || store.pacientes.find(p => p.id === internacion.pacienteId || p.dni === internacion.pacienteId) || {
|
||||
id: internacion.pacienteId || 'paciente-unknown',
|
||||
apellido: 'Paciente',
|
||||
nombre: 'Sin registrar',
|
||||
dni: internacion.pacienteId || 'N/A',
|
||||
fechaNacimiento: '1990-01-01',
|
||||
sexo: 'Otro' as const,
|
||||
fechaRegistro: new Date().toISOString()
|
||||
})
|
||||
: undefined;
|
||||
|
||||
if (!internacion) {
|
||||
if (!store.isLoaded) {
|
||||
return (
|
||||
<div className="p-8 text-center text-gray-500">
|
||||
<p>Cargando información de la internación...</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<div className="p-4 text-center">
|
||||
<div className="p-4 text-center space-y-4">
|
||||
<p className="text-gray-500 dark:text-gray-400">Internación no encontrada (id: {internacionId})</p>
|
||||
<Button onClick={() => store.setVista('internaciones')}>Volver a Internaciones</Button>
|
||||
</div>
|
||||
@@ -215,12 +233,30 @@ function AppContent() {
|
||||
);
|
||||
|
||||
case 'editaringreso': {
|
||||
const internacionId = store.currentInternacionId || '';
|
||||
const internacionId = store.currentInternacionId || sessionStorage.getItem('hospital_current_internacion_id') || '';
|
||||
const internacion = store.getInternacionById(internacionId);
|
||||
const paciente = internacion ? store.getPacienteById(internacion.pacienteId) : undefined;
|
||||
if (!internacion || !paciente) {
|
||||
const paciente = internacion
|
||||
? (store.getPacienteById(internacion.pacienteId) || store.pacientes.find(p => p.id === internacion.pacienteId || p.dni === internacion.pacienteId) || {
|
||||
id: internacion.pacienteId || 'paciente-unknown',
|
||||
apellido: 'Paciente',
|
||||
nombre: 'Sin registrar',
|
||||
dni: internacion.pacienteId || 'N/A',
|
||||
fechaNacimiento: '1990-01-01',
|
||||
sexo: 'Otro' as const,
|
||||
fechaRegistro: new Date().toISOString()
|
||||
})
|
||||
: undefined;
|
||||
|
||||
if (!internacion) {
|
||||
if (!store.isLoaded) {
|
||||
return (
|
||||
<div className="p-8 text-center text-gray-500">
|
||||
<p>Cargando información de la internación...</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<div className="p-4 text-center">
|
||||
<div className="p-4 text-center space-y-4">
|
||||
<p className="text-gray-500 dark:text-gray-400">Internación no encontrada (id: {internacionId})</p>
|
||||
<Button onClick={() => store.setVista('internaciones')}>Volver a Internaciones</Button>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user