Merge branch 'claude/youthful-mendel-0c569f'
This commit is contained in:
+52
-7
@@ -529,7 +529,7 @@ app.get('/api/dentistas', async (req, res) => {
|
||||
}
|
||||
query += ' ORDER BY ordem ASC, nome ASC';
|
||||
const { rows } = await pool.query(query, params);
|
||||
res.json(rows.map(d => ({ ...d, ativo: !!d.ativo })));
|
||||
res.json(rows.map(d => ({ ...d, ativo: !!d.ativo, corAgenda: d.coragenda })));
|
||||
} catch (err) { res.status(500).json({ error: err.message }); }
|
||||
});
|
||||
|
||||
@@ -666,7 +666,14 @@ app.get('/api/reports/productivity', async (req, res) => {
|
||||
app.get('/api/agendamentos', async (req, res) => {
|
||||
try {
|
||||
const { rows } = await pool.query('SELECT * FROM agendamentos');
|
||||
res.json(rows.map(r => ({ ...r, start: r.start_time, end: r.end_time })));
|
||||
res.json(rows.map(r => ({
|
||||
...r,
|
||||
dentistaId: r.dentistaid,
|
||||
pacienteNome: r.pacientenome,
|
||||
pacienteCelular: r.pacientecelular,
|
||||
start: r.start_time,
|
||||
end: r.end_time
|
||||
})));
|
||||
} catch (err) { res.status(500).json({ error: err.message }); }
|
||||
});
|
||||
|
||||
@@ -848,10 +855,19 @@ app.get('/api/procedimentos', async (req, res) => {
|
||||
|
||||
const data = procs.map(p => ({
|
||||
...p,
|
||||
valorParticular: parseFloat(p.valorParticular || 0),
|
||||
especialidadeId: p.especialidadeid,
|
||||
especialidadeNome: p.especialidadenome,
|
||||
valorParticular: parseFloat(p.valorparticular || 0),
|
||||
codigoInterno: p.codigointerno,
|
||||
valoresPlanos: valores
|
||||
.filter(v => v.procedimentoId === p.id)
|
||||
.map(v => ({ ...v, valor: parseFloat(v.valor || 0) }))
|
||||
.filter(v => v.procedimentoid === p.id)
|
||||
.map(v => ({
|
||||
...v,
|
||||
planoId: v.planoid,
|
||||
planoNome: v.planonome,
|
||||
codigoPlano: v.codigoplano,
|
||||
valor: parseFloat(v.valor || 0)
|
||||
}))
|
||||
}));
|
||||
res.json(data);
|
||||
} catch (err) { res.status(500).json({ error: err.message }); }
|
||||
@@ -1057,8 +1073,20 @@ app.get('/api/guias', async (req, res) => {
|
||||
const { rows } = await pool.query(query, [...params, limit, offset]);
|
||||
const { rows: totalRows } = await pool.query(countQuery, params);
|
||||
|
||||
const mapGuia = (g) => ({
|
||||
...g,
|
||||
numeroGuiaPrestador: g.numeroguiaprestador,
|
||||
numeroGuiaOperadora: g.numeroguiaoperadora,
|
||||
dataSolicitacao: g.datasolicitacao,
|
||||
tipoTratamento: g.tipotratamento,
|
||||
beneficiarioId: g.beneficiarioid,
|
||||
beneficiarioNome: g.beneficiarionome,
|
||||
beneficiarioIdentificacao: g.beneficiarioidentificacao,
|
||||
createdAt: g.createdat
|
||||
});
|
||||
|
||||
res.json({
|
||||
data: rows,
|
||||
data: rows.map(mapGuia),
|
||||
total: totalRows[0].total,
|
||||
page: parseInt(page),
|
||||
pageSize: limit
|
||||
@@ -1085,7 +1113,24 @@ app.get('/api/gto-builder/:id', async (req, res) => {
|
||||
try {
|
||||
const { rows: builder } = await pool.query('SELECT * FROM gto_builders WHERE id = $1', [req.params.id]);
|
||||
const { rows: items } = await pool.query('SELECT * FROM gto_items WHERE builderid = $1', [req.params.id]);
|
||||
res.json({ ...builder[0], items });
|
||||
const mappedItems = items.map(i => ({
|
||||
...i,
|
||||
builderId: i.builderid,
|
||||
procedimentoId: i.procedimentoid,
|
||||
codigoTUSS: i.codigotuss,
|
||||
codigoInterno: i.codigointerno,
|
||||
valorUnitario: parseFloat(i.valorunitario || 0),
|
||||
valorTotal: parseFloat(i.valortotal || 0),
|
||||
anexosCount: i.anexoscount
|
||||
}));
|
||||
const b = builder[0];
|
||||
res.json({
|
||||
...b,
|
||||
pacienteId: b?.pacienteid,
|
||||
dentistaId: b?.dentistaid,
|
||||
credenciadaId: b?.credenciadaid,
|
||||
items: mappedItems
|
||||
});
|
||||
} catch (err) { res.status(500).json({ error: err.message }); }
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user