Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

possible inconsistencies in using get_blank_appt_footprint() #1401

Open
tdm32 opened this issue Jun 11, 2024 · 2 comments
Open

possible inconsistencies in using get_blank_appt_footprint() #1401

tdm32 opened this issue Jun 11, 2024 · 2 comments
Assignees

Comments

@tdm32
Copy link
Collaborator

tdm32 commented Jun 11, 2024

Currently get_blank_appt_footprint() is used within some modules (HIV, TB etc) when a HSI has been scheduled but not resources are actually occupied, e.g. person is not eligible for test or is already on treatment. These HSIs are logged as having been delivered and therefore contribute to the total numbers of HSIs in outputs, even though no person-time / consumables are required.

When no resources are required, should a return statement be used so that this HSI is not logged? The current set-up may be skewing results where HSI numbers requested / delivered are used.

@tbhallett @marghe-molaro What do you think?

@tamuri tamuri added this to Issues in Issue management Jun 19, 2024
@tbhallett tbhallett moved this from Issues to To do in Issue management Jun 20, 2024
@tbhallett
Copy link
Collaborator

Thanks @tdm32

I agree with this being misleading if people are just looking at counts of HSI Event occurrences.

We could make a new logging key, which is for counts of appointment that incurred some HCW time (i.e. ran, and did not return a blank footprint). Would that help...?

@tbhallett
Copy link
Collaborator

@sakshimohan also notes here

Here is the script that I have used to get the total number of HSIs based on Number_By_Appt_Type_Code and TREATMENT_ID in the healthsystem.summary logger. Number_By_Appt_Type_Code gives me a 40% of the HSIs in total than what's recorded under TREATMENT_ID.

# Load outputs
results_folder = Path(outputspath / 'sakshi.mohan@york.ac.uk/impact_of_consumables_scenarios-2024-06-11T204007Z/')
log = load_pickled_dataframes(results_folder)

TARGET_PERIOD = (Date(2010, 1, 1), Date(2019, 12, 31))

def get_counts_of_hsi_by_treatment_id(_df):
    """Get the counts of the short TREATMENT_IDs occurring"""
    _counts_by_treatment_id = _df \
        .loc[pd.to_datetime(_df['date']).between(*TARGET_PERIOD), 'TREATMENT_ID'] \
        .apply(pd.Series) \
        .sum() \
        .astype(int)
    return _counts_by_treatment_id.groupby(level=0).sum()

counts_of_hsi_by_treatment_id = extract_results(
        results_folder,
        module='tlo.methods.healthsystem.summary',
        key='HSI_Event',
        custom_generate_series=get_counts_of_hsi_by_treatment_id,
        do_scaling=True
    )

def get_counts_of_hsis_by_level(_df):
    flattened_data = []
    for level, appt in _df['Number_By_Appt_Type_Code'].items():
        for appt, count in appt.items():
            flattened_data.append((level, appt, count))

    flattened_data = pd.DataFrame(flattened_data, columns=['Facility_Level', 'Appointment_Type', 'HSI_count'])
    flattened_data.set_index(['Facility_Level', 'Appointment_Type'], inplace = True)
    return pd.Series(flattened_data.stack()).fillna(0).astype(int)

counts_of_hsi_by_level = extract_results(
        results_folder,
        module='tlo.methods.healthsystem.summary',
        key='HSI_Event',
        custom_generate_series=get_counts_of_hsis_by_level,
        do_scaling=True
    )

total_hsis_using_log_by_facility_level = counts_of_hsi_by_level.sum()[0]
total_hsis_using_log_by_treatmentID = counts_of_hsi_by_treatment_id.sum()[0]

print(f"Baseline scenario (5 runs): \n HSIs based on 'Number_By_Appt_Type_Code' {total_hsis_using_log_by_facility_level} "
      f"\n HSIs based on 'TREATMENT_ID' {total_hsis_using_log_by_treatmentID}")

print(f"For run = 0, the total number HSIs as per 'Number_By_Appt_Type_Code_And_Level' key is {round(total_hsis_using_log_by_facility_level[0],2)},"
      f"whereas the total number of HSIs as per the 'TREATMENT_ID' key is {round(total_hsis_using_log_by_treatmentID[0],2)}")

@tbhallett responded:

I think this is to do with issue #1401 --- which notes many appointments that run have a blank_foot_print, meaning that that are counted in the HSI_Event logs used to generate the number of events by TREATMENT_ID.... but do not figure in 'Number_By_Appt_Type_Code' (because they do not have an Appt_Type).
It's a bit of a weird one! The top-line answer is that we're still thinking about but are leaning towards making an edit that avoids this by either; (i) making sure blank_appt_footprintgs are counted in ''Number_By_Appt_Type_Code'; or (ii) (more likely and easier) not counting as having run, any HSI_Event that returns a blank foot print.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

3 participants