def setUp(self, **kwargs): super(MetricsEhrApiTestBase, self).setUp(use_mysql=True, **kwargs) self.dao = ParticipantDao() self.ps_dao = ParticipantSummaryDao() self.ehr_receipt_dao = EhrReceiptDao() self.ps = ParticipantSummary() self.calendar_dao = CalendarDao() self.site_dao = SiteDao() self.hpo_dao = HPODao() self.org_dao = OrganizationDao() self.hpo_test = self._make_hpo(hpoId=TEST_HPO_ID, name=TEST_HPO_NAME, displayName='Test', organizationType=OrganizationType.UNSET) self.hpo_foo = self._make_hpo(hpoId=10, name='FOO', displayName='Foo') self.hpo_bar = self._make_hpo(hpoId=11, name='BAR', displayName='Bar') self.org_foo_a = self._make_org(organizationId=10, externalId='FOO_A', displayName='Foo A', hpoId=self.hpo_foo.hpoId) self.org_bar_a = self._make_org(organizationId=11, externalId='BAR_A', displayName='Bar A', hpoId=self.hpo_bar.hpoId)
def create_summary_for_participant(obj): return ParticipantSummary( participantId=obj.participantId, biobankId=obj.biobankId, signUpTime=obj.signUpTime, hpoId=obj.hpoId, withdrawalStatus=obj.withdrawalStatus, suspensionStatus=obj.suspensionStatus, enrollmentStatus=EnrollmentStatus.INTERESTED)
def testUpdateEnrollmentStatus(self): summary = ParticipantSummary( participantId=1, biobankId=2, consentForStudyEnrollment=QuestionnaireStatus.SUBMITTED, consentForElectronicHealthRecords=QuestionnaireStatus.SUBMITTED, enrollmentStatus=EnrollmentStatus.INTERESTED) self.dao.update_enrollment_status(summary) self.assertEquals(EnrollmentStatus.MEMBER, summary.enrollmentStatus)
def testUpdateEnrollmentStatus(self): ehr_consent_time = datetime.datetime(2018, 3, 1) summary = ParticipantSummary( participantId=1, biobankId=2, consentForStudyEnrollment=QuestionnaireStatus.SUBMITTED, consentForElectronicHealthRecords=QuestionnaireStatus.SUBMITTED, consentForElectronicHealthRecordsTime=ehr_consent_time, enrollmentStatus=EnrollmentStatus.INTERESTED) self.dao.update_enrollment_status(summary) self.assertEquals(EnrollmentStatus.MEMBER, summary.enrollmentStatus) self.assertEquals(ehr_consent_time, summary.enrollmentStatusMemberTime)
def _participant_summary_with_defaults(**kwargs): common_args = { 'hpoId': UNSET_HPO_ID, 'numCompletedPPIModules': 0, 'numCompletedBaselinePPIModules': 0, 'numBaselineSamplesArrived': 0, 'withdrawalStatus': WithdrawalStatus.NOT_WITHDRAWN, 'suspensionStatus': SuspensionStatus.NOT_SUSPENDED, 'enrollmentStatus': EnrollmentStatus.INTERESTED } common_args.update(kwargs) return ParticipantSummary(**common_args)
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 create_summary_for_participant(obj): return ParticipantSummary( participantId=obj.participantId, lastModified=obj.lastModified, biobankId=obj.biobankId, signUpTime=obj.signUpTime, hpoId=obj.hpoId, organizationId=obj.organizationId, siteId=obj.siteId, withdrawalStatus=obj.withdrawalStatus, withdrawalReason=obj.withdrawalReason, withdrawalReasonJustification=obj.withdrawalReasonJustification, suspensionStatus=obj.suspensionStatus, enrollmentStatus=EnrollmentStatus.INTERESTED)
def setUp(self): super(ParticipantCountsOverTimeApiTest, self).setUp(use_mysql=True) self.dao = ParticipantDao() self.ps_dao = ParticipantSummaryDao() self.ps = ParticipantSummary() self.calendar_dao = CalendarDao() self.hpo_dao = HPODao() # Needed by ParticipantCountsOverTimeApi self.hpo_dao.insert(HPO(hpoId=TEST_HPO_ID, name=TEST_HPO_NAME, displayName='Test', organizationType=OrganizationType.UNSET)) self.time1 = datetime.datetime(2017, 12, 31) self.time2 = datetime.datetime(2018, 1, 1) self.time3 = datetime.datetime(2018, 1, 2) self.time4 = datetime.datetime(2018, 1, 3) # Insert 2 weeks of dates curr_date = datetime.date(2017, 12, 22) for _ in xrange(0, 14): calendar_day = Calendar(day=curr_date ) CalendarDao().insert(calendar_day) curr_date = curr_date + datetime.timedelta(days=1)