---
# System prepended metadata

title: COVID "Score" Proposal

---

# COVID "Score" Proposal

This is a proposal to calculate a COVID score for a user's itinerary or a destination associated with a user's itinerary

### Objectives

* Get a sense for the rate of change of the COVID "situation" in a given state over some interval of time
* Take into account the population of a state (e.g. N cases in NY implies a different situation than N cases in Wyoming)
* Calculate a high level score and return that as a response to the Web backend/API layer triggered by an inbound HTTP request to the DS API
* Enable flexible changes to the score calculation without the need for updating code

### Primary COVID Attribute/Data Element

* Key off of the `new_case` CDC/SODA data element to calculate the score
* Fetch the given state's COVID date from `14` days ago (2 weeks ago) and from `1` day ago (yesterday)
    * Use environment variables for the time interval (e.g. `INT_START` and `INT_END`)
    * Use environment variables for low and high score values (e.g. `THRESHOLD_LOW`, `THRESHOLD_HIGH`)

### Calculation Methodology

1. Execute an outbound request from the DS backend/API to the CDC/SODA API
1. Grab the `new_case` values at the start of the interval and end of the interval
1. Calculate `new_case_per_million` (or per capita?)start and end values by dividing each value by the state's population (stored statically locally or in a database)
1. Generate the `new_case_rate_pct_diff` by dividing the difference between `new_case_per_million_end` and `new_case_per_million_start` by `new_case_per_million_start`
1. Generate a score value (e.g 0/Green, 1/Yellow, 2/Red):
    * **0/Green**: `new_case_rate_pct_diff < threshold_low` e.g. threshold_low = -.02 (-2%)
    * **1/Yellow**: `threshold_low < new_case_rate_pct_diff < threshold_high` e.g. threshold_high = .02 (2%)
    * **2/Red**: `new_case_rate_pct_diff > threshold_high`

### Inbound Request Parameters (Query Parameter)

* `state`

### Outbound Response Parameters (JSON document)
* `covid_score`: (0, 1, 2)
* `covid_data`: pass on the end interval covid API data (the web backend can use this or ignore it)

### Tasks

[ ] Review notes with team

### Issues

* What do we do if there is no data for the start and/or end dates?
* What type of visualization should we send back to the web API world?
    * Send back contiguous states?
    * Send back a live map of all 50 states?
    * Update the disclaimer with additional language

### Nice to Haves

* Precalcuate scores for each state every day (e.g. cron like task that executes daily)
* Define a route where an authorized caller can update configuration values on the fly:
    * `INT_START`
    * `INT_END`
    * `THRESHOLD_LOW`
    * `THRESHOLD_HIGH`
    * maybe the COVID API data element name (e.g. use new_death instead of new_case)

### Other

$newCasesRatePctDiff = (newCasesPerMillionEnd - newCasesPerMillionStart) / newCasesPerMillionStart$

or

$newCasesRatePctDiff = (newCasesPerCapitaEnd - newCasesPerCapitaStart) / newCasesPerCapitaStart$
