コード例 #1
0
def make_appointment(request):
    if request.method == 'POST':
        recaptcha_response = request.POST.get('g-recaptcha-response')
        url = 'https://www.google.com/recaptcha/api/siteverify'
        data = {
            'secret': settings.GOOGLE_RECAPTCHA_SECRET_KEY,
            'response': recaptcha_response
        }
        r = requests.post(url=url, data=data)
        result = r.json()
        print(result)
        if result['success']:
            data = request.POST
            datetime_object = datetime.strptime(data['date'],
                                                '%d-%m-%Y %I:%M %p')
            appointment = Appointment(name=data['name'],
                                      message=data['message'],
                                      email=data['email'],
                                      contactNumber=data['contactNumber'],
                                      date=datetime_object)
            appointment.save()
            return render(request, 'public/appointmentSubmission.html', {})
        else:
            return HttpResponseNotFound('<h1>Invalid ReCAPTCHA</h1>')
    else:
        return HttpResponseNotFound('<h1>Page not found</h1>')
コード例 #2
0
def post_appointment(request):
    user = request.user
    if request.method == 'POST':
        duration_choice = request.POST.get('duration', '')
        data_choice = request.POST.get('date', '')
        reason_reason = request.POST.get('reason', '')
        classroom_choice = request.POST.get('classroom', '')
        appointment = Appointment()
        appointment.duration = duration_choice
        appointment.classroom = Classroom.objects.get(name=classroom_choice)
        appointment.custom = Account.objects.get(user=request.user)
        appointment.date = data_choice
        appointment.reason = reason_reason
        appointment.save()
        return render(request, 'main_appointment.html', locals())
コード例 #3
0
def index(request):
    if request.method == 'POST':
        form = AppointmentForm(request.POST)

        if form.is_valid():
            start_time = datetime.datetime.strptime(form.data['time'], '%H:%M')
            end_time = start_time + datetime.timedelta(hours=1)

            appointment = Appointment()
            appointment.doctor_id = form.data['doctor']
            appointment.appointment_day = form.data['day']
            appointment.start_time = start_time.strftime('%H:%M')
            appointment.end_time = end_time.strftime('%H:%M')
            appointment.first_name = form.data['first_name']
            appointment.last_name = form.data['last_name']
            appointment.save()

            return HttpResponseRedirect(reverse('front:details', args=[appointment.id]))
    else:
        form = AppointmentForm()

    return render(request, 'front/index.html', {'form': form})
コード例 #4
0
 def create(self, request, *args, **kwargs):
     hour_id = AppointmentTime.objects.get(
         horario=request.data['horario']).id
     schedule = Schedule.objects.get(id=request.data['agenda_id'])
     schedule.horarios.remove(hour_id)
     user_id = self.get_user_id(request)
     client = User.objects.get(id=user_id)
     doctor_esp = schedule.medico.especialidade
     doctor = model_to_dict(schedule.medico)
     doctor['especialidade'] = model_to_dict(doctor_esp)
     appointment = {
         'client': client,
         'dia': schedule.dia,
         'horario': request.data['horario'],
         'data_agendamento': datetime.now(),
         'medico': schedule.medico
     }
     new_appointment = Appointment(**appointment)
     new_appointment.save()
     del appointment['client']
     appointment['id'] = new_appointment.id
     appointment['medico'] = doctor
     return Response(appointment)
コード例 #5
0
    def update(self, instance: Appointment, validated_data: dict) -> Appointment:
        instance.date = validated_data.get('date', instance.date)

        instance.start_at = validated_data.get('start_at', instance.start_at)
        instance.end_at = validated_data.get('end_at', instance.end_at)

        instance.procedure = validated_data.get('procedure', instance.procedure)

        validate_appointment_datetime(instance.date, instance.start_at,
                                      instance.end_at, update=True)

        patient = validated_data.get('patient')
        if patient is not None:
            instance.patient = get_patient_by_email(patient.get('email'))
        instance.save()

        return instance
コード例 #6
0
 def perform_destroy(self, instance: Appointment):
     instance.set_status(AppointmentStatus.CANCELLED_BY_STYLIST,
                         self.request.user)
