const fs = require('fs'); let code = fs.readFileSync('src/sections/HistoriaClinica.tsx', 'utf8'); // Add states for new OtroLaboratorio const newStates = ` const [otrosDialog, setOtrosDialog] = useState(false); const [nuevaObsFecha, setNuevaObsFecha] = useState(getLocalToday()); const [nuevaObsTexto, setNuevaObsTexto] = useState(''); `; code = code.replace("const [otrosDialog, setOtrosDialog] = useState(false);", newStates); // Inside the portalNode or regular buttons, add "Otros" button. // But we already have the DropdownMenu. Let's just add the "Otros" button inside the `flex gap-2` where Importar is. const importBtnRegex = /\n `; code = code.replace(importBtnRegex, newBtns); // Also remove the "Ver Otros" from Dropdown if it is there code = code.replace(/ setOtrosDialog\(true\)\}>\s*\s*Ver Otros\s*<\/DropdownMenuItem>/g, ''); // Now we need to merge the logic for the dialog const renderOtrosDialogRegex = /[\s\S]*?<\/Dialog>/; const newDialog = ` Otros / Observaciones de Laboratorio
{canEdit && (

Agregar Nuevo Registro (Otros)

setNuevaObsFecha(e.target.value)} />