From 6415d89e6660119ad6309817ab1e9cb3cea3682c Mon Sep 17 00:00:00 2001 From: Luka Renko <46861689+lukarenko@users.noreply.github.com> Date: Wed, 2 Feb 2022 19:20:46 +0100 Subject: [PATCH] * Patients: add red-zone and leadingCovid --- README.md | 5 +++++ .../SloCovidServer/Models/PatientsDay.cs | 17 +++++++++++------ .../Services/Implemented/Mapper.cs | 6 +++++- .../SloCovidServer/SloCovidServer/Startup.cs | 2 +- version.xml | 2 +- 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 5263149..6c608b7 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,11 @@ In case of failures a notification is set to slack channel #alert through Data A ## Changelog +## 1.18 + +* Patients: add red-zone and leadingCovid +* Schema version 47 + ## 1.17 * Summary: add daily new cases to CasesAvg7Days diff --git a/sources/SloCovidServer/SloCovidServer/Models/PatientsDay.cs b/sources/SloCovidServer/SloCovidServer/Models/PatientsDay.cs index b58f43a..0513951 100644 --- a/sources/SloCovidServer/SloCovidServer/Models/PatientsDay.cs +++ b/sources/SloCovidServer/SloCovidServer/Models/PatientsDay.cs @@ -24,16 +24,16 @@ public PatientsDay(int dayFromStart, int year, int month, int day, GeneralUnit t public record GeneralUnit : BaseUnit { public OutOfHospital OutOfHospital { get; init; } - public GeneralUnit(HospitalMovement inHospital, HospitalMovement iCU, HospitalMovement niv, HospitalMovement critical, StateDeceased deceased, HospitalMovement care, TodayToDate deceasedCare, - OutOfHospital outOfHospital) : base(inHospital, iCU, niv, critical, deceased, care, deceasedCare) + public GeneralUnit(HospitalMovement inHospital, HospitalMovement iCU, HospitalMovement niv, HospitalMovement critical, StateDeceased deceased, HospitalMovement redZone, HospitalMovement care, TodayToDate deceasedCare, + OutOfHospital outOfHospital) : base(inHospital, iCU, niv, critical, deceased, redZone, care, deceasedCare) { OutOfHospital = outOfHospital; } } public record Unit : BaseUnit { - public Unit(HospitalMovement inHospital, HospitalMovement iCU, HospitalMovement niv, HospitalMovement critical, HospitalDeceased deceased, HospitalMovement care, TodayToDate deceasedCare) - : base(inHospital, iCU, niv, critical, deceased, care, deceasedCare) + public Unit(HospitalMovement inHospital, HospitalMovement iCU, HospitalMovement niv, HospitalMovement critical, HospitalDeceased deceased, HospitalMovement redZone, HospitalMovement care, TodayToDate deceasedCare) + : base(inHospital, iCU, niv, critical, deceased, redZone, care, deceasedCare) { } } @@ -45,9 +45,10 @@ public record BaseUnit public HospitalMovement NIV { get; init; } public HospitalMovement Critical { get; init; } public TDeceased Deceased { get; init; } + public HospitalMovement RedZone { get; init; } public HospitalMovement Care { get; init; } public TodayToDate DeceasedCare { get; init; } - public BaseUnit(HospitalMovement inHospital, HospitalMovement iCU, HospitalMovement niv, HospitalMovement critical, TDeceased deceased, HospitalMovement care, TodayToDate deceasedCare) + public BaseUnit(HospitalMovement inHospital, HospitalMovement iCU, HospitalMovement niv, HospitalMovement critical, TDeceased deceased, HospitalMovement redZone, HospitalMovement care, TodayToDate deceasedCare) { InHospital = inHospital; ICU = iCU; @@ -55,6 +56,8 @@ public BaseUnit(HospitalMovement inHospital, HospitalMovement iCU, HospitalMovem Critical = critical; Deceased = deceased; + RedZone = redZone; + Care = care; DeceasedCare = deceasedCare; } @@ -66,12 +69,14 @@ public record HospitalMovement public int? Out { get; init; } public int? Today { get; init; } public int? ToDate { get; init; } - public HospitalMovement(int? inMovement, int? outMovement, int? current, int? today) + public int? ReasonCovid { get; init; } + public HospitalMovement(int? inMovement, int? outMovement, int? current, int? today, int? covid) { In = inMovement; Out = outMovement; Today = current; ToDate = today; + ReasonCovid = covid; } } diff --git a/sources/SloCovidServer/SloCovidServer/Services/Implemented/Mapper.cs b/sources/SloCovidServer/SloCovidServer/Services/Implemented/Mapper.cs index 3d6e3d3..28fce99 100644 --- a/sources/SloCovidServer/SloCovidServer/Services/Implemented/Mapper.cs +++ b/sources/SloCovidServer/SloCovidServer/Services/Implemented/Mapper.cs @@ -511,6 +511,7 @@ PatientsDay GetDailyPatientsFromRaw(ImmutableDictionary header, str GetHospitalMovement(facility: null, "niv", header, fields), GetHospitalMovement(facility: null, "critical", header, fields), GetStateDeceased(header, fields), + GetHospitalMovement(facility: null, "redzone", header, fields), GetHospitalMovement(facility: null, "care", header, fields), GetDeceasedCare(facility: null, header, fields), new OutOfHospital(GetInt(fields[header["state.out_of_hospital.todate"]])) @@ -524,6 +525,7 @@ PatientsDay GetDailyPatientsFromRaw(ImmutableDictionary header, str GetHospitalMovement(facility, "niv", header, fields), GetHospitalMovement(facility, "critical", header, fields), GetDeceased(facility, header, fields), + GetHospitalMovement(facility, "redzone", header, fields), GetHospitalMovement(facility, "care", header, fields), GetDeceasedCare(facility, header, fields) ); @@ -539,11 +541,13 @@ HospitalMovement GetHospitalMovement(string facility, string type, ImmutableDict string outKey = $"state{location}.{type}.out"; string currentKey = $"state{location}.{type}"; string toDateKey = $"state{location}.{type}.todate"; + string covidKey = $"state{location}.{type}.covid"; return new HospitalMovement( header.ContainsKey(inKey) ? GetInt(fields[header[inKey]]) : null, header.ContainsKey(outKey) ? GetInt(fields[header[outKey]]): null, header.ContainsKey(currentKey) ? GetInt(fields[header[currentKey]]): null, - header.ContainsKey(toDateKey) ? GetInt(fields[header[toDateKey]]): null + header.ContainsKey(toDateKey) ? GetInt(fields[header[toDateKey]]): null, + header.ContainsKey(covidKey) ? GetInt(fields[header[covidKey]]): null ); } diff --git a/sources/SloCovidServer/SloCovidServer/Startup.cs b/sources/SloCovidServer/SloCovidServer/Startup.cs index cc74da0..cb58290 100644 --- a/sources/SloCovidServer/SloCovidServer/Startup.cs +++ b/sources/SloCovidServer/SloCovidServer/Startup.cs @@ -17,7 +17,7 @@ namespace SloCovidServer { public class Startup { - const string SchemaVersion = "46"; + const string SchemaVersion = "47"; const string CorsPolicy = "Any"; readonly IWebHostEnvironment env; public Startup(IConfiguration configuration, IWebHostEnvironment env) diff --git a/version.xml b/version.xml index fa47ba2..32b5c59 100644 --- a/version.xml +++ b/version.xml @@ -1,2 +1,2 @@  -1.17 \ No newline at end of file +1.18 \ No newline at end of file