Skip to content

Sync v5.6.6 with mahis#829

Draft
andie23 wants to merge 3 commits into
chore/find_patients_paginationfrom
sync-v5.6.6-with-mahis
Draft

Sync v5.6.6 with mahis#829
andie23 wants to merge 3 commits into
chore/find_patients_paginationfrom
sync-v5.6.6-with-mahis

Conversation

@andie23
Copy link
Copy Markdown
Contributor

@andie23 andie23 commented Dec 2, 2025

This pull request introduces a new concern, Locatable, and integrates it across multiple models to ensure consistent handling of location-scoped data. The main goal is to automatically assign and scope records by location_id, improving multi-site support and data isolation. Additional changes ensure that the current location is properly set for the authenticated user and that queries for location or global properties are correctly unscoped where necessary.

Core Location Scoping and Model Updates:

  • Added a new Locatable concern (app/models/concerns/Locatable.rb) that automatically assigns and scopes records by location_id for models that have this column, using the current user's location or the globally set location.
  • Integrated Locatable into numerous models, including DrugOrder, Encounter, Observation, Order, Patient, Person, PersonAddress, PersonAttribute, PersonName, PatientIdentifier, PatientProgram, PatientState, Pharmacy, PharmacyBatch, and GlobalProperty, ensuring location scoping and validation across these records. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16]

Authentication and Current Location Handling:

  • Updated the authentication flow to set Location.current based on the authenticated user's location, ensuring that location-aware queries use the correct context.
  • Modified the location check to use unscoped queries for global properties, preventing unintended scoping and ensuring accurate retrieval of the current location.

Location and Facility Retrieval Adjustments:

  • Changed the controller logic for locations#show to use the Location model instead of Facility, aligning with the new location-centric approach.
  • Updated retrieval of the current health center to use unscoped queries for global properties, ensuring correct location resolution regardless of scoping.

These changes collectively enhance the application's support for multi-location environments, ensuring records are consistently associated with and scoped to the correct location.

@andie23 andie23 self-assigned this Dec 2, 2025
@andie23 andie23 marked this pull request as draft December 2, 2025 09:01
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.

2 participants