def load_by_id(cls, examination_id, auth_token):
        response = request_handler.load_patient_details_by_id(
            examination_id, auth_token)
        patient_details = None
        error = None
        case_status = None

        if response.ok:
            case_status = CaseStatus(response.json())
            modes_of_disposal_response = request_handler.load_modes_of_disposal(
                auth_token)
            if modes_of_disposal_response.ok:
                patient_details = PatientDetails(
                    response.json(), modes_of_disposal_response.json(),
                    examination_id)
            else:
                log_api_error('modes of disposal load', '')
                error = handle_error(modes_of_disposal_response, {
                    "action": "loading",
                    "type": "modes of disposal"
                })
        else:
            log_api_error('patient details load', response.text)
            error = handle_error(response, {
                "action": "loading",
                "type": "patient details"
            })
        return patient_details, case_status, error
Example #2
0
 def close_case(cls, auth_token, examination_id):
     response = request_handler.close_case(auth_token, examination_id)
     if response.status_code == status.HTTP_200_OK:
         return response.status_code
     else:
         return handle_error(response, {
             'type': 'case',
             'action': 'closing'
         })
Example #3
0
    def update_outstanding_items(cls, auth_token, examination_id, submission):
        response = request_handler.update_outcomes_outstanding_items(
            auth_token, examination_id, submission)

        if response.status_code == status.HTTP_200_OK:
            return response.status_code
        else:
            return handle_error(response, {
                'type': 'case',
                'action': 'updating'
            })
Example #4
0
    def confirm_coroner_referral(cls, auth_token, examination_id):
        response = request_handler.confirm_coroner_referral(
            auth_token, examination_id)

        if response.status_code == status.HTTP_200_OK:
            return response.status_code
        else:
            return handle_error(response, {
                'type': 'case',
                'action': 'confirming coroner referral'
            })
Example #5
0
    def get_all(cls, auth_token):
        response = request_handler.load_all_users(auth_token)

        if response.status_code == status.HTTP_200_OK:
            users = []
            user_data = response.json().get("users")
            for user in user_data:
                users.append(User(user))
            return users
        else:
            return handle_error(response, {
                'type': 'users',
                'action': 'loading'
            })
Example #6
0
    def load_by_id(cls, examination_id, auth_token):
        response = request_handler.load_case_outcome(auth_token,
                                                     examination_id)

        if response.status_code == status.HTTP_200_OK:
            return CaseOutcome(response.json(), examination_id), CaseStatus(
                response.json()), None
        else:
            log_api_error('case outcome load',
                          response.text if response.content != 'null' else '')
            return None, None, handle_error(response, {
                'type': 'case outcome',
                'action': 'loading'
            })
Example #7
0
    def load_by_id(cls, examination_id, auth_token):
        response = request_handler.load_medical_team_by_id(
            examination_id, auth_token)
        medical_team = None
        error = None
        case_status = None

        if response.ok:
            medical_team = MedicalTeam(response.json(), examination_id)
            case_status = CaseStatus(response.json())
        else:
            log_api_error('medical team load', response.text)
            error = handle_error(response, {
                "action": "loading",
                "type": "medical team"
            })

        return medical_team, case_status, error
Example #8
0
    def load_by_id(cls, examination_id, auth_token):
        response = request_handler.load_case_breakdown_by_id(
            examination_id, auth_token)
        case_breakdown = None
        error = None
        case_status = None

        if response.ok:
            from examinations.models.medical_team import MedicalTeam
            medical_team, case_status, medical_team_error = MedicalTeam.load_by_id(
                examination_id, auth_token)
            if medical_team_error:
                error = medical_team_error
            else:
                case_breakdown = CaseBreakdown(response.json(), medical_team)
        else:
            error = handle_error(response, {
                'type': 'case breakdown',
                'action': 'loading'
            })
        return case_breakdown, case_status, error
Example #9
0
 def test_handle_error_returns_a_generic_error_if_a_non_404_passed_in(self):
     response = SessionMocks.get_unsuccessful_validate_session_response()
     result = handle_error(response, {})
     self.assertEqual(type(result), GenericError)
Example #10
0
 def test_handle_error_returns_a_not_found_error_if_a_404_passed_in(self):
     response = ExaminationMocks.get_unsuccessful_patient_details_load_response(
     )
     result = handle_error(response, {})
     self.assertEqual(type(result), NotFoundError)