Skip to content

Commit e4e3958

Browse files
committed
docs: update header with general information and add code samples with updated clients.
1 parent 430ce6b commit e4e3958

14 files changed

+1144
-288
lines changed

docs/api/client_libraries.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
title: API Clients
3-
parent: Other Endpoints (COVID-19 and Other Diseases)
4-
nav_order: 1
3+
nav_order: 6
54
---
65

76
# Epidata API Clients
@@ -30,7 +29,7 @@ with `install.packages("epidatr")`.
3029
library(epidatr)
3130
data <- pub_covidcast('fb-survey', 'smoothed_cli', 'county', 'day', geo_values = '06001',
3231
time_values = c(20200401, 20200405:20200414))
33-
cat(data)
32+
print(data)
3433
```
3534

3635
### Python

docs/api/covid_hosp.md

Lines changed: 58 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,19 @@ nav_order: 2
66
---
77

88
# COVID-19 Hospitalization by State
9+
{: .no_toc}
910

10-
This data source is a mirror of the "COVID-19 Reported Patient Impact and
11-
Hospital Capacity by State Timeseries" and "COVID-19 Reported Patient Impact and
12-
Hospital Capacity by State" datasets provided by the US Department of
13-
Health & Human Services via healthdata.gov. The latter provides more frequent updates,
14-
so it is combined with the former to create a single dataset which is as recent as possible.
11+
* **Source name:** `covid_hosp_state_timeseries`
12+
* **Data source:** [US Department of Health & Human Services](https://healthdata.gov/Hospital/COVID-19-Reported-Patient-Impact-and-Hospital-Capa/g62h-syeh)
13+
* **Earliest issue available:** 2020-01-01
14+
* **Temporal Resolution:** Daily
15+
* **Spatial Resolution:** US States plus DC, PR, and VI
16+
* **License:** [Public Domain US Government](https://www.usa.gov/government-works)
17+
18+
## Overview
19+
{: .no_toc}
20+
21+
This data source provides various measures of COVID-19 burden on patients and healthcare facilities in the US. It is a mirror of the "COVID-19 Reported Patient Impact and Hospital Capacity by State Timeseries" and "COVID-19 Reported Patient Impact and Hospital Capacity by State" datasets provided by HHS via healthdata.gov. The latter provides more frequent updates, so it is combined with the former to create a single dataset which is as recent as possible.
1522

1623
HHS performs up to four days of forward-fill for missing values in the
1724
[facility-level data](covid_hosp_facility.md) which are aggregated to make this
@@ -34,17 +41,11 @@ General topics not specific to any particular data source are discussed in the
3441
[API overview](README.md). Such topics include:
3542
[contributing](README.md#contributing) and [citing](README.md#citing).
3643

37-
## Metadata
44+
## Table of contents
45+
{: .no_toc .text-delta}
3846

39-
This data source provides various measures of COVID-19 burden on patients and healthcare in the US.
40-
- Data source: US Department of Health & Human Services (HHS) [COVID-19 Reported Patient Impact and
41-
Hospital Capacity by State Timeseries](https://healthdata.gov/Hospital/COVID-19-Reported-Patient-Impact-and-Hospital-Capa/g62h-syeh) (published weekly)
42-
and [COVID-19 Reported Patient Impact and Hospital Capacity by State](https://healthdata.gov/dataset/COVID-19-Reported-Patient-Impact-and-Hospital-Capa/6xf2-c3ie) (published on an irregular schedule, every 1-6 days)
43-
- Temporal Resolution: Daily, starting 2020-01-01
44-
- Spatial Resolution: US States plus DC, PR, and VI
45-
- Open Access: [Public Domain US Government](https://www.usa.gov/government-works)
46-
- Versioned by Delphi according to "issue" date, which is the date that the
47-
dataset was published by HHS.
47+
1. TOC
48+
{:toc}
4849

4950
# The API
5051

@@ -218,12 +219,53 @@ https://api.delphi.cmu.edu/epidata/covid_hosp_state_timeseries/?states=MA&dates=
218219

219220
# Code Samples
220221

221-
Libraries are available for [JavaScript](https://github.com/cmu-delphi/delphi-epidata/blob/main/src/client/delphi_epidata.js), [Python](https://pypi.org/project/delphi-epidata/), and [R](https://github.com/cmu-delphi/delphi-epidata/blob/dev/src/client/delphi_epidata.R).
222+
Libraries are available for [R](https://cmu-delphi.github.io/epidatr/) and [Python](https://cmu-delphi.github.io/epidatpy/).
222223
The following sample shows how to import the library and fetch MA on 2020-05-10
223224
(per most recent issue).
224225

226+
### R
227+
228+
```R
229+
library(epidatr)
230+
# Fetch data
231+
res <- pub_covid_hosp_state_timeseries(states = "MA", dates = 20200510)
232+
print(res)
233+
```
234+
225235
### Python
226236

237+
Install the package using pip:
238+
```bash
239+
pip install -e "git+https://github.com/cmu-delphi/epidatpy.git#egg=epidatpy"
240+
```
241+
242+
```python
243+
# Import
244+
from epidatpy import CovidcastEpidata, EpiDataContext, EpiRange
245+
# Fetch data
246+
epidata = EpiDataContext()
247+
res = epidata.pub_covid_hosp(states="MA", dates=20200510)
248+
print(res)
249+
```
250+
251+
### Legacy Clients
252+
253+
We recommend using our modern client libraries: [epidatr](https://cmu-delphi.github.io/epidatr/) for R and [epidatpy](https://cmu-delphi.github.io/epidatpy/) for Python. Legacy clients are also available for [Python](https://pypi.org/project/delphi-epidata/) and [R](https://github.com/cmu-delphi/delphi-epidata/blob/dev/src/client/delphi_epidata.R).
254+
255+
#### R (Legacy)
256+
257+
Place `delphi_epidata.R` from this repo next to your R script.
258+
259+
```R
260+
source("delphi_epidata.R")
261+
# Fetch data
262+
res <- Epidata$covid_hosp(states = list("MA"), dates = list(20200510))
263+
print(res$message)
264+
print(length(res$epidata))
265+
```
266+
267+
#### Python (Legacy)
268+
227269
Optionally install the package using pip(env):
228270
```bash
229271
pip install delphi-epidata

docs/api/covid_hosp_facility.md

Lines changed: 62 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,19 @@ nav_order: 2
66
---
77

88
# COVID-19 Hospitalization by Facility
9+
{: .no_toc}
910

10-
This data source is a mirror of the "COVID-19 Reported Patient Impact and
11-
Hospital Capacity by Facility" dataset provided by the US Department of Health
12-
& Human Services via healthdata.gov.
11+
* **Source name:** `covid_hosp_facility`
12+
* **Data source:** [US Department of Health & Human Services](https://healthdata.gov/Hospital/COVID-19-Reported-Patient-Impact-and-Hospital-Capa/anag-cw7u)
13+
* **Earliest issue available:** 2020-07-31
14+
* **Geographic resolution:** healthcare facility (address, city, zip, fips)
15+
* **Temporal resolution:** weekly (Friday -- Thursday)
16+
* **License:** [Public Domain US Government](https://www.usa.gov/government-works)
17+
18+
## Overview
19+
{: .no_toc}
20+
21+
This data source provides various measures of COVID-19 burden on patients and healthcare facilities in the US. It is a mirror of the "COVID-19 Reported Patient Impact and Hospital Capacity by Facility" dataset provided by HHS via healthdata.gov.
1322

1423
HHS performs up to four days of forward-fill for missing values.
1524

@@ -26,16 +35,11 @@ General topics not specific to any particular data source are discussed in the
2635
[API overview](README.md). Such topics include:
2736
[contributing](README.md#contributing) and [citing](README.md#citing).
2837

29-
## Metadata
38+
## Table of contents
39+
{: .no_toc .text-delta}
3040

31-
This data source provides various measures of COVID-19 burden on patients and healthcare in the US.
32-
- Data source: [US Department of Health & Human Services](https://healthdata.gov/Hospital/COVID-19-Reported-Patient-Impact-and-Hospital-Capa/anag-cw7u) (HHS)
33-
- Geographic resolution: healthcare facility (address, city, zip, fips)
34-
- Temporal resolution: weekly (Friday -- Thursday)
35-
- First week: 2020-07-31
36-
- Open Access: [Public Domain US Government](https://www.usa.gov/government-works)
37-
- Versioned by Delphi according to the date that the dataset was published by
38-
HHS. New versions are expected to be published roughly weekly.
41+
1. TOC
42+
{:toc}
3943

4044
# The API
4145

@@ -199,24 +203,65 @@ https://api.delphi.cmu.edu/epidata/covid_hosp_facility/?hospital_pks=390119&coll
199203

200204
# Code Samples
201205

202-
Libraries are available for [JavaScript](https://github.com/cmu-delphi/delphi-epidata/blob/main/src/client/delphi_epidata.js), [Python](https://pypi.org/project/delphi-epidata/), and [R](https://github.com/cmu-delphi/delphi-epidata/blob/dev/src/client/delphi_epidata.R).
206+
Libraries are available for [R](https://cmu-delphi.github.io/epidatr/) and [Python](https://cmu-delphi.github.io/epidatpy/).
203207
The following sample shows how to import the library and fetch Moses Taylor
204208
Hospital (Scranton, PA) on the first collection week of December 2020 (per most
205209
recent issue).
206210

211+
### R
212+
213+
```R
214+
library(epidatr)
215+
# Fetch data
216+
res <- pub_covid_hosp_facility(hospital_pks = "390119", collection_weeks = epirange(20201201, 20201207))
217+
print(res)
218+
```
219+
207220
### Python
208221

222+
Install the package using pip:
223+
```bash
224+
pip install -e "git+https://github.com/cmu-delphi/epidatpy.git#egg=epidatpy"
225+
```
226+
227+
```python
228+
# Import
229+
from epidatpy import CovidcastEpidata, EpiDataContext, EpiRange
230+
# Fetch data
231+
epidata = EpiDataContext()
232+
res = epidata.pub_covid_hosp_facility(hospital_pks="390119", collection_weeks=EpiRange(20201201, 20201207))
233+
print(res)
234+
```
235+
236+
### Legacy Clients
237+
238+
We recommend using our modern client libraries: [epidatr](https://cmu-delphi.github.io/epidatr/) for R and [epidatpy](https://cmu-delphi.github.io/epidatpy/) for Python. Legacy clients are also available for [Python](https://pypi.org/project/delphi-epidata/) and [R](https://github.com/cmu-delphi/delphi-epidata/blob/dev/src/client/delphi_epidata.R).
239+
240+
#### R (Legacy)
241+
242+
Place `delphi_epidata.R` from this repo next to your R script.
243+
244+
```R
245+
source("delphi_epidata.R")
246+
# Fetch data
247+
res <- Epidata$covid_hosp_facility(hospital_pks = list("390119"), collection_weeks = list(Epidata$range(20201201, 20201207)))
248+
print(res$message)
249+
print(length(res$epidata))
250+
```
251+
252+
#### Python (Legacy)
253+
209254
Optionally install the package using pip(env):
210-
````bash
255+
```bash
211256
pip install delphi-epidata
212-
````
257+
```
213258

214259
Otherwise, place `delphi_epidata.py` from this repo next to your python script.
215260

216-
````python
261+
```python
217262
# Import
218263
from delphi_epidata import Epidata
219264
# Fetch data
220265
res = Epidata.covid_hosp_facility('390119', Epidata.range(20201201, 20201207))
221266
print(res['result'], res['message'], len(res['epidata']))
222-
````
267+
```

docs/api/covid_hosp_facility_lookup.md

Lines changed: 61 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,19 @@ nav_order: 2
66
---
77

88
# COVID-19 Hospitalization: Facility Lookup
9+
{: .no_toc}
910

10-
This endpoint is a companion to the
11-
[`covid_hosp_facility` endpoint](covid_hosp_facility.md). It provides a way to
12-
find unique identifiers and other metadata for facilities of interest.
11+
* **Source name:** `covid_hosp_facility_lookup`
12+
* **Data source:** [US Department of Health & Human Services](https://healthdata.gov/Hospital/COVID-19-Reported-Patient-Impact-and-Hospital-Capa/anag-cw7u)
13+
* **Total facilities:** 4922
14+
* **License:** [Public Domain US Government](https://www.usa.gov/government-works)
1315

14-
Metadata is derived from the "COVID-19 Reported Patient Impact and Hospital
15-
Capacity by Facility" dataset provided by the US Department of Health & Human
16-
Services via healthdata.gov.
16+
## Overview
17+
{: .no_toc}
18+
19+
This endpoint is a companion to the [`covid_hosp_facility` endpoint](covid_hosp_facility.md). It provides a way to find unique identifiers and other metadata for facilities of interest.
20+
21+
Metadata is derived from the "COVID-19 Reported Patient Impact and Hospital Capacity by Facility" dataset provided by HHS via healthdata.gov.
1722

1823
See the
1924
[official description and data dictionary at healthdata.gov](https://healthdata.gov/Hospital/COVID-19-Reported-Patient-Impact-and-Hospital-Capa/anag-cw7u)
@@ -23,12 +28,11 @@ General topics not specific to any particular data source are discussed in the
2328
[API overview](README.md). Such topics include:
2429
[contributing](README.md#contributing) and [citing](README.md#citing).
2530

26-
## Metadata
31+
## Table of contents
32+
{: .no_toc .text-delta}
2733

28-
This data source provides metadata about healthcare facilities in the US.
29-
- Data source: [US Department of Health & Human Services](https://healthdata.gov/Hospital/COVID-19-Reported-Patient-Impact-and-Hospital-Capa/anag-cw7u) (HHS)
30-
- Total number of facilities: 4922
31-
- Open Access: [Public Domain US Government](https://www.usa.gov/government-works)
34+
1. TOC
35+
{:toc}
3236

3337
# The API
3438

@@ -112,23 +116,64 @@ https://api.delphi.cmu.edu/epidata/covid_hosp_facility_lookup/?city=southlake
112116

113117
# Code Samples
114118

115-
Libraries are available for [JavaScript](https://github.com/cmu-delphi/delphi-epidata/blob/main/src/client/delphi_epidata.js), [Python](https://pypi.org/project/delphi-epidata/), and [R](https://github.com/cmu-delphi/delphi-epidata/blob/dev/src/client/delphi_epidata.R).
119+
Libraries are available for [R](https://cmu-delphi.github.io/epidatr/) and [Python](https://cmu-delphi.github.io/epidatpy/).
116120
The following sample shows how to import the library and fetch facilities in
117121
the city of Southlake (TX).
118122

123+
### R
124+
125+
```R
126+
library(epidatr)
127+
# Fetch data
128+
res <- pub_covid_hosp_facility_lookup(city = "southlake")
129+
print(res)
130+
```
131+
119132
### Python
120133

134+
Install the package using pip:
135+
```bash
136+
pip install -e "git+https://github.com/cmu-delphi/epidatpy.git#egg=epidatpy"
137+
```
138+
139+
```python
140+
# Import
141+
from epidatpy import CovidcastEpidata, EpiDataContext, EpiRange
142+
# Fetch data
143+
epidata = EpiDataContext()
144+
res = epidata.pub_covid_hosp_facility_lookup(city="southlake")
145+
print(res)
146+
```
147+
148+
### Legacy Clients
149+
150+
We recommend using our modern client libraries: [epidatr](https://cmu-delphi.github.io/epidatr/) for R and [epidatpy](https://cmu-delphi.github.io/epidatpy/) for Python. Legacy clients are also available for [Python](https://pypi.org/project/delphi-epidata/) and [R](https://github.com/cmu-delphi/delphi-epidata/blob/dev/src/client/delphi_epidata.R).
151+
152+
#### R (Legacy)
153+
154+
Place `delphi_epidata.R` from this repo next to your R script.
155+
156+
```R
157+
source("delphi_epidata.R")
158+
# Fetch data
159+
res <- Epidata$covid_hosp_facility_lookup(city = "southlake")
160+
print(res$message)
161+
print(length(res$epidata))
162+
```
163+
164+
#### Python (Legacy)
165+
121166
Optionally install the package using pip(env):
122-
````bash
167+
```bash
123168
pip install delphi-epidata
124-
````
169+
```
125170

126171
Otherwise, place `delphi_epidata.py` from this repo next to your python script.
127172

128-
````python
173+
```python
129174
# Import
130175
from delphi_epidata import Epidata
131176
# Fetch data
132177
res = Epidata.covid_hosp_facility_lookup(city='southlake')
133178
print(res['result'], res['message'], len(res['epidata']))
134-
````
179+
```

0 commit comments

Comments
 (0)