core package

Subpackages

Submodules

core.admin module

core.apps module

class core.apps.CoreConfig(app_name, app_module)[source]

Bases: AppConfig

default_auto_field = 'django.db.models.BigAutoField'
name = 'core'

core.models module

Module for models in the healthcare system

class core.models.Doctor(*args, **kwargs)[source]

Bases: AbstractUser

Model for representing a doctor in the healthcare system.

Extends the Django User model to support AGID authentication and adds fields specific to the medical profession.

Variables:
  • doctor_id – Unique UUID identifier for the doctor

  • specialization – Medical specialization of the doctor

  • department – Department to which the doctor belongs

  • license_number – Medical license number

  • is_emergency_doctor – Flag for emergency doctor authorization

  • created_at – Timestamp for record creation

  • last_login_at – Timestamp for last login

doctor_id

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

specialization

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

department

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

license_number

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

is_emergency_doctor

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

created_at

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

last_login_at

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

__str__()[source]

String representation of the Doctor model.

Returns:

String with doctor’s title, name, and specialization

Return type:

str

get_full_name()[source]

Returns the full name of the doctor with professional title.

Returns:

Full name formatted with title “Dr.”

Return type:

str

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

clinicaldata_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.

clinicalreport_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.

date_joined

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

email

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

encounters

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.

first_name

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

get_next_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=True, **kwargs)
get_next_by_date_joined(*, field=<django.db.models.fields.DateTimeField: date_joined>, is_next=True, **kwargs)
get_previous_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=False, **kwargs)
get_previous_by_date_joined(*, field=<django.db.models.fields.DateTimeField: date_joined>, is_next=False, **kwargs)
groups

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.

id

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

is_active

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

is_staff

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

is_superuser

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

last_login

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

last_name

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

logentry_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.

password

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

user_permissions

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.

username

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

class core.models.Patient(*args, **kwargs)[source]

Bases: Model

Model for representing a patient with essential demographic and clinical data.

Contains all the information necessary to uniquely identify a patient and manage their basic clinical data within the healthcare system.

Variables:
  • patient_id – Unique UUID identifier for the patient

  • first_name – First name of the patient

  • last_name – Last name of the patient

  • date_of_birth – Date of birth of the patient

  • place_of_birth – Place of birth of the patient

  • fiscal_code – Fiscal code of the patient (optional)

  • gender – Gender of the patient (‘M’, ‘F’, ‘O’)

  • phone – Phone number of the patient (optional)

  • emergency_contact – Emergency contact (optional)

  • weight – Weight of the patient in kg (optional)

  • height – Height of the patient in cm (optional)

  • blood_type – Blood type of the patient (optional)

  • allergies – Allergies notes of the patient (optional)

  • created_at – Timestamp of record creation

  • updated_at – Timestamp of last update

GENDER_CHOICES = [('M', 'Maschio'), ('F', 'Femmina'), ('O', 'Altro')]
patient_id

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

first_name

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

last_name

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

date_of_birth

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

place_of_birth

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

fiscal_code

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

gender

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

phone

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

emergency_contact

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.

height

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

blood_type

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

allergies

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

created_at

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

updated_at

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

__str__()[source]

String representation of the Patient model.

Returns:

String with patient’s name and fiscal code

Return type:

str

property age

Calculate the patient’s age in years as of the current date.

Returns:

Patient’s age in years

Return type:

int

get_full_name()[source]

Return the full name of the patient.

Returns:

Full name of the patient

Return type:

str

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

encounters

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.

get_gender_display(*, field=<django.db.models.fields.CharField: gender>)
get_next_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=True, **kwargs)
get_next_by_date_of_birth(*, field=<django.db.models.fields.DateField: date_of_birth>, is_next=True, **kwargs)
get_next_by_updated_at(*, field=<django.db.models.fields.DateTimeField: updated_at>, is_next=True, **kwargs)
get_previous_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=False, **kwargs)
get_previous_by_date_of_birth(*, field=<django.db.models.fields.DateField: date_of_birth>, is_next=False, **kwargs)
get_previous_by_updated_at(*, field=<django.db.models.fields.DateTimeField: updated_at>, is_next=False, **kwargs)
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 core.models.Encounter(*args, **kwargs)[source]

Bases: Model

Encounter model for episodes of care in the Emergency Room

