Group
Introduction #
The Group model gives you the stable external identifier Canvas uses to expose a Team or a PatientGroup as a single FHIR resource, so you can move between an SDK record and its FHIR representation without tracking a separate identifier yourself.
A Group is a stable external identifier that Canvas attaches through a generic relation — the content_type and object_id fields, the same pattern OrganizationalEntity uses — to either a Team or a PatientGroup, the record this reference calls the Group’s content object. This identifier is exactly what the FHIR Group endpoint exposes as its id. A Team surfaces as a FHIR Group of type practitioner, and a PatientGroup surfaces as a FHIR Group of type person.
Reach for Group when you hold a FHIR Group id — the stable external identifier — and need to resolve which SDK record it names, a Team or a PatientGroup. When you already have a Team in hand, its group_id is the shorter path, because it exposes the FHIR Group id directly.
Group exposes the linked record through typed property accessors, and the Group record itself is read-only; create or update the underlying FHIR Group through the FHIR API rather than an SDK effect.
Basic usage #
To follow a Group to the record it points at, retrieve the Group by id and read whichever typed property is set:
from canvas_sdk.v1.data import Group
group = Group.objects.get(id="d2194110-5c9a-4842-8733-ef09ea5ead11")
if group.team is not None:
linked = group.team
elif group.patient_group is not None:
linked = group.patient_group
else:
linked = None
For a Group whose content object is a Team, team returns the linked Team and patient_group is None. For a Group whose content object is a PatientGroup, patient_group returns the linked PatientGroup and team is None. When a Group is not backed by either type, both properties return None, so read whichever property is set rather than assuming one always resolves.
Attributes #
Group #
| Field Name | Type |
|---|---|
| id | UUID |
| dbid | Integer |
| created | DateTime |
| modified | DateTime |
| content_type | ContentType |
| object_id | Integer |
The object_id field holds the target record’s dbid — its internal integer identifier — rather than its id UUID.
Only two kinds of record get a Group, so content_type.model is always one of these two values. Read it to tell which one a Group points at, or use the typed properties below, which do the same check for you.
content_type.model | Content object |
|---|---|
team | Team |
patientgroup | PatientGroup |
Properties #
| Name | Type | Description |
|---|---|---|
| team | Team | None | The Team this group points at, or None when its content object is not a Team. |
| patient_group | PatientGroup | None | The PatientGroup this group points at, or None when its content object is not a PatientGroup. |