Condition

Introduction #

The Condition model represents a clinical condition, problem, diagnosis, or other event, situation, issue, or clinical concept that has risen to a level of concern.

Basic usage #

To get a condition by identifier, use the get method on the Condition model manager:

from canvas_sdk.v1.data.condition import Condition

condition = Condition.objects.get(id="b80b1cdc-2e6a-4aca-90cc-ebc02e683f35")

If you have a patient object, the conditions for a patient can be accessed with the conditions attribute on a Patient object:

from canvas_sdk.v1.data.patient import Patient

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

If you have a patient ID, you can get the conditions for the patient with the for_patient method on the Condition model manager:

from canvas_sdk.v1.data.condition import Condition

patient_id = "1eed3ea2a8d546a1b681a2a45de1d790"
condition = Condition.objects.for_patient(patient_id)

Codings #

The codings for a condition can be accessed with the codings attribute on an Condition object:

from canvas_sdk.v1.data.condition import Condition
from logger import log

condition = Condition.objects.get(id="b80b1cdc-2e6a-4aca-90cc-ebc02e683f35")

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

Filtering #

Conditions can be filtered by any attribute that exists on the model.

Filtering for conditions is done with the filter method on the Condition model manager.

By attribute #

Specify an attribute with filter to filter by that attribute:

from canvas_sdk.v1.data.condition import Condition

conditions = Condition.objects.filter(onset_date__gte="2024-10-15")

By ValueSet #

Filtering by ValueSet works a little differently. The find method on the model manager is used to perform ValueSet filtering:

from canvas_sdk.v1.data.condition import Condition
from canvas_sdk.value_set.v022.condition import Diabetes

conditions = Condition.objects.find(Diabetes)