Skip to content

Commit

Permalink
Merge pull request #3 from HYLODE/reversion
Browse files Browse the repository at this point in the history
Creating a minimum viable version of the sitrep dashboard
  • Loading branch information
harryjmoss authored Jan 26, 2024
2 parents eda34ae + 3ac3ee6 commit bcf476e
Show file tree
Hide file tree
Showing 121 changed files with 135 additions and 13,851 deletions.
3 changes: 0 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ API_BASEROW_USERNAME=hyui
# Current hycastle and hymind on GAE08 5207/5208 respectively
API_HYCASTLE_URL=http://hycastle:1234
API_HYMIND_URL=http://hymind:1234
API_TOWERMAIL_URL=http://towermail:1234
API_ELECTIVES_TAP_URL=http://somehost:1234
API_EMERGENCY_TAP_URL=http://somehost:1234
# Hylode-Bot : slack API hook
API_SLACK_LOG_WEBHOOK=https://hooks.slack.com/services/foo/bar/baz

Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -926,9 +926,6 @@ docs/_linkcheck/
# Docker cruft
.bash_history

# ignore generated data
src/api/perrt/admission_probability/generated_data

# local jupyter lab for exploratory work
jupyter/

Expand Down
4 changes: 4 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,7 @@ repos:
name: detect-secrets - Detect secrets in staged code
args: [ "--baseline", ".secrets.baseline" ]
exclude: .*/tests/.*|^\.cruft\.json|.env.example$
- repo: https://github.com/pappasam/toml-sort
rev: v0.23.1
hooks:
- id: toml-sort-fix
46 changes: 23 additions & 23 deletions api/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,36 @@ build-backend = "setuptools.build_meta"
name = "hyui-api"
version = "0.0.1"
dependencies = [
"loguru == 0.6.0",
"notifiers == 1.3.3",
"hyui-models",
"arrow == 1.2.3",
"fastapi[all] == 0.85.0",
"fastapi-utils==0.2.1",
"pandas == 1.5.1",
"pyodbc == 4.0.35",
"psycopg2-binary == 2.9.5",
"pydantic == 1.10.2",
"SQLAlchemy == 1.4.41",
"sqlmodel == 0.0.8",
"uvicorn[standard] == 0.18.3",
"scikit-learn == 1.1.3",
"imbalanced-learn == 0.10.1",
"category-encoders == 2.6.0",
"xgboost == 1.5.0",
"loguru == 0.6.0",
"notifiers == 1.3.3",
"hyui-models",
"arrow == 1.2.3",
"fastapi[all] == 0.99.1",
"fastapi-utils==0.2.1",
"pandas == 1.5.1",
"pyodbc == 4.0.35",
"psycopg2-binary == 2.9.5",
"pydantic >=1.10.2,<2.0",
"SQLAlchemy == 1.4.41",
"sqlmodel == 0.0.8",
"uvicorn[standard] == 0.18.3",
"scikit-learn == 1.1.3",
"imbalanced-learn == 0.10.1",
"category-encoders == 2.6.0",
"xgboost == 1.5.0"
]

[project.optional-dependencies]
test = [
"pre-commit == 2.20.0",
"pytest == 7.1.3"
"pre-commit == 2.20.0",
"pytest == 7.1.3"
]

[tool.setuptools.package-data]
"*" = ["*.sql", "*.json", "*.db"]

[tool.pytest.ini_options]
minversion = "7.1.3"
testpaths = [
"src/api/tests"
"src/api/tests"
]

[tool.setuptools.package-data]
"*" = ["*.sql", "*.json", "*.db"]
39 changes: 30 additions & 9 deletions api/src/api/census/wrangle.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import numpy as np
import pandas as pd
import warnings

Expand Down Expand Up @@ -49,10 +50,15 @@ def _aggregate_by_department(df: pd.DataFrame) -> pd.DataFrame:
# source
# placeholder: need to subtract closed from empties
# res["opens"] = res["empties"]

# Calculate days since last discharge, but handle NaT values in wards by allowing
# the quantity to be a float rather than integer
res["days_since_last_dc"] = (
(res["modified_at"] - res["days_since_last_dc"]).dt.floor("d").dt.days
)
# Convert remaining NaT values to -999, then convert the Series dtype to int
res["days_since_last_dc"] = (
(res["modified_at"] - res["days_since_last_dc"])
.apply(lambda x: pd.Timedelta.floor(x, "d"))
.dt.days
res["days_since_last_dc"].replace(np.nan, -999.0).astype(int)
)

# use days since last dc and there being no patients to define if a ward
Expand All @@ -65,12 +71,27 @@ def _aggregate_by_department(df: pd.DataFrame) -> pd.DataFrame:
]
).T.all(axis="columns")

res["closed_perm"] = pd.DataFrame(
[
res["days_since_last_dc"] > 30,
res["patients"] == 0,
]
).T.all(axis="columns")
def _closed_perm_conditions(row: pd.Series) -> bool:
"""Calculate permanent closure conditions.
Handles NaT values of days_since_last_dc, which are
converted to -999.
Args:
row (pd.Series): Pandas DataFrame row
Returns:
bool: Is the ward permanently closed?
"""
if row["days_since_last_dc"] > 30 and row["patients"] == 0:
closed = True
elif row["days_since_last_dc"] < 0:
closed = True
else:
closed = False
return closed

res["closed_perm"] = res.apply(_closed_perm_conditions, axis=1)

# drop closed perm
# mask = ~res["closed_perm"]
Expand Down
5 changes: 0 additions & 5 deletions api/src/api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ class Settings(BaseSettings):
baserow_username: str

hycastle_url: AnyHttpUrl
hymind_url: AnyHttpUrl
towermail_url: AnyHttpUrl

electives_tap_url: AnyHttpUrl
emergency_tap_url: AnyHttpUrl

echo_sql: bool = False

Expand Down
12 changes: 0 additions & 12 deletions api/src/api/consults/__init__.py

This file was deleted.

91 changes: 0 additions & 91 deletions api/src/api/consults/live.sql

This file was deleted.

Binary file removed api/src/api/consults/mock.h5
Binary file not shown.
7 changes: 0 additions & 7 deletions api/src/api/consults/mock.sql

This file was deleted.

16 changes: 0 additions & 16 deletions api/src/api/consults/readme.md

This file was deleted.

25 changes: 0 additions & 25 deletions api/src/api/consults/router.py

This file was deleted.

Loading

0 comments on commit bcf476e

Please sign in to comment.