Skip to content

feat: add Canada PIPEDA policy profile and register alias#561

Open
AbrarH4 wants to merge 2 commits into
maziyarpanahi:masterfrom
AbrarH4:feat/canada-pipeda-policy
Open

feat: add Canada PIPEDA policy profile and register alias#561
AbrarH4 wants to merge 2 commits into
maziyarpanahi:masterfrom
AbrarH4:feat/canada-pipeda-policy

Conversation

@AbrarH4

@AbrarH4 AbrarH4 commented Jun 22, 2026

Copy link
Copy Markdown

This PR implements the canada_pipeda policy profile to ensure compliance with Canada's PIPEDA, addressing the requirements for masking Canadian direct identifiers (SIN and provincial health-card numbers). It also updates existing core policies to include these identifiers to ensure consistent de-identification across the platform.
Type of Change
[x] New feature (non-breaking change which adds functionality)
[x] Test addition/improvement

Changes Made
Added openmed/core/policies/canada_pipeda.json with appropriate masking configurations.
Registered canada_pipeda (canonical) and pipeda (alias) in openmed/core/policy.py.
Updated core policy JSON files (clinical_minimal_redaction, gdpr_pseudonymization, hipaa_expert_review_assist, hipaa_safe_harbor, research_limited_dataset, strict_no_leak) to include Canadian SIN and health-card number identifiers.
Added unit tests in tests/unit/core/test_policy_profiles.py to verify profile resolution and masking efficacy.

Testing
[x] I have added tests that prove my feature works
[x] New and existing unit tests pass locally with my changes

Documentation

[ ] I have updated the documentation accordingly
[ ] I have added docstrings to new functions/classes
[ ] I have updated the CHANGELOG.md

Code Quality

[x] I ran make format, make lint, and make format-check
[x] I have performed a self-review of my own code
[x] My changes generate no new warnings

Dependencies
[x] I have not added any new dependencies

Checklist
[x] I have read the contributing guidelines
[x] My commits have clear, descriptive messages

Related Issues
Closes #517
Related to OM-327

@maziyarpanahi maziyarpanahi added help wanted Extra attention is needed good first issue Good for newcomers roadmap-v2 OpenMed V2 roadmap backlog feature New capability P2 Medium labels Jun 22, 2026
@maziyarpanahi

Copy link
Copy Markdown
Owner

Thank you @AbrarH4. I reviewed this against #517 and added a maintainer follow-up commit: fix: align Canada PIPEDA policy actions.

What changed:

  • restored existing policy profiles so the PR no longer carries unrelated formatting or schema churn;
  • kept the new canada_pipeda profile and pipeda alias, but aligned actions to canonical entity labels by masking ID_NUM and SSN instead of adding unregistered subtype keys;
  • added regression tests for profile loading, alias registration, policy listing, identifier masking, reversible IDs, and mapping retention.

Verification:

  • /Users/maziyar/Developer/openmed/.venv/bin/python -m pytest tests/unit/core/test_policy_profiles.py tests/unit/service/test_policy_rest.py tests/unit/eval/test_release_gates.py tests/unit/eval/test_release_gate_cli.py -q -> 28 passed
  • /Users/maziyar/Developer/openmed/.venv/bin/ruff check tests/unit/core/test_policy_profiles.py openmed/core/policy.py -> passed

I copied #517 labels onto the PR. The branch is mergeable with no conflicts. GitHub has not reported hosted checks for this fork head, so the validation above is local.

@AbrarH4

AbrarH4 commented Jun 22, 2026

Copy link
Copy Markdown
Author

Thank you @AbrarH4. I reviewed this against #517 and added a maintainer follow-up commit: fix: align Canada PIPEDA policy actions.

What changed:

* restored existing policy profiles so the PR no longer carries unrelated formatting or schema churn;

* kept the new `canada_pipeda` profile and `pipeda` alias, but aligned actions to canonical entity labels by masking `ID_NUM` and `SSN` instead of adding unregistered subtype keys;

* added regression tests for profile loading, alias registration, policy listing, identifier masking, reversible IDs, and mapping retention.

Verification:

* `/Users/maziyar/Developer/openmed/.venv/bin/python -m pytest tests/unit/core/test_policy_profiles.py tests/unit/service/test_policy_rest.py tests/unit/eval/test_release_gates.py tests/unit/eval/test_release_gate_cli.py -q` -> 28 passed

* `/Users/maziyar/Developer/openmed/.venv/bin/ruff check tests/unit/core/test_policy_profiles.py openmed/core/policy.py` -> passed

I copied #517 labels onto the PR. The branch is mergeable with no conflicts. GitHub has not reported hosted checks for this fork head, so the validation above is local.

Sorry, @maziyarpanahi
I should have solved the problem myself, yet you helped me fix it. I am apologising for the error in the code. Thank you for solving the error. I appreciate your help. I am looking forward to help you on the related issues, but now without throwing more errors at you or making your work more difficult.

@maziyarpanahi

Copy link
Copy Markdown
Owner

No worries at all! It's a community-driven library, we all help each other and learn while doing so. Thank you for your contributions.

@maziyarpanahi maziyarpanahi self-requested a review June 22, 2026 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New capability good first issue Good for newcomers help wanted Extra attention is needed P2 Medium roadmap-v2 OpenMed V2 roadmap backlog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a Canada PIPEDA policy profile as a data-driven config

3 participants