Пример #1
0
 def test_basic_create(self):
     "Minimal patient reminder data creation."
     data = self.get_minimal_data()
     form = PatientRemindersForm(data)
     self.assertTrue(form.is_valid(), str(form.errors))
     patient = form.save()
     self.assertEqual(patient.subject_number, 'XXXX')
     # Contact should be created with the same subject number
     self.assertEqual(patient.contact.name, 'XXXX')
Пример #2
0
 def test_with_feeds(self):
     "Save patient with feeds."
     feed = Feed.objects.create(name='test feed')
     data = self.get_minimal_data()
     data['feeds_1'] = [feed.pk, ]
     form = PatientRemindersForm(data)
     self.assertTrue(form.is_valid(), str(form.errors))
     patient = form.save()
     self.assertEqual(patient.contact.feeds.all().count(), 1)
Пример #3
0
 def test_basic_create(self):
     "Minimal patient reminder data creation."
     data = self.get_minimal_data()
     form = PatientRemindersForm(data)
     self.assertTrue(form.is_valid(), str(form.errors))
     patient = form.save()
     self.assertEqual(patient.subject_number, 'XXXX')
     # Contact should be created with the same subject number
     self.assertEqual(patient.contact.name, 'XXXX')
Пример #4
0
 def test_with_reminders(self):
     "Save patient with reminders."
     today = datetime.date.today()
     reminder = Reminder.objects.create(time_of_day='0:00', date=today)
     data = self.get_minimal_data()
     data['reminders_1'] = [reminder.pk, ]
     form = PatientRemindersForm(data)
     self.assertTrue(form.is_valid(), str(form.errors))
     patient = form.save()
     self.assertEqual(patient.contact.reminders.all().count(), 1)
Пример #5
0
 def test_with_feeds(self):
     "Save patient with feeds."
     feed = Feed.objects.create(name='test feed')
     data = self.get_minimal_data()
     data['feeds_1'] = [
         feed.pk,
     ]
     form = PatientRemindersForm(data)
     self.assertTrue(form.is_valid(), str(form.errors))
     patient = form.save()
     self.assertEqual(patient.contact.feeds.all().count(), 1)
Пример #6
0
 def test_with_reminders(self):
     "Save patient with reminders."
     today = datetime.date.today()
     reminder = Reminder.objects.create(time_of_day='0:00', date=today)
     data = self.get_minimal_data()
     data['reminders_1'] = [
         reminder.pk,
     ]
     form = PatientRemindersForm(data)
     self.assertTrue(form.is_valid(), str(form.errors))
     patient = form.save()
     self.assertEqual(patient.contact.reminders.all().count(), 1)
Пример #7
0
 def test_with_queries(self):
     "Save patient with query schedules."
     today = datetime.date.today()
     query = QuerySchedule.objects.create(
         start_date=today, time_of_day='0:00',
         query_type=1, days_between=4
     )
     data = self.get_minimal_data()
     data['queries_1'] = [query.pk, ]
     form = PatientRemindersForm(data)
     self.assertTrue(form.is_valid(), str(form.errors))
     patient = form.save()
     self.assertEqual(patient.adherence_query_schedules.all().count(), 1)
Пример #8
0
def create_edit_patient(request, patient_id=None):
    if patient_id:
        patient = get_object_or_404(patients.Patient, pk=patient_id)
    else:
        patient = patients.Patient()
    if request.method == 'POST':
        form = PatientRemindersForm(request.POST, instance=patient)
        if form.is_valid():
            form.save()
            messages.info(request, "Patient info saved.")
            return redirect('patient-list')
    else:
        form = PatientRemindersForm(instance=patient)
    context = {'patient': patient, 'form': form}
    return render(request, 'patients/create_edit_patient.html', context)
Пример #9
0
 def test_with_queries(self):
     "Save patient with query schedules."
     today = datetime.date.today()
     query = QuerySchedule.objects.create(start_date=today,
                                          time_of_day='0:00',
                                          query_type=1,
                                          days_between=4)
     data = self.get_minimal_data()
     data['queries_1'] = [
         query.pk,
     ]
     form = PatientRemindersForm(data)
     self.assertTrue(form.is_valid(), str(form.errors))
     patient = form.save()
     self.assertEqual(patient.adherence_query_schedules.all().count(), 1)
Пример #10
0
 def test_patient_reminders_form(self):
     contact = self.create_contact()
     today = datetime.date.today()
     reminder = Reminder.objects.create(time_of_day="0:00", date=today)
     feed = Feed.objects.create(name="test feed")
     query = QuerySchedule.objects.create(start_date=today, time_of_day="0:00", query_type=1, days_between=4)
     data = {
         "contact": contact,
         "subject_number": "foo",
         "mobile_number": "999555121212",
         "daily_doses": "1",
         "reminders_1": str(reminder.pk),
         "feeds_1": str(feed.pk),
         "queries_1": str(query.pk),
         "manual_adherence": 80,
     }
     form = PatientRemindersForm(data)
     if form.is_valid():
         form.save()
     else:
         self.fail("Form did not validate: %r" % form.errors)
Пример #11
0
def create_edit_patient(request, patient_id=None):
    if patient_id:
        patient = get_object_or_404(patients.Patient, pk=patient_id)
    else:
        patient = patients.Patient()
    if request.method == 'POST':
        form = PatientRemindersForm(request.POST, instance=patient)
        if form.is_valid():
            form.save()
            messages.info(request, "Patient info saved.")
            return redirect('patient-list')
    else:
        form = PatientRemindersForm(instance=patient)
    context = {'patient': patient, 'form': form}
    return render(request, 'patients/create_edit_patient.html', context)