def __init__(self):
        args = parser.parse_args()
        self.organization_dao = OrganizationDao()
        self.stub_geocoding = args.stub_geocoding
        self.ACTIVE = SiteStatus.ACTIVE
        self.status_exception_list = ['hpo-site-walgreensphoenix']
        self.instance = args.instance
        self.creds_file = args.creds_file
        self.new_sites_list = []
        self.project = None
        if args.project:
            self.project = args.project

        if self.project in ENV_LIST:
            self.environment = ' ' + self.project.split('-')[-1].upper()
        else:
            self.environment = ' ' + ENV_TEST.split('-')[-1].upper()

        super(SiteImporter,
              self).__init__('site', SiteDao(), 'siteId', 'googleGroup', [
                  SITE_ORGANIZATION_ID_COLUMN, SITE_SITE_ID_COLUMN,
                  SITE_SITE_COLUMN, SITE_STATUS_COLUMN + self.environment,
                  ENROLLING_STATUS_COLUMN + self.environment,
                  DIGITAL_SCHEDULING_STATUS_COLUMN + self.environment
              ])
  def setUp(self, with_data=True, use_mysql=True):
    super(MetricsEhrServiceTest, self).setUp(with_data=with_data, use_mysql=use_mysql)
    self.service = MetricsEhrService()
    self.hpo_dao = HPODao()
    self.org_dao = OrganizationDao()

    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
    )
    self.org_bar_b = self._make_org(
      organizationId=12,
      externalId='BAR_B',
      displayName='Bar B',
      hpoId=self.hpo_bar.hpoId
    )
示例#3
0
    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 _do_update_for_organization(organization_id, submission_date, person_file):
    """
  deferred task: creates EhrReceipt and updates ParticipantSummary objects from a person.csv file
  """
    updated_datetime = datetime.datetime.combine(submission_date,
                                                 datetime.datetime.min.time())

    org_dao = OrganizationDao()
    summary_dao = ParticipantSummaryDao()
    receipt_dao = EhrReceiptDao()

    org_external_id = organization_id.upper()
    org = org_dao.get_by_external_id(org_external_id)
    if org is None:
        LOG.info("Organization not found with external_id: {}".format(
            org_external_id))

    receipt = EhrReceipt(organizationId=org.organizationId,
                         receiptTime=updated_datetime)
    receipt_dao.insert(receipt)

    for participant_id in _get_participant_ids_from_person_file(person_file):
        summary = summary_dao.get(participant_id)
        if summary is None:
            LOG.info("Participant not found with participant_id: {}".format(
                participant_id))
            continue
        summary_dao.update_ehr_status(summary, updated_datetime)
        summary_dao.update(summary)
 def __init__(self):
     super(ParticipantSummaryDao,
           self).__init__(ParticipantSummary,
                          order_by_ending=_ORDER_BY_ENDING)
     self.hpo_dao = HPODao()
     self.code_dao = CodeDao()
     self.site_dao = SiteDao()
     self.organization_dao = OrganizationDao()
 def setUp(self, **kwargs):
     super(SyncConsentFilesTest, self).setUp(use_mysql=True, **kwargs)
     NdbTestBase.doSetUp(self)
     TestBase.setup_fake(self)
     self.org_dao = OrganizationDao()
     self.site_dao = SiteDao()
     self.participant_dao = ParticipantDao()
     self.summary_dao = ParticipantSummaryDao()
示例#7
0
 def __init__(self):
     super(OrganizationImporter, self).__init__(
         'organization', OrganizationDao(), 'organizationId', 'externalId',
         [
             ORGANIZATION_AWARDEE_ID_COLUMN,
             ORGANIZATION_ORGANIZATION_ID_COLUMN, ORGANIZATION_NAME_COLUMN
         ])
     self.hpo_dao = HPODao()
