Pular para conteúdo

Tasks: Paridade do Legado em Repositórios Separados

Input: Design documents in specs/002-legacy-repo-parity/.

Phase 1: Foundation

  • T001 Audit all prontuare-web calls that still import or assume legacy clients in prontuare-web/app/, prontuare-web/hooks/ and prontuare-web/lib/.
  • T002 [P] Define stable public error envelopes and ownership assertions in prontuare-api/src/lib/operability.ts and domain routes.
  • T003 [P] Establish repeatable local API/web/browser test setup in prontuare-api/test/ and prontuare-web/ documentation.

Phase 2: User Story 1 - Trabalho clínico sem regressão (P1)

Goal: conta, paciente, atendimento e limite gratuito funcionam somente com os repos Prontuare.

  • T004 [US1] Add API integration coverage for auth, ownership, five-patient entitlement and attendance history in prontuare-api/test/clinical.integration.test.ts.
  • T005 [US1] Reconcile patient/profile/attendance calls in prontuare-web/lib/api.ts, prontuare-web/hooks/ and prontuare-web/app/(dashboard)/patients/ with the API contract.
  • T006 [US1] Implement or correct missing API behavior found by T004 in prontuare-api/src/domains/{auth,clinical,attendance,plans,profile}/.
  • T007 [US1] Add Playwright journey for registration, patient CRUD, fifth-patient limit and attendance revisions in prontuare-web/tests/.

Phase 3: User Story 2 - Agenda e calendário (P1)

  • T008 [P] [US2] Add API integration coverage for appointment lifecycle, ownership and idempotent calendar sync in prontuare-api/test/calendar.integration.test.ts.
  • T009 [US2] Reconcile calendar and appointment UI calls and error states in prontuare-web/app/(dashboard)/{appointments,calendar}/.
  • T010 [US2] Correct calendar configuration, OAuth callback and synchronization failures in prontuare-api/src/domains/calendar/.
  • T011 [US2] Add browser coverage for local appointment lifecycle and unavailable calendar integration in prontuare-web/tests/.

Phase 4: User Story 3 - Formulários e respostas (P1)

  • T012 [P] [US3] Add API integration coverage for template versioning, application and patient response isolation in prontuare-api/test/forms.integration.test.ts.
  • T013 [US3] Reconcile form builder, template list and patient application screens in prontuare-web/app/(dashboard)/settings/forms/ and prontuare-web/app/(dashboard)/patients/[id]/records/.
  • T014 [US3] Correct form validation/versioning behavior in prontuare-api/src/domains/forms/.
  • T015 [US3] Add browser coverage for creating, publishing and applying a form in prontuare-web/tests/.

Phase 5: User Story 4 - Perfil e consultas assistidas (P2)

  • T016 [P] [US4] Compare onboarding/profile legacy fields against prontuare-api/src/domains/profile/ and document missing mappings in specs/002-legacy-repo-parity/parity-inventory.md.
  • T017 [US4] Implement profile-completion contract and web onboarding integration in prontuare-api/src/domains/profile/ and prontuare-web/app/onboarding/.
  • T018 [US4] Implement CEP/CNPJ/CFP lookup contracts with manual fallback, provider configuration and integration tests in prontuare-api/src/domains/lookups/ and prontuare-api/test/.

Phase 6: User Story 5 - Estados seguros para documentos e IA (P2)

  • T019 [US5] Replace unsupported document actions with explicit capability states in prontuare-web/app/(dashboard)/patients/[id]/documents/.
  • T020 [US5] Reconcile attendance AI draft/chat states, consent and cancellation with prontuare-api/src/domains/{attendance,ai}/ and prontuare-web/app/(dashboard)/patients/[id]/.
  • T021 [US5] Add integration tests proving AI/audio cannot persist a clinical record without human approval in prontuare-api/test/forms-ai.integration.test.ts.

Phase 7: Cross-cutting validation

  • T022 [P] Add pt-BR/en/es locale infrastructure and migrate the parity journeys in prontuare-web/.
  • T023 [P] Record every legacy area as preserved, adapted, pending or retired with evidence in specs/002-legacy-repo-parity/parity-inventory.md.
  • T024 Run the complete quickstart validation and update specs/002-legacy-repo-parity/quickstart.md with actual evidence.
  • T025 Commit and push API and web changes from prontuare-api/ and prontuare-web/ only after all relevant tests pass.

Dependencies & Execution Order

T001–T003 establish the baseline. T004–T007, T008–T011 and T012–T015 may run in parallel after the baseline, but must not modify the same API/web files at the same time. T016–T021 follow the P1 evidence. T022–T025 close the release.

Implementation Strategy

The first deployable increment is T004–T007. Calendar and forms follow only after their local browser journeys pass. Profile/lookups, documents/IA and i18n must not be marked complete by static build alone.