Skip to content

Commit 312b71f

Browse files
authored
Merge pull request #1070 from cmu-delphi/release/delphi-epidata-0.4.5
Release Delphi Epidata 0.4.5
2 parents f713e39 + 319e95f commit 312b71f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+856
-866
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.4.4
2+
current_version = 0.4.5
33
commit = False
44
tag = False
55

dev/local/setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = Delphi Development
3-
version = 0.4.4
3+
version = 0.4.5
44

55
[options]
66
packages =

docs/api/covidcast-signals/covid-act-now.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: COVID Act Now
3-
parent: Data Sources and Signals
3+
parent: Inactive Signals
44
grand_parent: COVIDcast Main Endpoint
55
---
66

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
title: Quidel
3+
parent: Inactive Signals
4+
grand_parent: COVIDcast Main Endpoint
5+
---
6+
7+
# Quidel
8+
{: .no_toc}
9+
10+
* **Source name:** `quidel`
11+
12+
## Table of Contents
13+
{: .no_toc .text-delta}
14+
15+
1. TOC
16+
{:toc}
17+
18+
19+
## COVID-19 Tests
20+
These signals are still active. Documentation is available on the [Quidel page](quidel.md).
21+
22+
## Flu Tests
23+
24+
* **Earliest issue available:** April 29, 2020
25+
* **Last issued:** May 19, 2020
26+
* **Number of data revisions since May 19, 2020:** 0
27+
* **Date of last change:** Never
28+
* **Available for:** msa, state (see [geography coding docs](../covidcast_geography.md))
29+
* **Time type:** day (see [date format docs](../covidcast_times.md))
30+
31+
Data source based on flu lab tests, provided to us by Quidel, Inc. When a
32+
patient (whether at a doctor’s office, clinic, or hospital) has COVID-like
33+
symptoms, doctors may perform a flu test to rule out seasonal flu (influenza),
34+
because these two diseases have similar symptoms. Using this lab test data, we
35+
estimate the total number of flu tests per medical device (a measure of testing
36+
frequency), and the percentage of flu tests that are *negative* (since ruling
37+
out flu leaves open another cause---possibly covid---for the patient's
38+
symptoms), in a given location, on a given day.
39+
40+
The number of flu tests conducted in individual counties can be quite small, so
41+
we do not report these signals at the county level.
42+
43+
The flu test data is no longer updated as of May 19, 2020, as the number of flu
44+
tests conducted during the summer (outside of the normal flu season) is quite
45+
small. The data may be updated again when the Winter 2020 flu season begins.
46+
47+
| Signal | Description |
48+
| --- | --- |
49+
| `raw_pct_negative` | The percentage of flu tests that are negative, suggesting the patient's illness has another cause, possibly COVID-19 <br/> **Earliest date available:** 2020-01-31 |
50+
| `smoothed_pct_negative` | Same as above, but smoothed in time <br/> **Earliest date available:** 2020-01-31 |
51+
| `raw_tests_per_device` | The average number of flu tests conducted by each testing device; measures volume of testing <br/> **Earliest date available:** 2020-01-31 |
52+
| `smoothed_tests_per_device` | Same as above, but smoothed in time <br/> **Earliest date available:** 2020-01-31 |

docs/api/covidcast-signals/quidel.md

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -157,34 +157,5 @@ not enough samples can be filled in from the parent state for smoothed signals s
157157
no data is reported for that area on that day; an API query for all reported geographic areas on
158158
that day will not include it.
159159

160-
## Flu Tests
161-
162-
* **Earliest issue available:** April 29, 2020
163-
* **Last issued:** May 19, 2020
164-
* **Number of data revisions since May 19, 2020:** 0
165-
* **Date of last change:** Never
166-
* **Available for:** msa, state (see [geography coding docs](../covidcast_geography.md))
167-
* **Time type:** day (see [date format docs](../covidcast_times.md))
168-
169-
Data source based on flu lab tests, provided to us by Quidel, Inc. When a
170-
patient (whether at a doctor’s office, clinic, or hospital) has COVID-like
171-
symptoms, doctors may perform a flu test to rule out seasonal flu (influenza),
172-
because these two diseases have similar symptoms. Using this lab test data, we
173-
estimate the total number of flu tests per medical device (a measure of testing
174-
frequency), and the percentage of flu tests that are *negative* (since ruling
175-
out flu leaves open another cause---possibly covid---for the patient's
176-
symptoms), in a given location, on a given day.
177-
178-
The number of flu tests conducted in individual counties can be quite small, so
179-
we do not report these signals at the county level.
180-
181-
The flu test data is no longer updated as of May 19, 2020, as the number of flu
182-
tests conducted during the summer (outside of the normal flu season) is quite
183-
small. The data may be updated again when the Winter 2020 flu season begins.
184-
185-
| Signal | Description |
186-
| --- | --- |
187-
| `raw_pct_negative` | The percentage of flu tests that are negative, suggesting the patient's illness has another cause, possibly COVID-19 <br/> **Earliest date available:** 2020-01-31 |
188-
| `smoothed_pct_negative` | Same as above, but smoothed in time <br/> **Earliest date available:** 2020-01-31 |
189-
| `raw_tests_per_device` | The average number of flu tests conducted by each testing device; measures volume of testing <br/> **Earliest date available:** 2020-01-31 |
190-
| `smoothed_tests_per_device` | Same as above, but smoothed in time <br/> **Earliest date available:** 2020-01-31 |
160+
## Flu Tests (inactive)
161+
These signals were updated until May 19, 2020. Documentation is still available on the [inactive Quidel page](quidel-inactive.md).

