예제 #1
0
    def createAppointment(self):
        access_token = self.get_token()
        api = AppointmentEndpoint(access_token)
        params = {}
        params['doctor'] = 252849
        params['duration'] = 1
        params['exam_room'] = 1
        params['office'] = 269267
        params['patient'] = 84394833
        today = datetime.date.today()

        params['scheduled_time'] = today.strftime('%Y-%m-%dT%H:%M:%S')

        api.create(data=params)
예제 #2
0
 def appointments_create(self, params=None, **kwargs):
     """ Obtains Appointments list
         https://app.drchrono.com/api-docs/#operation/appointments_create
     Args:
         params (dict, optional):
             date:	string (date)
             date_range:	string (date_range)
             doctor:	integer (doctor)
             office:	integer (office)
             patient:	integer (patient)
             since:	string (since)
             status:	string (status)
         date (string, optional): Date
         start (string, optional): Start
         end (string, optional):  End
     Returns:
         list: appointments list
     """
     api = AppointmentEndpoint(self.access_token)
     api.create(params, **kwargs)
예제 #3
0
 def create_appointment(self, patientId, timeString):
     api = AppointmentEndpoint(self.get_token())
     s = str(date.today()) + " " + timeString
     print(s)
     ts = parser.parse(s)
     d = ts.isoformat()
     print(d)
     data = {
         'patient': patientId,
         'doctor': 252357,
         'duration': 30,
         'exam_room': 4,
         'office': 268772,
         'status': 'Confirmed',
         'scheduled_time': d
     }
     return api.create(data=data)
예제 #4
0
    def form_valid(self, form):
        """
            update patient info.
            if patient already has an appointment, mark status as arrived
            else create an appointment and mark status as arrived
         """
        print('\n \n form VALID !!')
        todays_date = date.today()
        access_token = utility.get_token()
        patient_api = PatientEndpoint(access_token)

        # update patient demographics
        update_resp = patient_api.update(id=str(self.kwargs['patient_id']),
                                         data=form.cleaned_data)

        # check if this patient has an appointment
        appnt_api = AppointmentEndpoint(access_token)
        appnt_list = list(
            appnt_api.list(
                date=todays_date,
                params={'patient': self.kwargs['patient_id']},
            ))
        print()
        print('appnt_list={}'.format(appnt_list))

        # if appnt doesnt exist create one
        if appnt_list == []:
            new_appt = appnt_api.create(data={
                'date': todays_date,
                'patient': self.kwargs['patient_id']
            })

            print()
            print('new_appt={}'.format(new_appt))

        return super(PatientUpdateProfile, self).form_valid(form)
예제 #5
0
    def post(self, request, *args, **kwargs):
        # create a form instance and populate it with data from the request:
        form = CheckInForm(request.POST)
        # we need to get the list of pacents on the appointment to check if they are checking in or if its a walk-in
        data = request.POST.copy()
        ssn = data.get('ssn')
        access_token = get_token()
        appointment_api = AppointmentEndpoint(access_token)

        if form.is_valid() and check_ssn_format(ssn):
            first_name, last_name, date_of_birth = form.cleaned_data.get('first_name'), \
                                                   form.cleaned_data.get('last_name'), \
                                                   form.cleaned_data.get('date').strftime('%Y-%m-%d')

            # here we get data from App and Pa django objects instead
            p = Patient.objects.get(first_name=first_name,
                                    last_name=last_name,
                                    date_of_birth=date_of_birth,
                                    social_security_number=ssn)
            try:
                p = Patient.objects.get(first_name=first_name,
                                        last_name=last_name,
                                        date_of_birth=date_of_birth,
                                        social_security_number=ssn)
            except Patient.DoesNotExist:
                p = None

            if not p:
                return HttpResponseRedirect('/patient_new/')

            wi = form.cleaned_data.get('walk_in')

            if wi:
                doctor = next(DoctorEndpoint(get_token()).list())
                create_appointment = {
                    'status': 'Arrived',
                    'duration': 30,
                    'date': timezone.now(),
                    'doctor': doctor.get('id'),
                    'patient': p.patient_id,
                    'scheduled_time': timezone.now(),
                    'exam_room': 0,
                    'office': 276816,  # hardcoded for now
                    'notes': 'Walk-In'
                }
                created_appointment = appointment_api.create(
                    create_appointment)

                appointment, created = Appointment.objects.get_or_create(
                    appointment_id=created_appointment.get('id'),
                    patient_id=p.patient_id,
                    scheduled_time=created_appointment.get('scheduled_time'),
                    notes=created_appointment.get('notes'))
            else:
                today = timezone.now()
                try:
                    appointment = Appointment.objects.get(
                        patient_id=p.patient_id,
                        scheduled_time__year=today.year,
                        scheduled_time__month=today.month,
                        scheduled_time__day=today.day)
                except Appointment.DoesNotExist:
                    form.add_error(
                        'first_name',
                        "We are sorry, but we could not find you on todays list, is this a walk-in?"
                    )
                    return render(request, 'patient_check_in.html',
                                  {'form': form})

                appointment_api.update(appointment.appointment_id,
                                       {'status': 'Arrived'})

            if (appointment.status == 'Arrived'):
                # Here we return that they have already checked in
                return redirect('patient_demographic_information',
                                patient_id=p.patient_id)

            appointment.arrival_time = timezone.now()
            appointment.status = 'Arrived'
            appointment.save()
            # redirect to demographic information page
            return redirect('patient_demographic_information',
                            patient_id=p.patient_id)

        form.add_error('ssn', "Please Enter a Valid SSN in format 123-44-1234")

        return render(request, 'patient_check_in.html', {'form': form})
예제 #6
0
 def post_appointment(self, params):
     api = AppointmentEndpoint(self.access_token)
     api.create(data=params)