feat(msp-withdrawal -toggle): add logic to enable and disable withdrawal toggle - #2007
Draft
jdinh8124 wants to merge 1 commit into
Draft
feat(msp-withdrawal -toggle): add logic to enable and disable withdrawal toggle#2007jdinh8124 wants to merge 1 commit into
jdinh8124 wants to merge 1 commit into
Conversation
Collaborator
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Contributor
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ticket
https://jiraent.cms.gov/browse/OY2-41235
Context
OneMAC already consumes the SMART Kafka topic and dispatches valid records by
operationType, butMSP_RAI_WITHDRAWAL_TOGGLEDwas still using the default reservation path.This event represents a CMS action performed in SMART. It is not a general package-status synchronization event. OneMAC must use it to enable or disable the State-side Formal RAI Response withdrawal action while preserving the package’s existing lifecycle status.
Business confirmed:
raiIdidentifies the most recent applicable RAI.Solution
This PR implements the
MSP_RAI_WITHDRAWAL_TOGGLEDSMART event handler.Event validation
The handler validates the event-specific fields:
spaWaiverIdidorigin: "SMART"authoritycreatedAtoperationType: "MSP_RAI_WITHDRAWAL_TOGGLED"raiIdraiNameraiWithdrawnToggleraiWithdrawnToggleDateBoth Medicaid SPA and CHIP SPA packages are supported.
raiWithdrawnToggleDateis used as the authoritative event timestamp.createdAtis retained as a fallback for early producers that omit the event-specific timestamp.Invalid events and business-resolution failures are published to the configured BigMAC error queue.
Package resolution
The handler operates only on an existing visible package:
spaWaiverId.payload.id.idfor a legacy OneMAC package that SMART has not touched.spaWaiverIdwhen the ID fallback resolves an otherwise valid package.The event is rejected when:
spaWaiverIdis ambiguous or belongs to another package.Unlike manual-record events, an RAI toggle does not create a reservation or new package.
Toggle behavior
For a current event, the handler updates:
raiWithdrawEnabledraiIdraiNameraiWithdrawnToggleDatemakoChangedDateThe handler intentionally does not overwrite:
originseatoolStatuscmsStatusstateStatusPackage status remains governed by the established OneMAC lifecycle and status-update paths.
When enabled, the existing OneMAC rules display:
Withdraw Formal RAI Response - EnabledThese actions remain subject to existing package status, RAI-response, user-role, and locking safeguards.
Administrative Package Changes
Each event writes the existing
toggle-withdraw-raichangelog shape.Enabled events display:
Enable Formal RAI Response WithdrawDisabled events display:
Disable Formal RAI Response WithdrawThe changelog also retains
raiId,raiName,spaWaiverId,correlationId, andoperationTypefor traceability.Replay and ordering safeguards
Flow
flowchart TD kafka[SMART Kafka event] --> envelope[Validate base envelope] envelope -->|invalid| bigmac[Publish to BigMAC] envelope --> dispatch[Dispatch MSP_RAI_WITHDRAWAL_TOGGLED] dispatch --> validate[Validate RAI toggle fields] validate -->|invalid| bigmac validate --> external[Resolve package by spaWaiverId] external -->|not found| fallback[Fall back to package id] external --> verify[Verify visible package and matching authority] fallback --> verify fallback -->|not found or conflict| bigmac verify --> order{Compare toggle timestamps} order -->|current| update[Update raiWithdrawEnabled and RAI metadata] order -->|stale| preserve[Preserve current package state] update --> activity[Upsert deterministic admin event] preserve --> activityFeature flag rollout
The existing
hide-withdraw-rai-response-toggleflag remains as a rollout and rollback control.Recommended rollout:
The SMART consumer is not feature-gated, allowing event processing to be tested before the legacy controls are hidden.
Testing
Completed successfully:
bun run lintbun run buildbun run build:lib./run test --run lib/lambda/smartCoverage includes:
Deployment and QA notes
BIGMAC_ERROR_QUEUE_URLis configured before testing invalid events.Withdraw Formal RAI Response - Enabledappears.Normal deployment starts the consumer at
LATEST. Previously published events require a deliberate replay using a new consumer group or a targeted data correction.