Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjwood16 committed Nov 19, 2024
1 parent 43e5f9a commit eb35c92
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/bsa_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ def resource_name_list_filter(self):
pre_cache_year = int(CACHE_MANAGER_OBJ.return_pre_cache_year())

# Create the new column 'modified_table_name'
filtered_df = filtered_df.copy()
filtered_df['modified_table_name'] = filtered_df.apply(
lambda row: 'EPD_pre_2024' if row['date'].year < pre_cache_year else row['bq_table_name'],
axis=1
Expand Down
31 changes: 23 additions & 8 deletions src/main.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import pandas as pd
import bsa_utils
#import utils
#import testing_utils
#import os
import utils
import testing_utils
import os

def main():
dataset_id = "english-prescribing-data-epd" # Dataset ID
Expand All @@ -15,17 +15,32 @@ def main():

# Extract existing data from EPD
date_from = "earliest" # Can be "YYYYMM" or "earliest" or "latest", default="earliest"
date_to = "latest-1" # Can be "YYYYMM" or "latest" or "latest-1", default="latest"
date_to = "202401" # Can be "YYYYMM" or "latest" or "latest-1", default="latest"

# Fetch existing data using BSA API
existing_data_extract = bsa_utils.FetchData(resource=dataset_id, date_from=date_from, date_to=date_to, sql=sql, cache=True)

# Extract latest data from EPD
date_from = "latest" # Can be "YYYYMM" or "earliest" or "latest", default="earliest"
date_to = "latest" # Can be "YYYYMM" or "latest" or "latest-1", default="latest"
date_from = "202402" # Can be "YYYYMM" or "earliest" or "latest", default="earliest"
date_to = date_from # Can be "YYYYMM" or "latest" or "latest-1", default="latest"

# Fetch latest data using BSA API
#latest_data_extract = bsa_utils.FetchData(resource=dataset_id, date_from=date_from, date_to=date_to, sql=sql)
latest_data_extract = bsa_utils.FetchData(resource=dataset_id, date_from=date_from, date_to=date_to, sql=sql)

compare_data = utils.CompareLatest(
existing_data_extract.results(),
latest_data_extract.results(),
exclude_chapters=[]
)

chem_subs = compare_data.return_new_chem_subs()
bnf_codes = compare_data.return_new_bnf_codes()
return_new_desc_only = compare_data.return_new_desc_only()
data_for = latest_data_extract.return_resources_to()
utils.write_monthly_report_html(chem_subs, bnf_codes, return_new_desc_only, data_for)
utils.generate_list_reports_html()

testing_utils.run_tests(bnf_codes, data_for)

if __name__ == "__main__":
main()
main()

0 comments on commit eb35c92

Please sign in to comment.