def test_make_pm_after_cancel_latest_pm(self): _id = self.participant_id.strip('P') self.send_consent(self.participant_id) measurement = load_measurement_json(self.participant_id) measurement2 = load_measurement_json(self.participant_id) path = 'Participant/%s/PhysicalMeasurements' % self.participant_id with FakeClock(self.time1): self.send_post(path, measurement) with FakeClock(self.time2): response2 = self.send_post(path, measurement2) # cancel latest PM path = path + '/' + response2['id'] cancel_info = get_restore_or_cancel_info() self.send_patch(path, cancel_info) response = self.send_get(path) self.assertEqual(response['status'], 'CANCELLED') self.assertEqual(response['reason'], 'a mistake was made.') self.assertEqual(response['cancelledUsername'], '*****@*****.**') self.assertEqual(response['cancelledSiteId'], 1) ps = self.send_get('ParticipantSummary?participantId=%s' % _id) # should still get first PM in participant summary self.assertEqual(ps['entry'][0]['resource']['physicalMeasurementsStatus'], 'COMPLETED') self.assertEqual(ps['entry'][0]['resource']['physicalMeasurementsCreatedSite'], 'hpo-site-monroeville') self.assertEqual(ps['entry'][0]['resource']['physicalMeasurementsFinalizedSite'], 'hpo-site-bannerphoenix') self.assertIsNotNone(ps['entry'][0]['resource']['physicalMeasurementsTime']) self.assertEquals(ps['entry'][0]['resource']['physicalMeasurementsTime'], self.time1.isoformat())
def test_make_pm_after_cancel_first_pm(self): _id = self.participant_id.strip('P') self.send_consent(self.participant_id) measurement = load_measurement_json(self.participant_id) measurement2 = load_measurement_json(self.participant_id) path = 'Participant/%s/PhysicalMeasurements' % self.participant_id response = self.send_post(path, measurement) path = path + '/' + response['id'] cancel_info = get_restore_or_cancel_info() self.send_patch(path, cancel_info) # send another PM path = 'Participant/%s/PhysicalMeasurements' % self.participant_id self.send_post(path, measurement2) path = path + '/' + response['id'] response = self.send_get(path) self.assertEqual(response['status'], 'CANCELLED') self.assertEqual(response['reason'], 'a mistake was made.') self.assertEqual(response['cancelledUsername'], '*****@*****.**') self.assertEqual(response['cancelledSiteId'], 1) ps = self.send_get('ParticipantSummary?participantId=%s' % _id) # should be completed because of other valid PM self.assertEqual(ps['entry'][0]['resource']['physicalMeasurementsStatus'], 'COMPLETED') self.assertEqual(ps['entry'][0]['resource']['physicalMeasurementsCreatedSite'], 'hpo-site-monroeville') self.assertEqual(ps['entry'][0]['resource']['physicalMeasurementsFinalizedSite'], 'hpo-site-bannerphoenix') self.assertIsNotNone(ps['entry'][0]['resource']['physicalMeasurementsTime'])
def _insert_measurements(self, now=None): measurements_1 = load_measurement_json(self.participant_id, now) measurements_2 = load_measurement_json(self.participant_id_2, now) path_1 = 'Participant/%s/PhysicalMeasurements' % self.participant_id path_2 = 'Participant/%s/PhysicalMeasurements' % self.participant_id_2 self.send_post(path_1, measurements_1) self.send_post(path_2, measurements_2)
def test_cannot_cancel_a_cancelled_pm(self): self.send_consent(self.participant_id) measurement = load_measurement_json(self.participant_id) path = 'Participant/%s/PhysicalMeasurements' % self.participant_id response = self.send_post(path, measurement) path = path + '/' + response['id'] self.send_patch(path, get_restore_or_cancel_info()) self.send_patch(path, get_restore_or_cancel_info(), expected_status=httplib.BAD_REQUEST)
def test_cannot_restore_a_valid_pm(self): self.send_consent(self.participant_id) measurement = load_measurement_json(self.participant_id) path = 'Participant/%s/PhysicalMeasurements' % self.participant_id response = self.send_post(path, measurement) path = path + '/' + response['id'] restored_info = get_restore_or_cancel_info(reason='need to restore', status='restored', author='me') self.send_patch(path, restored_info, expected_status=httplib.BAD_REQUEST)
def setUp(self): super(PhysicalMeasurementsDaoTest, self).setUp() self.participant = Participant(participantId=1, biobankId=2) ParticipantDao().insert(self.participant) self.dao = PhysicalMeasurementsDao() self.participant_summary_dao = ParticipantSummaryDao() self.measurement_json = json.dumps(load_measurement_json(self.participant.participantId, TIME_1.isoformat())) self.biobank = BiobankOrderDao()
def test_pm_restore_cancel_biobank_restore_cancel(self): self.participant = self._insert(Participant(participantId=9, biobankId=13)) self.measurement_json = json.dumps(load_measurement_json(self.participant.participantId, TIME_4.isoformat())) measurement = self.measurement_dao.insert(self._make_physical_measurements(physicalMeasurementsId=669, finalized=TIME_4)) summary = self.dao.get(self.participant.participantId) self.assertEquals(summary.numberDistinctVisits, 1) with clock.FakeClock(TIME_5): order = self.order_dao.insert(self._make_biobank_order(biobankOrderId='2', identifiers=[ BiobankOrderIdentifier(system='b', value='d')], samples=[BiobankOrderedSample( biobankOrderId='2', finalized=TIME_5, test=BIOBANK_TESTS[0], description='description', processingRequired=True)])) with clock.FakeClock(TIME_7): summary = self.dao.get(self.participant.participantId) # distinct count should be 2 self.assertEquals(summary.numberDistinctVisits, 2) # cancel the measurement cancel_measurement = get_restore_or_cancel_info() with self.measurement_dao.session() as session: self.measurement_dao.update_with_patch(measurement.physicalMeasurementsId, session, cancel_measurement) summary = self.dao.get(self.participant.participantId) self.assertEquals(summary.numberDistinctVisits, 1) with clock.FakeClock(TIME_7): restore_measurement = get_restore_or_cancel_info(status='restored') with self.measurement_dao.session() as session: self.measurement_dao.update_with_patch(measurement.physicalMeasurementsId, session, restore_measurement) summary = self.dao.get(self.participant.participantId) self.assertEquals(summary.numberDistinctVisits, 2) cancel_request = cancel_biobank_order() order = self.order_dao.update_with_patch(order.biobankOrderId, cancel_request, order.version) summary = self.dao.get(self.participant.participantId) self.assertEquals(summary.numberDistinctVisits, 1) restore_order = get_restore_or_cancel_info(status='restored') restore_order['amendedReason'] = 'some reason' self.order_dao.update_with_patch(order.biobankOrderId, restore_order, order.version) summary = self.dao.get(self.participant.participantId) self.assertEquals(summary.numberDistinctVisits, 2)
def test_insert_and_amend(self): self.send_consent(self.participant_id) measurements_1 = load_measurement_json(self.participant_id) path_1 = 'Participant/%s/PhysicalMeasurements' % self.participant_id response = self.send_post(path_1, measurements_1) measurements_2 = load_measurement_json_amendment(self.participant_id, response['id']) self.send_post(path_1, measurements_2) response = self.send_get('Participant/%s/PhysicalMeasurements' % self.participant_id) self.assertEquals(2, len(response['entry'])) self.assertEquals("amended", response['entry'][0]['resource']['entry'][0]['resource']['status'])
def test_cancel_an_ammended_order(self): self.send_consent(self.participant_id) measurements_1 = load_measurement_json(self.participant_id) path = 'Participant/%s/PhysicalMeasurements' % self.participant_id response = self.send_post(path, measurements_1) measurements_2 = load_measurement_json_amendment(self.participant_id, response['id']) response_2 = self.send_post(path, measurements_2) path = path + '/' + response_2['id'] cancel_info = get_restore_or_cancel_info() self.send_patch(path, cancel_info) response = self.send_get(path) self.assertEqual(response['status'], 'CANCELLED') self.assertEqual(response['reason'], 'a mistake was made.') self.assertEqual(response['cancelledUsername'], '*****@*****.**') self.assertEqual(response['cancelledSiteId'], 1)
def test_restore_a_physical_measuremnet(self): self.send_consent(self.participant_id) measurement = load_measurement_json(self.participant_id) path = 'Participant/%s/PhysicalMeasurements' % self.participant_id response = self.send_post(path, measurement) path = path + '/' + response['id'] self.send_patch(path, get_restore_or_cancel_info()) restored_info = get_restore_or_cancel_info(reason='need to restore', status='restored', author='me') self.send_patch(path, restored_info) response = self.send_get(path) self.assertEqual(response['status'], 'RESTORED') self.assertEqual(response['reason'], 'need to restore') # Response should not contain cancelledInfo self.assertTrue('cancelledUsername' not in response) self.assertTrue('cancelledSiteId' not in response) self.assertTrue('cancelledTime' not in response)
def test_cancel_single_pm_returns_cancelled_in_summary(self): _id = self.participant_id.strip('P') self.send_consent(self.participant_id) measurement = load_measurement_json(self.participant_id) path = 'Participant/%s/PhysicalMeasurements' % self.participant_id response = self.send_post(path, measurement) path = path + '/' + response['id'] cancel_info = get_restore_or_cancel_info() self.send_patch(path, cancel_info) response = self.send_get(path) self.assertEqual(response['status'], 'CANCELLED') self.assertEqual(response['reason'], 'a mistake was made.') self.assertEqual(response['cancelledUsername'], '*****@*****.**') self.assertEqual(response['cancelledSiteId'], 1) ps = self.send_get('ParticipantSummary?participantId=%s' % _id) self.assertEqual(ps['entry'][0]['resource']['physicalMeasurementsStatus'], 'CANCELLED') self.assertNotIn('physicalMeasurementsTime', ps['entry'][0]['resource']) self.assertNotIn("physicalMeasurementsFinalizedSiteId", ps["entry"][0]["resource"]) self.assertEqual("UNSET", ps["entry"][0]["resource"]["physicalMeasurementsFinalizedSite"])
def setUp(self): super(BigQuerySyncDaoTest, self).setUp(use_mysql=True, with_consent_codes=True) self.dao = ParticipantDao() with self.dao.session() as session: self.site = session.query(Site).filter( Site.googleGroup == 'hpo-site-monroeville').first() self.hpo = session.query(HPO).filter(HPO.name == 'PITT').first() with clock.FakeClock(self.TIME_1): self.participant = Participant(participantId=123, biobankId=555) self.participant.hpoId = self.hpo.hpoId self.participant.siteId = self.site.siteId self.dao.insert(self.participant) ps = ParticipantSummary( participantId=123, biobankId=555, firstName='john', lastName='doe', withdrawalStatus=WithdrawalStatus.NOT_WITHDRAWN, suspensionStatus=SuspensionStatus.NOT_SUSPENDED) ps.hpoId = self.hpo.hpoId ps.siteId = self.site.siteId self.summary = ParticipantSummaryDao().insert(ps) self.pm_json = json.dumps( load_measurement_json(self.participant.participantId, self.TIME_1.isoformat())) self.pm = PhysicalMeasurementsDao().insert( self._make_physical_measurements()) with clock.FakeClock(self.TIME_2): self.dao = BiobankOrderDao() self.bio_order = BiobankOrderDao().insert( self._make_biobank_order( participantId=self.participant.participantId))
def testQuery_manyParticipants(self): SqlTestBase.setup_codes(["PIIState_VA", "male_sex", "male", "straight", "email_code", "en", "highschool", "lotsofmoney"], code_type=CodeType.ANSWER) questionnaire_id = self.create_questionnaire('questionnaire3.json') questionnaire_id_2 = self.create_questionnaire('questionnaire4.json') questionnaire_id_3 = self.create_questionnaire('all_consents_questionnaire.json') participant_1 = self.send_post('Participant', {"providerLink": [self.provider_link]}) participant_id_1 = participant_1['participantId'] participant_2 = self.send_post('Participant', {"providerLink": [self.provider_link]}) participant_id_2 = participant_2['participantId'] participant_3 = self.send_post('Participant', {}) participant_id_3 = participant_3['participantId'] with FakeClock(TIME_1): self.send_consent(participant_id_1) self.send_consent(participant_id_2) self.send_consent(participant_id_3) self.submit_questionnaire_response(participant_id_1, questionnaire_id, RACE_WHITE_CODE, "male", "Bob", "Q", "Jones", "78751", "PIIState_VA", "1234 Main Street", "Austin", "male_sex", "straight", "512-555-5555", "email_code", "en", "highschool", "lotsofmoney", datetime.date(1978, 10, 9), "signature.pdf") self.submit_questionnaire_response(participant_id_2, questionnaire_id, None, "female", "Mary", "Q", "Jones", "78751", None, None, None, None, None, None, None, None, None, None, datetime.date(1978, 10, 8), None) self.submit_questionnaire_response(participant_id_3, questionnaire_id, RACE_WHITE_CODE, "male", "Fred", "T", "Smith", "78752", None, None, None, None, None, None, None, None, None, None, datetime.date(1978, 10, 10), None) # Send a questionnaire response for the consent questionnaire for participants 2 and 3 self._submit_consent_questionnaire_response(participant_id_2, questionnaire_id_3, CONSENT_PERMISSION_YES_CODE) self._submit_consent_questionnaire_response(participant_id_3, questionnaire_id_3, CONSENT_PERMISSION_YES_CODE) # Send an empty questionnaire response for another questionnaire for participant 3, # completing the baseline PPI modules. self._submit_empty_questionnaire_response(participant_id_3, questionnaire_id_2) # Send physical measurements for participants 2 and 3 measurements_2 = load_measurement_json(participant_id_2) measurements_3 = load_measurement_json(participant_id_3) path_2 = 'Participant/%s/PhysicalMeasurements' % participant_id_2 path_3 = 'Participant/%s/PhysicalMeasurements' % participant_id_3 with FakeClock(TIME_2): self.send_post(path_2, measurements_2) # This pairs participant 3 with PITT and updates their version. self.send_post(path_3, measurements_3) # Store samples for DNA for participants 1 and 3 self._store_biobank_sample(participant_1, '1ED10') self._store_biobank_sample(participant_3, '1SAL') # Update participant summaries based on these changes. ParticipantSummaryDao().update_from_biobank_stored_samples() # Update version for participant 3, which has changed. participant_3 = self.send_get('Participant/%s' % participant_id_3) with FakeClock(TIME_3): participant_2['withdrawalStatus'] = 'NO_USE' participant_3['suspensionStatus'] = 'NO_CONTACT' self.send_put('Participant/%s' % participant_id_2, participant_2, headers={ 'If-Match': participant_2['meta']['versionId'] }) self.send_put('Participant/%s' % participant_id_3, participant_3, headers={ 'If-Match': participant_3['meta']['versionId'] }) with FakeClock(TIME_4): ps_1 = self.send_get('Participant/%s/Summary' % participant_id_1) ps_2 = self.send_get('Participant/%s/Summary' % participant_id_2) ps_3 = self.send_get('Participant/%s/Summary' % participant_id_3) self.assertEquals(1, ps_1['numCompletedBaselinePPIModules']) self.assertEquals(1, ps_1['numBaselineSamplesArrived']) self.assertEquals('RECEIVED', ps_1['sampleStatus1ED10']) self.assertEquals(TIME_1.isoformat(), ps_1['sampleStatus1ED10Time']) self.assertEquals('UNSET', ps_1['sampleStatus1SAL']) self.assertEquals('UNSET', ps_1['samplesToIsolateDNA']) self.assertEquals('INTERESTED', ps_1['enrollmentStatus']) self.assertEquals('UNSET', ps_1['physicalMeasurementsStatus']) self.assertIsNone(ps_1.get('physicalMeasurementsTime')) self.assertEquals('male', ps_1['genderIdentity']) self.assertEquals('NOT_WITHDRAWN', ps_1['withdrawalStatus']) self.assertEquals('NOT_SUSPENDED', ps_1['suspensionStatus']) self.assertEquals('email_code', ps_1['recontactMethod']) self.assertIsNone(ps_1.get('withdrawalTime')) self.assertIsNone(ps_1.get('suspensionTime')) # One day after participant 2 withdraws, their fields are still all populated. self.assertEquals(1, ps_2['numCompletedBaselinePPIModules']) self.assertEquals(0, ps_2['numBaselineSamplesArrived']) self.assertEquals('UNSET', ps_2['sampleStatus1ED10']) self.assertEquals('UNSET', ps_2['sampleStatus1SAL']) self.assertEquals('UNSET', ps_2['samplesToIsolateDNA']) self.assertEquals('MEMBER', ps_2['enrollmentStatus']) self.assertEquals('COMPLETED', ps_2['physicalMeasurementsStatus']) self.assertEquals(TIME_2.isoformat(), ps_2['physicalMeasurementsTime']) self.assertEquals('UNMAPPED', ps_2['genderIdentity']) self.assertEquals('NO_USE', ps_2['withdrawalStatus']) self.assertEquals('NOT_SUSPENDED', ps_2['suspensionStatus']) self.assertEquals('NO_CONTACT', ps_2['recontactMethod']) self.assertIsNotNone(ps_2['withdrawalTime']) self.assertIsNone(ps_2.get('suspensionTime')) self.assertEquals(3, ps_3['numCompletedBaselinePPIModules']) self.assertEquals(0, ps_3['numBaselineSamplesArrived']) self.assertEquals('UNSET', ps_3['sampleStatus1ED10']) self.assertEquals('RECEIVED', ps_3['sampleStatus1SAL']) self.assertEquals(TIME_1.isoformat(), ps_3['sampleStatus1SALTime']) self.assertEquals('RECEIVED', ps_3['samplesToIsolateDNA']) self.assertEquals('FULL_PARTICIPANT', ps_3['enrollmentStatus']) self.assertEquals('COMPLETED', ps_3['physicalMeasurementsStatus']) self.assertEquals(TIME_2.isoformat(), ps_3['physicalMeasurementsTime']) self.assertEquals('male', ps_3['genderIdentity']) self.assertEquals('NOT_WITHDRAWN', ps_3['withdrawalStatus']) self.assertEquals('NO_CONTACT', ps_3['suspensionStatus']) self.assertEquals('NO_CONTACT', ps_3['recontactMethod']) self.assertIsNone(ps_3.get('withdrawalTime')) self.assertIsNotNone(ps_3['suspensionTime']) # One day after participant 2 withdraws, the participant is still returned. with FakeClock(TIME_4): response = self.send_get('ParticipantSummary') self.assertBundle([_make_entry(ps_1), _make_entry(ps_2), _make_entry(ps_3)], response) self.assertResponses('ParticipantSummary?_count=2', [[ps_1, ps_2], [ps_3]]) # Test sorting on fields of different types. self.assertResponses('ParticipantSummary?_count=2&_sort=firstName', [[ps_1, ps_3], [ps_2]]) self.assertResponses('ParticipantSummary?_count=2&_sort:asc=firstName', [[ps_1, ps_3], [ps_2]]) self.assertResponses('ParticipantSummary?_count=2&_sort:desc=firstName', [[ps_2, ps_3], [ps_1]]) self.assertResponses('ParticipantSummary?_count=2&_sort=dateOfBirth', [[ps_2, ps_1], [ps_3]]) self.assertResponses('ParticipantSummary?_count=2&_sort:desc=dateOfBirth', [[ps_3, ps_1], [ps_2]]) self.assertResponses('ParticipantSummary?_count=2&_sort=genderIdentity', [[ps_1, ps_3], [ps_2]]) self.assertResponses('ParticipantSummary?_count=2&_sort:desc=genderIdentity', [[ps_2, ps_1], [ps_3]]) self.assertResponses('ParticipantSummary?_count=2&_sort=questionnaireOnTheBasics', [[ps_1, ps_2], [ps_3]]) self.assertResponses('ParticipantSummary?_count=2&_sort=hpoId', [[ps_1, ps_2], [ps_3]]) self.assertResponses('ParticipantSummary?_count=2&_sort:desc=hpoId', [[ps_1, ps_2], [ps_3]]) # Test filtering on fields. self.assertResponses('ParticipantSummary?_count=2&firstName=Mary', [[ps_2]]) self.assertResponses('ParticipantSummary?_count=2&middleName=Q', [[ps_1, ps_2]]) self.assertResponses('ParticipantSummary?_count=2&lastName=Smith', [[ps_3]]) self.assertResponses('ParticipantSummary?_count=2&zipCode=78752', [[ps_3]]) self.assertResponses('ParticipantSummary?_count=2&hpoId=PITT', [[ps_1, ps_2], [ps_3]]) self.assertResponses('ParticipantSummary?_count=2&hpoId=UNSET', [[]]) self.assertResponses('ParticipantSummary?_count=2&genderIdentity=male', [[ps_1, ps_3]]) self.assertResponses('ParticipantSummary?_count=2&race=WHITE', [[ps_1, ps_3]]) self.assertResponses('ParticipantSummary?_count=2&middleName=Q&race=WHITE', [[ps_1]]) self.assertResponses('ParticipantSummary?_count=2&middleName=Q&race=WHITE&zipCode=78752', [[]]) self.assertResponses('ParticipantSummary?_count=2&questionnaireOnTheBasics=SUBMITTED', [[ps_1, ps_2], [ps_3]]) self.assertResponses('ParticipantSummary?_count=2&consentForStudyEnrollment=SUBMITTED', [[ps_1, ps_2], [ps_3]]) self.assertResponses('ParticipantSummary?_count=2&consentForCABoR=SUBMITTED', [[ps_1]]) self.assertResponses('ParticipantSummary?_count=2&physicalMeasurementsStatus=UNSET', [[ps_1]]) self.assertResponses('ParticipantSummary?_count=2&physicalMeasurementsStatus=COMPLETED', [[ps_2, ps_3]]) self.assertResponses('ParticipantSummary?_count=2&enrollmentStatus=INTERESTED', [[ps_1]]) self.assertResponses('ParticipantSummary?_count=2&enrollmentStatus=MEMBER', [[ps_2]]) self.assertResponses('ParticipantSummary?_count=2&enrollmentStatus=FULL_PARTICIPANT', [[ps_3]]) self.assertResponses('ParticipantSummary?_count=2&dateOfBirth=1978-10-08', [[ps_2]]) self.assertResponses('ParticipantSummary?_count=2&dateOfBirth=gt1978-10-08', [[ps_1, ps_3]]) self.assertResponses('ParticipantSummary?_count=2&dateOfBirth=lt1978-10-08', [[]]) self.assertResponses('ParticipantSummary?_count=2&dateOfBirth=le1978-10-08', [[ps_2]]) self.assertResponses('ParticipantSummary?_count=2&dateOfBirth=ge1978-10-08', [[ps_1, ps_2], [ps_3]]) self.assertResponses('ParticipantSummary?_count=2&dateOfBirth=ge1978-10-08&' 'dateOfBirth=le1978-10-09', [[ps_1, ps_2]]) self.assertResponses('ParticipantSummary?_count=2&dateOfBirth=ne1978-10-09', [[ps_2, ps_3]]) self.assertResponses('ParticipantSummary?_count=2&withdrawalStatus=NOT_WITHDRAWN', [[ps_1, ps_3]]) self.assertResponses('ParticipantSummary?_count=2&withdrawalStatus=NO_USE', [[ps_2]]) self.assertResponses('ParticipantSummary?_count=2&withdrawalTime=lt2016-01-03', [[]]) self.assertResponses('ParticipantSummary?_count=2&withdrawalTime=ge2016-01-03', [[ps_2]]) self.assertResponses('ParticipantSummary?_count=2&suspensionStatus=NOT_SUSPENDED', [[ps_1, ps_2]]) self.assertResponses('ParticipantSummary?_count=2&suspensionStatus=NO_CONTACT', [[ps_3]]) self.assertResponses('ParticipantSummary?_count=2&suspensionTime=lt2016-01-03', [[]]) self.assertResponses('ParticipantSummary?_count=2&suspensionTime=ge2016-01-03', [[ps_3]]) # Two days after participant 2 withdraws, their fields are not set for anything but # participant ID, HPO ID, withdrawal status, and withdrawal time with FakeClock(TIME_5): new_ps_1 = self.send_get('Participant/%s/Summary' % participant_id_1) new_ps_2 = self.send_get('Participant/%s/Summary' % participant_id_2) new_ps_3 = self.send_get('Participant/%s/Summary' % participant_id_3) self.assertEquals(ps_1, new_ps_1) self.assertEquals(ps_3, new_ps_3) self.assertEquals('Mary', new_ps_2['firstName']) self.assertEquals('Q', new_ps_2['middleName']) self.assertEquals('Jones', new_ps_2['lastName']) self.assertIsNone(new_ps_2.get('numCompletedBaselinePPIModules')) self.assertIsNone(new_ps_2.get('numBaselineSamplesArrived')) self.assertEquals('UNSET', new_ps_2['sampleStatus1ED10']) self.assertEquals('UNSET', new_ps_2['sampleStatus1SAL']) self.assertEquals('UNSET', new_ps_2['samplesToIsolateDNA']) self.assertEquals('UNSET', new_ps_2['enrollmentStatus']) self.assertEquals('UNSET', new_ps_2['physicalMeasurementsStatus']) self.assertEquals('SUBMITTED', new_ps_2['consentForStudyEnrollment']) self.assertIsNotNone(new_ps_2['consentForStudyEnrollmentTime']) self.assertEquals('SUBMITTED', new_ps_2['consentForElectronicHealthRecords']) self.assertIsNotNone(new_ps_2['consentForElectronicHealthRecordsTime']) self.assertIsNone(new_ps_2.get('physicalMeasurementsTime')) self.assertEquals('UNSET', new_ps_2['genderIdentity']) self.assertEquals('NO_USE', new_ps_2['withdrawalStatus']) self.assertEquals(ps_2['biobankId'], new_ps_2['biobankId']) self.assertEquals('UNSET', new_ps_2['suspensionStatus']) self.assertEquals('NO_CONTACT', new_ps_2['recontactMethod']) self.assertEquals('PITT', new_ps_2['hpoId']) self.assertEquals(participant_id_2, new_ps_2['participantId']) self.assertIsNotNone(ps_2['withdrawalTime']) self.assertIsNone(new_ps_2.get('suspensionTime')) # Queries that filter on fields not returned for withdrawn participants no longer return # participant 2; queries that filter on fields that are returned for withdrawn participants # include it; queries that ask for withdrawn participants get back participant 2 only. # Sort order does not affect whether withdrawn participants are included. with FakeClock(TIME_5): self.assertResponses('ParticipantSummary?_count=2&_sort=firstName', [[ps_1, ps_3], [new_ps_2]]) self.assertResponses('ParticipantSummary?_count=2&_sort:asc=firstName', [[ps_1, ps_3], [new_ps_2]]) self.assertResponses('ParticipantSummary?_count=2&_sort:desc=firstName', [[new_ps_2, ps_3], [ps_1]]) self.assertResponses('ParticipantSummary?_count=2&_sort=dateOfBirth', [[new_ps_2, ps_1], [ps_3]]) self.assertResponses('ParticipantSummary?_count=2&_sort:desc=dateOfBirth', [[ps_3, ps_1], [new_ps_2]]) self.assertResponses('ParticipantSummary?_count=2&_sort=genderIdentity', [[ps_1, ps_3], [new_ps_2]]) self.assertResponses('ParticipantSummary?_count=2&_sort:desc=genderIdentity', [[new_ps_2, ps_1], [ps_3]]) self.assertResponses('ParticipantSummary?_count=2&_sort=questionnaireOnTheBasics', [[ps_1, new_ps_2], [ps_3]]) self.assertResponses('ParticipantSummary?_count=2&_sort=hpoId', [[ps_1, new_ps_2], [new_ps_3]]) self.assertResponses('ParticipantSummary?_count=2&_sort:desc=hpoId', [[ps_1, new_ps_2], [ps_3]]) self.assertResponses('ParticipantSummary?_count=2&firstName=Mary', [[new_ps_2]]) self.assertResponses('ParticipantSummary?_count=2&middleName=Q', [[ps_1, new_ps_2]]) self.assertResponses('ParticipantSummary?_count=2&lastName=Smith', [[ps_3]]) self.assertResponses('ParticipantSummary?_count=2&hpoId=PITT', [[ps_1, new_ps_2], [ps_3]]) self.assertResponses('ParticipantSummary?_count=2&withdrawalStatus=NO_USE', [[new_ps_2]]) self.assertResponses('ParticipantSummary?_count=2&withdrawalTime=lt2016-01-03', [[]]) self.assertResponses('ParticipantSummary?_count=2&withdrawalTime=ge2016-01-03', [[new_ps_2]]) self.assertResponses('ParticipantSummary?_count=2&suspensionStatus=NOT_SUSPENDED', [[ps_1]])
def _create_data(self): HPODao().insert(HPO(hpoId=PITT_HPO_ID + 1, name='AZ_TUCSON')) HPODao().insert(HPO(hpoId=PITT_HPO_ID + 2, name='TEST')) SqlTestBase.setup_codes( ANSWER_FIELD_TO_QUESTION_CODE.values() + [EHR_CONSENT_QUESTION_CODE], code_type=CodeType.QUESTION) SqlTestBase.setup_codes( FIELD_TO_QUESTIONNAIRE_MODULE_CODE.values(), code_type=CodeType.MODULE) # Import codes for white and female, but not male or black. SqlTestBase.setup_codes( [ RACE_WHITE_CODE, CONSENT_PERMISSION_YES_CODE, CONSENT_PERMISSION_NO_CODE, 'female', 'PIIState_VA' ], code_type=CodeType.ANSWER) participant_dao = ParticipantDao() questionnaire_id = self.create_questionnaire('questionnaire3.json') questionnaire_id_2 = self.create_questionnaire('questionnaire4.json') questionnaire_id_3 = self.create_questionnaire( 'all_consents_questionnaire.json') with FakeClock(TIME): participant = Participant( participantId=1, biobankId=2, providerLink=make_primary_provider_link_for_name('AZ_TUCSON')) participant_dao.insert(participant) self.send_consent('P1', email='*****@*****.**') with FakeClock(TIME): # Participant 2 starts out unpaired; later gets paired automatically when their physical # measurements come in. participant2 = Participant( participantId=2, biobankId=3) participant_dao.insert(participant2) self.send_consent('P2', email='*****@*****.**') with FakeClock(TIME): # Test HPO affiliation; this test participant is ignored. participant3 = Participant(participantId=3, biobankId=4, providerLink=make_primary_provider_link_for_name('TEST')) participant_dao.insert(participant3) self.send_consent('P3', email='*****@*****.**') # example.com e-mail; this test participant is ignored, too. participant4 = Participant(participantId=4, biobankId=5, providerLink=make_primary_provider_link_for_name('PITT')) participant_dao.insert(participant4) self.send_consent('P4', email='*****@*****.**') with FakeClock(TIME_2): # This update to participant has no effect, as the HPO ID didn't change. participant = self._participant_with_defaults( participantId=1, version=1, biobankId=2, providerLink=make_primary_provider_link_for_name('AZ_TUCSON')) participant_dao.update(participant) self.submit_questionnaire_response('P1', questionnaire_id, RACE_WHITE_CODE, 'male', None, datetime.date(1980, 1, 2)) self.submit_questionnaire_response('P2', questionnaire_id, None, None, None, None) with FakeClock(TIME_3): participant = self._participant_with_defaults( participantId=1, version=2, biobankId=2, providerLink=make_primary_provider_link_for_name('PITT')) participant_dao.update(participant) self.send_post('Participant/P2/PhysicalMeasurements', load_measurement_json(2)) self.send_post('Participant/P2/BiobankOrder', load_biobank_order_json(2)) self.submit_questionnaire_response('P1', questionnaire_id, 'black', 'female', None, datetime.date(1980, 1, 3)) self.submit_questionnaire_response('P2', questionnaire_id_2, None, None, 'PIIState_VA', None) self._submit_consent_questionnaire_response('P1', questionnaire_id_3, CONSENT_PERMISSION_NO_CODE) self._submit_consent_questionnaire_response('P2', questionnaire_id_3, CONSENT_PERMISSION_YES_CODE) sample_dao = BiobankStoredSampleDao() sample_dao.insert( BiobankStoredSample( biobankStoredSampleId='abc', biobankId=2, test='test', confirmed=TIME_2)) sample_dao.insert( BiobankStoredSample( biobankStoredSampleId='def', biobankId=3, test='1SAL', confirmed=TIME_2))
def testNumberDistinctVisitsCounts(self): self.participant = self._insert(Participant(participantId=7, biobankId=77)) # insert biobank order order = self.order_dao.insert(self._make_biobank_order()) summary = self.dao.get(self.participant.participantId) self.assertEquals(summary.numberDistinctVisits, 1) cancel_request = cancel_biobank_order() # cancel biobank order self.order_dao.update_with_patch(order.biobankOrderId, cancel_request, order.version) summary = self.dao.get(self.participant.participantId) # distinct count should be 0 self.assertEquals(summary.numberDistinctVisits, 0) self.measurement_json = json.dumps(load_measurement_json(self.participant.participantId, TIME_1.isoformat())) # insert physical measurement measurement = self.measurement_dao.insert(self._make_physical_measurements()) summary = self.dao.get(self.participant.participantId) # count should be 1 self.assertEquals(summary.numberDistinctVisits, 1) # cancel the measurement cancel_measurement = get_restore_or_cancel_info() with self.measurement_dao.session() as session: self.measurement_dao.update_with_patch(measurement.physicalMeasurementsId, session, cancel_measurement) summary = self.dao.get(self.participant.participantId) # count should be 0 self.assertEquals(summary.numberDistinctVisits, 0) with clock.FakeClock(TIME_1): self.order_dao.insert(self._make_biobank_order(biobankOrderId='2', identifiers=[ BiobankOrderIdentifier(system='b', value='d')], samples=[BiobankOrderedSample( biobankOrderId='2', test=BIOBANK_TESTS[0], description='description', processingRequired=True)])) with clock.FakeClock(TIME_2): self.measurement_dao.insert(self._make_physical_measurements( physicalMeasurementsId=2)) summary = self.dao.get(self.participant.participantId) # A PM on another day should add a new distinct count. self.assertEquals(summary.numberDistinctVisits, 2) with clock.FakeClock(TIME_3): self.order_dao.insert(self._make_biobank_order(biobankOrderId='3', identifiers=[ BiobankOrderIdentifier(system='s', value='s')], samples=[BiobankOrderedSample( biobankOrderId ='3', finalized=TIME_3, test=BIOBANK_TESTS[1], description='another description', processingRequired=False)])) # a physical measurement on same day as biobank order does not add distinct visit. self.measurement_dao.insert(self._make_physical_measurements(physicalMeasurementsId=6)) # another biobank order on the same day should also not add a distinct visit self.order_dao.insert(self._make_biobank_order(biobankOrderId='7', identifiers=[ BiobankOrderIdentifier(system='x', value='x')], samples=[BiobankOrderedSample( biobankOrderId ='7', finalized=TIME_3, test=BIOBANK_TESTS[1], description='another description', processingRequired=False)])) summary = self.dao.get(self.participant.participantId) # 1 from each of TIME_1 TIME_2 TIME_3 self.assertEquals(summary.numberDistinctVisits, 3)
def test_insert_before_consent_fails(self): measurements_1 = load_measurement_json(self.participant_id) path_1 = 'Participant/%s/PhysicalMeasurements' % self.participant_id self.send_post(path_1, measurements_1, expected_status=httplib.BAD_REQUEST)
def test_qa_scenarios_for_pmb_visits(self): """ PDR at https://docs.google.com/document/d/1sL54f-I91RvhjIprrdbwD8TlR9Jq91MX2ELf1EtJdxc/edit#heading=h.bqo8kt3igsrw<Paste> """ self.participant = self._insert(Participant(participantId=6, biobankId=66)) # test scenario 1 with clock.FakeClock(TIME_4): self.measurement_json = json.dumps(load_measurement_json(self.participant.participantId, TIME_4.isoformat())) self.measurement_dao.insert(self._make_physical_measurements(physicalMeasurementsId=666, participantId=self.participant.participantId, finalized=TIME_4)) summary = self.dao.get(self.participant.participantId) self.assertEquals(summary.numberDistinctVisits, 1) with clock.FakeClock(TIME_5): self.measurement_json = json.dumps(load_measurement_json(self.participant.participantId, TIME_5.isoformat())) self.measurement_dao.insert(self._make_physical_measurements(physicalMeasurementsId=669, finalized=TIME_5)) summary = self.dao.get(self.participant.participantId) self.assertEquals(summary.numberDistinctVisits, 2) # test scenario 2 with clock.FakeClock(TIME_6): self.participant = self._insert(Participant(participantId=9, biobankId=13)) self.measurement_json = json.dumps(load_measurement_json(self.participant.participantId, TIME_6.isoformat())) self.measurement_dao.insert(self._make_physical_measurements(physicalMeasurementsId=8, finalized=TIME_6)) self.order_dao.insert(self._make_biobank_order(biobankOrderId='2', identifiers=[ BiobankOrderIdentifier(system='b', value='d')], samples=[BiobankOrderedSample( biobankOrderId='2', finalized=TIME_7, test=BIOBANK_TESTS[0], description='description', processingRequired=True)])) summary = self.dao.get(self.participant.participantId) # distinct count should be 2 self.assertEquals(summary.numberDistinctVisits, 2) # test scenario 3 with clock.FakeClock(TIME_6): self.participant = self._insert(Participant(participantId=66, biobankId=42)) self.measurement_json = json.dumps(load_measurement_json(self.participant.participantId, TIME_6.isoformat())) self.measurement_dao.insert(self._make_physical_measurements(physicalMeasurementsId=12, createdSiteId=2, finalized=TIME_6)) self.order_dao.insert(self._make_biobank_order(biobankOrderId='18', finalizedSiteId=1, identifiers=[ BiobankOrderIdentifier(system='x', value='y')], samples=[BiobankOrderedSample( biobankOrderId='18', finalized=TIME_6, test=BIOBANK_TESTS[0], description='description', processingRequired=True)])) summary = self.dao.get(self.participant.participantId) # distinct count should be 1 self.assertEquals(summary.numberDistinctVisits, 1) # test scenario 4 with clock.FakeClock(TIME_8): self.participant = self._insert(Participant(participantId=6613, biobankId=142)) self.measurement_json = json.dumps(load_measurement_json(self.participant.participantId, TIME_8.isoformat())) self.measurement_dao.insert(self._make_physical_measurements(physicalMeasurementsId=129, finalized=TIME_8)) order = self.order_dao.insert(self._make_biobank_order(biobankOrderId='999', identifiers=[ BiobankOrderIdentifier(system='s', value='s')], samples=[BiobankOrderedSample( biobankOrderId='999', finalized=TIME_8, test=BIOBANK_TESTS[1], description='description', processingRequired=True)])) summary = self.dao.get(self.participant.participantId) # distinct count should be 1 self.assertEquals(summary.numberDistinctVisits, 1) # change finalized time, recalculating count with self.order_dao.session() as session: existing_order = copy.deepcopy(order) order.samples[0].finalized = TIME_9 self.order_dao._do_update(session, order, existing_order) summary = self.dao.get(self.participant.participantId) self.assertEquals(summary.numberDistinctVisits, 1) # change test, should not change count. with self.order_dao.session() as session: existing_order = copy.deepcopy(order) order.samples[0].test = BIOBANK_TESTS[0] self.order_dao._do_update(session, order, existing_order) summary = self.dao.get(self.participant.participantId) self.assertEquals(summary.numberDistinctVisits, 1) # test scenario 5 with clock.FakeClock(TIME_12): self.participant = self._insert(Participant(participantId=3000, biobankId=2019)) self.order_dao.insert(self._make_biobank_order(biobankOrderId='700', identifiers=[ BiobankOrderIdentifier(system='n', value='s')], samples=[BiobankOrderedSample( biobankOrderId='700', finalized=TIME_10, test=BIOBANK_TESTS[1], description='description', processingRequired=True)])) summary = self.dao.get(self.participant.participantId) # distinct count should be 1 self.assertEquals(summary.numberDistinctVisits, 1) other_order = self.order_dao.insert(self._make_biobank_order(biobankOrderId='701', identifiers=[ BiobankOrderIdentifier(system='n', value='t')], samples=[BiobankOrderedSample( biobankOrderId='701', finalized=TIME_11, test=BIOBANK_TESTS[1], description='description', processingRequired=True)])) summary = self.dao.get(self.participant.participantId) # distinct count should be 2 self.assertEquals(summary.numberDistinctVisits, 2) order = self.order_dao.insert(self._make_biobank_order(biobankOrderId='702', identifiers=[ BiobankOrderIdentifier(system='n', value='u')], samples=[BiobankOrderedSample( biobankOrderId='702', finalized=TIME_12, test=BIOBANK_TESTS[1], description='description', processingRequired=True)])) summary = self.dao.get(self.participant.participantId) # distinct count should be 3 self.assertEquals(summary.numberDistinctVisits, 3) self.measurement_json = json.dumps(load_measurement_json(self.participant.participantId, TIME_12.isoformat())) self.measurement_dao.insert(self._make_physical_measurements(physicalMeasurementsId=120, finalized=TIME_12)) summary = self.dao.get(self.participant.participantId) # distinct count should be 3 self.assertEquals(summary.numberDistinctVisits, 3) cancel_request = cancel_biobank_order() # cancel biobank order with PM on same day self.order_dao.update_with_patch(order.biobankOrderId, cancel_request, order.version) summary = self.dao.get(self.participant.participantId) # distinct count should be 3 (the PM on same day still counts) self.assertEquals(summary.numberDistinctVisits, 3) self.measurement_json = json.dumps(load_measurement_json(self.participant.participantId, TIME_1.isoformat())) self.measurement_dao.insert(self._make_physical_measurements(physicalMeasurementsId=150, finalized=TIME_1)) summary = self.dao.get(self.participant.participantId) # distinct count should be 4 self.assertEquals(summary.numberDistinctVisits, 4) # cancel order with pm on different day self.order_dao.update_with_patch(other_order.biobankOrderId, cancel_request, order.version) summary = self.dao.get(self.participant.participantId) # distinct count should be 3 self.assertEquals(summary.numberDistinctVisits, 3)
def _create_data(self): HPODao().insert(HPO(hpoId=PITT_HPO_ID + 1, name='AZ_TUCSON_2')) HPODao().insert(HPO(hpoId=PITT_HPO_ID + 4, name='TEST')) SqlTestBase.setup_codes( ANSWER_FIELD_TO_QUESTION_CODE.values() + [EHR_CONSENT_QUESTION_CODE], code_type=CodeType.QUESTION) SqlTestBase.setup_codes( FIELD_TO_QUESTIONNAIRE_MODULE_CODE.values(), code_type=CodeType.MODULE) # Import codes for white and female, but not male or black. SqlTestBase.setup_codes([ RACE_WHITE_CODE, CONSENT_PERMISSION_YES_CODE, RACE_NONE_OF_THESE_CODE, PMI_PREFER_NOT_TO_ANSWER_CODE, CONSENT_PERMISSION_NO_CODE, 'female', 'PIIState_VA', PMI_SKIP_CODE ], code_type=CodeType.ANSWER) participant_dao = ParticipantDao() questionnaire_id = self.create_questionnaire('questionnaire3.json') questionnaire_id_2 = self.create_questionnaire('questionnaire4.json') questionnaire_id_3 = self.create_questionnaire('all_consents_questionnaire.json') pl_tucson = make_primary_provider_link_for_name('AZ_TUCSON') pl_test = make_primary_provider_link_for_name('TEST') pl_pitt = make_primary_provider_link_for_name('PITT') with FakeClock(TIME): participant = Participant(participantId=1, biobankId=2, providerLink=pl_tucson) participant_dao.insert(participant) self.send_consent('P1', email='*****@*****.**') # Participant 2 starts out unpaired; later gets paired automatically when their physical # measurements come in. participant2 = Participant(participantId=2, biobankId=3) participant_dao.insert(participant2) self.send_consent('P2', email='*****@*****.**') # Test HPO affiliation; this test participant is ignored. participant3 = Participant(participantId=3, biobankId=4, providerLink=pl_test) participant_dao.insert(participant3) self.send_consent('P3', email='*****@*****.**') # example.com e-mail; this test participant is ignored, too. participant4 = Participant(participantId=4, biobankId=5, providerLink=pl_pitt) participant_dao.insert(participant4) self.send_consent('P4', email='*****@*****.**') participant5 = Participant(participantId=5, biobankId=6, providerLink=pl_tucson) participant_dao.insert(participant5) self.send_consent('P5', email='*****@*****.**') with FakeClock(TIME_2): # FIXME: The test passes, but the following "update" doesn't actually make much sense. The # providerlink is not changed but the HPO ID actually is (at this point in time # `participant.hpoId` evaluates to 4, which is the value given in `unit_test_util.AZ_HPO_ID`). # The original intent of the test is not clear. # This update to participant has no effect, as the HPO ID didn't change. participant = self._participant_with_defaults( participantId=1, version=1, biobankId=2, hpoId=3, # <<<< Had to add hpoId here, default is UNSET_HPO_ID providerLink=pl_tucson ) participant_dao.update(participant) self.submit_questionnaire_response('P1', questionnaire_id, race_code=RACE_WHITE_CODE, gender_code='male', state=PMI_SKIP_CODE, date_of_birth=datetime.date(1980, 1, 2)) self.submit_questionnaire_response('P2', questionnaire_id, race_code=RACE_NONE_OF_THESE_CODE, gender_code=None, state=None, date_of_birth=None) self.submit_questionnaire_response('P5', questionnaire_id, race_code=PMI_SKIP_CODE, gender_code=PMI_SKIP_CODE, state=None, date_of_birth=None) with FakeClock(TIME_3): # Re-pair the original participant participant.version = 2 participant.providerLink = pl_pitt participant_dao.update(participant) self.send_post('Participant/P2/PhysicalMeasurements', load_measurement_json(2)) self.send_post('Participant/P2/BiobankOrder', load_biobank_order_json(2)) self.submit_questionnaire_response('P1', questionnaire_id, race_code='black', gender_code='female', state=None, date_of_birth=datetime.date(1980, 1, 3)) self.submit_questionnaire_response('P2', questionnaire_id, race_code=None, gender_code=PMI_PREFER_NOT_TO_ANSWER_CODE, state=None, date_of_birth=None) self.submit_questionnaire_response('P2', questionnaire_id_2, race_code=None, gender_code=None, state='PIIState_VA', date_of_birth=None) self.submit_consent_questionnaire_response('P1', questionnaire_id_3, CONSENT_PERMISSION_NO_CODE) self.submit_consent_questionnaire_response('P2', questionnaire_id_3, CONSENT_PERMISSION_YES_CODE) sample_dao = BiobankStoredSampleDao() sample_dao.insert( BiobankStoredSample( biobankStoredSampleId='abc', biobankId=2, biobankOrderIdentifier='KIT', test='test', confirmed=TIME_2)) sample_dao.insert( BiobankStoredSample( biobankStoredSampleId='def', biobankId=3, biobankOrderIdentifier='KIT', test='1SAL', confirmed=TIME_2)) sample_dao.insert( BiobankStoredSample( biobankStoredSampleId='xyz', biobankId=4, biobankOrderIdentifier='KIT', test='1SAL', confirmed=TIME_2))
def _create_data(self): HPODao().insert(HPO(hpoId=AZ_HPO_ID + 1, name='AZ_TUCSON_2')) HPODao().insert(HPO(hpoId=PITT_HPO_ID + 4, name='TEST')) SqlTestBase.setup_codes( ANSWER_FIELD_TO_QUESTION_CODE.values() + [EHR_CONSENT_QUESTION_CODE], code_type=CodeType.QUESTION) SqlTestBase.setup_codes( FIELD_TO_QUESTIONNAIRE_MODULE_CODE.values(), code_type=CodeType.MODULE) # Import codes for white and female, but not male or black. SqlTestBase.setup_codes( [ RACE_WHITE_CODE, CONSENT_PERMISSION_YES_CODE, RACE_NONE_OF_THESE_CODE, PMI_PREFER_NOT_TO_ANSWER_CODE, CONSENT_PERMISSION_NO_CODE, 'female', 'PIIState_VA' ], code_type=CodeType.ANSWER) participant_dao = ParticipantDao() questionnaire_id = self.create_questionnaire('questionnaire3.json') questionnaire_id_2 = self.create_questionnaire('questionnaire4.json') questionnaire_id_3 = self.create_questionnaire( 'all_consents_questionnaire.json') with FakeClock(TIME): participant = self._participant_with_defaults( participantId=1, version=2, biobankId=2, providerLink=make_primary_provider_link_for_name('PITT')) participant_dao.insert(participant) self.send_consent('P1', email='*****@*****.**') # Participant 2 starts out unpaired; later gets paired automatically when their physical # measurements come in. participant2 = Participant(participantId=2, biobankId=3) participant_dao.insert(participant2) self.send_consent('P2', email='*****@*****.**') # Test HPO affiliation; this test participant is ignored. participant3 = Participant( participantId=3, biobankId=4, providerLink=make_primary_provider_link_for_name('TEST')) participant_dao.insert(participant3) self.send_consent('P3', email='*****@*****.**') # example.com e-mail; this test participant is ignored, too. participant4 = Participant( participantId=4, biobankId=5, providerLink=make_primary_provider_link_for_name('PITT')) participant_dao.insert(participant4) self.send_consent('P4', email='*****@*****.**') participant5 = Participant( participantId=5, biobankId=6, providerLink=make_primary_provider_link_for_name('PITT')) participant_dao.insert(participant5) self.send_consent('P5', email='*****@*****.**') # A withdrawn participant should be excluded from metrics. participant6 = Participant( participantId=6, biobankId=7, providerLink=make_primary_provider_link_for_name('PITT') ) participant_dao.insert(participant6) self.send_consent('P6', email='*****@*****.**') participant6.withdrawalStatus=WithdrawalStatus.NO_USE participant_dao.update(participant6) self.send_post('Participant/P2/PhysicalMeasurements', load_measurement_json(2)) self.send_post('Participant/P2/BiobankOrder', load_biobank_order_json(2)) self.submit_questionnaire_response('P1', questionnaire_id, RACE_WHITE_CODE, 'female', None, datetime.date(1980, 1, 2)) self.submit_questionnaire_response( 'P2', questionnaire_id, PMI_PREFER_NOT_TO_ANSWER_CODE, 'male', None, datetime.date(1920, 1, 3)) self.submit_questionnaire_response('P2', questionnaire_id_2, None, None, 'PIIState_VA', None) self.submit_questionnaire_response('P5', questionnaire_id, None, None, None, datetime.date(1970, 1, 2)) self.submit_consent_questionnaire_response('P1', questionnaire_id_3, CONSENT_PERMISSION_NO_CODE) self.submit_consent_questionnaire_response('P2', questionnaire_id_3, CONSENT_PERMISSION_YES_CODE) sample_dao = BiobankStoredSampleDao() sample_dao.insert( BiobankStoredSample( biobankStoredSampleId='abc', biobankId=2, biobankOrderIdentifier='KIT', test='test', confirmed=TIME)) sample_dao.insert( BiobankStoredSample( biobankStoredSampleId='def', biobankId=3, biobankOrderIdentifier='KIT', test='1SAL', confirmed=TIME)) # Required to update the HPO linkage (and test filtering for P3). sample_dao.insert( BiobankStoredSample( biobankStoredSampleId='xyz', biobankId=4, biobankOrderIdentifier='KIT', test='1SAL', confirmed=TIME))