Open dregypt opened 2 years ago
I don't understand what problem you face. Please explain it in details.
could talk telegram what's your number
need your advice this app to select by autocomplte doctor not work
class Profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) user_type = models.CharField(max_length=15, null=True,blank=False) address = models.CharField(max_length=256, null=True, blank=True) phone_regex = RegexValidator(regex=r'^[6-9]\d{9}$', message="Please enter valid mobile number.") mobile = models.CharField(validators=[phone_regex], max_length=10, blank=True) blood_group = models.IntegerField(choices=BLOOD_GROUP_CHOICE, default=1) gender = models.IntegerField(choices=GENDER_CHOICE, default=1) age = models.PositiveIntegerField(default=0)
class AppointmentForm(forms.Form):# BSModalModelForm
#doctor_name= Profile.objects.filter(user_type__in= ('Doctor'))#.filter(dod=False).count()
#doctor_name = forms.ModelMultipleChoiceField(queryset=Profile.objects.filter(user_type='Doctor'), widget=Select2MultipleWidget, required=True)
#doctor_name = forms.ModelChoiceField(queryset=Profile.objects.filter(user_type='Doctor'))
app_date = forms.DateField(widget=forms.TextInput(attrs={'placeholder':'MM/DD/YYYY', 'class': 'form-control', 'id': 'datepicker1', 'autocomplete': 'off'}))
#class Meta:
#model=Appointment
#fields = '__all__'
def clean(self):
super(AppointmentForm, self).clean()
appointment_date = self.cleaned_data.get('app_date')
if appointment_date <= date.today() + timedelta(days=1):
self.add_error('app_date', 'Please select valid date for appointment.')
if appointment_date > date.today() + timedelta(days=15):
self.add_error('app_date', 'Appointment date must be between 15 days.')
return self.cleaned_data
widgets = {
"full_name": DoctorWidget(select2_options={'width': '100%', }),
}
def new_appointment(request): if request.user.is_authenticated: if request.session['user_type'] == 'Receptionist': user = request.user booked_by = User.objects.get(pk=user.id)#i add if request.method == 'POST': patient_username = request.POST['username'] doc_username = request.POST['doc_username']
app_date = datetime.datetime.strptime(request.POST['date'], "%Y-%m-%d").date()
patient_data = User.objects.filter(username=patient_username)
doctor_data = User.objects.filter(username=doc_username)
#recp_data = User.objects.filter(username=recp_username)
today = date.today()
if app_date >= today:
for i in patient_data:
full_name = i.first_name +" "+ i.last_name
mobile = i.profile.mobile
file_number = i.profile.file_number
for i in doctor_data:
doctor_name = i.first_name + " " + i.last_name
dep = i.profile.department
#for i in recp_data:
#recp_name = i.first_name + " " + i.last_name
#dep = i.profile.department
app_count = Appointment.objects.filter(doctor_name=doctor_name, app_date=app_date).count()
if app_count < 10:
app_no = app_count + 1
check_data = Appointment.objects.filter(user=patient_username, doctor_name=doctor_name, app_date=app_date)
if check_data:
messages.warning(request, f'Appointment is already created for <strong>{full_name}</strong> on date <strong>{app_date}</strong>.')
else:
new_app = Appointment(user=patient_username, app_date=app_date, doctor_name=doctor_name, department=dep, book_date=today, full_name=full_name, mobile=mobile,file_number=file_number, appointment_no=app_no,booked_by=booked_by)
new_app.save()
messages.success(request, f'New appointment is created for <strong>{full_name}</strong> on date <strong>{app_date}</strong>.')
else:
messages.success(request, f'Appointment is not available on date {app_date}, please select another date for appointment.')
else:
messages.warning(request, f'New appointment date must be greater than or equal to today.')
return redirect('/arecp/lis/all')#/receptionist/patient_list/
else:
return redirect('/')
else:
return redirect('/')
{% extends 'accounts/receptionist/base.html' %} {% load static %} {% block title %} Patient List {% endblock %}
{% block page_location %}Patient List قائمة المرضي المسجلين {% endblock %}
{{ form.media.css }} {% block main_content %}Patient List
Sr._No. | Patient_Name | File_Number | QR | Mobile_Number | Address | registerd by | full_details | Medical_Records | Appointment_writeusername |
---|---|---|---|---|---|---|---|---|---|
{{forloop.counter}} | {{field.user.get_full_name}} | {{field.file_number}} | {{field.mobile}} | {{field.address}} | {{field.register_by}} | Details | View | Create |
{% endcomment %}
{% comment %}
$( function() {
$( ".form-select" ).autocomplete({
source: '{% url "dr-auoto" %}'
});
} );
{% endcomment %}
{% endblock %}
class Appointment(models.Model):
class Meta:
unique_together = ('doctor_name', 'app_date', 'timeslot')
TIMESLOT_LISTS = (
(0, '09:00 – 09:30'),
(1, '10:00 – 10:30'),
(2, '11:00 – 11:30'),
(3, '12:00 – 12:30'),
(4, '13:00 – 13:30'),
(5, '14:00 – 14:30'),
(6, '15:00 – 15:30'),
(7, '16:00 – 16:30'),
(8, '17:00 – 17:30'),
)
#patient = models.ForeignKey(User,related_name="appointmentcos",on_delete=models.CASCADE,blank=True,null=True)
#dermatologist = models.ForeignKey(User,related_name="appointmentcoss" ,on_delete=models.CASCADE,blank=True,null=True)
#Aesthetic_session = models.CharField(max_length=100,choices=Aesthticc_Types,blank=True,null=True)
#procedure = models.CharField(max_length=100,choices=Procedure_Types,blank=True,null=True)
#Laser_Sessions = models.CharField(max_length=100,choices=Laser_Types,blank=True,null=True)
#date = models.DateField(help_text="YYYY-MM-DD")
timeslot = models.IntegerField(max_length=100,choices=TIMESLOT_LISTS,blank=True,null=True)
appoint_type = models.CharField(max_length=1010,blank=True,null=True)
# id = models.UUIDField(primary_key = True, default = uuid.uuid4, editable = False)
user = models.CharField(max_length=256, null=False, blank=False)
full_name = models.CharField(max_length=256, null=False, blank=False, default='')
mobile = models.CharField(max_length=10, null=False, blank=False, default='')
file_number = models.CharField(max_length=14, null=False, blank=False, default='')
app_date = models.DateField(null=False, blank=False)
book_date = models.DateField(null=False, blank=False, auto_now=True)
doctor_name = models.CharField(max_length=256, null=False, blank=False)
department = models.CharField(max_length=100, null=False, blank=False
nice app how add on my project my users not models it by view dr and patient. user.profile types