Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
feat(COR-1765): ZKH in beeld – gemiddelde bedbezetting per dag (#4842)
Browse files Browse the repository at this point in the history
* feat(COR-1765): Added changes, expecting data

* feat(COR-1765): Renamed dateUnix to dateRangeUnix

* feat(COR-1765): PR comment resolution

* feat(COR-1765): PR comment resolution. Solved compiler issue because of DateRange

* feat(COR-1765): Schema corrections

* feat(COR-1765): KPI values correction
  • Loading branch information
VWSCoronaDashboard30 authored Aug 25, 2023
1 parent 089307c commit 56fcc70
Show file tree
Hide file tree
Showing 16 changed files with 77 additions and 36 deletions.
4 changes: 2 additions & 2 deletions packages/app/schema/nl/__difference.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
"$ref": "#/definitions/diff_decimal"
},
"hospital_lcps__beds_occupied_covid": {
"$ref": "#/definitions/diff_integer"
"$ref": "#/definitions/diff_decimal"
},
"intensive_care_nice__admissions_on_date_of_reporting_moving_average": {
"$ref": "#/definitions/diff_decimal"
},
"intensive_care_lcps__beds_occupied_covid": {
"$ref": "#/definitions/diff_integer"
"$ref": "#/definitions/diff_decimal"
},
"sewer__average": {
"$ref": "#/definitions/diff_integer"
Expand Down
14 changes: 13 additions & 1 deletion packages/app/schema/nl/hospital_lcps.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
"beds_occupied_covid": {
"type": ["integer", "null"]
},
"beds_occupied_covid_moving_average": {
"type": ["number", "null"]
},
"influx_covid_patients": {
"type": ["integer", "null"]
},
Expand All @@ -34,14 +37,23 @@
},
"date_of_insertion_unix": {
"type": "integer"
},
"date_start_unix": {
"type": "integer"
},
"date_end_unix": {
"type": "integer"
}
},
"required": [
"beds_occupied_covid",
"beds_occupied_covid_moving_average",
"influx_covid_patients",
"influx_covid_patients_moving_average",
"date_unix",
"date_of_insertion_unix"
"date_of_insertion_unix",
"date_start_unix",
"date_end_unix"
],
"additionalProperties": false
}
Expand Down
14 changes: 13 additions & 1 deletion packages/app/schema/nl/intensive_care_lcps.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
"beds_occupied_covid": {
"type": ["integer", "null"]
},
"beds_occupied_covid_moving_average": {
"type": ["number", "null"]
},
"beds_occupied_covid_percentage": {
"type": ["number", "null"]
},
Expand All @@ -37,15 +40,24 @@
},
"date_of_insertion_unix": {
"type": "integer"
},
"date_start_unix": {
"type": "integer"
},
"date_end_unix": {
"type": "integer"
}
},
"required": [
"beds_occupied_covid",
"beds_occupied_covid_moving_average",
"beds_occupied_covid_percentage",
"influx_covid_patients",
"influx_covid_patients_moving_average",
"date_unix",
"date_of_insertion_unix"
"date_of_insertion_unix",
"date_start_unix",
"date_end_unix"
],
"additionalProperties": false
}
Expand Down
4 changes: 2 additions & 2 deletions packages/app/src/components/kpi/bordered-kpi-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import { Text } from '../typography';
import { KpiContent } from './components/kpi-content';
import { BorderedKpiSectionProps } from './types';

