예제 #1
0
def sub_category_list(request):
    sub_categories = Sub_Category.objects.all()

    # Delete
    if request.is_ajax():
        if request.method == 'POST':
            get_object_or_none(Sub_Category,
                               id=request.POST.get('id')).delete()

    # Search
    if request.method == 'GET':
        query = request.GET.get('search')
        if query:
            sub_categories = sub_categories.filter(
                Q(id__icontains=query) | Q(name__icontains=query)
                | Q(main_category__name__icontains=query)).distinct()

    # Import from excel
    if request.method == 'POST':
        import_Sub_Categories()  # handel excel files

    # Pagination
    sub_categories_pages = Paginator(sub_categories, 20)
    sub_categories = sub_categories_pages.get_page(request.GET.get('page'))
    current_page = request.GET.get('page') if request.GET.get('page') else 1
    context = {
        'title': 'Sub Categories List',
        'sub_categories': sub_categories,
        'pages': str(sub_categories_pages.num_pages),
        'current_page': str(current_page)
    }
    return render(request, 'cpanel/Sub Category/sub_category_list.html',
                  context)
예제 #2
0
def case_add(request):
    charitable_activities = Sub_Category.objects.all()

    # Add data
    if request.is_ajax():
        if request.method == 'POST':
            case = get_object_or_none(Case, code=request.POST.get('code'))
            if case:
                return HttpResponseBadRequest('This Case is already exists')

            is_urgent = True if request.POST.get(
                'is_urgent') == 'on' else False

            sub_category = get_object_or_404(
                Sub_Category, id=request.POST.get('sub_category'))

            contribution = Contribution.objects.create(
                amount=request.POST.get('amount'),
                description=request.POST.get('description'),
                is_urgent=is_urgent,
            )

            Case.objects.create(
                case_id=contribution,
                code=request.POST.get('code'),
                sub_category=sub_category,
            )
예제 #3
0
def donation_list(request):
    donations = Donation.objects.all()

    # Delete
    if request.is_ajax():
        if request.method == 'POST':
            get_object_or_none(Donation, id=request.POST.get('id')).delete()

    # Search
    if request.method == 'GET':
        query = request.GET.get('search')
        if query:
            donations = donations.filter(
                Q(donor__name__icontains=query)
                | Q(assigned_agent__user__username__icontains=query)
                | Q(charitable_activity__name__icontains=query)).distinct()

    # Import from excel
    if request.method == 'POST':
        import_Donors()  # handel excel files

    # Pagination
    donations_pages = Paginator(donations, 20)
    donations = donations_pages.get_page(request.GET.get('page'))
    current_page = request.GET.get('page') if request.GET.get('page') else 1
    context = {
        'title': 'Donations List',
        'donations': donations,
        'pages': str(donations_pages.num_pages),
        'current_page': str(current_page)
    }
    return render(request, 'cpanel/Donations/donation_list.html', context)
예제 #4
0
파일: Mohamedviews.py 프로젝트: Yory1/HC-1
def Patient_history_add(request):
    if request.is_ajax():
        if request.method == 'POST':

            hide = True if request.POST.get('hide') == 'on' else False

            if not get_object_or_none(Patient, patient_nn=request.POST.get('patient_nn')):
                return HttpResponseNotFound("This Patient national number not exist")
            else:
                patient = get_object_or_none(Patient, patient_nn=request.POST.get('patient_nn'))

            if not get_object_or_none(Physician, physician_nn=request.POST.get('physician_nn')):
                return HttpResponseNotFound("This physician national number not exist")
            else:
                physician = get_object_or_none(Physician, physician_nn=request.POST.get('physician_nn'))

            patienthistory = PatientHistory.objects.create(
                patient_nn=patient,
                physician_nn=physician,
                date_time=request.POST.get('date_time'),
                visitation_type=request.POST.get('visitation_type'),
                prescription=request.POST.get('prescription'),
                physician_comments=request.POST.get('physician_comments'),
                diagnouse=request.POST.get('diagnouse'),
                analysis_radiology=request.POST.get('analysis_radiology'),
                disease_priority=request.POST.get('disease_priority'),
                hide=hide
            )

            return HttpResponse()
    return render(request, 'cpanel/Patient/Patient_History_add.html')
예제 #5
0
def donation_add(request):
    contributions = Contribution.objects.all()
    charitable_activities = Sub_Category.objects.all()

    if request.is_ajax():
        if request.method == 'POST':
            user = get_object_or_none(User, username=request.POST.get('donor'))
            donor = get_object_or_none(Donor, user=user)
            if not donor:
                return HttpResponseBadRequest('This Donor is not exists')

            contribution = get_object_or_none(
                Contribution, id=request.POST.get('contribution'))
            charitable_activity = get_object_or_none(
                Sub_Category, id=request.POST.get('charitable_activity'))

            Donation.objects.create(donor=donor,
                                    contribution=contribution,
                                    charitable_activity=charitable_activity,
                                    amount=request.POST.get('amount'),
                                    address_no=request.POST.get('address_no'))

    context = {
        'contributions': contributions,
        'charitable_activities': charitable_activities,
        'title': 'Donation Add'
    }
    return render(request, 'cpanel/Donations/donation_add.html', context)
예제 #6
0
def agent_list(request):
    agents = Agent.objects.all()

    # Delete
    if request.is_ajax():
        if request.method == 'POST':
            get_object_or_none(Agent, id=request.POST.get('id')).delete()

    # Search
    if request.method == 'GET':
        query = request.GET.get('search')
        if query:
            agents = agents.filter(
                Q(id__icontains=query) | Q(user__username__icontains=query)
                | Q(phone__icontains=query)).distinct()

    # Import from excel
    if request.method == 'POST':
        import_Agents()  # handel excel files

    # Pagination
    agents_pages = Paginator(agents, 20)
    agents = agents_pages.get_page(request.GET.get('page'))
    current_page = request.GET.get('page') if request.GET.get('page') else 1
    context = {
        'title': 'Agents List',
        'agents': agents,
        'pages': str(agents_pages.num_pages),
        'current_page': str(current_page)
    }
    return render(request, 'cpanel/Agents/agent_list.html', context)
예제 #7
0
 def get_name(self):
     name = get_object_or_none(Case, case_id=self.id)
     if name:
         name = name.code
     else:
         name = get_object_or_none(Project, project_id=self.id)
     return name
예제 #8
0
def our_sponsor_list(request):
    our_sponsors = Our_Sponsor.objects.all()

    # Delete
    if request.is_ajax():
        if request.method == 'POST':
            get_object_or_none(Our_Sponsor, id=request.POST.get('id')).delete()

    # Search
    if request.method == 'GET':
        query = request.GET.get('search')
        if query:
            our_sponsors = our_sponsors.filter(
                Q(id__icontains=query) | Q(name__icontains=query)).distinct()

    # Pagination
    our_sponsors_pages = Paginator(our_sponsors, 20)
    our_sponsors = our_sponsors_pages.get_page(request.GET.get('page'))
    current_page = request.GET.get('page') if request.GET.get('page') else 1
    context = {
        'title': 'Slider Images List',
        'slider_images': our_sponsors,
        'pages': str(our_sponsors_pages.num_pages),
        'current_page': str(current_page)
    }
    return render(request, 'cpanel/Our Sponsors/our_sponsor_list.html',
                  context)
예제 #9
0
def Pharmacy_add(request):
    if request.is_ajax():
        if request.method == 'POST':
            if get_object_or_none(Pharmacy, pharmacy=request.POST.get('lab')):
                return HttpResponseNotFound("This Pharmacy data is already stored")

            hide = True if request.POST.get('hide') == 'on' else False
            medical_institution = get_object_or_none(MedicalInstitutions, institution_id=request.POST.get('institution_id'))
            if not medical_institution:
                # Add User to django
                user = User.objects.create_user(
                    username=request.POST.get('institution_id'),
                    password=request.POST.get('password'),
                    is_staff=True
                )

                # Add user to the group
                group = Group.objects.get(name='Pharmacy')
                group.user_set.add(user)

                medical_institution = MedicalInstitutions.objects.create(
                    institution_id=request.POST.get('institution_id'),
                    institution_name=request.POST.get('institution_name'),
                    user=user
                )

                if request.FILES.get('image'):
                    medical_institution.image = request.FILES.get('image')
                    medical_institution.save()

                for phone in request.POST.getlist('phone'):
                    MedicalInstitutionsPhone.objects.create(
                        institution=medical_institution,
                        phone=phone
                    )

                for address in request.POST.getlist('address'):
                    MedicalInstitutionsAddress.objects.create(
                        institution=medical_institution,
                        address=address
                    )

            else:
                group = Group.objects.get(name='Pharmacy')
                group.user_set.add(medical_institution.user)

            owner = get_object_or_none(Pharmacist, pharmacist_nn=request.POST.get('owner'))
            if not owner:
                return HttpResponseNotFound("This Pharmacist data is not stored")

            Pharmacy.objects.create(
                pharmacy=medical_institution,
                pharmacy_type=request.POST.get('pharmacy_type'),
                owner=owner,
                hide=hide
            )

            return HttpResponse()

    return render(request, 'cpanel/Pharmacy/Pharmacy_add.html')
예제 #10
0
def slider_image_list(request):
    slider_images = Slider_Image.objects.all()
    # Delete
    if request.is_ajax():
        if request.method == 'POST':
            get_object_or_none(Slider_Image,
                               id=request.POST.get('id')).delete()

    # Search
    if request.method == 'GET':
        query = request.GET.get('search')
        if query:
            slider_images = slider_images.filter(
                Q(id__icontains=query) | Q(name__icontains=query)).distinct()

    # Pagination
    slider_images_pages = Paginator(slider_images, 20)
    slider_images = slider_images_pages.get_page(request.GET.get('page'))
    current_page = request.GET.get('page') if request.GET.get('page') else 1
    context = {
        'title': 'Slider Images List',
        'slider_images': slider_images,
        'pages': str(slider_images_pages.num_pages),
        'current_page': str(current_page)
    }
    return render(request, 'cpanel/Slider Image/slider_image_list_ar.html',
                  context)
예제 #11
0
def project_list(request):
    projects = Project.objects.all()

    # Delete
    if request.is_ajax():
        if request.method == 'POST':
            get_object_or_none(Project,
                               project_id=request.POST.get('id')).delete()
            get_object_or_none(Contribution,
                               id=request.POST.get('id')).delete()

    # Search
    if request.method == 'GET':
        query = request.GET.get('search')
        if query:
            projects = projects.filter(
                Q(project_id__id__icontains=query) | Q(name__icontains=query)
                | Q(project_id__amount__icontains=query)
                | Q(project_id__is_urgent__icontains=query)).distinct()

    # Import from excel
    if request.method == 'POST':
        import_projects()  # handel excel files

    # Pagination
    projects_pages = Paginator(projects, 20)
    projects = projects_pages.get_page(request.GET.get('page'))
    current_page = request.GET.get('page') if request.GET.get('page') else 1
    context = {
        'title': 'Projects List',
        'projects': projects,
        'pages': str(projects_pages.num_pages),
        'current_page': str(current_page)
    }
    return render(request, 'cpanel/projects/project_list.html', context)
예제 #12
0
def case_list(request):
    cases = Case.objects.all()

    # Delete
    if request.is_ajax():
        if request.method == 'POST':
            get_object_or_none(Case, case_id=request.POST.get('id')).delete()
            get_object_or_none(Contribution,
                               id=request.POST.get('id')).delete()

    # Search
    if request.method == 'GET':
        query = request.GET.get('search')
        if query:
            cases = cases.filter(
                Q(case_id__id__icontains=query) | Q(code__icontains=query)
                | Q(case_id__amount__icontains=query)
                | Q(case_id__is_urgent__icontains=query)).distinct()

    # Import from excel
    if request.method == 'POST':
        import_cases(request.FILES.get('file'))  # handel excel files

    # Pagination
    cases_pages = Paginator(cases, 20)
    cases = cases_pages.get_page(request.GET.get('page'))
    current_page = request.GET.get('page') if request.GET.get('page') else 1
    context = {
        'title': 'Cases list',
        'cases': cases,
        'pages': str(cases_pages.num_pages),
        'current_page': str(current_page)
    }
    return render(request, 'cpanel/cases/case_list.html', context)
예제 #13
0
def Stakeholder_add(request):
    if request.is_ajax():
        if request.method == 'POST':
            if get_object_or_none(
                    Stakeholders,
                    national_number=request.POST.get('national_number')):
                return HttpResponseNotFound(
                    "This Stakeholder data is already stored")

            hide = True if request.POST.get('hide') == 'on' else False

            stakeholder = get_object_or_none(
                Stakeholders,
                national_number=request.POST.get('national_number'))
            if not stakeholder:
                # Add User to django
                user = User.objects.create_user(
                    username=request.POST.get('national_number'),
                    password=request.POST.get('password'),
                    is_staff=True)

                # Add user to the group
                group = Group.objects.get(name='Stakeholder')
                group.user_set.add(user)

                date = request.POST.get('birthday').split('-')
                date = f'{date[2]}-{date[0]}-{date[1]}'

                stakeholder = Stakeholders.objects.create(
                    stakeholder_name=request.POST.get('stakeholder_name'),
                    national_number=request.POST.get('national_number'),
                    stakeholder_last_name=request.POST.get(
                        'stakeholder_last_name'),
                    birthday=date,
                    gender=request.POST.get('gender'),
                    email=request.POST.get('email'),
                    marital_status=request.POST.get('marital_status'),
                    nationality=request.POST.get('nationality'),
                    cv=request.POST.get('cv'),
                    stakeholder_type=request.POST.get('stakeholder_type'),
                    user=user)
                if request.FILES.get('image'):
                    stakeholder.image = request.FILES.get('image')
                    stakeholder.save()

                for phone in request.POST.getlist('phone'):
                    StakeholdersPhones.objects.create(
                        national_number=stakeholder, phone=phone)

                for address in request.POST.getlist('address'):
                    StakeholdersAddress.objects.create(
                        national_number=stakeholder, address=address)

            else:
                group = Group.objects.get(name='Stakeholder')
                group.user_set.add(stakeholder.user)

            return HttpResponse()
    return render(request, 'cpanel/Stakeholders/Stakeholders_add.html')
예제 #14
0
def Lab_add(request):
    if request.is_ajax():
        if request.method == 'POST':
            if get_object_or_none(Labs, lab=request.POST.get('lab')):
                return HttpResponseNotFound("This lab data is already stored")

            hide = True if request.POST.get('hide') == 'on' else False

            medical_institution = get_object_or_none(
                MedicalInstitutions,
                institution_id=request.POST.get('institution_id'))
            if not medical_institution:
                # Add User to django
                user = User.objects.create_user(
                    username=request.POST.get('institution_id'),
                    password=request.POST.get('password'),
                    is_staff=True)

                # Add user to the group
                group = Group.objects.get(name='Lab')
                group.user_set.add(user)

                medical_institution = MedicalInstitutions.objects.create(
                    institution_id=request.POST.get('institution_id'),
                    institution_name=request.POST.get('institution_name'),
                    user=user)

                if request.FILES.get('image'):
                    medical_institution.image = request.FILES.get('image')
                    medical_institution.save()

                for phone in request.POST.getlist('phone'):
                    MedicalInstitutionsPhone.objects.create(
                        institution=medical_institution, phone=phone)

                for address in request.POST.getlist('address'):
                    MedicalInstitutionsAddress.objects.create(
                        institution=medical_institution, address=address)

            else:
                group = Group.objects.get(name='Lab')
                group.user_set.add(medical_institution.user)

            lab = Labs.objects.create(lab=medical_institution,
                                      email=request.POST.get('email'),
                                      fax=request.POST.get('fax'),
                                      hide=hide)

            for analysis in request.POST.getlist('analysis_and_radiology'):
                LabsAnalysisAndRadiology.objects.create(
                    lab=lab, analysis_and_radiology=analysis)

            return HttpResponse()

    return render(request, 'cpanel/Lab/Labs_add.html')
예제 #15
0
파일: Mohamedviews.py 프로젝트: Yory1/HC-1
def Doctor_add(request):
    if request.is_ajax():
        if request.method == 'POST':
            print(request.POST)
            if get_object_or_none(Physician, physician_nn=request.POST.get('national_number')):
                return HttpResponseNotFound("This doctor data is already stored")

            # data preprocessing
            hide = True if request.POST.get('hide') == 'on' else False
            date = request.POST.get('birthday').split('-')
            date = f'{date[2]}-{date[0]}-{date[1]}'

            stakeholder = get_object_or_none(Stakeholders, national_number=request.POST.get('national_number'))
            if not stakeholder:
                stakeholder = Stakeholders.objects.create(
                    stakeholder_name=request.POST.get('stakeholder_name'),
                    national_number=request.POST.get('national_number'),
                    stakeholder_last_name=request.POST.get('stakeholder_last_name'),
                    password=request.POST.get('password'),
                    birthday=date,
                    gender=request.POST.get('gender'),
                    email=request.POST.get('email'),
                    marital_status=request.POST.get('marital_status'),
                    nationality=request.POST.get('nationality'),
                    cv=request.POST.get('cv'),
                    image=request.FILES.get('image')
                )

            physician = Physician.objects.create(
                physician_nn=stakeholder,
                title=request.POST.get('title'),
                hide=hide
            )

            for specialization in request.POST.getlist('specialization'):
                PhysicianSpecialization.objects.create(
                    physician_nn=physician,
                    specialization=specialization
                )

            for phone in request.POST.getlist('Phone'):
                StakeholdersPhones.objects.create(
                    national_number=stakeholder,
                    phone=phone
                )

            for address in request.POST.getlist('address'):
                StakeholdersAddress.objects.create(
                    national_number=stakeholder,
                    address=address
                )

            return HttpResponse()
    return render(request, 'cpanel/Doctor/Doctor_add.html')
예제 #16
0
파일: Mohamedviews.py 프로젝트: Yory1/HC-1
def Patient_add(request):
    if request.is_ajax():
        if request.method == 'POST':
            if get_object_or_none(Patient, patient_nn=request.POST.get('national_number')):
                return HttpResponseNotFound("This Patient data is already stored")

            hide = True if request.POST.get('hide') == 'on' else False

            stakeholder = get_object_or_none(Stakeholders, national_number=request.POST.get('national_number'))
            if not stakeholder:
                date = request.POST.get('birthday').split('-')
                date = f'{date[2]}-{date[0]}-{date[1]}'
                stakeholder = Stakeholders.objects.create(
                    stakeholder_name=request.POST.get('stakeholder_name'),
                    national_number=request.POST.get('national_number'),
                    stakeholder_last_name=request.POST.get('stakeholder_last_name'),
                    password=request.POST.get('password'),
                    birthday=date,
                    gender=request.POST.get('gender'),
                    email=request.POST.get('email'),
                    marital_status=request.POST.get('marital_status'),
                    nationality=request.POST.get('nationality'),
                    cv=request.POST.get('cv'),
                    image=request.FILES.get('image')
                )

            print(hide)
            patient = Patient.objects.create(
                patient_nn=stakeholder,
                blood_type=request.POST.get('blood_type'),
                chronic_diseases_name=request.POST.get('chronic_diseases_name'),
                chronic_diseases_type=request.POST.get('chronic_diseases_type'),
                hide=hide
            )

            for phone in request.POST.getlist('Phone'):
                StakeholdersPhones.objects.create(
                    national_number=stakeholder,
                    phone=phone
                )
            for phone in request.POST.getlist('relatives_phones'):
                PatientRelativesPhones.objects.create(
                    patient_nn=patient,
                    phone=phone
                )
            for address in request.POST.getlist('address'):
                StakeholdersAddress.objects.create(
                    national_number=stakeholder,
                    address=address
                )

            return HttpResponse()
    return render(request, 'cpanel/Patient/Patient_add.html')
예제 #17
0
파일: Mohamedviews.py 프로젝트: Yory1/HC-1
def Nurse_add(request):
    if request.is_ajax():
        if request.method == 'POST':
            if get_object_or_none(Nurse, nurse_nn=request.POST.get('national_number')):
                return HttpResponseNotFound("This Nurse data is already stored")

            hide = True if request.POST.get('hide') == 'on' else False

            stakeholder = get_object_or_none(Stakeholders, national_number=request.POST.get('national_number'))
            if not stakeholder:
                date = request.POST.get('birthday').split('-')
                date = f'{date[2]}-{date[0]}-{date[1]}'
                stakeholder = Stakeholders.objects.create(
                    stakeholder_name=request.POST.get('stakeholder_name'),
                    national_number=request.POST.get('national_number'),
                    stakeholder_last_name=request.POST.get('stakeholder_last_name'),
                    password=request.POST.get('password'),
                    birthday=date,
                    gender=request.POST.get('gender'),
                    email=request.POST.get('email'),
                    marital_status=request.POST.get('marital_status'),
                    nationality=request.POST.get('nationality'),
                    cv=request.POST.get('cv'),
                    image=request.FILES.get('image')
                )

            nurse = Nurse.objects.create(
                nurse_nn=stakeholder,
                hide=hide
            )

            for phone in request.POST.getlist('Phone'):
                StakeholdersPhones.objects.create(
                    national_number=stakeholder,
                    phone=phone
                )

            for address in request.POST.getlist('address'):
                StakeholdersAddress.objects.create(
                    national_number=stakeholder,
                    address=address
                )
            for specialization in request.POST.getlist('specialization'):
                NurseSpecialization.objects.create(
                    nurse_nn=nurse,
                    specialization=specialization
                )

            return HttpResponse()
    return render(request, 'cpanel/Nurse/Nurse_add.html')
예제 #18
0
def Lab_list(request):
    if str(request.user.groups.all().first()) == 'Nurse':
        labs = set()
        user = request.user
        labNurses = LabNurses.objects.all().filter(
            Q(nurse_nn__nurse_nn__user=user)).distinct()
        for nurses in labNurses:
            labs.add(nurses.lab)

    elif str(request.user.groups.all().first()) == 'Specialist':
        labs = set()
        user = request.user
        labSpecialists = LabSpecialists.objects.all().filter(
            Q(specialist_nn__specialist_nn__user=user)).distinct()
        for specialists in labSpecialists:
            labs.add(specialists.lab)
    else:
        labs = Labs.objects.all().filter(hide=False)

    if request.method == 'POST':
        lab = get_object_or_none(Labs, lab=request.POST.get('id'))
        if lab:
            lab.hide = True
            lab.save()
    context = {
        "labs": labs,
    }
    return render(request, 'cpanel/Lab/Lab_list.html', context)
예제 #19
0
def donor_add(request):
    if request.is_ajax():
        if request.method == 'POST':
            donor = get_object_or_none(User,
                                       username=request.POST.get('username'))
            if donor:
                return HttpResponseBadRequest('This Donor is already exists')

            user = User.objects.create_user(
                username=request.POST.get('username'),
                password=request.POST.get('password'),
            )
            Donor.objects.create(
                name=request.POST.get('name'),
                user=user,
                city_1=request.POST.get('city_1'),
                country_1=request.POST.get('country_1'),
                apartment_no_1=request.POST.get('apartment_no_1'),
                building_1=request.POST.get('building_1'),
                area_1=request.POST.get('area_1'),
                phone_1=request.POST.get('phone_1'),
                street_1=request.POST.get('street_1'),
                floor_1=request.POST.get('floor_1'),
                address_1=request.POST.get('address_1'),
                city_2=request.POST.get('city_2'),
                country_2=request.POST.get('country_2'),
                apartment_no_2=request.POST.get('apartment_no_2'),
                building_2=request.POST.get('building_2'),
                area_2=request.POST.get('area_2'),
                phone_2=request.POST.get('phone_2'),
                street_2=request.POST.get('street_2'),
                floor_2=request.POST.get('floor_2'),
                address_2=request.POST.get('address_2'))
    context = {'title': 'Donor Add'}
    return render(request, 'cpanel/Donors/donor_add.html', context)
예제 #20
0
def Patient_history_list(request):
    if request.user.groups.filter(name__in=['Paramedic', 'Admin']):
        patients_history = PatientHistory.objects.all().filter(hide=False)

    elif str(request.user.groups.all().first()) == 'Patient':
        user = request.user
        patients_history = PatientHistory.objects.all().filter(
            Q(hide=False) &
            Q(patient_nn__patient_nn__user=user)).distinct()

    elif str(request.user.groups.all().first()) == 'Physician':
        patients = set()
        user = request.user
        patients_history = PatientHistory.objects.all().filter(
            Q(hide=False) &
            Q(physician_nn__physician_nn__user=user)).distinct()
        for history in patients_history:
            patients.add(history.patient_nn)
    else:
        patients_history = PatientHistory.objects.all().filter(hide=False)

    if request.method == 'POST':
        history = get_object_or_none(PatientHistory, id=request.POST.get('id'))
        if history:
            history.hide = True
            history.save()
    context = {
        "patients_history": patients_history,
    }
    return render(request, 'cpanel/Patient/Patient_History_list.html', context)
예제 #21
0
def Patient_list(request):
    if str(request.user.groups.all().first()) == 'Physician':
        patients = set()
        user = request.user
        patient_history = PatientHistory.objects.all().filter(
            Q(hide=False) &
            Q(physician_nn__physician_nn__user=user)).distinct()
        for history in patient_history:
            patients.add(history.patient_nn)

    elif str(request.user.groups.all().first()) == 'Hospital':
        patients = set()
        user = request.user
        hospitals = HospitalRating.objects.all().filter(
            Q(hospital__hospital__user=user)).distinct()
        for hospital in hospitals:
            patients.add(hospital.patient_nn)

    else:
        patients = Patient.objects.all().filter(hide=False)

    if request.method == 'POST':
        patient = get_object_or_none(Patient, patient_nn=request.POST.get('id'))
        if patient:
            patient.hide = True
            patient.save()
    context = {
        "patients": patients,
    }
    return render(request, 'cpanel/Patient/Patient_list.html', context)
예제 #22
0
def Insurance_Company_add(request):
    if request.is_ajax():
        if request.method == 'POST':
            if get_object_or_none(InsuranceCompanies,
                                  company_id=request.POST.get('company_id')):
                return HttpResponseNotFound(
                    "This Insurance Company data is already stored")

            hide = True if request.POST.get('hide') == 'on' else False

            company = InsuranceCompanies.objects.create(
                company_id=request.POST.get('company_id'),
                email=request.POST.get('email'),
                fax=request.POST.get('fax'),
                company_name=request.POST.get('company_name'),
                company_type=request.POST.get('company_type'),
                hide=hide)

            for phone in request.POST.getlist('phone'):
                InsuranceCompaniesPhone.objects.create(company=company,
                                                       phone=phone)

            for address in request.POST.getlist('address'):
                InsuranceCompaniesAddress.objects.create(company=company,
                                                         address=address)

            return HttpResponse()
    return render(request,
                  'cpanel/Insurance Company/Insurance_Company_add.html')
예제 #23
0
def Medical_Institution_add(request):
    if request.is_ajax():
        if request.method == 'POST':
            if get_object_or_none(
                    MedicalInstitutions,
                    institution_id=request.POST.get('institution_id')):
                return HttpResponseNotFound(
                    "This Medical Institutions data is already stored")

            hide = True if request.POST.get('hide') == 'on' else False

            Medical_Institutions = MedicalInstitutions.objects.create(
                institution_id=request.POST.get('institution_id'),
                image=request.FILES.get('image'),
                institution_name=request.POST.get('institution_name'),
                hide=hide,
            )

            for phone in request.POST.getlist('Phone'):
                MedicalInstitutionsPhone.objects.create(
                    institution=Medical_Institutions, phone=phone)

            for address in request.POST.getlist('address'):
                MedicalInstitutionsAddress.objects.create(
                    institution=Medical_Institutions, address=address)

            return HttpResponse()

    return render(request,
                  'cpanel/Medical Institutions/Medical_institution_add.html')
예제 #24
0
def get_image_url(value):
    user = get_object_or_none(User, username=value)
    stakeholder = get_object_or_none(Stakeholders, user=user)
    name = None
    if stakeholder:
        image = stakeholder.image.url
    else:
        medical_institution = get_object_or_none(MedicalInstitutions,
                                                 user=user)
        if medical_institution:
            image = medical_institution.image.url
        else:
            insurance_company = get_object_or_none(InsuranceCompanies,
                                                   user=user)
            if insurance_company:
                image = insurance_company.image.url
    return image
예제 #25
0
def allowed_users(user, allowed_groups):
    user = get_object_or_none(User, username=user)
    allowed_roles = allowed_groups.split(',')

    if user:
        group = user.groups.filter(name__in=allowed_roles).exists()
        return group
    return None
