covid19-etl/etl/idph_vaccine.py
def parse_county_data(self):
        """
        For each county, converts the raw data into Sheepdog submissions by
        mapping properties to match the PRC data dictionary.
        Return the `submitter_id` for the state-wide `summary_clinical` record.
        """
        county_vaccine_mapping = {
            "AdministeredCount": "vaccine_administered_count",
            "AdministeredCountChange": "vaccine_administered_count_change",
            "AdministeredCountRollAvg": "vaccine_administered_count_roll_avg",
            "PersonsFullyVaccinated": "vaccine_persons_fully_vaccinated",
            "Report_Date": "date",
            "PctVaccinatedPopulation": "vaccine_persons_fully_vaccinated_pct",
        }

        county_demo_mapping = {
            "AgeGroup": "age_group",
            "Race": "race",
            "Gender": "gender",
            "AdministeredCount": "vaccine_administered_count",
            "PersonsFullyVaccinated": "vaccine_persons_fully_vaccinated",
        }

        inventory_reported = {
            "LHDReportedInventory": "vaccine_LHDR_reported_inventory",
            "CommunityReportedInventory": "vaccine_community_reported_inventory",
            "TotalReportedInventory": "vaccine_reported_inventory",
            "InventoryReportDate": "date",
        }

        self.parse_list_of_counties()
        illinois_summary_clinical_submitter_id = ""
        for i, county in enumerate(self.counties_inventory):
            if i % 10 == 0:
                print(f"{i} / {len(self.counties_inventory)} counties")
            county_covid_response = self.get(
                COUNTY_COVID_LINK_FORMAT.format(county),
                headers={"content-type": "json"},
            )
            county_covid_data = json.loads(county_covid_response.text).get(
                "CurrentVaccineAdministration"
            )
            county_demo_response = self.get(
                COUNTY_DEMO_LINK_FORMAT.format(county), headers={"content-type": "json"}
            )
            county_demo_data = json.loads(county_demo_response.text)

            (
                summary_location_submitter_id,
                summary_clinical_submitter_id,
            ) = self.get_location_and_clinical_submitter_id(county, self.date)
            if county.lower() == "illinois":
                illinois_summary_clinical_submitter_id = summary_clinical_submitter_id

            for k in ["Age", "Race", "Gender"]:
                data = county_demo_data.get(k, [])
                for item in data:
                    keys, props = self.parse_group_clinical_demographic(
                        county_demo_mapping, item
                    )
                    group_demographics_submitter_id = (
                        self.get_group_clinical_demographic_submitter_id(
                            summary_clinical_submitter_id, keys
                        )
                    )
                    props["submitter_id"] = group_demographics_submitter_id
                    props["summary_clinicals"] = [
                        {"submitter_id": summary_clinical_submitter_id}
                    ]
                    self.summary_group_demographic[
                        group_demographics_submitter_id
                    ] = props

            summary_location = {
                "country_region": self.country,
                "submitter_id": summary_location_submitter_id,
                "projects": [{"code": self.project_code}],
                "province_state": self.state,
                "county": county,
            }
            summary_clinical = {
                "submitter_id": summary_clinical_submitter_id,
                "date": self.date,
                "summary_locations": [{"submitter_id": summary_location_submitter_id}],
            }
            for (key, value) in county_vaccine_mapping.items():
                if value == "vaccine_persons_fully_vaccinated_pct":
                    summary_clinical[value] = int(county_covid_data.get(key) * 100)
                elif value == "vaccine_administered_count_roll_avg":
                    summary_clinical[value] = int(county_covid_data.get(key))
                elif value == "date":
                    summary_clinical[value] = remove_time_from_date_time(
                        county_covid_data.get(key)
                    )
                else:
                    summary_clinical[value] = county_covid_data.get(key)
            # for (key, value) in county_demo_mapping.items():
            #     summary_clinical[value] = county_demo_data.get(key)
            for (key, value) in inventory_reported.items():
                summary_clinical[value] = (
                    self.counties_inventory[county].get(key)
                    if value != "date"
                    else remove_time_from_date_time(
                        self.counties_inventory[county].get(key)
                    )
                )

            self.summary_locations[summary_location_submitter_id] = summary_location
            self.summary_clinicals[summary_clinical_submitter_id] = summary_clinical
        return illinois_summary_clinical_submitter_id

        For each county, converts the raw data into Sheepdog submissions by
        mapping properties to match the PRC data dictionary.
        Return the `submitter_id` for the state-wide `summary_clinical` record.
        
