示例#1
0
 def fetch_a_patient(self, id='None'):
     """
     Fetch a patient using ID, return the result
     """
     access_token = self.get_token()
     api = PatientEndpoint(access_token)
     return api.fetch(id)
示例#2
0
 def get_patient(self, patient_id):
     """
     Load a patient by id
     """
     access_token = self.get_token()
     api = PatientEndpoint(access_token)
     return api.fetch(patient_id)
 def get(self, request):
     oauth_provider = get_object_or_404(UserSocialAuth, provider='drchrono')
     access_token = oauth_provider.extra_data['access_token']
     patient_client = PatientEndpoint(access_token)
     patient = patient_client.fetch(request.GET.get('patient_id'))
     return render(request, 'demographics.html',
                   {'form': DemographicForm(initial=patient), 'patient_id': request.GET.get('patient_id')})
示例#4
0
    def get(self, request, patient_id):
        # GET send a blank form for the patient
        template = 'patient_details.html'
        access_token = get_token()
        patient_api = PatientEndpoint(access_token)
        patient = patient_api.fetch(patient_id)

        return render(request, template, {'patient': patient})
示例#5
0
    def get_patient_id(self, patient_id):
        """
        :param patient_id:
        :return:
        """

        api = PatientEndpoint(self.access_token)
        return api.fetch(patient_id)
示例#6
0
 def get(self, request, *args, **kwargs):
     '''
     Return patient details
     '''
     patient = request.GET.get('patient')
     doctor_welcome = DoctorWelcome()
     access_token = doctor_welcome.get_token()
     api = PatientEndpoint(access_token)
     patient_data = api.fetch(patient)
     return JsonResponse(patient_data)
示例#7
0
 def fetch_one_patient(self, id):
     """
     Use the token we have stored in the DB to make an API request and get doctor details. If this succeeds, we've
     proved that the OAuth setup is working
     """
     # We can create an instance of an endpoint resource class, and use it to fetch details
     access_token = self.get_token()
     api = PatientEndpoint(access_token)
     # Fetch one patient.
     return api.fetch(id=id)
 def get_initial(self):
     """
     Returns the initial data to use for forms on this view.
     """
     initial = super(PatientInformationView, self).get_initial()
     patient_id = self.kwargs['p_id']
     access_token = get_token()
     api = PatientEndpoint(access_token)
     patient_info = api.fetch(id=patient_id)
     initial = merge_two_dicts(patient_info, initial)
     return initial
示例#9
0
 def get_context_data(self, **kwargs):
     """
     :return: dictionary to populate template data
     """
     print('PatientUpdateProfile get_context_data')
     print('self = ', self)
     print('self.kwargs[patient_id]=', self.kwargs['patient_id'])
     kwargs = super(PatientUpdateProfile, self).get_context_data(**kwargs)
     # get patient using patient_id
     access_token = utility.get_token()
     patient_api = PatientEndpoint(access_token)
     patient = patient_api.fetch(id=str(self.kwargs['patient_id']))
     patient = utility.convert_unicode_to_string(patient)
     print('cellphone = ', patient['cell_phone'])
     kwargs['patient'] = patient
     return kwargs
示例#10
0
 def get_patient_by_id(self, patientId):
     api = PatientEndpoint(self.get_token())
     return api.fetch(id=patientId)
    def verify_patient_has_appointment(params):
        """
        Verify that a patient has a confirmed appointment with the doctor before
        asking for their Demographics information.
        
        parameters = {
            'patient_id',
            'first_name',
            'last_name',
            'appointment_id',
            'override_late'  # Will not exclude this appointment from 
            }
        """

        current_date = datetime.now().strftime("%Y-%m-%d")

        # Check if the patient actually exists.
        patient_api = PatientEndpoint(ChronoOauth.get_token())
        patient = None
        if 'patient_id' in params:
            patient = patient_api.fetch(id=params['patient_id'])
        elif 'first_name' in params and 'last_name' in params:
            patient = PatientService.find_patient_by_name(
                params['first_name'], params['last_name'])

        if not patient:
            return {'error': 'Patient not found in the Doctor\'s database.'}

        api_appt = AppointmentEndpoint(ChronoOauth.get_token())
        if 'appointment_id' in params and params['appointment_id']:
            """
            Check a patient into a specific appointment.
            """
            target_appointment = api_appt.fetch(id=params['appointment_id'])

        else:
            """
            Grab a list of the nearest available Appointment.
            """

            current_appointments = api_appt.list(date=current_date)
            current_appointments_list = list(current_appointments)

            # Determine whether a patient can be seen by the doctor.
            # The api automatically sorts the schedules by the time.
            #TODO: Do not yet factor Early Checkin or Late Arrivals. Just deal with a single status.
            target_appointment = None
            for appointment in current_appointments_list:

                # If a patient has multiple schedules throughout the day,
                # that patient cannot be 'checked_in' twice.
                if appointment['patient'] == patient['id'] and \
                    appointment['status'] in settings.DRCHRONO_VALID_SEEABLE_PATIENTS:
                    break

                if appointment['patient'] == patient['id'] and \
                    appointment['status'] in settings.DRCHRONO_VALID_APPOINTMENTS:

                    # No time to debug this extra functionality...
                    #if 'override_late' not in params or not params['override_late']:
                    #    # If this appointment time is later than the Doctors Practice's
                    #    # Late limit, then skip this appointment.
                    #    scheduled_time = datetime.strptime (appointment['scheduled_time'], "%Y-%m-%dT%H:%M:%S")
                    #    schedule_epoch = (scheduled_time - datetime(1970, 1, 1)).total_seconds()
                    #
                    #    late_time = time.time() - schedule_epoch
                    #    if late_time > settings.PATIENT_LATE_CUTOFF_TIME*60:
                    #        print('wut? {} {}'.format(late_time, settings.PATIENT_LATE_CUTOFF_TIME))
                    #        continue

                    target_appointment = appointment
                    break

                elif appointment['patient'] == patient['id']:
                    pass

        if not target_appointment:
            return {
                'error' : 'Were sorry, it appears you have either: not confirmed an appointment, '+\
                        'have already checked in, are Late (over {} Minutes), rescheduled, etc'.\
                            format(settings.PATIENT_LATE_CUTOFF_TIME)
            }

        return target_appointment
示例#12
0
 def get_patient(self, id):
     access_token = self.get_token()
     api = PatientEndpoint(access_token)
     return api.fetch(id)