From c12bac572fc9aa9c47a166169e427bf000aa7638 Mon Sep 17 00:00:00 2001 From: Emmanuel-W Date: Mon, 13 Apr 2020 18:21:30 +0300 Subject: [PATCH 01/16] First commit --- src/estimator.php | 144 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 142 insertions(+), 2 deletions(-) diff --git a/src/estimator.php b/src/estimator.php index 5ae6bad..9d52df3 100644 --- a/src/estimator.php +++ b/src/estimator.php @@ -1,6 +1,146 @@ $data, + 'impact' => array( + 'currentlyInfected'=>currentlyInfected($data['reportedCases']), + 'infectionsByRequestedTime'=>infectionsByRequestedTime(currentlyInfected($data['reportedCases']),$data['periodType']), + 'severeCasesByRequestedTime'=>severeCasesByRequestedTime(infectionsByRequestedTime(currentlyInfected($data['reportedCases']),$data['periodType'])), + 'hospitalBedsByRequestedTime'=>hospitalBedsByRequestedTime(severeCasesByRequestedTime(infectionsByRequestedTime(currentlyInfected($data['reportedCases']),$data['periodType'])),$data['totalHospitalBeds']), + 'casesForICUByRequestedTime'=>casesForICUByRequestedTime(infectionsByRequestedTime(currentlyInfected($data['reportedCases']),$data['periodType'])), + 'casesForVentilatorsByRequestedTime'=>casesForVentilatorsByRequestedTime(infectionsByRequestedTime(currentlyInfected($data['reportedCases']),$data['periodType'])), + 'dollarsInFlight'=>dollarsInFlight(infectionsByRequestedTime(currentlyInfected($data['reportedCases']),$data['periodType'])), + ), + 'severeImpact' => array( + 'currentlyInfected'=>currentlyInfectedSevereImpact($data['reportedCases']), + 'infectionsByRequestedTime'=>infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data['reportedCases']),$data['periodType']), + 'severeCasesByRequestedTime'=>severeCasesByRequestedTimeSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data['reportedCases']),$data['periodType'])), + 'hospitalBedsByRequestedTime'=>hospitalBedsByRequestedTimeSevereImpact(severeCasesByRequestedTimeSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data['reportedCases']),$data['periodType'])),$data['totalHospitalBeds']), + 'casesForICUByRequestedTime'=>casesForICUByRequestedTimeSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data['reportedCases']),$data['periodType'])), + 'casesForVentilatorsByRequestedTime'=>casesForVentilatorsByRequestedTimeSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data['reportedCases']),$data['periodType'])), + 'dollarsInFlight'=>dollarsInFlightSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data['reportedCases']),$data['periodType'])), + ) + ); + + return $output; +} + +var_dump(covid19ImpactEstimator($data_json)); From 0f32c650692f0e1d9dc8d6c2b57a62dff6138abb Mon Sep 17 00:00:00 2001 From: Emmanuel-W Date: Mon, 13 Apr 2020 18:51:09 +0300 Subject: [PATCH 02/16] Second attempt --- src/estimator.php | 55 ++++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/src/estimator.php b/src/estimator.php index 9d52df3..2f41dd4 100644 --- a/src/estimator.php +++ b/src/estimator.php @@ -13,6 +13,8 @@ "totalHospitalBeds": 1380614 }'; + + function currentlyInfected($reportedCases) { $value=$reportedCases * 10; @@ -113,34 +115,33 @@ function dollarsInFlightSevereImpact($infectionsByRequestedTimeSevereImpact) return round($value,2); } +$data1 = json_decode($data_json, true); + +$data = array( + 'data' => $data1, + 'impact' => array( + 'currentlyInfected'=>currentlyInfected($data1['reportedCases']), + 'infectionsByRequestedTime'=>infectionsByRequestedTime(currentlyInfected($data1['reportedCases']),$data1['periodType']), + 'severeCasesByRequestedTime'=>severeCasesByRequestedTime(infectionsByRequestedTime(currentlyInfected($data1['reportedCases']),$data1['periodType'])), + 'hospitalBedsByRequestedTime'=>hospitalBedsByRequestedTime(severeCasesByRequestedTime(infectionsByRequestedTime(currentlyInfected($data1['reportedCases']),$data1['periodType'])),$data1['totalHospitalBeds']), + 'casesForICUByRequestedTime'=>casesForICUByRequestedTime(infectionsByRequestedTime(currentlyInfected($data1['reportedCases']),$data1['periodType'])), + 'casesForVentilatorsByRequestedTime'=>casesForVentilatorsByRequestedTime(infectionsByRequestedTime(currentlyInfected($data1['reportedCases']),$data1['periodType'])), + 'dollarsInFlight'=>dollarsInFlight(infectionsByRequestedTime(currentlyInfected($data1['reportedCases']),$data1['periodType'])), + ), + 'severeImpact' => array( + 'currentlyInfected'=>currentlyInfectedSevereImpact($data1['reportedCases']), + 'infectionsByRequestedTime'=>infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data1['reportedCases']),$data1['periodType']), + 'severeCasesByRequestedTime'=>severeCasesByRequestedTimeSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data1['reportedCases']),$data1['periodType'])), + 'hospitalBedsByRequestedTime'=>hospitalBedsByRequestedTimeSevereImpact(severeCasesByRequestedTimeSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data1['reportedCases']),$data1['periodType'])),$data['totalHospitalBeds']), + 'casesForICUByRequestedTime'=>casesForICUByRequestedTimeSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data1['reportedCases']),$data1['periodType'])), + 'casesForVentilatorsByRequestedTime'=>casesForVentilatorsByRequestedTimeSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data1['reportedCases']),$data1['periodType'])), + 'dollarsInFlight'=>dollarsInFlightSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data1['reportedCases']),$data1['periodType'])), + ) +); + function covid19ImpactEstimator($data) { - $data = json_decode($data, true); - - $output = array( - 'data' => $data, - 'impact' => array( - 'currentlyInfected'=>currentlyInfected($data['reportedCases']), - 'infectionsByRequestedTime'=>infectionsByRequestedTime(currentlyInfected($data['reportedCases']),$data['periodType']), - 'severeCasesByRequestedTime'=>severeCasesByRequestedTime(infectionsByRequestedTime(currentlyInfected($data['reportedCases']),$data['periodType'])), - 'hospitalBedsByRequestedTime'=>hospitalBedsByRequestedTime(severeCasesByRequestedTime(infectionsByRequestedTime(currentlyInfected($data['reportedCases']),$data['periodType'])),$data['totalHospitalBeds']), - 'casesForICUByRequestedTime'=>casesForICUByRequestedTime(infectionsByRequestedTime(currentlyInfected($data['reportedCases']),$data['periodType'])), - 'casesForVentilatorsByRequestedTime'=>casesForVentilatorsByRequestedTime(infectionsByRequestedTime(currentlyInfected($data['reportedCases']),$data['periodType'])), - 'dollarsInFlight'=>dollarsInFlight(infectionsByRequestedTime(currentlyInfected($data['reportedCases']),$data['periodType'])), - ), - 'severeImpact' => array( - 'currentlyInfected'=>currentlyInfectedSevereImpact($data['reportedCases']), - 'infectionsByRequestedTime'=>infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data['reportedCases']),$data['periodType']), - 'severeCasesByRequestedTime'=>severeCasesByRequestedTimeSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data['reportedCases']),$data['periodType'])), - 'hospitalBedsByRequestedTime'=>hospitalBedsByRequestedTimeSevereImpact(severeCasesByRequestedTimeSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data['reportedCases']),$data['periodType'])),$data['totalHospitalBeds']), - 'casesForICUByRequestedTime'=>casesForICUByRequestedTimeSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data['reportedCases']),$data['periodType'])), - 'casesForVentilatorsByRequestedTime'=>casesForVentilatorsByRequestedTimeSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data['reportedCases']),$data['periodType'])), - 'dollarsInFlight'=>dollarsInFlightSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data['reportedCases']),$data['periodType'])), - ) - ); - - return $output; -} -var_dump(covid19ImpactEstimator($data_json)); + return $data; +} From 10a20051df0ca308ff72ad1e51d8a45e7eded9dd Mon Sep 17 00:00:00 2001 From: Emmanuel-W Date: Mon, 13 Apr 2020 18:56:06 +0300 Subject: [PATCH 03/16] Third attempt --- src/estimator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/estimator.php b/src/estimator.php index 2f41dd4..01bf541 100644 --- a/src/estimator.php +++ b/src/estimator.php @@ -132,7 +132,7 @@ function dollarsInFlightSevereImpact($infectionsByRequestedTimeSevereImpact) 'currentlyInfected'=>currentlyInfectedSevereImpact($data1['reportedCases']), 'infectionsByRequestedTime'=>infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data1['reportedCases']),$data1['periodType']), 'severeCasesByRequestedTime'=>severeCasesByRequestedTimeSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data1['reportedCases']),$data1['periodType'])), - 'hospitalBedsByRequestedTime'=>hospitalBedsByRequestedTimeSevereImpact(severeCasesByRequestedTimeSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data1['reportedCases']),$data1['periodType'])),$data['totalHospitalBeds']), + 'hospitalBedsByRequestedTime'=>hospitalBedsByRequestedTimeSevereImpact(severeCasesByRequestedTimeSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data1['reportedCases']),$data1['periodType'])),$data1['totalHospitalBeds']), 'casesForICUByRequestedTime'=>casesForICUByRequestedTimeSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data1['reportedCases']),$data1['periodType'])), 'casesForVentilatorsByRequestedTime'=>casesForVentilatorsByRequestedTimeSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data1['reportedCases']),$data1['periodType'])), 'dollarsInFlight'=>dollarsInFlightSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data1['reportedCases']),$data1['periodType'])), From 055eab3d426c590978037cd35eda8eb9192ae85d Mon Sep 17 00:00:00 2001 From: Emmanuel-W Date: Mon, 13 Apr 2020 19:04:03 +0300 Subject: [PATCH 04/16] Fourth attempt --- src/estimator.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/estimator.php b/src/estimator.php index 01bf541..dc91b80 100644 --- a/src/estimator.php +++ b/src/estimator.php @@ -117,7 +117,7 @@ function dollarsInFlightSevereImpact($infectionsByRequestedTimeSevereImpact) } $data1 = json_decode($data_json, true); -$data = array( +$data_array = array( 'data' => $data1, 'impact' => array( 'currentlyInfected'=>currentlyInfected($data1['reportedCases']), @@ -139,6 +139,7 @@ function dollarsInFlightSevereImpact($infectionsByRequestedTimeSevereImpact) ) ); +$data = json_encode($data_array); function covid19ImpactEstimator($data) { From 6e58b14eb6c0ae7bcc231cd81dc654d6210e5afc Mon Sep 17 00:00:00 2001 From: Emmanuel-W Date: Mon, 13 Apr 2020 20:59:44 +0300 Subject: [PATCH 05/16] Fifth attempt --- src/estimator.php | 53 ++++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/src/estimator.php b/src/estimator.php index dc91b80..54dd691 100644 --- a/src/estimator.php +++ b/src/estimator.php @@ -115,34 +115,35 @@ function dollarsInFlightSevereImpact($infectionsByRequestedTimeSevereImpact) return round($value,2); } -$data1 = json_decode($data_json, true); - -$data_array = array( - 'data' => $data1, - 'impact' => array( - 'currentlyInfected'=>currentlyInfected($data1['reportedCases']), - 'infectionsByRequestedTime'=>infectionsByRequestedTime(currentlyInfected($data1['reportedCases']),$data1['periodType']), - 'severeCasesByRequestedTime'=>severeCasesByRequestedTime(infectionsByRequestedTime(currentlyInfected($data1['reportedCases']),$data1['periodType'])), - 'hospitalBedsByRequestedTime'=>hospitalBedsByRequestedTime(severeCasesByRequestedTime(infectionsByRequestedTime(currentlyInfected($data1['reportedCases']),$data1['periodType'])),$data1['totalHospitalBeds']), - 'casesForICUByRequestedTime'=>casesForICUByRequestedTime(infectionsByRequestedTime(currentlyInfected($data1['reportedCases']),$data1['periodType'])), - 'casesForVentilatorsByRequestedTime'=>casesForVentilatorsByRequestedTime(infectionsByRequestedTime(currentlyInfected($data1['reportedCases']),$data1['periodType'])), - 'dollarsInFlight'=>dollarsInFlight(infectionsByRequestedTime(currentlyInfected($data1['reportedCases']),$data1['periodType'])), - ), - 'severeImpact' => array( - 'currentlyInfected'=>currentlyInfectedSevereImpact($data1['reportedCases']), - 'infectionsByRequestedTime'=>infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data1['reportedCases']),$data1['periodType']), - 'severeCasesByRequestedTime'=>severeCasesByRequestedTimeSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data1['reportedCases']),$data1['periodType'])), - 'hospitalBedsByRequestedTime'=>hospitalBedsByRequestedTimeSevereImpact(severeCasesByRequestedTimeSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data1['reportedCases']),$data1['periodType'])),$data1['totalHospitalBeds']), - 'casesForICUByRequestedTime'=>casesForICUByRequestedTimeSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data1['reportedCases']),$data1['periodType'])), - 'casesForVentilatorsByRequestedTime'=>casesForVentilatorsByRequestedTimeSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data1['reportedCases']),$data1['periodType'])), - 'dollarsInFlight'=>dollarsInFlightSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data1['reportedCases']),$data1['periodType'])), - ) -); - -$data = json_encode($data_array); + + + + + function covid19ImpactEstimator($data) { - + $data1 = json_decode($data, true); + $data = array( + 'data' => $data1, + 'impact' => array( + 'currentlyInfected'=>currentlyInfected($data1['reportedCases']), + 'infectionsByRequestedTime'=>infectionsByRequestedTime(currentlyInfected($data1['reportedCases']),$data1['periodType']), + 'severeCasesByRequestedTime'=>severeCasesByRequestedTime(infectionsByRequestedTime(currentlyInfected($data1['reportedCases']),$data1['periodType'])), + 'hospitalBedsByRequestedTime'=>hospitalBedsByRequestedTime(severeCasesByRequestedTime(infectionsByRequestedTime(currentlyInfected($data1['reportedCases']),$data1['periodType'])),$data1['totalHospitalBeds']), + 'casesForICUByRequestedTime'=>casesForICUByRequestedTime(infectionsByRequestedTime(currentlyInfected($data1['reportedCases']),$data1['periodType'])), + 'casesForVentilatorsByRequestedTime'=>casesForVentilatorsByRequestedTime(infectionsByRequestedTime(currentlyInfected($data1['reportedCases']),$data1['periodType'])), + 'dollarsInFlight'=>dollarsInFlight(infectionsByRequestedTime(currentlyInfected($data1['reportedCases']),$data1['periodType'])), + ), + 'severeImpact' => array( + 'currentlyInfected'=>currentlyInfectedSevereImpact($data1['reportedCases']), + 'infectionsByRequestedTime'=>infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data1['reportedCases']),$data1['periodType']), + 'severeCasesByRequestedTime'=>severeCasesByRequestedTimeSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data1['reportedCases']),$data1['periodType'])), + 'hospitalBedsByRequestedTime'=>hospitalBedsByRequestedTimeSevereImpact(severeCasesByRequestedTimeSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data1['reportedCases']),$data1['periodType'])),$data1['totalHospitalBeds']), + 'casesForICUByRequestedTime'=>casesForICUByRequestedTimeSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data1['reportedCases']),$data1['periodType'])), + 'casesForVentilatorsByRequestedTime'=>casesForVentilatorsByRequestedTimeSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data1['reportedCases']),$data1['periodType'])), + 'dollarsInFlight'=>dollarsInFlightSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data1['reportedCases']),$data1['periodType'])), + ) + ); return $data; } From ea36a55a06b2d4958f0b27060fcefcb36cdd920e Mon Sep 17 00:00:00 2001 From: Emmanuel-W Date: Mon, 13 Apr 2020 21:04:18 +0300 Subject: [PATCH 06/16] Sixth --- src/estimator.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/estimator.php b/src/estimator.php index 54dd691..b8ff655 100644 --- a/src/estimator.php +++ b/src/estimator.php @@ -117,13 +117,9 @@ function dollarsInFlightSevereImpact($infectionsByRequestedTimeSevereImpact) } - - - - function covid19ImpactEstimator($data) { - $data1 = json_decode($data, true); + $data1 = json_decode($data_json, true); $data = array( 'data' => $data1, 'impact' => array( From 5aa9e2fae248880b8133c659d40b3790fb915a55 Mon Sep 17 00:00:00 2001 From: Emmanuel-W Date: Mon, 13 Apr 2020 21:12:25 +0300 Subject: [PATCH 07/16] seventh --- src/estimator.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/estimator.php b/src/estimator.php index b8ff655..2e488e9 100644 --- a/src/estimator.php +++ b/src/estimator.php @@ -119,7 +119,7 @@ function dollarsInFlightSevereImpact($infectionsByRequestedTimeSevereImpact) function covid19ImpactEstimator($data) { - $data1 = json_decode($data_json, true); + $data1 = json_decode($data, true); $data = array( 'data' => $data1, 'impact' => array( @@ -143,3 +143,5 @@ function covid19ImpactEstimator($data) ); return $data; } + +covid19ImpactEstimator($data_json); From b85db4dff6e80f51cd6249ce77985f3897fe6c75 Mon Sep 17 00:00:00 2001 From: Emmanuel-W Date: Mon, 13 Apr 2020 21:40:42 +0300 Subject: [PATCH 08/16] eigth --- src/estimator.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/estimator.php b/src/estimator.php index 2e488e9..08f7080 100644 --- a/src/estimator.php +++ b/src/estimator.php @@ -119,7 +119,8 @@ function dollarsInFlightSevereImpact($infectionsByRequestedTimeSevereImpact) function covid19ImpactEstimator($data) { - $data1 = json_decode($data, true); + + $data1 = json_decode((string)$data, true); $data = array( 'data' => $data1, 'impact' => array( From 2bf12eca4113f611b9ffd1a2c45117a2dddfcf02 Mon Sep 17 00:00:00 2001 From: Emmanuel-W Date: Mon, 13 Apr 2020 21:47:56 +0300 Subject: [PATCH 09/16] eigth --- src/estimator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/estimator.php b/src/estimator.php index 08f7080..3153d6a 100644 --- a/src/estimator.php +++ b/src/estimator.php @@ -120,7 +120,7 @@ function dollarsInFlightSevereImpact($infectionsByRequestedTimeSevereImpact) function covid19ImpactEstimator($data) { - $data1 = json_decode((string)$data, true); + $data1 = json_decode((object)$data, true); $data = array( 'data' => $data1, 'impact' => array( From b1d37eea10843736a208636b949f0647f52a6a67 Mon Sep 17 00:00:00 2001 From: Emmanuel-W Date: Mon, 13 Apr 2020 21:56:47 +0300 Subject: [PATCH 10/16] tenth --- src/estimator.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/estimator.php b/src/estimator.php index 3153d6a..bbf56f3 100644 --- a/src/estimator.php +++ b/src/estimator.php @@ -120,7 +120,7 @@ function dollarsInFlightSevereImpact($infectionsByRequestedTimeSevereImpact) function covid19ImpactEstimator($data) { - $data1 = json_decode((object)$data, true); + $data1 = json_decode($data, true); $data = array( 'data' => $data1, 'impact' => array( @@ -142,7 +142,7 @@ function covid19ImpactEstimator($data) 'dollarsInFlight'=>dollarsInFlightSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data1['reportedCases']),$data1['periodType'])), ) ); - return $data; + return json_encode($data); } covid19ImpactEstimator($data_json); From 91d78a4c018d51dc5301f235348e8b3f5b1ca578 Mon Sep 17 00:00:00 2001 From: Emmanuel-W Date: Tue, 14 Apr 2020 21:06:04 +0300 Subject: [PATCH 11/16] Tenth I guess --- src/estimator.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/estimator.php b/src/estimator.php index bbf56f3..956d41b 100644 --- a/src/estimator.php +++ b/src/estimator.php @@ -142,7 +142,5 @@ function covid19ImpactEstimator($data) 'dollarsInFlight'=>dollarsInFlightSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data1['reportedCases']),$data1['periodType'])), ) ); - return json_encode($data); + return $data; } - -covid19ImpactEstimator($data_json); From 99143feb1af6933c0cf745568b0ff4358ca0e629 Mon Sep 17 00:00:00 2001 From: Emmanuel-W Date: Tue, 14 Apr 2020 22:02:30 +0300 Subject: [PATCH 12/16] eleventh --- src/estimator.php | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/src/estimator.php b/src/estimator.php index 956d41b..b2ba95e 100644 --- a/src/estimator.php +++ b/src/estimator.php @@ -121,26 +121,29 @@ function covid19ImpactEstimator($data) { $data1 = json_decode($data, true); + $impact = array( + 'currentlyInfected'=>currentlyInfected($data1['reportedCases']), + 'infectionsByRequestedTime'=>infectionsByRequestedTime(currentlyInfected($data1['reportedCases']),$data1['periodType']), + 'severeCasesByRequestedTime'=>severeCasesByRequestedTime(infectionsByRequestedTime(currentlyInfected($data1['reportedCases']),$data1['periodType'])), + 'hospitalBedsByRequestedTime'=>hospitalBedsByRequestedTime(severeCasesByRequestedTime(infectionsByRequestedTime(currentlyInfected($data1['reportedCases']),$data1['periodType'])),$data1['totalHospitalBeds']), + 'casesForICUByRequestedTime'=>casesForICUByRequestedTime(infectionsByRequestedTime(currentlyInfected($data1['reportedCases']),$data1['periodType'])), + 'casesForVentilatorsByRequestedTime'=>casesForVentilatorsByRequestedTime(infectionsByRequestedTime(currentlyInfected($data1['reportedCases']),$data1['periodType'])), + 'dollarsInFlight'=>dollarsInFlight(infectionsByRequestedTime(currentlyInfected($data1['reportedCases']),$data1['periodType'])), + ); + $severeImpact = array( + 'currentlyInfected'=>currentlyInfectedSevereImpact($data1['reportedCases']), + 'infectionsByRequestedTime'=>infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data1['reportedCases']),$data1['periodType']), + 'severeCasesByRequestedTime'=>severeCasesByRequestedTimeSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data1['reportedCases']),$data1['periodType'])), + 'hospitalBedsByRequestedTime'=>hospitalBedsByRequestedTimeSevereImpact(severeCasesByRequestedTimeSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data1['reportedCases']),$data1['periodType'])),$data1['totalHospitalBeds']), + 'casesForICUByRequestedTime'=>casesForICUByRequestedTimeSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data1['reportedCases']),$data1['periodType'])), + 'casesForVentilatorsByRequestedTime'=>casesForVentilatorsByRequestedTimeSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data1['reportedCases']),$data1['periodType'])), + 'dollarsInFlight'=>dollarsInFlightSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data1['reportedCases']),$data1['periodType'])), + ); + $data = array( 'data' => $data1, - 'impact' => array( - 'currentlyInfected'=>currentlyInfected($data1['reportedCases']), - 'infectionsByRequestedTime'=>infectionsByRequestedTime(currentlyInfected($data1['reportedCases']),$data1['periodType']), - 'severeCasesByRequestedTime'=>severeCasesByRequestedTime(infectionsByRequestedTime(currentlyInfected($data1['reportedCases']),$data1['periodType'])), - 'hospitalBedsByRequestedTime'=>hospitalBedsByRequestedTime(severeCasesByRequestedTime(infectionsByRequestedTime(currentlyInfected($data1['reportedCases']),$data1['periodType'])),$data1['totalHospitalBeds']), - 'casesForICUByRequestedTime'=>casesForICUByRequestedTime(infectionsByRequestedTime(currentlyInfected($data1['reportedCases']),$data1['periodType'])), - 'casesForVentilatorsByRequestedTime'=>casesForVentilatorsByRequestedTime(infectionsByRequestedTime(currentlyInfected($data1['reportedCases']),$data1['periodType'])), - 'dollarsInFlight'=>dollarsInFlight(infectionsByRequestedTime(currentlyInfected($data1['reportedCases']),$data1['periodType'])), - ), - 'severeImpact' => array( - 'currentlyInfected'=>currentlyInfectedSevereImpact($data1['reportedCases']), - 'infectionsByRequestedTime'=>infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data1['reportedCases']),$data1['periodType']), - 'severeCasesByRequestedTime'=>severeCasesByRequestedTimeSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data1['reportedCases']),$data1['periodType'])), - 'hospitalBedsByRequestedTime'=>hospitalBedsByRequestedTimeSevereImpact(severeCasesByRequestedTimeSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data1['reportedCases']),$data1['periodType'])),$data1['totalHospitalBeds']), - 'casesForICUByRequestedTime'=>casesForICUByRequestedTimeSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data1['reportedCases']),$data1['periodType'])), - 'casesForVentilatorsByRequestedTime'=>casesForVentilatorsByRequestedTimeSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data1['reportedCases']),$data1['periodType'])), - 'dollarsInFlight'=>dollarsInFlightSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data1['reportedCases']),$data1['periodType'])), - ) + 'impact' => $impact, + 'severeImpact' => $severeImpact; ); return $data; } From a8363d0fa275821b90b286f03716e5e0948ea6b5 Mon Sep 17 00:00:00 2001 From: Emmanuel-W Date: Tue, 14 Apr 2020 22:04:31 +0300 Subject: [PATCH 13/16] twelveth --- src/estimator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/estimator.php b/src/estimator.php index b2ba95e..b800bbd 100644 --- a/src/estimator.php +++ b/src/estimator.php @@ -143,7 +143,7 @@ function covid19ImpactEstimator($data) $data = array( 'data' => $data1, 'impact' => $impact, - 'severeImpact' => $severeImpact; + 'severeImpact' => $severeImpact, ); return $data; } From 3e68ea24ebb0e8ee2b82cfaea066f809502e1165 Mon Sep 17 00:00:00 2001 From: Emmanuel-W Date: Tue, 14 Apr 2020 22:24:28 +0300 Subject: [PATCH 14/16] Thirteenth --- src/estimator.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/estimator.php b/src/estimator.php index b800bbd..b2d27b5 100644 --- a/src/estimator.php +++ b/src/estimator.php @@ -140,10 +140,10 @@ function covid19ImpactEstimator($data) 'dollarsInFlight'=>dollarsInFlightSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data1['reportedCases']),$data1['periodType'])), ); - $data = array( + + return array( 'data' => $data1, 'impact' => $impact, 'severeImpact' => $severeImpact, ); - return $data; } From 59004f05daa250bc48fe9c2301ff110e634184cc Mon Sep 17 00:00:00 2001 From: Emmanuel-W Date: Tue, 14 Apr 2020 22:34:18 +0300 Subject: [PATCH 15/16] fourteenth --- src/estimator.php | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/estimator.php b/src/estimator.php index b2d27b5..fd3c064 100644 --- a/src/estimator.php +++ b/src/estimator.php @@ -13,6 +13,8 @@ "totalHospitalBeds": 1380614 }'; +$data1 = json_decode($data_json, true); + function currentlyInfected($reportedCases) @@ -120,29 +122,29 @@ function dollarsInFlightSevereImpact($infectionsByRequestedTimeSevereImpact) function covid19ImpactEstimator($data) { - $data1 = json_decode($data, true); + $impact = array( - 'currentlyInfected'=>currentlyInfected($data1['reportedCases']), - 'infectionsByRequestedTime'=>infectionsByRequestedTime(currentlyInfected($data1['reportedCases']),$data1['periodType']), - 'severeCasesByRequestedTime'=>severeCasesByRequestedTime(infectionsByRequestedTime(currentlyInfected($data1['reportedCases']),$data1['periodType'])), - 'hospitalBedsByRequestedTime'=>hospitalBedsByRequestedTime(severeCasesByRequestedTime(infectionsByRequestedTime(currentlyInfected($data1['reportedCases']),$data1['periodType'])),$data1['totalHospitalBeds']), + 'currentlyInfected'=>currentlyInfected($data['reportedCases']), + 'infectionsByRequestedTime'=>infectionsByRequestedTime(currentlyInfected($data['reportedCases']),$data['periodType']), + 'severeCasesByRequestedTime'=>severeCasesByRequestedTime(infectionsByRequestedTime(currentlyInfected($data['reportedCases']),$data['periodType'])), 'casesForICUByRequestedTime'=>casesForICUByRequestedTime(infectionsByRequestedTime(currentlyInfected($data1['reportedCases']),$data1['periodType'])), - 'casesForVentilatorsByRequestedTime'=>casesForVentilatorsByRequestedTime(infectionsByRequestedTime(currentlyInfected($data1['reportedCases']),$data1['periodType'])), - 'dollarsInFlight'=>dollarsInFlight(infectionsByRequestedTime(currentlyInfected($data1['reportedCases']),$data1['periodType'])), + 'hospitalBedsByRequestedTime'=>hospitalBedsByRequestedTime(severeCasesByRequestedTime(infectionsByRequestedTime(currentlyInfected($data['reportedCases']),$data['periodType'])),$data['totalHospitalBeds']), + 'casesForVentilatorsByRequestedTime'=>casesForVentilatorsByRequestedTime(infectionsByRequestedTime(currentlyInfected($data['reportedCases']),$data['periodType'])), + 'dollarsInFlight'=>dollarsInFlight(infectionsByRequestedTime(currentlyInfected($data['reportedCases']),$data['periodType'])), ); $severeImpact = array( - 'currentlyInfected'=>currentlyInfectedSevereImpact($data1['reportedCases']), - 'infectionsByRequestedTime'=>infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data1['reportedCases']),$data1['periodType']), - 'severeCasesByRequestedTime'=>severeCasesByRequestedTimeSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data1['reportedCases']),$data1['periodType'])), - 'hospitalBedsByRequestedTime'=>hospitalBedsByRequestedTimeSevereImpact(severeCasesByRequestedTimeSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data1['reportedCases']),$data1['periodType'])),$data1['totalHospitalBeds']), - 'casesForICUByRequestedTime'=>casesForICUByRequestedTimeSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data1['reportedCases']),$data1['periodType'])), - 'casesForVentilatorsByRequestedTime'=>casesForVentilatorsByRequestedTimeSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data1['reportedCases']),$data1['periodType'])), - 'dollarsInFlight'=>dollarsInFlightSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data1['reportedCases']),$data1['periodType'])), + 'currentlyInfected'=>currentlyInfectedSevereImpact($data['reportedCases']), + 'infectionsByRequestedTime'=>infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data['reportedCases']),$data['periodType']), + 'severeCasesByRequestedTime'=>severeCasesByRequestedTimeSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data['reportedCases']),$data['periodType'])), + 'hospitalBedsByRequestedTime'=>hospitalBedsByRequestedTimeSevereImpact(severeCasesByRequestedTimeSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data['reportedCases']),$data['periodType'])),$data['totalHospitalBeds']), + 'casesForICUByRequestedTime'=>casesForICUByRequestedTimeSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data['reportedCases']),$data['periodType'])), + 'casesForVentilatorsByRequestedTime'=>casesForVentilatorsByRequestedTimeSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data['reportedCases']),$data['periodType'])), + 'dollarsInFlight'=>dollarsInFlightSevereImpact(infectionsByRequestedTimeSevereImpact(currentlyInfectedSevereImpact($data['reportedCases']),$data['periodType'])), ); return array( - 'data' => $data1, + 'data' => $data, 'impact' => $impact, 'severeImpact' => $severeImpact, ); From 1bec2144ef70aa003d50aafe28b42ec44fc7f81b Mon Sep 17 00:00:00 2001 From: Emmanuel-W Date: Tue, 14 Apr 2020 22:39:10 +0300 Subject: [PATCH 16/16] fifteenth --- src/estimator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/estimator.php b/src/estimator.php index fd3c064..e09f00a 100644 --- a/src/estimator.php +++ b/src/estimator.php @@ -127,7 +127,7 @@ function covid19ImpactEstimator($data) 'currentlyInfected'=>currentlyInfected($data['reportedCases']), 'infectionsByRequestedTime'=>infectionsByRequestedTime(currentlyInfected($data['reportedCases']),$data['periodType']), 'severeCasesByRequestedTime'=>severeCasesByRequestedTime(infectionsByRequestedTime(currentlyInfected($data['reportedCases']),$data['periodType'])), - 'casesForICUByRequestedTime'=>casesForICUByRequestedTime(infectionsByRequestedTime(currentlyInfected($data1['reportedCases']),$data1['periodType'])), + 'casesForICUByRequestedTime'=>casesForICUByRequestedTime(infectionsByRequestedTime(currentlyInfected($data['reportedCases']),$data['periodType'])), 'hospitalBedsByRequestedTime'=>hospitalBedsByRequestedTime(severeCasesByRequestedTime(infectionsByRequestedTime(currentlyInfected($data['reportedCases']),$data['periodType'])),$data['totalHospitalBeds']), 'casesForVentilatorsByRequestedTime'=>casesForVentilatorsByRequestedTime(infectionsByRequestedTime(currentlyInfected($data['reportedCases']),$data['periodType'])), 'dollarsInFlight'=>dollarsInFlight(infectionsByRequestedTime(currentlyInfected($data['reportedCases']),$data['periodType'])),