Skip to content

feat(frontend): room occupancy + invoice-to-client checkout and workspace task unification - #1749

Merged
harshvardhan-yc merged 19 commits into
devfrom
unknown repository
Jul 1, 2026
Merged

feat(frontend): room occupancy + invoice-to-client checkout and workspace task unification#1749
harshvardhan-yc merged 19 commits into
devfrom
unknown repository

Conversation

@ghost

@ghost ghost commented Jul 1, 2026

Copy link
Copy Markdown

PR Checklist

  • The PR title follows our guidelines.
  • There is an issue for the bug/feature this PR is for.
  • All existing tests and lints pass.

What is the current behavior?

  • Room/unit pickers offer occupied beds; nothing distinguishes an active-admission unit from a free one.
  • No send-to-client checkout; POST /:invoiceId/checkout-session runs without a billing-edit permission check.
  • Lines already paid on a past invoice can be re-seeded onto the editable bill and charged again.
  • Workspace Schedule and the Tasks panel hold separate state (local-only duplicates possible); completed schedule rows disappear on refresh.
  • Chat appointment header has no lifecycle actions; the forms builder shows no summary for multi-task templates.
  • Sonar smells: nested ternaries in InvoiceStep.tsx / lib/forms.ts, duplicate @yosemite-crew/types imports in DocumentsPanel.tsx. Two broken reporoster.com image embeds in the README.

What is the new behavior?

1. Room-unit occupancy (backend + types + frontend)

  • backend/room-unit.service.ts: getOccupiedUnitIds() queries active, non-discharged admissions with a unitId; toDomain() sets isOccupied and list results are enriched per org (service test updated).
  • types/roomUnit.ts: optional isOccupied with room-unit-occupied FHIR extension in toFHIRRoomUnit/fromFHIRRoomUnit.
  • New features/appointments/lib/roomUnitAvailability.ts (isAssignableRoomUnit, getAssignableRoomUnits, getFirstAssignableRoomUnitId, toAssignableRoomOptions) — treats a unit as assignable unless occupied (a unit keeps its own current occupant). Consumed by ChangeRoom, AppointmentWorkspace, InpatientSchedule, and workspace services/store.

2. Invoice → client checkout & double-bill safety (backend + frontend)

  • backend/invoice.router.ts: checkout-session route now requires withInvoiceOrgPermissions() + requirePermission("billing:edit:any") (router test updated).
  • billing/invoiceService.ts: new sendInvoiceToClient(invoiceId) returning { checkout, emailSent }.
  • InvoiceStep.tsx: send-to-client flow gated on "Ready for billing"; state-correct payment controls (Abort while checking, Done when confirmed, Abort + Check again when delayed); printInvoice now returns success so a popup-blocked download surfaces instead of failing silently; settled-line guard — any line name on a settled/paid past invoice is excluded from the editable bill regardless of the billed flag.

3. Workspace task/schedule unification

  • TreatmentStep.tsx: the task store is the single source of truth for schedule rows (no local duplicates); workspace task load forces includeCompleted so completed rows survive refresh.
  • InpatientSchedule.tsx simplified to a template-search + read model; SummaryStep, workspace aggregate/template services, store, and types/workspace.ts updated to match.

4. Chat appointment actions

  • ChatContainer.tsx / ChatHeaderContext.tsx: Reschedule, Mark complete (changeAppointmentStatus → COMPLETED with success/error toasts), and Book follow-up from the chat appointment header.

5. Forms task-template summary + UI polish

  • FormInfo.tsx: TaskTemplateSummary renders multi-task template blocks (labels resolved from taxonomy); AddForm Details/Review/index and lib/forms.ts / taskService.ts normalize task-block instructions.
  • CompanionsTable.tsx + DataTable.css, UserHeader.tsx (route-change reset moved into an effect to avoid cross-component render warning).

6. Cleanup

  • Sonar: flattened nested ternaries (InvoiceStep.tsx, lib/forms.ts), deduped type imports (DocumentsPanel.tsx).
  • README: removed Release Versioning (kept in apps/frontend/README.md); replaced broken reporoster.com image embeds with working GitHub stargazer/forker links.
  • ~25 __tests__ files added/updated across all workstreams.

Related Issue(s)

Fixes #1748

Validation performed

  • npx tsc --noemit (frontend) — clean.
  • Targeted Jest: workspace steps, panels, room-unit availability, invoice/workspace/task services, store, forms, tasks, chat, companions.
  • Backend room-unit.service and invoice.router suites updated and passing.

Impact area

frontend (appointment workspace, room mgmt, billing, forms, tasks, chat, UI), backend (room-unit service, invoice router), types (roomUnit). Additive shared type; no Merck paths; no breaking changes.

@ghost ghost self-assigned this Jul 1, 2026
@ghost ghost added the PMS label Jul 1, 2026
@ghost ghost added this to Roadmap Jul 1, 2026
@ghost
ghost requested a review from harshvardhan-yc July 1, 2026 14:21
@ghost ghost moved this to In Progress in Roadmap Jul 1, 2026

@harshvardhan-yc harshvardhan-yc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Ready to merge

@harshvardhan-yc
harshvardhan-yc merged commit 66672ac into YosemiteCrew:dev Jul 1, 2026
32 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Completed in Roadmap Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

feat(frontend): room occupancy + invoice-to-client checkout and workspace task unification

1 participant