fix(protocols): fix yaml syntax formats and complete yaml-to-mongo script
This commit is contained in:
parent
5ba4a25182
commit
c242a93f6e
|
|
@ -17,6 +17,20 @@ async function migrate() {
|
||||||
await mongoose.connect(MONGODB_URI);
|
await mongoose.connect(MONGODB_URI);
|
||||||
console.log('✅ Conectado a MongoDB');
|
console.log('✅ Conectado a MongoDB');
|
||||||
|
|
||||||
|
function normalizeItems(items: any[] | undefined): string[] {
|
||||||
|
if (!items) return [];
|
||||||
|
return items.map(item => {
|
||||||
|
if (typeof item === 'string') return item;
|
||||||
|
if (typeof item === 'object' && item !== null) {
|
||||||
|
const entries = Object.entries(item);
|
||||||
|
if (entries.length > 0) {
|
||||||
|
const [key, value] = entries[0];
|
||||||
|
return `${key}: ${value}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return String(item);
|
||||||
|
});
|
||||||
|
}
|
||||||
const folders = fs.readdirSync(PROTOCOLS_DIR);
|
const folders = fs.readdirSync(PROTOCOLS_DIR);
|
||||||
let totalMigrated = 0;
|
let totalMigrated = 0;
|
||||||
|
|
||||||
|
|
@ -29,12 +43,33 @@ async function migrate() {
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
const filePath = path.join(folderPath, file);
|
const filePath = path.join(folderPath, file);
|
||||||
const content = fs.readFileSync(filePath, 'utf8');
|
const content = fs.readFileSync(filePath, 'utf8');
|
||||||
const data = yaml.load(content) as ClinicalProtocol;
|
const data = yaml.load(content) as any;
|
||||||
|
|
||||||
if (!data.id) {
|
if (!data.id) {
|
||||||
data.id = file.replace('.yaml', '');
|
data.id = file.replace('.yaml', '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Normalizar items en pasos
|
||||||
|
if (data.pasos) {
|
||||||
|
data.pasos = data.pasos.map((p: any) => ({
|
||||||
|
...p,
|
||||||
|
items: normalizeItems(p.items)
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Normalizar items en fases
|
||||||
|
if (data.fases) {
|
||||||
|
data.fases = data.fases.map((f: any) => ({
|
||||||
|
...f,
|
||||||
|
items: normalizeItems(f.items)
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Normalizar equipamiento
|
||||||
|
if (data.equipamiento) {
|
||||||
|
data.equipamiento = normalizeItems(data.equipamiento);
|
||||||
|
}
|
||||||
|
|
||||||
// Upsert
|
// Upsert
|
||||||
await ProtocolModel.findOneAndUpdate(
|
await ProtocolModel.findOneAndUpdate(
|
||||||
{ id: data.id },
|
{ id: data.id },
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,8 @@ pasos:
|
||||||
titulo: Valoración Clínica
|
titulo: Valoración Clínica
|
||||||
descripcion: Signos típicos de crisis.
|
descripcion: Signos típicos de crisis.
|
||||||
items:
|
items:
|
||||||
- Valorar triada: Polidipsia (mucha sed), Poliuria, Polifagia
|
- "Valorar triada: Polidipsia (mucha sed), Poliuria, Polifagia"
|
||||||
- Evaluar hidratación: Mucosas secas, signo del pliegue (+)
|
- "Evaluar hidratación: Mucosas secas, signo del pliegue (+)"
|
||||||
- Verificar nivel de consciencia (Glasgow)
|
- Verificar nivel de consciencia (Glasgow)
|
||||||
- Medir constantes vitales (TA, FC, Tª)
|
- Medir constantes vitales (TA, FC, Tª)
|
||||||
|
|
||||||
|
|
@ -45,11 +45,11 @@ pasos:
|
||||||
- Monitorización continua del ritmo cardíaco (Riesgo de arritmias por potasio)
|
- Monitorización continua del ritmo cardíaco (Riesgo de arritmias por potasio)
|
||||||
|
|
||||||
- tipo: info
|
- tipo: info
|
||||||
titulo: Identificación: CAD vs EHH
|
titulo: "Identificación: CAD vs EHH"
|
||||||
descripcion: Diferenciación rápida para el informe médico.
|
descripcion: Diferenciación rápida para el informe médico.
|
||||||
items:
|
items:
|
||||||
- Cetoacidosis (CAD): Más frecuente en DM1, inicio rápido, aliento cetósico y dolor abdominal.
|
- "Cetoacidosis (CAD): Más frecuente en DM1, inicio rápido, aliento cetósico y dolor abdominal."
|
||||||
- Estado Hiperosmolar (EHH): Más frecuente en DM2 (ancianos), inicio lento, deshidratación extrema y alteraciones neurológicas.
|
- "Estado Hiperosmolar (EHH): Más frecuente en DM2 (ancianos), inicio lento, deshidratación extrema y alteraciones neurológicas."
|
||||||
|
|
||||||
# ─── FÁRMACOS ──────────────────────────────────────────────────
|
# ─── FÁRMACOS ──────────────────────────────────────────────────
|
||||||
farmacos:
|
farmacos:
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,7 @@ alertas:
|
||||||
- tipo: danger
|
- tipo: danger
|
||||||
texto: "Mantener alineación espinal en pacientes traumáticos."
|
texto: "Mantener alineación espinal en pacientes traumáticos."
|
||||||
- tipo: warning
|
- tipo: warning
|
||||||
text
|
texto: "Usar técnicas ergonómicas para prevenir lesiones."
|
||||||
|
|
||||||
#警戒
|
|
||||||
texto: "Usar técnicasergonómicas para prevenir lesiones."
|
|
||||||
|
|
||||||
# ─── PRINCIPIOS ────────────────────────────────────────────────
|
# ─── PRINCIPIOS ────────────────────────────────────────────────
|
||||||
principios:
|
principios:
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ pasos:
|
||||||
descripcion: "Verificar respiración correcta a través de la cánula."
|
descripcion: "Verificar respiración correcta a través de la cánula."
|
||||||
|
|
||||||
# ─── TÉCNICA NASOFARINGEA ────────────────────────────────────
|
# ─── TÉCNICA NASOFARINGEA ────────────────────────────────────
|
||||||
pasos:
|
|
||||||
- tipo: tecnica
|
- tipo: tecnica
|
||||||
titulo: Preparación
|
titulo: Preparación
|
||||||
descripcion: "Lubricar cánula."
|
descripcion: "Lubricar cánula."
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ tecnicas:
|
||||||
- titulo: Presión indirecta
|
- titulo: Presión indirecta
|
||||||
prioridad: 3
|
prioridad: 3
|
||||||
descripcion: "Presionar arteria proximal."
|
descripcion: "Presionar arteria proximal."
|
||||||
- torniquete
|
- titulo: Torniquete
|
||||||
prioridad: 4
|
prioridad: 4
|
||||||
descripcion: "Último recurso para hemorragia masiva de extremidad."
|
descripcion: "Último recurso para hemorragia masiva de extremidad."
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ actualizado: 2025-12-23
|
||||||
# ─── ALERTAS GLOBALES ─────────────────────────────────────────
|
# ─── ALERTAS GLOBALES ─────────────────────────────────────────
|
||||||
alertas:
|
alertas:
|
||||||
- tipo: danger
|
- tipo: danger
|
||||||
texto: "¿Puede hablar?" - Es la pregunta diagnóstica clave.
|
texto: '"¿Puede hablar?" - Es la pregunta diagnóstica clave.'
|
||||||
- tipo: danger
|
- tipo: danger
|
||||||
texto: "Si puede hablar/toser bien: ANIMA A TOSER. Si no: ACTÚA."
|
texto: "Si puede hablar/toser bien: ANIMA A TOSER. Si no: ACTÚA."
|
||||||
- tipo: warning
|
- tipo: warning
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue