Fix: Cálculo automático de estado de laboratorio (Normal/Alto/Bajo)
This commit is contained in:
@@ -78,6 +78,38 @@ const PARAMETROS_COMUNES: Record<string, { unidad: string; referencia: string }>
|
|||||||
'RIN': { unidad: '', referencia: '0.8-1.2' },
|
'RIN': { unidad: '', referencia: '0.8-1.2' },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const RANGOS_LABORATORIO: Record<string, { min: number; max: number }> = {
|
||||||
|
'Hematocrito': { min: 36, max: 46 },
|
||||||
|
'Hemoglobina': { min: 12, max: 16 },
|
||||||
|
'Leucocitos': { min: 4.5, max: 11 },
|
||||||
|
'Plaquetas': { min: 150, max: 450 },
|
||||||
|
'Glucemia': { min: 70, max: 100 },
|
||||||
|
'Urea': { min: 17, max: 43 },
|
||||||
|
'Creatinina': { min: 0.7, max: 1.3 },
|
||||||
|
'Sodio': { min: 135, max: 145 },
|
||||||
|
'Potasio': { min: 3.5, max: 5.0 },
|
||||||
|
'Cloro': { min: 98, max: 106 },
|
||||||
|
'Bilirrubina Total': { min: 0.1, max: 1.2 },
|
||||||
|
'Bilirrubina Directa': { min: 0, max: 0.3 },
|
||||||
|
'GOT': { min: 10, max: 40 },
|
||||||
|
'GPT': { min: 10, max: 40 },
|
||||||
|
'Tiempo de Protrombina': { min: 12, max: 14 },
|
||||||
|
'KPTT': { min: 25, max: 35 },
|
||||||
|
'INR': { min: 0.8, max: 1.2 },
|
||||||
|
};
|
||||||
|
|
||||||
|
function calcularEstadoLaboratorio(parametro: string, valor: string): 'Normal' | 'Alto' | 'Bajo' {
|
||||||
|
const rango = RANGOS_LABORATORIO[parametro];
|
||||||
|
if (!rango) return 'Normal';
|
||||||
|
|
||||||
|
const num = parseFloat(valor);
|
||||||
|
if (isNaN(num)) return 'Normal';
|
||||||
|
|
||||||
|
if (num < rango.min) return 'Bajo';
|
||||||
|
if (num > rango.max) return 'Alto';
|
||||||
|
return 'Normal';
|
||||||
|
}
|
||||||
|
|
||||||
export function HistoriaClinica({
|
export function HistoriaClinica({
|
||||||
internacion,
|
internacion,
|
||||||
paciente,
|
paciente,
|
||||||
@@ -421,23 +453,23 @@ function SeccionLaboratorios({ lab, patientId, add, update, del }: {
|
|||||||
|
|
||||||
const buildResultados = (): ResultadoLaboratorio[] => {
|
const buildResultados = (): ResultadoLaboratorio[] => {
|
||||||
const res: ResultadoLaboratorio[] = [];
|
const res: ResultadoLaboratorio[] = [];
|
||||||
if (hto) res.push({ parametro: 'Hematocrito', valor: hto, unidad: '%', estado: 'Normal' });
|
if (hto) res.push({ parametro: 'Hematocrito', valor: hto, unidad: '%', estado: calcularEstadoLaboratorio('Hematocrito', hto) });
|
||||||
if (hb) res.push({ parametro: 'Hemoglobina', valor: hb, unidad: 'g/dL', estado: 'Normal' });
|
if (hb) res.push({ parametro: 'Hemoglobina', valor: hb, unidad: 'g/dL', estado: calcularEstadoLaboratorio('Hemoglobina', hb) });
|
||||||
if (gb) res.push({ parametro: 'Leucocitos', valor: gb, unidad: '/mm3', estado: 'Normal' });
|
if (gb) res.push({ parametro: 'Leucocitos', valor: gb, unidad: '/mm3', estado: calcularEstadoLaboratorio('Leucocitos', gb) });
|
||||||
if (plaq) res.push({ parametro: 'Plaquetas', valor: plaq, unidad: '/mm3', estado: 'Normal' });
|
if (plaq) res.push({ parametro: 'Plaquetas', valor: plaq, unidad: '/mm3', estado: calcularEstadoLaboratorio('Plaquetas', plaq) });
|
||||||
if (gluc) res.push({ parametro: 'Glucemia', valor: gluc, unidad: 'mg/dL', estado: 'Normal' });
|
if (gluc) res.push({ parametro: 'Glucemia', valor: gluc, unidad: 'mg/dL', estado: calcularEstadoLaboratorio('Glucemia', gluc) });
|
||||||
if (urea) res.push({ parametro: 'Urea', valor: urea, unidad: 'mg/dL', estado: 'Normal' });
|
if (urea) res.push({ parametro: 'Urea', valor: urea, unidad: 'mg/dL', estado: calcularEstadoLaboratorio('Urea', urea) });
|
||||||
if (creat) res.push({ parametro: 'Creatinina', valor: creat, unidad: 'mg/dL', estado: 'Normal' });
|
if (creat) res.push({ parametro: 'Creatinina', valor: creat, unidad: 'mg/dL', estado: calcularEstadoLaboratorio('Creatinina', creat) });
|
||||||
if (na) res.push({ parametro: 'Sodio', valor: na, unidad: 'mEq/L', estado: 'Normal' });
|
if (na) res.push({ parametro: 'Sodio', valor: na, unidad: 'mEq/L', estado: calcularEstadoLaboratorio('Sodio', na) });
|
||||||
if (k) res.push({ parametro: 'Potasio', valor: k, unidad: 'mEq/L', estado: 'Normal' });
|
if (k) res.push({ parametro: 'Potasio', valor: k, unidad: 'mEq/L', estado: calcularEstadoLaboratorio('Potasio', k) });
|
||||||
if (cl) res.push({ parametro: 'Cloro', valor: cl, unidad: 'mEq/L', estado: 'Normal' });
|
if (cl) res.push({ parametro: 'Cloro', valor: cl, unidad: 'mEq/L', estado: calcularEstadoLaboratorio('Cloro', cl) });
|
||||||
if (bt) res.push({ parametro: 'Bilirrubina Total', valor: bt, unidad: 'mg/dL', estado: 'Normal' });
|
if (bt) res.push({ parametro: 'Bilirrubina Total', valor: bt, unidad: 'mg/dL', estado: calcularEstadoLaboratorio('Bilirrubina Total', bt) });
|
||||||
if (bd) res.push({ parametro: 'Bilirrubina Directa', valor: bd, unidad: 'mg/dL', estado: 'Normal' });
|
if (bd) res.push({ parametro: 'Bilirrubina Directa', valor: bd, unidad: 'mg/dL', estado: calcularEstadoLaboratorio('Bilirrubina Directa', bd) });
|
||||||
if (got) res.push({ parametro: 'GOT', valor: got, unidad: 'U/L', estado: 'Normal' });
|
if (got) res.push({ parametro: 'GOT', valor: got, unidad: 'U/L', estado: calcularEstadoLaboratorio('GOT', got) });
|
||||||
if (gpt) res.push({ parametro: 'GPT', valor: gpt, unidad: 'U/L', estado: 'Normal' });
|
if (gpt) res.push({ parametro: 'GPT', valor: gpt, unidad: 'U/L', estado: calcularEstadoLaboratorio('GPT', gpt) });
|
||||||
if (tp) res.push({ parametro: 'Tiempo de Protrombina', valor: tp, unidad: 'seg', estado: 'Normal' });
|
if (tp) res.push({ parametro: 'Tiempo de Protrombina', valor: tp, unidad: 'seg', estado: calcularEstadoLaboratorio('Tiempo de Protrombina', tp) });
|
||||||
if (kptt) res.push({ parametro: 'KPTT', valor: kptt, unidad: 'seg', estado: 'Normal' });
|
if (kptt) res.push({ parametro: 'KPTT', valor: kptt, unidad: 'seg', estado: calcularEstadoLaboratorio('KPTT', kptt) });
|
||||||
if (rin) res.push({ parametro: 'INR', valor: rin, unidad: '', estado: 'Normal' });
|
if (rin) res.push({ parametro: 'INR', valor: rin, unidad: '', estado: calcularEstadoLaboratorio('INR', rin) });
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user