Skip to content

Sensory ZPP refactor - #46

Merged
EddieMachete merged 4 commits into
masterfrom
43-sensory-zpp-refactor-2
Feb 18, 2026
Merged

Sensory ZPP refactor#46
EddieMachete merged 4 commits into
masterfrom
43-sensory-zpp-refactor-2

Conversation

@EddieMachete

Copy link
Copy Markdown
Contributor

Closes #43

Refactors the calculation for the Sensory Zone of Partial Preservation using the chain-of-command design pattern to match the calculations for motor ZPP.

@EddieMachete
EddieMachete requested a review from Copilot February 18, 2026 20:21
@EddieMachete EddieMachete self-assigned this Feb 18, 2026
@EddieMachete EddieMachete added the enhancement New feature or request label Feb 18, 2026
@EddieMachete
EddieMachete marked this pull request as ready for review February 18, 2026 20:21

Copilot AI 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.

Pull request overview

This pull request successfully refactors the Sensory Zone of Partial Preservation (Sensory ZPP) calculation to use a step-based, chain-of-command design pattern that mirrors the existing Motor ZPP implementation. The refactor improves code maintainability and transparency by breaking down the calculation into discrete, traceable steps that clinicians can follow.

Changes:

  • Refactored Sensory ZPP calculation from a procedural loop-based approach to a step-based chain-of-command pattern with five distinct steps: checkIfSensoryZPPIsApplicable, checkSacralLevel, getTopAndBottomLevelsForCheck, checkLevel, and sortSensoryZPP
  • Extracted shared Step and StepHandler types to src/classification/common/step.ts for reuse across both Motor and Sensory ZPP modules
  • Added comprehensive documentation including a detailed README and architecture specification document explaining the algorithm logic and step-by-step flow

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/classification/common/step.ts New shared module defining generic Step, StepHandler, and createStep helper for step-based algorithms
src/classification/zoneOfPartialPreservation/sensoryZPP.ts Complete refactor of sensory ZPP calculation using step-based pattern; maintains algorithm fidelity with original implementation
src/classification/zoneOfPartialPreservation/sensoryZPPErrors.ts New error handling with SensoryZPPError class and centralized error messages following Motor ZPP pattern
src/classification/zoneOfPartialPreservation/sensoryZPP.spec.ts Comprehensive test suite covering all step functions, edge cases, and generator function; 300+ tests maintained
src/classification/zoneOfPartialPreservation/motorZPP.ts Updated to use shared step types from common/step.ts; added params to translation keys for better templating
src/en.ts Added 13 new Sensory ZPP translation keys; updated 3 Motor ZPP translation keys to include level name parameters
src/classification/zoneOfPartialPreservation/README.md New comprehensive documentation explaining both Sensory and Motor ZPP algorithms with step-by-step descriptions and flow diagrams
docs/sensoryZPP-architecture.md Detailed architecture specification document describing the refactor design, step definitions, and implementation details

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docs/sensoryZPP-architecture.md Outdated
- Else:
- Call `checkLevelForSensoryZPP(side, currentLevel.name, variable)`.
- `variable = variable || result.variable`.
- If `result.level` → unshift `result.level` to zpp.

Copilot AI Feb 18, 2026

Copy link

Choose a reason for hiding this comment

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

The architecture documentation states "If result.level → unshift result.level to zpp" (line 115), but the actual implementation uses push (append) with [...state.zpp, result.level]. The documentation should say "push" or "append" instead of "unshift" to match the implementation.

Suggested change
- If `result.level`unshift `result.level` to zpp.
- If `result.level`push/append `result.level` to zpp.

Copilot uses AI. Check for mistakes.
@EddieMachete
EddieMachete force-pushed the 43-sensory-zpp-refactor-2 branch from 441dacd to 6c9279a Compare February 18, 2026 20:39
@EddieMachete
EddieMachete merged commit 2afbaef into master Feb 18, 2026
2 checks passed
@EddieMachete
EddieMachete deleted the 43-sensory-zpp-refactor-2 branch February 25, 2026 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sensory ZPP refactor

2 participants