Variables:
  • encounter_id (models.UUIDField) – Unique UUID identifier for the encounter

  • patient (models.ForeignKey) – Reference to the Patient involved in the encounter

  • doctor (models.ForeignKey) – Reference to the Doctor managing the encounter

  • admission_time (models.DateTimeField) – Timestamp of patient admission

  • chief_complaint (models.TextField) – Chief complaint reported at admission

  • triage_priority (models.CharField) – Triage priority code assigned at admission

  • status (models.CharField) – Current status of the encounter

  • discharge_time (models.DateTimeField) – Timestamp of patient discharge (optional)

  • created_at (models.DateTimeField) – Timestamp of record creation

  • updated_at (models.DateTimeField) – Timestamp of last update

STATUS_CHOICES = [('in_progress', 'In corso'), ('completed', 'Completato'), ('cancelled', 'Annullato')]
PRIORITY_CHOICES = [('white', 'Codice Bianco'), ('green', 'Codice Verde'), ('yellow', 'Codice Giallo'), ('red', 'Codice Rosso'), ('black', 'Codice Nero')]
encounter_id

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

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.

doctor

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.

admission_time

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

chief_complaint

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

triage_priority

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

status

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

discharge_time

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

created_at

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

updated_at

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

__str__()[source]

String representation of the Encounter model.

Returns:

String with encounter ID, patient name, and admission time

Return type:

str

property duration

Calculates the duration of the encounter in minutes

Returns:

Duration in minutes

Return type:

float

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

doctor_id
get_next_by_admission_time(*, field=<django.db.models.fields.DateTimeField: admission_time>, is_next=True, **kwargs)
get_next_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=True, **kwargs)
get_next_by_updated_at(*, field=<django.db.models.fields.DateTimeField: updated_at>, is_next=True, **kwargs)
get_previous_by_admission_time(*, field=<django.db.models.fields.DateTimeField: admission_time>, is_next=False, **kwargs)
get_previous_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=False, **kwargs)
get_previous_by_updated_at(*, field=<django.db.models.fields.DateTimeField: updated_at>, is_next=False, **kwargs)
get_status_display(*, field=<django.db.models.fields.CharField: status>)
get_triage_priority_display(*, field=<django.db.models.fields.CharField: triage_priority>)
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>
patient_id
reports

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.

transcripts

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.

class core.models.AudioTranscript(*args, **kwargs)[source]

Bases: Model

Model for audio transcripts of encounters

Variables:
  • transcript_id (models.UUIDField) – Unique UUID identifier for the transcript

  • encounter (models.ForeignKey) – Reference to the associated Encounter

  • audio_file (models.FileField) – Uploaded audio file

  • audio_duration (models.FloatField) – Duration of the audio in seconds

  • transcript_text (models.TextField) – Transcribed text from the audio

  • confidence_score (models.FloatField) – Confidence score of the transcription

  • language (models.CharField) – Language code of the audio

  • status (models.CharField) – Current status of the transcription process

  • error_message (models.TextField) – Error message if transcription failed

  • created_at (models.DateTimeField) – Timestamp of record creation

  • updated_at (models.DateTimeField) – Timestamp of last update

  • transcription_completed_at (models.DateTimeField) – Timestamp when transcription was completed

STATUS_CHOICES = [('pending', 'In attesa'), ('transcribing', 'Trascrizione in corso'), ('completed', 'Completato'), ('error', 'Errore')]
transcript_id

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

encounter

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.

audio_file

The descriptor for the file attribute on the model instance. Return a FieldFile when accessed so you can write code like:

>>> from myapp.models import MyModel
>>> instance = MyModel.objects.get(pk=1)
>>> instance.file.size

Assign a file object on assignment so you can do:

>>> with open('/path/to/hello.world') as f:
...     instance.file = File(f)
audio_duration

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

transcript_text

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

confidence_score

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

language

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

status

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

error_message

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

created_at

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

updated_at

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

transcription_completed_at

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

__str__()[source]

String representation of the AudioTranscript model.

Returns:

String with transcript ID and associated encounter

Return type:

str

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

clinical_data

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