예제 #26
0
    def get(self, request, username):
        user = get_object_or_404(User, username=username)
        token = get_object_or_none(Token, user=user)
        if not token:
            token = Token.objects.create(user=user)

        data = {'token': token.key}
        return Response(data, status=status.HTTP_200_OK)
예제 #27
0
def get_name(value):
    user = get_object_or_none(User, username=value)
    stakeholder = get_object_or_none(Stakeholders, user=user)
    name = None
    if stakeholder:
        name = stakeholder.stakeholder_name
    else:
        medical_institution = get_object_or_none(MedicalInstitutions,
                                                 user=user)
        if medical_institution:
            name = medical_institution.institution_name
        else:
            insurance_company = get_object_or_none(InsuranceCompanies,
                                                   user=user)
            if insurance_company:
                name = insurance_company.company_name

    return name
예제 #28
0
파일: Mohamedviews.py 프로젝트: Yory1/HC-1
def Pharmacy_add(request):
    if request.is_ajax():
        if request.method == 'POST':
            if get_object_or_none(Pharmacy, pharmacy=request.POST.get('lab')):
                return HttpResponseNotFound("This Pharmacy data is already stored")

            hide = True if request.POST.get('hide') == 'on' else False

            Medical_Institutions = MedicalInstitutions.objects.create(
                institution_id=request.POST.get('institution_id'),
                image=request.FILES.get('image'),
                institution_name=request.POST.get('institution_name'),
                hide=hide,
            )

            for phone in request.POST.getlist('phone'):
                MedicalInstitutionsPhone.objects.create(
                    institution=Medical_Institutions,
                    phone=phone
                )

            for address in request.POST.getlist('address'):
                MedicalInstitutionsAddress.objects.create(
                    institution=Medical_Institutions,
                    address=address
                )

            owner = get_object_or_none(Pharmacist, pharmacist_nn=request.POST.get('owner'))
            print(request.POST.get('owner'))
            if not owner:
                return HttpResponseNotFound("This Pharmacist data is not stored")

            Pharmacy.objects.create(
                pharmacy=Medical_Institutions,
                pharmacy_type=request.POST.get('pharmacy_type'),
                owner=owner,
                hide=hide,
            )

            return HttpResponse()

    return render(request, 'cpanel/Pharmacy/Pharmacy_add.html')
예제 #29
0
def Physician_Clinic_Working_Time_add(request):
    if request.is_ajax():
        if request.method == 'POST':
            physician = get_object_or_none(
                Physician, physician_nn=request.POST.get('physician_nn'))
            if not physician:
                return HttpResponseNotFound(
                    "This Doctor national number not exists")

            clinic = get_object_or_none(Clinic,
                                        clinic=request.POST.get('clinic'))
            if not clinic:
                return HttpResponseNotFound("This Clinic ID number not exists")

            for day in request.POST.getlist('week_day'):
                work_day = PhysicianClinicWorkingTime.objects.filter(
                    physician_nn=physician,
                    clinic=clinic,
                    week_day=day,
                    start_time=request.POST.get('start_time'),
                    end_time=request.POST.get('end_time'))
                if work_day.count():
                    return HttpResponseNotFound(
                        "This working day data is already stored you can go to working days edit"
                    )

            hide = True if request.POST.get('hide') == 'on' else False

            for day in request.POST.getlist('week_day'):
                PhysicianClinicWorkingTime.objects.create(
                    physician_nn=physician,
                    clinic=clinic,
                    week_day=day,
                    start_time=request.POST.get('start_time'),
                    end_time=request.POST.get('end_time'),
                    fee=request.POST.get('fee'),
                    hide=hide,
                )
            return HttpResponse()

    return render(request,
                  'cpanel/Clinic/Physician_Clinic_working_time_add.html')
예제 #30
0
def Pharmacist_list(request):
    pharmacists = Pharmacist.objects.all().filter(hide=False)
    if request.method == 'POST':
        pharmacist = get_object_or_none(Pharmacist, pharmacist_nn=request.POST.get('id'))
        if pharmacist:
            pharmacist.hide = True
            pharmacist.save()
    context = {
        "pharmacists": pharmacists,
    }
    return render(request, 'cpanel/Pharmacist/Pharmacist_list.html', context)