コード例 #7
0
    def post(self,request):
        """create patient object check wether it is already in db
        if it is don't store check wether the appointment is 
        within 15 days of the previous one if it is 'review' 
        else it is 'fresh'.Retrieve the particular patient 
        object from db create the appointment object and 
        point it to the patient
        if patient ain't in db store patient and create
        appointment pointing to that patient and store it"""
        F=request.POST
        try:
            pp=Patient.objects.get(patient_name=F['name'],
                                    patient_email=F['email']
                    )
            try:
                app=pp.appointment
            except Appointment.DoesNotExist:
                pass
            comp=datetime.strptime(F['datetime'],'%Y-%m-%d %H:%M:%S')
            if comp.day-app.appointment_datetime.day <= 15: #review
                store_app=Appointment(
                    appointment_datetime=comp,
                    fresh_or_review=True,
                    appointment_problem=F['problem'])
                store_app.save()
                pp.appointment=store_app
                pp.save()
                mail_to_doctor=EmailMessage('appointment for %s'%pp.patient_name,
                    store_app.appointment_problem,
                    to=['*****@*****.**'] 
                )
                mail_to_doctor.send() #returns 1 on success or SMTP standard errors
                mess='''Respected Sir/Madam,
                                           Your review appointment is scheduled on %s'''%F['datetime']
                mail_to_patient=EmailMessage('clinic\'s name',
                    mess,
                to=['%s'%pp.patient_email]
                
                )
                mail_to_patient.send()

            else:
                store_app=Appointment(
                appointment_datetime=comp,
                appointment_problem=F['problem'])
                store_app.save()
                pp.appointment=store_app
                pp.save()
                mail_to_doctor=EmailMessage('appointment for %s'%pp.patient_name,
                    store_app.appointment_problem,
                    to=['*****@*****.**'] 
                )
                mail_to_doctor.send()
                mess='''Respected Sir/Madam,
                                           Your fresh appointment is scheduled on %s'''%F['datetime']
                mail_to_patient=EmailMessage('clinic\'s name',
                    mess,
                to=['%s'%pp.patient_email]
                
                )
                mail_to_patient.send()
                
            return HttpResponseRedirect('results/')
            
        except Patient.DoesNotExist:
            try:
                z=phonenumbers.parse(F['phonenum'],"IN")
            except phonenumbers.NumberParseException:
                cont={'error_message': '    Invalid Phone Number  '}
                return render(request,'appointment/index_l.html',cont)
            if int(F['age']) >= 120 or int(F['age']) < 1:
                con={'error_message': '%s is your age eh !! Nice try'%F['age']}
                return render(request,'appointment/index_l.html',con)
            if len(F['phonenum'][3:])!=10:
                cont={'error_message': '    Invalid Phone Number  '}
                return render(request,'appointment/index_l.html',cont)
            try:
                u=(int(x) for x in F['phonenum'][1:])
                for uu in u:
                    uu=type(uu)
            except ValueError:
                cont={'error_message': '    Invalid Phone Number  '}
                return render(request,'appointment/index_l.html',cont)
            
            if not phonenumbers.is_possible_number(z):
                cont={'error_message': '    Invalid Phone Number  '}
                return render(request,'appointment/index_l.html',cont)
            
            if not phonenumbers.is_valid_number:
                cont={'error_message': '    Invalid Phone Number  '}
                return render(request,'appointment/index_l.html',cont)    
            email_doms=['aol.com','comcast.net','facebook.com',
                        'gmail.com', 'hotmail.com','msn.com'
                        'outlook.com','yahoo.com','yahoo.co.in'
            ]
            if str(F['email']).split('@')[0] == '':
                err_mail={'error_message':'     Invalid email address  '}
                return render(request,'appointment/index_l.html',err_mail)

            if  F['email'].split('@')[1] not in email_doms :
                err_mail={'error_message':'   No support for email by %s'%F['email'].split('@')[1]}
                return render(request,'appointment/index_l.html',err_mail)
            comp=datetime.strptime(F['datetime'],'%Y-%m-%d %H:%M:%S')
            store_app=Appointment(
                        appointment_datetime=comp,
                        appointment_problem=F['problem'])
            store_app.save()
            p=Patient(appointment=store_app,
                       patient_name=F['name'],
                       patient_age=int(F['age']),
                       patient_sex=F['sex'],
                       patient_email=F['email'],
                       patient_phone=F['phonenum'])
            p.save()
            mail_to_doctor=EmailMessage('appointment for %s'%p.patient_name,
                    store_app.appointment_problem,
                    to=['*****@*****.**'] 
                )
            mail_to_doctor.send()
            
            mess='''Respected Sir/Madam,
                                        We are glad to offer our services,Kindly visit the clinic on %s'''%F['datetime']
            mail_to_patient=EmailMessage('clinic\'s name',
                    mess,
                to=['%s'%p.patient_email]
                
            )
            mail_to_patient.send()

            return HttpResponseRedirect('results/')   
