Skip to content

Commit bf9c61f

Browse files
authored
Add support for the 'fluview_clinical' API endpoint (#119)
1 parent c287203 commit bf9c61f

File tree

5 files changed

+77
-0
lines changed

5 files changed

+77
-0
lines changed

src/api/EpiData.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,35 @@ export function importFluView({
437437
});
438438
}
439439

440+
export function importFluViewClinical({
441+
regions,
442+
issues,
443+
lag,
444+
}: {
445+
regions: string;
446+
issues?: number | null;
447+
lag?: number | null;
448+
}): Promise<DataGroup | null> {
449+
const regionLabel = fluViewRegions.find((d) => d.value === regions)?.label ?? '?';
450+
const title = appendIssueToTitle(`[API] FluView Clinical: ${regionLabel}`, { issues, lag });
451+
return loadDataSet(
452+
title,
453+
'fluview_clinical',
454+
{
455+
epiweeks: epiRange(firstEpiWeek.fluview, currentEpiWeek),
456+
},
457+
{ regions, issues, lag },
458+
['total_specimens', 'total_a', 'total_b', 'percent_positive', 'percent_a', 'percent_b'],
459+
).then((ds) => {
460+
// get inside the Promise and make sure its not null,
461+
// then enable display of 'percent_positive' data
462+
if (ds instanceof DataGroup) {
463+
ds.defaultEnabled = ['percent_positive'];
464+
}
465+
return ds;
466+
});
467+
}
468+
440469
export function importGFT({ locations }: { locations: string }): Promise<DataGroup | null> {
441470
const regionLabel = gftLocations.find((d) => d.value === locations)?.label ?? '?';
442471
const title = `[API] GFT: ${regionLabel}`;

src/components/dialogs/ImportAPIDialog.svelte

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script lang="ts">
22
import FluSurv from './dataSources/FluSurv.svelte';
33
import FluView from './dataSources/FluView.svelte';
4+
import FluViewClinical from './dataSources/FluViewClinical.svelte';
45
56
import { createEventDispatcher } from 'svelte';
67
@@ -81,6 +82,17 @@
8182
>cmu-delphi.github.io</a
8283
>)</label
8384
>
85+
<label
86+
><input
87+
class="uk-radio"
88+
type="radio"
89+
name="dataSource"
90+
bind:group={$formSelections.dataSource}
91+
value="fluview_clinical"
92+
/>
93+
FluView Clinical (source:
94+
<a target="_blank" href="https://gis.cdc.gov/grasp/fluview/fluportaldashboard.html">cdc.gov</a>)
95+
</label>
8496
<label
8597
><input
8698
class="uk-radio"
@@ -200,6 +212,8 @@
200212

201213
{#if $formSelections.dataSource === 'fluview'}
202214
<FluView {id} bind:this={handler} />
215+
{:else if $formSelections.dataSource === 'fluview_clinical'}
216+
<FluViewClinical {id} bind:this={handler} />
203217
{:else if $formSelections.dataSource === 'flusurv'}
204218
<FluSurv {id} bind:this={handler} />
205219
{:else if $formSelections.dataSource === 'gft'}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<script lang="ts">
2+
import { importFluViewClinical } from '../../../api/EpiData';
3+
import { fluViewRegions } from '../../../data/data';
4+
import SelectField from '../inputs/SelectField.svelte';
5+
import SelectIssue from '../inputs/SelectIssue.svelte';
6+
import { formSelections } from '../../../store';
7+
8+
export let id: string;
9+
10+
export function importDataSet() {
11+
return importFluViewClinical({
12+
regions: $formSelections.fluViewClinical.locations,
13+
...$formSelections.fluViewClinical.issue,
14+
});
15+
}
16+
</script>
17+
18+
<SelectField
19+
id="{id}-r"
20+
label="Region"
21+
bind:value={$formSelections.fluViewClinical.locations}
22+
options={fluViewRegions}
23+
/>
24+
<SelectIssue {id} bind:value={$formSelections.fluViewClinical.issue} />

src/components/dialogs/formSelections.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ export class FluViewSelections {
4444
issue = DEFAULT_ISSUE;
4545
}
4646

47+
export class FluViewClinicalSelections {
48+
locations = fluViewRegions[0].value;
49+
issue = DEFAULT_ISSUE;
50+
}
51+
4752
export class GftSelections {
4853
locations = gftLocations[0].value;
4954
}
@@ -93,6 +98,7 @@ export class WikiSelections {
9398
export default class FormSelections {
9499
dataSource:
95100
| 'fluview'
101+
| 'fluview_clinical'
96102
| 'flusurv'
97103
| 'gft'
98104
| 'ght'
@@ -111,6 +117,7 @@ export default class FormSelections {
111117
covidHosp = new CovidHospSelections();
112118
fluSurv = new FluSurvSelections();
113119
fluView = new FluViewSelections();
120+
fluViewClinical = new FluViewClinicalSelections();
114121
gft = new GftSelections();
115122
ght = new GhtSelections();
116123
nidssDengue = new NidssDengueSelections();

src/deriveLinkDefaults.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
importCOVIDcast,
55
importFluSurv,
66
importFluView,
7+
importFluViewClinical,
78
importGFT,
89
importGHT,
910
importNIDSSDengue,
@@ -54,6 +55,7 @@ const lookups = {
5455
covidcast: importCOVIDcast,
5556
flusurv: importFluSurv,
5657
fluview: importFluView,
58+
fluview_clinical: importFluViewClinical,
5759
gft: importGFT,
5860
ght: importGHT,
5961
nidss_dengue: importNIDSSDengue,
@@ -73,6 +75,7 @@ const argOrders: Record<string, string[]> = {
7375
covid_hosp: ['states', 'issues'],
7476
flusurv: ['locations', 'issues', 'lag'],
7577
fluview: ['regions', 'issues', 'lag', 'auth'],
78+
fluview_clinical: ['regions', 'issues', 'lag'],
7679
gft: ['locations'],
7780
ght: ['auth', 'locations', 'query'],
7881
nidss_dengue: ['locations'],

0 commit comments

Comments
 (0)