示例#8
0
 def _get_organization_ids_from_organizations(organizations):
     dao = OrganizationDao()
     try:
         return [
             dao.get_by_external_id(name).organizationId
             for name in organizations
         ]
     except AttributeError:
         raise BadRequest('Invalid organization {value}'.format(
             value=','.join(organizations)))
示例#9
0
    def _setup_hpos(self, org_dao=None):
        hpo_dao = HPODao()
        hpo_dao.insert(
            HPO(hpoId=UNSET_HPO_ID,
                name='UNSET',
                displayName='Unset',
                organizationType=OrganizationType.UNSET))
        hpo_dao.insert(
            HPO(hpoId=PITT_HPO_ID,
                name='PITT',
                displayName='Pittsburgh',
                organizationType=OrganizationType.HPO))
        hpo_dao.insert(
            HPO(hpoId=AZ_HPO_ID,
                name='AZ_TUCSON',
                displayName='Arizona',
                organizationType=OrganizationType.HPO))
        self.hpo_id = PITT_HPO_ID

        org_dao = OrganizationDao()
        org_dao.insert(
            Organization(organizationId=AZ_ORG_ID,
                         externalId='AZ_TUCSON_BANNER_HEALTH',
                         displayName='Banner Health',
                         hpoId=AZ_HPO_ID))

        created_org = org_dao.insert(
            Organization(organizationId=PITT_ORG_ID,
                         externalId='PITT_BANNER_HEALTH',
                         displayName='PITT display Banner Health',
                         hpoId=PITT_HPO_ID))
        self.organization_id = created_org.organizationId

        site_dao = SiteDao()
        created_site = site_dao.insert(
            Site(siteName='Monroeville Urgent Care Center',
                 googleGroup='hpo-site-monroeville',
                 mayolinkClientNumber=7035769,
                 organizationId=PITT_ORG_ID,
                 hpoId=PITT_HPO_ID))
        self.site_id = created_site.siteId
        site_dao.insert(
            Site(siteName='Phoenix Urgent Care Center',
                 googleGroup='hpo-site-bannerphoenix',
                 mayolinkClientNumber=7035770,
                 organizationId=PITT_ORG_ID,
                 hpoId=PITT_HPO_ID))

        site_dao.insert(
            Site(siteName='Phoenix clinic',
                 googleGroup='hpo-site-clinic-phoenix',
                 mayolinkClientNumber=7035770,
                 organizationId=AZ_ORG_ID,
                 hpoId=AZ_HPO_ID))
 def setUp(self, with_data=True, use_mysql=True):
     super(EhrReceiptDaoTest, self).setUp(with_data=with_data,
                                          use_mysql=use_mysql)
     self.setup_fake()
     self.calendar_dao = CalendarDao()
     self.org_dao = OrganizationDao()
     self.hpo_dao = HPODao()
     self.participant_dao = ParticipantDao()
     self.summary_dao = ParticipantSummaryDao()
     self.ehr_receipt_dao = EhrReceiptDao()
     self._setup_initial_data()
def main(args):
    HPOImporter().run(args.awardee_file, args.dry_run)
    HPODao()._invalidate_cache()
    OrganizationImporter().run(args.organization_file, args.dry_run)
    OrganizationDao()._invalidate_cache()
    SiteImporter().run(args.site_file, args.dry_run)

    # Update Organization BigQuery records
    if not args.dry_run:
        bq_hpo_update(args.project)
        bq_organization_update(args.project)
        bq_site_update(args.project)
示例#12
0
    def __init__(self):
        super(SiteImporter,
              self).__init__('site', SiteDao(), 'siteId', 'googleGroup', [
                  SITE_ORGANIZATION_ID_COLUMN, SITE_SITE_ID_COLUMN,
                  SITE_SITE_COLUMN, SITE_STATUS_COLUMN, ENROLLING_STATUS_COLUMN
              ])

        self.organization_dao = OrganizationDao()
        args = parser.parse_args()
        self.geocode_flag = args.geocode_flag
        self.ACTIVE = SiteStatus.ACTIVE
        self.status_exception_list = ['hpo-site-walgreensphoenix']
