Skip to content

Commit 5bd05ee

Browse files
authored
Merge pull request #1024 from cmu-delphi/release/delphi-epidata-0.4.1
Release Delphi Epidata 0.4.1
2 parents 67c2226 + 800b7f6 commit 5bd05ee

19 files changed

+239
-113
lines changed

.bumpversion.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.4.0
2+
current_version = 0.4.1
33
commit = False
44
tag = False
55

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ You should now have the following directory structure:
2626
│ ├── .dockerignore -> repos/delphi/delphi-epidata/dev/local/.dockerignore
2727
│ ├── Makefile -> repos/delphi/delphi-epidata/dev/local/Makefile
2828
│ ├── repos
29+
│ │ ├── pyproject.toml -> delphi/delphi-epidata/dev/local/pyproject.toml
30+
│ │ ├── setup.cfg -> delphi/delphi-epidata/dev/local/setup.cfg
2931
│ │ └── delphi
3032
│ │ ├── delphi-epidata
3133
│ │ ├── flu-contest
@@ -52,6 +54,16 @@ $ [sudo] make test pdb=1
5254
$ [sudo] make test test=repos/delphi/delphi-epidata/integrations/acquisition
5355
```
5456

57+
Enabling features like code autocompletion and linting in your editor
58+
requires one extra step (prerequisites: up-to-date pip and setuptools v64+):
59+
60+
```sh
61+
$ cd repos
62+
63+
# Installs the working directory as an "editable package"
64+
$ pip install -e . --config-settings editable_mode=strict
65+
```
66+
5567
# COVIDcast
5668

5769
At the present, our primary focus is developing and expanding the

dev/local/install.sh

+8-1
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@
22
# Bootstrap delphi-epidata development
33
#
44
# Downloads the repos needed for local delphi-epidata development into current dir
5-
# and provides a Makefile with Docker control commands.
5+
# and provides a Makefile with Docker control commands
6+
# as well as pyproject/setup.cfg files for IDE mappings.
67
#
78
# Creates the directory structure:
89
#
910
# driver/
1011
# .dockerignore
1112
# Makefile
1213
# repos/
14+
# pyproject.toml
15+
# setup.cfg
1316
# delphi/
1417
# operations/
1518
# delphi-epidata/
@@ -43,3 +46,7 @@ cd ../../
4346

4447
ln -s repos/delphi/delphi-epidata/dev/local/Makefile
4548
ln -s repos/delphi/delphi-epidata/dev/local/.dockerignore
49+
cd repos
50+
ln -s delphi/delphi-epidata/dev/local/pyproject.toml
51+
ln -s delphi/delphi-epidata/dev/local/setup.cfg
52+
cd -

dev/local/pyproject.toml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["setuptools>=65", "wheel"]
3+
build-backend = "setuptools.build_meta"

dev/local/setup.cfg

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
[metadata]
2+
name = Delphi Development
3+
version = 0.4.0
4+
5+
[options]
6+
packages =
7+
delphi.epidata
8+
delphi.epidata.acquisition
9+
delphi.epidata.acquisition.afhsb
10+
delphi.epidata.acquisition.cdcp
11+
delphi.epidata.acquisition.covid_hosp
12+
delphi.epidata.acquisition.covid_hosp.common
13+
delphi.epidata.acquisition.covid_hosp.facility
14+
delphi.epidata.acquisition.covid_hosp.state_daily
15+
delphi.epidata.acquisition.covid_hosp.state_timeseries
16+
delphi.epidata.acquisition.covidcast
17+
delphi.epidata.acquisition.covidcast_nowcast
18+
delphi.epidata.acquisition.ecdc
19+
delphi.epidata.acquisition.flusurv
20+
delphi.epidata.acquisition.fluview
21+
delphi.epidata.acquisition.ght
22+
delphi.epidata.acquisition.kcdc
23+
delphi.epidata.acquisition.nidss
24+
delphi.epidata.acquisition.norostat
25+
delphi.epidata.acquisition.paho
26+
delphi.epidata.acquisition.quidel
27+
delphi.epidata.acquisition.twtr
28+
delphi.epidata.acquisition.wiki
29+
delphi.epidata.client
30+
delphi.epidata.server
31+
delphi.epidata.server.covidcast_issues_migration
32+
delphi.epidata.server.endpoints
33+
delphi.epidata.server.endpoints.covidcast_utils
34+
delphi.epidata.server.utils
35+
delphi.flu_contest
36+
delphi.flu_contest
37+
delphi.flu_contest.archefilter
38+
delphi.flu_contest.covid
39+
delphi.flu_contest.epicast
40+
delphi.flu_contest.forecasters
41+
delphi.flu_contest.hosp
42+
delphi.flu_contest.main
43+
delphi.flu_contest.uploads
44+
delphi.flu_contest.utils
45+
delphi.github_deploy_repo
46+
delphi.github_deploy_repo.actions
47+
delphi.nowcast
48+
delphi.nowcast.experiments
49+
delphi.nowcast.fusion
50+
delphi.nowcast.obsolete
51+
delphi.nowcast.sensors
52+
delphi.nowcast.util
53+
delphi.operations
54+
delphi.operations.database_metrics
55+
delphi.operations.screenshots
56+
delphi.operations.screenshots.covidcast
57+
delphi.utils
58+
delphi.utils.geo
59+
delphi.utils.obsolete
60+
undefx.py3tester
61+
undefx.undef_analysis
62+
63+
package_dir =
64+
delphi.epidata = delphi/delphi-epidata/src
65+
delphi.flu_contest = delphi/flu-contest/src
66+
delphi.github_deploy_repo = delphi/github-deploy-repo/src
67+
delphi.nowcast = delphi/nowcast/src
68+
delphi.operations = delphi/operations/src
69+
delphi.utils = delphi/utils/src
70+
undefx.py3tester = undefx/py3tester/src
71+
undefx.undef_analysis = undefx/undef-analysis

docs/api/covid_hosp.md

+23-6
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,22 @@ Hospital Capacity by State" datasets provided by the US Department of
1111
Health & Human Services via healthdata.gov. The latter provides more frequent updates,
1212
so it is combined with the former to create a single dataset which is as recent as possible.
1313

14+
HHS performs up to four days of forward-fill for missing values in the
15+
[facility-level data](covid_hosp_facility.md) which are aggregated to make this
16+
state-level dataset. This sometimes results in repeated values in the state-level data.
17+
A sequence of two repeated values is extremely common, and longer sequences are rare.
18+
Repeated values added in this way are sometimes updated if the underlying missing data can
19+
be completed at a later date.
20+
21+
Starting October 1, 2022, some facilities are only required to report annually.
22+
1423
For more information, see the
1524
[official description and data dictionary at healthdata.gov](https://healthdata.gov/Hospital/COVID-19-Reported-Patient-Impact-and-Hospital-Capa/g62h-syeh)
1625
for "COVID-19 Reported Patient Impact and Hospital Capacity by State Timeseries,"
1726
as well as the [official description](https://healthdata.gov/dataset/COVID-19-Reported-Patient-Impact-and-Hospital-Capa/6xf2-c3ie)
18-
for "COVID-19 Reported Patient Impact and Hospital Capacity by State."
27+
for "COVID-19 Reported Patient Impact and Hospital Capacity by State." The data elements,
28+
cadence, and how the data are being used in the federal response are documented in
29+
[a FAQ published by Health & Human Services](https://www.hhs.gov/sites/default/files/covid-19-faqs-hospitals-hospital-laboratory-acute-care-facility-data-reporting.pdf).
1930

2031
General topics not specific to any particular data source are discussed in the
2132
[API overview](README.md). Such topics include:
@@ -65,7 +76,7 @@ If `issues` is not specified, then the most recent issue is used by default.
6576
| `epidata[].state` | state pertaining to this row | string |
6677
| `epidata[].date` | date pertaining to this row | integer |
6778
| `epidata[].issue` | the date on which the dataset containing this row was published | integer |
68-
| `epidata[].*` | see the [data dictionary](https://healthdata.gov/covid-19-reported-patient-impact-and-hospital-capacity-state-data-dictionary) | |
79+
| `epidata[].*` | see the [data dictionary](https://healthdata.gov/Hospital/COVID-19-Reported-Patient-Impact-and-Hospital-Capa/g62h-syeh). Last synced: 2021-10-21 | |
6980
| `message` | `success` or error message | string |
7081

7182
# Example URLs
@@ -149,25 +160,31 @@ The following sample shows how to import the library and fetch MA on 2020-05-10
149160
### Python
150161

151162
Optionally install the package using pip(env):
152-
````bash
163+
```bash
153164
pip install delphi-epidata
154-
````
165+
```
155166

156167
Otherwise, place `delphi_epidata.py` from this repo next to your python script.
157168

158-
````python
169+
```python
159170
# Import
160171
from delphi_epidata import Epidata
161172
# Fetch data
162173
res = Epidata.covid_hosp('MA', 20200510)
163174
print(res['result'], res['message'], len(res['epidata']))
164-
````
175+
```
165176

166177
# Repair Log
167178

168179
If we ever need to repair the data record due to a bug in our code (not at the
169180
source), we will update the list below.
170181

182+
## October 21, 2021
183+
184+
All issues between 20210430 and 20211021 were re-uploaded to include new columns added by
185+
HHS. If you pulled these issues before October 21, the data you received was correct, but
186+
was missing the added columns.
187+
171188
## January 22, 2021
172189

173190
The following issues were repaired:

docs/api/covid_hosp_facility.md

+9-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,16 @@ This data source is a mirror of the "COVID-19 Reported Patient Impact and
99
Hospital Capacity by Facility" dataset provided by the US Department of Health
1010
& Human Services via healthdata.gov.
1111

12+
HHS performs up to four days of forward-fill for missing values.
13+
14+
Starting October 1, 2022, some facilities are only required to report annually.
15+
1216
See the
1317
[official description and data dictionary at healthdata.gov](https://healthdata.gov/Hospital/COVID-19-Reported-Patient-Impact-and-Hospital-Capa/anag-cw7u)
14-
for more information.
18+
for more information. The data elements, cadence, and how the data are being used in the
19+
federal response are documented in
20+
[a FAQ published by Health & Human Services](https://www.hhs.gov/sites/default/files/covid-19-faqs-hospitals-hospital-laboratory-acute-care-facility-data-reporting.pdf).
21+
1522

1623
General topics not specific to any particular data source are discussed in the
1724
[API overview](README.md). Such topics include:
@@ -74,7 +81,7 @@ has been renamed here for clarity.
7481
| `epidata[].hospital_pk` | facility identified by this row | string |
7582
| `epidata[].collection_week` | Friday's date in the week pertaining to this row | integer |
7683
| `epidata[].publication_date` | the date on which the dataset containing this row was published | integer |
77-
| `epidata[].*` | see the [data dictionary](https://healthdata.gov/covid-19-reported-patient-impact-and-hospital-capacity-facility-data-dictionary) | |
84+
| `epidata[].*` | see the [data dictionary](https://healthdata.gov/Hospital/COVID-19-Reported-Patient-Impact-and-Hospital-Capa/anag-cw7u) | |
7885
| `message` | `success` or error message | string |
7986

8087
# Example URLs

docs/api/covid_hosp_facility_lookup.md

+13-2
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,21 @@ supported.
5454
| --- | --- | --- |
5555
| `result` | result code: 1 = success, 2 = too many results, -2 = no results | integer |
5656
| `epidata` | list of results | array of objects |
57-
| `epidata[].hospital_pk` | facility identified by this row | string |
58-
| `epidata[].*` | see the [data dictionary](https://healthdata.gov/covid-19-reported-patient-impact-and-hospital-capacity-facility-data-dictionary) | |
57+
| `epidata[].hospital_pk` | unique identifier for this facility (will match CCN if CCN exists) | string |
58+
| `epidata[].state` | two-letter state code | string |
59+
| `epidata[].ccn` | CMS Certification Number for this facility | string |
60+
| `epidata[].hospital_name` | facility name | string |
61+
| `epidata[].address` | facility address | string |
62+
| `epidata[].city` | facility city | string |
63+
| `epidata[].zip` | 5-digit ZIP code | string |
64+
| `epidata[].hospital_subtype` | one of: Childrens Hospitals, Critical Access Hospitals, Long Term, Psychiatric, Rehabilitation, Short Term | string |
65+
| `epidata[].fips_code` | 5-digit FIPS county code | string |
66+
| `epidata[].is_metro_micro` | 1 if this facility serves a metropolitan or micropolitan area, 0 otherwise | integer |
5967
| `message` | `success` or error message | string |
6068

69+
Use the `hospital_pk` value when querying
70+
[the COVID-19 Reported Patient Impact and Hospital Capacity by Facility endpoint](covid_hosp_facility.md).
71+
6172
# Example URLs
6273

6374
### Lookup facilities in the city of Southlake (TX)

src/client/delphi_epidata.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Epidata <- (function() {
1515
# API base url
1616
BASE_URL <- 'https://delphi.cmu.edu/epidata/api.php'
1717

18-
client_version <- '0.4.0'
18+
client_version <- '0.4.1'
1919

2020
# Helper function to cast values and/or ranges to strings
2121
.listitem <- function(value) {

src/client/delphi_epidata.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
}
2323
})(this, function (exports, fetchImpl, jQuery) {
2424
const BASE_URL = "https://delphi.cmu.edu/epidata/";
25-
const client_version = "0.4.0";
25+
const client_version = "0.4.1";
2626

2727
// Helper function to cast values and/or ranges to strings
2828
function _listitem(value) {

src/client/packaging/npm/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "delphi_epidata",
33
"description": "Delphi Epidata API Client",
44
"authors": "Delphi Group",
5-
"version": "0.4.0",
5+
"version": "0.4.1",
66
"license": "MIT",
77
"homepage": "https://github.com/cmu-delphi/delphi-epidata",
88
"bugs": {
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
from .delphi_epidata import Epidata
22

33
name = 'delphi_epidata'
4-
__version__ = '0.4.0'
4+
__version__ = '0.4.1'

src/client/packaging/pypi/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="delphi_epidata",
8-
version="0.4.0",
8+
version="0.4.1",
99
author="David Farrow",
1010
author_email="[email protected]",
1111
description="A programmatic interface to Delphi's Epidata API.",

src/server/_config.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
load_dotenv()
77

8-
VERSION = "0.4.0"
8+
VERSION = "0.4.1"
99

1010
MAX_RESULTS = int(10e6)
1111
MAX_COMPATIBILITY_RESULTS = int(3650)

src/server/_query.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from ._exceptions import DatabaseErrorException
2323
from ._validate import DateRange, extract_strings
2424
from ._params import GeoPair, SourceSignalPair, TimePair
25-
from .utils import dates_to_ranges
25+
from .utils import time_values_to_ranges, days_to_ranges, weeks_to_ranges
2626

2727

2828
def date_string(value: int) -> str:
@@ -90,7 +90,7 @@ def filter_dates(
9090
param_key: str,
9191
params: Dict[str, Any],
9292
):
93-
ranges = dates_to_ranges(values)
93+
ranges = time_values_to_ranges(values)
9494
return filter_values(field, ranges, param_key, params, date_string)
9595

9696

@@ -187,7 +187,7 @@ def filter_pair(pair: TimePair, i) -> str:
187187
params[type_param] = pair.time_type
188188
if isinstance(pair.time_values, bool) and pair.time_values:
189189
return f"{type_field} = :{type_param}"
190-
ranges = dates_to_ranges(pair.time_values)
190+
ranges = weeks_to_ranges(pair.time_values) if pair.is_week else days_to_ranges(pair.time_values)
191191
return f"({type_field} = :{type_param} AND {filter_integers(time_field, cast(Sequence[Union[int, Tuple[int,int]]], ranges), type_param, params)})"
192192

193193
parts = [filter_pair(p, i) for i, p in enumerate(values)]

src/server/utils/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from .dates import shift_time_value, date_to_time_value, time_value_to_iso, time_value_to_date, days_in_range, weeks_in_range, shift_week_value, week_to_time_value, week_value_to_week, guess_time_value_is_day, dates_to_ranges
1+
from .dates import shift_time_value, date_to_time_value, time_value_to_iso, time_value_to_date, days_in_range, weeks_in_range, shift_week_value, week_to_time_value, week_value_to_week, guess_time_value_is_day, time_values_to_ranges, days_to_ranges, weeks_to_ranges

0 commit comments

Comments
 (0)