Hospital
AbstractHospital
Hospital functionality common for all hospitals (internal to the domain and external).
Source code in june/groups/hospital.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
|
__init__()
Initialise the hospital with a disease configuration.
Parameters
disease_config : DiseaseConfig Configuration object for the disease.
Source code in june/groups/hospital.py
34 35 36 37 38 39 40 41 42 43 44 |
|
add_to_icu(person)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
person
|
|
required |
Source code in june/groups/hospital.py
66 67 68 69 70 71 72 73 74 |
|
add_to_ward(person)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
person
|
|
required |
Source code in june/groups/hospital.py
46 47 48 49 50 51 52 53 54 |
|
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, transferred, 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.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
person
|
|
required |
Source code in june/groups/hospital.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
|
release_patient(person)
Releases patient from hospital.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
person
|
|
required |
Source code in june/groups/hospital.py
140 141 142 143 144 145 146 147 148 149 150 151 152 |
|
remove_from_icu(person)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
person
|
|
required |
Source code in june/groups/hospital.py
76 77 78 79 80 81 82 83 84 |
|
remove_from_ward(person)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
person
|
|
required |
Source code in june/groups/hospital.py
56 57 58 59 60 61 62 63 64 |
|
ExternalHospital
Bases: ExternalGroup
, AbstractHospital
, MedicalFacility
Source code in june/groups/hospital.py
484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 |
|
SubgroupType
Bases: IntEnum
Source code in june/groups/hospital.py
489 490 491 492 493 |
|
Hospital
Bases: Group
, AbstractHospital
, MedicalFacility
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
Source code in june/groups/hospital.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 |
|
full
property
Check whether all regular beds are being used
full_ICU
property
Check whether all ICU beds are being used
icu
property
region
property
region_name
property
super_area
property
ward
property
__init__(n_beds, n_icu_beds, area=None, coordinates=None, trust_code=None)
Create a Hospital given its description.
Parameters
n_beds: int Total number of regular beds in the hospital. n_icu_beds: int Total number of ICU beds in the hospital. disease_config: DiseaseConfig Configuration object for the disease. area: str, optional Name of the super area the hospital belongs to. coordinates: tuple of float, optional Latitude and longitude. trust_code: str, optional Trust code associated with the hospital.
Source code in june/groups/hospital.py
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
|
add(person, subgroup_type)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
person
|
|
required | |
subgroup_type
|
|
required |
Source code in june/groups/hospital.py
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
|
Hospitals
Bases: Supergroup
, MedicalFacilities
Source code in june/groups/hospital.py
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 |
|
__init__(hospitals, neighbour_hospitals=5, 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
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hospitals
|
List[Hospital]
|
list of hospitals to aggrupate |
required |
neighbour_hospitals
|
int
|
number of closest hospitals to look for. Default is 5. |
5
|
ball_tree
|
bool
|
If true initialise a tree. Default is True. |
True
|
Source code in june/groups/hospital.py
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 |
|
create_hospital_from_df_row(area, row)
classmethod
Create a hospital from a row in the hospital dataframe.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
area
|
Area
|
The area object associated with the hospital. |
required |
row
|
Series
|
The row from the hospital dataframe. |
required |
Returns:
Name | Type | Description |
---|---|---|
Hospital |
A newly created Hospital instance. |
Source code in june/groups/hospital.py
381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 |
|
for_geography(geography, filename=default_data_filename, config_filename=default_config_filename)
classmethod
Create hospitals for the given geography based on input files and disease configuration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
geography
|
Geography
|
The geography object containing areas. |
required |
filename
|
str
|
Path to the file containing hospital data. (Default value = default_data_filename) |
default_data_filename
|
config_filename
|
str
|
Path to the configuration file. (Default value = default_config_filename) |
default_config_filename
|
Returns:
Name | Type | Description |
---|---|---|
cls |
An instance of the Hospitals class. |
Source code in june/groups/hospital.py
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 |
|
from_file(filename=default_data_filename, config_filename=default_config_filename)
classmethod
Initialise Hospitals from path to data frame, and path to config file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename
|
str
|
path to hospital dataframe (Default value = default_data_filename) |
default_data_filename
|
config_filename
|
str
|
path to hospital config dictionary (Default value = default_config_filename) |
default_config_filename
|
Source code in june/groups/hospital.py
292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 |
|
get_closest_hospitals(coordinates, k)
OUTDATED DOCUMENTATION? Get the k-th closest hospital to a given coordinate
Parameters:
Name | Type | Description | Default |
---|---|---|---|
coordinates
|
Tuple[float, float]
|
latitude and longitude |
required |
k
|
int
|
k-th neighbour |
required |
Source code in june/groups/hospital.py
466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 |
|
get_closest_hospitals_idx(coordinates, k)
OUTDATED DOCUMENTATION? Get the k-th closest hospital to a given coordinate
Parameters:
Name | Type | Description | Default |
---|---|---|---|
coordinates
|
Tuple[float, float]
|
latitude and longitude |
required |
k
|
int
|
k-th neighbour |
required |
Source code in june/groups/hospital.py
449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 |
|
init_hospitals(hospital_df)
Create Hospital objects with the right characteristics, as given by dataframe.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hospital_df
|
DataFrame
|
dataframe with hospital characteristics data |
required |
Returns:
Type | Description |
---|---|
List[Hospital]
|
List["Hospital"]: list of hospital objects |
Source code in june/groups/hospital.py
408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 |
|
init_trees(hospital_coordinates)
Reads hospital location and sizes, it initialises a KD tree on a sphere, to query the closest hospital to a given location.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hospital_coordinates
|
array
|
|
required |
Returns:
Name | Type | Description |
---|---|---|
BallTree |
BallTree
|
Tree to query nearby schools |
Source code in june/groups/hospital.py
434 435 436 437 438 439 440 441 442 443 444 445 446 447 |
|
MedicalFacilities
Source code in june/groups/hospital.py
26 27 28 |
|
MedicalFacility
Source code in june/groups/hospital.py
21 22 23 |
|