docs/api/covidcast-signals/safegraph.md

Lines changed: 0 additions & 87 deletions
This file was deleted.

docs/api/covidcast-signals/usa-facts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: USAFacts Cases and Deaths
3-
parent: Data Sources and Signals
3+
parent: Inactive Signals
44
grand_parent: COVIDcast Main Endpoint
55
---
66

integrations/server/test_covidcast.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,18 @@ def _insert_placeholder_set_four(self):
7373
for i in [4, 5, 6]
7474
]
7575
self._insert_rows(rows)
76+
return rows
77+
78+
def _insert_placeholder_set_five(self):
79+
rows = [
80+
self._make_placeholder_row(time_value=2000_01_01, value=i*1., stderr=i*10., sample_size=i*100., issue=2000_01_03+i)[0]
81+
for i in [1, 2, 3]
82+
] + [
83+
# different time_values, same issues
84+
self._make_placeholder_row(time_value=2000_01_01+i-3, value=i*1., stderr=i*10., sample_size=i*100., issue=2000_01_03+i-3)[0]
85+
for i in [4, 5, 6]
86+
]
87+
self._insert_rows(rows)
7688
return rows
7789

7890
def test_round_trip(self):
@@ -237,6 +249,46 @@ def test_location_wildcard(self):
237249
'message': 'success',
238250
})
239251

252+
def test_time_values_wildcard(self):
253+
"""Select all time_values with a wildcard query."""
254+
255+
# insert placeholder data
256+
rows = self._insert_placeholder_set_three()
257+
expected_time_values = [
258+
self.expected_from_row(r) for r in rows[:3]
259+
]
260+
261+
# make the request
262+
response, _ = self.request_based_on_row(rows[0], time_values="*")
263+
264+
self.maxDiff = None
265+
# assert that the right data came back
266+
self.assertEqual(response, {
267+
'result': 1,
268+
'epidata': expected_time_values,
269+
'message': 'success',
270+
})
271+
272+
def test_issues_wildcard(self):
273+
"""Select all issues with a wildcard query."""
274+
275+
# insert placeholder data
276+
rows = self._insert_placeholder_set_five()
277+
expected_issues = [
278+
self.expected_from_row(r) for r in rows[:3]
279+
]
280+
281+
# make the request
282+
response, _ = self.request_based_on_row(rows[0], issues="*")
283+
284+
self.maxDiff = None
285+
# assert that the right data came back
286+
self.assertEqual(response, {
287+
'result': 1,
288+
'epidata': expected_issues,
289+
'message': 'success',
290+
})
291+
240292
def test_signal_wildcard(self):
241293
"""Select all signals with a wildcard query."""
242294

src/acquisition/covid_hosp/common/database.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class Database:
1919
def __init__(self,
2020
connection,
2121
table_name=None,
22+
hhs_dataset_id=None,
2223
columns_and_types=None,
2324
key_columns=None,
2425
additional_fields=None):
@@ -30,6 +31,8 @@ def __init__(self,
3031
An open connection to a database.
3132
table_name : str
3233
The name of the table which holds the dataset.
34+
hhs_dataset_id : str
35+
The 9-character healthdata.gov identifier for this dataset.
3336
columns_and_types : tuple[str, str, Callable]
3437
List of 3-tuples of (CSV header name, SQL column name, data type) for
3538
all the columns in the CSV file.
@@ -40,6 +43,7 @@ def __init__(self,
4043

4144
self.connection = connection
4245
self.table_name = table_name
46+
self.hhs_dataset_id = hhs_dataset_id
4347
self.publication_col_name = "issue" if table_name == 'covid_hosp_state_timeseries' else \
4448
'publication_date'
4549
self.columns_and_types = {
@@ -115,8 +119,8 @@ def contains_revision(self, revision):
115119
FROM
116120
`covid_hosp_meta`
117121
WHERE
118-
`dataset_name` = %s AND `revision_timestamp` = %s
119-
''', (self.table_name, revision))
122+
`hhs_dataset_id` = %s AND `revision_timestamp` = %s
123+
''', (self.hhs_dataset_id, revision))
120124
for (result,) in cursor:
121125
return bool(result)
122126

@@ -138,14 +142,15 @@ def insert_metadata(self, publication_date, revision, meta_json):
138142
INSERT INTO
139143
`covid_hosp_meta` (
140144
`dataset_name`,
145+
`hhs_dataset_id`,
141146
`publication_date`,
142147
`revision_timestamp`,
143148
`metadata_json`,
144149
`acquisition_datetime`
145150
)
146151
VALUES
147-
(%s, %s, %s, %s, NOW())
148-
''', (self.table_name, publication_date, revision, meta_json))
152+
(%s, %s, %s, %s, %s, NOW())
153+
''', (self.table_name, self.hhs_dataset_id, publication_date, revision, meta_json))
149154

150155
def insert_dataset(self, publication_date, dataframe):
151156
"""Add a dataset to the database.
@@ -232,7 +237,7 @@ def get_max_issue(self):
232237
from
233238
`covid_hosp_meta`
234239
WHERE
235-
dataset_name = "{self.table_name}"
240+
hhs_dataset_id = "{self.hhs_dataset_id}"
236241
''')
237242
for (result,) in cursor:
238243
if result is not None:

src/acquisition/covid_hosp/common/utils.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,19 +169,20 @@ def update_dataset(database, network, newer_than=None, older_than=None):
169169
# download the dataset and add it to the database
170170
dataset = Utils.merge_by_key_cols([network.fetch_dataset(url) for url, _ in revisions],
171171
db.KEY_COLS)
172-
# add metadata to the database using the last revision seen.
173-
last_url, last_index = revisions[-1]
174-
metadata_json = metadata.loc[last_index].reset_index().to_json()
172+
# add metadata to the database
173+
all_metadata = []
174+
for url, index in revisions:
175+
all_metadata.append((url, metadata.loc[index].reset_index().to_json()))
175176
datasets.append((
176177
issue_int,
177178
dataset,
178-
last_url,
179-
metadata_json
179+
all_metadata
180180
))
181181
with database.connect() as db:
182-
for issue_int, dataset, last_url, metadata_json in datasets:
182+
for issue_int, dataset, all_metadata in datasets:
183183
db.insert_dataset(issue_int, dataset)
184-
db.insert_metadata(issue_int, last_url, metadata_json)
184+
for url, metadata_json in all_metadata:
185+
db.insert_metadata(issue_int, url, metadata_json)
185186
print(f'successfully acquired {len(dataset)} rows')
186187

187188
# note that the transaction is committed by exiting the `with` block

src/acquisition/covid_hosp/facility/database.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from delphi.epidata.acquisition.covid_hosp.common.database import Database as BaseDatabase
33
from delphi.epidata.acquisition.covid_hosp.common.database import Columndef
44
from delphi.epidata.acquisition.covid_hosp.common.utils import Utils
5+
from delphi.epidata.acquisition.covid_hosp.facility.network import Network
56

67

78
class Database(BaseDatabase):
@@ -213,5 +214,6 @@ def __init__(self, *args, **kwargs):
213214
*args,
214215
**kwargs,
215216
table_name=Database.TABLE_NAME,
217+
hhs_dataset_id=Network.DATASET_ID,
216218
key_columns=Database.KEY_COLS,
217219
columns_and_types=Database.ORDERED_CSV_COLUMNS)

src/acquisition/covid_hosp/state_daily/database.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from delphi.epidata.acquisition.covid_hosp.common.database import Database as BaseDatabase
33
from delphi.epidata.acquisition.covid_hosp.common.database import Columndef
44
from delphi.epidata.acquisition.covid_hosp.common.utils import Utils
5+
from delphi.epidata.acquisition.covid_hosp.state_daily.network import Network
56

67

78
class Database(BaseDatabase):
@@ -223,6 +224,7 @@ def __init__(self, *args, **kwargs):
223224
*args,
224225
**kwargs,
225226
table_name=Database.TABLE_NAME,
227+
hhs_dataset_id=Network.DATASET_ID,
226228
columns_and_types=Database.ORDERED_CSV_COLUMNS,
227229
key_columns=Database.KEY_COLS,
228230
additional_fields=[Columndef('D', 'record_type', None)])

0 commit comments

Comments
 (0)