Pular para conteúdo

Tasks: Validação e escopo por CRP

Phase 1: Setup

  • T001 Verify dirty worktrees and ignore files in prontuare-api/ and prontuare-web/
  • T002 [P] Add deterministic CRP/document tests in prontuare-api/test/crp-domain.unit.test.ts
  • T003 [P] Add browser fixtures in prontuare-web/tests/fixtures/crp-scope.ts

Phase 2: Foundational

  • T004 Add additive CRP/profile/patient schema migration in prontuare-api/drizzle/0008_crp_scope_validation.sql and prontuare-api/src/db/schema.ts
  • T005 [P] Implement CPF/CNPJ/CRP normalization in prontuare-api/src/domains/profile/documents.ts
  • T006 Implement authenticated CRP scope resolution in prontuare-api/src/domains/crp/crp.service.ts and affected routes
  • T007 Implement N-blocker decision service in prontuare-api/src/domains/plans/plans.service.ts
  • T008 Expose account capabilities routes in prontuare-api/src/domains/plans/plans.routes.ts and prontuare-api/src/main.ts

Phase 3: User Story 1 — Complete profile

  • T009 [US1] Extend profile validation/unicity and completion in prontuare-api/src/domains/profile/profile.service.ts and profile.routes.ts
  • T010 [US1] Consolidate CPF+CNPJ profile editor in prontuare-web/app/(dashboard)/settings/profile/_components/professional-profile-form.tsx
  • T011 [US1] Redirect new accounts while preserving safe navigation in prontuare-web/app/onboarding/

Phase 4: User Stories 2 and 6 — CRP validation/revalidation

  • T012 [US2] Implement provider adapter and registration service/routes in prontuare-api/src/domains/crp/
  • T013 [US6] Implement CRP validation BullMQ queue and worker processing in prontuare-api/src/domains/crp/crp.queue.ts and prontuare-api/src/worker.ts
  • T014 [US2] Add CRP collection/editor and states to prontuare-web/app/(dashboard)/settings/profile/_components/professional-profile-form.tsx
  • T015 [P] [US6] Test five-day/idempotent transitions in prontuare-api/test/crp-policy.unit.test.ts

Phase 5: User Story 3 — CRP/Todos scope

  • T016 [US3] Apply patient CRP assignment/filter and safe direct access in prontuare-api/src/domains/clinical/clinical.service.ts and clinical.routes.ts
  • T017 [US3] Derive patient CRP in dashboard/calendar/forms/attendance/AI services under prontuare-api/src/domains/
  • T018 [US3] Add scope-aware API client/provider in prontuare-web/lib/api.ts and prontuare-web/components/crp-scope-provider.tsx
  • T019 [US3] Add Todos/CRP selector near avatar in prontuare-web/app/(dashboard)/_components/dashboard-sidebar.tsx
  • T020 [US3] Make patient queries/forms scope-aware in prontuare-web/app/(dashboard)/patients/

Phase 6: User Stories 4, 5 and 7 — quota and blockers

  • T021 [US4] Preserve global concurrent free quota and return structured blockers in prontuare-api/src/domains/clinical/clinical.service.ts
  • T022 [US7] Enforce profile/CRP/tier decisions on protected mutations under prontuare-api/src/domains/
  • T023 [US7] Render zero/one/N blockers and resolution links in prontuare-web/components/operation-blockers.tsx
  • T024 [US5] Add reusable capability guards to protected web creation flows under prontuare-web/app/(dashboard)/

Phase 7: Verification and rollout

  • T025 [P] Add API integration coverage in prontuare-api/test/crp-scope.integration.test.ts and capabilities.integration.test.ts
  • T026 [P] Add Playwright vertical coverage in prontuare-web/tests/crp-scope.spec.ts
  • T027 Update migration readiness and deployment docs in prontuare-api/src/db/readiness.ts and feature docs
  • T028 Run API tests/typecheck, web typecheck/build and real Playwright flow from specs/004-crp-scope-validation/quickstart.md
  • T029 [US3] Hide “Todos” and the selector for a single CRP in prontuare-web/app/(dashboard)/_components/dashboard-sidebar.tsx
  • T030 [US5] Move compact account blockers into the sidebar in prontuare-web/components/account-readiness-banner.tsx
  • T031 [US7] Localize operation blockers to pt-BR in prontuare-api/src/domains/plans/plans.service.ts
  • T032 [US4] Preselect the current CRP and disable patient creation for blocking pendencies in prontuare-web/app/(dashboard)/patients/_components/new-patient-dialog.tsx
  • T033 [P] Add single-CRP and blocked-account UI coverage in prontuare-web/tests/crp-scope.spec.ts

Dependencies

  • T004–T008 block all user-story phases.
  • US1 and US2 establish valid registrations before US3 filtering.
  • US4/US7 depend on scope and capabilities but retain owner-global quota.
  • T025–T028 validate the complete vertical slice.

Parallel Strategy

  • API foundation/CRP, web UI/provider and tests can proceed in parallel after contracts.
  • Within source code, tasks sharing clinical.service.ts or the profile form execute sequentially.
  • Suggested MVP is US1 + US2 + US6; production rollout additionally requires US3, US4 and US7.