Skip to content

AB2D-7403 Update service-date Validation - #1862

Open
colby-seyferth-nava wants to merge 4 commits into
mainfrom
AB2D-7403
Open

AB2D-7403 Update service-date Validation#1862
colby-seyferth-nava wants to merge 4 commits into
mainfrom
AB2D-7403

Conversation

@colby-seyferth-nava

@colby-seyferth-nava colby-seyferth-nava commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

🎫 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

@colby-seyferth-nava
colby-seyferth-nava marked this pull request as ready for review September 4, 2026 23:44
@colby-seyferth-nava
colby-seyferth-nava requested a review from a team as a code owner September 4, 2026 23:44
@Sadibhatla
Sadibhatla requested a lite review from Copilot September 8, 2026 17:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 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.checkServiceDates with DateRangeParam#setValuesAsQueryTokens(...) parsing.
  • Expanded unit test coverage for additional valid/invalid service-date combinations.
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));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants