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

feature/COR-1914_archive-view-on-patients-choropleth #4982

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/app/schema/archived_gm/__index.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"vaccine_coverage_per_age_group_archived_20220622",
"vaccine_coverage_per_age_group_archived_20220908",
"vaccine_coverage_per_age_group_archived_20231004",
"tested_overall_archived_20230331"
"tested_overall_archived_20230331",
"hospital_nice_archived_20240228"
],
"properties": {
"difference": {
Expand Down Expand Up @@ -53,6 +54,9 @@
},
"tested_overall_archived_20230331": {
"$ref": "positive_tests/tested_overall.json"
},
"hospital_nice_archived_20240228": {
"$ref": "hospital_nice.json"
}
},
"$defs": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"definitions": {
"value": {
"title": "gm_hospital_nice_value",
"title": "archived_gm_hospital_nice_value",
"type": "object",
"additionalProperties": false,
"required": [
Expand Down
9 changes: 9 additions & 0 deletions packages/app/schema/archived_gm_collection/__index.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"name",
"code",
"hospital_nice_choropleth_archived_20230830",
"hospital_nice_choropleth_archived_20240228",
"sewer_archived_20230623",
"tested_overall_archived_20230331",
"vaccine_coverage_per_age_group_choropleth_archived_20231004"
Expand All @@ -34,6 +35,14 @@
"$ref": "hospital_nice_choropleth.json"
}
},
"hospital_nice_choropleth_archived_20240228": {
"type": "array",
"minItems": 342,
"maxItems": 342,
"items": {
"$ref": "hospital_nice_choropleth_weekly_admissions.json"
}
},
"sewer_archived_20230623": {
"type": "array",
"minItems": 342,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"title": "gm_collection_hospital_nice_choropleth",
"title": "archived_gm_collection_hospital_nice_choropleth_weekly_admissions",
"additionalProperties": false,
"required": ["date_unix", "gmcode", "admissions_in_the_last_7_days_per_100000", "date_of_insertion_unix", "date_start_unix", "date_end_unix"],
"properties": {
Expand Down
5 changes: 1 addition & 4 deletions packages/app/schema/gm/__index.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "object",
"title": "gm",
"additionalProperties": false,
"required": ["name", "proto_name", "code", "difference", "static_values", "hospital_nice", "sewer_installation_measurement", "sewer_per_installation", "sewer", "last_generated"],
"required": ["name", "proto_name", "code", "difference", "static_values", "sewer_installation_measurement", "sewer_per_installation", "sewer", "last_generated"],
"properties": {
"last_generated": {
"type": "string"
Expand All @@ -23,9 +23,6 @@
"difference": {
"$ref": "__difference.json"
},
"hospital_nice": {
"$ref": "hospital_nice.json"
},
"sewer": {
"$ref": "sewer.json"
},
Expand Down
10 changes: 1 addition & 9 deletions packages/app/schema/gm_collection/__index.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "object",
"title": "gm_collection",
"additionalProperties": false,
"required": ["last_generated", "proto_name", "name", "code", "hospital_nice_choropleth", "sewer"],
"required": ["last_generated", "proto_name", "name", "code", "sewer"],
"properties": {
"last_generated": {
"type": "string"
Expand All @@ -17,14 +17,6 @@
"code": {
"$ref": "#/$defs/gm_collection_id"
},
"hospital_nice_choropleth": {
"type": "array",
"minItems": 342,
"maxItems": 342,
"items": {
"$ref": "hospital_nice_choropleth.json"
}
},
"sewer": {
"type": "array",
"minItems": 342,
Expand Down
6 changes: 4 additions & 2 deletions packages/app/src/components/choropleth/logic/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import type {
ArchivedGmCollection,
ArchivedGmCollectionHospitalNiceChoropleth,
GmCollection,
GmCollectionHospitalNiceChoropleth,
GmCollectionSewer,
ArchivedGmCollectionVaccineCoveragePerAgeGroupChoropleth,
ArchivedGmCollectionTestedOverall,
ArchivedVrCollection,
VrCollectionVulnerableNursingHome,
VrCollectionElderlyAtHome,
VrCollectionDisabilityCare,
ArchivedGmCollectionHospitalNiceChoroplethWeeklyAdmissions,
} from '@corona-dashboard/common';
import type { ParsedFeature } from '@visx/geo/lib/projections/Projection';
import type { Feature, FeatureCollection, MultiPolygon, Polygon } from 'geojson';
Expand Down Expand Up @@ -57,13 +57,15 @@ export type InferedDataCollection<T extends ChoroplethDataItem> = T extends GmDa
? ArchivedVrCollection
: never;

export type GmDataCollection = GmCollectionHospitalNiceChoropleth[] | GmCollectionSewer[];
export type GmDataCollection = GmCollectionSewer[];
export type GmDataItem = GmDataCollection[number];

export type ArchivedGmDataCollection =
| ArchivedGmCollectionTestedOverall[]
| ArchivedGmCollectionHospitalNiceChoropleth[]
| ArchivedGmCollectionHospitalNiceChoroplethWeeklyAdmissions[]
| ArchivedGmCollectionVaccineCoveragePerAgeGroupChoropleth[];

export type ArchivedGmDataItem = ArchivedGmDataCollection[number];

export type ArchivedVrDataCollection = VrCollectionVulnerableNursingHome[] | VrCollectionElderlyAtHome[] | VrCollectionDisabilityCare[];
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/components/sitemap/use-data-sitemap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function useDataSitemap(base: 'nl' | 'gm', code?: string, data?: Pick<Nl,
links: [
{
text: commonTexts.sidebar.metrics.hospital_admissions.title,
href: reverseRouter.gm.ziekenhuisopnames(code),
href: reverseRouter.gm.patientenInBeeld(code),
ben-van-eekelen marked this conversation as resolved.
Show resolved Hide resolved
},
],
},
Expand Down
3 changes: 1 addition & 2 deletions packages/app/src/domain/layout/gm-layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,8 @@ export function GmLayout(props: GmLayoutProps) {
code: code,
map: [
['development_of_the_virus', ['sewage_measurement']],
['consequences_for_healthcare', ['hospital_admissions']],
['actions_to_take', ['the_corona_vaccine']],
['archived_metrics', ['positive_tests', 'mortality']],
['archived_metrics', ['positive_tests', 'mortality', 'patients']],
],
});

Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/domain/layout/logic/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export type Layout = 'nl' | 'gm' | 'custom';

type SharedCategoryKeys = 'development_of_the_virus' | 'consequences_for_healthcare' | 'actions_to_take';

export type GmItemKeys = 'hospital_admissions' | 'mortality' | 'positive_tests' | 'sewage_measurement' | 'the_corona_vaccine';
export type GmItemKeys = 'patients' | 'mortality' | 'positive_tests' | 'sewage_measurement' | 'the_corona_vaccine';
ben-van-eekelen marked this conversation as resolved.
Show resolved Hide resolved

export type GmCategoryKeys = SharedCategoryKeys | 'archived_metrics';

Expand Down
6 changes: 6 additions & 0 deletions packages/app/src/next-config/redirects/redirects.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ async function redirects() {
destination: `/gemeente/GM${to}/:page*`,
permanent: true,
})),
// Redirects for municipal patienten-in-beeld
...gmRedirects.map(({ from, to }) => ({
source: `/gemeente/:gm(gm|GM|gM|Gm):nr(${from.join('|')})/ziekenhuis-opnames`,
destination: `/gemeente/GM${to}/patienten-in-beeld`,
permanent: true,
})),
// Redirects for the NL pages
{
source: '/landelijk/ziekenhuis-opnames',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ChartTile } from '~/components/chart-tile';
import { ChoroplethTile } from '~/components/choropleth-tile';
import { colors, DAY_IN_SECONDS, TimeframeOption, TimeframeOptionsList, WEEK_IN_SECONDS } from '@corona-dashboard/common';
import { countTrailingNullValues, getBoundaryDateStartUnix, replaceVariablesInText, useReverseRouter } from '~/utils';
import { createGetArchivedChoroplethData, createGetChoroplethData, createGetContent, getLastGeneratedDate, getLokalizeTexts, selectGmData } from '~/static-props/get-data';
import { createGetArchivedChoroplethData, createGetContent, getLastGeneratedDate, getLokalizeTexts, selectArchivedGmData } from '~/static-props/get-data';
import { createGetStaticProps, StaticProps } from '~/static-props/create-get-static-props';
import { DynamicChoropleth } from '~/components/choropleth';
import { ElementsQueryResult, getElementsQuery, getTimelineEvents } from '~/queries/get-elements-query';
Expand Down Expand Up @@ -48,15 +48,11 @@ export { getStaticPaths } from '~/static-paths/gm';
export const getStaticProps = createGetStaticProps(
({ locale }: { locale: keyof Languages }) => getLokalizeTexts(selectLokalizeTexts, locale),
getLastGeneratedDate,
selectGmData('hospital_nice', 'code'),
createGetChoroplethData({
gm: ({ hospital_nice_choropleth }, context) => ({
hospital_nice_choropleth: filterByRegionMunicipalities(hospital_nice_choropleth, context),
}),
}),
selectArchivedGmData('hospital_nice_archived_20240228', 'code'),
createGetArchivedChoroplethData({
gm: ({ hospital_nice_choropleth_archived_20230830 }, context) => ({
gm: ({ hospital_nice_choropleth_archived_20230830, hospital_nice_choropleth_archived_20240228 }, context) => ({
hospital_nice_choropleth_archived_20230830: filterByRegionMunicipalities(hospital_nice_choropleth_archived_20230830, context),
hospital_nice_choropleth_archived_20240228: filterByRegionMunicipalities(hospital_nice_choropleth_archived_20240228, context),
}),
}),
async (context: GetStaticPropsContext) => {
Expand Down Expand Up @@ -84,7 +80,7 @@ export const getStaticProps = createGetStaticProps(

function IntakeHospital(props: StaticProps<typeof getStaticProps>) {
const router = useRouter();
const { pageText, selectedGmData: data, choropleth, archivedChoropleth, municipalityName, content, lastGenerated } = props;
const { pageText, selectedArchivedGmData: data, archivedChoropleth, municipalityName, content, lastGenerated } = props;
const [isArchivedContentShown, setIsArchivedContentShown] = useState<boolean>(false);

const [hospitalAdmissionsOverTimeTimeframe, setHospitalAdmissionsOverTimeTimeframe] = useState<TimeframeOption>(TimeframeOption.ALL);
Expand All @@ -94,10 +90,13 @@ function IntakeHospital(props: StaticProps<typeof getStaticProps>) {

const { textGm, jsonText } = useDynamicLokalizeTexts<LokalizeTexts>(pageText, selectLokalizeTexts);

const lastValue = data.hospital_nice.last_value;
const lastValueChoropleth = last(choropleth.gm.hospital_nice_choropleth) || lastValue;
const lastValue = data.hospital_nice_archived_20240228.last_value;
const lastValueChoropleth = last(archivedChoropleth.gm.hospital_nice_choropleth_archived_20240228) || lastValue;

const underReportedRange = getBoundaryDateStartUnix(data.hospital_nice.values, countTrailingNullValues(data.hospital_nice.values, 'admissions_in_the_last_7_days'));
const underReportedRange = getBoundaryDateStartUnix(
data.hospital_nice_archived_20240228.values,
countTrailingNullValues(data.hospital_nice_archived_20240228.values, 'admissions_in_the_last_7_days')
);

const sevenDayAverageDates = { start: underReportedRange - WEEK_IN_SECONDS, end: underReportedRange - DAY_IN_SECONDS };

Expand Down Expand Up @@ -171,7 +170,7 @@ function IntakeHospital(props: StaticProps<typeof getStaticProps>) {
accessibility={{
key: 'hospital_admissions_over_time_chart',
}}
values={data.hospital_nice.values}
values={data.hospital_nice_archived_20240228.values}
timeframe={hospitalAdmissionsOverTimeTimeframe}
seriesConfig={[
{
Expand Down Expand Up @@ -202,44 +201,6 @@ function IntakeHospital(props: StaticProps<typeof getStaticProps>) {
/>
</ChartTile>

<ChoroplethTile
title={replaceVariablesInText(textGm.map_titel, {
municipality: municipalityName,
})}
metadata={{
date: { start: lastValueChoropleth.date_start_unix, end: lastValueChoropleth.date_end_unix },
source: textGm.bronnen.rivm,
}}
description={textGm.map_toelichting}
legend={{
title: textGm.chloropleth_legenda.titel,
thresholds: thresholds.gm.admissions_in_the_last_7_days_per_100000,
outdatedDataLabel: textGm.choropleth_legend_outdated_data_label,
}}
pageType="ziekenhuis-opnames"
notification={textGm.choropleth_update_notification}
>
<DynamicChoropleth
map="gm"
accessibility={{
key: 'hospital_admissions_choropleth',
}}
data={choropleth.gm.hospital_nice_choropleth}
dataConfig={{
metricName: 'hospital_nice_choropleth',
metricProperty: 'admissions_in_the_last_7_days_per_100000',
}}
dataOptions={{
selectedCode: data.code,
highlightSelection: true,
getLink: reverseRouter.gm.ziekenhuisopnames,
tooltipVariables: {
patients: commonTexts.choropleth_tooltip.patients,
},
}}
/>
</ChoroplethTile>

{content.faqs && content.faqs.questions?.length > 0 && <PageFaqTile questions={content.faqs.questions} title={content.faqs.sectionTitle} />}

{content.articles && content.articles.articles?.length > 0 && (
Expand Down Expand Up @@ -284,7 +245,45 @@ function IntakeHospital(props: StaticProps<typeof getStaticProps>) {
dataOptions={{
selectedCode: data.code,
highlightSelection: true,
getLink: reverseRouter.gm.ziekenhuisopnames,
getLink: reverseRouter.gm.patientenInBeeld,
tooltipVariables: {
patients: commonTexts.choropleth_tooltip.patients,
},
}}
/>
</ChoroplethTile>

<ChoroplethTile
title={replaceVariablesInText(textGm.map_titel, {
municipality: municipalityName,
})}
metadata={{
date: { start: lastValueChoropleth.date_start_unix, end: lastValueChoropleth.date_end_unix },
source: textGm.bronnen.rivm,
}}
description={textGm.map_toelichting}
legend={{
title: textGm.chloropleth_legenda.titel,
thresholds: thresholds.gm.admissions_in_the_last_7_days_per_100000,
outdatedDataLabel: textGm.choropleth_legend_outdated_data_label,
}}
pageType="ziekenhuis-opnames"
notification={textGm.choropleth_update_notification}
>
<DynamicChoropleth
map="gm"
accessibility={{
key: 'hospital_admissions_choropleth',
}}
data={archivedChoropleth.gm.hospital_nice_choropleth_archived_20240228}
dataConfig={{
metricName: 'hospital_nice_choropleth_archived_20240228',
metricProperty: 'admissions_in_the_last_7_days_per_100000',
}}
dataOptions={{
selectedCode: data.code,
highlightSelection: true,
getLink: reverseRouter.gm.patientenInBeeld,
tooltipVariables: {
patients: commonTexts.choropleth_tooltip.patients,
},
Expand Down
Loading
Loading