M2: patients — selects + repository + 8 composables refatorados
Modulo 2 da Fase 1 de padronizacao em batch unico. patientsSelects.js nova com 11 constantes de select. patientsRepository.js estendido com ~15 funcoes novas (markIntakeConverted, list/get/update por contexto, etc). 8 composables refatorados em paralelo (usePatients, useDetail, Financial, Sessions, Messages, Documents, Recurrences, SupportContacts) — zero supabase.from() em qualquer composable de patients. _lastPatientId movido pra DENTRO das functions nos 3 composables que tinham. CadastrosRecebidosPage + MelissaCadastros Recebidos pegam carona dos selects. Aguarda teste batch consolidado. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -17,6 +17,8 @@ import { useToast } from 'primevue/usetoast';
|
||||
import { useConfirm } from 'primevue/useconfirm';
|
||||
import { supabase } from '@/lib/supabase/client';
|
||||
import { useTenantStore } from '@/stores/tenantStore';
|
||||
// Fase 2 (Graphify hotspot): convertToPatient duplicado em 2 pages — extração pro repository.
|
||||
import { createPatient, markIntakeConverted } from '@/features/patients/services/patientsRepository';
|
||||
import { brToISO, isoToBR } from '@/utils/dateBR';
|
||||
// Dialog/Textarea/Button auto-imported via PrimeVueResolver
|
||||
|
||||
@@ -429,16 +431,12 @@ async function convertToPatient() {
|
||||
if (patientPayload[k] === undefined) delete patientPayload[k];
|
||||
});
|
||||
|
||||
const { data: created, error: insErr } = await supabase.from('patients')
|
||||
.insert(patientPayload).select('id').single();
|
||||
if (insErr) throw insErr;
|
||||
// Repository chamadas (Fase 2 — convertToPatient de-dup).
|
||||
const created = await createPatient(patientPayload);
|
||||
const patientId = created?.id;
|
||||
if (!patientId) throw new Error('Falha ao obter ID do paciente.');
|
||||
|
||||
const { error: upErr } = await supabase.from('patient_intake_requests')
|
||||
.update({ status: 'converted', converted_patient_id: patientId, updated_at: new Date().toISOString() })
|
||||
.eq('id', item.id);
|
||||
if (upErr) throw upErr;
|
||||
await markIntakeConverted(item.id, patientId);
|
||||
|
||||
toast.add({ severity: 'success', summary: 'Convertido em paciente', life: 2500 });
|
||||
closeDlg();
|
||||
|
||||
Reference in New Issue
Block a user