PatientConsent
Introduction #
The PatientConsent model represents documented patient consents in Canvas that ensure legal compliance and protect patient rights. Each PatientConsent is linked to a Patient, has a category (which is a PatientConsentCoding), and optionally a rejection reason (which is a PatientConsentRejectionCoding).
Usage #
The PatientConsent model can be used to find all of the patient consents for a given patient and organization:
>>> from canvas_sdk.v1.data import PatientConsent, Patient, Organization
>>> patient_1 = Patient.objects.get(id="aebe4d3f5d18410388dc69c4b5169fc3")
>>> organization_1 = Organization.objects.first()
>>> patient_1_consents = PatientConsent.objects.filter(patient=patient_1, organization=organization_1)
>>> print([consent.category.display for consent in patient_1_consents])
['Surgical Consent Form', 'Telehealth', 'HIPAA']
You can also access a patient’s consents from the Patient model:
>>> from canvas_sdk.v1.data import PatientConsent, Patient
>>> patient_1 = Patient.objects.get(id="aebe4d3f5d18410388dc69c4b5169fc3")
>>> patient_1_consents = patient_1.patient_consent.all()
>>> print([consent.category.display for consent in patient_1_consents])
['Surgical Consent Form', 'Telehealth', 'HIPAA']
And you can also access all of the PatientConsents for a given PatientConsentCoding (aka category):
>>> from canvas_sdk.v1.data import PatientConsentCoding
>>> coding = PatientConsentCoding.objects.get(code='59284-0', system='LOINC')
>>> consents = coding.patient_consent.all()
>>> print([consent.state for consent in consents])
['accepted', 'accepted_via_patient_portal', 'rejected']
Each PatientConsentCoding has a document field containing the URL to the consent template document:
>>> from canvas_sdk.v1.data import PatientConsentCoding
>>> coding = PatientConsentCoding.objects.first()
>>> print(coding.document)
'consent_templates/hipaa_consent.pdf'
Accessing Document Files #
The document_url property returns a presigned S3 URL for securely accessing the blank consent template — the form you send to a patient to collect their consent. The copy the patient signs and returns is a separate record; see Signed consent documents.
from canvas_sdk.v1.data import PatientConsentCoding
consent_coding = PatientConsentCoding.objects.first()
# Returns a presigned S3 URL (valid for 1 hour)
url = consent_coding.document_url
Signed consent documents #
The PatientConsentCoding.document above is the blank template sent to the patient. The signed documents the patient completes and returns are PatientAdministrativeDocument records, reachable from the consent through the documents relation:
from canvas_sdk.v1.data import PatientConsent
consent = PatientConsent.objects.get(id="8a2b1c3d-4e5f-6a7b-8c9d-0e1f2a3b4c5d")
# Every signed document attached to this consent.
signed_documents = consent.documents.all()
# The current signed document (the most recent non-junked one), or None.
current = consent.active_document
Each signed document’s FHIR DocumentReference is reachable through document_references, so a plugin can read the reference (and its related_object) in-process without a FHIR call:
from canvas_sdk.v1.data import PatientConsent
consent = PatientConsent.objects.get(id="8a2b1c3d-4e5f-6a7b-8c9d-0e1f2a3b4c5d")
for reference in consent.document_references:
url = reference.document_url
Attributes #
PatientConsent #
| Field Name | Type |
|---|---|
| id | UUID |
| dbid | Integer |
| patient | Patient |
| category | PatientConsentCoding |
| state | PatientConsentStatus |
| effective_date | DateTime |
| expired_date | DateTime |
| rejection_reason | PatientConsentRejectionCoding |
| originator | CanvasUser |
| documents | QuerySet[PatientAdministrativeDocument] — the signed consent documents |
| active_document | PatientAdministrativeDocument (property) — the current signed document, or None |
| document_references | QuerySet[DocumentReference] (property) — references for the signed documents |
PatientConsentCoding #
| Field Name | Type |
|---|---|
| dbid | Integer |
| system | String |
| version | String |
| code | String |
| display | String |
| user_selected | Boolean |
| expiration_rule | PatientConsentExpirationRule |
| is_mandatory | Boolean |
| is_proof_required | Boolean |
| show_in_patient_portal | Boolean |
| summary | String |
| document | String |
| document_url | String (property) — presigned S3 URL |
| patient_consent | QuerySet[PatientConsent] |
PatientConsentRejectionCoding #
| Field Name | Type |
|---|---|
| dbid | Integer |
| system | String |
| version | String |
| code | String |
| display | String |
| user_selected | Boolean |
| patient_consents | QuerySet[PatientConsent] |
Enumeration types #
PatientConsentStatus #
| Value | Label |
|---|---|
| accepted | Accepted |
| accepted_via_patient_portal | Accepted Via Patient Portal |
| rejected | Rejected |
| rejected_via_patient_portal | Rejected Via Patient Portal |
PatientConsentExpirationRule #
| Value | Label |
|---|---|
| never | Never |
| in_one_year | In one year |
| end_of_year | End of year |