MelissaPaciente Fase 1: foundation (5 composables + skeleton 7 tabs + slug paciente)
Inicio do port do PatientProntuario.vue (3593L Dialog) pra Melissa nativo. Plano em 8 fases — esta entrega cobre apenas a Fase 1 (foundation). PatientProntuario continua intocado nos 4 callsites (TherapistDashboard, MelissaAgenda, MelissaPacientes, PatientsListPage); migration acontece nas fases 2-8. 5 COMPOSABLES NOVOS em src/features/patients/composables/ - usePatientDetail.js (108L): patients + groups + tags - usePatientSessions.js (83L): agenda_eventos + computeds proxima/ultima/totais - usePatientFinancial.js (82L): financial_records + computeds totalRecebido/Aberto/Atrasado - usePatientMessages.js (64L): conversation_messages + computeds recentes/totalIn/Out - usePatientDocuments.js (70L): documents + computeds total/Bytes/tiposCount Cada composable encapsula a query original do PatientProntuario.vue + adiciona computeds derivados. Reutilizaveis em outros lugares no futuro (dashboards, relatorios, etc). MELISSAPACIENTE.VUE NOVO (1190L) em src/layout/melissa/ - Prefixo CSS .mpa-*. Chrome glass + drawer mobile + right: max(...) >=1024px (mesmo padrao MelissaAgendador/Negocio). - Header: avatar + nome + ageLabel + pronomes + Tag status/convenio + risco-elevado pill + actions (Conversar / Editar / Close). - Subheader condicional: banner risco elevado. - Body 2-col: sidebar 320px (esquerda, drawer no mobile) + main flex 1. - Sidebar com 4 cards: Acoes Rapidas / Navegacao 7 tabs / Sub-nav Perfil / Vinculos (chips grupos+tags). - Main: 7 tabs (Visao Geral / Perfil / Prontuario / Agenda / Financeiro / Documentos / Conversas). Visao Geral ja mostra 4 KPIs reais via composables. Outras 6 abas com placeholders "Em desenvolvimento — Fase X". MELISSALAYOUT.VUE - Import MelissaPaciente. - SECOES.paciente entry novo. - 'paciente' adicionado ao MELISSA_NON_CONFIG_SLUGS. - Render condicional com :patient-id="String(route.query.id || '')" — navegacao via /melissa/paciente?id=xxx. ESLint: 0 errors da mudanca. 2 errors pre-existentes em MelissaLayout (duplicate key 'financeiro' L242, empty block L1130) — nao toquei essas linhas. PatientProntuario tem outros pre-existentes nao tocados. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Agência PSI
|
||||
|--------------------------------------------------------------------------
|
||||
| Arquivo: src/features/patients/composables/usePatientSessions.js
|
||||
|
|
||||
| Carrega sessoes (agenda_eventos) do paciente. Limit 100 mais recentes
|
||||
| ordenadas desc por inicio_em. Compativel com a logica original do
|
||||
| PatientProntuario.vue.
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
import { ref, computed } from 'vue';
|
||||
import { supabase } from '@/lib/supabase/client';
|
||||
|
||||
export function usePatientSessions() {
|
||||
const sessions = ref([]);
|
||||
const loading = ref(false);
|
||||
const error = ref('');
|
||||
|
||||
async function load(patientId) {
|
||||
if (!patientId) {
|
||||
sessions.value = [];
|
||||
return;
|
||||
}
|
||||
loading.value = true;
|
||||
error.value = '';
|
||||
sessions.value = [];
|
||||
try {
|
||||
const { data, error: err } = await supabase
|
||||
.from('agenda_eventos')
|
||||
.select('id, inicio_em, fim_em, status, modalidade, tipo, titulo, titulo_custom, observacoes')
|
||||
.eq('patient_id', patientId)
|
||||
.order('inicio_em', { ascending: false })
|
||||
.limit(100);
|
||||
if (err) throw err;
|
||||
sessions.value = data || [];
|
||||
} catch (e) {
|
||||
error.value = e?.message || 'Falha ao carregar sessões.';
|
||||
sessions.value = [];
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Helpers derivados — proxima sessao agendada e status corrente
|
||||
const proximaSessao = computed(() => {
|
||||
const now = Date.now();
|
||||
return [...sessions.value]
|
||||
.filter((s) => s.inicio_em && new Date(s.inicio_em).getTime() >= now)
|
||||
.sort((a, b) => new Date(a.inicio_em) - new Date(b.inicio_em))[0] || null;
|
||||
});
|
||||
|
||||
const ultimaSessao = computed(() => {
|
||||
const now = Date.now();
|
||||
return sessions.value
|
||||
.filter((s) => s.inicio_em && new Date(s.inicio_em).getTime() < now)
|
||||
.sort((a, b) => new Date(b.inicio_em) - new Date(a.inicio_em))[0] || null;
|
||||
});
|
||||
|
||||
const totalSessoes = computed(() => sessions.value.length);
|
||||
const totalRealizadas = computed(() =>
|
||||
sessions.value.filter((s) => s.status === 'realizada' || s.status === 'presente').length
|
||||
);
|
||||
const totalFaltas = computed(() =>
|
||||
sessions.value.filter((s) => s.status === 'falta').length
|
||||
);
|
||||
const totalCanceladas = computed(() =>
|
||||
sessions.value.filter((s) => s.status === 'cancelada' || s.status === 'cancelado').length
|
||||
);
|
||||
|
||||
return {
|
||||
sessions,
|
||||
loading,
|
||||
error,
|
||||
load,
|
||||
proximaSessao,
|
||||
ultimaSessao,
|
||||
totalSessoes,
|
||||
totalRealizadas,
|
||||
totalFaltas,
|
||||
totalCanceladas
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user