feat: update hospital management system and fix linter issues
This commit is contained in:
+14
-23
@@ -1,30 +1,21 @@
|
||||
const fs = require('fs');
|
||||
let code = fs.readFileSync('src/hooks/useHospitalStore.ts', 'utf8');
|
||||
|
||||
code = code.replace(
|
||||
/const nuevaCama: Cama = \{\s*\.\.\.cama,\s*id: generateUUID\(\),\s*\} as Cama;/,
|
||||
`const nuevaCama: Cama = {
|
||||
...cama,
|
||||
id: generateUUID(),
|
||||
sector: computeSector(cama.numero),
|
||||
} as Cama;`
|
||||
);
|
||||
code = code.replace(/getLaboratoriosByPaciente = useCallback\(\(pacienteId: string\)/g, 'getLaboratoriosByInternacion = useCallback((internacionId: string)');
|
||||
code = code.replace(/\.filter\(l => l\.pacienteId === pacienteId\)/g, '.filter(l => l.internacionId === internacionId)');
|
||||
|
||||
// We need to import computeSector if it's not imported.
|
||||
// It is in utils.ts, and we already import isCamaFueraDeGrupo.
|
||||
code = code.replace(
|
||||
/import \{ getNombreProfesional, isCamaFueraDeGrupo \} from '@\/lib\/utils';/,
|
||||
`import { getNombreProfesional, isCamaFueraDeGrupo, computeSector } from '@/lib/utils';`
|
||||
);
|
||||
code = code.replace(/getGlucemiasByPaciente = useCallback\(\(pacienteId: string\)/g, 'getGlucemiasByInternacion = useCallback((internacionId: string)');
|
||||
code = code.replace(/\.filter\(g => g\.pacienteId === pacienteId\)/g, '.filter(g => g.internacionId === internacionId)');
|
||||
|
||||
code = code.replace(
|
||||
/const actualizarCama = useCallback\(async \(id: string, datos: Partial<Cama>\) => \{\s*try \{\s*await apiCall\('PUT', `\/camas\/\$\{id\}`/,
|
||||
`const actualizarCama = useCallback(async (id: string, datos: Partial<Cama>) => {
|
||||
try {
|
||||
if (datos.numero !== undefined) {
|
||||
datos.sector = computeSector(datos.numero);
|
||||
}
|
||||
await apiCall('PUT', \`/camas/\${id}\``
|
||||
);
|
||||
code = code.replace(/getAcidosBaseByPaciente = useCallback\(\(pacienteId: string\)/g, 'getAcidosBaseByInternacion = useCallback((internacionId: string)');
|
||||
code = code.replace(/\.filter\(a => a\.pacienteId === pacienteId\)/g, '.filter(a => a.internacionId === internacionId)');
|
||||
|
||||
code = code.replace(/getCultivosByPaciente = useCallback\(\(pacienteId: string\)/g, 'getCultivosByInternacion = useCallback((internacionId: string)');
|
||||
code = code.replace(/\.filter\(c => c\.pacienteId === pacienteId\)/g, '.filter(c => c.internacionId === internacionId)');
|
||||
|
||||
code = code.replace(/getLaboratoriosByPaciente,/g, 'getLaboratoriosByInternacion,');
|
||||
code = code.replace(/getGlucemiasByPaciente,/g, 'getGlucemiasByInternacion,');
|
||||
code = code.replace(/getAcidosBaseByPaciente,/g, 'getAcidosBaseByInternacion,');
|
||||
code = code.replace(/getCultivosByPaciente,/g, 'getCultivosByInternacion,');
|
||||
|
||||
fs.writeFileSync('src/hooks/useHospitalStore.ts', code);
|
||||
|
||||
Reference in New Issue
Block a user