示例#1
0
文件: views.py 项目: faradzh/medilix
def create_notification(request):
    if request.method == 'POST':
        patient_id = request.POST.get('patient_id')
        doctor_id = request.POST.get('doctor_id')
        complaints = request.POST.get('complaints')
        date = request.POST.get('date')
        hospital_id = request.POST.get('hospital_id')
        repeat_visit = request.POST.get('repeat_visit')

        doctor_profile = DoctorProfile.objects.get(user_id=doctor_id)
        patient_profile = PatientProfile.objects.get(user_id=patient_id)
        hospital = Hospital.objects.get(pk=hospital_id)

        notification = Notification(complaints=complaints, date=date)
        notification.patient_profile = patient_profile
        notification.doctor_profile = doctor_profile
        notification.hospital = hospital

        if repeat_visit == 'true':
            notification.visit_number = 2
        notification.save()

    return JsonResponse({"message": "OK"}, static=201)