# FILE: counselling_interval_script.py # CREATED: 1/12/25 # AUTHOR: Vincent Allen # CONTACT: vincent@vtallen.com valle276@live.kutztown.edu # PURPOSE: # This library file implements control code needed to take the input yearly satisfaction survey data obtained through # the satisfaction survey scorecard in Neoserra and pass it to the library functions that generate the graph images. # No data cleaning is required for the files in this dataset as the scorecard does that for us. We are just taking the data and showing it per # center instead of network wide. The network wide stat is retained through a horizontal line. # Third party libraries import pandas as pd # Python modules import sys import os.path import argparse import json # Custom modules from section_1_graph_library_module import ( #pyright:ignore make_interval_snapshot_chart ) from pasbdc_data_cleaning import clean_center_name #pyright:ignore from constants_module import NEOSERRA_COLUMNS, OUT_COLUMNS def parse_args(): parser = argparse.ArgumentParser() parser.add_argument("--signuptostartcsv", type=str, required=True, help='The path to the dataset containing the "Average # of Days between Client Sign-up and Client Start Date" from the Neoserra scorecard. If provided the graph will be generated') parser.add_argument("--signuptostartfigure", type=str, required=False, default="signuptostart", help='The filename to give the sign up to client start date graph.') parser.add_argument("--signuptocounsellingcsv", type=str, required=True, help='The path to the dataset containing the "Average # of Days between Client Sign-up and 1st Counseling Session" from the Neoserra scorecard. If provided the graph will be generated') parser.add_argument("--signuptocounsellingfigure", type=str, required=False, default="signuptocounselling", help='The filename to give the sign up to first counselling graph.') parser.add_argument("--starttocounsellingcsv", type=str, required=True, help='The path to the dataset containing the "Average # of Days between Client Start Date to 1st Counseling Session" from the Neoserra scorecard. If provided the graph will be generated') parser.add_argument("--starttocounsellingfigure", type=str, required=False, default="starttocounselling", help='The filename to give the sign up to first counselling graph.') parser.add_argument("--initialtofollowupcsv", type=str, required=True, help='The path to the dataset containing the "Average # of Days between Initial Counseling in the period to 1st Followup Counseling" from the Neoserra scorecard. If provided the graph will be generated') parser.add_argument("--initialtofollowupfigure", type=str, required=False, default="initialtofollowup", help='The filename to give the inital session to follow up graph.') parser.add_argument("--trainingtocounsellingcsv", type=str, required=True, help='The path to the dataset containing the "Avg. # of Days between Training in the period to 1st Counseling Session" from the Neoserra scorecard. If provided the graph will be generated') parser.add_argument("--trainingtocounsellingfigure", type=str, required=False, default="trainingtocounselling", help='The filename to give the inital session to follow up graph.') parser.add_argument("--fiscalyear", type=str, required=True, help="The fiscal year tag to place at the end of graph titles to indicate which year the data came from.") parser.add_argument("--outpath", type=str, required=True, help="The base directory path to place generated files into.") parser.add_argument("--report", type=str, required=False, default="counselling-interval", help="The name to give the graphs of this report. Will be used by the word code to determine what report the grpahs belong to." ) parser.add_argument("--mapping", type=str, required=False, help="Path to a JSON file to override default column names mappings.") return parser.parse_args() if __name__ == "__main__": args = parse_args() # Handle optional JSON mapping override if args.mapping: NEOSERRA_COLUMNS.apply_json_mapping(args.mapping) OUT_COLUMNS.apply_json_mapping(args.mapping) # Ensure output directory exists if not os.path.exists(args.outpath): try: os.makedirs(args.outpath) except OSError as e: print(f"Error creating output directory: {e}") sys.exit(1) if args.signuptostartcsv: signup_to_start_df = pd.read_csv(args.signuptostartcsv) # Filter out a testing record that can appear in this data set signup_to_start_df = signup_to_start_df[signup_to_start_df[NEOSERRA_COLUMNS.center] != 'API Testing Sandbox'] clean_center_name(signup_to_start_df ) fig = make_interval_snapshot_chart( signup_to_start_df, title=f"Average Days between Client Sign-up and Client Start Date", fiscal_year_tag=args.fiscalyear, col_interval_data_value=NEOSERRA_COLUMNS.interval_data_value, col_neo_center=NEOSERRA_COLUMNS.center ) fig.write_image(os.path.join(args.outpath, f"{args.report}_{args.signuptostartfigure}_.png")) if args.signuptocounsellingcsv: signup_to_counselling_df = pd.read_csv(args.signuptocounsellingcsv) clean_center_name(signup_to_counselling_df ) fig = make_interval_snapshot_chart( signup_to_counselling_df , title=f"Average Days between Client Sign-up and 1st Counseling Session", fiscal_year_tag=args.fiscalyear, col_interval_data_value=NEOSERRA_COLUMNS.interval_data_value, col_neo_center=NEOSERRA_COLUMNS.center ) fig.write_image(os.path.join(args.outpath, f"{args.report}_{args.signuptocounsellingfigure}_.png")) if args.starttocounsellingcsv: start_to_counselling_df = pd.read_csv(args.starttocounsellingcsv) clean_center_name(start_to_counselling_df ) fig = make_interval_snapshot_chart( start_to_counselling_df, title=f"Average Days between Client Start Date and 1st Counseling Session", fiscal_year_tag=args.fiscalyear, col_interval_data_value=NEOSERRA_COLUMNS.interval_data_value, col_neo_center=NEOSERRA_COLUMNS.center ) fig.write_image(os.path.join(args.outpath, f"{args.report}_{args.starttocounsellingfigure}_.png")) if args.initialtofollowupcsv: inital_to_followup_df = pd.read_csv(args.initialtofollowupcsv) clean_center_name(inital_to_followup_df ) fig = make_interval_snapshot_chart( inital_to_followup_df , title=f"Average Days between Initial Counseling and 1st Followup Counseling", fiscal_year_tag=args.fiscalyear, col_interval_data_value=NEOSERRA_COLUMNS.interval_data_value, col_neo_center=NEOSERRA_COLUMNS.center ) fig.write_image(os.path.join(args.outpath, f"{args.report}_{args.initialtofollowupfigure}_.png")) if args.trainingtocounsellingcsv: training_to_counselling_df = pd.read_csv(args.trainingtocounsellingcsv) clean_center_name(training_to_counselling_df ) fig = make_interval_snapshot_chart( training_to_counselling_df, title=f"Average Days between Training and 1st Counseling Session", fiscal_year_tag=args.fiscalyear, col_interval_data_value=NEOSERRA_COLUMNS.interval_data_value, col_neo_center=NEOSERRA_COLUMNS.center ) fig.write_image(os.path.join(args.outpath, f"{args.report}_{args.trainingtocounsellingfigure}_.png"))