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

Adiciona ocupação de UTIs #133

Open
wants to merge 1 commit into
base: stable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/loader/endpoints.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@
python_file: get_cities_rt
skip: False

- endpoint: br/states/beds_occupation
python_file: get_states_beds_occupation
skip: False

- endpoint: br/health_region/farolcovid/main
python_file: get_health_region_farolcovid_main
skip: False
Expand Down
90 changes: 9 additions & 81 deletions src/loader/endpoints/get_cities_farolcovid_main.py
Original file line number Diff line number Diff line change
@@ -1,96 +1,26 @@
import pandas as pd
import numpy as np
import datetime as dt
import yaml

from endpoints import (
get_cities_cases,
get_cities_rt,
get_health_region_rt,
get_cnes,
get_health_region_farolcovid_main,
)

from endpoints.get_health_region_farolcovid_main import (
get_situation_indicators,
get_control_indicators,
get_capacity_indicators,
get_trust_indicators,
get_overall_alert,
)

from endpoints import get_cities_cases, get_cities_rt, get_health_region_rt
from endpoints.get_indicators import get_place_indicators
from endpoints.helpers import allow_local


@allow_local
def now(config):

# Get resource data
df = (
get_cnes.now(config)[
[
"country_iso",
"country_name",
"state_num_id",
"state_id",
"state_name",
"health_region_id",
"health_region_name",
"city_name",
"city_id",
"last_updated_number_beds",
"author_number_beds",
"last_updated_number_icu_beds",
"author_number_icu_beds",
"population",
]
]
.sort_values("city_id")
.set_index("city_id")
)

df = get_situation_indicators(
df,
data=get_cities_cases.now(config),
place_id="city_id",
rules=config["br"]["farolcovid"]["rules"],
classify="situation_classification",
)
data_cases = get_cities_cases.now(config)
data_rt = get_cities_rt.now(config)
data_rt_region = get_health_region_rt.now(config)

df = get_control_indicators(
df,
data=get_cities_rt.now(config),
return get_place_indicators(
place_id="city_id",
rules=config["br"]["farolcovid"]["rules"],
classify="control_classification",
data_cases=data_cases,
data_rt=data_rt,
data_rt_region=data_rt_region,
config=config,
region_data=get_health_region_farolcovid_main.now(config),
)

df = get_trust_indicators(
df,
data=get_cities_cases.now(config),
place_id="city_id",
rules=config["br"]["farolcovid"]["rules"],
classify="trust_classification",
)

df = get_capacity_indicators(
df,
place_id="city_id",
config=config,
rules=config["br"]["farolcovid"]["rules"],
classify="capacity_classification",
data=get_health_region_farolcovid_main.now(config),
)

cols = [col for col in df.columns if "classification" in col]
df["overall_alert"] = df.apply(
lambda row: get_overall_alert(row[cols]), axis=1
) # .replace(config["br"]["farolcovid"]["categories"])

return df.reset_index()


TESTS = {
"doesnt have 5570 cities": lambda df: len(df["city_id"].unique()) == 5570,
Expand Down Expand Up @@ -122,7 +52,6 @@ def now(config):
]
.isnull()
.apply(lambda x: any(x), axis=1)
== True
),
"city without classification got an alert": lambda df: all(
df[
Expand All @@ -137,6 +66,5 @@ def now(config):
.isnull()
.any(axis=1)
]["overall_alert"].isnull()
== True
),
}
Loading