Open
Conversation
- Add migration to create patient_scores table (with existence check) - Add PatientScore model with Mergeable concern - Add Api::V4::PatientScoresController with sync_to_user only - Add PatientScoreTransformer for response transformation - Add patient_score schema to Api::V4::Models - Add GET route for /patient_scores/sync - Add factory and controller spec for patient_scores (sync_to_user only)
…t line 9724, which terminated the INSERT INTO schema_migrations statement early. The migration versions on lines 9725-9729 were left as orphaned SQL, causing the syntax error.
# Conflicts: # app/controllers/admin/deduplicate_patients_controller.rb # app/views/admin/deduplicate_patients/show.html.erb # db/structure.sql
Remove hardcoded Time.current for created_at/updated_at and let the base transformer use the actual device_created_at/device_updated_at from the record. This fixes pagination issues in sync.
Remove duplicate entry for migration 20260212195326 and fix chronological ordering of migration entries.
Add data migration to fix sync pagination issue where bulk-inserted PatientScores share the same updated_at timestamp, causing the process_token to never advance. The migration: 1. Finds timestamps with >1000 records clustered 2. If device_updated_at is well-distributed, uses that 3. Otherwise spreads by id with millisecond offsets
- Replace timestamp-only pagination with (updated_at, id) keyset pagination - Add process token tracking for last_id to ensure no records are skipped - Prevents duplicate/missed records when multiple scores share same timestamp
…stamps stored in process_token are UTC strings (ending with 'Z'),but the inherited to_time method converts them to local timezone.This causes incorrect comparisons when the server timezone differs from UTC, resulting in 0 records returned on subsequent sync requests. Override other_facilities_processed_since and current_facility_processed_since to explicitly parse timestamps in UTC using to_time(:utc).
…ity bucket Replace keyset pagination with simple OFFSET-based next_page counter in the process_token. Patient scores now sync only for the current facility's prioritized patients; the other-facilities bucket is dropped. Updates specs to match the new token contract.
Previously the token reset next_page to 1 as soon as a partial page was returned, so calling the endpoint again with the returned token re-fetched the same records instead of returning empty. Now next_page advances on every non-empty response (full or partial) and resets to 1 only when the query returns zero records, giving clients a clear 'sync complete' signal.
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.
Story card: SIMPLEBACK-34
Because
Enter the reason for raising this PR...
This addresses
Enter the details of what all this covers...
Test instructions
Enter detailed instructions for how to test this PR...