diff --git a/doctor/forms.py b/doctor/forms.py index aefe962..f257474 100644 --- a/doctor/forms.py +++ b/doctor/forms.py @@ -4,11 +4,6 @@ from doctor.models import Doctor from user.models import User -# Note: -# - Utilize Manager Object for doctor creation -# - Mixins for forms -# - Create a process for existing doctors, invite link or direct invite - class BaseDoctorForm(forms.ModelForm): GENDER_TYPES = [ @@ -23,8 +18,18 @@ class BaseDoctorForm(forms.ModelForm): registration_number = forms.CharField(label="PRC License No.", max_length=55) specialization = forms.CharField(max_length=55) + def __init__(self, *args, **kwargs): + instance = kwargs.get("instance") + if instance: + self.base_fields["email"].required = False + + super().__init__(*args, **kwargs) + def clean_mobile(self): mobile = str(self.cleaned_data.get("mobile")).strip() + if self.instance.pk: + return mobile + pattern = r"^((\+?63)|0|9)(9\d{9})$" if not re.match(pattern, mobile): self.add_error(field="mobile", error="Use a Philippine Mobile Number ex. (09123456789 or +639123456789)") @@ -34,10 +39,10 @@ def clean_mobile(self): def save(self, commit=True): user: User = super().save() doctor = Doctor.objects.get_or_create(user=user)[0] - doctor.gender = self.cleaned_data["gender"] - doctor.registration_number = self.cleaned_data["registration_number"] - doctor.experience_years = self.cleaned_data["experience_years"] - doctor.specialization = self.cleaned_data["specialization"] + doctor.gender = self.cleaned_data.get("gender") + doctor.registration_number = self.cleaned_data.get("registration_number") + doctor.experience_years = self.cleaned_data.get("experience_years") + doctor.specialization = self.cleaned_data.get("specialization") doctor.save() return doctor diff --git a/doctor/models.py b/doctor/models.py index 8bd41fe..5954431 100644 --- a/doctor/models.py +++ b/doctor/models.py @@ -21,6 +21,9 @@ def generate_doctor_code(): user = models.OneToOneField("user.user", related_name="doctor", on_delete=models.CASCADE) + def __str__(self): + return f"Doctor [{self.user.get_full_name()}]" + class Meta: ordering = ["-pk"] verbose_name = "Doctor" diff --git a/doctor/templates/doctor/components/base/header.html b/doctor/templates/doctor/components/base/header.html new file mode 100644 index 0000000..4195c8c --- /dev/null +++ b/doctor/templates/doctor/components/base/header.html @@ -0,0 +1,13 @@ +
+
+
+ + {% include 'patient/components/base/navbar.html'%} +
+
+
diff --git a/doctor/templates/doctor/components/base/navbar.html b/doctor/templates/doctor/components/base/navbar.html new file mode 100644 index 0000000..e3cdb7d --- /dev/null +++ b/doctor/templates/doctor/components/base/navbar.html @@ -0,0 +1,35 @@ +
+
+
+ + + Welcome, {{ user.first_name }}! + + + +
+ +
+
diff --git a/doctor/templates/doctor/components/base/sidebar.html b/doctor/templates/doctor/components/base/sidebar.html new file mode 100644 index 0000000..6c60e01 --- /dev/null +++ b/doctor/templates/doctor/components/base/sidebar.html @@ -0,0 +1,47 @@ + diff --git a/doctor/templates/doctor/index.html b/doctor/templates/doctor/index.html index 6bd8eaf..79918c2 100644 --- a/doctor/templates/doctor/index.html +++ b/doctor/templates/doctor/index.html @@ -1,36 +1,8 @@ -{% extends 'layout/master.html' %} +{% extends 'theme/base.html' %} -{% block layout %} - -
- -
- {% include 'doctor/partials/header.html' %} - -
- {% include 'doctor/partials/sidebar.html' %} - -
- -
- -
- -
- {% block content %} {% endblock content %} -
- -
- -
- -
- -
- -
- +{% block content %} +
+ {% include 'doctor/components/base/sidebar.html' %} + {% block main %} {% endblock %}
- - -{% endblock layout %} +{% endblock %} diff --git a/doctor/templates/doctor/pages/dashboard.html b/doctor/templates/doctor/pages/dashboard.html index 1a04dd9..6d969cf 100644 --- a/doctor/templates/doctor/pages/dashboard.html +++ b/doctor/templates/doctor/pages/dashboard.html @@ -1,33 +1,18 @@ -{% extends 'doctor/index.html' %} +{% extends "doctor/index.html" %} -{% block content %} -
-
-
-

Doctor Dashboard

- -
-
-
-
-
-
-
-

- Welcome {{ user.get_full_name }} and you're currently signed in - under the email {{ user.email }}.
- Navigate through the Apollo system using the bar on the left-hand side of the browser. -

-
-
+{% load static %} + +{% block main %} +
+
+

+
Welcome back, {{ user.first_name }}
+
Medsync Doctor Account
+

+ + + Send a referral +
{% endblock %} diff --git a/doctor/templates/doctor/pages/facilities.html b/doctor/templates/doctor/pages/facilities.html deleted file mode 100644 index 5cee99d..0000000 --- a/doctor/templates/doctor/pages/facilities.html +++ /dev/null @@ -1,22 +0,0 @@ -{% extends 'doctor/index.html' %} - -{% block content %} -
-
-
-

- Facilities -

- -
-
-
-{% endblock %} diff --git a/doctor/templates/doctor/pages/patients.html b/doctor/templates/doctor/pages/patients.html deleted file mode 100644 index ea78b04..0000000 --- a/doctor/templates/doctor/pages/patients.html +++ /dev/null @@ -1,22 +0,0 @@ -{% extends 'doctor/index.html' %} - -{% block content %} -
-
-
-

