AB2D-7403 Update service-date Validation - #1862
Open
colby-seyferth-nava wants to merge 4 commits into
Open
Conversation
colby-seyferth-nava
marked this pull request as ready for review
September 4, 2026 23:44
colby-seyferth-nava
requested review from
Sadibhatla,
bennavapbc,
keeyanghoreshi-rgb and
smirnovaae
September 8, 2026 15:32
smirnovaae
approved these changes
Sep 8, 2026
bennavapbc
approved these changes
Sep 8, 2026
There was a problem hiding this comment.
🟡 Changes recommended
The new validation path should avoid per-request FhirContext creation and should not surface raw HAPI exception messages to clients (plus a small test naming fix).
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR updates service-date query parameter validation by replacing custom regex-based checks with HAPI FHIR’s built-in date range parsing/validation, aiming to close validation gaps while simplifying the code.
Changes:
- Replaced regex validation in
ApiCommon.checkServiceDateswithDateRangeParam#setValuesAsQueryTokens(...)parsing. - Expanded unit test coverage for additional valid/invalid
service-datecombinations.
File summaries
| File | Description |
|---|---|
| api/src/main/java/gov/cms/ab2d/api/controller/common/ApiCommon.java | Switches service-date validation to HAPI FHIR parsing instead of regex matching. |
| api/src/test/java/gov/cms/ab2d/api/controller/common/ApiCommonTest.java | Adds more service-date validation test cases to cover additional scenarios. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+179
to
+181
| try { | ||
| serviceDateRange.setValuesAsQueryTokens(FhirContext.forR4(), "service-date", qualifiedServiceDateParams); | ||
| } catch (InvalidRequestException | DataFormatException e) { |
Comment on lines
+181
to
184
| } catch (InvalidRequestException | DataFormatException e) { | ||
| log.error("Invalid service-date received {}", serviceDates); | ||
| throw new InvalidClientInputException("invalid service-date parameter: " + e.getMessage()); | ||
| } |
Comment on lines
+133
to
+144
| List<String> invalidMultipleLowerBound = List.of("gt2020-01-01", "ge2020-07-01"); | ||
| List<String> invalidUpperBoundAndEquals = List.of("gt2024-06-07", "eq2024"); | ||
| assertDoesNotThrow(() -> apiCommon.checkServiceDates(null)); | ||
| assertDoesNotThrow(() -> apiCommon.checkServiceDates(validServiceDates)); | ||
| assertDoesNotThrow(() -> apiCommon.checkServiceDates(validYearOnly)); | ||
| assertDoesNotThrow(() -> apiCommon.checkServiceDates(validLowerBound)); | ||
| assertDoesNotThrow(() -> apiCommon.checkServiceDates(validUpperBound)); | ||
| assertThrows(InvalidClientInputException.class, () -> apiCommon.checkServiceDates(invalidOperatorCode)); | ||
| assertThrows(InvalidClientInputException.class, () -> apiCommon.checkServiceDates(invalidFormat)); | ||
| assertThrows(InvalidClientInputException.class, () -> apiCommon.checkServiceDates(invalidNotRealDate)); | ||
| assertThrows(InvalidClientInputException.class, () -> apiCommon.checkServiceDates(invalidMultipleLowerBound)); | ||
| assertThrows(InvalidClientInputException.class, () -> apiCommon.checkServiceDates(invalidUpperBoundAndEquals)); |
Sadibhatla
approved these changes
Sep 8, 2026
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://jira.cms.gov/browse/AB2D-7403
🛠 Changes
Added validation for the service-date param. Instead of adding our own validation logic, we'll leverage the HAPI FHIR validation methods.
ℹ️ Context
There were some gaps in the initial validation logic, and it was more complex than needed. This way we just leverage the existing tools
🧪 Validation
Unit tests and ran some requests locally