Imaging

Introduction #

The ImagingOrder, ImagingCoding, ImagingReview, ImagingReport, and ImagingReportCoding models represent imaging orders and results.

Basic Usage #

To retrieve an ImagingOrder, ImagingReview, or ImagingReport by identifier, use the get method on the model manager:

from canvas_sdk.v1.data.imaging import ImagingOrder, ImagingReview, ImagingReport

imaging_order = ImagingOrder.objects.get(id="d2194110-5c9a-4842-8733-ef09ea5ead11")
imaging_review = ImagingReview.objects.get(id="c02c6b02-2581-46bf-819c-b5aacad2134c")
imaging_report = ImagingReport.objects.get(id="c1a5a35a-4ee2-4a0e-85c0-21739dc8c4a8")

If you have a patient object, the orders, reviews, and reports can be accessed with the imaging_orders, imaging_reviews, and imaging_results attributes, respectively on a Patient object:

from canvas_sdk.v1.data.patient import Patient

patient = Patient.objects.get(id="1eed3ea2a8d546a1b681a2a45de1d790")
orders = patient.imaging_orders.all()
reviews = patient.imaging_reviews.all()
reports = patient.imaging_results.all()

Filtering #

Imaging orders, reviews, and reports can be filtered by any attribute that exists on the models.

Filtering is done with the filter method on the ImagingOrder, ImagingReview, and ImagingReport model managers.

By attribute #

Specify an attribute with filter to filter by that attribute:

from canvas_sdk.v1.data.imaging import ImagingOrder, ImagingReview, ImagingReport

orders = ImagingOrder.objects.filter(status="completed")
reviews = ImagingReview.objects.filter(is_released_to_patient=False)
reports = ImagingReport.objects.filter(requires_signature=True)

By ValueSet #

See Value Sets for the library of built-in value sets and how to create your own.

ImagingReport supports ValueSet filtering through the find method on its model manager:

from canvas_sdk.v1.data.imaging import ImagingReport
from canvas_sdk.value_set.v2022.diagnostic_study import Mammography

reports = ImagingReport.objects.find(Mammography)

find joins through the report’s codings reverse relation and matches on (system, code) pairs from the value set, so a coding must match both the code system and the code to be included.

Committed records #

The committed method returns ImagingOrder and ImagingReview records that have been committed and not entered in error:

from canvas_sdk.v1.data.imaging import ImagingOrder, ImagingReview

committed_orders = ImagingOrder.objects.committed()
committed_reviews = ImagingReview.objects.committed()

Imaging order codings #

The codings of the imaging ordered on an imaging order can be accessed with the codings attribute on an ImagingOrder object:

from canvas_sdk.v1.data.imaging import ImagingOrder
from logger import log

imaging_order = ImagingOrder.objects.get(id="d2194110-5c9a-4842-8733-ef09ea5ead11")

for coding in imaging_order.codings.all():
    log.info(f"system:  {coding.system}")
    log.info(f"code:    {coding.code}")
    log.info(f"display: {coding.display}")

Related Tasks #

To retrieve an Imaging Order’s related tasks, use the get_task_objects method on the ImagingOrder object.

from canvas_sdk.v1.data.imaging import ImagingOrder

imaging_order = ImagingOrder.objects.get(id="d2194110-5c9a-4842-8733-ef09ea5ead11")
tasks = imaging_order.get_task_objects().all()

The task_list computed property returns the same related tasks as a list[Task]:

from canvas_sdk.v1.data.imaging import ImagingOrder

imaging_order = ImagingOrder.objects.get(id="d2194110-5c9a-4842-8733-ef09ea5ead11")
tasks = imaging_order.task_list

Accessing the report file #

The document_url property on ImagingReport returns a presigned S3 URL for securely accessing the report’s file. The URL is valid for one hour and is regenerated on each access, so don’t persist or cache it. If the report has no associated file, document_url returns None.

from canvas_sdk.v1.data.imaging import ImagingReport

imaging_report = ImagingReport.objects.get(id="c1a5a35a-4ee2-4a0e-85c0-21739dc8c4a8")

# Presigned S3 URL to the report file, or None if the report has no file
url = imaging_report.document_url

The latest annotated version #

When staff annotate or sign an imaging report in Canvas, Canvas saves the result as a new PDF in a DocumentAnnotation and leaves the original file unchanged. The newest annotation is the version Canvas shows. document_url returns the original report file, so look for an annotation first and fall back to document_url when there’s none.

Find the annotations through the annotation’s link to its document: resolve the ContentType at runtime from its stable app_label and model, never the per-environment dbid, and match object_id against the report’s dbid. Annotations made in Data Integration before the report was filed are linked to the report when it’s filed, so the same lookup finds them.

from canvas_sdk.v1.data import ContentType, DocumentAnnotation, ImagingReport

imaging_report = ImagingReport.objects.get(id="c1a5a35a-4ee2-4a0e-85c0-21739dc8c4a8")

content_type = ContentType.objects.filter(app_label="api", model="imagingreport").first()

latest = (
    DocumentAnnotation.objects.filter(content_type=content_type, object_id=imaging_report.dbid)
    .order_by("created")
    .last()
)

# The version Canvas shows: the newest annotation, else the original report file
url = latest.document_url if latest else imaging_report.document_url

Accessing the imaging order PDF #

The document_url property on ImagingOrder returns a presigned S3 URL for the order’s PDF, or None when the order has none. Canvas saves the PDF the first time the order is faxed. Printing the order doesn’t save it, so an order that has never been faxed has no file. The URL is valid for one hour, so generate it when you need it rather than storing it.