export const BorderedKpiSection = ({ title, description, source, dateUnix, tilesData }: BorderedKpiSectionProps) => {
export const BorderedKpiSection = ({ title, description, source, dateOrRange, tilesData }: BorderedKpiSectionProps) => {
const metadata: MetadataProps = {
date: dateUnix,
date: dateOrRange,
source: source,
};

Expand Down
7 changes: 6 additions & 1 deletion packages/app/src/components/kpi/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@ export type TileData = {
differenceValue?: DifferenceInteger;
};

interface DateRange {
start: number;
end: number;
}

export interface BorderedKpiSectionProps {
dateUnix: number;
dateOrRange: number | DateRange;
description: string;
source: {
href: string;
Expand Down
18 changes: 12 additions & 6 deletions packages/app/src/components/metadata.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@ type source = {
href: string;
aria_text?: string;
};

interface DateRange {
start: number;
end: number;
}

export interface MetadataProps extends MarginBottomProps {
date?: number | [number, number] | string;
date?: number | DateRange | string;
source?: source;
dataSources?: source[];
obtainedAt?: number;
Expand All @@ -29,13 +35,13 @@ export function Metadata({ date, source, obtainedAt, isTileFooter, datumsText, m
? replaceVariablesInText(commonTexts.common.metadata.date, {
date: formatDateFromSeconds(date, 'weekday-long'),
})
: Array.isArray(date)
? replaceVariablesInText(commonTexts.common.metadata.date_from_to, {
startDate: formatDateFromSeconds(date[0], 'weekday-long'),
endDate: formatDateFromSeconds(date[1], 'weekday-long'),
})
: typeof date === 'string'
? date
: date && date.start && date.end
? replaceVariablesInText(commonTexts.common.metadata.date_from_to, {
startDate: formatDateFromSeconds(date.start, 'weekday-long'),
endDate: formatDateFromSeconds(date.end, 'weekday-long'),
})
: null;

const intervalString =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function VariantsTableTileWithData({
const { formatDateSpan } = useIntl();

const metadata: MetadataProps = {
date: [dates.date_start_unix, dates.date_end_unix],
date: { start: dates.date_start_unix, end: dates.date_end_unix },
source,
obtainedAt: dates.date_of_report_unix,
};
Expand Down
4 changes: 2 additions & 2 deletions packages/app/src/pages/gemeente/[code]/rioolwater.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ const SewerWater = (props: StaticProps<typeof getStaticProps>) => {
<KpiTile
title={textGm.barscale_titel}
metadata={{
date: [sewerAverages.last_value.date_start_unix, sewerAverages.last_value.date_end_unix],
date: { start: sewerAverages.last_value.date_start_unix, end: sewerAverages.last_value.date_end_unix },
source: textGm.bronnen.rivm,
}}
>
Expand All @@ -145,7 +145,7 @@ const SewerWater = (props: StaticProps<typeof getStaticProps>) => {
title={textGm.total_measurements_title}
description={textGm.total_measurements_description}
metadata={{
date: [sewerInstallationMeasurement.date_start_unix, sewerInstallationMeasurement.date_end_unix],
date: { start: sewerInstallationMeasurement.date_start_unix, end: sewerInstallationMeasurement.date_end_unix },
source: textGm.bronnen.rivm,
}}
>
Expand Down
4 changes: 2 additions & 2 deletions packages/app/src/pages/gemeente/[code]/vaccinaties.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export const VaccinationsGmPage = (props: StaticProps<typeof getStaticProps>) =>
},
},
]}
dateUnix={filteredVaccination.autumn2022.date_unix}
dateOrRange={filteredVaccination.autumn2022.date_unix}
/>
)}
<BorderedKpiSection
Expand Down Expand Up @@ -198,7 +198,7 @@ export const VaccinationsGmPage = (props: StaticProps<typeof getStaticProps>) =>
},
},
]}
dateUnix={filteredVaccination.primarySeries.date_unix}
dateOrRange={filteredVaccination.primarySeries.date_unix}
/>
<VaccineCoverageChoropleth
data={choropleth.gm.vaccine_coverage_per_age_group}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ function IntakeHospital(props: StaticProps<typeof getStaticProps>) {
dateEnd: formatDateFromSeconds(sevenDayAverageDates[1], 'weekday-long'),
})}
metadata={{
date: sevenDayAverageDates,
date: { start: sevenDayAverageDates[0], end: sevenDayAverageDates[1] },
source: textGm.bronnen.rivm,
}}
>
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/pages/landelijk/gedrag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ export default function BehaviorPage(props: StaticProps<typeof getStaticProps>)
<BehaviorLineChartTile
values={behaviorValues}
metadata={{
date: [behaviorLastValue.date_start_unix, behaviorLastValue.date_end_unix],
date: { start: behaviorLastValue.date_start_unix, end: behaviorLastValue.date_end_unix },
source: textNl.bronnen.rivm,
}}
{...timelineProp}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ function VulnerableGroups(props: StaticProps<typeof getStaticProps>) {
title={ElderlyPeopleText.hospital_admissions.kpi_titel}
description={ElderlyPeopleText.hospital_admissions.kpi_toelichting}
metadata={{
date: [vulnerableHospitalAdmissionsData.date_start_unix, vulnerableHospitalAdmissionsData.date_end_unix],
date: { start: vulnerableHospitalAdmissionsData.date_start_unix, end: vulnerableHospitalAdmissionsData.date_end_unix },
source: ElderlyPeopleText.bronnen.rivm,
}}
>
Expand All @@ -162,7 +162,7 @@ function VulnerableGroups(props: StaticProps<typeof getStaticProps>) {
title={textNl.kpi_tiles.infected_locations.title}
description={textNl.kpi_tiles.infected_locations.description}
source={infectedLocationsText.bronnen.rivm}
dateUnix={vulnerableNursingHomeDataLastValue.date_unix}
dateOrRange={vulnerableNursingHomeDataLastValue.date_unix}
tilesData={[
{
value: vulnerableNursingHomeDataLastValue.infected_locations_total,
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/pages/landelijk/rioolwater.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ const SewerWater = (props: StaticProps<typeof getStaticProps>) => {
title={textNl.map_titel}
description={textNl.map_toelichting}
metadata={{
date: [choropleth.gm.sewer[0].date_start_unix, choropleth.gm.sewer[0].date_end_unix],
date: { start: choropleth.gm.sewer[0].date_start_unix, end: choropleth.gm.sewer[0].date_end_unix },
source: textNl.bronnen.rivm,
}}
valueAnnotation={commonTexts.waarde_annotaties.riool_normalized}
Expand Down
14 changes: 7 additions & 7 deletions packages/app/src/pages/landelijk/vaccinaties.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ function VaccinationPage(props: StaticProps<typeof getStaticProps>) {
},
},
]}
dateUnix={vaccineCoverageEstimatedAutumn2022.date_unix}
dateOrRange={vaccineCoverageEstimatedAutumn2022.date_unix}
/>
<BorderedKpiSection
title={textShared.vaccination_grade_tile.fully_vaccinated_labels.title}
Expand Down Expand Up @@ -250,7 +250,7 @@ function VaccinationPage(props: StaticProps<typeof getStaticProps>) {
},
},
]}
dateUnix={vaccineCoverageEstimatedFullyVaccinated.date_unix}
dateOrRange={vaccineCoverageEstimatedFullyVaccinated.date_unix}
/>

