-
Notifications
You must be signed in to change notification settings - Fork 1.4k
MDM expansion support for Patient instance bulk export operations #7422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
epeartree
wants to merge
20
commits into
master
Choose a base branch
from
ehp_20251127_mdmPatientExportExpand_feature
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+630
−83
Conversation
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
This commit eliminates redundant MDM expansion queries in bulk export
operations by introducing a caching mechanism for expanded patient sets.
Changes:
- ExportPIDIteratorParameters: Added two cache fields to store expanded
patient IDs across resource type iterations:
* myExpandedPatientIdsForGroupExport (HashSet<JpaPid>) for Group exports
* myExpandedPatientIdsForPatientExport (HashSet<String>) for Patient exports
- JpaBulkExportProcessor: Refactored expansion methods with caching:
* Renamed getExpandedPatientList → getExpandedPatientSetForGroupExport
with cache-first lookup logic
* Created getExpandedPatientSetForPatientExport with caching support
* Updated getPidsForPatientStyleExport to use cached expansion
* Modified filterBySpecificPatient signature to accept expanded patient
IDs directly instead of ExportPIDIteratorParameters
Performance Impact:
MDM expansion now happens ONCE per bulk export job instead of N times
(once per resource type), significantly reducing database queries for
multi-resource exports.
Tests:
- All 19 bulk export tests pass (JpaBulkExportProcessorTest,
BulkExportHelperServiceTest)
- Code compiled successfully with spotless formatting applied
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude 4.5 Sonnet <noreply@anthropic.com>
Implements GL_7714 to enable MDM (Master Data Management) auto-expansion for Patient instance-level bulk exports (POST /Patient/[id]/$export?_mdm=true), extending existing Group export MDM expansion pattern to Patient exports. ## Changes ### API Layer - BulkDataExportProvider: Added _mdm parameter to patientInstanceExport() operation (Patient/[id]/$export only, not type-level Patient/$export) - Updated doPatientExport() to accept and propagate theMdm parameter - Added StringType import for parameter conversion ### MDM Interface & Implementations - IBulkExportMdmResourceExpander: Added expandPatient() method signature for expanding single patient IDs via MDM links - BulkExportMdmResourceExpander: Implemented expandPatient() for full MDM mode * Uses expandPidsBySourcePidAndMatchResult() to find all patients in MDM cluster * Populates MDM cache for resource annotation * Handles patients without MDM links gracefully - BulkExportMdmEidMatchOnlyResourceExpander: Implemented expandPatient() for EID Match-Only mode using EID-based matching via expandMdmBySourceResourceId() ### Core Bulk Export Logic - JpaBulkExportProcessor.getExpandedPatientSetForPatientExport(): Added MDM expansion logic that calls expandPatient() for each patient when _mdm=true - Leverages caching infrastructure from GL_XXXX (fix redundant expansion) to expand once per job across all resource types ### Documentation - BulkExportJobParameters: Updated comment to reflect MDM support for both group and patient instance exports ## Technical Details - **Caching**: Expansion results cached in ExportPIDIteratorParameters to avoid redundant queries across resource type iterations - **Dual Mode Support**: Works with both full MDM mode (link table) and EID Match-Only mode - **Partition Aware**: Properly propagates RequestPartitionId through all queries - **Error Handling**: Returns empty set if patient doesn't exist; returns single patient if no MDM links found - **Type Consistency**: Uses Set<String> for patient IDs (e.g., "Patient/123") ## Testing - All 15 JpaBulkExportProcessorTest tests pass - Modules compile successfully - Code formatted with spotless ## Dependencies - Prerequisite: GL_XXXX (fix redundant MDM expansion) - provides caching infrastructure via getExpandedPatientSetForPatientExport() method 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude 4.5 Sonnet <noreply@anthropic.com>
Implements unit tests for the expandPatient() method which expands a single patient ID to include all MDM-linked patients in the cluster. Tests verify MDM link expansion, numeric PID handling, partition propagation, and no-link scenarios using Mockito mocks. ## Changes ### Test Class Created - BulkExportMdmResourceExpanderTest: Unit tests for expandPatient() method * Uses MockitoExtension with @mock and @Injectmocks * Mocks: MdmExpansionCacheSvc, IMdmLinkDao, IIdHelperService, DaoRegistry, IFhirResourceDao<Patient>, FhirContext ### Test Coverage (4 tests) 1. testExpandPatient_withMdmLinks_returnsExpandedCluster - Verifies patient with MDM links expands to include golden + all linked patients - Tests expansion from 1 patient to 4 patients (golden + 3 sources) - Validates MDM link DAO called with MATCH result - Confirms cache populated via setCacheContents() 2. testExpandPatient_withoutMdmLinks_returnsOnlySelf - Verifies patient without MDM links returns only itself - Tests empty MDM link list handling - Confirms cache NOT populated when no links exist 3. testExpandPatient_withNumericPids_usesNumericIds - Verifies numeric PIDs used when forced IDs are absent - Tests Optional.empty() handling for forced ID translation - Validates correct formatting (e.g., "Patient/999", "Patient/123") 4. testExpandPatient_partitionContextPropagated - Verifies RequestPartitionId propagated to DAO calls - Uses ArgumentCaptor to validate partition in SystemRequestDetails - Tests specific partition (RequestPartitionId.fromPartitionId(5)) - Confirms partition used in both read() and getPidOrNull() ## Technical Details - **MdmPidTuple Construction**: Uses static factory method `MdmPidTuple.fromGoldenAndSource()` (constructor is private) - **PersistentIdToForcedIdMap Mocking**: Created proper mock for translatePidsToForcedIds() to avoid NullPointerException in populateMdmResourceCache() - **Test Strategy**: Pure unit tests with mocks, no database or Spring context - **Assertions**: Uses AssertJ for fluent assertions ## Validation All 4 tests pass: - Tests run: 4, Failures: 0, Errors: 0, Skipped: 0 - Build: SUCCESS 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude 4.5 Sonnet <noreply@anthropic.com>
…roken due to volatile caching of expansion.
…rces depending on export style
…ientExportExpand_feature
Contributor
|
Formatting check succeeded! |
- code clean up based on sonarQube
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.
Overview:
Implemented MDM (Master Data Management) expansion support for Patient instance bulk export operations. When the
_mdmparameter is enabled, patient exports now automatically include all MDM-linked patients (golden resources and linked patients) along with their patient compartment resources.What was done:
expandPatient()method toIBulkExportMdmResourceExpanderinterfaceBulkExportMdmResourceExpander:MATCHrelationshipsBulkExportMdmEidMatchOnlyResourceExpanderreusing existing functionalitiescloses #7421