Skip to content

Commit

Permalink
Frontend: Adds chr gun deaths behind flag (#3914)
Browse files Browse the repository at this point in the history
# Description and Motivation
<!--- bulleted, high level items. use keywords (eg "closes #144" or
"fixes #4323") -->

- adds feature flag
- conditionally adds "Gun Deaths" as new dropdown topic
- adds handling for gun deaths from CHR to AHR provider (maybe should be
gun violence? Maybe we should rethink the provider structure overall)


## Has this been tested? How?

e2e tests still passing. manually confirmed only working with flag
enabled on county-level data

## Screenshots (if appropriate)


![image](https://github.com/user-attachments/assets/3523411e-54c5-4ef5-bd08-5dbc3a48067b)


![image](https://github.com/user-attachments/assets/6c6489cb-bc09-4bf0-b54c-b4226ffb8fd5)


## Types of changes

(leave all that apply)

- New content or feature

## New frontend preview link is below in the Netlify comment 😎
  • Loading branch information
benhammondmusic authored Jan 24, 2025
1 parent 610cae6 commit 3e393fd
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 5 deletions.
1 change: 1 addition & 0 deletions frontend/.env.deploy_preview
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ VITE_SHOW_NEW_MATERNAL_MORTALITY=1
VITE_SHOW_CANCER_SCREENINGS=1
VITE_SHOW_CORRELATION_CARD=1
VITE_SHOW_INSIGHT_GENERATION=1
VITE_SHOW_CHR_GUN_DEATHS=1
1 change: 1 addition & 0 deletions frontend/.env.staging
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ VITE_SHOW_CANCER_SCREENINGS=1
VITE_SHOW_NEW_MATERNAL_MORTALITY=1
VITE_SHOW_CORRELATION_CARD=1
VITE_SHOW_INSIGHT_GENERATION=1
VITE_SHOW_CHR_GUN_DEATHS=1
7 changes: 5 additions & 2 deletions frontend/src/data/config/MetadataMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,11 @@ export const dataSourceMetadataMap: Record<DataSourceId, DataSourceMetadata> = {
demographic_granularity: 'Race/ethnicity (partial)',
update_frequency: 'Annual',
description:
'The prevalence of multiple conditions at the county level, including chronic disease (diabetes), behavioral health indicators (suicide, frequent mental distress, excessive drinking), and other determinants of health (preventable hospitalizations).',
dataset_ids: ['chr_data-race_and_ethnicity_county_current'],
'The prevalence of multiple conditions at the county level, including chronic disease (diabetes), behavioral health indicators (suicide, frequent mental distress, excessive drinking), community safety (gun deaths), and other determinants of health (preventable hospitalizations).',
dataset_ids: [
'chr_data-race_and_ethnicity_county_current',
'chr_data-race_and_ethnicity_county_historical',
],
downloadable: true,
time_period_range: null,
},
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/data/config/MetricConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
} from './MetricConfigChronicDisease'
import {
GUN_DEATHS_BLACK_MEN_METRICS,
GUN_DEATH_METRICS,
GUN_VIOLENCE_METRICS,
GUN_VIOLENCE_YOUTH_METRICS,
} from './MetricConfigCommunitySafety'
Expand Down Expand Up @@ -70,6 +71,7 @@ export const METRIC_CONFIG: Record<DropdownVarId, DataTypeConfig[]> = {
frequent_mental_distress: FREQUENT_MENTAL_DISTRESS_METRICS,
gun_violence: GUN_VIOLENCE_METRICS,
gun_violence_youth: GUN_VIOLENCE_YOUTH_METRICS,
gun_deaths: GUN_DEATH_METRICS,
gun_deaths_black_men: GUN_DEATHS_BLACK_MEN_METRICS,
substance: SUBSTANCE_MISUSE_METRICS,
suicide: SUICIDE_METRICS,
Expand Down
37 changes: 37 additions & 0 deletions frontend/src/data/config/MetricConfigCommunitySafety.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ import {
} from './MetricConfigUtils'

export const COMMUNITY_SAFETY_DROPDOWNIDS = [
'gun_deaths',
'gun_deaths_black_men',
'gun_violence',
'gun_violence_youth',
] as const

export const COMMUNITY_SAFETY_DROPDOWNIDS_NO_CHR = [
'gun_deaths_black_men',
'gun_violence',
'gun_violence_youth',
Expand Down Expand Up @@ -52,6 +59,7 @@ export type CommunitySafetyMetricId =
| 'gun_homicides_black_men_per_100k'
| 'gun_homicides_black_men_population_estimated_total'
| 'gun_homicides_black_men_population_pct'
| 'gun_deaths_per_100k'

export const GUN_VIOLENCE_METRICS: DataTypeConfig[] = [
{
Expand Down Expand Up @@ -174,6 +182,35 @@ export const GUN_VIOLENCE_METRICS: DataTypeConfig[] = [
},
]

export const GUN_DEATH_METRICS: DataTypeConfig[] = [
{
categoryId: 'community-safety',
dataTableTitle: 'Summary for gun deaths',
dataTypeId: 'gun_deaths',
dataTypeShortLabel: 'Gun Deaths',
definition: {
text: 'Deaths resulting from firearms.',
},
description: {
text: '',
},
fullDisplayName: 'Gun deaths',
fullDisplayNameInline: 'gun deaths',
mapConfig: defaultHigherIsWorseMapConfig,
metrics: {
per100k: {
timeSeriesCadence: 'yearly',
chartTitle: 'Rates of gun deaths',
columnTitleHeader: 'Gun deaths per 100k people',
metricId: 'gun_deaths_per_100k',
shortLabel: 'deaths per 100k',
trendsCardTitleName: 'Rates of gun deaths over time',
type: 'per100k',
},
},
},
]

export const GUN_VIOLENCE_YOUTH_METRICS: DataTypeConfig[] = [
{
categoryId: 'community-safety',
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/data/config/MetricConfigPhrma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { DataTypeConfig } from './MetricConfigTypes'
export const MEDICARE_CATEGORY_HIV_AND_CVD_DROPDOWNIDS = [
'medicare_cardiovascular',
'medicare_hiv',
]
] as const

export const MEDICARE_CATEGORY_DROPDOWNIDS = [
'medicare_cardiovascular',
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/data/providers/AhrProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const CHR_DATATYPE_IDS_ONLY_ALLS: DataTypeId[] = [
const CHR_DATATYPE_IDS_BY_RACE: DataTypeId[] = [
'preventable_hospitalizations',
'suicide',
'gun_deaths',
]

export const CHR_DATATYPE_IDS: DataTypeId[] = [
Expand Down Expand Up @@ -112,6 +113,7 @@ const CHR_METRICS: MetricId[] = [
'excessive_drinking_per_100k',
'frequent_mental_distress_per_100k',
'preventable_hospitalizations_per_100k',
'gun_deaths_per_100k',
]

export const AHR_DATATYPES_WITH_MISSING_AGE_DEMO: DataTypeId[] = [
Expand All @@ -135,6 +137,7 @@ class AhrProvider extends VariableProvider {
...AHR_METRICS,
...AHR_VOTER_AGE_METRICS,
...AHR_DECADE_PLUS_5_AGE_METRICS,
...CHR_METRICS,
])
}

Expand Down
13 changes: 11 additions & 2 deletions frontend/src/utils/MadLibs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { METRIC_CONFIG } from '../data/config/MetricConfig'
import { BEHAVIORAL_HEALTH_CATEGORY_DROPDOWNIDS } from '../data/config/MetricConfigBehavioralHealth'
import { CDC_CANCER_CATEGORY_DROPDOWNIDS } from '../data/config/MetricConfigCancer'
import { CHRONIC_DISEASE_CATEGORY_DROPDOWNIDS } from '../data/config/MetricConfigChronicDisease'
import { COMMUNITY_SAFETY_DROPDOWNIDS } from '../data/config/MetricConfigCommunitySafety'
import {
COMMUNITY_SAFETY_DROPDOWNIDS,
COMMUNITY_SAFETY_DROPDOWNIDS_NO_CHR,
} from '../data/config/MetricConfigCommunitySafety'
import { COVID_CATEGORY_DROPDOWNIDS } from '../data/config/MetricConfigCovidCategory'
import { HIV_CATEGORY_DROPDOWNIDS } from '../data/config/MetricConfigHivCategory'
import { MATERNAL_HEALTH_CATEGORY_DROPDOWNIDS } from '../data/config/MetricConfigMaternalHealth'
Expand All @@ -18,12 +21,15 @@ import type {
DataTypeConfig,
DataTypeId,
} from '../data/config/MetricConfigTypes'

import { SHOW_NEW_MATERNAL_MORTALITY } from '../data/providers/MaternalMortalityProvider'
import { SHOW_CANCER_SCREENINGS } from '../data/providers/PhrmaBrfssProvider'
import { SHOW_PHRMA_MENTAL_HEALTH } from '../data/providers/PhrmaProvider'
import { GEORGIA_FIPS, USA_FIPS } from '../data/utils/ConstantsGeography'
import { FIPS_MAP } from '../data/utils/FipsData'

const SHOW_CHR_GUN_DEATHS = import.meta.env.VITE_SHOW_CHR_GUN_DEATHS

// Map of phrase segment index to its selected value
export type PhraseSelections = Record<number, string>

Expand Down Expand Up @@ -151,6 +157,7 @@ export const DROPDOWN_TOPIC_MAP: Record<
diabetes: 'Diabetes',
excessive_drinking: 'Excessive Drinking',
frequent_mental_distress: 'Frequent Mental Distress',
gun_deaths: 'Gun Deaths',
gun_violence: 'Gun Homicides and Suicides',
gun_violence_youth: 'Gun Deaths (Youth)',
gun_deaths_black_men: 'Gun Homicides (Black Men)',
Expand Down Expand Up @@ -230,7 +237,9 @@ const CATEGORIES_LIST: Category[] = [
{
title: 'Community Safety',
definition: '',
options: COMMUNITY_SAFETY_DROPDOWNIDS as unknown as DropdownVarId[],
options: SHOW_CHR_GUN_DEATHS
? (COMMUNITY_SAFETY_DROPDOWNIDS as unknown as DropdownVarId[])
: (COMMUNITY_SAFETY_DROPDOWNIDS_NO_CHR as unknown as DropdownVarId[]),
},
{
title: 'Medication Utilization in the Medicare Population',
Expand Down

0 comments on commit 3e393fd

Please sign in to comment.