示例#13
0
 def _setup_unset_enrollment_site(self):
     site_dao = SiteDao()
     organization_dao = OrganizationDao()
     org_2 = organization_dao.insert(
         Organization(externalId='ORG_2',
                      displayName='Organization 2',
                      hpoId=PITT_HPO_ID))
     site_dao.insert(
         Site(siteName='not enrolling site',
              googleGroup='not_enrolling_dot_com',
              organizationId=org_2.organizationId,
              enrollingStatus=EnrollingStatus.UNSET,
              siteStatus=SiteStatus.INACTIVE))
def update_organizations_from_job(job):
  organization_dao = OrganizationDao()
  receipt_dao = EhrReceiptDao()
  for page in job:
    for row in page:
      org = organization_dao.get_by_external_id(row.org_id)
      if org:
        try:
          receipt_time = datetime_as_naive_utc(row.person_upload_time)
        except TypeError:
          continue
        receipt_dao.get_or_create(
          insert_if_created=True,
          organizationId=org.organizationId,
          receiptTime=receipt_time
        )
示例#15
0
    def _setup_data(self):
        organization_dao = OrganizationDao()
        site_dao = SiteDao()
        org_1 = organization_dao.insert(
            Organization(externalId='ORG_1',
                         displayName='Organization 1',
                         hpoId=PITT_HPO_ID,
                         resourceId='o123456'))
        organization_dao.insert(
            Organization(externalId='AARDVARK_ORG',
                         displayName='Aardvarks Rock',
                         hpoId=PITT_HPO_ID,
                         resourceId='o123457'))

        site_dao.insert(
            Site(siteName='Site 1',
                 googleGroup='hpo-site-1',
                 mayolinkClientNumber=123456,
                 organizationId=org_1.organizationId,
                 siteStatus=SiteStatus.ACTIVE,
                 enrollingStatus=EnrollingStatus.ACTIVE,
                 launchDate=datetime.datetime(2016, 1, 1),
                 notes='notes',
                 latitude=12.1,
                 longitude=13.1,
                 directions='directions',
                 physicalLocationName='locationName',
                 address1='address1',
                 address2='address2',
                 city='Austin',
                 state='TX',
                 zipCode='78751',
                 phoneNumber='555-555-5555',
                 adminEmails='[email protected], [email protected]',
                 link='http://www.example.com'))
        site_dao.insert(
            Site(siteName='Zebras Rock',
                 googleGroup='aaaaaaa',
                 organizationId=org_1.organizationId,
                 enrollingStatus=EnrollingStatus.INACTIVE,
                 siteStatus=SiteStatus.INACTIVE))
    def _cleanup_old_entities(self, session, row_list, dry_run):
        log_prefix = '(dry run) ' if dry_run else ''
        self.org_dao = OrganizationDao()
        existing_orgs = set(
            str(org.externalId) for org in self.org_dao.get_all())
        org_group_list_from_sheet = [
            row[ORGANIZATION_ORGANIZATION_ID_COLUMN].upper()
            for row in row_list
        ]

        orgs_to_remove = existing_orgs - set(org_group_list_from_sheet)
        if orgs_to_remove:
            org_id_list = []
            for org in orgs_to_remove:
                old_org = self.org_dao.get_by_external_id(org)
                if old_org and old_org.isObsolete != ObsoleteStatus.OBSOLETE:
                    org_id_list.append(old_org.organizationId)
                    self.deletion_count += 1
                elif old_org and old_org.isObsolete == ObsoleteStatus.OBSOLETE:
                    logging.info(
                        'Not attempting to delete org [%s] with existing obsolete status',
                        old_org.displayName)

            if org_id_list and not dry_run:
                logging.info(
                    log_prefix + 'Marking old Organization as obsolete : %s',
                    old_org)
                str_list = ','.join([str(i) for i in org_id_list])
                sql = """ UPDATE organization
            SET is_obsolete = 1
            WHERE organization_id in ({org_id_list})""".format(
                    org_id_list=str_list)
                session.execute(sql)

                logging.info(
                    log_prefix +
                    'Deleting old Organization no longer in Google sheet: %s',
                    org)
                self.delete_sql_statement(session, str_list)
                self.org_dao._invalidate_cache()
示例#17
0
    def setUp(self):
        super(HierarchyContentApiTest, self).setUp(with_data=False)

        hpo_dao = HPODao()
        hpo_dao.insert(
            HPO(hpoId=UNSET_HPO_ID,
                name='UNSET',
                displayName='Unset',
                organizationType=OrganizationType.UNSET,
                resourceId='h123456'))
        hpo_dao.insert(
            HPO(hpoId=PITT_HPO_ID,
                name='PITT',
                displayName='Pittsburgh',
                organizationType=OrganizationType.HPO,
                resourceId='h123457'))
        hpo_dao.insert(
            HPO(hpoId=AZ_HPO_ID,
                name='AZ_TUCSON',
                displayName='Arizona',
                organizationType=OrganizationType.HPO,
                resourceId='h123458'))
        self.site_dao = SiteDao()
        self.org_dao = OrganizationDao()
    def setUp(self, **kwargs):
        super(UpdateEhrStatusUpdatesTestCase, self).setUp(use_mysql=True,
                                                          **kwargs)
        self.hpo_dao = HPODao()
        self.org_dao = OrganizationDao()
        self.participant_dao = ParticipantDao()
        self.summary_dao = ParticipantSummaryDao()
        self.ehr_receipt_dao = EhrReceiptDao()

        self.hpo_foo = self._make_hpo(int_id=10, string_id='hpo_foo')
        self.hpo_bar = self._make_hpo(int_id=11, string_id='hpo_bar')

        self.org_foo_a = self._make_org(hpo=self.hpo_foo,
                                        int_id=10,
                                        external_id='FOO_A')
        self.org_foo_b = self._make_org(hpo=self.hpo_foo,
                                        int_id=11,
                                        external_id='FOO_B')
        self.org_bar_a = self._make_org(hpo=self.hpo_bar,
                                        int_id=12,
                                        external_id='BAR_A')

        self.participants = [
            self._make_participant(hpo=self.hpo_foo,
                                   org=self.org_foo_a,
                                   int_id=11),
            self._make_participant(hpo=self.hpo_foo,
                                   org=self.org_foo_b,
                                   int_id=12),
            self._make_participant(hpo=self.hpo_bar,
                                   org=self.org_bar_a,
                                   int_id=13),
            self._make_participant(hpo=self.hpo_bar,
                                   org=self.org_bar_a,
                                   int_id=14),
        ]
def main(args):
    HPOImporter().run(args.awardee_file, args.dry_run)
    HPODao()._invalidate_cache()
    OrganizationImporter().run(args.organization_file, args.dry_run)
    OrganizationDao()._invalidate_cache()
    SiteImporter().run(args.site_file, args.dry_run)
示例#20
0
 def setUp(self):
   super(OrganizationDaoTest, self).setUp()
   self.organization_dao = OrganizationDao()
   self.participant_dao = ParticipantDao()
   self.ps_dao = ParticipantSummaryDao()
   self.ps_history = ParticipantHistoryDao()
 def __init__(self):
     super(OrganizationHierarchySyncDao, self).__init__(HPO)
     self.hpo_dao = HPODao()
     self.organization_dao = OrganizationDao()
     self.site_dao = SiteDao()
示例#22
0
  def __init__(self):
    super(ParticipantDao, self).__init__(Participant)

    self.hpo_dao = HPODao()
    self.organization_dao = OrganizationDao()
    self.site_dao = SiteDao()