# Title of Dataset
---

Python code for "Deconstructing the effects of stochasticity on transmission of hospital-acquired infections in ICUs"


## Description of the data and file structure

Contents of the "data" folder:
1. hospitals_data.csv: contains hospital-level parameters. Each row represents a unique hospital to be created by the code. Description of the parameters (columns):
	- name: name of the hospital (e.g., Johns Hopkins Hospital or JHH)
	- number_units: number of units (departments) to be created for the hospital.
	- doctor_patient_ratio: average physician-to-patient-ratio on the hospital level (average number of patients divided by average number of on-call physicians)
	- beds: total number of beds
	- doctor_hygience_compliance_enter_mean: average physicians compliance rate to hand washing before entering a patient room (values between 0 and 1) 
	- doctor_hygience_compliance_enter_half_interval: half interval of the uniform distribution for physicians compliance rate to hand washing before entering a patient room
	- doctor_hygience_compliance_exit_mean: average physicians compliance rate to hand washing when exiting a patient room (values between 0 and 1)
	- doctor_hygience_compliance_exit_half_interval: half interval of the uniform distribution for physicians compliance rate to hand washing when exiting a patient room
	- doctor_PPE_compliance_mean: average physicians compliance rate to wearing personal protection equipment (i.e., gloves and gowns), values between 0 and 1
	- doctor_PPE_compliance_half_interval: half interval of the uniform distribution for physicians compliance rate to wearing personal protection equipment (i.e., gloves and gowns)
	- physician_contacts_per_patient_day_mean_CP: average number of daily visits to a patient under contact precautions by a physician
	- physician_contacts_per_patient_day_half_interval_CP: half interval of the uniform distribution for the number of daily visits to a patient under contact precautions by a physician
	- physician_contacts_per_patient_day_mean_NCP: average number of daily visits to a patient not under contact precautions by a physician
	- physician_contacts_per_patient_day_half_interval_NCP: half interval of the uniform distribution for the number of daily visits to a patient not under contact precautions by a physician

2. units_parameters.csv: contains ICU-level parameters. Each row represents a separate ICU to be created by the code. Description of the parameters (columns):
	- ID: identification number of the unit
	- name: name of the unit (e.g., intensive care)
	- patient_rooms: number of patient rooms (all assumed to be single rooms in this version of the model)
	- capacity: total patient capacity of the unit
	- shared_bathrooms: number of bathrooms shared by the healthcare workers and patients
	- initial_patients: initial number of patients in the unit when simulation starts
	- nurse_patient_ratio: average nurse-to-patient ratio (average number of patients divided by average number of on-call nurses)
	- bed_utilization_min: lower bound for the bed utilization rate
	- bed_utilization_max: upper bound for the bed utilization rate
	- admission_mean: average number of daily admissions
	- admission_sd: standard deviation of number of daily admission
	- admission_highly_susceptible_min: lower bound of the proportion of admissions that are highly susceptible to hospital-acquired infections (e.g., those that have been using antibiotics)
	- admission_highly_susceptible_max: upper bound of the proportion of admissions that are highly susceptible to hospital-acquired infections (e.g., those that have been using antibiotics)
	- admission_colonized_min: lower bound of the proportion of patients with a positive pathogen test at admission 
	- admission_colonized_max: upper bound of the proportion of patients with a positive pathogen test at admission 
	- admission_infected: proportion of patients who are already infected at admission
	- LOS_log_mean: average length of stay
	- LOS_log_sd: standard deviation of length of stay
	- surface_disinfection_frequency_days: how often room and other common surfaces are cleaned with disinfecting agents
	- tertminal_room_disinfection: 1=rooms are disinfected following patient discharge; 0=otherwise
	- admission_testing: 1=patients are tested for pathogens at admission
	- regular_testing_probablity: proportion of patients on active surveillance
	- regular_testing_frequency_days: active surveillance frequency (# days)
	- testing_accuracy: accuracy of pathogen tests
	- ambulatory_ratio: proportion of patients that are ambulatory
	- nurse_shift_hours: length of nurse shifts
	- nurse_hygiene_compliance_enter_mean: average nurses compliance rate to hand washing before entering a patient room (values between 0 and 1)
	- nurse_hygiene_compliance_enter_half_interval: half interval of the uniform distribution for nurses compliance rate to hand washing before entering a patient room
	- nurse_hygiene_compliance_exit_mean: average nurses compliance rate to hand washing when exiting a patient room (values between 0 and 1)
	- nurse_hygiene_compliance_exit_half_interval: half interval of the uniform distribution for nurses compliance rate to hand washing when exiting a patient room
	- nurse_PPE_compliance_mean: average nurses compliance rate to wearing personal protection equipment (i.e., gloves and gowns), values between 0 and 1
	- nurse_PPE_compliance_half_interval: half interval of the uniform distribution for nurses compliance rate to wearing personal protection equipment (i.e., gloves and gowns)
	- nurse_contacts_per_patient_day_mean_CP: average number of daily visits to a patient under contact precautions by a nurse
	- nurse_contacts_per_patient_day_half_interval_CP: half interval of the uniform distribution for the number of daily visits to a patient under contact precautions by a nurse
	- nurse_contacts_per_patient_day_mean_NCP: average number of daily visits to a patient not under contact precautions by a nurse
	- nurse_contacts_per_patient_day_half_interval_NCP: half interval of the uniform distribution for the number of daily visits to a patient not under contact precautions by a nurse
	- primary_nurse_visit_ratio: average proportion of nurse visits to a patient done by their primary nurse

3. transmission_parameters.csv: contains values of deterministic parameters:
	- infection recovery: length of infection treatment (days)
	- background_transmission_probability: probability of background transmission (0 to 1)
	- Transmission increase factor for highly susceptible: increase risk factor of probability of colonization/infection for highly susceptible patients 
	- probability of direct infection from exposure: probability that exposure to pathogens leads directly to an infection, and not a colonization
	- probability of colonization to infection: probability of a colonized patient becoming infected without external factors
	- probability of environmental colonization: probability that a patient becomes colonized by contacting their environment in a day
	- probability of room contamination by colonized/infected patient per day: probability that a colonized/infected patient contaminates their room environment in a day
	- probability of death: probability of death during stay in hospital from a hospital-acquired infection
	- shedding increase factor for infected: with respect to colonized patients
	- pathogen natural clearance rate from dry surfaces: inverse of average surviving length (days) of pathogens on dry surfaces
	- pathogen natural clearance rate from wet surfaces: inverse of average surviving length (days) of pathogens on wet surfaces
	- disinfection efficacy from dry surfaces: effectiveness of cleaning agents on dry surfaces (values 0 to 1)
	- disinfection efficacy from wet surfaces: effectiveness of cleaning agents on wet surfaces (values 0 to 1)
	- disinfection efficacy from hands (hygiene): effectiveness of cleaning agents when washing hands (values 0 to 1)
	- mean probability of transmission from contaminated hcw to susceptible patient
	- mean probability of transmission from colonized/infected patient to uncontaminated hcw
	- mean probability of HCW contamination from contaminated environment
	- mean probability of environmental contamination from contaminated HCW
	- seasonality_quarter: the calendar year quarter (90-day or 3-month period) that importation increases (high season), values from 1 to 4. E.g., "1" represents Jan through Mar.
	- seasonality_strength: the strength of the seasonality in importation (for details and equations, refer to the Methods section of the article)


4. transmission_pathways.csv: contains pathways of transmission to be considered in the model. To include, change values from 0 to 1.
	- environmental: environmental transmission pathway (patient and HCW contacting the environment during a HCW visit)
	- patient_room: patient-room contamination/colonization (outside of HCW visits)
	- patient_bathroom: patient-bathroom contamination/colonization (outside of HCW visits)
	- nursing_station: HCW contamination from/to the nursing station
	- nurse_bathroom: HCW contamination from/to the bathrooms

5. mc_parameters_ranges.csv: contains the parameters of distributions for stocahstic parameters. All parameters are assumed to follow a uniform distribution (refer to the manuscript for the details and rationale). Column "min" refers to the lower bound of the uniform distribution, and column "max" is the upper bound.

Python files:
1. seasonality_effects_different_measures.py: Used to analyze the results of seasonality detection and generate figures.
2. agents.py: Python class file containing the agents and their subprocesses.
3. post_processing.py: source file for all functions used for postprocessing the results of the monte carlo simulations and creating the figures.
4. pcorr.py: Code for conducting partial correlation rank analysis.
5. monte_carlo_simulation.py: Code for conducting monte carlo simulations.
6. main.py: Code for conducting one single simulation for a given time window.


## Code/Software
Python version 3.7 or higher
Input files, including parameters and sampling distributions for Monte Carlo simulations should be put in a folder called "data". First, run "monte_carlo_simulation.py" for simulations. Then, run "pcorr.py" for uncertainty analysis on the results of the simulations. The results of the simulations can be found in the "monte carlo" folder, after running the code. The results of the uncertainty analysis can be found in the "output" folder, after running the code.