For each county, converts the raw data into Sheepdog submissions by
mapping properties to match the PRC data dictionary.
Return the `submitter_id` for the state-wide `summary_clinical` record.
For each county converts the raw data into Sheepdog submissions by mapping properties to match the PRC data dictionary . Return the ` submitter_id ` for the state - wide ` summary_clinical ` record .
def parse_county_data(self):
        county_vaccine_mapping = {
            "AdministeredCount": "vaccine_administered_count",
            "AdministeredCountChange": "vaccine_administered_count_change",
            "AdministeredCountRollAvg": "vaccine_administered_count_roll_avg",
            "PersonsFullyVaccinated": "vaccine_persons_fully_vaccinated",
            "Report_Date": "date",
            "PctVaccinatedPopulation": "vaccine_persons_fully_vaccinated_pct",
        }
        county_demo_mapping = {
            "AgeGroup": "age_group",
            "Race": "race",
            "Gender": "gender",
            "AdministeredCount": "vaccine_administered_count",
            "PersonsFullyVaccinated": "vaccine_persons_fully_vaccinated",
        }
        inventory_reported = {
            "LHDReportedInventory": "vaccine_LHDR_reported_inventory",
            "CommunityReportedInventory": "vaccine_community_reported_inventory",
            "TotalReportedInventory": "vaccine_reported_inventory",
            "InventoryReportDate": "date",
        }
        self.parse_list_of_counties()
        illinois_summary_clinical_submitter_id = ""
        for i, county in enumerate(self.counties_inventory):
            if i % 10 == 0:
                print(f"{i} / {len(self.counties_inventory)} counties")
            county_covid_response = self.get(
                COUNTY_COVID_LINK_FORMAT.format(county),
                headers={"content-type": "json"},
            )
            county_covid_data = json.loads(county_covid_response.text).get(
                "CurrentVaccineAdministration"
            )
            county_demo_response = self.get(
                COUNTY_DEMO_LINK_FORMAT.format(county), headers={"content-type": "json"}
            )
            county_demo_data = json.loads(county_demo_response.text)
            (
                summary_location_submitter_id,
                summary_clinical_submitter_id,
            ) = self.get_location_and_clinical_submitter_id(county, self.date)
            if county.lower() == "illinois":
                illinois_summary_clinical_submitter_id = summary_clinical_submitter_id
            for k in ["Age", "Race", "Gender"]:
                data = county_demo_data.get(k, [])
                for item in data:
                    keys, props = self.parse_group_clinical_demographic(
                        county_demo_mapping, item
                    )
                    group_demographics_submitter_id = (
                        self.get_group_clinical_demographic_submitter_id(
                            summary_clinical_submitter_id, keys
                        )
                    )
                    props["submitter_id"] = group_demographics_submitter_id
                    props["summary_clinicals"] = [
                        {"submitter_id": summary_clinical_submitter_id}
                    ]
                    self.summary_group_demographic[
                        group_demographics_submitter_id
                    ] = props
            summary_location = {
                "country_region": self.country,
                "submitter_id": summary_location_submitter_id,
                "projects": [{"code": self.project_code}],
                "province_state": self.state,
                "county": county,
            }
            summary_clinical = {
                "submitter_id": summary_clinical_submitter_id,
                "date": self.date,
                "summary_locations": [{"submitter_id": summary_location_submitter_id}],
            }
            for (key, value) in county_vaccine_mapping.items():
                if value == "vaccine_persons_fully_vaccinated_pct":
                    summary_clinical[value] = int(county_covid_data.get(key) * 100)
                elif value == "vaccine_administered_count_roll_avg":
                    summary_clinical[value] = int(county_covid_data.get(key))
                elif value == "date":
                    summary_clinical[value] = remove_time_from_date_time(
                        county_covid_data.get(key)
                    )
                else:
                    summary_clinical[value] = county_covid_data.get(key)
            for (key, value) in inventory_reported.items():
                summary_clinical[value] = (
                    self.counties_inventory[county].get(key)
                    if value != "date"
                    else remove_time_from_date_time(
                        self.counties_inventory[county].get(key)
                    )
                )
            self.summary_locations[summary_location_submitter_id] = summary_location
            self.summary_clinicals[summary_clinical_submitter_id] = summary_clinical
        return illinois_summary_clinical_submitter_id
def parse_county_data ( self ) : county_vaccine_mapping = { "AdministeredCount" : "vaccine_administered_count" , "AdministeredCountChange" : "vaccine_administered_count_change" , "AdministeredCountRollAvg" : "vaccine_administered_count_roll_avg" , "PersonsFullyVaccinated" : "vaccine_persons_fully_vaccinated" , "Report_Date" : "date" , "PctVaccinatedPopulation" : "vaccine_persons_fully_vaccinated_pct" , } county_demo_mapping = { "AgeGroup" : "age_group" , "Race" : "race" , "Gender" : "gender" , "AdministeredCount" : "vaccine_administered_count" , "PersonsFullyVaccinated" : "vaccine_persons_fully_vaccinated" , } inventory_reported = { "LHDReportedInventory" : "vaccine_LHDR_reported_inventory" , "CommunityReportedInventory" : "vaccine_community_reported_inventory" , "TotalReportedInventory" : "vaccine_reported_inventory" , "InventoryReportDate" : "date" , } self . parse_list_of_counties ( ) illinois_summary_clinical_submitter_id = "" for i , county in enumerate ( self . counties_inventory ) : if i % 10 == 0 : print ( f"{i} / {len(self.counties_inventory)} counties" ) county_covid_response = self . get ( COUNTY_COVID_LINK_FORMAT . format ( county ) , headers = { "content-type" : "json" } , ) county_covid_data = json . loads ( county_covid_response . text ) . get ( "CurrentVaccineAdministration" ) county_demo_response = self . get ( COUNTY_DEMO_LINK_FORMAT . format ( county ) , headers = { "content-type" : "json" } ) county_demo_data = json . loads ( county_demo_response . text ) ( summary_location_submitter_id , summary_clinical_submitter_id , ) = self . get_location_and_clinical_submitter_id ( county , self . date ) if county . lower ( ) == "illinois" : illinois_summary_clinical_submitter_id = summary_clinical_submitter_id for k in [ "Age" , "Race" , "Gender" ] : data = county_demo_data . get ( k , [ ] ) for item in data : keys , props = self . parse_group_clinical_demographic ( county_demo_mapping , item ) group_demographics_submitter_id = ( self . get_group_clinical_demographic_submitter_id ( summary_clinical_submitter_id , keys ) ) props [ "submitter_id" ] = group_demographics_submitter_id props [ "summary_clinicals" ] = [ { "submitter_id" : summary_clinical_submitter_id } ] self . summary_group_demographic [ group_demographics_submitter_id ] = props summary_location = { "country_region" : self . country , "submitter_id" : summary_location_submitter_id , "projects" : [ { "code" : self . project_code } ] , "province_state" : self . state , "county" : county , } summary_clinical = { "submitter_id" : summary_clinical_submitter_id , "date" : self . date , "summary_locations" : [ { "submitter_id" : summary_location_submitter_id } ] , } for ( key , value ) in county_vaccine_mapping . items ( ) : if value == "vaccine_persons_fully_vaccinated_pct" : summary_clinical [ value ] = int ( county_covid_data . get ( key ) * 100 ) elif value == "vaccine_administered_count_roll_avg" : summary_clinical [ value ] = int ( county_covid_data . get ( key ) ) elif value == "date" : summary_clinical [ value ] = remove_time_from_date_time ( county_covid_data . get ( key ) ) else : summary_clinical [ value ] = county_covid_data . get ( key ) for ( key , value ) in inventory_reported . items ( ) : summary_clinical [ value ] = ( self . counties_inventory [ county ] . get ( key ) if value != "date" else remove_time_from_date_time ( self . counties_inventory [ county ] . get ( key ) ) ) self . summary_locations [ summary_location_submitter_id ] = summary_location self . summary_clinicals [ summary_clinical_submitter_id ] = summary_clinical return illinois_summary_clinical_submitter_id
For each county, converts the raw data into Sheepdog submissions by
mapping properties to match the PRC data dictionary.
For each county converts the raw data into Sheepdog submissions by mapping properties to match the PRC data dictionary .
"""
        For each county, converts the raw data into Sheepdog submissions by
        mapping properties to match the PRC data dictionary.
        Return the `submitter_id` for the state-wide `summary_clinical` record.
        """ # for (key, value) in county_demo_mapping.items(): #     summary_clinical[value] = county_demo_data.get(key)
self