Exemple #1
0
def init_doctor_data():
    hospital_list = loadHospital()
    date_list = getEveryDay()
    doctor_index = 0
    while (doctor_index < 1000):
        doctor = Doctor()
        doctor.name = getRandomName()
        doctor.age_group = random.choice(age_group_list)
        doctor.disease_list = random.sample(
            disease_list, random.choice(range(1, len(disease_list), 1)))
        doctor.doctor_office = random.choice(doctor_office_list)
        doctor.doctor_title = random.choice(doctor_title_list)
        doctor.phone = str(random.randrange(18800000001, 18899999999, 1))
        # register_day
        now_date = datetime.datetime.strptime(random.choice(date_list),
                                              "%Y-%m-%d")
        doctor.register_year = now_date.year
        doctor.register_month = now_date.month
        doctor.register_day = now_date.day
        # hospital_info
        hospital = random.choice(hospital_list)
        # print(hospital)#test output
        doctor.hospital_name = hospital[0]
        doctor.hospital_level = hospital[1]
        doctor.province = hospital[2]
        doctor.city = hospital[3]
        doctor.longitude = float(hospital[4])
        doctor.latitude = float(hospital[5])
        doctor.save()
        doctor_index += 1
 def post(self, request):
     titlePk = request.POST.get("Title", "")
     firstName = request.POST.get('FirstName', '')
     lastName = request.POST.get('LastName', '')
     default_time_exam = request.POST.get('DefaultExampTime', 20)
     #Make some checks
     title = Title.objects.get(pk=titlePk)
     doctor = Doctor(title=title, first_name=firstName, last_name=lastName, default_exam_time=default_time_exam)
     doctor.save()
     return redirect(doctors)
 def post(self, request, *args, **kwargs):
     form = SignUpForm(request.POST)
     if form.is_valid():
         user = User()
         user.password = make_password(form.cleaned_data['password'])
         user.username = form.cleaned_data['username']
         user.first_name = form.cleaned_data['first_name']
         user.last_name = form.cleaned_data['last_name']
         user.email = form.cleaned_data['email']
         user.save()
         doctor = Doctor(user=user)
         doctor.save()
         return HttpResponseRedirect(reverse('app:login'))
     else:
         return render(request, 'app/doctor/doctor_signup.haml',
                       {'form': form})