Skip to content

Commit

Permalink
Made Hospital Admissions sensor work as Doctor Visits and Deaths. Rem…
Browse files Browse the repository at this point in the history
…oved annotation for Hosptal Admissions sensor when we don't have recent data for choosen date
  • Loading branch information
dmytrotsko committed Mar 1, 2024
1 parent 63d23f2 commit 510332f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 37 deletions.
10 changes: 4 additions & 6 deletions src/blocks/NoRecentDataWarning.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script>
import { formatAPITime } from '../data';
import { formatDateYearDayOfWeekAbbr } from '../formats';
/**
* @type {import("../stores/params").DateParam}
Expand Down Expand Up @@ -35,11 +34,10 @@
{#if casesMaxDate.toString() != date.value.toString() || deathSensorMaxDate.toString() != date.value.toString() || hospitalAdmissionMaxDate.toString() != date.value.toString()}
<div data-uk-alert class="uk-alert-warning">
<p>
The data for the {formatDateYearDayOfWeekAbbr(todaysDate)} is not available yet. The latest known data for all indicators
is available on
<a href="?date={formatAPITime(minMaxDate.value)}&{window.location.search.split('&').slice(1).join('&')}"
>{formatDateYearDayOfWeekAbbr(minMaxDate)}</a
>.
The data for the {formatDateYearDayOfWeekAbbr(todaysDate)} is not yet available. The date is set to the most recent
date we have data for all 3 indicators which is {formatDateYearDayOfWeekAbbr(minMaxDate)}. <br /> You can check the
hints to see the latest available date for each indicator. Note that the latest available date may be different for
each indicator.
</p>
</div>
{/if}
36 changes: 5 additions & 31 deletions src/modes/summary/Overview.svelte
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
<script>
import KPIValue from '../../components/KPIValue.svelte';
import KPIChange from '../../components/KPIChange.svelte';
import { DateParam, SensorParam } from '../../stores/params';
import { SensorParam } from '../../stores/params';
import SensorUnit from '../../components/SensorUnit.svelte';
import IndicatorAnnotations from '../../components/IndicatorAnnotations.svelte';
import MaxDateHint from '../../blocks/MaxDateHint.svelte';
import IndicatorWarning from '../../blocks/IndicatorWarning.svelte';
import NoRecentDataWarning from '../../blocks/NoRecentDataWarning.svelte';
import { defaultDeathSensor, defaultCasesSensor, defaultHospitalSensor, metaDataManager } from '../../stores';
import IndicatorFallbackWarning from '../../blocks/IndicatorFallbackWarning.svelte';
import { onMount, afterUpdate, beforeUpdate } from 'svelte';
/**
Expand All @@ -28,25 +25,16 @@
$: DEATHS = new SensorParam($defaultDeathSensor, $metaDataManager);
$: HOSPITAL_ADMISSION = new SensorParam($defaultHospitalSensor, $metaDataManager);
function fetchFallback(fetcher, sensor, region, trend) {
return trend.then((t) => {
if (t && t.value != null) {
return t;
}
return fetcher.fetch1Sensor1Region1DateTrend(sensor, region, DateParam.box(sensor.timeFrame.max));
});
}
$: trends = fetcher.fetchNSensors1Region1DateTrend([CASES, HOSPITAL_ADMISSION, DEATHS], region, date);
$: casesTrend = trends[0];
$: hospitalTrend = fetchFallback(fetcher, HOSPITAL_ADMISSION, region, trends[1]);
$: hospitalTrend = trends[1];
$: deathTrend = trends[2];
let minMaxDate = new Date();
let showWarning = false;
onMount(() => {
[CASES, DEATHS, HOSPITAL_ADMISSION].map((s) => {
[CASES, HOSPITAL_ADMISSION].map((s) => {
if (s.timeFrame.max < minMaxDate) {
minMaxDate = s.timeFrame.max;
}
Expand All @@ -70,9 +58,6 @@
});
</script>

<IndicatorWarning sensor={CASES} {date} {region} {fetcher} />
<IndicatorAnnotations {date} {region} sensor={CASES} range="sparkLine" />

{#if showWarning}
<NoRecentDataWarning
casesSensor={CASES}
Expand All @@ -83,12 +68,6 @@
/>
{/if}

<!-- <p>
On {formatDateDayOfWeek(date.value)}
<MaxDateHint sensor={CASES.value} suffix="," {fetcher} />
the {CASES.valueUnit}s were:
</p> -->

<div class="mobile-three-col">
<div class="mobile-kpi">
<h3>
Expand All @@ -115,7 +94,7 @@
{#await hospitalTrend}
<KPIValue value={null} loading />
{:then d}
<KPIValue value={d ? d.value : null} asterisk={d != null && (d.value == null || d.date < date.value)} />
<KPIValue value={d ? d.value : null} />
{/await}
</div>
<div class="sub">
Expand Down Expand Up @@ -158,10 +137,7 @@
{#await hospitalTrend}
<KPIChange value={null} loading />
{:then d}
<KPIChange
value={d && d.value != null && !Number.isNaN(d.value) ? d.change : null}
asterisk={d != null && (d.value == null || d.date < date.value)}
/>
<KPIChange value={d && d.value != null && !Number.isNaN(d.value) ? d.change : null} />
{/await}
</div>
<div class="sub">Relative change to 7 days ago</div>
Expand All @@ -177,5 +153,3 @@
<div class="sub">Relative change to 7 days ago</div>
</div>
</div>

<IndicatorFallbackWarning trend={hospitalTrend} date={date.value} level={region.level} sensor={HOSPITAL_ADMISSION} />

0 comments on commit 510332f

Please sign in to comment.