from canvas_sdk.v1.data.imaging import ImagingOrder

imaging_order = ImagingOrder.objects.get(id="d2194110-5c9a-4842-8733-ef09ea5ead11")

# Presigned S3 URL to the order PDF, or None if no PDF has been saved
url = imaging_order.document_url

Review assignment #

An imaging report is assigned for review to staff members or to a team. reviewers holds the assigned staff members, and team holds the assigned team, or None when no team is assigned.

from canvas_sdk.v1.data import ImagingReport, Staff

imaging_report = ImagingReport.objects.get(id="c1a5a35a-4ee2-4a0e-85c0-21739dc8c4a8")

# The staff members and the team the imaging report is assigned to
reviewers = imaging_report.reviewers.all()
team = imaging_report.team

# Every imaging report assigned to this staff member
staff = Staff.objects.get(id="4150cd20de8a470aa570a852859ac87e")
assigned = ImagingReport.objects.filter(reviewers__id=staff.id)

Delegations #

When staff send an imaging report to a provider for signature, Canvas records a DocumentReviewDelegation. It records another when the provider signs the report and Canvas returns it. The delegations for an imaging report are available through two accessors:

from canvas_sdk.v1.data import ImagingReport

imaging_report = ImagingReport.objects.get(id="c1a5a35a-4ee2-4a0e-85c0-21739dc8c4a8")

# The full delegation history, oldest first.
history = imaging_report.delegations

# The active delegation, or None when no delegation is in effect.
current = imaging_report.active_delegation

For the report’s full timeline, including reassignments, comments, and signatures, see DocumentHistoryEvent.

The document reference #

A report that has a file also has a DocumentReference pointing back at it — the record that carries the report’s document coding, category, and status, and that represents it in the FHIR API. document_url above is the direct route to the file itself; reach for the document reference when you want that surrounding metadata.

Resolve the ContentType at runtime from its stable app_label and model — never hardcode the per-environment dbid — and match object_id against the report’s dbid:

from canvas_sdk.v1.data import ContentType, DocumentReference, ImagingReport

imaging_report = ImagingReport.objects.get(id="c1a5a35a-4ee2-4a0e-85c0-21739dc8c4a8")

content_type = ContentType.objects.filter(app_label="api", model="imagingreport").first()

document = DocumentReference.objects.filter(
    content_type=content_type, object_id=imaging_report.dbid
).first()

Attributes #

ImagingOrder #

Field NameType
idUUID
dbidInteger
createdDateTime
modifiedDateTime
originatorCanvasUser
committerCanvasUser
entered_in_errorCanvasUser
patientPatient
noteNote
assessmentAssessment
assessmentsAssessment[]
imagingString
imaging_centerServiceProvider
note_to_radiologistString
internal_commentString
statusOrderStatus
date_time_orderedDateTime
ordering_providerStaff
priorityString
delegatedBoolean
documentFile (S3 key)
document_urlString (computed)
task_idsString
resultsImagingReport[]
action_eventsImagingOrderActionEvent[]
codingsImagingCoding[]

ImagingCoding #

Field NameType
dbidInteger
createdDateTime
modifiedDateTime
systemString
versionString
codeString
displayString
user_selectedBoolean
imaging_orderImagingOrder

An imaging order has two relations to assessments:

  • assessment is the assessment the order is linked to through its assessment_id. Its reverse is linked_imaging_orders on Assessment.
  • assessments holds the assessments for the conditions selected as the order’s indications. Its reverse is imaging_orders on Assessment.

ImagingOrderAssessment #

The join behind assessments. Reach an order’s assessments through its assessments attribute rather than querying this model.

from canvas_sdk.v1.data.imaging import ImagingOrder

imaging_order = ImagingOrder.objects.get(id="c1a5a35a-4ee2-4a0e-85c0-21739dc8c4a8")

# The conditions selected as the order's indications
indications = [
    assessment.condition
    for assessment in imaging_order.assessments.select_related("condition")
    if assessment.condition
]
Field NameType
dbidInteger
imaging_orderImagingOrder
assessmentAssessment

ImagingReview #

Field NameType
idUUID
dbidInteger
createdDateTime
modifiedDateTime
originatorCanvasUser
committerCanvasUser
entered_in_errorCanvasUser
patient_communication_methodReviewPatientCommunicationMethod
internal_commentString
message_to_patientString
is_released_to_patientBoolean
statusReviewStatus
noteNote
patientPatient

ImagingReport #

Field NameTypeDescription
idUUID 
dbidInteger 
createdDateTime 
modifiedDateTime 
review_modeDocumentReviewMode 
junkedBoolean 
requires_signatureBoolean 
assigned_dateDateTime 
assigned_byCanvasUser 
reviewersStaff[] 
teamTeam 
team_assigned_dateDateTime 
patientPatient 
orderImagingOrder 
sourceImagingReportSource 
nameString 
result_dateDate 
original_dateDate 
reviewImagingReview 
document_urlString (computed)Presigned S3 URL, or None if the report has no file
codingsImagingReportCoding[] 
delegationsDocumentReviewDelegation[] (computed)The report’s delegations, oldest first
active_delegationDocumentReviewDelegation (computed)The delegation in effect, or None

ImagingReportCoding #

Field NameType
dbidInteger
createdDateTime
modifiedDateTime
reportImagingReport
systemString
versionString
codeString
displayString
user_selectedBoolean
valueString

Enumeration types #

ImagingReportSource #

ValueLabel
RADIOLOGY_PATIENTRadiology Report From Patient
VERBAL_PATIENTVerbal Report From Patient
DIRECTLY_RADIOLOGYDirectly Radiology Report