ProtocolOverride

Introduction #

The ProtocolOverride model represents an instance of a protocol being snoozed for a patient. The ProtocolOverrideSnoozeReason model represents a reason a protocol can be snoozed for.

Basic usage #

To get a protocol override by identifier, use the get method on the ProtocolOverride model manager:

from canvas_sdk.v1.data.protocol_override import ProtocolOverride

protocol_override = ProtocolOverride.objects.get(id="b80b1cdc-2e6a-4aca-90cc-ebc02e683f35")

If you have a patient object, the protocol overrides for a patient can be accessed with the protocol_overrides attribute on a Patient object:

from canvas_sdk.v1.data.patient import Patient

patient = Patient.objects.get(id="1eed3ea2a8d546a1b681a2a45de1d790")
overrides = patient.protocol_overrides.all()

If you have a patient ID, you can get the protocol overrides for the patient with the for_patient method on the ProtocolOverride model manager:

from canvas_sdk.v1.data.protocol_override import ProtocolOverride

patient_id = "1eed3ea2a8d546a1b681a2a45de1d790"
override = ProtocolOverride.objects.for_patient(patient_id)

Filtering #

Protocol overrides can be filtered by any attribute that exists on the model.

By attribute #

Specify an attribute with filter to filter by that attribute:

from canvas_sdk.v1.data.protocol_override import ProtocolOverride

overrides = ProtocolOverride.objects.filter(status="active")

Convenience methods #

The ProtocolOverride model manager includes convenience methods for the filters plugins most often apply when working with protocol overrides.

active returns the overrides whose status is active:

from canvas_sdk.v1.data.protocol_override import ProtocolOverride

active_overrides = ProtocolOverride.objects.active()

adjustments returns the adjustment overrides (is_adjustment=True) for a given protocol key, and snoozes returns the snooze overrides (is_snooze=True) for a given protocol key:

from canvas_sdk.v1.data.protocol_override import ProtocolOverride

adjustments = ProtocolOverride.objects.adjustments("HCC001v1")
snoozes = ProtocolOverride.objects.snoozes("HCC001v1")

Each method returns a queryset, so you can chain them with for_patient, committed, and with one another. For example, to get the active adjustments for a given patient and protocol key:

from canvas_sdk.v1.data.protocol_override import ProtocolOverride

adjustments = (
    ProtocolOverride.objects
    .for_patient("1eed3ea2a8d546a1b681a2a45de1d790")
    .committed()
    .active()
    .adjustments("HCC001v1")
)

Snooze reasons #

When a clinician snoozes a protocol, they choose a reason from a list that Canvas admins maintain. Each override’s reason attribute is the ProtocolOverrideSnoozeReason record for that choice. Use it to show or report why a protocol was snoozed:

from canvas_sdk.v1.data.protocol_override import ProtocolOverride

for override in ProtocolOverride.objects.snoozes("HCC001v1").select_related("reason"):
    print(override.reason.snooze_reason, override.reason.description)

Every override has a reason. When no reason was chosen, Canvas sets it to the reason whose snooze_reason is OTHER.

To list the reasons that clinicians can currently choose from, in the order Canvas shows them, filter ProtocolOverrideSnoozeReason by active:

from canvas_sdk.v1.data.protocol_override import ProtocolOverrideSnoozeReason

reasons = ProtocolOverrideSnoozeReason.objects.filter(active=True).order_by("sort")

To find the overrides that use a reason, use its overrides attribute:

from canvas_sdk.v1.data.protocol_override import ProtocolOverrideSnoozeReason

reason = ProtocolOverrideSnoozeReason.objects.get(snooze_reason="PATIENT_REFUSED")
refused = reason.overrides.filter(is_snooze=True)

Attributes #

ProtocolOverride #

Field NameType
idUUID
dbidInteger
createdDateTime
modifiedDateTime
deletedBoolean
committerCanvasUser
entered_in_errorCanvasUser
patientPatient
protocol_keyString
is_adjustmentBoolean
reference_dateDateTime
cycle_in_daysInteger
is_snoozeBoolean
snooze_dateDate
snoozed_daysInteger
reasonProtocolOverrideSnoozeReason
snooze_commentString
narrativeString
cycle_quantityInteger
cycle_unitIntervalUnit
statusStatus

ProtocolOverrideSnoozeReason #

Field NameTypeDescription
idUUIDUnique identifier for the snooze reason.
dbidIntegerDatabase identifier.
snooze_reasonStringUnique code for the reason, in capital letters and underscores, such as PATIENT_REFUSED.
descriptionStringThe label clinicians see when they choose a reason, such as Patient refused.
snomed_codeStringThe SNOMED CT code for the reason.
activeBooleanWhether clinicians can choose the reason when they snooze a protocol.
sortIntegerThe reason’s position in the list of choices.
overridesProtocolOverride[]The overrides that use this reason.

Enumeration types #

IntervalUnit #

ValueLabel
daysdays
monthsmonths
yearsyears

Status #

ValueLabel
activeactive
inactiveinactive