care.facility.models.patient_consultation module

class ConsentType(*values)

Bases: IntegerChoices

CONSENT_FOR_ADMISSION = 1
PATIENT_CODE_STATUS = 2
CONSENT_FOR_PROCEDURE = 3
OTHERS = 5
class PatientConsultation(id, external_id, created_date, modified_date, deleted, patient, patient_no, facility, deprecated_covid_category, category, examination_details, history_of_present_illness, treatment_plan, consultation_notes, course_in_facility, investigation, procedure, suggestion, route_to_facility, review_interval, referred_to, referred_to_external, transferred_from_location, referred_from_facility, referred_from_facility_external, referred_by_external, previous_consultation, is_readmission, admitted, encounter_date, icu_admission_date, discharge_date, discharge_reason, new_discharge_reason, discharge_notes, death_datetime, death_confirmed_doctor, bed_number, is_kasp, kasp_enabled_date, is_telemedicine, last_updated_by_telemedicine, assigned_to, medico_legal_case, deprecated_verified_by, treating_physician, created_by, last_edited_by, last_daily_round, current_bed, height, weight, operation, special_instruction, intubation_history, has_consents)

Bases: PatientBaseModel, ConsultationRelatedPermissionMixin

SUGGESTION_CHOICES = [('HI', 'HOME ISOLATION'), ('A', 'ADMISSION'), ('R', 'REFERRAL'), ('OP', 'OP CONSULTATION'), ('DC', 'DOMICILIARY CARE'), ('DD', 'DECLARE DEATH')]
REVERSE_SUGGESTION_CHOICES = {'A': 'ADMISSION', 'DC': 'DOMICILIARY CARE', 'DD': 'DECLARE DEATH', 'HI': 'HOME ISOLATION', 'OP': 'OP CONSULTATION', 'R': 'REFERRAL'}
patient

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

patient_no

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

facility

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

deprecated_covid_category

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

category

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

examination_details

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

history_of_present_illness

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

treatment_plan

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

consultation_notes

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

course_in_facility

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

investigation

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

procedure

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

suggestion

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

route_to_facility

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

review_interval

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

referred_to

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

referred_to_external

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

transferred_from_location

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

referred_from_facility

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

referred_from_facility_external

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

referred_by_external

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

previous_consultation

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

is_readmission

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

admitted

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

encounter_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

icu_admission_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

discharge_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

discharge_reason

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

new_discharge_reason

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

discharge_notes

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

death_datetime

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

death_confirmed_doctor

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

bed_number

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

is_kasp

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

kasp_enabled_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

is_telemedicine

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

last_updated_by_telemedicine

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

assigned_to

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

assigned_clinicians

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

deprecated_verified_by

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

treating_physician

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

created_by

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

last_edited_by

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

last_daily_round

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

current_bed

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

height

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

weight

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

operation

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

special_instruction

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

intubation_history

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

has_consents

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

CSV_MAPPING = {'category': 'Category', 'consultation_created_date': 'Date of Consultation', 'deprecated_covid_category': 'Covid Category', 'deprecated_symptoms': 'Symptoms at time of consultation', 'deprecated_symptoms_onset_date': 'Date of Onset of Symptoms', 'encounter_date': 'Date of Admission', 'examination_details': 'Examination Details', 'suggestion': 'Suggestion'}
CSV_MAKE_PRETTY = {'category': <function PatientConsultation.<lambda>>, 'deprecated_covid_category': <function PatientConsultation.<lambda>>, 'suggestion': <function PatientConsultation.<lambda>>}
save(*args, **kwargs)

Persist the consultation and sync related patient fields.

Currently this method updates the patient’s death_datetime if it changed here.

Historical logic that updated the patient’s facility on referral has been intentionally removed. For reference, the deprecated logic looked like this:

# Removed: Patient hospital change on referral
# if not self.pk or self.referred_to is not None:
#     # pk is None when the consultation is created
#     # referred_to is not null when the person is being referred
#     # to a new facility
#     self.patient.facility = self.referred_to or self.facility
#     self.patient.save()
static has_write_permission(request)
has_object_read_permission(request)
has_object_update_permission(request)
has_object_discharge_patient_permission(request)
has_object_email_discharge_summary_permission(request)
has_object_generate_discharge_summary_permission(request)
exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

assigned_to_id
consents

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

consultationbed_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

consultationclinician_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

created_by_id
created_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

current_bed_id
daily_rounds

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

deleted

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

diagnoses

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

events

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

external_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

facility_id
get_category_display(*, field=<django.db.models.fields.CharField: category>)
get_deprecated_covid_category_display(*, field=<django.db.models.fields.CharField: deprecated_covid_category>)
get_discharge_reason_display(*, field=<django.db.models.fields.CharField: discharge_reason>)
get_new_discharge_reason_display(*, field=<django.db.models.fields.SmallIntegerField: new_discharge_reason>)
get_next_by_encounter_date(*, field=<django.db.models.fields.DateTimeField: encounter_date>, is_next=True, **kwargs)
get_previous_by_encounter_date(*, field=<django.db.models.fields.DateTimeField: encounter_date>, is_next=False, **kwargs)
get_route_to_facility_display(*, field=<django.db.models.fields.SmallIntegerField: route_to_facility>)
get_suggestion_display(*, field=<django.db.models.fields.CharField: suggestion>)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

investigationvalue_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

last_daily_round_id
last_edited_by_id
modified_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

patient_id
patientconsultation_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

patientnotes_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

patientregistration_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

patientsample_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

prescription_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

previous_consultation_id
referred_from_facility_id
referred_to_id
symptoms

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

transferred_from_location_id
treating_physician_id
class PatientCodeStatusType(*values)

Bases: IntegerChoices

NOT_SPECIFIED = 0
DNH = 1
DNR = 2
COMFORT_CARE = 3
ACTIVE_TREATMENT = 4
class ConsultationClinician(id, consultation, clinician)

Bases: Model

consultation

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

clinician

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

clinician_id
consultation_id
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
class PatientConsent(id, external_id, created_date, modified_date, deleted, consultation, type, patient_code_status, archived, archived_by, archived_date, created_by, is_migrated)

Bases: BaseModel, ConsultationRelatedPermissionMixin

consultation

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

type

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

patient_code_status

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

archived

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

archived_by

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

archived_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

created_by

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

is_migrated

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

save(*args, **kwargs)
static has_write_permission(request)
has_object_read_permission(request)
has_object_update_permission(request)
exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

archived_by_id
consultation_id
created_by_id
created_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

deleted

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

external_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_patient_code_status_display(*, field=<django.db.models.fields.IntegerField: patient_code_status>)
get_type_display(*, field=<django.db.models.fields.IntegerField: type>)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

modified_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.