Skip to content

Commit

Permalink
Deceased infocard from NIJZ OPSI - try
Browse files Browse the repository at this point in the history
  • Loading branch information
lukarenko committed Dec 15, 2023
1 parent 2735981 commit 29447cf
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions sources/SloCovidServer/SloCovidServer/Mappers/SummaryMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ public static Summary CreateSummary(DateTime? toDate, ImmutableArray<StatsDaily>
var casesActive100k = GetCasesActive100k(toDate, stats);
var hospitalizedCurrent = GetHospitalizedCurrent(toDate, patients);
var icuCurrent = GetIcuCurrent(toDate, patients);
var deceasedToDay = GetDeceasedToDay(toDate, patients);
var deceasedToday = GetDeceasedToday(toDate, stats);
var casesAvg7Days = GetCasesAvg7Days(toDate, stats);
var testsToday = GetTestsToday(toDate, labTests);
var testsTodayHAT = GetTestsTodayHAT(toDate, labTests);
return new Summary(vaccinationToDate, casesToDate, casesActive, casesActive100k, casesAvg7Days, hospitalizedCurrent, icuCurrent, deceasedToDay, testsToday, testsTodayHAT);
return new Summary(vaccinationToDate, casesToDate, casesActive, casesActive100k, casesAvg7Days, hospitalizedCurrent, icuCurrent, deceasedToday, testsToday, testsTodayHAT);
}
internal static TestsToday GetTestsToday(DateTime? toDate, ImmutableArray<LabTestDay> labTests)
{
Expand Down Expand Up @@ -80,7 +80,7 @@ internal static HospitalizedCurrent GetHospitalizedCurrent(DateTime? toDate, Imm
lastPatient.Value.Last.Year, lastPatient.Value.Last.Month, lastPatient.Value.Last.Day)
: null;
}
internal static DeceasedToDate GetDeceasedToDay(DateTime? toDate, ImmutableArray<PatientsDay> patients)
internal static DeceasedToDate GetDeceasedToday(DateTime? toDate, ImmutableArray<PatientsDay> patients)
{
var lastPatient = GetLastAndPreviousItem(toDate, patients, p => p.Total?.Deceased?.ToDate != null);
return lastPatient.HasValue ?
Expand Down Expand Up @@ -108,6 +108,19 @@ internal static ICUCurrent GetIcuCurrent(DateTime? toDate, ImmutableArray<Patien
lastPatient.Value.Last.Year, lastPatient.Value.Last.Month, lastPatient.Value.Last.Day)
: null;
}
internal static DeceasedToDate GetDeceasedToday(DateTime? toDate, ImmutableArray<StatsDaily> stats)
{
var lastStats = GetLastAndPreviousItem(toDate, stats, s => s.DeceasedToDate != null);
return lastStats.HasValue ?
new DeceasedToDate(
lastStats.Value.Last.DeceasedToDate,
new DeceasedToDateSubValues(
lastStats.Value.Last.Deceased
),
CalculateDifference(lastStats.Value.Last.DeceasedToDate, lastStats.Value.Previous?.DeceasedToDate),
lastStats.Value.Last.Year, lastStats.Value.Last.Month, lastStats.Value.Last.Day)
: null;
}
internal static CasesActive GetCasesActive(DateTime? toDate, ImmutableArray<StatsDaily> stats)
{
var lastStats = GetLastAndPreviousItem(toDate, stats, s => s.Cases?.Active != null);
Expand Down

0 comments on commit 29447cf

Please sign in to comment.