encounter_id
get_next_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=True, **kwargs)
get_next_by_updated_at(*, field=<django.db.models.fields.DateTimeField: updated_at>, is_next=True, **kwargs)
get_previous_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=False, **kwargs)
get_previous_by_updated_at(*, field=<django.db.models.fields.DateTimeField: updated_at>, is_next=False, **kwargs)
get_status_display(*, field=<django.db.models.fields.CharField: status>)
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 core.models.ClinicalData(*args, **kwargs)[source]

Bases: Model

Model for clinical data extracted from the transcription

Variables:
  • transcript (models.OneToOneField) – Reference to the associated AudioTranscript

  • patient_name (models.CharField) – Extracted patient name

  • patient_age (models.IntegerField) – Extracted patient age

  • codice_fiscale (models.CharField) – Extracted fiscal code

  • patient_gender (models.CharField) – Extracted patient gender

  • chief_complaint (models.TextField) – Extracted chief complaint

  • history_present_illness (models.TextField) – Extracted history of present illness

  • past_medical_history (models.JSONField) – Extracted past medical history

  • medications (models.JSONField) – Extracted current medications

  • allergies (models.JSONField) – Extracted allergies

  • vital_signs (models.JSONField) – Extracted vital signs

  • physical_examination (models.JSONField) – Extracted physical examination findings

  • assessment (models.TextField) – Extracted assessment

  • diagnosis (models.JSONField) – Extracted diagnosis

  • treatment_plan (models.TextField) – Extracted treatment plan

  • confidence_score (models.FloatField) – Confidence score of the extraction

  • extracted_at (models.DateTimeField) – Timestamp when data was extracted

  • validated (models.BooleanField) – Flag indicating if data has been validated

  • validated_by (models.ForeignKey) – Reference to the Doctor who validated the data (optional)

transcript

Accessor to the related object on the forward side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Restaurant.place is a ForwardOneToOneDescriptor instance.

patient_name

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

patient_age

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

codice_fiscale

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

patient_gender

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

chief_complaint

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

history_present_illness

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

past_medical_history

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

medications

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

allergies

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

vital_signs

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

physical_examination

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

assessment

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

diagnosis

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.

confidence_score

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

extracted_at

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

validated

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

validated_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.

__str__()[source]

String representation of the ClinicalData model.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

clinicalreport_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.

get_next_by_extracted_at(*, field=<django.db.models.fields.DateTimeField: extracted_at>, is_next=True, **kwargs)
get_previous_by_extracted_at(*, field=<django.db.models.fields.DateTimeField: extracted_at>, is_next=False, **kwargs)
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>
transcript_id
validated_by_id
class core.models.ClinicalReport(*args, **kwargs)[source]

Bases: Model

Model for clinical reports of finalized encounters

Variables:
  • report_id (models.UUIDField) – Unique UUID identifier for the report

  • encounter (models.ForeignKey) – Reference to the associated Encounter

  • clinical_data (models.ForeignKey) – Reference to the associated ClinicalData (optional)

  • template_type (models.CharField) – Type of report template used

  • report_content (models.JSONField) – Structured content of the report

  • pdf_file (models.FileField) – Uploaded PDF file of the report (optional)

  • is_finalized (models.BooleanField) – Flag indicating if the report is finalized

  • finalized_at (models.DateTimeField) – Timestamp when the report was finalized (optional)

  • finalized_by (models.ForeignKey) – Reference to the Doctor who finalized the report (optional)

  • created_at (models.DateTimeField) – Timestamp of record creation

  • updated_at (models.DateTimeField) – Timestamp of last update

TEMPLATE_CHOICES = [('emergency', 'Pronto Soccorso'), ('consultation', 'Consulenza'), ('admission', 'Ricovero')]
report_id

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

encounter

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.

clinical_data

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.

template_type

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

report_content

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

pdf_file

The descriptor for the file attribute on the model instance. Return a FieldFile when accessed so you can write code like:

>>> from myapp.models import MyModel
>>> instance = MyModel.objects.get(pk=1)
>>> instance.file.size

Assign a file object on assignment so you can do:

>>> with open('/path/to/hello.world') as f:
...     instance.file = File(f)
is_finalized

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

finalized_at

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

finalized_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.

created_at

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

updated_at

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

__str__()[source]

String representation of the ClinicalReport model.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