<VaccineCampaignsTile
Expand All @@ -273,7 +273,7 @@ function VaccinationPage(props: StaticProps<typeof getStaticProps>) {
data={currentData.vaccine_administered_last_timeframe.vaccine_types}
metadata={{
source: textShared.bronnen.rivm,
date: [currentData.vaccine_administered_last_timeframe.date_start_unix, currentData.vaccine_administered_last_timeframe.date_end_unix],
date: { start: currentData.vaccine_administered_last_timeframe.date_start_unix, end: currentData.vaccine_administered_last_timeframe.date_end_unix },
obtainedAt: currentData.vaccine_administered_last_timeframe.date_of_insertion_unix,
}}
/>
Expand Down Expand Up @@ -457,10 +457,10 @@ function VaccinationPage(props: StaticProps<typeof getStaticProps>) {
description={textNl.grafiek_draagvlak.omschrijving}
metadata={{
datumsText: textNl.grafiek_draagvlak.metadata_tekst,
date: [
archivedData.vaccine_vaccinated_or_support_archived_20230411.last_value.date_start_unix,
archivedData.vaccine_vaccinated_or_support_archived_20230411.last_value.date_end_unix,
],
date: {
start: archivedData.vaccine_vaccinated_or_support_archived_20230411.last_value.date_start_unix,
end: archivedData.vaccine_vaccinated_or_support_archived_20230411.last_value.date_end_unix,
},
}}
>
<TimeSeriesChart
Expand Down
8 changes: 4 additions & 4 deletions packages/app/src/pages/landelijk/ziekenhuizen-in-beeld.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,16 @@ const HospitalsAndCarePage = (props: StaticProps<typeof getStaticProps>) => {
title={textNl.kpi_tiles.occupancies.title}
description={textNl.kpi_tiles.occupancies.description}
source={textNl.sources.lnaz}
dateUnix={mostRecentDateUnix}
dateOrRange={{ start: hospitalLastValue.date_start_unix, end: hospitalLastValue.date_end_unix }}
tilesData={[
{
value: hospitalLastValue.beds_occupied_covid,
value: hospitalLastValue.beds_occupied_covid_moving_average,
differenceValue: data.difference.hospital_lcps__beds_occupied_covid,
title: textNl.kpi_tiles.occupancies.hospital.title,
description: textNl.kpi_tiles.occupancies.hospital.description,
},
{
value: icuLastValue.beds_occupied_covid,
value: icuLastValue.beds_occupied_covid_moving_average,
differenceValue: data.difference.intensive_care_lcps__beds_occupied_covid,
title: textNl.kpi_tiles.occupancies.icu.title,
description: textNl.kpi_tiles.occupancies.icu.description,
Expand Down Expand Up @@ -262,7 +262,7 @@ const HospitalsAndCarePage = (props: StaticProps<typeof getStaticProps>) => {
title={textNl.kpi_tiles.influxes.title}
description={textNl.kpi_tiles.influxes.description}
source={textNl.sources.lnaz}
dateUnix={mostRecentDateUnix}
dateOrRange={mostRecentDateUnix}
tilesData={[
{
value: hospitalLastValue.influx_covid_patients,
Expand Down
10 changes: 8 additions & 2 deletions packages/common/src/types/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -904,9 +904,9 @@ export interface Nl {
export interface NlDifference {
infectious_people__estimate: DifferenceInteger;
hospital_nice__admissions_on_date_of_reporting_moving_average: DifferenceDecimal;
hospital_lcps__beds_occupied_covid: DifferenceInteger;
hospital_lcps__beds_occupied_covid: DifferenceDecimal;
intensive_care_nice__admissions_on_date_of_reporting_moving_average: DifferenceDecimal;
intensive_care_lcps__beds_occupied_covid: DifferenceInteger;
intensive_care_lcps__beds_occupied_covid: DifferenceDecimal;
sewer__average: DifferenceInteger;
reproduction__index_average?: DifferenceDecimal;
vulnerable_hospital_admissions?: DifferenceInteger;
Expand Down Expand Up @@ -1010,22 +1010,28 @@ export interface NlHospitalLcps {
}
export interface NlHospitalLcpsValue {
beds_occupied_covid: number | null;
beds_occupied_covid_moving_average: number | null;
influx_covid_patients: number | null;
influx_covid_patients_moving_average: number | null;
date_unix: number;
date_of_insertion_unix: number;
date_start_unix: number;
date_end_unix: number;
}
export interface NlIntensiveCareLcps {
values: NlIntensiveCareLcpsValue[];
last_value: NlIntensiveCareLcpsValue;
}
export interface NlIntensiveCareLcpsValue {
beds_occupied_covid: number | null;
beds_occupied_covid_moving_average: number | null;
beds_occupied_covid_percentage: number | null;
influx_covid_patients: number | null;
influx_covid_patients_moving_average: number | null;
date_unix: number;
date_of_insertion_unix: number;
date_start_unix: number;
date_end_unix: number;
}
export interface NlDeceasedCbs {
values: NlDeceasedCbsValue[];
Expand Down

0 comments on commit 56fcc70

Please sign in to comment.