コード例 #8
0
    def _create_appointments(self):

        app_list = [
            Appointment(patient_ID=Patient.objects.get(id=1),
                        doctor_ID=Doctor.objects.get(id=1),
                        location='Rochester',
                        date=timezone.now(),
                        time=timezone.now(),
                        endTime=timezone.now() + timezone.timedelta(hours=1),
                        description='Stitches'),
            Appointment(patient_ID=Patient.objects.get(id=1),
                        doctor_ID=Doctor.objects.get(id=1),
                        location='Rochester',
                        date=timezone.now() + timezone.timedelta(days=1),
                        time=timezone.now(),
                        endTime=timezone.now() + timezone.timedelta(hours=1),
                        description='Physical'),
            Appointment(patient_ID=Patient.objects.get(id=1),
                        doctor_ID=Doctor.objects.get(id=1),
                        location='Rochester',
                        date=timezone.now() + timezone.timedelta(days=3),
                        time=timezone.now(),
                        endTime=timezone.now() + timezone.timedelta(hours=1),
                        description='Therapy'),
            Appointment(patient_ID=Patient.objects.get(id=2),
                        doctor_ID=Doctor.objects.get(id=1),
                        location='Rochester',
                        date=timezone.now(),
                        time=timezone.now() + timezone.timedelta(hours=2),
                        endTime=timezone.now() + timezone.timedelta(hours=3),
                        description='Orthopedics'),
            Appointment(patient_ID=Patient.objects.get(id=2),
                        doctor_ID=Doctor.objects.get(id=1),
                        location='Rochester',
                        date=timezone.now() + timezone.timedelta(days=2),
                        time=timezone.now(),
                        endTime=timezone.now() + timezone.timedelta(hours=1),
                        description='Triple Bi Pass'),
            Appointment(patient_ID=Patient.objects.get(id=3),
                        doctor_ID=Doctor.objects.get(id=2),
                        location='Canandaiguia',
                        date=timezone.now(),
                        time=timezone.now(),
                        endTime=timezone.now() + timezone.timedelta(hours=1),
                        description='Rehabilitation'),
            Appointment(patient_ID=Patient.objects.get(id=3),
                        doctor_ID=Doctor.objects.get(id=2),
                        location='Canandaiguia',
                        date=timezone.now() + timezone.timedelta(days=1),
                        time=timezone.now(),
                        endTime=timezone.now() + timezone.timedelta(hours=1),
                        description='Ligament tear'),
            Appointment(patient_ID=Patient.objects.get(id=4),
                        doctor_ID=Doctor.objects.get(id=2),
                        location='Canandaiguia',
                        date=timezone.now(),
                        time=timezone.now() + timezone.timedelta(hours=2),
                        endTime=timezone.now() + timezone.timedelta(hours=3),
                        description='ACL Tear'),
            Appointment(patient_ID=Patient.objects.get(id=4),
                        doctor_ID=Doctor.objects.get(id=2),
                        location='Canandaiguia',
                        date=timezone.now() + timezone.timedelta(days=4),
                        time=timezone.now(),
                        endTime=timezone.now() + timezone.timedelta(hours=1),
                        description='Eye examination'),
            Appointment(patient_ID=Patient.objects.get(id=5),
                        doctor_ID=Doctor.objects.get(id=3),
                        location='Maryland',
                        date=timezone.now(),
                        time=timezone.now(),
                        endTime=timezone.now() + timezone.timedelta(hours=1),
                        description='Physical')
        ]

        for app in app_list:
            app.save()
