Skip to content

Handle Non-Patient Compartment Resource IDs#1320

Open
trobanga wants to merge 27 commits intomainfrom
942-non-patient-related-resource-ids
Open

Handle Non-Patient Compartment Resource IDs#1320
trobanga wants to merge 27 commits intomainfrom
942-non-patient-related-resource-ids

Conversation

@trobanga
Copy link
Contributor

@trobanga trobanga commented Dec 2, 2025

Summary

IDs of resources NOT in the patient compartment are now pseudonymized directly via gPAS, instead of being derived from patient ID/salt. This addresses issue #942.

Changes

  • PatientCompartment utility: Loads the FHIR R4B patient compartment definition and checks if a resource type has a param key (indicating it's patient-related)
  • GpasClient: Added batch fetchOrCreatePseudonyms() method for efficient pseudonymization of multiple IDs
  • FhirMappingProvider: Splits resource IDs by compartment membership:
    • Patient-compartment resources (66 types): Continue using salt-based SHA256 hashing
    • Non-compartment resources (Organization, Practitioner, Medication, etc.): Direct gPAS pseudonymization

Technical Details

  • Resource ID format: {patientId}.{ResourceType}:{id}
  • Identifier format: {patientId}.identifier.{system}:{value} (always treated as patient-related)
  • Uses embedded compartmentdefinition-patient.json from FHIR R4B spec

Test Plan

  • All existing tests pass (85 tests in trust-center-agent)
  • New unit tests for PatientCompartment (6 tests)
  • New unit tests for extractResourceType and generateNonCompartmentMapping (7 tests)
  • Integration test with actual gPAS instance

Closes #942

@trobanga trobanga linked an issue Dec 2, 2025 that may be closed by this pull request
@codecov
Copy link

codecov bot commented Dec 2, 2025

Codecov Report

❌ Patch coverage is 98.44961% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 99.16%. Comparing base (aaff6e3) to head (739e0ba).
⚠️ Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
...rvices/deidentifhir/PatientCompartmentService.java 97.87% 1 Missing and 2 partials ⚠️
...ith/fts/cda/services/deidentifhir/IdatScraper.java 96.15% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##               main    #1320      +/-   ##
============================================
- Coverage     99.27%   99.16%   -0.12%     
- Complexity      493      550      +57     
============================================
  Files           124      126       +2     
  Lines          1803     2030     +227     
  Branches         47       70      +23     
============================================
+ Hits           1790     2013     +223     
- Misses            2        3       +1     
- Partials         11       14       +3     
Files with missing lines Coverage Δ
...ava/care/smith/fts/api/ConsentedPatientBundle.java 100.00% <100.00%> (ø)
...re/smith/fts/cda/DefaultTransferProcessRunner.java 100.00% <100.00%> (ø)
...java/care/smith/fts/cda/impl/DeidentifhirStep.java 100.00% <100.00%> (ø)
...are/smith/fts/cda/impl/DeidentifhirStepConfig.java 100.00% <100.00%> (ø)
...re/smith/fts/cda/impl/DeidentifhirStepFactory.java 100.00% <100.00%> (ø)
...are/smith/fts/cda/impl/EverythingDataSelector.java 100.00% <100.00%> (ø)
...fts/cda/services/deidentifhir/ScrapingStorage.java 100.00% <100.00%> (ø)
...ration/PatientCompartmentServiceConfiguration.java 100.00% <100.00%> (ø)
.../fts/tca/deidentification/FhirMappingProvider.java 100.00% <100.00%> (ø)
...re/smith/fts/util/tca/TransportMappingRequest.java 100.00% <ø> (ø)
... and 2 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@trobanga trobanga force-pushed the 942-non-patient-related-resource-ids branch from 994e4e6 to 681de99 Compare December 2, 2025 08:34
@trobanga trobanga requested a review from knoppiks December 2, 2025 09:41
@trobanga trobanga force-pushed the 942-non-patient-related-resource-ids branch 2 times, most recently from 31fc982 to 89d0846 Compare December 2, 2025 11:46
@knoppiks knoppiks removed their request for review December 2, 2025 12:17
@trobanga trobanga force-pushed the 942-non-patient-related-resource-ids branch 14 times, most recently from 3c69a63 to 5611c2a Compare December 5, 2025 08:31
Resource IDs outside the patient compartment are now pseudonymized
directly via gPAS instead of using patient-derived salt.

- Add PatientCompartment to check FHIR compartment membership
- Add batch fetchOrCreatePseudonyms to GpasClient
- Split ID handling in FhirMappingProvider by compartment type

Closes #942
Reduce FhirMappingProvider from 321 to 189 lines by extracting
compartment-related logic into a dedicated class.
CDA now determines actual compartment membership by checking
if resource param fields reference the patient. TCA uses
prefix-based checking only.
- Switch gpas-db from MySQL 9.5 to MariaDB 11.4
- Add custom gPAS Dockerfile with MariaDB JDBC driver
- Update environment variables and healthcheck for MariaDB
@trobanga trobanga force-pushed the 942-non-patient-related-resource-ids branch from 9a5e72a to bc8761f Compare December 5, 2025 08:41
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.

non-Patient Related Resource IDs

1 participant