Effects

Effects are instructions that plugins can return in order to perform an action in the Canvas EMR. This makes it possible to define workflows that create commands, show notifications, modify search results, etc.

Effects have a type and a payload. The type determines the action that will be performed with the data provided in the payload.

Using Effects #

Effects are returned as a list from the compute method of a plugin that inherits from BaseHandler. For example:

import json

from canvas_sdk.events import EventType
from canvas_sdk.effects import Effect, EffectType
from canvas_sdk.handlers.base import BaseHandler

class Protocol(BaseHandler):
    RESPONDS_TO = EventType.Name(EventType.MEDICATION_STATEMENT__MEDICATION__POST_SEARCH)

    def compute(self):
        results = self.context.get("results")

        post_processed_results = []
        ## custom results-modifying code here
        ...

        return [
            Effect(
                type=EffectType.AUTOCOMPLETE_SEARCH_RESULTS,
                payload=json.dumps(post_processed_results),
            )
        ]

In the above example, the Effect object is constructed manually, with the type and payload set directly.

Some effects have helper classes that assist you by providing payload validation and constructing the effect object for you. The example below shows the PatientChartSummaryConfiguration class in use:

from canvas_sdk.events import EventType
from canvas_sdk.handlers.base import BaseHandler
from canvas_sdk.effects.patient_chart_summary_configuration import PatientChartSummaryConfiguration


class CustomChartLayout(BaseHandler):
    """
    This event handler rearranges the patient summary section and hides those
    not used by the installation's organization.
    """

    # This event fires when a patient's chart summary section is loading.
    RESPONDS_TO = EventType.Name(EventType.PATIENT_CHART_SUMMARY__SECTION_CONFIGURATION)

    def compute(self):
        layout = PatientChartSummaryConfiguration(sections=[
          PatientChartSummaryConfiguration.Section.SOCIAL_DETERMINANTS,
          PatientChartSummaryConfiguration.Section.ALLERGIES,
          PatientChartSummaryConfiguration.Section.VITALS,
          PatientChartSummaryConfiguration.Section.MEDICATIONS,
          PatientChartSummaryConfiguration.Section.CONDITIONS,
          PatientChartSummaryConfiguration.Section.IMMUNIZATIONS,
        ])

        return [layout.apply()]

Effect Classes #

Protocol Cards #

Calls to action in a patient's chart, commonly used for decision support intervention.

Banner Alerts #

Contextual information in a patient's chart.

Layout Effects #

Rearrange or hide summary sections in a patient's chart.

Tasks #

Create or update tasks.

Commands #

The building blocks of many end-user workflows in Canvas, including nearly all clinical workflows for documentation.

Effect Types #

The following effects are available to be applied in Canvas.

EffectDescription
ADD_BANNER_ALERTCan be used to add a banner alert to a patient’s chart.
REMOVE_BANNER_ALERTCan be used to remove a banner alert from a patient’s chart.
SHOW_PATIENT_CHART_SUMMARY_SECTIONSCan be used to reorder or hide the summary sections in a patient chart. Check out this effect class.
ADD_OR_UPDATE_PROTOCOL_CARDCan be used to generate a ProtocolCard in the Canvas UI. Use the ProtocolCard class in the effects module.
ANNOTATE_CLAIM_CONDITION_RESULTSCan be used to add annotations to the conditions appearing in a claim’s detail view.
ANNOTATE_PATIENT_CHART_CONDITION_RESULTSAdd an annotation to a condition within the patient summary.
AUTOCOMPLETE_SEARCH_RESULTSCan be used to modify search results by re-ordering or adding text annotations to individual result records. To see how you can put this to use, check out this guide.
PATIENT_PROFILE__ADD_PHARMACY__POST_SEARCH_RESULTSCan be used to modify pharmacy results when adding pharmacies in the patient profile.
CREATE_TASKCause a task you define in a plugin to be created.
UPDATE_TASKCause a task to be updated.
CREATE_TASK_COMMENTAdd a comment to an existing task.
ORIGINATE_ALLERGY_COMMANDCan be used to originate an allergy command in a note.
ORIGINATE_REMOVE_ALLERGY_COMMANDCan be used to originate a remove allergy command in a note.
ORIGINATE_GOAL_COMMANDCan be used to originate a goal command in a note.
ORIGINATE_UPDATE_GOAL_COMMANDCan be used to originate an update goal command in a note.
ORIGINATE_CLOSE_GOAL_COMMANDCan be used to originate a close goal command in a note.
ORIGINATE_DIAGNOSE_COMMANDCan be used to originate a diagnose command in a note.
ORIGINATE_UPDATE_DIAGNOSIS_COMMANDCan be used to originate an update diagnosis command in a note.
ORIGINATE_ASSESS_COMMANDCan be used to originate an assess command in a note.
ORIGINATE_PRESCRIBE_COMMANDCan be used to originate a prescribe command in a note.
ORIGINATE_REFILL_COMMANDCan be used to originate a refill command in a note.
ORIGINATE_MEDICATION_STATEMENT_COMMANDCan be used to originate a medication statement command in a note.
ORIGINATE_STOP_MEDICATION_COMMANDCan be used to originate a stop medication command in a note.
ORIGINATE_PLAN_COMMANDCan be used to originate a plan command in a note.
ORIGINATE_HPI_COMMANDCan be used to originate a history of present illness command in a note.
ORIGINATE_FAMILY_HISTORY_COMMANDCan be used to originate a family history command in a note.
ORIGINATE_MEDICAL_HISTORY_COMMANDCan be used to originate a medical history command in a note.
ORIGINATE_SURGICAL_HISTORY_COMMANDCan be used to originate a surgical history command in a note.
ORIGINATE_INSTRUCT_COMMANDCan be used to originate an instruct command in a note.
ORIGINATE_LAB_ORDER_COMMANDCan be used to originate a lab order command in a note.
ORIGINATE_PERFORM_COMMANDCan be used to originate a perform command in a note.
ORIGINATE_QUESTIONNAIRE_COMMANDCan be used to originate a questionnaire command in a note.
ORIGINATE_REASON_FOR_VISIT_COMMANDCan be used to originate a reason for visit command in a note.
ORIGINATE_TASK_COMMANDCan be used to originate a task command in a note.
ORIGINATE_VITALS_COMMANDCan be used to originate a vitals command in a note.