Skip to content

feat: patient group data model, events, and effects#1544

Open
nmpsilva wants to merge 6 commits intomainfrom
nuno/sdk-patient-groups
Open

feat: patient group data model, events, and effects#1544
nmpsilva wants to merge 6 commits intomainfrom
nuno/sdk-patient-groups

Conversation

@nmpsilva
Copy link
Collaborator

@nmpsilva nmpsilva commented Mar 3, 2026

Internal tracking: KOALA-3047

This pull request introduces support for patient groups and their memberships in the SDK and underlying protocol buffers. The main changes add new effect and event types for managing patient group membership, implement corresponding SDK classes and database models, and update module import permissions for plugins.

Patient Group Effects and Events:

  • Added new effect types ENSURE_PATIENT_IN_GROUP and ENSURE_PATIENT_NOT_IN_GROUP to the EffectType enum in both the protocol buffer definitions (effects.proto) and the generated Python stubs (effects_pb2.pyi). These effects allow idempotent management of a patient's membership in a group. [1] [2] [3]
  • Added new event types for patient group and membership lifecycle (PATIENT_GROUP_CREATED, PATIENT_GROUP_UPDATED, PATIENT_GROUP_MEMBERSHIP_CREATED, PATIENT_GROUP_MEMBERSHIP_DELETED) to the EventType enum in both the protocol buffer definitions (events.proto) and the generated Python stubs (events_pb2.pyi). [1] [2] [3]

SDK Implementation:

  • Implemented new effect classes EnsurePatientInGroup and EnsurePatientNotInGroup in canvas_sdk/effects/patient_group.py to provide a Python interface for the new effect types.
  • Added new Django models PatientGroup and PatientGroupMembership in canvas_sdk/v1/data/patient_group.py to represent patient groups and their memberships in the database. Updated the SDK data module exports and initialization to include these models. [1] [2] [3]

Plugin Module Import Permissions:

  • Updated plugin_runner/allowed-module-imports.json to allow plugins to import the new patient group effect classes and data models. [1] [2] [3]

@nmpsilva nmpsilva requested a review from a team as a code owner March 3, 2026 16:09
@codecov
Copy link

codecov bot commented Mar 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.63%. Comparing base (a1a063b) to head (081b7a9).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1544      +/-   ##
==========================================
+ Coverage   93.61%   93.63%   +0.01%     
==========================================
  Files         491      494       +3     
  Lines       22019    22084      +65     
  Branches     1020     1020              
==========================================
+ Hits        20613    20678      +65     
  Misses       1253     1253              
  Partials      153      153              
Flag Coverage Δ
plugin-abnormal_lab_task_notification 100.00% <ø> (ø)
plugin-api_samples 33.33% <ø> (ø)
plugin-appointment_coverage_label 100.00% <ø> (ø)
plugin-coverage_metadata_sync 100.00% <ø> (ø)
plugin-my_first_plugin 100.00% <ø> (ø)
plugin-patient_summary_chart_groups 100.00% <ø> (ø)
plugin-preact_hello_world 100.00% <ø> (ø)
plugin-send_all_prescriptions 100.00% <ø> (ø)
plugin-simple_note_button_plugin 100.00% <ø> (ø)
plugin-supervising_provider_prescribe 100.00% <ø> (ø)
plugin-supervising_provider_prescribe_protocol 100.00% <ø> (ø)
plugin-upsert_patient_metadata 100.00% <ø> (ø)
plugin-vitals_visualizer_plugin 98.43% <ø> (ø)
py3.11 93.66% <100.00%> (+0.01%) ⬆️
py3.12 93.66% <100.00%> (+0.01%) ⬆️
sdk-core 93.66% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions github-actions bot added Jira: Linked PR body contains a Jira link PR: Conflicts labels Mar 3, 2026
@miguelquintas miguelquintas force-pushed the nuno/sdk-patient-groups branch from e18754c to 904f88d Compare March 9, 2026 15:10
nmpsilva and others added 5 commits March 12, 2026 09:17
^ Conflicts:
^	canvas_generated/messages/effects_pb2.py
^	canvas_generated/messages/effects_pb2.pyi
^	plugin_runner/allowed-module-imports.json
^	protobufs/canvas_generated/messages/effects.proto
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Jira: Linked PR body contains a Jira link

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants