Exemplo n.º 1
0
    def post(self, request, examination_id):
        post_body = request.POST
        if CaseOutcome.SCRUTINY_CONFIRMATION_FORM_TYPE in post_body:
            result = CaseOutcome.complete_scrutiny(self.user.auth_token, examination_id)
        elif CaseOutcome.CORONER_REFERRAL_FORM_TYPE in post_body:
            result = CaseOutcome.confirm_coroner_referral(self.user.auth_token, examination_id)
        elif CaseOutcome.OUTSTANDING_ITEMS_FORM_TYPE in post_body:
            form = OutstandingItemsForm(post_body)
            result = CaseOutcome.update_outstanding_items(self.user.auth_token, examination_id, form.for_request())
        elif CaseOutcome.CLOSE_CASE_FORM_TYPE in post_body:
            result = CaseOutcome.close_case(self.user.auth_token, examination_id)
        else:
            result = GenericError(BadRequestResponse.new(), {'type': 'form', 'action': 'submitting'})

        if result and not result == status.HTTP_200_OK:
            log_api_error('case outcome update', result.get_message())
            self._log_case_outcome_unsuccessful(post_body, examination_id)
            return render_error(request, self.user, result)

        self._load_case_outcome(examination_id)
        context = self._set_context()

        self._log_case_outcome(post_body)

        return render(request, self.template, context, status=self.status_code)
Exemplo n.º 2
0
    def get(self, request, examination_id):
        self._load_case_outcome(examination_id)
        if self.error:
            return render_error(request, self.user, self.error)

        context = self._set_context()

        return render(request, self.template, context, status=self.status_code)
Exemplo n.º 3
0
    def get(self, request, examination_id):
        self._load_breakdown(examination_id)
        if self.error:
            return render_error(request, self.user, self.error)

        self.medical_team, self.case_status, error = MedicalTeam.load_by_id(examination_id, self.user.auth_token)
        self.patient_details, self.case_status, error = PatientDetails.load_by_id(examination_id, self.user.auth_token)
        self.amend_type = request.GET.get('amendType')

        context = self._set_context(examination_id, False)

        return render(request, self.template, context, status=self.status_code)
Exemplo n.º 4
0
    def dispatch(self, request, *args, **kwargs):
        if self.examination_section == enums.examination_sections.PATIENT_DETAILS:
            self.examination, self.case_status, self.error = PatientDetails.load_by_id(kwargs.get('examination_id'),
                                                                                       self.user.auth_token)
        elif self.examination_section == enums.examination_sections.MEDICAL_TEAM:
            self.examination, self.case_status, self.error = MedicalTeam.load_by_id(kwargs.get('examination_id'),
                                                                                    self.user.auth_token)
        elif self.examination_section == enums.examination_sections.CASE_BREAKDOWN:
            print('not implemented yet')
        elif self.examination_section == enums.examination_sections.CASE_OUTCOMES:
            print('not implemented yet')
        else:
            log_internal_error('EditExaminationSectionBaseView section load', 'Unknown examination section requested')

        if self.error is not None:
            return render_error(request, self.user, self.error)

        return super().dispatch(request, *args, **kwargs)
Exemplo n.º 5
0
    def post(self, request, examination_id):
        post_body = request.POST
        form = VoidCaseForm(post_body)

        if not form.is_valid():
            status_code = status.HTTP_400_BAD_REQUEST
            monitor.log_void_case_unsuccessful(self.user, examination_id)
            context = self._get_context(examination_id, form)

            return render(request, self.template, context, status=status_code)

        else:
            result = Examination.void(examination_id, form.to_object(), self.user.auth_token)

            if result.status_code == status.HTTP_200_OK:
                monitor.log_void_case_success(self.user, examination_id)

                return redirect('void-case-success')

            else:
                log_api_error('void case', result.__dict__)
                monitor.log_void_case_unsuccessful(self.user, examination_id)

                return render_error(request, self.user, result)