clinical_data_id
encounter_id
finalized_by_id
get_next_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=True, **kwargs)
get_next_by_updated_at(*, field=<django.db.models.fields.DateTimeField: updated_at>, is_next=True, **kwargs)
get_previous_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=False, **kwargs)
get_previous_by_updated_at(*, field=<django.db.models.fields.DateTimeField: updated_at>, is_next=False, **kwargs)
get_template_type_display(*, field=<django.db.models.fields.CharField: template_type>)
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>

core.mongodb_models module

Modelli MongoDB per transcript, audio, e clinical data Utilizza MongoEngine per l’integrazione con Django

class core.mongodb_models.AudioSegment(*args, **kwargs)[source]

Bases: EmbeddedDocument

Rappresenta un segmento audio con timestamp e metadati per la trascrizione.

Utilizzato per tracciare frammenti audio specifici all’interno di una registrazione più lunga, consentendo l’analisi e la trascrizione segmentata del contenuto audio.

Variables:
  • segment_id – Identificatore univoco del segmento

  • start_ms – Timestamp di inizio in millisecondi

  • end_ms – Timestamp di fine in millisecondi

  • duration_ms – Durata del segmento in millisecondi

  • file_path – Percorso del file audio segmentato

  • chunk_index – Indice del chunk nel flusso audio

class core.mongodb_models.TranscriptSegment(*args, **kwargs)[source]

Bases: EmbeddedDocument

Rappresenta un singolo segmento di trascrizione con informazioni su speaker e affidabilità.

Contiene il testo trascritto per un segmento temporale specifico, includendo metadati come identificazione speaker, confidence score e informazioni di post-processing.

Variables:
  • segment_id – Identificatore univoco del segmento di trascrizione

  • text – Testo trascritto per questo segmento

  • speaker_id – ID numerico dello speaker (0=medico, 1=paziente, 2=altro)

  • speaker_label – Etichetta testuale dello speaker

  • start_ms – Timestamp di inizio in millisecondi

  • end_ms – Timestamp di fine in millisecondi

  • confidence – Punteggio di affidabilità della trascrizione (0.0-1.0)

  • language – Codice lingua rilevata

  • engine – Engine STT utilizzato per la trascrizione

  • tokens – Lista dei token individuali estratti

  • is_corrected – Flag che indica se il testo è stato corretto manualmente

  • original_text – Testo originale prima delle correzioni

class core.mongodb_models.MedicalPatientData(*args, **kwargs)[source]

Bases: EmbeddedDocument

Rappresenta i dati anagrafici del paziente estratti dal testo medico.

Struttura che segue il formato del Project 2 per la memorizzazione di informazioni paziente estratte automaticamente dalle trascrizioni mediante tecniche di NLP e LLM.

Variables:
  • first_name – Nome del paziente

  • last_name – Cognome del paziente

  • codice_fiscale – Codice fiscale del paziente (max 16 caratteri)

class core.mongodb_models.VitalSigns(*args, **kwargs)[source]

Bases: EmbeddedDocument

Parametri vitali estratti dalla trascrizione

class core.mongodb_models.ClinicalAssessment(*args, **kwargs)[source]

Bases: EmbeddedDocument

Valutazione clinica strutturata

class core.mongodb_models.ClinicalData(*args, **kwargs)[source]

Bases: EmbeddedDocument

Dati clinici completi estratti dal transcript

patient_data

alias of MedicalPatientData

vital_signs

alias of VitalSigns

clinical_assessment

alias of ClinicalAssessment

class core.mongodb_models.AudioTranscript(*args, **kwargs)[source]

Bases: Document

Documento principale per audio e transcript di un encounter

clinical_data

alias of ClinicalData

meta = {'collection': 'audio_transcripts', 'indexes': ['encounter_id', 'patient_id', 'doctor_id', 'processing_status', '-created_at', ('encounter_id', 'version')]}
save(*args, **kwargs)[source]

Override save per aggiornare timestamp

property duration_seconds

Durata in secondi

property total_segments

Numero totale segmenti

property average_confidence

Confidence media dei segmenti

class core.mongodb_models.ClinicalReport(*args, **kwargs)[source]

Bases: Document

Report clinico finalizzato per generazione PDF

meta = {'collection': 'clinical_reports', 'indexes': ['encounter_id', 'transcript_id', 'is_finalized', '-created_at']}
save(*args, **kwargs)[source]

Override save per aggiornare timestamp

core.tests module

core.views module