synthpops.ltcfs module¶
Modeling Seattle Metro Long Term Care Facilities
-
generate_ltcfs
(n, with_facilities, loc_pars, expected_age_dist, ages_left_to_assign)[source]¶ Generate residents living in long term care facilities and their ages.
Parameters: - n (int) – The number of people to generate in the population
- with_facilities (bool) – If True, create long term care facilities, currently only available for locations in the US.
- loc_pars (dict) – A dictionary of location parameters
- expected_age_dist (dict) – The expected age distribution
- ages_left_to_assign (dic) – The counter of ages for the generated population left to place in a residence
-
assign_facility_staff
(datadir, location, state_location, country_location, ltcf_staff_age_min, ltcf_staff_age_max, facilities, workers_by_age_to_assign_count, potential_worker_uids_by_age, potential_worker_uids, facilities_by_uids, age_by_uid, use_default=False)[source]¶ Assign Long Term Care Facility staff to the generated facilities with residents.
Parameters: - datadir (string) – The file path to the data directory.
- location – name of the location
- state_location (string) – name of the state the location is in
- country_location (string) – name of the country the location is in
- ltcf_staff_age_min (int) – Long term care facility staff minimum age.
- ltcf_staff_age_max (int) – Long term care facility staff maximum age.
- facilities (list) – A list of lists where each sublist is a facility with the resident ages
- workers_by_age_to_assign_count (dict) – A dictionary mapping age to the count of employed individuals of that age.
- potential_worker_uids (dict) – dictionary of potential workers mapping their id to their age
- facilities – A list of lists where each sublist is a facility with the resident IDs
- age_by_uid (dict) – dictionary mapping id to age for all individuals in the population
- use_default (bool) – If True, try to first use the other parameters to find data specific to the location under study; otherwise, return default data drawing from default_location, default_state, default_country.
Returns: A list of lists with the facility staff IDs for each facility.
Return type: list
-
remove_ltcf_residents_from_potential_workers
(facilities_by_uids, potential_worker_uids, potential_worker_uids_by_age, workers_by_age_to_assign_count, age_by_uid)[source]¶ Remove facilities residents from potential workers
Parameters: - facilities_by_uids (list) – A list of lists, where each sublist represents a skilled nursing or long term care facility and the ids of the residents living within it
- potential_worker_uids (dict) – dictionary of potential workers mapping their id to their age
- potential_worker_uids_by_age (dict) – dictionary mapping age to the list of worker ids with that age
- workers_by_age_to_assign_count (dict) – dictionary of the count of workers left to assign by age
- age_by_uid_dic (dict) – dictionary mapping id to age for all individuals in the population
Returns: Updated dictionaries for potential worker ids, lists of potential worker ids mapped to age, and the number of workers left to assign by age.
-
ltcf_resample_age
(exp_age_distr, a)[source]¶ Resampling younger ages to better match data
Parameters: - exp_age_distr (dict) – age distribution
- age (int) – age as an integer
Returns: Resampled age as an integer.
Notes
This is not always necessary, but is mostly used to smooth out sharp edges in the age distribution when spsamp.resample_age() produces too many of one year and under produces the surrounding ages. For example, new borns (0 years old) may be over produced, and 1 year olds under produced, so this function can be customized to correct for that. It is currently customized to model well the age distribution for Seattle, Washington.
-
get_ltcf_sizes
(popdict, keys_to_exclude=[])[source]¶ Get long term care facility sizes, including both residents and staff.
Parameters: - popdict (dict) – population dictionary
- keys_to_exclude (list) – possible keys to exclude for roles in long term care facilities. See notes.
Returns: Dictionary of the size for each long term care facility generated.
Return type: dict
Notes
keys_to_exclude is an empty list by default, but can contain the different long term care facility roles: ‘ltcf_res’ for residents and ‘ltcf_staff’ for staff. If either role is included in the parameter keys_to_exclude, then individuals with that value equal to 1 will not be counted.
-
class
LongTermCareFacility
(ltcfid=None, resident_uids=array([], dtype=int64), staff_uids=array([], dtype=int64), **kwargs)[source]¶ Bases:
synthpops.base.LayerGroup
A class for individual long term care facilities and methods to operate on each.
Parameters: kwargs (dict) – data dictionary of the long term care facility Class constructor for empty long term care facility (ltcf).
Parameters: - **ltcfid (int) – ltcf id
- **resident_uids (np.array) – ids of ltcf members
- **staff_uids (np.array) – ages of ltcf members
-
validate
()[source]¶ Check that information supplied to make a long term care facility is valid and update to the correct type if necessary.
-
member_uids
¶ residents and staff.
Returns: ltcf member ids Return type: np.ndarray Type: Return ids of all ltcf members
-
member_ages
(age_by_uid)[source]¶ Return ages of all ltcf members: residents and staff.
Parameters: age_by_uid (np.ndarray) – mapping of age to uid Returns: ltcf member ages Return type: np.ndarray
-
get_ltcf
(pop, ltcfid)[source]¶ Return ltcf with id: ltcfid.
Parameters: - pop (sp.Pop) – population
- ltcfid (int) – ltcf id number
Returns: A populated ltcf.
Return type: sp.LongTermCareFacility
-
add_ltcf
(pop, ltcf)[source]¶ Add a ltcf to the list of ltcfs.
Parameters: - pop (sp.Pop) – population
- ltcf (sp.LongTermCareFacility) – ltcf with at minimum the ltcfid, resident_uids and staff_uids.
-
initialize_empty_ltcfs
(pop, n_ltcfs=None)[source]¶ Array of empty ltcfs.
Parameters: - pop (sp.Pop) – population
- n_ltcfs (int) – the number of ltcfs to initialize
-
populate_ltcfs
(pop, resident_lists, staff_lists)[source]¶ Populate all of the ltcfs. Store each ltcf at the index corresponding to it’s ltcfid.
Parameters: - pop (sp.Pop) – population
- residents_list (list) – list of lists where each sublist represents a ltcf and contains the ids of the residents
- staff_lists (list) – list of lists where each sublist represents a ltcf and contains the ids of the staff