Issue Description :
Currently, the system allows patients to register with any age. In a medical context, blood requests for minors often require different oversight, or there should be a logical minimum age for a "Patient" profile (e.g., above 0). Adding validation ensures data integrity.
File to Modify : bloodbankmanagement/patient/forms.py (and models.py)
Logic: Add a clean_age method to the Patient form to ensure the age is within a realistic range (e.g., 0–120).
Code Implementation :
# In bloodbankmanagement/patient/forms.py
from django import forms
from .models import Patient
class PatientForm(forms.ModelForm):
class Meta:
model = Patient
fields = ['age', 'bloodgroup', 'disease', 'doctorname', 'address', 'mobile', 'profile_pic']
def clean_age(self):
age = self.cleaned_data.get('age')
if age <= 0 or age > 120:
raise forms.ValidationError("Please enter a valid age between 1 and 120.")
return age
Issue Description :
Currently, the system allows patients to register with any age. In a medical context, blood requests for minors often require different oversight, or there should be a logical minimum age for a "Patient" profile (e.g., above 0). Adding validation ensures data integrity.
File to Modify :
bloodbankmanagement/patient/forms.py (and models.py)Logic: Add a
clean_agemethod to the Patient form to ensure the age is within a realistic range (e.g., 0–120).Code Implementation :