Note

Introduction #

The Note model represents clinical notes that appear on a patient’s chart. A Note can contain multiple commands.

Basic usage #

Retrieve a specific note #

To get a note by identifier, use the get method on the Note model manager:

from canvas_sdk.v1.data.note import Note

note = Note.objects.get(id="89992c23-c298-4118-864a-26cb3e1ae822")

Find all notes for a patient #

If you have a patient object, the notes for a patient can be found using the notes attribute on the Patient instance:

from canvas_sdk.v1.data.patient import Patient

patient = Patient.objects.get(id="fd2ecd87c26044a6a755287f296dd17f")
patient_notes = patient.notes.all()

Retrieve the audit history for a note #

The audit history for a note can be found using the NoteStateChangeEvent model. You can access this model directly or through the state_history relation on the note object.

from canvas_sdk.v1.data.note import Note, NoteStateChangeEvent

note = Note.objects.first()

# Use the state_history relation
option_1 = note.state_history.all()

# Use the note object to filter the QuerySet
option_2 = NoteStateChangeEvent.objects.filter(note=note)

# Use the note's UUID to filter the QuerySet, which joins to the note table
# where the note's dbid column is equal to the note_id column of the note
# state change event and the note's id column is equal to the note's UUID.
option_3 = NoteStateChangeEvent.objects.filter(note__id=note.id)

# Use the note's auto-increment database id to filter the QuerySet by the
# foreign key column without joining to the notes table.
option_4 = NoteStateChangeEvent.objects.filter(note_id=note.dbid)

In the above code sample, options 1, 2, and 4 produce identical SQL queries.

Determine if a note is locked #

To see if a note is presently locked, you can use the CurrentNoteStateEvent model to check if the current note state is ‘Locked’. (See: NoteState for an explanation of the different note states you might encounter)

from canvas_sdk.v1.data.note import Note, CurrentNoteStateEvent, NoteStates

note = Note.objects.first()

# You can retrieve the CurrentNoteStateEvent record for the note and check its
# state attribute.
if CurrentNoteStateEvent.objects.get(note=note).state == NoteStates.LOCKED:
    # This note is locked!
    pass

# You can skip retrieving the record by just checking if a
# CurrentNoteStateEvent record exists for that note with the state 'Locked'.
if CurrentNoteStateEvent.objects.filter(note=note, state=NoteStates.LOCKED).exists():
    # This note is locked!
    pass

Find all open notes #

You can find all open notes by retrieving the note records with a current state which indicates it can be edited. (See list below)

from canvas_sdk.v1.data.note import Note, CurrentNoteStateEvent, NoteStates

open_note_states = [
    NoteStates.NEW,
    NoteStates.PUSHED,
    NoteStates.UNLOCKED,
    NoteStates.RESTORED,
    NoteStates.UNDELETED,
]

# This will execute one query per CurrentNoteStateEvent object returned
open_notes_via_list_comprehension = [event.note for event in CurrentNoteStateEvent.objects.filter(state__in=open_note_states)]

# This will always execute two queries: one to find the note ids of open
# notes, and a second query to fetch the note records by the ids returned in the
# first query
open_note_ids = CurrentNoteStateEvent.objects.filter(state__in=open_note_states).values_list('note_id', flat=True)
open_notes_via_multiple_queries = Note.objects.filter(dbid__in=open_note_ids)

Get the current state of a given note #

To get a note’s current state, retrieve its CurrentNoteStateEvent and check the state attribute.

from canvas_sdk.v1.data.note import Note, CurrentNoteStateEvent

note = Note.objects.first()

current_note_state = CurrentNoteStateEvent.objects.get(note=note).state

Filtering #

By attribute #

Notes can also be filtered by attribute. For example, to get all notes for a patient where the datetime_of_service is after a certain date, the following code can be used:

import arrow

from canvas_sdk.v1.data.note import Note
from canvas_sdk.v1.data.patient import Patient

patient = Patient.objects.get(id="fd2ecd87c26044a6a755287f296dd17f")
recent_notes = Note.objects.filter(
    patient=patient,
    datetime_of_service__gte=arrow.now().shift(weeks=-3).datetime
)

The NoteType model can also be used to find notes by type.

from canvas_sdk.v1.data.note import NoteType
from canvas_sdk.v1.data.patient import Patient

