Created
November 1, 2020 15:43
-
-
Save Meir017/872a171662eaf5f5bd755b635e35d4c1 to your computer and use it in GitHub Desktop.
Covid 19 Israel status check
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum Covid19Query { | |
lastUpdate | |
sickPerDateTwoDays | |
sickPatientPerLocation | |
deadPatientsPerDate | |
recoveredPerDay | |
testResultsPerDate | |
infectedPerDate | |
infectedByAgeAndGenderPublic | |
isolatedDoctorsAndNurses | |
contagionDataPerCityPublic | |
hospitalStatus | |
doublingRate | |
patientsPerDate | |
updatedPatientsOverallStatus | |
CalculatedVerified | |
} | |
function Show-Covid19 { | |
param ( | |
[Covid19Query] | |
$Name | |
) | |
(Invoke-RestMethod "https://datadashboardapi.health.gov.il/api/queries/$Name") | |
} | |
function Show-Covid19TestResultsPerDate { | |
param ($Count = 20) | |
$lastUpdate = (Invoke-RestMethod 'https://datadashboardapi.health.gov.il/api/queries/lastUpdate').lastUpdate | |
if ($lastUpdate -ne $Global:Covid19LastUpdate) { | |
$testResultsPerDate = Show-Covid19 testResultsPerDate | Sort-Object date -Descending | |
$infectedPerDate = Show-Covid19 infectedPerDate | Sort-Object date -Descending | |
for ($i = 0; $i -lt $testResultsPerDate.Count; $i++) { | |
Add-Member -Name 'recovered' -Type NoteProperty -InputObject $testResultsPerDate[$i] -Value $infectedPerDate[$i].recovered | |
Add-Member -Name 'balance' -Type NoteProperty -InputObject $testResultsPerDate[$i] -Value ($testResultsPerDate[$i].positiveAmount - $testResultsPerDate[$i].recovered) | |
Add-Member -Name 'percent' -Type NoteProperty -InputObject $testResultsPerDate[$i] -Value (($testResultsPerDate[$i].positiveAmount / $testResultsPerDate[$i].amount) * 100) | |
} | |
$Global:Covid19TestResultsPerDate = $testResultsPerDate | Sort-Object date | |
$Global:Covid19LastUpdate = $lastUpdate | |
} | |
Write-Host "Last Update: $lastUpdate" -ForegroundColor Gray | |
$Global:Covid19TestResultsPerDate | Select-Object -Last $Count | Format-Table | |
} | |
Set-Alias covid19 Show-Covid19TestResultsPerDate |
Author
Meir017
commented
Nov 1, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment