june.groups.hospital¶
-
class
june.groups.hospital.
AbstractHospital
¶ Hospital functionality common for all hospitals (internal to the domain and external).
-
__init__
()¶ Initialize self. See help(type(self)) for accurate signature.
-
add_to_icu
(person)¶
-
add_to_ward
(person)¶
-
allocate_patient
(person)¶ Allocate a patient inside the hospital, in the ward, in the ICU, or transfer. To correctly log if the person has been just admitted, transfered, or released, we return a few flags: - “ward_admitted” : this person has been admitted to the ward. - “icu_admitted” : this person has been directly admitted to icu. - “ward_transferred” : this person has been transferred to ward (from icu) - “icu_transferred” : this person has been transferred to icu (from ward) - “no_change” : no change respect to last time step.
-
release_patient
(person)¶ Releases patient from hospital.
-
remove_from_icu
(person)¶
-
remove_from_ward
(person)¶
-
-
class
june.groups.hospital.
ExternalHospital
(id, spec, domain_id, region_name)¶ -
__init__
(id, spec, domain_id, region_name)¶ Initialize self. See help(type(self)) for accurate signature.
-
add_to_icu
(person)¶
-
add_to_ward
(person)¶
-
allocate_patient
(person)¶ Allocate a patient inside the hospital, in the ward, in the ICU, or transfer. To correctly log if the person has been just admitted, transfered, or released, we return a few flags: - “ward_admitted” : this person has been admitted to the ward. - “icu_admitted” : this person has been directly admitted to icu. - “ward_transferred” : this person has been transferred to ward (from icu) - “icu_transferred” : this person has been transferred to icu (from ward) - “no_change” : no change respect to last time step.
-
release_patient
(person)¶ Releases patient from hospital.
-
remove_from_icu
(person)¶
-
remove_from_ward
(person)¶
-
domain_id
¶
-
external
= True¶
-
icu_ids
¶
-
id
¶
-
region_name
¶
-
spec
¶
-
ward_ids
¶
-
-
class
june.groups.hospital.
Hospital
(n_beds: int, n_icu_beds: int, area: str = None, coordinates: Optional[Tuple[float, float]] = None, trust_code: str = None)¶ The Hospital class represents a hospital and contains information about its patients and workers - the latter being the usual “people”.
We currently use three subgroups: 0 - workers (i.e. nurses, doctors, etc.), 1 - patients 2 - ICU patients
Create a Hospital given its description.
- n_beds:
total number of regular beds in the hospital
- n_icu_beds:
total number of ICU beds in the hospital
- area:
name of the super area the hospital belongs to
- coordinates:
latitude and longitude
-
__init__
(n_beds: int, n_icu_beds: int, area: str = None, coordinates: Optional[Tuple[float, float]] = None, trust_code: str = None)¶ Create a Hospital given its description.
- n_beds:
total number of regular beds in the hospital
- n_icu_beds:
total number of ICU beds in the hospital
- area:
name of the super area the hospital belongs to
- coordinates:
latitude and longitude
-
_collate_from_subgroups
(attribute: str) → List[june.demography.person.Person]¶ Return a set of all of the people in the subgroups with a particular health status
- attribute
The name of the attribute in the subgroup, e.g. “in_hospital”
The union of all the sets with the given attribute name in all of the sub groups.
-
classmethod
_next_id
() → int¶ Iterate an id for this class. Each group class has its own id iterator starting at 0
-
add
(person, subgroup_type=<SubgroupType.workers: 0>)¶ Add a person to a given subgroup. For example, in a school a student is added to the subgroup matching their age.
- person
A person
group_type
-
add_to_icu
(person)¶
-
add_to_ward
(person)¶
-
allocate_patient
(person)¶ Allocate a patient inside the hospital, in the ward, in the ICU, or transfer. To correctly log if the person has been just admitted, transfered, or released, we return a few flags: - “ward_admitted” : this person has been admitted to the ward. - “icu_admitted” : this person has been directly admitted to icu. - “ward_transferred” : this person has been transferred to ward (from icu) - “icu_transferred” : this person has been transferred to icu (from ward) - “no_change” : no change respect to last time step.
-
clear
()¶
-
get_spec
() → str¶ Returns the speciailization of the group.
-
release_patient
(person)¶ Releases patient from hospital.
-
remove_from_icu
(person)¶
-
remove_from_ward
(person)¶
-
remove_person
(person: june.demography.person.Person)¶ Remove a person from this group by removing them from the subgroup to which they belong
- person
A person
-
_abc_impl
= <_abc_data object>¶
-
area
¶
-
property
contains_people
¶ Does this group contain at least one person?
-
coordinates
¶
-
property
dead
¶
-
external
= False¶
-
property
full
¶ Check whether all regular beds are being used
-
property
full_ICU
¶ Check whether all ICU beds are being used
-
property
icu
¶
-
id
¶
-
property
in_hospital
¶
-
property
infected
¶
-
property
must_timestep
¶
-
n_beds
¶
-
n_icu_beds
¶
-
property
name
¶ The name is computed on the fly to reduce memory footprint. It combines the name fo the class with the id of the instance.
-
property
people
¶ All the people in this group
-
property
recovered
¶
-
property
region
¶
-
property
region_name
¶
-
property
size
¶
-
property
size_infected
¶
-
property
size_recovered
¶
-
property
size_susceptible
¶
-
spec
¶
-
subgroups
¶
-
property
super_area
¶
-
property
susceptible
¶
-
trust_code
¶
-
property
ward
¶
-
class
june.groups.hospital.
Hospitals
(hospitals: List[Hospital], neighbour_hospitals: int = 5, box_mode: bool = False, ball_tree=True)¶ Create a group of hospitals, and provide functionality to locate patients to a nearby hospital. It will check in order the first
`neighbour_hospitals`
, when one has space available the patient is allocated to it. If none of the closest ones has beds available it will pick one of them at random and that hospital will overflow- hospitals:
list of hospitals to aggrupate
- neighbour_hospitals:
number of closest hospitals to look for
- box_mode:
whether to run in single box mode, or full simulation
-
__init__
(hospitals: List[Hospital], neighbour_hospitals: int = 5, box_mode: bool = False, ball_tree=True)¶ Create a group of hospitals, and provide functionality to locate patients to a nearby hospital. It will check in order the first
`neighbour_hospitals`
, when one has space available the patient is allocated to it. If none of the closest ones has beds available it will pick one of them at random and that hospital will overflow- hospitals:
list of hospitals to aggrupate
- neighbour_hospitals:
number of closest hospitals to look for
- box_mode:
whether to run in single box mode, or full simulation
-
_make_member_ids_dict
(members)¶ Makes a dictionary with the ids of the members.
-
add
(group)¶
-
clear
()¶
-
classmethod
create_hospital_from_df_row
(area, row)¶
-
classmethod
for_box_mode
()¶
-
classmethod
for_geography
(geography, filename: str = PosixPath('/home/sadie/JUNE/data/input/hospitals/trusts.csv'), config_filename: str = PosixPath('/home/sadie/JUNE/configs/defaults/groups/hospitals.yaml'))¶
-
classmethod
from_file
(filename: str = PosixPath('/home/sadie/JUNE/data/input/hospitals/trusts.csv'), config_filename: str = PosixPath('/home/sadie/JUNE/configs/defaults/groups/hospitals.yaml')) → june.groups.hospital.Hospitals¶ Initialize Hospitals from path to data frame, and path to config file.
- filename:
path to hospital dataframe
- config_filename:
path to hospital config dictionary
Hospitals instance
-
get_closest_hospitals
(coordinates: Tuple[float, float], k: int) → Tuple[float, float]¶ Get the k-th closest hospital to a given coordinate
- coordinates:
latitude and longitude
- k:
k-th neighbour
ID of the k-th closest hospital
-
get_closest_hospitals_idx
(coordinates: Tuple[float, float], k: int) → Tuple[float, float]¶ Get the k-th closest hospital to a given coordinate
- coordinates:
latitude and longitude
- k:
k-th neighbour
ID of the k-th closest hospital
-
get_from_id
(id)¶
-
get_spec
() → str¶ Returns the speciailization of the super group.
-
init_hospitals
(hospital_df: pandas.core.frame.DataFrame) → List[june.groups.hospital.Hospital]¶ Create Hospital objects with the right characteristics, as given by dataframe.
- hospital_df:
dataframe with hospital characteristics data
-
init_trees
(hospital_coordinates: numpy.array) → sklearn.neighbors._ball_tree.BallTree¶ Reads hospital location and sizes, it initializes a KD tree on a sphere, to query the closest hospital to a given location.
- hospital_df:
dataframe with hospital characteristics data
Tree to query nearby schools
-
property
group_spec
¶
-
property
member_ids
¶
-
june.groups.hospital.
random
() → x in the interval [0, 1).¶