Exemplo n.º 1
0
def professional_noncompliant_report(request):
    return generic_form(request,
                        form_class=ProfessionalNoncompliantReportForm,
                        form_kwargs={'user': request.user},
                        page_title='Generate Non-Compliant Report',
                        system_message='Your report has been generated.',
                        send_download_url=True)
Exemplo n.º 2
0
def professional_target_range_report(request):
    return generic_form(request,
                        form_class=ProfessionalTargetRangeReportForm,
                        form_kwargs={'user': request.user},
                        page_title='Generate Target Range Report',
                        system_message='Your report has been generated.',
                        send_download_url=True)
Exemplo n.º 3
0
def import_csv(request, group_id=None):
    try:
        if group_id:
            assert request.user.is_admin()
            group = GenesisGroup.objects.get(pk=group_id)
        else:
            assert request.user.is_professional()
            group = request.user.professional_profile.parent_group
    except (AssertionError, GenesisGroup.DoesNotExist) as e:
        return debug_response(e)

    if request.user.is_admin():
        breadcrumbs = [
            Breadcrumb('Business Partners', reverse('accounts:manage-groups')),
            Breadcrumb(
                'Business Partner: {0}'.format(group.name),
                reverse('accounts:manage-groups-detail', args=[group.pk])),
            Breadcrumb(
                'Professionals',
                reverse('accounts:manage-groups-professionals',
                        args=[group.pk]))
        ]
    else:
        breadcrumbs = []

    return generic_form(request,
                        form_class=ImportProfessionalForm,
                        form_kwargs={
                            'requester': request.user,
                            'initial_group': group
                        },
                        page_title='Import Professional',
                        breadcrumbs=breadcrumbs,
                        system_message='The professionals have been imported')
Exemplo n.º 4
0
def audit_average(request):
    return generic_form(request,
                        form_class=AverageReportForm,
                        form_kwargs={'requester': request.user},
                        page_title='Generate Daily Average Report',
                        system_message='Your report has been generated.',
                        send_download_url=True)
Exemplo n.º 5
0
def edit(request, patient_id, group_id=None):
    try:
        if group_id:
            group = GenesisGroup.objects.get(pk=group_id)
            patient = group.get_patients().filter(
                patient_profile__demo_patient=True).get(pk=patient_id)
        else:
            patient = User.objects.filter(
                patient_profile__demo_patient=True).get(pk=patient_id)
            group = patient.patient_profile.get_group()
    except (GenesisGroup.DoesNotExist, User.DoesNotExist) as e:
        return HttpResponse(repr(e), status=500)

    form_kwargs = {'instance': patient, 'initial_group': group}

    breadcrumbs = [
        Breadcrumb('Business Partners', reverse('accounts:manage-groups')),
        Breadcrumb('Business Partner: {0}'.format(group.name),
                   reverse('accounts:manage-groups-detail', args=[group.pk])),
        Breadcrumb('Demo Patients'.format(group.name),
                   reverse('accounts:manage-groups-demo', args=[group.pk])),
        Breadcrumb(
            'Patient: {0}'.format(patient.get_reversed_name()),
            reverse('accounts:manage-patients-detail', args=[patient.pk]))
    ]

    return generic_form(request,
                        form_class=DemoPatientForm,
                        page_title='Edit %s' % patient,
                        system_message="The patient has been updated.",
                        breadcrumbs=breadcrumbs,
                        form_kwargs=form_kwargs)
Exemplo n.º 6
0
def edit(request, patient_id=None, group_id=None):
    try:
        if patient_id:
            assert request.user.is_professional()
            patient = request.user.professional_profile.get_patients().get(
                pk=patient_id)
        else:
            assert request.user.is_patient()
            patient = request.user
    except (User.DoesNotExist, AssertionError) as e:
        return debug_response(e)

    try:
        hi = HealthInformation.objects.get(patient=patient)
    except HealthInformation.DoesNotExist:
        hi = HealthInformation(patient=patient)
    message = '%s health information has been updated.' % (
        request.user.is_patient() and 'Your' or 'The patient\'s')
    return generic_form(request,
                        form_class=HealthInformationForm,
                        page_title='Edit Health Targets',
                        system_message=message,
                        go_back_until=[
                            'edit-health-information-for-patient',
                            'edit-health-information'
                        ],
                        form_kwargs={'instance': hi})
Exemplo n.º 7
0
def edit(request, company_id, group_id=None):
    if group_id:
        if not request.user.is_admin():
            return HttpResponseNotFound()
        group = GenesisGroup.objects.get(pk=group_id)
    else:
        if not request.user.is_professional():
            return HttpResponseNotFound()
        group = request.user.professional_profile.parent_group
    company = group.companies.get(pk=company_id)

    if request.user.is_admin():
        breadcrumbs = [
            Breadcrumb('Business Partners',
                       reverse('accounts:manage-groups')),
            Breadcrumb(
                'Business Partner: {0}'.format(group.name),
                reverse('accounts:manage-groups-detail',
                        args=[group.pk])),
            Breadcrumb(
                'Companies',
                reverse('accounts:manage-groups-companies',
                        args=[group.pk]))
        ]
    else:
        breadcrumbs = []

    return generic_form(
        request,
        form_class=CompanyForm,
        page_title='Edit Group/Employer',
        system_message="The group/employer has been updated.",
        breadcrumbs=breadcrumbs,
        form_kwargs={'initial_group': group, 'instance': company})
Exemplo n.º 8
0
def add(request, group_id=None):
    try:
        if group_id:
            assert request.user.is_admin()
            group = GenesisGroup.objects.get(pk=group_id)
            page_title = "Add Payor/TPA for %s" % group
        else:
            assert request.user.is_professional()
            group = request.user.professional_profile.parent_group
            page_title = "Add Payor/TPA"
    except (GenesisGroup.DoesNotExist, AssertionError) as e:
        return debug_response(e)

    if request.user.is_admin():
        breadcrumbs = [
            Breadcrumb('Business Partners', reverse('accounts:manage-groups')),
            Breadcrumb(
                'Business Partner: {0}'.format(group.name),
                reverse('accounts:manage-groups-detail', args=[group.pk])),
            Breadcrumb(
                'Payors',
                reverse('accounts:manage-groups-payors', args=[group.pk]))
        ]
    else:
        breadcrumbs = []

    return generic_form(request,
                        form_class=PayorForm,
                        page_title=page_title,
                        system_message="The payor/TPA has been created.",
                        breadcrumbs=breadcrumbs,
                        form_kwargs={'initial_group': group})
Exemplo n.º 9
0
def batch_unassign(request, group_id=None):
    try:
        if group_id:
            assert request.user.is_admin()
            group = GenesisGroup.objects.get(pk=group_id)
        else:
            assert request.user.is_professional()
            group = request.user.professional_profile.parent_group
    except (GenesisGroup.DoesNotExist, AssertionError) as e:
        return debug_response(e)

    if request.user.is_admin():
        batch_queryset = group.get_patients()
    else:
        batch_queryset = request.user.professional_profile.get_patients()

    return generic_form(
        request,
        form_class=BatchUnassignPatientForm,
        page_title='Assign Patients',
        system_message="The patients have been unassigned.",
        batch=True,
        go_back_until=[
            'accounts:manage-patients', 'accounts:manage-groups-patients'],
        only_batch_input=True,
        batch_queryset=batch_queryset
    )
Exemplo n.º 10
0
def batch_assign(request, group_id=None):
    try:
        if group_id:
            assert request.user.is_admin()
            group = GenesisGroup.objects.get(pk=group_id)
        else:
            assert request.user.is_professional()
            group = request.user.professional_profile.parent_group
    except (GenesisGroup.DoesNotExist, AssertionError) as e:
        return debug_response(e)

    if request.user.is_admin():
        batch_queryset = group.get_patients()
    else:
        batch_queryset = request.user.professional_profile.get_patients()

    return generic_form(
        request,
        form_class=BatchAssignPatientForm,
        page_title='Assign Patients',
        system_message="The patients have been assigned.",
        form_kwargs={'professionals': group.get_professionals()},
        batch=True,
        batch_queryset=batch_queryset
    )
Exemplo n.º 11
0
def import_csv(request, group_id=None):
    if group_id:
        if not request.user.is_admin():
            return HttpResponseNotFound()
        group = GenesisGroup.objects.get(pk=group_id)
    else:
        if not request.user.is_professional():
            return HttpResponseNotFound()
        group = request.user.professional_profile.parent_group

    if request.user.is_admin():
        breadcrumbs = [
            Breadcrumb('Business Partners',
                       reverse('accounts:manage-groups')),
            Breadcrumb(
                'Business Partner: {0}'.format(group.name),
                reverse('accounts:manage-groups-detail',
                        args=[group.pk])),
            Breadcrumb(
                'Companies',
                reverse('accounts:manage-groups-companies',
                        args=[group.pk]))
        ]
    else:
        breadcrumbs = []

    return generic_form(
        request,
        form_class=ImportCompaniesForm,
        form_kwargs={'initial_group': group},
        page_title='Import Companies for %s' % group,
        breadcrumbs=breadcrumbs,
        system_message='The companies have been imported')
Exemplo n.º 12
0
def import_devices(request, group_id=None):
    group = None
    if group_id:
        try:
            group = GenesisGroup.objects.get(pk=group_id)
        except GenesisGroup.DoesNotExist as e:
            return debug_response(e)
        else:
            form_kwargs = {'group': group}
    else:
        form_kwargs = {}

    breadcrumbs = [
        Breadcrumb('Business Partners', reverse('accounts:manage-groups')),
        Breadcrumb('Business Partner: {0}'.format(group.name),
                   reverse('accounts:manage-groups-detail', args=[group.pk])),
        Breadcrumb('Devices'.format(group.name),
                   reverse('accounts:manage-groups-devices', args=[group.pk])),
    ]

    return generic_form(request,
                        page_title='Import Devices',
                        form_class=ImportDevicesForm,
                        form_kwargs=form_kwargs,
                        breadcrumbs=breadcrumbs,
                        system_message='The devices have been imported.')
Exemplo n.º 13
0
def update_email(request):  # REFACTOR
    return generic_form(request,
                        form_class=UpdateEmailForm,
                        form_kwargs={'user': request.user},
                        page_title='Update Your Email Address',
                        system_message='Your email address has been updated.',
                        form_template='accounts/update_email.html')
Exemplo n.º 14
0
def batch_update_device_status(request):
    return generic_form(request,
                        form_class=BatchUpdateGDriveStatusForm,
                        page_title='Update Device Status',
                        system_message="The devices have been updated.",
                        batch=True,
                        batch_queryset=GDrive.objects.all())
Exemplo n.º 15
0
def batch_recover_readings(request):
    return generic_form(request,
                        form_class=BatchRecoverReadingsForm,
                        page_title='Recover Readings',
                        system_message="The readings have been recovered.",
                        batch=True,
                        batch_queryset=GDrive.objects.all())
Exemplo n.º 16
0
def batch_assign_apipartner(request):
    return generic_form(request,
                        form_class=BatchAssignDeviceAPIPartnerForm,
                        page_title='Assign Devices to a API Partner',
                        system_message="The devices have been assigned.",
                        batch=True,
                        batch_queryset=GDrive.objects.all())
Exemplo n.º 17
0
def edit(request, patient_id, group_id=None):
    try:
        if group_id:
            assert request.user.is_admin()
            group = GenesisGroup.objects.get(pk=group_id)
            patient = group.get_patients().get(pk=patient_id)
        else:
            if request.user.is_professional():
                group = request.user.professional_profile.parent_group
                patient = request.user.professional_profile.get_patients(
                    ['edit-patient-profile']).get(pk=patient_id)
            else:
                patient = PatientProfile.myghr_patients.get_users().get(
                    pk=patient_id)
                group = patient.patient_profile.get_group()
    except (GenesisGroup.DoesNotExist, User.DoesNotExist, AssertionError) as e:
        return debug_response(e)

    breadcrumbs = get_patient_breadcrumbs(patient, request.user)

    return generic_form(
        request,
        form_class=PatientForm,
        page_title='Edit Patient {}'.format(patient.get_reversed_name()),
        system_message="The patient has been updated.",
        form_kwargs={'initial_group': group, 'instance': patient},
        breadcrumbs=breadcrumbs)
Exemplo n.º 18
0
def edit(request, group_id=None):
    if group_id:
        if not request.user.is_admin():
            return HttpResponseNotFound()
        group = GenesisGroup.objects.get(pk=group_id)
        breadcrumbs = [
            Breadcrumb('Business Partners', reverse('accounts:manage-groups')),
            Breadcrumb(
                'Business Partner: {0}'.format(group.name),
                reverse('accounts:manage-groups-detail', args=[group.pk]))
        ]
    else:
        if not request.user.is_professional():
            return HttpResponseNotFound()
        breadcrumbs = []
        group = request.user.professional_profile.parent_group

    return generic_form(
        request,
        form_class=GroupForm,
        page_title='Edit %s' % group,
        thanks_view_name=(request.user.is_professional()
                          and 'accounts:manage-my-group' or None),
        system_message='Business partner information has been updated.',
        breadcrumbs=breadcrumbs,
        form_kwargs={'instance': group})
Exemplo n.º 19
0
def call_log_report(request):
    return generic_form(
        request,
        form_class=CallLogReportForm,
        form_kwargs={'requester': request.user},
        page_title='Generate Call Log',
        system_message='Your report has been generated.',
        send_download_url=True)
Exemplo n.º 20
0
def batch_unassign(request):
    return generic_form(
        request,
        form_class=BatchUnassignDeviceForm,
        go_back_until=['manage-devices', 'manage-groups-devices'],
        batch=True,
        only_batch_input=True,
        batch_queryset=GDrive.objects.all())
Exemplo n.º 21
0
def setup_security(request, **kwargs):  # REFACTOR
    return generic_form(
        request,
        form_class=ConfigureForm,
        form_kwargs={'user': request.user},
        page_title='Set up security questions',
        system_message='Your security questions have been updated.',
        thanks_view_name=reverse('dashboard:home'))
Exemplo n.º 22
0
def reset_password_finish(request, **kwargs):  # REFACTOR
    """This screen appears when the user logs in for the first time
    after having their password reset."""
    return generic_form(request,
                        form_class=ResetPasswordEmailFinishForm,
                        form_kwargs={'requester': request.user},
                        page_title='Change your password',
                        system_message='Your password has been updated.',
                        thanks_view_name=reverse('dashboard:home'))
Exemplo n.º 23
0
def update_password_expired(request):  # REFACTOR
    user = request.user
    return generic_form(request,
                        form_class=UpdatePasswordForm,
                        form_kwargs={'user': user},
                        page_title="Your password has expired",
                        thanks_view_name=reverse(
                            get_home_view_name(request.user)),
                        system_message="Your password has been updated.")
Exemplo n.º 24
0
def batch_unassign_from_partner(request):
    return generic_form(
        request,
        form_class=BatchUnassignFromAPIPartnerForm,
        page_title='Unassign Patients from API Partner',
        system_message="The patients have been unassigned.",
        batch=True,
        batch_queryset=PatientProfile.objects.get_users()
    )
Exemplo n.º 25
0
def batch_recover_readings(request):
    return generic_form(
        request,
        form_class=BatchRecoverReadingsForm,
        page_title='Recover Readings',
        system_message=(
            "Readings for the selected patients have been recovered."),
        batch=True,
        batch_queryset=PatientProfile.objects.get_users()
    )
Exemplo n.º 26
0
def batch_remove_from_watch_list(request):
    return generic_form(
        request,
        form_class=BatchRemoveFromWatchListForm,
        form_kwargs={'requester': request.user},
        system_message='The patients have been removed to your watch list.',
        go_back_until=['accounts:manage-patients'],
        batch=True,
        only_batch_input=True,
        batch_queryset=request.user.professional_profile.get_patients())
Exemplo n.º 27
0
def import_group(request):
    breadcrumbs = [
        Breadcrumb('Business Partners', reverse('accounts:manage-groups')),
    ]
    return generic_form(
        request,
        form_class=ImportGroupsForm,
        page_title='Import Business Partners',
        breadcrumbs=breadcrumbs,
        system_message='The business partners have been imported.')
Exemplo n.º 28
0
def contact(request):
    """Contact form view"""
    return generic_form(
        request,
        form_class=ContactForm,
        form_kwargs={'requester': request.user},
        page_title='Contact Us',
        go_back_until=(('contact:contact-main', ), ),
        system_message=
        'Your message has been sent.  We appreciate your feedback.')
Exemplo n.º 29
0
def add(request):
    breadcrumbs = [
        Breadcrumb('Business Partners', reverse('accounts:manage-groups')),
    ]
    return generic_form(
        request,
        form_class=GroupForm,
        page_title='Add Business Partner',
        breadcrumbs=breadcrumbs,
        system_message='The business partner has been created.')
Exemplo n.º 30
0
def batch_mark_delivery_failed(request):
    return generic_form(request,
                        form_class=BatchMarkFailedDeliveryForm,
                        page_title='Mark Devices With Failed Delivery',
                        system_message="The devices have been updated.",
                        batch=True,
                        only_batch_input=True,
                        form_template='gdrives/mark_failed_delivery.html',
                        batch_queryset=GDrive.objects.filter(
                            status=GDrive.DEVICE_STATUS_ASSIGNED))