From bde654095b067d9981eef893ac532f62917a5771 Mon Sep 17 00:00:00 2001 From: george Date: Tue, 7 May 2024 20:19:53 -0400 Subject: [PATCH] =?UTF-8?q?Revert=20"Update=20flusurv=20schema=20and=20doc?= =?UTF-8?q?s=20with=20new=20age,=20sex,=20and=20race=20groups=20(#1?= =?UTF-8?q?=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 9de7d643138f7ef24ea26500c644fbcab1f3827b. --- docs/api/flusurv.md | 50 +++++-------- src/acquisition/flusurv/flusurv_update.py | 39 ++++++++++- src/ddl/fluview.sql | 70 ++++++------------- .../flusurv_age_sex_race_strata.sql | 18 ----- src/server/endpoints/flusurv.py | 23 +----- 5 files changed, 73 insertions(+), 127 deletions(-) delete mode 100644 src/ddl/migrations/flusurv_age_sex_race_strata.sql diff --git a/docs/api/flusurv.md b/docs/api/flusurv.md index 92acd2e5d..b33f5c22d 100644 --- a/docs/api/flusurv.md +++ b/docs/api/flusurv.md @@ -52,40 +52,22 @@ If neither is specified, the current issues are used. ## Response -| Field | Description | Type | -|---|---|---| -| `result` | result code: 1 = success, 2 = too many results, -2 = no results | integer | -| `epidata` | list of results | array of objects | -| `epidata[].release_date` | the date when this record was first published by the CDC | string | -| `epidata[].location` | the name of the catchment (e.g. 'network_all', 'CA', 'NY_albany' | string | -| `epidata[].issue` | the epiweek of publication (e.g. issue 201453 includes epiweeks up to and including 2014w53, but not 2015w01 or following) | integer | -| `epidata[].epiweek` | the epiweek during which the data was collected | integer | -| `epidata[].lag` | number of weeks between `epiweek` and `issue` | integer | -| `epidata[].rate_age_0` | hospitalization rate for ages 0-4 | float | -| `epidata[].rate_age_1` | hospitalization rate for ages 5-17 | float | -| `epidata[].rate_age_2` | hospitalization rate for ages 18-49 | float | -| `epidata[].rate_age_3` | hospitalization rate for ages 50-64 | float | -| `epidata[].rate_age_4` | hospitalization rate for ages 65+ | float | -| `epidata[].rate_overall` | overall hospitalization rate | float | -| `epidata[].rate_age_5` | hospitalization rate for ages 65-74 | float | -| `epidata[].rate_age_6` | hospitalization rate for ages 75-84 | float | -| `epidata[].rate_age_7` | hospitalization rate for ages 85+ | float | -| `epidata[].rate_age_18t29` | hospitalization rate for ages 18 to 29 | float | -| `epidata[].rate_age_30t39` | hospitalization rate for ages 30 to 39 | float | -| `epidata[].rate_age_40t49` | hospitalization rate for ages 40 to 49 | float | -| `epidata[].rate_age_5t11` | hospitalization rate for ages 5 to 11 | float | -| `epidata[].rate_age_12t17` | hospitalization rate for ages 12 to 17 | float | -| `epidata[].rate_age_lt18` | hospitalization rate for ages <18 | float | -| `epidata[].rate_age_gte18` | hospitalization rate for ages >=18 | float | -| `epidata[].rate_race_white` | hospitalization rate for white people | float | -| `epidata[].rate_race_black` | hospitalization rate for black people | float | -| `epidata[].rate_race_hisp` | hospitalization rate for Hispanic/Latino people | float | -| `epidata[].rate_race_asian` | hospitalization rate for Asian people | float | -| `epidata[].rate_race_natamer` | hospitalization rate for American Indian/Alaskan Native people | float | -| `epidata[].rate_sex_male` | hospitalization rate for males | float | -| `epidata[].rate_sex_female` | hospitalization rate for females | float | -| `epidata[].season` | indicates the start and end years of the winter flu season in the format YYYY-YY (e.g. 2022-23 indicates the flu season running late 2022 through early 2023) | string | -| `message` | `success` or error message | string | +| Field | Description | Type | +|--------------------------|-----------------------------------------------------------------|------------------| +| `result` | result code: 1 = success, 2 = too many results, -2 = no results | integer | +| `epidata` | list of results | array of objects | +| `epidata[].release_date` | | string | +| `epidata[].location` | | string | +| `epidata[].issue` | | integer | +| `epidata[].epiweek` | | integer | +| `epidata[].lag` | | integer | +| `epidata[].rate_age_0` | | float | +| `epidata[].rate_age_1` | | float | +| `epidata[].rate_age_2` | | float | +| `epidata[].rate_age_3` | | float | +| `epidata[].rate_age_4` | | float | +| `epidata[].rate_overall` | | float | +| `message` | `success` or error message | string | Notes: * The `flusurv` age groups are, in general, not the same as the ILINet diff --git a/src/acquisition/flusurv/flusurv_update.py b/src/acquisition/flusurv/flusurv_update.py index 39e963646..b0073be4c 100644 --- a/src/acquisition/flusurv/flusurv_update.py +++ b/src/acquisition/flusurv/flusurv_update.py @@ -19,9 +19,42 @@ === Data Dictionary === ======================= -`flusurv` is the table where US flu hospitalization rates are stored. See -`strc/ddl/fluview.sql` for the `flusurv` schema. See `docs/api/flusurv.md` for -field descriptions. +`flusurv` is the table where US flu hospitalization rates are stored. ++--------------+-------------+------+-----+---------+----------------+ +| Field | Type | Null | Key | Default | Extra | ++--------------+-------------+------+-----+---------+----------------+ +| id | int(11) | NO | PRI | NULL | auto_increment | +| release_date | date | NO | MUL | NULL | | +| issue | int(11) | NO | MUL | NULL | | +| epiweek | int(11) | NO | MUL | NULL | | +| location | varchar(32) | NO | MUL | NULL | | +| lag | int(11) | NO | MUL | NULL | | +| rate_age_0 | double | YES | | NULL | | +| rate_age_1 | double | YES | | NULL | | +| rate_age_2 | double | YES | | NULL | | +| rate_age_3 | double | YES | | NULL | | +| rate_age_4 | double | YES | | NULL | | +| rate_overall | double | YES | | NULL | | +| rate_age_5 | double | YES | | NULL | | +| rate_age_6 | double | YES | | NULL | | +| rate_age_7 | double | YES | | NULL | | ++--------------+-------------+------+-----+---------+----------------+ +id: unique identifier for each record +release_date: the date when this record was first published by the CDC +issue: the epiweek of publication (e.g. issue 201453 includes epiweeks up to + and including 2014w53, but not 2015w01 or following) +epiweek: the epiweek during which the data was collected +location: the name of the catchment (e.g. 'network_all', 'CA', 'NY_albany') +lag: number of weeks between `epiweek` and `issue` +rate_age_0: hospitalization rate for ages 0-4 +rate_age_1: hospitalization rate for ages 5-17 +rate_age_2: hospitalization rate for ages 18-49 +rate_age_3: hospitalization rate for ages 50-64 +rate_age_4: hospitalization rate for ages 65+ +rate_overall: overall hospitalization rate +rate_age_5: hospitalization rate for ages 65-74 +rate_age_6: hospitalization rate for ages 75-84 +rate_age_7: hospitalization rate for ages 85+ ================= === Changelog === diff --git a/src/ddl/fluview.sql b/src/ddl/fluview.sql index adcddc66e..11f10c9dc 100644 --- a/src/ddl/fluview.sql +++ b/src/ddl/fluview.sql @@ -329,7 +329,7 @@ CREATE TABLE `fluview_public` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /* -`flusurv` stores FluSurv-NET data (flu hospitalization rates) as published by +`flusurv` stores FluSurv-NET data (flu hospitaliation rates) as published by CDC. Data is public. @@ -345,40 +345,25 @@ Note that the flusurv age groups are, in general, not the same as the ILINet particular "catchment" (e.g. 'network_all', 'CA', 'NY_albany') rather than by regions and states in general. -+-------------------+-------------+------+-----+---------+----------------+ -| Field | Type | Null | Key | Default | Extra | -+-------------------+-------------+------+-----+---------+----------------+ -| id | int(11) | NO | PRI | NULL | auto_increment | -| release_date | date | NO | MUL | NULL | | -| issue | int(11) | NO | MUL | NULL | | -| epiweek | int(11) | NO | MUL | NULL | | -| location | varchar(32) | NO | MUL | NULL | | -| lag | int(11) | NO | MUL | NULL | | -| rate_age_0 | double | YES | | NULL | | -| rate_age_1 | double | YES | | NULL | | -| rate_age_2 | double | YES | | NULL | | -| rate_age_3 | double | YES | | NULL | | -| rate_age_4 | double | YES | | NULL | | -| rate_overall | double | YES | | NULL | | -| rate_age_5 | double | YES | | NULL | | -| rate_age_6 | double | YES | | NULL | | -| rate_age_7 | double | YES | | NULL | | -| rate_age_18t29 | double | YES | | NULL | | -| rate_age_30t39 | double | YES | | NULL | | -| rate_age_40t49 | double | YES | | NULL | | -| rate_age_5t11 | double | YES | | NULL | | -| rate_age_12t17 | double | YES | | NULL | | -| rate_age_lt18 | double | YES | | NULL | | -| rate_age_gte18 | double | YES | | NULL | | -| rate_race_white | double | YES | | NULL | | -| rate_race_black | double | YES | | NULL | | -| rate_race_hisp | double | YES | | NULL | | -| rate_race_asian | double | YES | | NULL | | -| rate_race_natamer | double | YES | | NULL | | -| rate_sex_male | double | YES | | NULL | | -| rate_sex_female | double | YES | | NULL | | -| season | char(7) | YES | | NULL | | -+-------------------+-------------+------+-----+---------+----------------+ ++--------------+-------------+------+-----+---------+----------------+ +| Field | Type | Null | Key | Default | Extra | ++--------------+-------------+------+-----+---------+----------------+ +| id | int(11) | NO | PRI | NULL | auto_increment | +| release_date | date | NO | MUL | NULL | | +| issue | int(11) | NO | MUL | NULL | | +| epiweek | int(11) | NO | MUL | NULL | | +| location | varchar(32) | NO | MUL | NULL | | +| lag | int(11) | NO | MUL | NULL | | +| rate_age_0 | double | YES | | NULL | | +| rate_age_1 | double | YES | | NULL | | +| rate_age_2 | double | YES | | NULL | | +| rate_age_3 | double | YES | | NULL | | +| rate_age_4 | double | YES | | NULL | | +| rate_overall | double | YES | | NULL | | +| rate_age_5 | double | YES | | NULL | | +| rate_age_6 | double | YES | | NULL | | +| rate_age_7 | double | YES | | NULL | | ++--------------+-------------+------+-----+---------+----------------+ */ CREATE TABLE `flusurv` ( @@ -397,21 +382,6 @@ CREATE TABLE `flusurv` ( `rate_age_5` double DEFAULT NULL, `rate_age_6` double DEFAULT NULL, `rate_age_7` double DEFAULT NULL, - `rate_age_18t29` double DEFAULT NULL, - `rate_age_30t39` double DEFAULT NULL, - `rate_age_40t49` double DEFAULT NULL, - `rate_age_5t11` double DEFAULT NULL, - `rate_age_12t17` double DEFAULT NULL, - `rate_age_lt18` double DEFAULT NULL, - `rate_age_gte18` double DEFAULT NULL, - `rate_race_white` double DEFAULT NULL, - `rate_race_black` double DEFAULT NULL, - `rate_race_hisp` double DEFAULT NULL, - `rate_race_asian` double DEFAULT NULL, - `rate_race_natamer` double DEFAULT NULL, - `rate_sex_male` double DEFAULT NULL, - `rate_sex_female` double DEFAULT NULL, - `season` char(7) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `issue` (`issue`,`epiweek`,`location`), KEY `release_date` (`release_date`), diff --git a/src/ddl/migrations/flusurv_age_sex_race_strata.sql b/src/ddl/migrations/flusurv_age_sex_race_strata.sql deleted file mode 100644 index b6717e8b0..000000000 --- a/src/ddl/migrations/flusurv_age_sex_race_strata.sql +++ /dev/null @@ -1,18 +0,0 @@ --- Add new age, race, and sex strata, and season descriptor (YYYY-YY format) -ALTER TABLE `flusurv` ADD ( - `rate_age_18t29` double DEFAULT NULL, - `rate_age_30t39` double DEFAULT NULL, - `rate_age_40t49` double DEFAULT NULL, - `rate_age_5t11` double DEFAULT NULL, - `rate_age_12t17` double DEFAULT NULL, - `rate_age_lt18` double DEFAULT NULL, - `rate_age_gte18` double DEFAULT NULL, - `rate_race_white` double DEFAULT NULL, - `rate_race_black` double DEFAULT NULL, - `rate_race_hisp` double DEFAULT NULL, - `rate_race_asian` double DEFAULT NULL, - `rate_race_natamer` double DEFAULT NULL, - `rate_sex_male` double DEFAULT NULL, - `rate_sex_female` double DEFAULT NULL, - `season` char(7) DEFAULT NULL, -); diff --git a/src/server/endpoints/flusurv.py b/src/server/endpoints/flusurv.py index 1feea4834..08b2a14d9 100644 --- a/src/server/endpoints/flusurv.py +++ b/src/server/endpoints/flusurv.py @@ -19,7 +19,7 @@ def handle(): # basic query info q = QueryBuilder("flusurv", "fs") - fields_string = ["release_date", "location", "season"] + fields_string = ["release_date", "location"] fields_int = ["issue", "epiweek", "lag"] fields_float = [ "rate_age_0", @@ -28,27 +28,6 @@ def handle(): "rate_age_3", "rate_age_4", "rate_overall", - - "rate_age_5", - "rate_age_6", - "rate_age_7", - - "rate_age_18t29", - "rate_age_30t39", - "rate_age_40t49", - "rate_age_5t11", - "rate_age_12t17", - "rate_age_lt18", - "rate_age_gte18", - - "rate_race_white", - "rate_race_black", - "rate_race_hisp", - "rate_race_asian", - "rate_race_natamer", - - "rate_sex_male", - "rate_sex_female", ] q.set_fields(fields_string, fields_int, fields_float) q.set_sort_order("epiweek", "location", "issue")