Пример #1
0
 def test_formatted_number(self):
     """ Test that contacts get created for patients """
     node = self.create_xml_patient({'Mobile_Number': '(33)-0001112222'})
     payload = self.create_payload([node])
     parse_patient(node, payload)
     patient = payload.patients.all()[0]
     self.assertEqual(patient.contact.phone, '330001112222')
Пример #2
0
 def test_formatted_number(self):
     """ Test that contacts get created for patients """
     node = self.create_xml_patient({"Mobile_Number": "(33)-0001112222"})
     payload = self.create_payload([node])
     parse_patient(node, payload)
     patient = payload.patients.all()[0]
     self.assertEqual(patient.contact.phone, "330001112222")
Пример #3
0
 def test_reminder_time_not_required(self):
     """ Reminder_Time is not required """
     node = self.create_xml_patient({"Reminder_Time": ""})
     payload = self.create_payload([node])
     parse_patient(node, payload)
     self.assertEqual(payload.patients.count(), 1)
     patient = payload.patients.all()[0]
     self.assertFalse(patient.reminder_time)
Пример #4
0
 def test_reminder_time(self):
     """ Parse patient preferred reminder time """
     node = self.create_xml_patient({"Reminder_Time": "12:00"})
     payload = self.create_payload([node])
     parse_patient(node, payload)
     self.assertEqual(payload.patients.count(), 1)
     patient = payload.patients.all()[0]
     self.assertEqual(patient.reminder_time, datetime.time(12, 0))
Пример #5
0
 def test_patient_creation_without_country_code(self):
     """ Test patients missing country code are still inserted """
     node = self.create_xml_patient({"Mobile_Number": "2223334444"})
     payload = self.create_payload([node])
     with patch_settings(COUNTRY_CODE="66"):
         parse_patient(node, payload)
         created = patients.Patient.objects.all()
         self.assertEqual(created[0].mobile_number, "662223334444")
Пример #6
0
 def test_reminder_time_not_required(self):
     """ Reminder_Time is not required """
     node = self.create_xml_patient({'Reminder_Time': ''})
     payload = self.create_payload([node])
     parse_patient(node, payload)
     self.assertEqual(payload.patients.count(), 1)
     patient = payload.patients.all()[0]
     self.assertFalse(patient.reminder_time)
Пример #7
0
 def test_reminder_time(self):
     """ Parse patient preferred reminder time """
     node = self.create_xml_patient({'Reminder_Time': '12:00'})
     payload = self.create_payload([node])
     parse_patient(node, payload)
     self.assertEqual(payload.patients.count(), 1)
     patient = payload.patients.all()[0]
     self.assertEqual(patient.reminder_time, datetime.time(12, 0))
Пример #8
0
 def test_patient_creation_without_country_code(self):
     """ Test patients missing country code are still inserted """
     node = self.create_xml_patient({'Mobile_Number': '2223334444'})
     payload = self.create_payload([node])
     with patch_settings(COUNTRY_CODE='66'):
         parse_patient(node, payload)
         created = patients.Patient.objects.all()
         self.assertEqual(created[0].mobile_number, '662223334444')
Пример #9
0
 def test_new_contact_association(self):
     """ Test that contacts get created for patients """
     node = self.create_xml_patient({"Mobile_Number": "12223334444", "Pin_Code": "4444"})
     payload = self.create_payload([node])
     parse_patient(node, payload)
     patient = payload.patients.all()[0]
     self.assertTrue(patient.contact is not None)
     self.assertEqual(patient.contact.phone, "12223334444")
     self.assertEqual(patient.contact.pin, "4444")
Пример #10
0
 def test_patient_creation(self):
     """ Test that patients get created properly """
     node = self.create_xml_patient({"Mobile_Number": "12223334444"})
     payload = self.create_payload([node])
     parse_patient(node, payload)
     payload = patients.PatientDataPayload.objects.all()[0]
     self.assertEqual(payload.status, "success")
     created = patients.Patient.objects.all()
     self.assertEqual(created.count(), 1)
     self.assertEqual(created[0].mobile_number, "12223334444")
     self.assertEqual(created[0].raw_data.pk, payload.pk)
     self.assertTrue(created[0].contact is not None)
Пример #11
0
 def test_new_contact_association(self):
     """ Test that contacts get created for patients """
     node = self.create_xml_patient({
         'Mobile_Number': '12223334444',
         'Pin_Code': '4444'
     })
     payload = self.create_payload([node])
     parse_patient(node, payload)
     patient = payload.patients.all()[0]
     self.assertTrue(patient.contact is not None)
     self.assertEqual(patient.contact.phone, '12223334444')
     self.assertEqual(patient.contact.pin, '4444')
Пример #12
0
 def test_patient_creation(self):
     """ Test that patients get created properly """
     node = self.create_xml_patient({'Mobile_Number': '12223334444'})
     payload = self.create_payload([node])
     parse_patient(node, payload)
     payload = patients.PatientDataPayload.objects.all()[0]
     self.assertEqual(payload.status, 'success')
     created = patients.Patient.objects.all()
     self.assertEqual(created.count(), 1)
     self.assertEqual(created[0].mobile_number, '12223334444')
     self.assertEqual(created[0].raw_data.pk, payload.pk)
     self.assertTrue(created[0].contact is not None)
Пример #13
0
 def test_update_contact_association(self):
     """ Test that contacts get updated for patients """
     patient1 = self.create_patient({"mobile_number": "12223334444"})
     patient2 = self.create_patient()
     subject_number = patient1.subject_number
     node = self.create_xml_patient({"Subject_Number": subject_number, "Mobile_Number": "43332221111"})
     payload = self.create_payload([node])
     parse_patient(node, payload)
     patient = payload.patients.all()[0]
     self.assertNotEqual(patient.pk, patient2.pk)
     self.assertEqual(patient.pk, patient1.pk)
     self.assertNotEqual(patient.contact.pk, patient2.contact.pk)
     self.assertEqual(patient.contact.pk, patient1.contact.pk)
     self.assertEqual(patient.mobile_number, "43332221111")
     self.assertEqual(patient.contact.phone, "43332221111")
Пример #14
0
 def test_update_contact_association(self):
     """ Test that contacts get updated for patients """
     patient1 = self.create_patient({'mobile_number': '12223334444'})
     patient2 = self.create_patient()
     subject_number = patient1.subject_number
     node = self.create_xml_patient({
         'Subject_Number': subject_number,
         'Mobile_Number': '43332221111'
     })
     payload = self.create_payload([node])
     parse_patient(node, payload)
     patient = payload.patients.all()[0]
     self.assertNotEqual(patient.pk, patient2.pk)
     self.assertEqual(patient.pk, patient1.pk)
     self.assertNotEqual(patient.contact.pk, patient2.contact.pk)
     self.assertEqual(patient.contact.pk, patient1.contact.pk)
     self.assertEqual(patient.mobile_number, '43332221111')
     self.assertEqual(patient.contact.phone, '43332221111')
Пример #15
0
 def test_next_visit_not_required(self):
     """ Next_Visit shoudn't be required """
     node = self.create_xml_patient({"Next_Visit": ""})
     payload = self.create_payload([node])
     parse_patient(node, payload)
     self.assertEqual(payload.patients.count(), 1)
Пример #16
0
 def test_next_visit_not_required(self):
     """ Next_Visit shoudn't be required """
     node = self.create_xml_patient({'Next_Visit': ''})
     payload = self.create_payload([node])
     parse_patient(node, payload)
     self.assertEqual(payload.patients.count(), 1)