Skip to content

Instantly share code, notes, and snippets.

@Meir017
Created November 1, 2020 15:43
Show Gist options
  • Save Meir017/872a171662eaf5f5bd755b635e35d4c1 to your computer and use it in GitHub Desktop.
Save Meir017/872a171662eaf5f5bd755b635e35d4c1 to your computer and use it in GitHub Desktop.
Covid 19 Israel status check
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
@Meir017
Copy link
Author

Meir017 commented Nov 1, 2020

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment