Invoice

Introduction #

The Invoice model represents a statement generated for a patient or their guarantor — who it was addressed to, what it totals, how it was sent, and where it stands. It is a read-only data model.

Invoices are produced by Canvas billing workflows rather than by plugins: automated statement runs, batch runs, and one-off statements each record their origin in workflow.

Basic Usage #

from canvas_sdk.v1.data import Invoice

invoice = Invoice.objects.get(dbid=42)

If you have a Patient object, the statements addressed to them are available through the invoices reverse relation:

from canvas_sdk.v1.data import Patient

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

A Claim points at the most recent statement it appeared on:

from canvas_sdk.v1.data import Claim

claim = Claim.objects.get(id="d2194110-5c9a-4842-8733-ef09ea5ead11")
invoice = claim.latest_invoice

Filtering #

from canvas_sdk.v1.data.invoice import Invoice, InvoiceStatus, InvoiceWorkflow

# Active statements only
active = Invoice.objects.filter(status=InvoiceStatus.ACTIVE)

# Statements a staff member generated one at a time, rather than by a batch or automated run
adhoc = Invoice.objects.filter(workflow=InvoiceWorkflow.ADHOC)

Invoice is addressed through recipient rather than a patient field, so filter on recipient to scope to one patient:

from canvas_sdk.v1.data import Invoice

invoices = Invoice.objects.filter(recipient__id="1eed3ea2a8d546a1b681a2a45de1d790")

Accessing the statement PDF #

Invoice holds the statement’s amounts and delivery details, not the rendered file. Canvas attaches the PDF to a DocumentReference, which you reach by resolving the ContentType for the invoice and matching object_id against the invoice’s dbid:

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

invoice = Invoice.objects.get(dbid=42)

content_type = ContentType.objects.filter(
    app_label="quality_and_revenue", model="invoicefull"
).first()

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

url = document.document_url if document else None

Attributes #

Invoice #

Field NameType
dbidInteger
originatorCanvasUser
recipientPatient
recipient_typeInvoiceRecipients
total_amountDecimal
statusInvoiceStatus
workflowInvoiceWorkflow
error_messageString
sent_meanInvoiceSentMeans

error_message carries the reason a statement failed to go out, and is empty for statements that did not fail.

Enumeration types #

InvoiceRecipients #

Who the statement was addressed to.

ValueLabel
patientPatient
guarantorGuarantor

InvoiceStatus #

ValueLabel
activeActive
errorError
archivedArchived

InvoiceWorkflow #

How the statement was produced.

ValueLabel
automatedAutomated
adhocAdhoc
batchBatch

InvoiceSentMeans #

ValueLabel
mailMail
e-mailE-mail