Beispiel #1
0
 def append_rows(self, page_object, row_list_to_update):
     if self.registry_model.has_feature("consent_checks"):
         row_list_to_update.extend([
             self._get_row_dict(obj)
             for obj in page_object.object_list if consent_check(
                 self.registry_model, self.user, obj, "see_patient")
         ])
     else:
         row_list_to_update.extend(
             [self._get_row_dict(obj) for obj in page_object.object_list])
Beispiel #2
0
def user_allowed(user, registry_model, patient_model):
    """
    Can user see a cde value to verify -
    """
    from rdrf.helpers.utils import consent_check
    return all([
        user.is_clinician(),
        user.in_registry(registry_model), patient_model.pk
        in [p.id for p in Patient.objects.filter(clinician=user)],
        consent_check(registry_model, user, patient_model, "see_patient")
    ])
Beispiel #3
0
    def get(self, request, registry_code, patient_id):
        if not request.user.is_authenticated:
            patient_edit_url = reverse('patient_edit',
                                       args=[
                                           registry_code,
                                           patient_id,
                                       ])
            login_url = reverse('two_factor:login')
            return redirect("%s?next=%s" % (login_url, patient_edit_url))

        registry_model = Registry.objects.get(code=registry_code)

        section_blacklist = self._check_for_blacklisted_sections(
            registry_model)

        patient, form_sections = self._get_patient_and_forms_sections(
            patient_id, registry_code, request)

        security_check_user_patient(request.user, patient)

        if registry_model.has_feature("consent_checks"):
            from rdrf.helpers.utils import consent_check
            if not consent_check(registry_model, request.user, patient,
                                 "see_patient"):
                raise PermissionDenied

        context_launcher = RDRFContextLauncherComponent(
            request.user, registry_model, patient)
        patient_info = RDRFPatientInfoComponent(registry_model, patient)

        family_linkage_panel = FamilyLinkagePanel(request.user, registry_model,
                                                  patient)

        context = {
            "location":
            "Demographics",
            "context_launcher":
            context_launcher.html,
            "patient_info":
            patient_info.html,
            "forms":
            form_sections,
            "family_linkage_panel":
            family_linkage_panel.html,
            "patient":
            patient,
            "proms_link":
            self._get_proms_link(registry_model, patient),
            "patient_id":
            patient.id,
            "registry_code":
            registry_code,
            "form_links": [],
            "show_archive_button":
            request.user.can_archive,
            "archive_patient_url":
            patient.get_archive_url(registry_model)
            if request.user.can_archive else "",
            "consent":
            consent_status_for_patient(registry_code, patient),
            "section_blacklist":
            section_blacklist
        }
        if request.GET.get('just_created', False):
            context["message"] = _("Patient added successfully")

        context["not_linked"] = not patient.is_linked

        wizard = NavigationWizard(request.user, registry_model, patient,
                                  NavigationFormType.DEMOGRAPHICS, None, None)

        context["next_form_link"] = wizard.next_link
        context["previous_form_link"] = wizard.previous_link

        if request.user.is_parent:
            context['parent'] = ParentGuardian.objects.get(user=request.user)

        hidden_sectionlist = self._check_for_hidden_section(
            request.user, registry_model, form_sections)
        context["hidden_sectionlist"] = hidden_sectionlist

        return render(request, 'rdrf_cdes/patient_edit.html', context)