- Patients -

- -
-
-
-{% endblock %} diff --git a/doctor/templates/doctor/pages/referrals.html b/doctor/templates/doctor/pages/referrals.html deleted file mode 100644 index 4ae6317..0000000 --- a/doctor/templates/doctor/pages/referrals.html +++ /dev/null @@ -1,22 +0,0 @@ -{% extends 'doctor/index.html' %} - -{% block content %} -
-
-
-

- Referrals -

- -
-
-
-{% endblock %} diff --git a/doctor/templates/doctor/partials/header.html b/doctor/templates/doctor/partials/header.html deleted file mode 100644 index fa7cc34..0000000 --- a/doctor/templates/doctor/partials/header.html +++ /dev/null @@ -1,21 +0,0 @@ -{% load static %} -
-
-
-
- -
-
-
- - Logo - -
-
-
- {% include 'partials/header-user-menu-toggle.html'%} -
-
-
-
diff --git a/doctor/templates/doctor/partials/sidebar.html b/doctor/templates/doctor/partials/sidebar.html deleted file mode 100644 index a908f06..0000000 --- a/doctor/templates/doctor/partials/sidebar.html +++ /dev/null @@ -1,95 +0,0 @@ -{% load static %} - - - - - diff --git a/facility/forms/doctor_forms.py b/facility/forms/doctor_forms.py index 1f5e886..7cefd38 100644 --- a/facility/forms/doctor_forms.py +++ b/facility/forms/doctor_forms.py @@ -20,6 +20,7 @@ def setup_form_layout(self): "registration_number", "experience_years", "specialization", + "email", "mobile", "birth_date", "gender", @@ -29,5 +30,5 @@ def setup_form_layout(self): def save(self, commit=True): doctor: Doctor = super().save() - self.facility.patients.add(doctor) + self.facility.doctors.add(doctor) return doctor diff --git a/facility/forms/referral_forms.py b/facility/forms/referral_forms.py index 59d9210..361d5df 100644 --- a/facility/forms/referral_forms.py +++ b/facility/forms/referral_forms.py @@ -1,13 +1,12 @@ from autocomplete import widgets from crispy_forms.helper import FormHelper -from crispy_forms.layout import Fieldset, Layout, Div, Row, Column, Submit +from crispy_forms.layout import Layout, Div, Row, Column, Submit -from facility.models import Facility, FacilityDoctor, FacilityPatient +from theme.crispy_forms.layout import Fieldset +from facility.models import Facility from referrals.forms import BaseReferralForm -Fieldset.template = "theme/layout/fieldset.html" - -# Note: Add Environment Variable to enable/disable email sending for test environment +# TODO: Add Environment Variable to enable/disable email sending for test environment class FacilityReferralForm(BaseReferralForm): @@ -20,14 +19,20 @@ def setup_form_layout(self): self.helper = FormHelper() self.helper.layout = Layout( Fieldset( - "General Referral Details", + "Referring Health Care Institution", "origin_physician", + "description", + description="Your Facility information for the referral", + ), + Fieldset( + "Patient Information", "patient", "diagnosis", - "description", + description="The patient that will be reffered to this facility", + css_class="mt-5", ), Fieldset( - "Destination Information", + "Referral Health Care Institution", "destination", "destination_physician", Row( @@ -36,6 +41,7 @@ def setup_form_layout(self): css_class="grid grid-cols-2 gap-4", ), css_class="mt-5", + description="The receiving facility for the referral", ), Div( Submit("submit", "Send Referral Request", css_class="btn btn-primary mt-5 "), @@ -43,11 +49,9 @@ def setup_form_layout(self): ), ) - def setup_field_widgets(self): - self.fields["diagnosis"].widget.attrs["rows"] = 2 - class Meta(BaseReferralForm.Meta): add_exclude_fields = [ + "status", "is_urgent", "origin", "origin_email", @@ -62,12 +66,4 @@ class Meta(BaseReferralForm.Meta): name="destination", options={"item_label": "facility_name", "model": Facility}, ), - "patient": widgets.Autocomplete( - name="patient", - options={"model": FacilityPatient}, - ), - "origin_physician": widgets.Autocomplete( - name="origin_physician", - options={"model": FacilityDoctor}, - ), } diff --git a/facility/models.py b/facility/models.py index 721de16..2148063 100644 --- a/facility/models.py +++ b/facility/models.py @@ -84,6 +84,9 @@ class FacilityDoctor(models.Model): created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) + def __str__(self): + return f"Doctor [{self.doctor.user.get_full_name()}]" + class FacilityPatient(models.Model): facility = models.ForeignKey("facility.facility", on_delete=models.CASCADE) @@ -91,6 +94,9 @@ class FacilityPatient(models.Model): created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) + def __str__(self): + return f"Patient [{self.patient.user.get_full_name()}]" + class FacilityStaff(AbstractAddress, AbstractContact, AbstractGender): class StaffType(models.TextChoices): diff --git a/facility/templates/facility/components/base/navbar.html b/facility/templates/facility/components/base/navbar.html new file mode 100644 index 0000000..48d5234 --- /dev/null +++ b/facility/templates/facility/components/base/navbar.html @@ -0,0 +1,16 @@ +
+ Medsync Logo +
+ +
+
+ + diff --git a/facility/templates/facility/components/base/sidebar.html b/facility/templates/facility/components/base/sidebar.html index fd77d0a..9a4285d 100644 --- a/facility/templates/facility/components/base/sidebar.html +++ b/facility/templates/facility/components/base/sidebar.html @@ -1,6 +1,9 @@ -