def test_patient_history(self): """Test that the edit history page works as expected.""" self.login() patient = get_patient() response = self.client.get('/patient_history/{}'.format(patient.id)) self.assert200(response) self.assert_template_used('history.html')
def test_patient_screening_history(self): """Test that the patient referral/screening history page works as expected.""" add_service_data.main(self.app) user = get_user() user.service = Service.query.filter(Service.name == 'Daily Planet').first() self.login() patient = get_patient() # Make sure the page loads as expected response = self.client.get('/patient_screening_history/{}'.format(patient.id)) self.assert200(response) self.assert_template_used('patient_screening_history.html') # Make sure you can save a new screening result response = self.client.post( '/patient_screening_history/{}'.format(patient.id), data=dict( eligible_yn='Y', sliding_scale_id=user.service.sliding_scales[0].id, notes='Test' ), follow_redirects=True ) self.assert200(response) # User should stay on the same page after saving self.assert_template_used('patient_screening_history.html') screening_result = Patient.query.first().screening_results[0] self.assertEquals(screening_result.service_id, user.service_id) self.assertEquals(screening_result.eligible_yn, 'Y') self.assertEquals(screening_result.sliding_scale_id, user.service.sliding_scales[0].id) self.assertEquals(screening_result.notes, 'Test')
def test_patient_share(self): """Test that the share patient page works as expected.""" self.login() patient = get_patient() response = self.client.get('/patient_share/{}'.format(patient.id)) self.assert200(response) self.assert_template_used('patient_share.html')
def test_patient_overview(self): """Test that the patient overview and screening result page works as expected.""" add_service_data.main(self.app) user = get_user() user.service = Service.query.filter( Service.name == 'Daily Planet').first() self.login() patient = get_patient(user) # Make sure the page loads as expected response = self.client.get('/patient_overview/{}'.format(patient.id)) self.assert200(response) self.assert_template_used('patient_overview.html') # Make sure you can save a new screening result response = self.client.post( '/patient_overview/{}'.format(patient.id), data=dict(eligible_yn='Y', sliding_scale_id=user.service.sliding_scales[0].id, notes='Test'), follow_redirects=True) self.assert200(response) # User should stay on the same page after saving self.assert_template_used('patient_overview.html') screening_result = Patient.query.first().screening_results[0] self.assertEquals(screening_result.service_id, user.service_id) self.assertEquals(screening_result.eligible_yn, 'Y') self.assertEquals(screening_result.sliding_scale_id, user.service.sliding_scales[0].id) self.assertEquals(screening_result.notes, 'Test')
def test_patient_share(self): """Test that the share patient page works as expected.""" self.login() patient = get_patient() response = self.client.get('/patient_share/{}'.format(patient.id)) self.assert200(response) self.assert_template_used('patient_share.html')
def test_patient_history(self): """Test that the edit history page works as expected.""" self.login() patient = get_patient() response = self.client.get('/patient_history/{}'.format(patient.id)) self.assert200(response) self.assert_template_used('patient_history.html')
def test_delete_patient(self): """Test that hard-deleting a patient works as expected.""" self.login() patient = get_patient() response = self.client.get('/delete/{}'.format(patient.id), follow_redirects=True) self.assert200(response) # Check that patient was deleted self.assertEquals(len(Patient.query.all()), 0) # Check that user is redirected to index page self.assert_template_used('index.html')
def test_delete_patient(self): """Test that hard-deleting a patient works as expected.""" self.login() patient = get_patient() response = self.client.get('/delete/{}'.format(patient.id), follow_redirects=True) self.assert200(response) # Check that patient was deleted self.assertEquals(len(Patient.query.all()), 0) # Check that user is redirected to index page self.assert_template_used('index.html')
def test_patient_screening_history(self): """Test that the patient referral/screening history page works as expected.""" add_service_data.main(self.app) user = get_user() user.service = Service.query.filter(Service.name == 'Daily Planet').first() self.login() patient = get_patient() # Make sure the page loads as expected response = self.client.get('/patient_screening_history/{}'.format(patient.id)) self.assert200(response) self.assert_template_used('patient_screening_history.html')
def test_add_referral(self): """Test that adding a referral works as expected.""" self.login() user = AppUser.query.first() patient = get_patient() response = self.client.post('/add_referral', data=dict( patient_id=patient.id, app_user_id=user.id, service_id='1' ), follow_redirects=True) self.assert200(response) referral = Patient.query.first().referrals[0] self.assertEquals(referral.from_app_user_id, user.id) self.assertEquals(referral.to_service_id, 1)
def test_patient_screening_history(self): """Test that the patient referral/screening history page works as expected.""" add_service_data.main(self.app) user = get_user() user.service = Service.query.filter( Service.name == 'Daily Planet').first() self.login() patient = get_patient() # Make sure the page loads as expected response = self.client.get('/patient_screening_history/{}'.format( patient.id)) self.assert200(response) self.assert_template_used('patient_screening_history.html')
def test_add_referral(self): """Test that adding a referral works as expected.""" self.login() user = AppUser.query.first() patient = get_patient() response = self.client.post('/add_referral', data=dict( patient_id=patient.id, app_user_id=user.id, service_id='1' ), follow_redirects=True) self.assert200(response) referral = Patient.query.first().referrals[0] self.assertEquals(referral.from_app_user_id, user.id) self.assertEquals(referral.to_service_id, 1)
def test_update_patient(self): """Test that updating an existing patient works as expected.""" self.login() patient = get_patient() # Check that the patient details page loads for an existing patient response = self.client.get('/patient_details/{}'.format(patient.id)) self.assert200(response) self.assert_template_used('patient_details.html') # Check that updates to the patient save, including many-to-one fields post_data = dict( first_name='James', last_name='Richmond', dob='1950-12-12', ssn='222-22-2222', email='*****@*****.**', has_transport_yn='N', gender='M', transgender='No', race='AA', ethnicity='NHL', languages=['EN', 'ES'], has_interpreter_yn='N', education_level='High school', marital_status='MAR', veteran_yn='N', housing_status='REN', years_living_in_area='5', months_living_in_area='1', city_or_county_of_residence='Richmond', temp_visa_yn='N', student_status='Not a student', employment_status='FT', spouse_employment_status='PT', years_unemployed='0', months_unemployed='6', spouse_years_unemployed='1', spouse_months_unemployed='11', years_at_current_employer='0', spouse_years_at_current_employer='10', last_healthcare='Last year at VCU ED', insurance_status='N', coverage_type='VCC', has_prescription_coverage_yn='N', has_vcc='Y', eligible_insurance_types='NE', applied_for_vets_benefits_yn='N', eligible_for_vets_benefits_yn='N', applied_for_medicaid_yn='N', medicaid_date_effective='2015-01-01', applied_for_ssd_yn='N', ssd_date_effective='1999-12-12', care_due_to_accident_yn='N', accident_work_related_yn='N', filed_taxes_yn='N', claimed_as_dependent_yn='N', how_food_and_shelter='Stay with sister', how_other_expenses='Gets money from father' ) post_data['phone_numbers-0-phone_number'] = '(111) 111-1111' post_data['phone_numbers-0-number_description'] = 'cell' post_data['phone_numbers-1-phone_number'] = '(222) 222-2222' post_data['phone_numbers-1-number_description'] = 'home' post_data['addresses-0-address1'] = '1 Main St.' post_data['addresses-0-address2'] = 'Apt. 1' post_data['addresses-0-city'] = 'Richmond' post_data['addresses-0-state'] = 'VA' post_data['addresses-0-zip'] = '11111' post_data['addresses-0-address_description'] = 'home' post_data['addresses-1-address1'] = '1 Maple St.' post_data['addresses-1-address2'] = '' post_data['addresses-1-city'] = 'Richmond' post_data['addresses-1-state'] = 'VA' post_data['addresses-1-zip'] = '11111' post_data['addresses-1-address_description'] = 'mother\'s' post_data['emergency_contacts-0-full_name'] = 'Jane Johnson' post_data['emergency_contacts-0-relationship'] = 'mother' post_data['emergency_contacts-0-phone_number'] = '(111) 111-1111' post_data['emergency_contacts-1-full_name'] = 'Mary Richmond' post_data['emergency_contacts-1-relationship'] = 'sister' post_data['emergency_contacts-1-phone_number'] = '(222) 222-2222' post_data['household_members-0-full_name'] = 'Michael Richmond' post_data['household_members-0-dob'] = '2000-12-12' post_data['household_members-0-ssn'] = '999-99-9999' post_data['household_members-0-relationship'] = 'son' post_data['household_members-1-full_name'] = '11111' post_data['household_members-1-dob'] = '2006-02-28' post_data['household_members-1-ssn'] = '888-88-8888' post_data['household_members-1-relationship'] = 'Emily Richmond' post_data['income_sources-0-source'] = 'job' post_data['income_sources-0-monthly_amount'] = '1000' post_data['income_sources-1-source'] = 'food stamps' post_data['income_sources-1-monthly_amount'] = '200' post_data['employers-0-employer_name'] = 'Target' post_data['employers-0-phone_number'] = '(111) 111-1111' post_data['employers-0-employee'] = 'Patient' post_data['employers-0-start_date'] = '2014-01-01' post_data['employers-1-employer_name'] = 'Walmart' post_data['employers-1-phone_number'] = '(222) 222-2222' post_data['employers-1-employee'] = 'Spouse' post_data['employers-1-start_date'] = '1999-12-12' response = self.client.post( '/patient_details/{}'.format(patient.id), data=post_data, follow_redirects=True ) saved_patient = Patient.query.first() self.assertEquals( saved_patient.first_name, 'James' ) self.assertEquals( saved_patient.last_name, 'Richmond' ) self.assertEquals( saved_patient.dob, datetime.date(1950, 12, 12) ) self.assertEquals( saved_patient.ssn, '222-22-2222' ) self.assertEquals(saved_patient.phone_numbers.count(), 2) self.assertEquals(saved_patient.addresses.count(), 2) self.assertEquals(saved_patient.emergency_contacts.count(), 2) self.assertEquals(saved_patient.household_members.count(), 2) self.assertEquals(saved_patient.income_sources.count(), 2) self.assertEquals(saved_patient.employers.count(), 2) # Check that the user stays on patient details page after saving self.assert_template_used('patient_details.html') # Check that updated many-to-one fields save correctly post_data['phone_numbers-0-phone_number'] = '(333) 333-3333' post_data['phone_numbers-0-number_description'] = 'work' response = self.client.post( '/patient_details/{}'.format(patient.id), data=post_data, follow_redirects=True ) self.assert200(response) saved_patient = Patient.query.first() self.assertEquals(saved_patient.phone_numbers[0].phone_number, '(333) 333-3333') self.assertEquals(saved_patient.phone_numbers[0].number_description, 'work') self.assert_template_used('patient_details.html') # Check that deleting many-to-one fields works as expected post_data['phone_numbers-0-phone_number'] = '' post_data['phone_numbers-0-number_description'] = '' response = self.client.post( '/patient_details/{}'.format(patient.id), data=post_data, follow_redirects=True ) self.assert200(response) self.assertEquals(saved_patient.phone_numbers.count(), 1) self.assertEquals(saved_patient.phone_numbers[0].phone_number, '(222) 222-2222') self.assertEquals(saved_patient.phone_numbers[0].number_description, 'home') self.assert_template_used('patient_details.html')
def test_patient_print(self): """Test that the print patient page works as expected.""" patient = get_patient() response = self.client.get('/patient_print/{}'.format(patient.id)) self.assert200(response) self.assert_template_used('patient_details.html')
def test_document_image(self): """Test that uploading document images works as expected.""" self.login() patient = get_patient() # Check that multiple document image uploads save correctly with open('tests/unit/screener/test_image.jpg') as test_image: img_string_io = StringIO(test_image.read()) post_data = dict( first_name='James', last_name='Richmond', dob='1950-12-12', gender='', transgender='', race='', ethnicity='', coverage_type='', student_status='', employment_status='', marital_status='', housing_status='', veteran_yn='', insurance_status='', spouse_employment_status='', has_prescription_coverage_yn='N', eligible_for_vets_benefits_yn='N', eligible_insurance_types='', applied_for_ssd_yn='', accident_work_related_yn='', has_vcc='', filed_taxes_yn='', applied_for_medicaid_yn='', has_interpreter_yn='', applied_for_vets_benefits_yn='', has_transport_yn='', claimed_as_dependent_yn='', temp_visa_yn='', care_due_to_accident_yn='' ) post_data['document_images-0-file_name'] = (img_string_io, 'test_image.jpg') post_data['document_images-0-file_description'] = 'Test' post_data['document_images-1-file_name'] = (img_string_io, 'test_image_2.jpg') post_data['document_images-1-file_description'] = 'Test 2' response = self.client.post( '/patient_details/{}'.format(patient.id), data=post_data, follow_redirects=True ) self.assert200(response) saved_patient = Patient.query.first() self.assertEquals(saved_patient.document_images.count(), 2) # Check that the page that displays the images loads correctly for image in saved_patient.document_images: response = self.client.get( '/document_image/{}'.format(image.id) ) self.assert200(response) self.assert_template_used('documentimage.html')
def test_update_patient(self): """Test that updating an existing patient works as expected.""" self.login() patient = get_patient() # Check that the patient details page loads for an existing patient response = self.client.get('/patient_details/{}'.format(patient.id)) self.assert200(response) self.assert_template_used('patient_details.html') # Check that updates to the patient save, including many-to-one fields post_data = dict( first_name='James', last_name='Richmond', dob='1950-12-12', ssn='222-22-2222', medical_home="CAHN", email='*****@*****.**', has_transport_yn='N', gender='M', transgender='No', race='AA', ethnicity='NHL', languages=['EN', 'ES'], has_interpreter_yn='N', education_level='High school', marital_status='MAR', veteran_yn='N', housing_status='REN', # years_living_in_area='5', # months_living_in_area='1', time_in_area='LESS THAN 6', city_or_county_of_residence='Richmond', temp_visa_yn='N', student_status='Not a student', employment_status='FT', spouse_employment_status='PT', years_unemployed='0', months_unemployed='6', spouse_years_unemployed='1', spouse_months_unemployed='11', years_at_current_employer='LESS', spouse_years_at_current_employer='LESS', last_healthcare='Last year at VCU ED', insurance_status='N', coverage_type='VCC', has_prescription_coverage_yn='N', has_vcc='Y', eligible_insurance_types='NE', applied_for_vets_benefits_yn='N', eligible_for_vets_benefits_yn='N', applied_for_medicaid_yn='N', medicaid_date_effective='2015-01-01', applied_for_ssd_yn='N', ssd_date_effective='1999-12-12', care_due_to_accident_yn='N', accident_work_related_yn='N', filed_taxes_yn='N', claimed_as_dependent_yn='N', how_food_and_shelter='Stay with sister', how_other_expenses='Gets money from father') post_data['phone_numbers-0-phone_number'] = '(111) 111-1111' post_data['phone_numbers-0-number_description'] = 'CELL' post_data['phone_numbers-1-phone_number'] = '(222) 222-2222' post_data['phone_numbers-1-number_description'] = 'HOME' post_data['addresses-0-address1'] = '1 Main St.' post_data['addresses-0-address2'] = 'Apt. 1' post_data['addresses-0-city'] = 'Richmond' post_data['addresses-0-state'] = 'VA' post_data['addresses-0-zip'] = '11111' post_data['addresses-0-address_description'] = 'OWN' post_data['addresses-1-address1'] = '1 Maple St.' post_data['addresses-1-address2'] = '' post_data['addresses-1-city'] = 'Richmond' post_data['addresses-1-state'] = 'VA' post_data['addresses-1-zip'] = '11111' post_data['addresses-1-address_description'] = 'RELATIVE' post_data['emergency_contacts-0-full_name'] = 'Jane Johnson' post_data['emergency_contacts-0-relationship'] = 'mother' post_data['emergency_contacts-0-phone_number'] = '(111) 111-1111' post_data['emergency_contacts-1-full_name'] = 'Mary Richmond' post_data['emergency_contacts-1-relationship'] = 'sister' post_data['emergency_contacts-1-phone_number'] = '(222) 222-2222' post_data['household_members-0-full_name'] = 'Michael Richmond' post_data['household_members-0-dob'] = '2000-12-12' post_data['household_members-0-ssn'] = '999-99-9999' post_data['household_members-0-relationship'] = 'son' post_data['household_members-1-full_name'] = '11111' post_data['household_members-1-dob'] = '2006-02-28' post_data['household_members-1-ssn'] = '888-88-8888' post_data['household_members-1-relationship'] = 'Emily Richmond' post_data['income_sources-0-source'] = 'job' post_data['income_sources-0-monthly_amount'] = '1000' post_data['income_sources-1-source'] = 'food stamps' post_data['income_sources-1-monthly_amount'] = '200' post_data['employers-0-employer_name'] = 'Target' post_data['employers-0-phone_number'] = '(111) 111-1111' post_data['employers-0-employee'] = 'Patient' post_data['employers-0-start_date'] = '2014-01-01' post_data['employers-1-employer_name'] = 'Walmart' post_data['employers-1-phone_number'] = '(222) 222-2222' post_data['employers-1-employee'] = 'Spouse' post_data['employers-1-start_date'] = '1999-12-12' response = self.client.post('/patient_details/{}'.format(patient.id), data=post_data, follow_redirects=True) saved_patient = Patient.query.first() self.assertEquals(saved_patient.first_name, 'James') self.assertEquals(saved_patient.last_name, 'Richmond') self.assertEquals(saved_patient.dob, datetime.date(1950, 12, 12)) self.assertEquals(saved_patient.ssn, '222-22-2222') self.assertEquals(saved_patient.phone_numbers.count(), 2) self.assertEquals(saved_patient.addresses.count(), 2) self.assertEquals(saved_patient.emergency_contacts.count(), 2) self.assertEquals(saved_patient.household_members.count(), 2) self.assertEquals(saved_patient.income_sources.count(), 2) self.assertEquals(saved_patient.employers.count(), 2) # Check that the user stays on patient details page after saving self.assert_template_used('patient_details.html') # Check that updated many-to-one fields save correctly post_data['phone_numbers-0-phone_number'] = '(333) 333-3333' post_data['phone_numbers-0-number_description'] = 'WORK' response = self.client.post('/patient_details/{}'.format(patient.id), data=post_data, follow_redirects=True) self.assert200(response) saved_patient = Patient.query.first() self.assertEquals(saved_patient.phone_numbers[0].phone_number, '(333) 333-3333') self.assertEquals(saved_patient.phone_numbers[0].number_description, 'WORK') self.assert_template_used('patient_details.html') # Check that deleting many-to-one fields works as expected post_data['phone_numbers-0-phone_number'] = '' post_data['phone_numbers-0-number_description'] = '' response = self.client.post('/patient_details/{}'.format(patient.id), data=post_data, follow_redirects=True) self.assert200(response) self.assertEquals(saved_patient.phone_numbers.count(), 1) self.assertEquals(saved_patient.phone_numbers[0].phone_number, '(222) 222-2222') self.assertEquals(saved_patient.phone_numbers[0].number_description, 'HOME') self.assert_template_used('patient_details.html')