feat(COG-146): Add provider availability management backend - #18
Open
devin-ai-integration[bot] wants to merge 3 commits into
Open
devin-ai-integration[bot] wants to merge 3 commits into
devin-ai-integration[bot] wants to merge 3 commits into
Conversation
- Flyway V3 migration creating provider_availability table - BlockType enum (AVAILABLE, ADMIN, LUNCH, MEETING) - ProviderAvailability JPA entity with @manytoone to Provider - ProviderAvailabilityDTO with validation annotations - ProviderAvailabilityRepository with custom queries - ProviderAvailabilityService with CRUD and validation - ProviderAvailabilityController with RESTful endpoints Co-Authored-By: Stephen Cornwell <stephen@cognition.ai>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
- Fix @table index annotations to use SQL column names instead of Java field names - Fix findEffectiveForDate to not mutate JPA-returned list - Add 15 unit tests for ProviderAvailabilityService covering: - CRUD operations (create, update, deactivate) - Validation: time range, recurring/specific date, slot duration, day of week - All block types and slot duration values - Effective date combining recurring + overrides Co-Authored-By: Stephen Cornwell <stephen@cognition.ai>
… getter - Prevent LazyInitializationException on GET endpoints by hiding LAZY provider - Add @transient getProviderId() so JSON response still includes provider ID Co-Authored-By: Stephen Cornwell <stephen@cognition.ai>
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.
Summary
Adds full-stack backend support for managing provider scheduling availability. This includes:
provider_availabilitytable with constraints for block types, time ranges, slot durations, and a recurring-vs-specific-date XOR checkProviderAvailability) with@ManyToOnetoProvider, optimistic locking via@Version,@JsonIgnoreon the LAZY provider field, and a@TransientgetProviderId()getter for JSON serialization@NotNullvalidation on required fieldsdeactivate), and validation (time ordering, slot duration whitelist, recurring/specific-date constraints)/v1/providers/{providerId}/availabilitywith 8 endpoints (list, get, recurring, by-date, effective, range, create, update, delete) including provider ownership checksUpdates since last revision
@Table(indexes=...)to use SQL column names (day_of_week,block_type) instead of Java field names, avoiding potential duplicate-index conflicts with the Flyway migrationfindEffectiveForDateto copy the JPA-returned list into a newArrayListbefore appending overrides, preventingUnsupportedOperationExceptionon unmodifiable listsProviderAvailabilityServiceTestwith 15 Mockito-based unit tests@JsonIgnoreon theproviderfield to preventLazyInitializationExceptionon GET endpoints@Transient getProviderId()so the JSON response still includes the provider's ID without triggering lazy loadingReview & Testing Checklist for Human
getProviderId()outside transaction: The@Transientgetter callsprovider.getId()on a LAZY proxy. Hibernate proxies store the ID without lazy loading, so this should work outside the@Transactionalboundary — but verify with a live request that GET responses includeproviderIdcorrectly and don't throwLazyInitializationException.@Querymethods (findEffectiveRecurringForDate,findByProviderIdAndDateRange) are not exercised against a real database. Consider adding an integration test with H2 to verify these queries.date.getDayOfWeek().getValue() % 7maps Sunday→0, Monday→1 ... Saturday→6. Verify this matches the frontend's convention and thechk_day_of_weekconstraint (0–6).Suggested test plan: Start the API with a running Postgres instance, execute the Flyway migration, and manually test the CRUD endpoints via curl/Postman. Specifically verify: creating a recurring block, creating a specific-date override, the
/effectiveendpoint returns both, the DELETE endpoint soft-deletes correctly, and that GET responses includeproviderIdin the JSON without errors.Notes
active=false) rather than hard delete — this is intentionalBlockTypeenum is shared with the frontend PR (COG-GTM/demos-coghealth-ehr-web)findByProviderIdAndBlockTypeAndActiveTrueis declared in the repository but not currently called by the service or controller — it's available for future useLink to Devin session: https://app.devin.ai/sessions/f65523f6eeb84bbb9f183b66eea0786a
Requested by: @stephencornwell