note_type = NoteType.objects.get(name="Office visit")
patient = Patient.objects.get(id="fd2ecd87c26044a6a755287f296dd17f")
patient_office_visits = Note.objects.filter(patient=patient, note_type_version=note_type)

All of the commands in a Note can be found by using the commands attribute:

from canvas_sdk.v1.data.note import Note

note = Note.objects.get(id="89992c23-c298-4118-864a-26cb3e1ae822")
commands_in_note = Note.commands.all()

Attributes #

Note #

Field NameTypeNotes
idUUID 
dbidInteger 
createdDateTime 
modifiedDateTime 
patientPatient 
note_type_versionNoteType 
titleString 
bodyJSON 
originatorCanvasUser 
providerStaff 
checksumString 
billing_noteString 
related_dataJSONCan contain one key, roomNumber, if the Note is an inpatient stay.
datetime_of_serviceDateTime 
place_of_serviceString 

NoteType #

Field NameType
dbidInteger
createdDateTime
modifiedDateTime
systemString
versionString
codeString
displayString
user_selectedBoolean
nameString
iconString
categoryNoteTypeCategories
rankInteger
is_default_appointment_typeBoolean
is_scheduleableBoolean
is_telehealthBoolean
is_billableBoolean
defer_place_of_service_to_practice_locationBoolean
available_places_of_serviceArray[PracticeLocationPOS]
default_place_of_servicePracticeLocationPOS
is_system_managedBoolean
is_visibleBoolean
is_activeBoolean
unique_identifierUUID
deprecated_atDateTime
is_patient_requiredBoolean
allow_custom_titleBoolean

NoteStateChangeEvent #

Field NameType
idUUID
dbidInteger
createdDateTime
modifiedDateTime
noteNote
originatorCanvasUser
stateNoteState
note_state_documentString
note_state_htmlString

CurrentNoteStateEvent #

Field NameType
idUUID
dbidInteger
stateNoteState
noteNote

Enumeration types #

NoteStates #

ValueDescriptionNotes
NEWCreated 
PSHPushed the charges for 
LKDLocked 
ULKUnlocked 
DLTDeleted 
RLKRelocked 
RSTRestored 
RCLRecalled 
UNDUndeleted 
DSCDischarged 
SCHSchedulingUsed in appointment notes
BKDBookedUsed in appointment notes
CVDConvertedUsed in appointment notes
CLDCanceledUsed in appointment notes
NSWNo showUsed in appointment notes
RVTRevertedUsed in appointment notes
CNFConfirmedUsed for CCDA import notes

NoteTypeCategories #

ValueDescription
messageMessage
letterLetter
inpatientInpatient Visit Note
reviewChart Review Note
encounterEncounter Note
appointmentAppointment Note
taskTask
dataData
ccdaC-CDA
schedule_eventSchedule Event

PracticeLocationPOS #

ValueDescription
01Pharmacy
02Telehealth
03Education Facility
04Homeless Shelter
09Prison
10Telehealth in Patient’s Home
11Office
12Home
13Asssisted Living Facility
14Group Home
15Mobile Unit
17Walk-In Retail Health Clinic
19Off-Campus Outpatient Hospital
20Urgent Care Facility
21Inpatient Hospital
22On-Campus Outpatient Hospital
23Emergency Room Hospital
24Ambulatory Surgery Center
25Birthing Center
26Military Treatment Facility
27Outreach Site / Street
31Skilled Nursing Facility
32Nursing Facility
33Custodial Care Facility
34Hospice
41Ambulance Land
42Ambulance Air or Water
49Independent Clinic
50Federally Qualified Health Center
51Inpatient Psychiatric Facility
52Inpatient Psychiatric Facility - Partial Hospitalization
53Community Mental Health Center
54Intermediate Care Facility for Mentally Retarded
55Residential Substance Abuse Treatment Facility
56Psychiatric Residential Treatment Center
57Non-Residential Substance Abuse Treatment Facility
60Mass Immunization Center
61Inpatient Rehabilitation Facility
62Outpatient Rehabilitation Facility
65End-Stage Renal Disease Treatment Facility
71State or Local Public Health Clinic
72Rural Health Clinic
81Independent Laboratory
99Other Place of Service