diff --git a/care/facility/migrations/0415_consultationclinician_and_more.py b/care/facility/migrations/0415_consultationclinician_and_more.py new file mode 100644 index 0000000000..0165cef66b --- /dev/null +++ b/care/facility/migrations/0415_consultationclinician_and_more.py @@ -0,0 +1,52 @@ +# Generated by Django 4.2.8 on 2024-02-23 06:38 + +import django.db.models.deletion +from django.conf import settings +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ("facility", "0414_remove_bed_old_name"), + ] + + operations = [ + migrations.CreateModel( + name="ConsultationClinician", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ( + "clinician", + models.ForeignKey( + on_delete=django.db.models.deletion.PROTECT, + to=settings.AUTH_USER_MODEL, + ), + ), + ( + "consultation", + models.ForeignKey( + on_delete=django.db.models.deletion.PROTECT, + to="facility.patientconsultation", + ), + ), + ], + ), + migrations.AddField( + model_name="patientconsultation", + name="assigned_clinicians", + field=models.ManyToManyField( + related_name="patient_assigned_clinician", + through="facility.ConsultationClinician", + to=settings.AUTH_USER_MODEL, + ), + ), + ] diff --git a/care/facility/models/patient_consultation.py b/care/facility/models/patient_consultation.py index a16c08e2ae..8f1400d9ff 100644 --- a/care/facility/models/patient_consultation.py +++ b/care/facility/models/patient_consultation.py @@ -168,6 +168,12 @@ class PatientConsultation(PatientBaseModel, ConsultationRelatedPermissionMixin): related_name="patient_assigned_to", ) + assigned_clinicians = models.ManyToManyField( + User, + related_name="patient_assigned_clinician", + through="ConsultationClinician", + ) + medico_legal_case = models.BooleanField(default=False) deprecated_verified_by = models.TextField( @@ -338,3 +344,14 @@ def has_object_email_discharge_summary_permission(self, request): def has_object_generate_discharge_summary_permission(self, request): return self.has_object_read_permission(request) + + +class ConsultationClinician(models.Model): + consultation = models.ForeignKey( + PatientConsultation, + on_delete=models.PROTECT, + ) + clinician = models.ForeignKey( + User, + on_delete=models.PROTECT, + )