コード例 #9
0
ファイル: views.py プロジェクト: selseo/hospital
def seed(request):
    #if request.user.is_authenticated():
        #if getUserProfile(request.user).role==2:
            # d1,xxx=Doctor.objects.get_or_create(
            #         drusername="******",
            #         defaults={'drpassword':make_password(password="******",hasher='sha1'),
            #         'drphone':"021234567",
            #         'drname':"John",
            #         'drsurname':"Smith",
            #         'drsex':'m',
            #         'drbirthdate':"1990-12-12",
            #         'dridcard':"12345617890123",
            #         'draddress':"aaa",
            #         'dremail':"*****@*****.**"}
            # )
            # user0,xxx=User.objects.get_or_create(
            #     username="******",
            #     defaults={'password':make_password(password="******",hasher='sha1'),'email':"*****@*****.**"}
            # )
            # user0.save()
            # userp0,xxx=UserProfile.objects.get_or_create(
                
            #     user=user0,
            #     defaults={'firstname':"Doctor",'lastname':"Tneitap",'role':1,'status':True}
            # )
            userp0=UserProfile.objects.get(
                firstname="Doctor",
                # defaults={'firstname':"Doctor",'lastname':"Tneitap",'role':1,'status':True}
            )
            # userp0.save()
            d1,xxx=Doctor.objects.get_or_create(
                userprofile=userp0,
                defaults={'department' : 'Cancer'}
            )
            d1.save()
            t11,xxx=timeTable.objects.get_or_create(doctor_id=d1,date=datetime.now()-timedelta(hours=random.randrange(-200,200)),period=random.choice(['m','a']),)
            t11.save()
            t12,xxx=timeTable.objects.get_or_create(doctor_id=d1,date=datetime.now()-timedelta(hours=random.randrange(-200,200)),period=random.choice(['m','a']),)
            t12.save()
            t13,xxx=timeTable.objects.get_or_create(doctor_id=d1,date=datetime.now()-timedelta(hours=random.randrange(-200,200)),period=random.choice(['m','a']),)
            t13.save()
            t14,xxx=timeTable.objects.get_or_create(doctor_id=d1,date=datetime.now()-timedelta(hours=random.randrange(-200,200)),period=random.choice(['m','a']),)
            t14.save()
            t15,xxx=timeTable.objects.get_or_create(doctor_id=d1,date=datetime.now()-timedelta(hours=random.randrange(-200,200)),period=random.choice(['m','a']),)
            t15.save()
            user1,xxx=User.objects.get_or_create(
                username="******",
                defaults={'password':make_password(password="******",hasher='sha1'),'email':"*****@*****.**"}
            )
            user1.save()
            userp1,xxx=UserProfile.objects.get_or_create(
                user=user1,
                defaults={'user':user1,'firstname':"QQQ",'lastname':"WWWW",'role':1,'status':True}
            )
            userp1.save()
            d2,xxx=Doctor.objects.get_or_create(
                userprofile=userp1,
                defaults={'department' : 'Cancer'}
            )
            d2.save()
            t21,xxx=timeTable.objects.get_or_create(doctor_id=d2,date=datetime.now()-timedelta(hours=random.randrange(-200,200)),period=random.choice(['m','a']),)
            t21.save()
            t22,xxx=timeTable.objects.get_or_create(doctor_id=d2,date=datetime.now()-timedelta(hours=random.randrange(-200,200)),period=random.choice(['m','a']),)
            t22.save()
            t23,xxx=timeTable.objects.get_or_create(doctor_id=d2,date=datetime.now()-timedelta(hours=random.randrange(-200,200)),period=random.choice(['m','a']),)
            t23.save()
            t24,xxx=timeTable.objects.get_or_create(doctor_id=d2,date=datetime.now()-timedelta(hours=random.randrange(-200,200)),period=random.choice(['m','a']),)
            t24.save()
            t25,xxx=timeTable.objects.get_or_create(doctor_id=d2,date=datetime.now()-timedelta(hours=random.randrange(-200,200)),period=random.choice(['m','a']),)
            t25.save()
            for i in range(0,10) :
                u = User(
                    username='******'+str(random.randrange(1,100000000)),
                    email='username'+str(random.randrange(1,100000000))+'@example.com',
                    password='******'+str(random.randrange(1,100000000)),
                )
                u.save()
                up = UserProfile(
                        user=u,
                        firstname='name'+str(random.randrange(1,100)),
                        lastname='sur'+str(random.randrange(1,100)),
                        role=0,
                )
                up.save()
                pt = Patient(
                userprofile=up,
                sex=random.choice(['M','F']),
                birthdate=datetime.now()-timedelta(days=random.randrange(1000,10000)),
                idcard=str(random.randrange(1,100)),
                address=str(random.randrange(1,100)),
                phone=str(random.randrange(1,100)),

                )
                pt.save()
                a = Appointment(timetable_id=random.choice([t11,t12,t13,t14,t15,t21,t22,t23,t24,t25,]), patient_id=pt, symptom="DiE dIe :) JubJub", cause="StupiD")
                a.save()
                v = PatientVisitInfo(appointment=a,
            weight=str(random.randrange(50,100)),
            height=str(random.randrange(100,200)),
            bodyTemp=str(random.randrange(26,35)),
            pulse=str(random.randrange(40,120)),
            systolic=str(random.randrange(50,110)),
            diastolic=str(random.randrange(100,200)),
            status=str(random.randrange(0,4)),
            note=str(random.randrange(13,103452350)),)
                v.save()

                PatientVisitInfo.objects.filter(appointment=a).update(lastUpdate=v.lastUpdate-timedelta(hours=random.randrange(0,4)*random.randrange(0,5)*random.randrange(0,6)*random.randrange(0,7)))

            return render(request, 'seed.html')
        #else :
            #return HttpResponseRedirect('/default/')
    #else :
        #return HttpResponseRedirect('/default/')