MelissaPaciente Fase 8: wire-up final (Dialog -> route /melissa/paciente?id=X)
PLANO DE 8 FASES COMPLETO. Os 2 callsites Melissa do PatientProntuario.vue
legacy (3593L Dialog) trocam por navegacao pra MelissaPaciente nativo via
router.push. PatientProntuario continua intocado pros 2 callsites legacy
fora do Melissa (TherapistDashboard, PatientsListPage).
MELISSAPACIENTE.VUE — wire-up interno
- Imports: useRouter + useConversationDrawerStore
- close(): emit + router.push('/melissa/pacientes')
- editPatient(): emit + router.push('/melissa/pacientes', query: {edit: id})
pra MelissaPacientes auto-abrir o cadastroFullDialog
- openWhatsapp(): emit + conversationDrawerStore.openForPatient({id, name,
phone, avatar_url}) — drawer global desce sobre Melissa
- addFinancial(): emit + toast "Em breve" (Fase 9 — dialog inline)
MELISSAPACIENTES.VUE
- Removeu import PatientProntuario + refs prontuarioOpen/prontuarioPatient
- Removeu <PatientProntuario> template (substituido por comentario)
- abrirProntuario(p): router.push('/melissa/paciente', query: {id})
- onMounted detecta route.query.edit -> abre cadastroFullDialog +
router.replace pra limpar query (handshake com MelissaPaciente)
- Comentario header atualizado
MELISSAAGENDA.VUE
- Removeu import PatientProntuario + refs prontuarioOpen/prontuarioPatient
- Removeu <PatientProntuario> template
- abrirProntuarioPorId(id): router.push pra rota Melissa nativa
- abrirProntuarioPaciente / openProntuario / kebab "Prontuario" delegam
pra abrirProntuarioPorId
MELISSALAYOUT.VUE
- Render <MelissaPaciente> simplificado: so @close="fecharSecao".
Acoes edit/open-whatsapp/add-financial ficam internas.
ESLint: 0 errors da minha mudanca (9 pre-existentes nos arquivos tocados
sao baseline; confirmados via git stash — mesmos errors em ambos lados).
PLANO COMPLETO. Total de 8 commits no branch (Fases 1-8). MelissaPaciente.vue
~2400L + 5 composables (~407L) + utils ~280L. PatientProntuario.vue
intocado pra fallback legacy (TherapistDashboard, PatientsListPage).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -34,7 +34,6 @@ import MelissaAgendaSearchPopover from './MelissaAgendaSearchPopover.vue';
|
||||
import MelissaAgendaActionsPopover from './MelissaAgendaActionsPopover.vue';
|
||||
import PatientCadastroDialog from '@/components/ui/PatientCadastroDialog.vue';
|
||||
import ComponentCadastroRapido from '@/components/ComponentCadastroRapido.vue';
|
||||
import PatientProntuario from '@/features/patients/prontuario/PatientProntuario.vue';
|
||||
import { useConversationDrawerStore } from '@/stores/conversationDrawerStore';
|
||||
import { getSessionCounts } from '@/features/patients/services/patientsRepository';
|
||||
// `Menu` PrimeVue: NÃO importar explicitamente — projeto usa auto-import
|
||||
@@ -234,13 +233,9 @@ function pacienteRowDblclick(id) {
|
||||
abrirProntuarioPorId(id);
|
||||
}
|
||||
function abrirProntuarioPorId(id) {
|
||||
const p =
|
||||
props.pacientes.find((x) => x.id === id) ||
|
||||
pacientesAside.value.find((x) => x.id === id) ||
|
||||
null;
|
||||
if (!p) return;
|
||||
prontuarioPatient.value = { ...p };
|
||||
prontuarioOpen.value = true;
|
||||
if (!id) return;
|
||||
// Fase 8 wire-up: navega pra MelissaPaciente nativo.
|
||||
router.push({ path: '/melissa/paciente', query: { id: String(id) } });
|
||||
}
|
||||
|
||||
// ── Calendar (FullCalendar) ───────────────────────────────────
|
||||
@@ -992,8 +987,6 @@ function onPatientCreated() {
|
||||
// Pattern espelha PatientsListPage (goEdit/goConversation/openProntuario).
|
||||
// Aparece no .melissa-dock via Teleport quando há paciente selecionado.
|
||||
const conversationDrawerStore = useConversationDrawerStore();
|
||||
const prontuarioOpen = ref(false);
|
||||
const prontuarioPatient = ref(null);
|
||||
const sessionCountsMap = ref(new Map()); // id → count (cache)
|
||||
|
||||
// Cache pra patients carregados sob demanda — quando o pacienteSelecionadoId
|
||||
@@ -1169,9 +1162,8 @@ function abrirWhatsappPaciente() {
|
||||
}
|
||||
function abrirProntuarioPaciente() {
|
||||
const p = pacienteSelecionado.value;
|
||||
if (!p) return;
|
||||
prontuarioPatient.value = { ...p };
|
||||
prontuarioOpen.value = true;
|
||||
if (!p?.id) return;
|
||||
abrirProntuarioPorId(p.id);
|
||||
}
|
||||
// API pública pra MelissaLayout chamar via ref (botão "Editar paciente"
|
||||
// do MelissaEventoPanel). Abre o PatientCadastroDialog já no modo edição.
|
||||
@@ -1211,7 +1203,7 @@ const kebabItems = computed(() => {
|
||||
return [
|
||||
{ label: 'Sessões', icon: 'pi pi-history', command: () => { pacienteSelecionadoId.value = p.id; abrirSessoesPaciente(); } },
|
||||
{ label: 'WhatsApp', icon: 'pi pi-whatsapp', command: () => conversationDrawerStore.openForPatient(String(p.id)) },
|
||||
{ label: 'Prontuário', icon: 'pi pi-file', command: () => { prontuarioPatient.value = { ...p }; prontuarioOpen.value = true; } },
|
||||
{ label: 'Prontuário', icon: 'pi pi-file', command: () => abrirProntuarioPorId(p.id) },
|
||||
{ label: 'Editar', icon: 'pi pi-pencil', command: () => { editPatientId.value = String(p.id); cadastroFullDialog.value = true; } }
|
||||
];
|
||||
});
|
||||
@@ -1220,9 +1212,8 @@ const kebabItems = computed(() => {
|
||||
// MelissaEventoPanel emite ações que o parent precisa orquestrar com
|
||||
// a Agenda — aqui ficam os métodos invocáveis via ref.
|
||||
function openProntuario(patient) {
|
||||
if (!patient) return;
|
||||
prontuarioPatient.value = { ...patient };
|
||||
prontuarioOpen.value = true;
|
||||
if (!patient?.id) return;
|
||||
abrirProntuarioPorId(patient.id);
|
||||
}
|
||||
defineExpose({
|
||||
refetch: refetchEventosFc,
|
||||
@@ -1905,17 +1896,9 @@ defineExpose({
|
||||
<!-- Menu kebab (mobile) — abre via toggleKebab a partir de qualquer .ma-pat -->
|
||||
<Menu ref="kebabMenu" :model="kebabItems" popup append-to="body" />
|
||||
|
||||
<!-- Dialog Prontuário — reaproveita componente do PatientsListPage.
|
||||
:key força re-mount quando troca de paciente. Optional chain
|
||||
em prontuarioPatient pra blindar contra bloco-tree opt do Vue. -->
|
||||
<PatientProntuario
|
||||
v-if="prontuarioPatient"
|
||||
:key="prontuarioPatient?.id || 'none'"
|
||||
v-model="prontuarioOpen"
|
||||
:patient="prontuarioPatient"
|
||||
@close="prontuarioOpen = false"
|
||||
@edit="(id) => { prontuarioOpen = false; editPatientId = String(id); cadastroFullDialog = true; }"
|
||||
/>
|
||||
<!-- Prontuario migrado pra MelissaPaciente nativo (Fase 8 wire-up).
|
||||
abrirProntuarioPorId(id) navega pra /melissa/paciente?id=X. -->
|
||||
|
||||
</section>
|
||||
</template>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user