[{"id":"da7d3608.233f08","type":"tab","label":"corona comparison hubei","disabled":false,"info":"node-red-corona-comparison-hubei\n================================\n\n# Description\n\nThis node-red flow is creating a dashboard showing the historical statistics of the corona deaths and corona confirmed cases for the selected country or province/state.\n\nThe statistics are retrieved from [github.com/CSSEGISandData/COVID-19](https://github.com/CSSEGISandData/COVID-19). More precisely it is based on the following 2 files from this github repository:\n - [time_series_covid19_deaths_global.csv](https://github.com/CSSEGISandData/COVID-19/blob/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_deaths_global.csv)\n - [time_series_covid19_confirmed_global.csv](https://github.com/CSSEGISandData/COVID-19/blob/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv)\n\nIt also puts in the same charts the statistics for the province Hubei (China) were the outbreak began. To make comparison easy I have scaled and shifted the chart for Hubei.\n\n## lock down date, hubei date shift and hubei factor\n\nThe time shift (`\"hubei date shift\"`) is determined by the `\"lock down date\"` that you can specify. So the Hubei charts will be shifted so that the lock down date of Hubei (= 23rd of January 2020) falls together with the `\"lock down date\"` you have specified.\n\nThe `\"hubei factor\"` is the factor used to scale the Hubei deaths and Hubei confirmed cases in the charts. The `\"hubei factor\"` is calculated as the ratio of the current total number of deaths for the selected country or province over the total number of deaths in Hubei at corresponding date relative to the start of lock down.\n\n## Smooth hubei charts\n\nIt is also possible to smooth the Hubei data in the charts by clicking on the `\"smooth Hubei charts\"` toggle button. When activated it has the following effect on the Hubei:\n1. The new confirmed cases for days 12, 13 and 14 of February 2020 have been replaced by _interpolated_ values. This is to get rid of the big spike caused due to the new way of testing at that time.\n2. furthermore the new confirmed cases andnew deatsh for Hubei have been smoothed by taking a weighted running average of 3 points. So the smoothed value for point i is calculated as 50% of value of point i + 25% of the values of point i-1 and point i+1.\n3. total deaths and total confirmed cases are recalculated based on smoothed new deaths and smoothed new confirmed cases (see points 1 and 2)\n\nTip: you can also clearly visualize the effect of smoothing by selecting as country \"China\" and as province/state \"Hubei\" and then activating the `smooth Hubei charts` toggle button\n\n## Add todays data\n\nThe source for the charts is only updated once a day. In other words clicking on the button `\"retrieve data from github\"` a second time during the same day won't make a difference. So it might mean that the charts don't show the latest available information for the selected country. In that case it is possible to manually add latest information using the form `\"Add todays data for selected country/region\"` that you find at the bottom of your screen. Note that this information is not persisted, so it is lost when redeploying the node-red flow or when clicking on `\"retrieve data from github\"`.\n\n# Examples\n\nSee Node-RED forum thread: [Corona country comparison with Hubei (China)](https://discourse.nodered.org/t/flow-corona-country-comparison-with-hubei-china/23237)\n\n# (First time) Usage\n\nAt startup this flow will read the statistics from a local file `\"covid.json\"`. The very first time this local file does not exist and an error message is reported in the dashboard (this is normal).\nSo in that case you must retrieve the data from Github by clicking on the button `retrieve data from github`.\nNote that this takes several minutes. You will even loose your browser connection. This is expected. Just be patient and you will be automatically reconnected. If everything is fine then this data is also stored in the local file.\n\nFYI it is not the retrieving that takes a lot of time but converting the data to proper json structure that is time consuming.\n\nOnce the data is retrieved, you can select the `country`, `province/state` and `lock down date` and the charts will automatically be updated.\n\nYou can always refresh the data with the latest available data from github by clicking on the button (but as said this takes several minutes).\n"},{"id":"eb3e18e.d4e24e8","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"a31f3c67.3e6a2","type":"ui_group","z":"","name":"charts","tab":"dfd19edc.c94e2","order":5,"disp":false,"width":27,"collapse":false},{"id":"935635d4.d4b018","type":"ui_group","z":"","name":"Location1","tab":"dfd19edc.c94e2","order":2,"disp":true,"width":"12","collapse":false},{"id":"22d37c26.1207a4","type":"ui_group","z":"","name":"retrieve and process covid data","tab":"dfd19edc.c94e2","order":1,"disp":false,"width":"27","collapse":false},{"id":"dfd19edc.c94e2","type":"ui_tab","z":"","name":"corona-evolution","icon":"dashboard","disabled":false,"hidden":false},{"id":"7b3e6c52.f55654","type":"ui_base","theme":{"name":"theme-light","lightTheme":{"default":"#0094CE","baseColor":"#0094CE","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif","edited":true,"reset":false},"darkTheme":{"default":"#097479","baseColor":"#097479","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif","edited":false},"customTheme":{"name":"Untitled Theme 1","default":"#4B7930","baseColor":"#4B7930","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"},"themeState":{"base-color":{"default":"#0094CE","value":"#0094CE","edited":false},"page-titlebar-backgroundColor":{"value":"#0094CE","edited":false},"page-backgroundColor":{"value":"#fafafa","edited":false},"page-sidebar-backgroundColor":{"value":"#ffffff","edited":false},"group-textColor":{"value":"#1bbfff","edited":false},"group-borderColor":{"value":"#ffffff","edited":false},"group-backgroundColor":{"value":"#ffffff","edited":false},"widget-textColor":{"value":"#111111","edited":false},"widget-backgroundColor":{"value":"#0094ce","edited":false},"widget-borderColor":{"value":"#ffffff","edited":false},"base-font":{"value":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"}},"angularTheme":{"primary":"indigo","accents":"blue","warn":"red","background":"grey"}},"site":{"name":"Node-RED Dashboard","hideToolbar":"true","allowSwipe":"false","lockMenu":"false","allowTempTheme":"true","dateFormat":"DD/MM/YYYY","sizes":{"sx":48,"sy":48,"gx":6,"gy":6,"cx":6,"cy":6,"px":0,"py":0}}},{"id":"6b90da1c.04f984","type":"ui_group","z":"","name":"Add new data for Location1","tab":"dfd19edc.c94e2","order":6,"disp":true,"width":"8","collapse":false},{"id":"bef9dde3.0058a","type":"ui_group","z":"","name":"Location2","tab":"dfd19edc.c94e2","order":3,"disp":true,"width":"12","collapse":false},{"id":"ce673549.1ea3f8","type":"ui_group","z":"","name":"Update charts","tab":"dfd19edc.c94e2","order":4,"disp":false,"width":"20","collapse":false},{"id":"ebbf9e2d.8e452","type":"inject","z":"da7d3608.233f08","name":"","repeat":"","crontab":"","once":false,"onceDelay":"0.2","topic":"","payload":"","payloadType":"date","x":100,"y":60,"wires":[["90a4cc34.50154"]]},{"id":"ec5b1bb0.7da778","type":"exec","z":"da7d3608.233f08","command":"curl -L https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"get time_series covid confirmed","x":250,"y":260,"wires":[["897eb31d.aaebe","3f2e70af.58e2f"],[],[]]},{"id":"897eb31d.aaebe","type":"debug","z":"da7d3608.233f08","name":"get time_series covid confirmed","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1010,"y":240,"wires":[]},{"id":"e11cff08.91ad2","type":"csv","z":"da7d3608.233f08","name":"csv2array","sep":",","hdrin":true,"hdrout":"","multi":"mult","ret":"\\n","temp":"","skip":"0","strings":true,"x":560,"y":320,"wires":[["a70f5101.b3484","593ca514.902dcc","cac97ba7.7aa1c8"]]},{"id":"3f2e70af.58e2f","type":"switch","z":"da7d3608.233f08","name":"return code ok ?","property":"rc.code","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":580,"y":280,"wires":[["e11cff08.91ad2","32b650ff.aaf6a"]]},{"id":"c3eef553.76d088","type":"ui_chart","z":"da7d3608.233f08","name":"","group":"a31f3c67.3e6a2","order":7,"width":9,"height":7,"label":"total confirmed cases","chartType":"line","legend":"true","xformat":"D/M","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#008f00","#0433ff","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":920,"y":2040,"wires":[["d5a617cb.df3688"]]},{"id":"f39294ca.4ff928","type":"change","z":"da7d3608.233f08","name":"prepare confirmed cases chart","rules":[{"t":"set","p":"payload","pt":"msg","to":"(\t /* graph starts from (lock_down_date - 1 week) */\t $location2_timeshift_ms := location2_timeshift_ms;\t $location2_death_factor := location2_death_factor;\t $start_x := $toMillis(lock_down_date1,\"[M]/[D]/[Y]\")-(7*24*60*60*1000);\t [{ \t \"series\": [ location_id1, location_id2 \t & (($location2_timeshift_ms !=0) and ($location2_death_factor = 1)?'- shifted':'')\t & (($location2_timeshift_ms = 0) and ($location2_death_factor !=1)?'- scaled':'')\t & (($location2_timeshift_ms !=0) and ($location2_death_factor !=1)?'- shifted and scaled':'')],\t \"data\" : [ \t [$map(location1.total_confirmed_cases,\t function($v, $i, $a) { { \"x\": $v.date_ms, \t \"y\": $v.value } } )[x >= $start_x]]\t ,\t [$map(location2.total_confirmed_cases,\t function($v, $i, $a) { { \"x\": $v.date_ms + $location2_timeshift_ms, \t \"y\": $v.value * $location2_death_factor } } )[x >= $start_x]]\t ],\t \"labels\": [\"\"]\t }]\t)\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":530,"y":2040,"wires":[["c3eef553.76d088","4907ad01.9cf104"]]},{"id":"d5a617cb.df3688","type":"debug","z":"da7d3608.233f08","name":"chart output","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1150,"y":2040,"wires":[]},{"id":"4c4cf2d5.a478fc","type":"ui_dropdown","z":"da7d3608.233f08","name":"select country1","label":"country","tooltip":"","place":"Select option","group":"935635d4.d4b018","order":1,"width":"5","height":1,"passthru":true,"options":[{"label":"","value":"","type":"str"}],"payload":"","topic":"","x":900,"y":1140,"wires":[["4b7d4b8a.c2b754"]]},{"id":"3d46854a.1b12da","type":"change","z":"da7d3608.233f08","name":"msg.options = country list","rules":[{"t":"set","p":"options","pt":"msg","to":"covid.total_deaths.country_region ~> $distinct ~> $sort\t/*\t{\t \"covid\": {\t \"total_deaths\": [\t {\t \"location_id\": \"Thailand:\",\t \"country_region\": \"Thailand\",\t \"latitude\": 15,\t \"longitude\": 101,\t \"history\": [\t {\t \"date\": \"1/22/2020\",\t \"date_ms\": 1579651200000,\t \"value\": 2\t },\t {\t \"date\": \"1/23/2020\",\t \"date_ms\": 1579737600000,\t \"value\": 3\t },\t {\t \"date\": \"1/24/2020\",\t \"date_ms\": 1579824000000,\t \"value\": 5\t },\t {\t \"date\": \"1/25/2020\",\t \"date_ms\": 1579910400000,\t \"value\": 7\t },\t {\t \"date\": \"1/26/2020\",\t \"date_ms\": 1579996800000,\t \"value\": 8\t },\t {\t \"date\": \"1/27/2020\",\t \"date_ms\": 1580083200000,\t \"value\": 8\t },\t {\t \"date\": \"1/28/2020\",\t \"date_ms\": 1580169600000,\t \"value\": 14\t },\t {\t \"date\": \"1/29/2020\",\t \"date_ms\": 1580256000000,\t \"value\": 14\t },\t {\t \"date\": \"1/30/2020\",\t \"date_ms\": 1580342400000,\t \"value\": 14\t },\t {\t \"date\": \"1/31/2020\",\t \"date_ms\": 1580428800000,\t \"value\": 19\t },\t {\t \"date\": \"2/1/2020\",\t \"date_ms\": 1580515200000,\t \"value\": 19\t },\t {\t \"date\": \"2/2/2020\",\t \"date_ms\": 1580601600000,\t \"value\": 19\t },\t {\t \"date\": \"2/3/2020\",\t \"date_ms\": 1580688000000,\t \"value\": 19\t },\t {\t \"date\": \"2/4/2020\",\t \"date_ms\": 1580774400000,\t \"value\": 25\t }\t ]\t },\t {\t \"location_id\": \"Australia:New South Wales\",\t \"country_region\": \"Australia\",\t \"province_state\": \"New South Wales\",\t \"latitude\": -33.8688,\t \"longitude\": 151.2093,\t \"history\": [\t {\t \"date\": \"1/22/2020\",\t \"date_ms\": 1579651200000,\t \"value\": 0\t },\t {\t \"date\": \"1/23/2020\",\t \"date_ms\": 1579737600000,\t \"value\": 0\t },\t {\t \"date\": \"1/24/2020\",\t \"date_ms\": 1579824000000,\t \"value\": 0\t },\t {\t \"date\": \"1/25/2020\",\t \"date_ms\": 1579910400000,\t \"value\": 0\t },\t {\t \"date\": \"1/26/2020\",\t \"date_ms\": 1579996800000,\t \"value\": 3\t },\t {\t \"date\": \"1/27/2020\",\t \"date_ms\": 1580083200000,\t \"value\": 4\t },\t {\t \"date\": \"1/28/2020\",\t \"date_ms\": 1580169600000,\t \"value\": 4\t },\t {\t \"date\": \"1/29/2020\",\t \"date_ms\": 1580256000000,\t \"value\": 4\t },\t {\t \"date\": \"1/30/2020\",\t \"date_ms\": 1580342400000,\t \"value\": 4\t },\t {\t \"date\": \"1/31/2020\",\t \"date_ms\": 1580428800000,\t \"value\": 4\t },\t {\t \"date\": \"2/1/2020\",\t \"date_ms\": 1580515200000,\t \"value\": 4\t },\t {\t \"date\": \"2/2/2020\",\t \"date_ms\": 1580601600000,\t \"value\": 4\t },\t {\t \"date\": \"2/3/2020\",\t \"date_ms\": 1580688000000,\t \"value\": 4\t },\t {\t \"date\": \"2/4/2020\",\t \"date_ms\": 1580774400000,\t \"value\": 4\t }\t ]\t }\t ],\t \"total_confirmed_cases\": [\t {\t \"location_id\": \"Thailand:\",\t \"country_region\": \"Thailand\",\t \"latitude\": 15,\t \"longitude\": 101,\t \"history\": [\t {\t \"date\": \"1/22/2020\",\t \"date_ms\": 1579651200000,\t \"value\": 2\t },\t {\t \"date\": \"1/23/2020\",\t \"date_ms\": 1579737600000,\t \"value\": 3\t },\t {\t \"date\": \"1/24/2020\",\t \"date_ms\": 1579824000000,\t \"value\": 5\t },\t {\t \"date\": \"1/25/2020\",\t \"date_ms\": 1579910400000,\t \"value\": 7\t },\t {\t \"date\": \"1/26/2020\",\t \"date_ms\": 1579996800000,\t \"value\": 8\t },\t {\t \"date\": \"1/27/2020\",\t \"date_ms\": 1580083200000,\t \"value\": 8\t },\t {\t \"date\": \"1/28/2020\",\t \"date_ms\": 1580169600000,\t \"value\": 14\t },\t {\t \"date\": \"1/29/2020\",\t \"date_ms\": 1580256000000,\t \"value\": 14\t },\t {\t \"date\": \"1/30/2020\",\t \"date_ms\": 1580342400000,\t \"value\": 14\t },\t {\t \"date\": \"1/31/2020\",\t \"date_ms\": 1580428800000,\t \"value\": 19\t },\t {\t \"date\": \"2/1/2020\",\t \"date_ms\": 1580515200000,\t \"value\": 19\t },\t {\t \"date\": \"2/2/2020\",\t \"date_ms\": 1580601600000,\t \"value\": 19\t },\t {\t \"date\": \"2/3/2020\",\t \"date_ms\": 1580688000000,\t \"value\": 19\t },\t {\t \"date\": \"2/4/2020\",\t \"date_ms\": 1580774400000,\t \"value\": 25\t }\t ]\t },\t {\t \"location_id\": \"Australia:New South Wales\",\t \"country_region\": \"Australia\",\t \"province_state\": \"New South Wales\",\t \"latitude\": -33.8688,\t \"longitude\": 151.2093,\t \"history\": [\t {\t \"date\": \"1/22/2020\",\t \"date_ms\": 1579651200000,\t \"value\": 0\t },\t {\t \"date\": \"1/23/2020\",\t \"date_ms\": 1579737600000,\t \"value\": 0\t },\t {\t \"date\": \"1/24/2020\",\t \"date_ms\": 1579824000000,\t \"value\": 0\t },\t {\t \"date\": \"1/25/2020\",\t \"date_ms\": 1579910400000,\t \"value\": 0\t },\t {\t \"date\": \"1/26/2020\",\t \"date_ms\": 1579996800000,\t \"value\": 3\t },\t {\t \"date\": \"1/27/2020\",\t \"date_ms\": 1580083200000,\t \"value\": 4\t },\t {\t \"date\": \"1/28/2020\",\t \"date_ms\": 1580169600000,\t \"value\": 4\t },\t {\t \"date\": \"1/29/2020\",\t \"date_ms\": 1580256000000,\t \"value\": 4\t },\t {\t \"date\": \"1/30/2020\",\t \"date_ms\": 1580342400000,\t \"value\": 4\t },\t {\t \"date\": \"1/31/2020\",\t \"date_ms\": 1580428800000,\t \"value\": 4\t },\t {\t \"date\": \"2/1/2020\",\t \"date_ms\": 1580515200000,\t \"value\": 4\t },\t {\t \"date\": \"2/2/2020\",\t \"date_ms\": 1580601600000,\t \"value\": 4\t },\t {\t \"date\": \"2/3/2020\",\t \"date_ms\": 1580688000000,\t \"value\": 4\t },\t {\t \"date\": \"2/4/2020\",\t \"date_ms\": 1580774400000,\t \"value\": 4\t }\t ]\t }\t ]\t }\t}\t*/","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":390,"y":1100,"wires":[["3c40c5b2.e3afca","cc025d1e.8ac83","572424cb.d7435c"]]},{"id":"70989403.b51d8c","type":"debug","z":"da7d3608.233f08","name":"flow.selected_country","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1440,"y":1140,"wires":[]},{"id":"bed0fd9.5b2ab","type":"debug","z":"da7d3608.233f08","name":"copied flow to location1 and location2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":950,"y":1620,"wires":[]},{"id":"38ff5c00.6b79d4","type":"ui_dropdown","z":"da7d3608.233f08","name":"select lock down date1","label":"lock down date","tooltip":"Date drastic measures are taken to reduce spread of virus","place":"Select option","group":"935635d4.d4b018","order":3,"width":"7","height":1,"passthru":true,"options":[{"label":"","value":"","type":"str"}],"payload":"","topic":"","x":930,"y":1420,"wires":[["82cb217a.94e9b"]]},{"id":"fac7b993.b120a8","type":"change","z":"da7d3608.233f08","name":"msg.options = date list","rules":[{"t":"set","p":"options","pt":"msg","to":"covid.total_deaths[0].history.date\t/*\tinput example:\t\t{\t \"selected_country\" : \"Thailand\",\t \"covid\": {\t \"total_deaths\": [\t {\t \"location_id\": \"Thailand:\",\t \"country_region\": \"Thailand\",\t \"province_state\": \"state 1 of Thailand\",\t \"latitude\": 15,\t \"longitude\": 101,\t \"history\": [\t {\t \"date\": \"1/22/2020\",\t \"date_ms\": 1579651200000,\t \"value\": 2\t },\t {\t \"date\": \"1/23/2020\",\t \"date_ms\": 1579737600000,\t \"value\": 3\t },\t {\t \"date\": \"1/24/2020\",\t \"date_ms\": 1579824000000,\t \"value\": 5\t },\t {\t \"date\": \"1/25/2020\",\t \"date_ms\": 1579910400000,\t \"value\": 7\t },\t {\t \"date\": \"1/26/2020\",\t \"date_ms\": 1579996800000,\t \"value\": 8\t },\t {\t \"date\": \"1/27/2020\",\t \"date_ms\": 1580083200000,\t \"value\": 8\t },\t {\t \"date\": \"1/28/2020\",\t \"date_ms\": 1580169600000,\t \"value\": 14\t },\t {\t \"date\": \"1/29/2020\",\t \"date_ms\": 1580256000000,\t \"value\": 14\t },\t {\t \"date\": \"1/30/2020\",\t \"date_ms\": 1580342400000,\t \"value\": 14\t },\t {\t \"date\": \"1/31/2020\",\t \"date_ms\": 1580428800000,\t \"value\": 19\t },\t {\t \"date\": \"2/1/2020\",\t \"date_ms\": 1580515200000,\t \"value\": 19\t },\t {\t \"date\": \"2/2/2020\",\t \"date_ms\": 1580601600000,\t \"value\": 19\t },\t {\t \"date\": \"2/3/2020\",\t \"date_ms\": 1580688000000,\t \"value\": 19\t },\t {\t \"date\": \"2/4/2020\",\t \"date_ms\": 1580774400000,\t \"value\": 25\t }\t ]\t },\t {\t \"location_id\": \"Australia:New South Wales\",\t \"country_region\": \"Australia\",\t \"province_state\": \"New South Wales\",\t \"latitude\": -33.8688,\t \"longitude\": 151.2093,\t \"history\": [\t {\t \"date\": \"1/22/2020\",\t \"date_ms\": 1579651200000,\t \"value\": 0\t },\t {\t \"date\": \"1/23/2020\",\t \"date_ms\": 1579737600000,\t \"value\": 0\t },\t {\t \"date\": \"1/24/2020\",\t \"date_ms\": 1579824000000,\t \"value\": 0\t },\t {\t \"date\": \"1/25/2020\",\t \"date_ms\": 1579910400000,\t \"value\": 0\t },\t {\t \"date\": \"1/26/2020\",\t \"date_ms\": 1579996800000,\t \"value\": 3\t },\t {\t \"date\": \"1/27/2020\",\t \"date_ms\": 1580083200000,\t \"value\": 4\t },\t {\t \"date\": \"1/28/2020\",\t \"date_ms\": 1580169600000,\t \"value\": 4\t },\t {\t \"date\": \"1/29/2020\",\t \"date_ms\": 1580256000000,\t \"value\": 4\t },\t {\t \"date\": \"1/30/2020\",\t \"date_ms\": 1580342400000,\t \"value\": 4\t },\t {\t \"date\": \"1/31/2020\",\t \"date_ms\": 1580428800000,\t \"value\": 4\t },\t {\t \"date\": \"2/1/2020\",\t \"date_ms\": 1580515200000,\t \"value\": 4\t },\t {\t \"date\": \"2/2/2020\",\t \"date_ms\": 1580601600000,\t \"value\": 4\t },\t {\t \"date\": \"2/3/2020\",\t \"date_ms\": 1580688000000,\t \"value\": 4\t },\t {\t \"date\": \"2/4/2020\",\t \"date_ms\": 1580774400000,\t \"value\": 4\t }\t ]\t }\t ],\t \"total_confirmed_cases\": [\t {\t \"location_id\": \"Thailand:\",\t \"country_region\": \"Thailand\",\t \"latitude\": 15,\t \"longitude\": 101,\t \"history\": [\t {\t \"date\": \"1/22/2020\",\t \"date_ms\": 1579651200000,\t \"value\": 2\t },\t {\t \"date\": \"1/23/2020\",\t \"date_ms\": 1579737600000,\t \"value\": 3\t },\t {\t \"date\": \"1/24/2020\",\t \"date_ms\": 1579824000000,\t \"value\": 5\t },\t {\t \"date\": \"1/25/2020\",\t \"date_ms\": 1579910400000,\t \"value\": 7\t },\t {\t \"date\": \"1/26/2020\",\t \"date_ms\": 1579996800000,\t \"value\": 8\t },\t {\t \"date\": \"1/27/2020\",\t \"date_ms\": 1580083200000,\t \"value\": 8\t },\t {\t \"date\": \"1/28/2020\",\t \"date_ms\": 1580169600000,\t \"value\": 14\t },\t {\t \"date\": \"1/29/2020\",\t \"date_ms\": 1580256000000,\t \"value\": 14\t },\t {\t \"date\": \"1/30/2020\",\t \"date_ms\": 1580342400000,\t \"value\": 14\t },\t {\t \"date\": \"1/31/2020\",\t \"date_ms\": 1580428800000,\t \"value\": 19\t },\t {\t \"date\": \"2/1/2020\",\t \"date_ms\": 1580515200000,\t \"value\": 19\t },\t {\t \"date\": \"2/2/2020\",\t \"date_ms\": 1580601600000,\t \"value\": 19\t },\t {\t \"date\": \"2/3/2020\",\t \"date_ms\": 1580688000000,\t \"value\": 19\t },\t {\t \"date\": \"2/4/2020\",\t \"date_ms\": 1580774400000,\t \"value\": 25\t }\t ]\t },\t {\t \"location_id\": \"Australia:New South Wales\",\t \"country_region\": \"Australia\",\t \"province_state\": \"New South Wales\",\t \"latitude\": -33.8688,\t \"longitude\": 151.2093,\t \"history\": [\t {\t \"date\": \"1/22/2020\",\t \"date_ms\": 1579651200000,\t \"value\": 0\t },\t {\t \"date\": \"1/23/2020\",\t \"date_ms\": 1579737600000,\t \"value\": 0\t },\t {\t \"date\": \"1/24/2020\",\t \"date_ms\": 1579824000000,\t \"value\": 0\t },\t {\t \"date\": \"1/25/2020\",\t \"date_ms\": 1579910400000,\t \"value\": 0\t },\t {\t \"date\": \"1/26/2020\",\t \"date_ms\": 1579996800000,\t \"value\": 3\t },\t {\t \"date\": \"1/27/2020\",\t \"date_ms\": 1580083200000,\t \"value\": 4\t },\t {\t \"date\": \"1/28/2020\",\t \"date_ms\": 1580169600000,\t \"value\": 4\t },\t {\t \"date\": \"1/29/2020\",\t \"date_ms\": 1580256000000,\t \"value\": 4\t },\t {\t \"date\": \"1/30/2020\",\t \"date_ms\": 1580342400000,\t \"value\": 4\t },\t {\t \"date\": \"1/31/2020\",\t \"date_ms\": 1580428800000,\t \"value\": 4\t },\t {\t \"date\": \"2/1/2020\",\t \"date_ms\": 1580515200000,\t \"value\": 4\t },\t {\t \"date\": \"2/2/2020\",\t \"date_ms\": 1580601600000,\t \"value\": 4\t },\t {\t \"date\": \"2/3/2020\",\t \"date_ms\": 1580688000000,\t \"value\": 4\t },\t {\t \"date\": \"2/4/2020\",\t \"date_ms\": 1580774400000,\t \"value\": 4\t }\t ]\t }\t ]\t }\t}\t*/","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":1400,"wires":[["27e465f3.ab346a","657155ef.49631c"]]},{"id":"4b7d4b8a.c2b754","type":"change","z":"da7d3608.233f08","name":"","rules":[{"t":"set","p":"country1","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1150,"y":1140,"wires":[["70989403.b51d8c","d1b6a9c1.a23b18"]]},{"id":"82cb217a.94e9b","type":"change","z":"da7d3608.233f08","name":"","rules":[{"t":"set","p":"lock_down_date1","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1230,"y":1420,"wires":[[]]},{"id":"b3c468f5.310988","type":"ui_dropdown","z":"da7d3608.233f08","name":"select province/state1","label":"state","tooltip":"","place":"Select option","group":"935635d4.d4b018","order":2,"width":"5","height":1,"passthru":true,"options":[{"label":"","value":"","type":"str"}],"payload":"","topic":"","x":940,"y":1280,"wires":[["ffbd353b.9fccc8"]]},{"id":"d1b6a9c1.a23b18","type":"change","z":"da7d3608.233f08","name":"msg.options = province/state list for selected country1","rules":[{"t":"set","p":"selected_country","pt":"msg","to":"country1","tot":"flow"},{"t":"set","p":"covid","pt":"msg","to":"covid","tot":"flow"},{"t":"set","p":"options","pt":"msg","to":"(\t $country := selected_country;\t $locations_list := covid.total_deaths[country_region= $country ].province_state ~> $append( \"\") ~> $distinct ~> $sort ;\t ( $exists($locations_list) ? $locations_list : [ \"\" ] )\t)\t/*\tinput example:\t{\t \"selected_country\" : \"Thailand\",\t \"covid\": {\t \"total_deaths\": [\t {\t \"location_id\": \"Thailand:\",\t \"country_region\": \"Thailand\",\t \"province_state\": \"state 1 of Thailand\",\t \"latitude\": 15,\t \"longitude\": 101,\t \"history\": [\t {\t \"date\": \"1/22/2020\",\t \"date_ms\": 1579651200000,\t \"value\": 2\t },\t {\t \"date\": \"1/23/2020\",\t \"date_ms\": 1579737600000,\t \"value\": 3\t },\t {\t \"date\": \"1/24/2020\",\t \"date_ms\": 1579824000000,\t \"value\": 5\t },\t {\t \"date\": \"1/25/2020\",\t \"date_ms\": 1579910400000,\t \"value\": 7\t },\t {\t \"date\": \"1/26/2020\",\t \"date_ms\": 1579996800000,\t \"value\": 8\t },\t {\t \"date\": \"1/27/2020\",\t \"date_ms\": 1580083200000,\t \"value\": 8\t },\t {\t \"date\": \"1/28/2020\",\t \"date_ms\": 1580169600000,\t \"value\": 14\t },\t {\t \"date\": \"1/29/2020\",\t \"date_ms\": 1580256000000,\t \"value\": 14\t },\t {\t \"date\": \"1/30/2020\",\t \"date_ms\": 1580342400000,\t \"value\": 14\t },\t {\t \"date\": \"1/31/2020\",\t \"date_ms\": 1580428800000,\t \"value\": 19\t },\t {\t \"date\": \"2/1/2020\",\t \"date_ms\": 1580515200000,\t \"value\": 19\t },\t {\t \"date\": \"2/2/2020\",\t \"date_ms\": 1580601600000,\t \"value\": 19\t },\t {\t \"date\": \"2/3/2020\",\t \"date_ms\": 1580688000000,\t \"value\": 19\t },\t {\t \"date\": \"2/4/2020\",\t \"date_ms\": 1580774400000,\t \"value\": 25\t }\t ]\t },\t {\t \"location_id\": \"Australia:New South Wales\",\t \"country_region\": \"Australia\",\t \"province_state\": \"New South Wales\",\t \"latitude\": -33.8688,\t \"longitude\": 151.2093,\t \"history\": [\t {\t \"date\": \"1/22/2020\",\t \"date_ms\": 1579651200000,\t \"value\": 0\t },\t {\t \"date\": \"1/23/2020\",\t \"date_ms\": 1579737600000,\t \"value\": 0\t },\t {\t \"date\": \"1/24/2020\",\t \"date_ms\": 1579824000000,\t \"value\": 0\t },\t {\t \"date\": \"1/25/2020\",\t \"date_ms\": 1579910400000,\t \"value\": 0\t },\t {\t \"date\": \"1/26/2020\",\t \"date_ms\": 1579996800000,\t \"value\": 3\t },\t {\t \"date\": \"1/27/2020\",\t \"date_ms\": 1580083200000,\t \"value\": 4\t },\t {\t \"date\": \"1/28/2020\",\t \"date_ms\": 1580169600000,\t \"value\": 4\t },\t {\t \"date\": \"1/29/2020\",\t \"date_ms\": 1580256000000,\t \"value\": 4\t },\t {\t \"date\": \"1/30/2020\",\t \"date_ms\": 1580342400000,\t \"value\": 4\t },\t {\t \"date\": \"1/31/2020\",\t \"date_ms\": 1580428800000,\t \"value\": 4\t },\t {\t \"date\": \"2/1/2020\",\t \"date_ms\": 1580515200000,\t \"value\": 4\t },\t {\t \"date\": \"2/2/2020\",\t \"date_ms\": 1580601600000,\t \"value\": 4\t },\t {\t \"date\": \"2/3/2020\",\t \"date_ms\": 1580688000000,\t \"value\": 4\t },\t {\t \"date\": \"2/4/2020\",\t \"date_ms\": 1580774400000,\t \"value\": 4\t }\t ]\t }\t ],\t \"total_confirmed_cases\": [\t {\t \"location_id\": \"Thailand:\",\t \"country_region\": \"Thailand\",\t \"latitude\": 15,\t \"longitude\": 101,\t \"history\": [\t {\t \"date\": \"1/22/2020\",\t \"date_ms\": 1579651200000,\t \"value\": 2\t },\t {\t \"date\": \"1/23/2020\",\t \"date_ms\": 1579737600000,\t \"value\": 3\t },\t {\t \"date\": \"1/24/2020\",\t \"date_ms\": 1579824000000,\t \"value\": 5\t },\t {\t \"date\": \"1/25/2020\",\t \"date_ms\": 1579910400000,\t \"value\": 7\t },\t {\t \"date\": \"1/26/2020\",\t \"date_ms\": 1579996800000,\t \"value\": 8\t },\t {\t \"date\": \"1/27/2020\",\t \"date_ms\": 1580083200000,\t \"value\": 8\t },\t {\t \"date\": \"1/28/2020\",\t \"date_ms\": 1580169600000,\t \"value\": 14\t },\t {\t \"date\": \"1/29/2020\",\t \"date_ms\": 1580256000000,\t \"value\": 14\t },\t {\t \"date\": \"1/30/2020\",\t \"date_ms\": 1580342400000,\t \"value\": 14\t },\t {\t \"date\": \"1/31/2020\",\t \"date_ms\": 1580428800000,\t \"value\": 19\t },\t {\t \"date\": \"2/1/2020\",\t \"date_ms\": 1580515200000,\t \"value\": 19\t },\t {\t \"date\": \"2/2/2020\",\t \"date_ms\": 1580601600000,\t \"value\": 19\t },\t {\t \"date\": \"2/3/2020\",\t \"date_ms\": 1580688000000,\t \"value\": 19\t },\t {\t \"date\": \"2/4/2020\",\t \"date_ms\": 1580774400000,\t \"value\": 25\t }\t ]\t },\t {\t \"location_id\": \"Australia:New South Wales\",\t \"country_region\": \"Australia\",\t \"province_state\": \"New South Wales\",\t \"latitude\": -33.8688,\t \"longitude\": 151.2093,\t \"history\": [\t {\t \"date\": \"1/22/2020\",\t \"date_ms\": 1579651200000,\t \"value\": 0\t },\t {\t \"date\": \"1/23/2020\",\t \"date_ms\": 1579737600000,\t \"value\": 0\t },\t {\t \"date\": \"1/24/2020\",\t \"date_ms\": 1579824000000,\t \"value\": 0\t },\t {\t \"date\": \"1/25/2020\",\t \"date_ms\": 1579910400000,\t \"value\": 0\t },\t {\t \"date\": \"1/26/2020\",\t \"date_ms\": 1579996800000,\t \"value\": 3\t },\t {\t \"date\": \"1/27/2020\",\t \"date_ms\": 1580083200000,\t \"value\": 4\t },\t {\t \"date\": \"1/28/2020\",\t \"date_ms\": 1580169600000,\t \"value\": 4\t },\t {\t \"date\": \"1/29/2020\",\t \"date_ms\": 1580256000000,\t \"value\": 4\t },\t {\t \"date\": \"1/30/2020\",\t \"date_ms\": 1580342400000,\t \"value\": 4\t },\t {\t \"date\": \"1/31/2020\",\t \"date_ms\": 1580428800000,\t \"value\": 4\t },\t {\t \"date\": \"2/1/2020\",\t \"date_ms\": 1580515200000,\t \"value\": 4\t },\t {\t \"date\": \"2/2/2020\",\t \"date_ms\": 1580601600000,\t \"value\": 4\t },\t {\t \"date\": \"2/3/2020\",\t \"date_ms\": 1580688000000,\t \"value\": 4\t },\t {\t \"date\": \"2/4/2020\",\t \"date_ms\": 1580774400000,\t \"value\": 4\t }\t ]\t }\t ]\t }\t}\t*/","tot":"jsonata"},{"t":"set","p":"payload","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":1280,"wires":[["b3c468f5.310988","94379557.3bcde8"]]},{"id":"ffbd353b.9fccc8","type":"change","z":"da7d3608.233f08","name":"","rules":[{"t":"set","p":"province_state1","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1230,"y":1280,"wires":[["76e9e0b2.4ded"]]},{"id":"76e9e0b2.4ded","type":"debug","z":"da7d3608.233f08","name":"flow.selected_province_state","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1500,"y":1280,"wires":[]},{"id":"90a4cc34.50154","type":"exec","z":"da7d3608.233f08","command":"curl -L https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_deaths_global.csv","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"get time_series covid deaths","x":240,"y":120,"wires":[["ced45051.634b5","a7d0f1f3.98b44"],[],[]]},{"id":"ced45051.634b5","type":"debug","z":"da7d3608.233f08","name":"get time_series covid deaths","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1000,"y":100,"wires":[]},{"id":"a7d0f1f3.98b44","type":"switch","z":"da7d3608.233f08","name":"return code ok ?","property":"rc.code","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":580,"y":120,"wires":[["3a334c0f.26db44","13b09d87.5a3312"]]},{"id":"6ea5c40f.d3fc3c","type":"ui_chart","z":"da7d3608.233f08","name":"","group":"a31f3c67.3e6a2","order":5,"width":9,"height":7,"label":"total deaths","chartType":"line","legend":"true","xformat":"D/M","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#008f00","#0433ff","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":890,"y":2080,"wires":[[]]},{"id":"4907ad01.9cf104","type":"change","z":"da7d3608.233f08","name":"prepare total deaths chart","rules":[{"t":"set","p":"payload","pt":"msg","to":"(\t /* graph starts from (lock_down_date - 1 week) */\t $location2_timeshift_ms := location2_timeshift_ms;\t $location2_death_factor := location2_death_factor;\t $start_x := $toMillis(lock_down_date1,\"[M]/[D]/[Y]\")-(7*24*60*60*1000);\t [{ \t\"series\": [ location_id1, location_id2 \t & (($location2_timeshift_ms !=0) and ($location2_death_factor = 1)?'- shifted':'')\t & (($location2_timeshift_ms = 0) and ($location2_death_factor !=1)?'- scaled':'')\t & (($location2_timeshift_ms !=0) and ($location2_death_factor !=1)?'- shifted and scaled':'')],\t \"data\" : [ \t [$map(location1.total_deaths,\t function($v, $i, $a) { { \"x\": $v.date_ms, \t \"y\": $v.value } } )[x >= $start_x]]\t ,\t [$map(location2.total_deaths,\t function($v, $i, $a) { { \"x\": $v.date_ms + $location2_timeshift_ms, \t \"y\": $v.value * $location2_death_factor } } )[x >= $start_x]]\t ],\t \"labels\": [\"\"]\t }]\t)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":2080,"wires":[["6ea5c40f.d3fc3c","f813b77f.68ddb8"]]},{"id":"a70f5101.b3484","type":"debug","z":"da7d3608.233f08","name":"confirmed2array","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":960,"y":320,"wires":[]},{"id":"270fbd92.e75db2","type":"debug","z":"da7d3608.233f08","name":"create msg.total_confirmed_cases","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"total_confirmed_cases","targetType":"msg","x":1020,"y":360,"wires":[]},{"id":"f5a8a0eb.5a704","type":"debug","z":"da7d3608.233f08","name":"create msg.total_deaths","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"total_deaths","targetType":"msg","x":990,"y":200,"wires":[]},{"id":"41cc9f27.9609c","type":"debug","z":"da7d3608.233f08","name":"death2array","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":950,"y":160,"wires":[]},{"id":"3a334c0f.26db44","type":"csv","z":"da7d3608.233f08","name":"csv2array","sep":",","hdrin":true,"hdrout":"","multi":"mult","ret":"\\n","temp":"","skip":"0","strings":true,"x":560,"y":160,"wires":[["26b293d6.ff211c","41cc9f27.9609c","afa688eb.70fa18"]]},{"id":"26b293d6.ff211c","type":"change","z":"da7d3608.233f08","name":"create msg.total_deaths","rules":[{"t":"set","p":"total_deaths","pt":"msg","to":"/* returns an array of locations */\tpayload@$c[].{\t \"location_id\" : $c.`Country/Region` & \":\" & $c.`Province/State`,\t /* \"is_country\" : $not($exists($c.`Province/State`)), */\t \"country_region\": $c.`Country/Region`,\t \"province_state\": $c.`Province/State`,\t \"latitude\" : $c.`Lat`,\t \"longitude\" : $c.`Long`,\t \"history\": $c.$sift(\t function($v, $k) {$k ~> /^[0-9]/}\t ) ~> \t $each(\t function($v, $k){ {\t \"date\" : $substring($k, 0,$length($k)-2) & '20' & $substring($k,-2),\t \"date_ms\": $toMillis($substring($k, 0,$length($k)-2) & '20' & $substring($k,-2),\t '[M]/[D]/[Y]'),\t \"value\" : $v\t \t }\t }\t )\t }\t/*\texample input\t{\t \"payload\": [\t {\t \"Country/Region\": \"Thailand\",\t \"Lat\": 15,\t \"Long\": 101,\t \"1/22/20\": 2,\t \"1/23/20\": 3,\t \"1/24/20\": 5,\t \"1/25/20\": 7,\t \"1/26/20\": 8,\t \"1/27/20\": 8,\t \"1/28/20\": 14,\t \"1/29/20\": 14,\t \"1/30/20\": 14,\t \"1/31/20\": 19,\t \"2/1/20\": 19,\t \"2/2/20\": 19,\t \"2/3/20\": 19,\t \"2/4/20\": 25\t \t },\t {\t \"Province/State\": \"New South Wales\",\t \"Country/Region\": \"Australia\",\t \"Lat\": -33.8688,\t \"Long\": 151.2093,\t \"1/22/20\": 0,\t \"1/23/20\": 0,\t \"1/24/20\": 0,\t \"1/25/20\": 0,\t \"1/26/20\": 3,\t \"1/27/20\": 4,\t \"1/28/20\": 4,\t \"1/29/20\": 4,\t \"1/30/20\": 4,\t \"1/31/20\": 4,\t \"2/1/20\": 4,\t \"2/2/20\": 4,\t \"2/3/20\": 4,\t \"2/4/20\": 4\t }\t ]\t}\t*/","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":610,"y":200,"wires":[["ec5b1bb0.7da778","f5a8a0eb.5a704","e27e28bc.ee49b8"]]},{"id":"94379557.3bcde8","type":"debug","z":"da7d3608.233f08","name":"province/state list","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":710,"y":1320,"wires":[]},{"id":"cf8043c6.efaf","type":"file","z":"da7d3608.233f08","name":"","filename":"covid.json","appendNewline":true,"createDir":false,"overwriteFile":"true","encoding":"none","x":550,"y":660,"wires":[["9afaeb76.542858","4acf9b5a.c06064"]]},{"id":"6594387c.e1f1c8","type":"file in","z":"da7d3608.233f08","name":"","filename":"covid.json","format":"utf8","chunk":false,"sendError":false,"encoding":"none","x":490,"y":740,"wires":[["5fb8cec5.6aff1"]]},{"id":"18829766.14f0f9","type":"inject","z":"da7d3608.233f08","name":"","repeat":"","crontab":"","once":true,"onceDelay":"1","topic":"","payload":"","payloadType":"date","x":250,"y":700,"wires":[["833731e3.0a138","6594387c.e1f1c8","76caa84.13b7458"]]},{"id":"255f1cb1.6dbb24","type":"json","z":"da7d3608.233f08","name":"","property":"payload","action":"","pretty":false,"x":530,"y":620,"wires":[["cf8043c6.efaf"]]},{"id":"5fb8cec5.6aff1","type":"json","z":"da7d3608.233f08","name":"","property":"payload","action":"","pretty":false,"x":470,"y":780,"wires":[["7fb5a40b.24e08c"]]},{"id":"7fb5a40b.24e08c","type":"change","z":"da7d3608.233f08","name":"set flow.covid","rules":[{"t":"set","p":"covid","pt":"flow","to":"payload","tot":"msg"},{"t":"set","p":"covid","pt":"msg","to":"covid","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":820,"wires":[["38be36d5.17ed1a","fdf78f3e.a8f67","a4ea5a53.770b48"]]},{"id":"9afaeb76.542858","type":"debug","z":"da7d3608.233f08","name":"stored covid.json","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":950,"y":660,"wires":[]},{"id":"3c40c5b2.e3afca","type":"debug","z":"da7d3608.233f08","name":"country list","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":510,"y":1060,"wires":[]},{"id":"7be329bb.36c528","type":"ui_chart","z":"da7d3608.233f08","name":"","group":"a31f3c67.3e6a2","order":4,"width":9,"height":"7","label":"new confirmed cases","chartType":"line","legend":"true","xformat":"D/M","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#008f00","#0433ff","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":920,"y":2120,"wires":[[]]},{"id":"f813b77f.68ddb8","type":"change","z":"da7d3608.233f08","name":"prepare new confirmed cases chart","rules":[{"t":"set","p":"payload","pt":"msg","to":"(\t /* graph starts from (lock_down_date - 1 week) */\t $location2_timeshift_ms := location2_timeshift_ms;\t $location2_death_factor := location2_death_factor;\t $start_x := $toMillis(lock_down_date1,\"[M]/[D]/[Y]\")-(7*24*60*60*1000);\t [{ \t\"series\": [ location_id1, location_id2 \t & (($location2_timeshift_ms !=0) and ($location2_death_factor = 1)?'- shifted':'')\t & (($location2_timeshift_ms = 0) and ($location2_death_factor !=1)?'- scaled':'')\t & (($location2_timeshift_ms !=0) and ($location2_death_factor !=1)?'- shifted and scaled':'')],\t \"data\" : [ \t [$map(location1.new_confirmed_cases,\t function($v, $i, $a) { { \"x\": $v.date_ms, \t \"y\": $v.value } } )[x >= $start_x]]\t ,\t [$map(location2.new_confirmed_cases,\t function($v, $i, $a) { { \"x\": $v.date_ms + $location2_timeshift_ms, \t \"y\": $v.value * $location2_death_factor } } )[x >= $start_x]]\t ],\t \"labels\": [\"\"]\t }]\t)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":2120,"wires":[["7be329bb.36c528","dc21a8da.46e3c8"]]},{"id":"4923c596.5d115c","type":"ui_chart","z":"da7d3608.233f08","name":"","group":"a31f3c67.3e6a2","order":1,"width":9,"height":"7","label":"new deaths","chartType":"line","legend":"true","xformat":"D/M","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#008f00","#0433ff","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":890,"y":2160,"wires":[[]]},{"id":"dc21a8da.46e3c8","type":"change","z":"da7d3608.233f08","name":"prepare new deaths chart","rules":[{"t":"set","p":"payload","pt":"msg","to":"(\t /* graph starts from (lock_down_date - 1 week) */\t $location2_timeshift_ms := location2_timeshift_ms;\t $location2_death_factor := location2_death_factor;\t $start_x := $toMillis(lock_down_date1,\"[M]/[D]/[Y]\")-(7*24*60*60*1000);\t [{ \t\"series\": [ location_id1, location_id2 \t & (($location2_timeshift_ms !=0) and ($location2_death_factor = 1)?'- shifted':'')\t & (($location2_timeshift_ms = 0) and ($location2_death_factor !=1)?'- scaled':'')\t & (($location2_timeshift_ms !=0) and ($location2_death_factor !=1)?'- shifted and scaled':'')],\t \"data\" : [ \t [$map(location1.new_deaths,\t function($v, $i, $a) { { \"x\": $v.date_ms, \t \"y\": $v.value } } )[x >= $start_x]]\t ,\t [$map(location2.new_deaths,\t function($v, $i, $a) { { \"x\": $v.date_ms + $location2_timeshift_ms, \t \"y\": $v.value * $location2_death_factor } } )[x >= $start_x]]\t ],\t \"labels\": [\"\"]\t }]\t)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":2160,"wires":[["4923c596.5d115c","2052e0bf.129c5","898c2956.2aa3b8"]]},{"id":"c1e834aa.123e68","type":"ui_button","z":"da7d3608.233f08","name":"","group":"22d37c26.1207a4","order":1,"width":5,"height":1,"passthru":false,"label":"retrieve data from github","tooltip":"This will retrieve the historical data from the internet (github) and convert it for charting. This will take several minutes !","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":330,"y":60,"wires":[["90a4cc34.50154","c9862823.1333b8"]]},{"id":"19002c0a.7a7d24","type":"ui_text","z":"da7d3608.233f08","group":"22d37c26.1207a4","order":2,"width":"12","height":1,"name":"data state","label":"","format":"{{msg.payload}}","layout":"row-left","x":1580,"y":320,"wires":[]},{"id":"c9862823.1333b8","type":"change","z":"da7d3608.233f08","name":"1.","rules":[{"t":"set","p":"payload","pt":"msg","to":"1. retrieving covid death data...","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1270,"y":60,"wires":[["19002c0a.7a7d24"]]},{"id":"13b09d87.5a3312","type":"change","z":"da7d3608.233f08","name":"2....","rules":[{"t":"set","p":"payload","pt":"msg","to":"2. converting csv to array ...","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1270,"y":140,"wires":[["19002c0a.7a7d24"]]},{"id":"afa688eb.70fa18","type":"change","z":"da7d3608.233f08","name":"3...","rules":[{"t":"set","p":"payload","pt":"msg","to":"3. converting total deaths to proper json...","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1270,"y":180,"wires":[["19002c0a.7a7d24"]]},{"id":"e27e28bc.ee49b8","type":"change","z":"da7d3608.233f08","name":"4. ...","rules":[{"t":"set","p":"payload","pt":"msg","to":"4. retrieving covid confirmed cases ...","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1270,"y":220,"wires":[["19002c0a.7a7d24"]]},{"id":"32b650ff.aaf6a","type":"change","z":"da7d3608.233f08","name":"5....","rules":[{"t":"set","p":"payload","pt":"msg","to":"5. converting csv to array ... ","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1270,"y":280,"wires":[["19002c0a.7a7d24"]]},{"id":"593ca514.902dcc","type":"change","z":"da7d3608.233f08","name":"6...","rules":[{"t":"set","p":"payload","pt":"msg","to":"6. convert confirmed cases to proper json ...","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1270,"y":320,"wires":[["19002c0a.7a7d24"]]},{"id":"449ff85e.e5d0c8","type":"change","z":"da7d3608.233f08","name":"7...","rules":[{"t":"set","p":"payload","pt":"msg","to":"7. retrieving US states data...","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1270,"y":360,"wires":[["19002c0a.7a7d24"]]},{"id":"4acf9b5a.c06064","type":"change","z":"da7d3608.233f08","name":"11...","rules":[{"t":"set","p":"payload","pt":"msg","to":"11. data successfully retrieved and stored in file","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1270,"y":600,"wires":[["19002c0a.7a7d24"]]},{"id":"38be36d5.17ed1a","type":"change","z":"da7d3608.233f08","name":"successfully read from file","rules":[{"t":"set","p":"payload","pt":"msg","to":"last data retrieved from github successfully read from local file","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1290,"y":820,"wires":[["19002c0a.7a7d24"]]},{"id":"833731e3.0a138","type":"change","z":"da7d3608.233f08","name":"reading from file....","rules":[{"t":"set","p":"payload","pt":"msg","to":"reading from file....","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1290,"y":700,"wires":[["19002c0a.7a7d24"]]},{"id":"e193f8b4.53b0c8","type":"link in","z":"da7d3608.233f08","name":"select location","links":["64713cf0.c619a4","fdf78f3e.a8f67"],"x":75,"y":1200,"wires":[["3d46854a.1b12da","fac7b993.b120a8","9b8e2708.73e998"]]},{"id":"fdf78f3e.a8f67","type":"link out","z":"da7d3608.233f08","name":"covid read from file","links":["e193f8b4.53b0c8"],"x":615,"y":840,"wires":[]},{"id":"64713cf0.c619a4","type":"link out","z":"da7d3608.233f08","name":"covid data retrieved from github","links":["e193f8b4.53b0c8"],"x":835,"y":580,"wires":[]},{"id":"7bf8afc5.80a8f","type":"ui_text","z":"da7d3608.233f08","group":"22d37c26.1207a4","order":3,"width":6,"height":1,"name":"","label":"current date","format":"{{msg.payload}}","layout":"row-spread","x":810,"y":1000,"wires":[]},{"id":"9b8e2708.73e998","type":"change","z":"da7d3608.233f08","name":"returns the current date of msg.covid","rules":[{"t":"set","p":"payload","pt":"msg","to":"/* returns the date of the last history record for the first location */\t$current_date :=covid.total_deaths[0].history[-1].date\t/*\t{\t \"covid\": {\t \"total_deaths\": [\t {\t \"location_id\": \"Thailand:\",\t \"country_region\": \"Thailand\",\t \"latitude\": 15,\t \"longitude\": 101,\t \"history\": [\t {\t \"date\": \"1/22/2020\",\t \"date_ms\": 1579651200000,\t \"value\": 2\t },\t {\t \"date\": \"1/23/2020\",\t \"date_ms\": 1579737600000,\t \"value\": 3\t },\t {\t \"date\": \"1/24/2020\",\t \"date_ms\": 1579824000000,\t \"value\": 5\t },\t {\t \"date\": \"1/25/2020\",\t \"date_ms\": 1579910400000,\t \"value\": 7\t },\t {\t \"date\": \"1/26/2020\",\t \"date_ms\": 1579996800000,\t \"value\": 8\t },\t {\t \"date\": \"1/27/2020\",\t \"date_ms\": 1580083200000,\t \"value\": 8\t },\t {\t \"date\": \"1/28/2020\",\t \"date_ms\": 1580169600000,\t \"value\": 14\t },\t {\t \"date\": \"1/29/2020\",\t \"date_ms\": 1580256000000,\t \"value\": 14\t },\t {\t \"date\": \"1/30/2020\",\t \"date_ms\": 1580342400000,\t \"value\": 14\t },\t {\t \"date\": \"1/31/2020\",\t \"date_ms\": 1580428800000,\t \"value\": 19\t },\t {\t \"date\": \"2/1/2020\",\t \"date_ms\": 1580515200000,\t \"value\": 19\t },\t {\t \"date\": \"2/2/2020\",\t \"date_ms\": 1580601600000,\t \"value\": 19\t },\t {\t \"date\": \"2/3/2020\",\t \"date_ms\": 1580688000000,\t \"value\": 19\t },\t {\t \"date\": \"2/4/2020\",\t \"date_ms\": 1580774400000,\t \"value\": 25\t }\t ]\t },\t {\t \"location_id\": \"Australia:New South Wales\",\t \"country_region\": \"Australia\",\t \"province_state\": \"New South Wales\",\t \"latitude\": -33.8688,\t \"longitude\": 151.2093,\t \"history\": [\t {\t \"date\": \"1/22/2020\",\t \"date_ms\": 1579651200000,\t \"value\": 0\t },\t {\t \"date\": \"1/23/2020\",\t \"date_ms\": 1579737600000,\t \"value\": 0\t },\t {\t \"date\": \"1/24/2020\",\t \"date_ms\": 1579824000000,\t \"value\": 0\t },\t {\t \"date\": \"1/25/2020\",\t \"date_ms\": 1579910400000,\t \"value\": 0\t },\t {\t \"date\": \"1/26/2020\",\t \"date_ms\": 1579996800000,\t \"value\": 3\t },\t {\t \"date\": \"1/27/2020\",\t \"date_ms\": 1580083200000,\t \"value\": 4\t },\t {\t \"date\": \"1/28/2020\",\t \"date_ms\": 1580169600000,\t \"value\": 4\t },\t {\t \"date\": \"1/29/2020\",\t \"date_ms\": 1580256000000,\t \"value\": 4\t },\t {\t \"date\": \"1/30/2020\",\t \"date_ms\": 1580342400000,\t \"value\": 4\t },\t {\t \"date\": \"1/31/2020\",\t \"date_ms\": 1580428800000,\t \"value\": 4\t },\t {\t \"date\": \"2/1/2020\",\t \"date_ms\": 1580515200000,\t \"value\": 4\t },\t {\t \"date\": \"2/2/2020\",\t \"date_ms\": 1580601600000,\t \"value\": 4\t },\t {\t \"date\": \"2/3/2020\",\t \"date_ms\": 1580688000000,\t \"value\": 4\t },\t {\t \"date\": \"2/4/2020\",\t \"date_ms\": 1580774400000,\t \"value\": 4\t }\t ]\t }\t ],\t \"total_confirmed_cases\": [\t {\t \"location_id\": \"Thailand:\",\t \"country_region\": \"Thailand\",\t \"latitude\": 15,\t \"longitude\": 101,\t \"history\": [\t {\t \"date\": \"1/22/2020\",\t \"date_ms\": 1579651200000,\t \"value\": 2\t },\t {\t \"date\": \"1/23/2020\",\t \"date_ms\": 1579737600000,\t \"value\": 3\t },\t {\t \"date\": \"1/24/2020\",\t \"date_ms\": 1579824000000,\t \"value\": 5\t },\t {\t \"date\": \"1/25/2020\",\t \"date_ms\": 1579910400000,\t \"value\": 7\t },\t {\t \"date\": \"1/26/2020\",\t \"date_ms\": 1579996800000,\t \"value\": 8\t },\t {\t \"date\": \"1/27/2020\",\t \"date_ms\": 1580083200000,\t \"value\": 8\t },\t {\t \"date\": \"1/28/2020\",\t \"date_ms\": 1580169600000,\t \"value\": 14\t },\t {\t \"date\": \"1/29/2020\",\t \"date_ms\": 1580256000000,\t \"value\": 14\t },\t {\t \"date\": \"1/30/2020\",\t \"date_ms\": 1580342400000,\t \"value\": 14\t },\t {\t \"date\": \"1/31/2020\",\t \"date_ms\": 1580428800000,\t \"value\": 19\t },\t {\t \"date\": \"2/1/2020\",\t \"date_ms\": 1580515200000,\t \"value\": 19\t },\t {\t \"date\": \"2/2/2020\",\t \"date_ms\": 1580601600000,\t \"value\": 19\t },\t {\t \"date\": \"2/3/2020\",\t \"date_ms\": 1580688000000,\t \"value\": 19\t },\t {\t \"date\": \"2/4/2020\",\t \"date_ms\": 1580774400000,\t \"value\": 25\t }\t ]\t },\t {\t \"location_id\": \"Australia:New South Wales\",\t \"country_region\": \"Australia\",\t \"province_state\": \"New South Wales\",\t \"latitude\": -33.8688,\t \"longitude\": 151.2093,\t \"history\": [\t {\t \"date\": \"1/22/2020\",\t \"date_ms\": 1579651200000,\t \"value\": 0\t },\t {\t \"date\": \"1/23/2020\",\t \"date_ms\": 1579737600000,\t \"value\": 0\t },\t {\t \"date\": \"1/24/2020\",\t \"date_ms\": 1579824000000,\t \"value\": 0\t },\t {\t \"date\": \"1/25/2020\",\t \"date_ms\": 1579910400000,\t \"value\": 0\t },\t {\t \"date\": \"1/26/2020\",\t \"date_ms\": 1579996800000,\t \"value\": 3\t },\t {\t \"date\": \"1/27/2020\",\t \"date_ms\": 1580083200000,\t \"value\": 4\t },\t {\t \"date\": \"1/28/2020\",\t \"date_ms\": 1580169600000,\t \"value\": 4\t },\t {\t \"date\": \"1/29/2020\",\t \"date_ms\": 1580256000000,\t \"value\": 4\t },\t {\t \"date\": \"1/30/2020\",\t \"date_ms\": 1580342400000,\t \"value\": 4\t },\t {\t \"date\": \"1/31/2020\",\t \"date_ms\": 1580428800000,\t \"value\": 4\t },\t {\t \"date\": \"2/1/2020\",\t \"date_ms\": 1580515200000,\t \"value\": 4\t },\t {\t \"date\": \"2/2/2020\",\t \"date_ms\": 1580601600000,\t \"value\": 4\t },\t {\t \"date\": \"2/3/2020\",\t \"date_ms\": 1580688000000,\t \"value\": 4\t },\t {\t \"date\": \"2/4/2020\",\t \"date_ms\": 1580774400000,\t \"value\": 4\t }\t ]\t }\t ]\t }\t}\t*/","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":1000,"wires":[["7bf8afc5.80a8f"]]},{"id":"4ebbe35e.4b7b2c","type":"ui_text","z":"da7d3608.233f08","group":"ce673549.1ea3f8","order":5,"width":"4","height":1,"name":"","label":"scale factor","format":"{{msg.location2_death_factor | number:3}}","layout":"row-spread","x":730,"y":1920,"wires":[]},{"id":"260f05e7.4f476a","type":"ui_text","z":"da7d3608.233f08","group":"ce673549.1ea3f8","order":4,"width":"3","height":1,"name":"","label":"date shift","format":"{{msg.payload}} days","layout":"row-spread","x":940,"y":1880,"wires":[]},{"id":"195c38e4.b877d7","type":"change","z":"da7d3608.233f08","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"location2_timeshift_ms/(1000*60*60*24)\t/*\t example input\t \t{\t \"location2_timeshift_ms\": 4233600000\t}\t*/","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":740,"y":1880,"wires":[["260f05e7.4f476a"]]},{"id":"30a28e20.b2b6d2","type":"catch","z":"da7d3608.233f08","name":"error reading covid file","scope":["6594387c.e1f1c8"],"uncaught":false,"x":740,"y":740,"wires":[["79eaf6a0.aebe58"]]},{"id":"79eaf6a0.aebe58","type":"change","z":"da7d3608.233f08","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"error.message & \". If this is the first time you have started this flow then click on button 'retrieve data from github'\"","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1280,"y":740,"wires":[["19002c0a.7a7d24"]]},{"id":"a3fff518.6ad538","type":"ui_chart","z":"da7d3608.233f08","name":"","group":"a31f3c67.3e6a2","order":6,"width":9,"height":"6","label":"infection fatality rate % (= (new deaths @ date X +8 ) /(new confirmed cases @ date X)","chartType":"line","legend":"true","xformat":"D/M","interpolate":"linear","nodata":"","dot":false,"ymin":"0","ymax":"100","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#008f00","#0433ff","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":1120,"y":2200,"wires":[[]]},{"id":"171ea321.f64fbd","type":"ui_text_input","z":"da7d3608.233f08","name":"","label":"new confirmed cases","tooltip":"","group":"6b90da1c.04f984","order":3,"width":0,"height":0,"passthru":false,"mode":"number","delay":"300","topic":"","x":660,"y":2520,"wires":[["d4e3eeca.f7c08"]]},{"id":"ba09d527.f19c68","type":"ui_text_input","z":"da7d3608.233f08","name":"","label":"new deaths","tooltip":"","group":"6b90da1c.04f984","order":4,"width":0,"height":0,"passthru":false,"mode":"number","delay":"300","topic":"","x":630,"y":2560,"wires":[["2cf06370.646b7c"]]},{"id":"d31b56fc.45d158","type":"ui_button","z":"da7d3608.233f08","name":"","group":"6b90da1c.04f984","order":5,"width":0,"height":0,"passthru":false,"label":"register","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":660,"y":2640,"wires":[["a1ca50e7.7075c","377835de.682faa"]]},{"id":"ab1e0770.2b3dd8","type":"ui_text","z":"da7d3608.233f08","group":"6b90da1c.04f984","order":2,"width":0,"height":0,"name":"","label":"new date","format":"{{msg.payload}}","layout":"row-spread","x":480,"y":2460,"wires":[]},{"id":"63aa89ef.dc8eb8","type":"link in","z":"da7d3608.233f08","name":"manual add deaths/new confirmed cases","links":["79ea1271.0a7b7c","d16e1ae4.7805c8"],"x":115,"y":2440,"wires":[["38ae9fde.180cf","ff773d15.b423a","1ca695c6.a9f68a"]]},{"id":"38ae9fde.180cf","type":"change","z":"da7d3608.233f08","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"/* returns current date */\t$fromMillis($floor($millis()/(24*60*60*1000))*24*60*60*1000, \"[M]/[D]/[Y]\")","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":2460,"wires":[["ab1e0770.2b3dd8"]]},{"id":"d4e3eeca.f7c08","type":"change","z":"da7d3608.233f08","name":"","rules":[{"t":"set","p":"new_confirmed_cases","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":930,"y":2520,"wires":[[]]},{"id":"2cf06370.646b7c","type":"change","z":"da7d3608.233f08","name":"","rules":[{"t":"set","p":"new_deaths","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":2560,"wires":[[]]},{"id":"a1ca50e7.7075c","type":"change","z":"da7d3608.233f08","name":"update flow.covid","rules":[{"t":"set","p":"location_id","pt":"msg","to":"$flowContext(\"country1\") & \":\" & $flowContext(\"province_state1\")","tot":"jsonata"},{"t":"set","p":"new_confirmed_cases","pt":"msg","to":"new_confirmed_cases","tot":"flow"},{"t":"set","p":"new_deaths","pt":"msg","to":"new_deaths","tot":"flow"},{"t":"set","p":"covid","pt":"msg","to":"covid","tot":"flow"},{"t":"set","p":"covid","pt":"flow","to":"( \t $new_confirmed_cases := new_confirmed_cases;\t $new_deaths := new_deaths;\t $location_id := location_id;\t $one_day_ms := 24*60*60*1000;\t covid ~> | total_deaths[location_id = $location_id] | \t { \t \"history\" : $append(history, { \"date\" : $fromMillis(history[-1].date_ms + $one_day_ms,\t \"[M]/[D]/[Y]\"),\t \"date_ms\" : history[-1].date_ms + $one_day_ms,\t \"value\" : history[-1].value+$new_deaths })\t } \t |\t ~> | total_confirmed_cases[location_id = $location_id] | \t { \t \"history\" : $append(history, { \"date\" : $fromMillis(history[-1].date_ms + $one_day_ms,\t \"[M]/[D]/[Y]\"),\t \"date_ms\" : history[-1].date_ms + $one_day_ms,\t \"value\" : history[-1].value+$new_confirmed_cases })\t } \t |\t)\t/*\t example input\t \t{\t \"location_id\": \"Belgium:\",\t \"new_confirmed_cases\" : 50,\t \"new_deaths\" : 20,\t \"lock_down_date\": \"1/31/2020\",\t \"hubei_current_date_shifted\": \"1/24/2020\",\t \"covid\": {\t \"current_date\": \"2/1/2020\",\t \"new_date\":\"2/2/2020\",\t \"dates\": [\t \"1/22/2020\",\t \"1/23/2020\",\t \"1/24/2020\",\t \"1/30/2020\",\t \"1/31/2020\",\t \"2/1/2020\",\t \"2/2/2020\"\t ],\t \"date2index\": {\t \"1/22/2020\": 0,\t \"1/23/2020\": 1,\t \"1/24/2020\": 2,\t \"1/31/2020\": 3,\t \"2/1/2020\": 4,\t \"2/2/2020\": 5\t },\t \"locations\": [\t {\t \"is_country\": false,\t \"country_region\": \"China\",\t \"province_state\": \"Hubei\",\t \"location_id\": \"China:Hubei\",\t \"latitude\": 15,\t \"longitude\": 101,\t \"dates\": [\t \"1/22/2020\",\t \"1/23/2020\",\t \"1/30/2020\",\t \"1/31/2020\",\t \"2/1/2020\"\t ],\t \"total_deaths\": [\t 0,\t 0,\t 3,\t 1,\t 1,\t 1\t ],\t \"total_confirmed_cases\": [\t 2,\t 3,\t 75,\t 82,\t 114\t ],\t \"current_total_deaths\": 1,\t \"current_total_confirmed_cases\": 114,\t \"new_deaths\": [\t 0,\t 0,\t 0,\t 1,\t 0,\t 0\t ],\t \"new_confirmed_cases\": [\t 2,\t 1,\t 72,\t 7,\t 32\t ]\t },\t {\t \"is_country\": true,\t \"country_region\": \"Belgium\",\t \"location_id\": \"Belgium:\",\t \"latitude\": 36,\t \"longitude\": 138,\t \"dates\": [\t \"1/22/2020\",\t \"1/23/2020\",\t \"1/24/2020\",\t \"1/25/2020\",\t \"3/12/2020\",\t \"3/13/2020\",\t \"3/14/2020\",\t \"3/15/2020\"\t ],\t \"total_deaths\": [\t 0,\t 0,\t 0,\t 0,\t 15,\t 16,\t 19,\t 22,\t 22\t ],\t \"total_confirmed_cases\": [\t 2,\t 1,\t 2,\t 701,\t 773,\t 839\t ],\t \"current_total_deaths\": 22,\t \"current_total_confirmed_cases\": 839,\t \"new_deaths\": [\t 0,\t 0,\t 0,\t 0,\t 15,\t 1,\t 3,\t 3,\t 0\t ],\t \"new_confirmed_cases\": [\t 2,\t -1,\t 1,\t 699,\t 72,\t 66\t ]\t }\t ]\t }\t}\t*/","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":870,"y":2640,"wires":[["caf12f3b.7398c","83a548db.2ed118"]]},{"id":"caf12f3b.7398c","type":"debug","z":"da7d3608.233f08","name":"flow.covid","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"$flowContext(\"covid\")","targetType":"jsonata","x":1120,"y":2640,"wires":[]},{"id":"ff773d15.b423a","type":"change","z":"da7d3608.233f08","name":"","rules":[{"t":"set","p":"enabled","pt":"msg","to":"( \t $one_day_ms := 24*60*60*1000;\t $floor($millis()/$one_day_ms)*$one_day_ms = (location1.total_deaths[-1].date_ms + $one_day_ms);\t)\t/*\t example input\t \t \t*/","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":230,"y":2580,"wires":[["a3e7132c.7de86","7c608dbf.8586c4","d31b56fc.45d158"]]},{"id":"a3e7132c.7de86","type":"change","z":"da7d3608.233f08","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"(\t enabled ? \"\" :\t location1.total_confirmed_cases[-1].value -\t location1.total_confirmed_cases[-2].value\t)\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":2520,"wires":[["171ea321.f64fbd"]]},{"id":"7c608dbf.8586c4","type":"change","z":"da7d3608.233f08","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"(\t enabled ? \"\" :\t location1.total_deaths[-1].value -\t location1.total_deaths[-2].value\t)\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":2560,"wires":[["ba09d527.f19c68"]]},{"id":"ade9caf2.de1e18","type":"comment","z":"da7d3608.233f08","name":"5. UI to manually add new deaths and new confirmed cases for selected location","info":"","x":320,"y":2360,"wires":[]},{"id":"ea4ae6fd.c515b8","type":"comment","z":"da7d3608.233f08","name":"3; Select location","info":"","x":100,"y":940,"wires":[]},{"id":"570d420c.df8bac","type":"comment","z":"da7d3608.233f08","name":"1. retrieve input data","info":"","x":90,"y":20,"wires":[]},{"id":"eb661cbb.c6e84","type":"comment","z":"da7d3608.233f08","name":"2. read from file at startup","info":"","x":130,"y":660,"wires":[]},{"id":"a9c75ca2.06dc6","type":"comment","z":"da7d3608.233f08","name":"4. Draw Charts","info":"","x":120,"y":1480,"wires":[]},{"id":"cac97ba7.7aa1c8","type":"change","z":"da7d3608.233f08","name":"create msg.total_confirmed_cases","rules":[{"t":"set","p":"total_confirmed_cases","pt":"msg","to":"/* returns an array of locations */\tpayload@$c[].{\t \"location_id\" : $c.`Country/Region` & \":\" & $c.`Province/State`,\t /* \"is_country\" : $not($exists($c.`Province/State`)), */\t \"country_region\": $c.`Country/Region`,\t \"province_state\": $c.`Province/State`,\t \"latitude\" : $c.`Lat`,\t \"longitude\" : $c.`Long`,\t \"history\": $c.$sift(\t function($v, $k) {$k ~> /^[0-9]/}\t ) ~> \t $each(\t function($v, $k){ {\t \"date\" : $substring($k, 0,$length($k)-2) & '20' & $substring($k,-2),\t \"date_ms\": $toMillis($substring($k, 0,$length($k)-2) & '20' & $substring($k,-2),\t '[M]/[D]/[Y]'),\t \"value\" : $v\t \t }\t }\t )\t }\t/*\texample input\t{\t \"payload\": [\t {\t \"Country/Region\": \"Thailand\",\t \"Lat\": 15,\t \"Long\": 101,\t \"1/22/20\": 2,\t \"1/23/20\": 3,\t \"1/24/20\": 5,\t \"1/25/20\": 7,\t \"1/26/20\": 8,\t \"1/27/20\": 8,\t \"1/28/20\": 14,\t \"1/29/20\": 14,\t \"1/30/20\": 14,\t \"1/31/20\": 19,\t \"2/1/20\": 19,\t \"2/2/20\": 19,\t \"2/3/20\": 19,\t \"2/4/20\": 25\t \t },\t {\t \"Province/State\": \"New South Wales\",\t \"Country/Region\": \"Australia\",\t \"Lat\": -33.8688,\t \"Long\": 151.2093,\t \"1/22/20\": 0,\t \"1/23/20\": 0,\t \"1/24/20\": 0,\t \"1/25/20\": 0,\t \"1/26/20\": 3,\t \"1/27/20\": 4,\t \"1/28/20\": 4,\t \"1/29/20\": 4,\t \"1/30/20\": 4,\t \"1/31/20\": 4,\t \"2/1/20\": 4,\t \"2/2/20\": 4,\t \"2/3/20\": 4,\t \"2/4/20\": 4\t \t }\t \t ]\t\t}\t*/","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":360,"wires":[["270fbd92.e75db2","449ff85e.e5d0c8","e83cf31a.6a0c"]]},{"id":"b96ef28a.4e6d4","type":"change","z":"da7d3608.233f08","name":"store in flow.covid","rules":[{"t":"set","p":"covid","pt":"msg","to":"{\"total_deaths\":\"\",\"total_confirmed_cases\":\"\"}","tot":"json"},{"t":"set","p":"covid.total_deaths","pt":"msg","to":"total_deaths","tot":"msg"},{"t":"set","p":"covid.total_confirmed_cases","pt":"msg","to":"total_confirmed_cases","tot":"msg"},{"t":"set","p":"covid","pt":"flow","to":"covid","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"covid","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":530,"y":580,"wires":[["255f1cb1.6dbb24","64713cf0.c619a4"]]},{"id":"a4ea5a53.770b48","type":"debug","z":"da7d3608.233f08","name":"read covd file","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":670,"y":780,"wires":[]},{"id":"178a0b6e.a40255","type":"ui_dropdown","z":"da7d3608.233f08","name":"select country2","label":"country","tooltip":"","place":"Select option","group":"bef9dde3.0058a","order":1,"width":5,"height":1,"passthru":true,"options":[{"label":"","value":"","type":"str"}],"payload":"","topic":"","x":900,"y":1080,"wires":[["6dd30e7f.2752f"]]},{"id":"1740dc.434d3f25","type":"ui_dropdown","z":"da7d3608.233f08","name":"select lock down date2","label":"lock down date","tooltip":"Date drastic measures are taken to reduce spread of virus","place":"Select option","group":"bef9dde3.0058a","order":3,"width":"7","height":1,"passthru":true,"options":[{"label":"","value":"","type":"str"}],"payload":"","topic":"","x":930,"y":1360,"wires":[["c7e4f672.dceeb8"]]},{"id":"9fa05e99.03682","type":"ui_dropdown","z":"da7d3608.233f08","name":"select province/state2","label":"province/state","tooltip":"","place":"Select option","group":"bef9dde3.0058a","order":2,"width":7,"height":1,"passthru":true,"options":[{"label":"","value":"","type":"str"}],"payload":"","topic":"","x":940,"y":1220,"wires":[["d4e79716.188e68"]]},{"id":"19b5d350.b6b54d","type":"ui_button","z":"da7d3608.233f08","name":"","group":"ce673549.1ea3f8","order":3,"width":"5","height":"1","passthru":false,"label":"update charts","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":320,"y":1620,"wires":[["c230e5ba.f6a238"]]},{"id":"d4e79716.188e68","type":"change","z":"da7d3608.233f08","name":"","rules":[{"t":"set","p":"province_state2","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1230,"y":1220,"wires":[[]]},{"id":"6dd30e7f.2752f","type":"change","z":"da7d3608.233f08","name":"","rules":[{"t":"set","p":"country2","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1150,"y":1080,"wires":[["40c9fde3.a91b14"]]},{"id":"40c9fde3.a91b14","type":"change","z":"da7d3608.233f08","name":"msg.options = province/state list for selected country2","rules":[{"t":"set","p":"selected_country","pt":"msg","to":"country2","tot":"flow"},{"t":"set","p":"covid","pt":"msg","to":"covid","tot":"flow"},{"t":"set","p":"options","pt":"msg","to":"(\t $country := selected_country;\t $locations_list := covid.total_deaths[country_region= $country ].province_state ~> $append( \"\") ~> $distinct ~> $sort ;\t ( $exists($locations_list) ? $locations_list : [ \"\" ] )\t)\t/*\tinput example:\t{\t \"selected_country\" : \"Thailand\",\t \"covid\": {\t \"total_deaths\": [\t {\t \"location_id\": \"Thailand:\",\t \"country_region\": \"Thailand\",\t \"province_state\": \"state 1 of Thailand\",\t \"latitude\": 15,\t \"longitude\": 101,\t \"history\": [\t {\t \"date\": \"1/22/2020\",\t \"date_ms\": 1579651200000,\t \"value\": 2\t },\t {\t \"date\": \"1/23/2020\",\t \"date_ms\": 1579737600000,\t \"value\": 3\t },\t {\t \"date\": \"1/24/2020\",\t \"date_ms\": 1579824000000,\t \"value\": 5\t },\t {\t \"date\": \"1/25/2020\",\t \"date_ms\": 1579910400000,\t \"value\": 7\t },\t {\t \"date\": \"1/26/2020\",\t \"date_ms\": 1579996800000,\t \"value\": 8\t },\t {\t \"date\": \"1/27/2020\",\t \"date_ms\": 1580083200000,\t \"value\": 8\t },\t {\t \"date\": \"1/28/2020\",\t \"date_ms\": 1580169600000,\t \"value\": 14\t },\t {\t \"date\": \"1/29/2020\",\t \"date_ms\": 1580256000000,\t \"value\": 14\t },\t {\t \"date\": \"1/30/2020\",\t \"date_ms\": 1580342400000,\t \"value\": 14\t },\t {\t \"date\": \"1/31/2020\",\t \"date_ms\": 1580428800000,\t \"value\": 19\t },\t {\t \"date\": \"2/1/2020\",\t \"date_ms\": 1580515200000,\t \"value\": 19\t },\t {\t \"date\": \"2/2/2020\",\t \"date_ms\": 1580601600000,\t \"value\": 19\t },\t {\t \"date\": \"2/3/2020\",\t \"date_ms\": 1580688000000,\t \"value\": 19\t },\t {\t \"date\": \"2/4/2020\",\t \"date_ms\": 1580774400000,\t \"value\": 25\t }\t ]\t },\t {\t \"location_id\": \"Australia:New South Wales\",\t \"country_region\": \"Australia\",\t \"province_state\": \"New South Wales\",\t \"latitude\": -33.8688,\t \"longitude\": 151.2093,\t \"history\": [\t {\t \"date\": \"1/22/2020\",\t \"date_ms\": 1579651200000,\t \"value\": 0\t },\t {\t \"date\": \"1/23/2020\",\t \"date_ms\": 1579737600000,\t \"value\": 0\t },\t {\t \"date\": \"1/24/2020\",\t \"date_ms\": 1579824000000,\t \"value\": 0\t },\t {\t \"date\": \"1/25/2020\",\t \"date_ms\": 1579910400000,\t \"value\": 0\t },\t {\t \"date\": \"1/26/2020\",\t \"date_ms\": 1579996800000,\t \"value\": 3\t },\t {\t \"date\": \"1/27/2020\",\t \"date_ms\": 1580083200000,\t \"value\": 4\t },\t {\t \"date\": \"1/28/2020\",\t \"date_ms\": 1580169600000,\t \"value\": 4\t },\t {\t \"date\": \"1/29/2020\",\t \"date_ms\": 1580256000000,\t \"value\": 4\t },\t {\t \"date\": \"1/30/2020\",\t \"date_ms\": 1580342400000,\t \"value\": 4\t },\t {\t \"date\": \"1/31/2020\",\t \"date_ms\": 1580428800000,\t \"value\": 4\t },\t {\t \"date\": \"2/1/2020\",\t \"date_ms\": 1580515200000,\t \"value\": 4\t },\t {\t \"date\": \"2/2/2020\",\t \"date_ms\": 1580601600000,\t \"value\": 4\t },\t {\t \"date\": \"2/3/2020\",\t \"date_ms\": 1580688000000,\t \"value\": 4\t },\t {\t \"date\": \"2/4/2020\",\t \"date_ms\": 1580774400000,\t \"value\": 4\t }\t ]\t }\t ],\t \"total_confirmed_cases\": [\t {\t \"location_id\": \"Thailand:\",\t \"country_region\": \"Thailand\",\t \"latitude\": 15,\t \"longitude\": 101,\t \"history\": [\t {\t \"date\": \"1/22/2020\",\t \"date_ms\": 1579651200000,\t \"value\": 2\t },\t {\t \"date\": \"1/23/2020\",\t \"date_ms\": 1579737600000,\t \"value\": 3\t },\t {\t \"date\": \"1/24/2020\",\t \"date_ms\": 1579824000000,\t \"value\": 5\t },\t {\t \"date\": \"1/25/2020\",\t \"date_ms\": 1579910400000,\t \"value\": 7\t },\t {\t \"date\": \"1/26/2020\",\t \"date_ms\": 1579996800000,\t \"value\": 8\t },\t {\t \"date\": \"1/27/2020\",\t \"date_ms\": 1580083200000,\t \"value\": 8\t },\t {\t \"date\": \"1/28/2020\",\t \"date_ms\": 1580169600000,\t \"value\": 14\t },\t {\t \"date\": \"1/29/2020\",\t \"date_ms\": 1580256000000,\t \"value\": 14\t },\t {\t \"date\": \"1/30/2020\",\t \"date_ms\": 1580342400000,\t \"value\": 14\t },\t {\t \"date\": \"1/31/2020\",\t \"date_ms\": 1580428800000,\t \"value\": 19\t },\t {\t \"date\": \"2/1/2020\",\t \"date_ms\": 1580515200000,\t \"value\": 19\t },\t {\t \"date\": \"2/2/2020\",\t \"date_ms\": 1580601600000,\t \"value\": 19\t },\t {\t \"date\": \"2/3/2020\",\t \"date_ms\": 1580688000000,\t \"value\": 19\t },\t {\t \"date\": \"2/4/2020\",\t \"date_ms\": 1580774400000,\t \"value\": 25\t }\t ]\t },\t {\t \"location_id\": \"Australia:New South Wales\",\t \"country_region\": \"Australia\",\t \"province_state\": \"New South Wales\",\t \"latitude\": -33.8688,\t \"longitude\": 151.2093,\t \"history\": [\t {\t \"date\": \"1/22/2020\",\t \"date_ms\": 1579651200000,\t \"value\": 0\t },\t {\t \"date\": \"1/23/2020\",\t \"date_ms\": 1579737600000,\t \"value\": 0\t },\t {\t \"date\": \"1/24/2020\",\t \"date_ms\": 1579824000000,\t \"value\": 0\t },\t {\t \"date\": \"1/25/2020\",\t \"date_ms\": 1579910400000,\t \"value\": 0\t },\t {\t \"date\": \"1/26/2020\",\t \"date_ms\": 1579996800000,\t \"value\": 3\t },\t {\t \"date\": \"1/27/2020\",\t \"date_ms\": 1580083200000,\t \"value\": 4\t },\t {\t \"date\": \"1/28/2020\",\t \"date_ms\": 1580169600000,\t \"value\": 4\t },\t {\t \"date\": \"1/29/2020\",\t \"date_ms\": 1580256000000,\t \"value\": 4\t },\t {\t \"date\": \"1/30/2020\",\t \"date_ms\": 1580342400000,\t \"value\": 4\t },\t {\t \"date\": \"1/31/2020\",\t \"date_ms\": 1580428800000,\t \"value\": 4\t },\t {\t \"date\": \"2/1/2020\",\t \"date_ms\": 1580515200000,\t \"value\": 4\t },\t {\t \"date\": \"2/2/2020\",\t \"date_ms\": 1580601600000,\t \"value\": 4\t },\t {\t \"date\": \"2/3/2020\",\t \"date_ms\": 1580688000000,\t \"value\": 4\t },\t {\t \"date\": \"2/4/2020\",\t \"date_ms\": 1580774400000,\t \"value\": 4\t }\t ]\t }\t ]\t }\t}\t*/","tot":"jsonata"},{"t":"set","p":"payload","pt":"msg","to":"Hubei","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":1220,"wires":[["9fa05e99.03682"]]},{"id":"c7e4f672.dceeb8","type":"change","z":"da7d3608.233f08","name":"","rules":[{"t":"set","p":"lock_down_date2","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1210,"y":1360,"wires":[[]]},{"id":"c230e5ba.f6a238","type":"change","z":"da7d3608.233f08","name":"copy flow => location1 & location2","rules":[{"t":"set","p":"location_id1","pt":"msg","to":"$flowContext(\"country1\") & \":\" & $flowContext(\"province_state1\")\t/*\t\texample input\tTODO\t*/\t","tot":"jsonata"},{"t":"set","p":"location_id2","pt":"msg","to":"$flowContext(\"country2\") & \":\" & $flowContext(\"province_state2\")\t","tot":"jsonata"},{"t":"set","p":"covid","pt":"msg","to":"covid","tot":"flow"},{"t":"set","p":"location1","pt":"msg","to":"(\t $location_id := location_id1;\t covid.{\t \"total_deaths\" : total_deaths[location_id = $location_id].history,\t \"total_confirmed_cases\" : total_confirmed_cases[location_id = $location_id].history\t }\t)\t/*\t input example\t \t {\t \"location_id1\" : \"Thailand:\",\t \"covid\": {\t \"total_deaths\": [\t {\t \"location_id\": \"Thailand:\",\t \"country_region\": \"Thailand\",\t \"province_state\": \"state 1 of Thailand\",\t \"latitude\": 15,\t \"longitude\": 101,\t \"history\": [\t {\t \"date\": \"1/22/2020\",\t \"date_ms\": 1579651200000,\t \"value\": 2\t },\t {\t \"date\": \"1/23/2020\",\t \"date_ms\": 1579737600000,\t \"value\": 3\t },\t {\t \"date\": \"1/24/2020\",\t \"date_ms\": 1579824000000,\t \"value\": 5\t },\t {\t \"date\": \"1/25/2020\",\t \"date_ms\": 1579910400000,\t \"value\": 7\t },\t {\t \"date\": \"1/26/2020\",\t \"date_ms\": 1579996800000,\t \"value\": 8\t },\t {\t \"date\": \"1/27/2020\",\t \"date_ms\": 1580083200000,\t \"value\": 8\t },\t {\t \"date\": \"1/28/2020\",\t \"date_ms\": 1580169600000,\t \"value\": 14\t },\t {\t \"date\": \"1/29/2020\",\t \"date_ms\": 1580256000000,\t \"value\": 14\t },\t {\t \"date\": \"1/30/2020\",\t \"date_ms\": 1580342400000,\t \"value\": 14\t },\t {\t \"date\": \"1/31/2020\",\t \"date_ms\": 1580428800000,\t \"value\": 19\t },\t {\t \"date\": \"2/1/2020\",\t \"date_ms\": 1580515200000,\t \"value\": 19\t },\t {\t \"date\": \"2/2/2020\",\t \"date_ms\": 1580601600000,\t \"value\": 19\t },\t {\t \"date\": \"2/3/2020\",\t \"date_ms\": 1580688000000,\t \"value\": 19\t },\t {\t \"date\": \"2/4/2020\",\t \"date_ms\": 1580774400000,\t \"value\": 25\t }\t ]\t },\t {\t \"location_id\": \"Australia:New South Wales\",\t \"country_region\": \"Australia\",\t \"province_state\": \"New South Wales\",\t \"latitude\": -33.8688,\t \"longitude\": 151.2093,\t \"history\": [\t {\t \"date\": \"1/22/2020\",\t \"date_ms\": 1579651200000,\t \"value\": 0\t },\t {\t \"date\": \"1/23/2020\",\t \"date_ms\": 1579737600000,\t \"value\": 0\t },\t {\t \"date\": \"1/24/2020\",\t \"date_ms\": 1579824000000,\t \"value\": 0\t },\t {\t \"date\": \"1/25/2020\",\t \"date_ms\": 1579910400000,\t \"value\": 0\t },\t {\t \"date\": \"1/26/2020\",\t \"date_ms\": 1579996800000,\t \"value\": 3\t },\t {\t \"date\": \"1/27/2020\",\t \"date_ms\": 1580083200000,\t \"value\": 4\t },\t {\t \"date\": \"1/28/2020\",\t \"date_ms\": 1580169600000,\t \"value\": 4\t },\t {\t \"date\": \"1/29/2020\",\t \"date_ms\": 1580256000000,\t \"value\": 4\t },\t {\t \"date\": \"1/30/2020\",\t \"date_ms\": 1580342400000,\t \"value\": 4\t },\t {\t \"date\": \"1/31/2020\",\t \"date_ms\": 1580428800000,\t \"value\": 4\t },\t {\t \"date\": \"2/1/2020\",\t \"date_ms\": 1580515200000,\t \"value\": 4\t },\t {\t \"date\": \"2/2/2020\",\t \"date_ms\": 1580601600000,\t \"value\": 4\t },\t {\t \"date\": \"2/3/2020\",\t \"date_ms\": 1580688000000,\t \"value\": 4\t },\t {\t \"date\": \"2/4/2020\",\t \"date_ms\": 1580774400000,\t \"value\": 4\t }\t ]\t }\t ],\t \"total_confirmed_cases\": [\t {\t \"location_id\": \"Thailand:\",\t \"country_region\": \"Thailand\",\t \"latitude\": 15,\t \"longitude\": 101,\t \"history\": [\t {\t \"date\": \"1/22/2020\",\t \"date_ms\": 1579651200000,\t \"value\": 2\t },\t {\t \"date\": \"1/23/2020\",\t \"date_ms\": 1579737600000,\t \"value\": 3\t },\t {\t \"date\": \"1/24/2020\",\t \"date_ms\": 1579824000000,\t \"value\": 5\t },\t {\t \"date\": \"1/25/2020\",\t \"date_ms\": 1579910400000,\t \"value\": 7\t },\t {\t \"date\": \"1/26/2020\",\t \"date_ms\": 1579996800000,\t \"value\": 8\t },\t {\t \"date\": \"1/27/2020\",\t \"date_ms\": 1580083200000,\t \"value\": 8\t },\t {\t \"date\": \"1/28/2020\",\t \"date_ms\": 1580169600000,\t \"value\": 14\t },\t {\t \"date\": \"1/29/2020\",\t \"date_ms\": 1580256000000,\t \"value\": 14\t },\t {\t \"date\": \"1/30/2020\",\t \"date_ms\": 1580342400000,\t \"value\": 14\t },\t {\t \"date\": \"1/31/2020\",\t \"date_ms\": 1580428800000,\t \"value\": 19\t },\t {\t \"date\": \"2/1/2020\",\t \"date_ms\": 1580515200000,\t \"value\": 19\t },\t {\t \"date\": \"2/2/2020\",\t \"date_ms\": 1580601600000,\t \"value\": 19\t },\t {\t \"date\": \"2/3/2020\",\t \"date_ms\": 1580688000000,\t \"value\": 19\t },\t {\t \"date\": \"2/4/2020\",\t \"date_ms\": 1580774400000,\t \"value\": 25\t }\t ]\t },\t {\t \"location_id\": \"Australia:New South Wales\",\t \"country_region\": \"Australia\",\t \"province_state\": \"New South Wales\",\t \"latitude\": -33.8688,\t \"longitude\": 151.2093,\t \"history\": [\t {\t \"date\": \"1/22/2020\",\t \"date_ms\": 1579651200000,\t \"value\": 0\t },\t {\t \"date\": \"1/23/2020\",\t \"date_ms\": 1579737600000,\t \"value\": 0\t },\t {\t \"date\": \"1/24/2020\",\t \"date_ms\": 1579824000000,\t \"value\": 0\t },\t {\t \"date\": \"1/25/2020\",\t \"date_ms\": 1579910400000,\t \"value\": 0\t },\t {\t \"date\": \"1/26/2020\",\t \"date_ms\": 1579996800000,\t \"value\": 3\t },\t {\t \"date\": \"1/27/2020\",\t \"date_ms\": 1580083200000,\t \"value\": 4\t },\t {\t \"date\": \"1/28/2020\",\t \"date_ms\": 1580169600000,\t \"value\": 4\t },\t {\t \"date\": \"1/29/2020\",\t \"date_ms\": 1580256000000,\t \"value\": 4\t },\t {\t \"date\": \"1/30/2020\",\t \"date_ms\": 1580342400000,\t \"value\": 4\t },\t {\t \"date\": \"1/31/2020\",\t \"date_ms\": 1580428800000,\t \"value\": 4\t },\t {\t \"date\": \"2/1/2020\",\t \"date_ms\": 1580515200000,\t \"value\": 4\t },\t {\t \"date\": \"2/2/2020\",\t \"date_ms\": 1580601600000,\t \"value\": 4\t },\t {\t \"date\": \"2/3/2020\",\t \"date_ms\": 1580688000000,\t \"value\": 4\t },\t {\t \"date\": \"2/4/2020\",\t \"date_ms\": 1580774400000,\t \"value\": 4\t }\t ]\t }\t ]\t }\t}\t*/","tot":"jsonata"},{"t":"set","p":"location2","pt":"msg","to":"(\t $location_id := location_id2;\t covid.{\t \"total_deaths\" : total_deaths[location_id = $location_id].history,\t \"total_confirmed_cases\" : total_confirmed_cases[location_id = $location_id].history\t }\t)\t/*\t input example\t \t {\t \"location_id2\" : \"Thailand:\",\t \"covid\": {\t \"total_deaths\": [\t {\t \"location_id\": \"Thailand:\",\t \"country_region\": \"Thailand\",\t \"province_state\": \"state 1 of Thailand\",\t \"latitude\": 15,\t \"longitude\": 101,\t \"history\": [\t {\t \"date\": \"1/22/2020\",\t \"date_ms\": 1579651200000,\t \"value\": 2\t },\t {\t \"date\": \"1/23/2020\",\t \"date_ms\": 1579737600000,\t \"value\": 3\t },\t {\t \"date\": \"1/24/2020\",\t \"date_ms\": 1579824000000,\t \"value\": 5\t },\t {\t \"date\": \"1/25/2020\",\t \"date_ms\": 1579910400000,\t \"value\": 7\t },\t {\t \"date\": \"1/26/2020\",\t \"date_ms\": 1579996800000,\t \"value\": 8\t },\t {\t \"date\": \"1/27/2020\",\t \"date_ms\": 1580083200000,\t \"value\": 8\t },\t {\t \"date\": \"1/28/2020\",\t \"date_ms\": 1580169600000,\t \"value\": 14\t },\t {\t \"date\": \"1/29/2020\",\t \"date_ms\": 1580256000000,\t \"value\": 14\t },\t {\t \"date\": \"1/30/2020\",\t \"date_ms\": 1580342400000,\t \"value\": 14\t },\t {\t \"date\": \"1/31/2020\",\t \"date_ms\": 1580428800000,\t \"value\": 19\t },\t {\t \"date\": \"2/1/2020\",\t \"date_ms\": 1580515200000,\t \"value\": 19\t },\t {\t \"date\": \"2/2/2020\",\t \"date_ms\": 1580601600000,\t \"value\": 19\t },\t {\t \"date\": \"2/3/2020\",\t \"date_ms\": 1580688000000,\t \"value\": 19\t },\t {\t \"date\": \"2/4/2020\",\t \"date_ms\": 1580774400000,\t \"value\": 25\t }\t ]\t },\t {\t \"location_id\": \"Australia:New South Wales\",\t \"country_region\": \"Australia\",\t \"province_state\": \"New South Wales\",\t \"latitude\": -33.8688,\t \"longitude\": 151.2093,\t \"history\": [\t {\t \"date\": \"1/22/2020\",\t \"date_ms\": 1579651200000,\t \"value\": 0\t },\t {\t \"date\": \"1/23/2020\",\t \"date_ms\": 1579737600000,\t \"value\": 0\t },\t {\t \"date\": \"1/24/2020\",\t \"date_ms\": 1579824000000,\t \"value\": 0\t },\t {\t \"date\": \"1/25/2020\",\t \"date_ms\": 1579910400000,\t \"value\": 0\t },\t {\t \"date\": \"1/26/2020\",\t \"date_ms\": 1579996800000,\t \"value\": 3\t },\t {\t \"date\": \"1/27/2020\",\t \"date_ms\": 1580083200000,\t \"value\": 4\t },\t {\t \"date\": \"1/28/2020\",\t \"date_ms\": 1580169600000,\t \"value\": 4\t },\t {\t \"date\": \"1/29/2020\",\t \"date_ms\": 1580256000000,\t \"value\": 4\t },\t {\t \"date\": \"1/30/2020\",\t \"date_ms\": 1580342400000,\t \"value\": 4\t },\t {\t \"date\": \"1/31/2020\",\t \"date_ms\": 1580428800000,\t \"value\": 4\t },\t {\t \"date\": \"2/1/2020\",\t \"date_ms\": 1580515200000,\t \"value\": 4\t },\t {\t \"date\": \"2/2/2020\",\t \"date_ms\": 1580601600000,\t \"value\": 4\t },\t {\t \"date\": \"2/3/2020\",\t \"date_ms\": 1580688000000,\t \"value\": 4\t },\t {\t \"date\": \"2/4/2020\",\t \"date_ms\": 1580774400000,\t \"value\": 4\t }\t ]\t }\t ],\t \"total_confirmed_cases\": [\t {\t \"location_id\": \"Thailand:\",\t \"country_region\": \"Thailand\",\t \"latitude\": 15,\t \"longitude\": 101,\t \"history\": [\t {\t \"date\": \"1/22/2020\",\t \"date_ms\": 1579651200000,\t \"value\": 2\t },\t {\t \"date\": \"1/23/2020\",\t \"date_ms\": 1579737600000,\t \"value\": 3\t },\t {\t \"date\": \"1/24/2020\",\t \"date_ms\": 1579824000000,\t \"value\": 5\t },\t {\t \"date\": \"1/25/2020\",\t \"date_ms\": 1579910400000,\t \"value\": 7\t },\t {\t \"date\": \"1/26/2020\",\t \"date_ms\": 1579996800000,\t \"value\": 8\t },\t {\t \"date\": \"1/27/2020\",\t \"date_ms\": 1580083200000,\t \"value\": 8\t },\t {\t \"date\": \"1/28/2020\",\t \"date_ms\": 1580169600000,\t \"value\": 14\t },\t {\t \"date\": \"1/29/2020\",\t \"date_ms\": 1580256000000,\t \"value\": 14\t },\t {\t \"date\": \"1/30/2020\",\t \"date_ms\": 1580342400000,\t \"value\": 14\t },\t {\t \"date\": \"1/31/2020\",\t \"date_ms\": 1580428800000,\t \"value\": 19\t },\t {\t \"date\": \"2/1/2020\",\t \"date_ms\": 1580515200000,\t \"value\": 19\t },\t {\t \"date\": \"2/2/2020\",\t \"date_ms\": 1580601600000,\t \"value\": 19\t },\t {\t \"date\": \"2/3/2020\",\t \"date_ms\": 1580688000000,\t \"value\": 19\t },\t {\t \"date\": \"2/4/2020\",\t \"date_ms\": 1580774400000,\t \"value\": 25\t }\t ]\t },\t {\t \"location_id\": \"Australia:New South Wales\",\t \"country_region\": \"Australia\",\t \"province_state\": \"New South Wales\",\t \"latitude\": -33.8688,\t \"longitude\": 151.2093,\t \"history\": [\t {\t \"date\": \"1/22/2020\",\t \"date_ms\": 1579651200000,\t \"value\": 0\t },\t {\t \"date\": \"1/23/2020\",\t \"date_ms\": 1579737600000,\t \"value\": 0\t },\t {\t \"date\": \"1/24/2020\",\t \"date_ms\": 1579824000000,\t \"value\": 0\t },\t {\t \"date\": \"1/25/2020\",\t \"date_ms\": 1579910400000,\t \"value\": 0\t },\t {\t \"date\": \"1/26/2020\",\t \"date_ms\": 1579996800000,\t \"value\": 3\t },\t {\t \"date\": \"1/27/2020\",\t \"date_ms\": 1580083200000,\t \"value\": 4\t },\t {\t \"date\": \"1/28/2020\",\t \"date_ms\": 1580169600000,\t \"value\": 4\t },\t {\t \"date\": \"1/29/2020\",\t \"date_ms\": 1580256000000,\t \"value\": 4\t },\t {\t \"date\": \"1/30/2020\",\t \"date_ms\": 1580342400000,\t \"value\": 4\t },\t {\t \"date\": \"1/31/2020\",\t \"date_ms\": 1580428800000,\t \"value\": 4\t },\t {\t \"date\": \"2/1/2020\",\t \"date_ms\": 1580515200000,\t \"value\": 4\t },\t {\t \"date\": \"2/2/2020\",\t \"date_ms\": 1580601600000,\t \"value\": 4\t },\t {\t \"date\": \"2/3/2020\",\t \"date_ms\": 1580688000000,\t \"value\": 4\t },\t {\t \"date\": \"2/4/2020\",\t \"date_ms\": 1580774400000,\t \"value\": 4\t }\t ]\t }\t ]\t }\t}\t*/","tot":"jsonata"},{"t":"set","p":"lock_down_date1","pt":"msg","to":"lock_down_date1","tot":"flow"},{"t":"set","p":"lock_down_date2","pt":"msg","to":"lock_down_date2","tot":"flow"},{"t":"set","p":"smooth_charts_location1","pt":"msg","to":"smooth_charts_location1","tot":"flow"},{"t":"set","p":"smooth_charts_location2","pt":"msg","to":"smooth_charts_location2","tot":"flow"},{"t":"delete","p":"covid","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":1620,"wires":[["bed0fd9.5b2ab","d16e1ae4.7805c8","77e237a.be02bc8"]]},{"id":"5c7c5e5.cede7a","type":"change","z":"da7d3608.233f08","name":"extend locations with new deaths and conf cases","rules":[{"t":"set","p":"location1","pt":"msg","to":"location1 ~> | $ | {\t \"new_deaths\" : $map(total_deaths, function($v, $i, $a) {\t $merge( [ $v , { \"value\" : $v.value - $a[$i-1].value } ] )})\t ~>$filter(function($v, $i, $a) {$i>0}),\t \"new_confirmed_cases\" : $map(total_confirmed_cases, function($v, $i, $a) {\t $merge( [ $v , { \"value\" : $v.value - $a[$i-1].value } ] )})\t ~>$filter(function($v, $i, $a) {$i>0})\t } |\t \t/* example input\t{\t \"location1\": {\t \"total_deaths\": [\t {\t \"date\": \"1/22/2020\",\t \"date_ms\": 1579651200000,\t \"value\": 2\t },\t {\t \"date\": \"1/23/2020\",\t \"date_ms\": 1579737600000,\t \"value\": 3\t },\t {\t \"date\": \"1/24/2020\",\t \"date_ms\": 1579824000000,\t \"value\": 5\t },\t {\t \"date\": \"1/25/2020\",\t \"date_ms\": 1579910400000,\t \"value\": 7\t },\t {\t \"date\": \"1/26/2020\",\t \"date_ms\": 1579996800000,\t \"value\": 8\t },\t {\t \"date\": \"1/27/2020\",\t \"date_ms\": 1580083200000,\t \"value\": 8\t },\t {\t \"date\": \"1/28/2020\",\t \"date_ms\": 1580169600000,\t \"value\": 14\t },\t {\t \"date\": \"1/29/2020\",\t \"date_ms\": 1580256000000,\t \"value\": 14\t },\t {\t \"date\": \"1/30/2020\",\t \"date_ms\": 1580342400000,\t \"value\": 14\t },\t {\t \"date\": \"1/31/2020\",\t \"date_ms\": 1580428800000,\t \"value\": 19\t },\t {\t \"date\": \"2/1/2020\",\t \"date_ms\": 1580515200000,\t \"value\": 19\t },\t {\t \"date\": \"2/2/2020\",\t \"date_ms\": 1580601600000,\t \"value\": 19\t },\t {\t \"date\": \"2/3/2020\",\t \"date_ms\": 1580688000000,\t \"value\": 19\t },\t {\t \"date\": \"2/4/2020\",\t \"date_ms\": 1580774400000,\t \"value\": 25\t }\t ],\t \"total_confirmed_cases\": [\t {\t \"date\": \"1/22/2020\",\t \"date_ms\": 1579651200000,\t \"value\": 2\t },\t {\t \"date\": \"1/23/2020\",\t \"date_ms\": 1579737600000,\t \"value\": 3\t },\t {\t \"date\": \"1/24/2020\",\t \"date_ms\": 1579824000000,\t \"value\": 5\t },\t {\t \"date\": \"1/25/2020\",\t \"date_ms\": 1579910400000,\t \"value\": 7\t },\t {\t \"date\": \"1/26/2020\",\t \"date_ms\": 1579996800000,\t \"value\": 8\t },\t {\t \"date\": \"1/27/2020\",\t \"date_ms\": 1580083200000,\t \"value\": 8\t },\t {\t \"date\": \"1/28/2020\",\t \"date_ms\": 1580169600000,\t \"value\": 14\t },\t {\t \"date\": \"1/29/2020\",\t \"date_ms\": 1580256000000,\t \"value\": 14\t },\t {\t \"date\": \"1/30/2020\",\t \"date_ms\": 1580342400000,\t \"value\": 14\t },\t {\t \"date\": \"1/31/2020\",\t \"date_ms\": 1580428800000,\t \"value\": 19\t },\t {\t \"date\": \"2/1/2020\",\t \"date_ms\": 1580515200000,\t \"value\": 19\t },\t {\t \"date\": \"2/2/2020\",\t \"date_ms\": 1580601600000,\t \"value\": 19\t },\t {\t \"date\": \"2/3/2020\",\t \"date_ms\": 1580688000000,\t \"value\": 19\t },\t {\t \"date\": \"2/4/2020\",\t \"date_ms\": 1580774400000,\t \"value\": 25\t }\t ]\t }\t}\t*/","tot":"jsonata"},{"t":"set","p":"location2","pt":"msg","to":"location2 ~> | $ | {\t \"new_deaths\" : $map(total_deaths, function($v, $i, $a) {\t $merge( [ $v , { \"value\" : $v.value - $a[$i-1].value } ] )})\t ~>$filter(function($v, $i, $a) {$i>0}),\t \"new_confirmed_cases\" : $map(total_confirmed_cases, function($v, $i, $a) {\t $merge( [ $v , { \"value\" : $v.value - $a[$i-1].value } ] )})\t ~>$filter(function($v, $i, $a) {$i>0})\t } |\t \t/* example input\t{\t \"location2\": {\t \"total_deaths\": [\t {\t \"date\": \"1/22/2020\",\t \"date_ms\": 1579651200000,\t \"value\": 2\t },\t {\t \"date\": \"1/23/2020\",\t \"date_ms\": 1579737600000,\t \"value\": 3\t },\t {\t \"date\": \"1/24/2020\",\t \"date_ms\": 1579824000000,\t \"value\": 5\t },\t {\t \"date\": \"1/25/2020\",\t \"date_ms\": 1579910400000,\t \"value\": 7\t },\t {\t \"date\": \"1/26/2020\",\t \"date_ms\": 1579996800000,\t \"value\": 8\t },\t {\t \"date\": \"1/27/2020\",\t \"date_ms\": 1580083200000,\t \"value\": 8\t },\t {\t \"date\": \"1/28/2020\",\t \"date_ms\": 1580169600000,\t \"value\": 14\t },\t {\t \"date\": \"1/29/2020\",\t \"date_ms\": 1580256000000,\t \"value\": 14\t },\t {\t \"date\": \"1/30/2020\",\t \"date_ms\": 1580342400000,\t \"value\": 14\t },\t {\t \"date\": \"1/31/2020\",\t \"date_ms\": 1580428800000,\t \"value\": 19\t },\t {\t \"date\": \"2/1/2020\",\t \"date_ms\": 1580515200000,\t \"value\": 19\t },\t {\t \"date\": \"2/2/2020\",\t \"date_ms\": 1580601600000,\t \"value\": 19\t },\t {\t \"date\": \"2/3/2020\",\t \"date_ms\": 1580688000000,\t \"value\": 19\t },\t {\t \"date\": \"2/4/2020\",\t \"date_ms\": 1580774400000,\t \"value\": 25\t }\t ],\t \"total_confirmed_cases\": [\t {\t \"date\": \"1/22/2020\",\t \"date_ms\": 1579651200000,\t \"value\": 2\t },\t {\t \"date\": \"1/23/2020\",\t \"date_ms\": 1579737600000,\t \"value\": 3\t },\t {\t \"date\": \"1/24/2020\",\t \"date_ms\": 1579824000000,\t \"value\": 5\t },\t {\t \"date\": \"1/25/2020\",\t \"date_ms\": 1579910400000,\t \"value\": 7\t },\t {\t \"date\": \"1/26/2020\",\t \"date_ms\": 1579996800000,\t \"value\": 8\t },\t {\t \"date\": \"1/27/2020\",\t \"date_ms\": 1580083200000,\t \"value\": 8\t },\t {\t \"date\": \"1/28/2020\",\t \"date_ms\": 1580169600000,\t \"value\": 14\t },\t {\t \"date\": \"1/29/2020\",\t \"date_ms\": 1580256000000,\t \"value\": 14\t },\t {\t \"date\": \"1/30/2020\",\t \"date_ms\": 1580342400000,\t \"value\": 14\t },\t {\t \"date\": \"1/31/2020\",\t \"date_ms\": 1580428800000,\t \"value\": 19\t },\t {\t \"date\": \"2/1/2020\",\t \"date_ms\": 1580515200000,\t \"value\": 19\t },\t {\t \"date\": \"2/2/2020\",\t \"date_ms\": 1580601600000,\t \"value\": 19\t },\t {\t \"date\": \"2/3/2020\",\t \"date_ms\": 1580688000000,\t \"value\": 19\t },\t {\t \"date\": \"2/4/2020\",\t \"date_ms\": 1580774400000,\t \"value\": 25\t }\t ]\t }\t}\t*/","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":450,"y":1960,"wires":[["654d7ff9.3ecc4","1dd21bf5.0e8bd4"]]},{"id":"78583155.8806b","type":"change","z":"da7d3608.233f08","name":"calculage date shift and death factor","rules":[{"t":"set","p":"location2_timeshift_ms","pt":"msg","to":"$toMillis(lock_down_date1,'[M]/[D]/[Y]')-$toMillis(lock_down_date2,'[M]/[D]/[Y]')","tot":"jsonata"},{"t":"set","p":"location2_current_date_shifted","pt":"msg","to":"( $location_id := location_id; \t $fromMillis(location1.total_deaths[-1].date_ms-location2_timeshift_ms,'[M]/[D]/[Y]');\t)\t/*\texample input\t{\t \"location_id\": \"Australia:New South Wales\",\t \"lock_down_date\": \"1/31/2020\",\t \"hubei_timeshift_ms\" : 259200000,\t \"hubei_current_date_shifted\": \"1/24/2020\",\t \"covid\": {\t \"total_deaths\": [\t {\t \"location_id\": \"Thailand:\",\t \"country_region\": \"Thailand\",\t \"province_state\": \"state 1 of Thailand\",\t \"latitude\": 15,\t \"longitude\": 101,\t \"history\": [\t {\t \"date\": \"1/22/2020\",\t \"date_ms\": 1579651200000,\t \"value\": 2\t },\t {\t \"date\": \"1/23/2020\",\t \"date_ms\": 1579737600000,\t \"value\": 3\t },\t {\t \"date\": \"1/24/2020\",\t \"date_ms\": 1579824000000,\t \"value\": 5\t },\t {\t \"date\": \"1/25/2020\",\t \"date_ms\": 1579910400000,\t \"value\": 7\t },\t {\t \"date\": \"1/26/2020\",\t \"date_ms\": 1579996800000,\t \"value\": 8\t },\t {\t \"date\": \"1/27/2020\",\t \"date_ms\": 1580083200000,\t \"value\": 8\t },\t {\t \"date\": \"1/28/2020\",\t \"date_ms\": 1580169600000,\t \"value\": 14\t },\t {\t \"date\": \"1/29/2020\",\t \"date_ms\": 1580256000000,\t \"value\": 14\t },\t {\t \"date\": \"1/30/2020\",\t \"date_ms\": 1580342400000,\t \"value\": 14\t },\t {\t \"date\": \"1/31/2020\",\t \"date_ms\": 1580428800000,\t \"value\": 19\t },\t {\t \"date\": \"2/1/2020\",\t \"date_ms\": 1580515200000,\t \"value\": 19\t },\t {\t \"date\": \"2/2/2020\",\t \"date_ms\": 1580601600000,\t \"value\": 19\t },\t {\t \"date\": \"2/3/2020\",\t \"date_ms\": 1580688000000,\t \"value\": 19\t },\t {\t \"date\": \"2/4/2020\",\t \"date_ms\": 1580774400000,\t \"value\": 25\t }\t ]\t },\t {\t \"location_id\": \"Australia:New South Wales\",\t \"country_region\": \"Australia\",\t \"province_state\": \"New South Wales\",\t \"latitude\": -33.8688,\t \"longitude\": 151.2093,\t \"history\": [\t {\t \"date\": \"1/22/2020\",\t \"date_ms\": 1579651200000,\t \"value\": 0\t },\t {\t \"date\": \"1/23/2020\",\t \"date_ms\": 1579737600000,\t \"value\": 0\t },\t {\t \"date\": \"1/24/2020\",\t \"date_ms\": 1579824000000,\t \"value\": 0\t },\t {\t \"date\": \"1/25/2020\",\t \"date_ms\": 1579910400000,\t \"value\": 0\t },\t {\t \"date\": \"1/26/2020\",\t \"date_ms\": 1579996800000,\t \"value\": 3\t },\t {\t \"date\": \"1/27/2020\",\t \"date_ms\": 1580083200000,\t \"value\": 4\t },\t {\t \"date\": \"1/28/2020\",\t \"date_ms\": 1580169600000,\t \"value\": 4\t },\t {\t \"date\": \"1/29/2020\",\t \"date_ms\": 1580256000000,\t \"value\": 4\t },\t {\t \"date\": \"1/30/2020\",\t \"date_ms\": 1580342400000,\t \"value\": 4\t },\t {\t \"date\": \"1/31/2020\",\t \"date_ms\": 1580428800000,\t \"value\": 4\t },\t {\t \"date\": \"2/1/2020\",\t \"date_ms\": 1580515200000,\t \"value\": 4\t },\t {\t \"date\": \"2/2/2020\",\t \"date_ms\": 1580601600000,\t \"value\": 4\t },\t {\t \"date\": \"2/3/2020\",\t \"date_ms\": 1580688000000,\t \"value\": 4\t },\t {\t \"date\": \"2/4/2020\",\t \"date_ms\": 1580774400000,\t \"value\": 4\t }\t ]\t }\t ],\t \"total_confirmed_cases\": [\t {\t \"location_id\": \"Thailand:\",\t \"country_region\": \"Thailand\",\t \"latitude\": 15,\t \"longitude\": 101,\t \"history\": [\t {\t \"date\": \"1/22/2020\",\t \"date_ms\": 1579651200000,\t \"value\": 2\t },\t {\t \"date\": \"1/23/2020\",\t \"date_ms\": 1579737600000,\t \"value\": 3\t },\t {\t \"date\": \"1/24/2020\",\t \"date_ms\": 1579824000000,\t \"value\": 5\t },\t {\t \"date\": \"1/25/2020\",\t \"date_ms\": 1579910400000,\t \"value\": 7\t },\t {\t \"date\": \"1/26/2020\",\t \"date_ms\": 1579996800000,\t \"value\": 8\t },\t {\t \"date\": \"1/27/2020\",\t \"date_ms\": 1580083200000,\t \"value\": 8\t },\t {\t \"date\": \"1/28/2020\",\t \"date_ms\": 1580169600000,\t \"value\": 14\t },\t {\t \"date\": \"1/29/2020\",\t \"date_ms\": 1580256000000,\t \"value\": 14\t },\t {\t \"date\": \"1/30/2020\",\t \"date_ms\": 1580342400000,\t \"value\": 14\t },\t {\t \"date\": \"1/31/2020\",\t \"date_ms\": 1580428800000,\t \"value\": 19\t },\t {\t \"date\": \"2/1/2020\",\t \"date_ms\": 1580515200000,\t \"value\": 19\t },\t {\t \"date\": \"2/2/2020\",\t \"date_ms\": 1580601600000,\t \"value\": 19\t },\t {\t \"date\": \"2/3/2020\",\t \"date_ms\": 1580688000000,\t \"value\": 19\t },\t {\t \"date\": \"2/4/2020\",\t \"date_ms\": 1580774400000,\t \"value\": 25\t }\t ]\t },\t {\t \"location_id\": \"Australia:New South Wales\",\t \"country_region\": \"Australia\",\t \"province_state\": \"New South Wales\",\t \"latitude\": -33.8688,\t \"longitude\": 151.2093,\t \"history\": [\t {\t \"date\": \"1/22/2020\",\t \"date_ms\": 1579651200000,\t \"value\": 0\t },\t {\t \"date\": \"1/23/2020\",\t \"date_ms\": 1579737600000,\t \"value\": 0\t },\t {\t \"date\": \"1/24/2020\",\t \"date_ms\": 1579824000000,\t \"value\": 0\t },\t {\t \"date\": \"1/25/2020\",\t \"date_ms\": 1579910400000,\t \"value\": 0\t },\t {\t \"date\": \"1/26/2020\",\t \"date_ms\": 1579996800000,\t \"value\": 3\t },\t {\t \"date\": \"1/27/2020\",\t \"date_ms\": 1580083200000,\t \"value\": 4\t },\t {\t \"date\": \"1/28/2020\",\t \"date_ms\": 1580169600000,\t \"value\": 4\t },\t {\t \"date\": \"1/29/2020\",\t \"date_ms\": 1580256000000,\t \"value\": 4\t },\t {\t \"date\": \"1/30/2020\",\t \"date_ms\": 1580342400000,\t \"value\": 4\t },\t {\t \"date\": \"1/31/2020\",\t \"date_ms\": 1580428800000,\t \"value\": 4\t },\t {\t \"date\": \"2/1/2020\",\t \"date_ms\": 1580515200000,\t \"value\": 4\t },\t {\t \"date\": \"2/2/2020\",\t \"date_ms\": 1580601600000,\t \"value\": 4\t },\t {\t \"date\": \"2/3/2020\",\t \"date_ms\": 1580688000000,\t \"value\": 4\t },\t {\t \"date\": \"2/4/2020\",\t \"date_ms\": 1580774400000,\t \"value\": 4\t }\t ]\t }\t ]\t }\t}\t*/","tot":"jsonata"},{"t":"set","p":"location2_death_factor","pt":"msg","to":"/* calculates the fraction of death for location1 at last date\t compared to the deaths of location2 time shifted,\t \t in case the timeshift is negative we calculate the fraction of death for location1 $current_date_time_shifted\t compared to the deaths of location2 at the last date */\t(\t location2_timeshift_ms >= 0\t ?\t ( $current_total_death_loc1 := location1.total_deaths[-1].value;\t $current_date_time_shifted := location1.total_deaths[-1].date_ms - location2_timeshift_ms;\t $current_date_time_shifted_total_death_loc2 := location2.total_deaths[date_ms = $current_date_time_shifted].value;\t $current_total_death_loc1/$current_date_time_shifted_total_death_loc2; ) \t : ( $current_total_death_loc2 := location2.total_deaths[-1].value;\t $current_date_time_shifted := location2.total_deaths[-1].date_ms + location2_timeshift_ms;\t $current_date_time_shifted_total_death_loc1 := location1.total_deaths[date_ms = $current_date_time_shifted].value;\t $current_date_time_shifted_total_death_loc1/$current_total_death_loc2;\t )\t)\t/*\t example input\t \t{\t \"lock_down_date1\": \"1/27/2020\",\t \"lock_down_date2\": \"1/23/2020\",\t \"location2_timeshift_ms\" : 345600000,\t \"location1\": {\t \"total_deaths\": [\t {\t \"date\": \"1/22/2020\",\t \"date_ms\": 1579651200000,\t \"value\": 2\t },\t {\t \"date\": \"1/23/2020\",\t \"date_ms\": 1579737600000,\t \"value\": 3\t },\t {\t \"date\": \"1/24/2020\",\t \"date_ms\": 1579824000000,\t \"value\": 5\t },\t {\t \"date\": \"1/25/2020\",\t \"date_ms\": 1579910400000,\t \"value\": 7\t },\t {\t \"date\": \"1/26/2020\",\t \"date_ms\": 1579996800000,\t \"value\": 8\t },\t {\t \"date\": \"1/27/2020\",\t \"date_ms\": 1580083200000,\t \"value\": 8\t },\t {\t \"date\": \"1/28/2020\",\t \"date_ms\": 1580169600000,\t \"value\": 14\t },\t {\t \"date\": \"1/29/2020\",\t \"date_ms\": 1580256000000,\t \"value\": 14\t },\t {\t \"date\": \"1/30/2020\",\t \"date_ms\": 1580342400000,\t \"value\": 14\t },\t {\t \"date\": \"1/31/2020\",\t \"date_ms\": 1580428800000,\t \"value\": 19\t },\t {\t \"date\": \"2/1/2020\",\t \"date_ms\": 1580515200000,\t \"value\": 19\t },\t {\t \"date\": \"2/2/2020\",\t \"date_ms\": 1580601600000,\t \"value\": 19\t },\t {\t \"date\": \"2/3/2020\",\t \"date_ms\": 1580688000000,\t \"value\": 19\t },\t {\t \"date\": \"2/4/2020\",\t \"date_ms\": 1580774400000,\t \"value\": 25\t }\t ],\t \"total_confirmed_cases\": [\t {\t \"date\": \"1/22/2020\",\t \"date_ms\": 1579651200000,\t \"value\": 2\t },\t {\t \"date\": \"1/23/2020\",\t \"date_ms\": 1579737600000,\t \"value\": 3\t },\t {\t \"date\": \"1/24/2020\",\t \"date_ms\": 1579824000000,\t \"value\": 5\t },\t {\t \"date\": \"1/25/2020\",\t \"date_ms\": 1579910400000,\t \"value\": 7\t },\t {\t \"date\": \"1/26/2020\",\t \"date_ms\": 1579996800000,\t \"value\": 8\t },\t {\t \"date\": \"1/27/2020\",\t \"date_ms\": 1580083200000,\t \"value\": 8\t },\t {\t \"date\": \"1/28/2020\",\t \"date_ms\": 1580169600000,\t \"value\": 14\t },\t {\t \"date\": \"1/29/2020\",\t \"date_ms\": 1580256000000,\t \"value\": 14\t },\t {\t \"date\": \"1/30/2020\",\t \"date_ms\": 1580342400000,\t \"value\": 14\t },\t {\t \"date\": \"1/31/2020\",\t \"date_ms\": 1580428800000,\t \"value\": 19\t },\t {\t \"date\": \"2/1/2020\",\t \"date_ms\": 1580515200000,\t \"value\": 19\t },\t {\t \"date\": \"2/2/2020\",\t \"date_ms\": 1580601600000,\t \"value\": 19\t },\t {\t \"date\": \"2/3/2020\",\t \"date_ms\": 1580688000000,\t \"value\": 19\t },\t {\t \"date\": \"2/4/2020\",\t \"date_ms\": 1580774400000,\t \"value\": 25\t }\t ]\t },\t \"location2\" : {\t \"total_deaths\": [\t {\t \"date\": \"1/22/2020\",\t \"date_ms\": 1579651200000,\t \"value\": 2\t },\t {\t \"date\": \"1/23/2020\",\t \"date_ms\": 1579737600000,\t \"value\": 3\t },\t {\t \"date\": \"1/24/2020\",\t \"date_ms\": 1579824000000,\t \"value\": 5\t },\t {\t \"date\": \"1/25/2020\",\t \"date_ms\": 1579910400000,\t \"value\": 7\t },\t {\t \"date\": \"1/26/2020\",\t \"date_ms\": 1579996800000,\t \"value\": 8\t },\t {\t \"date\": \"1/27/2020\",\t \"date_ms\": 1580083200000,\t \"value\": 8\t },\t {\t \"date\": \"1/28/2020\",\t \"date_ms\": 1580169600000,\t \"value\": 14\t },\t {\t \"date\": \"1/29/2020\",\t \"date_ms\": 1580256000000,\t \"value\": 14\t },\t {\t \"date\": \"1/30/2020\",\t \"date_ms\": 1580342400000,\t \"value\": 14\t },\t {\t \"date\": \"1/31/2020\",\t \"date_ms\": 1580428800000,\t \"value\": 19\t },\t {\t \"date\": \"2/1/2020\",\t \"date_ms\": 1580515200000,\t \"value\": 19\t },\t {\t \"date\": \"2/2/2020\",\t \"date_ms\": 1580601600000,\t \"value\": 19\t },\t {\t \"date\": \"2/3/2020\",\t \"date_ms\": 1580688000000,\t \"value\": 19\t },\t {\t \"date\": \"2/4/2020\",\t \"date_ms\": 1580774400000,\t \"value\": 25\t }\t ],\t \"total_confirmed_cases\": [\t {\t \"date\": \"1/22/2020\",\t \"date_ms\": 1579651200000,\t \"value\": 2\t },\t {\t \"date\": \"1/23/2020\",\t \"date_ms\": 1579737600000,\t \"value\": 3\t },\t {\t \"date\": \"1/24/2020\",\t \"date_ms\": 1579824000000,\t \"value\": 5\t },\t {\t \"date\": \"1/25/2020\",\t \"date_ms\": 1579910400000,\t \"value\": 7\t },\t {\t \"date\": \"1/26/2020\",\t \"date_ms\": 1579996800000,\t \"value\": 8\t },\t {\t \"date\": \"1/27/2020\",\t \"date_ms\": 1580083200000,\t \"value\": 8\t },\t {\t \"date\": \"1/28/2020\",\t \"date_ms\": 1580169600000,\t \"value\": 14\t },\t {\t \"date\": \"1/29/2020\",\t \"date_ms\": 1580256000000,\t \"value\": 14\t },\t {\t \"date\": \"1/30/2020\",\t \"date_ms\": 1580342400000,\t \"value\": 14\t },\t {\t \"date\": \"1/31/2020\",\t \"date_ms\": 1580428800000,\t \"value\": 19\t },\t {\t \"date\": \"2/1/2020\",\t \"date_ms\": 1580515200000,\t \"value\": 19\t },\t {\t \"date\": \"2/2/2020\",\t \"date_ms\": 1580601600000,\t \"value\": 19\t },\t {\t \"date\": \"2/3/2020\",\t \"date_ms\": 1580688000000,\t \"value\": 19\t },\t {\t \"date\": \"2/4/2020\",\t \"date_ms\": 1580774400000,\t \"value\": 25\t }\t ]\t }\t}\t*/","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":390,"y":1860,"wires":[["5c7c5e5.cede7a","195c38e4.b877d7","4ebbe35e.4b7b2c","24d31fa2.51206"]]},{"id":"654d7ff9.3ecc4","type":"debug","z":"da7d3608.233f08","name":"extended with new totals and conf cases","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":880,"y":1960,"wires":[]},{"id":"24d31fa2.51206","type":"debug","z":"da7d3608.233f08","name":"calculate date shift and death factor","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":810,"y":1840,"wires":[]},{"id":"4bf2c7f8.12a208","type":"change","z":"da7d3608.233f08","name":"running average location2","rules":[{"t":"set","p":"running_average_days","pt":"msg","to":"running_average_days","tot":"flow"},{"t":"set","p":"location2","pt":"msg","to":"(\t $x := running_average_days;\t\tlocation2.{\t \"total_deaths\" : $map(total_deaths,function($v,$i,$a) \t { (\t $v_min_x := $a[$i-$x+1]; /* take care this is circular !*/\t \t { \"date\" : (($v.date_ms+$v_min_x.date_ms)/2) ~> $fromMillis('[M]/[D]/[Y]'),\t \"date_ms\" : ($v.date_ms+$v_min_x.date_ms)/2,\t \"value\" : (($a ~> $filter (function($v1, $i1, $a1) { $i1 >= $i-$x+1 and $i1 <= $i})).value\t ~> $sum())/$x\t })\t })~> $filter (function($v, $i, $a) { $i>=$x-1}), \t \"total_confirmed_cases\" : $map(total_confirmed_cases,function($v,$i,$a) \t { (\t $v_min_x := $a[$i-$x+1]; /* take care this is circular !*/\t \t { \"date\" : (($v.date_ms+$v_min_x.date_ms)/2) ~> $fromMillis('[M]/[D]/[Y]'),\t \"date_ms\" : ($v.date_ms+$v_min_x.date_ms)/2,\t \"value\" : (($a ~> $filter (function($v1, $i1, $a1) { $i1 >= $i-$x+1 and $i1 <= $i})).value\t ~> $sum())/$x\t })\t })~> $filter (function($v, $i, $a) { $i>=$x-1})\t}\t)\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":890,"y":1680,"wires":[["9861bbd0.14ad18","bffa99f3.65b278"]]},{"id":"c7394d09.25a65","type":"change","z":"da7d3608.233f08","name":"running average location1","rules":[{"t":"set","p":"location1","pt":"msg","to":"(\t $x := running_average_days;\t\tlocation1.{\t \"total_deaths\" : $map(total_deaths,function($v,$i,$a) \t { (\t $v_min_x := $a[$i-$x+1]; /* take care this is circular !*/\t \t { \"date\" : (($v.date_ms+$v_min_x.date_ms)/2) ~> $fromMillis('[M]/[D]/[Y]'),\t \"date_ms\" : ($v.date_ms+$v_min_x.date_ms)/2,\t \"value\" : (($a ~> $filter (function($v1, $i1, $a1) { $i1 >= $i-$x+1 and $i1 <= $i})).value\t ~> $sum())/$x\t })\t })~> $filter (function($v, $i, $a) { $i>=$x-1}), \t \"total_confirmed_cases\" : $map(total_confirmed_cases,function($v,$i,$a) \t { (\t $v_min_x := $a[$i-$x+1]; /* take care this is circular !*/\t \t { \"date\" : (($v.date_ms+$v_min_x.date_ms)/2) ~> $fromMillis('[M]/[D]/[Y]'),\t \"date_ms\" : ($v.date_ms+$v_min_x.date_ms)/2,\t \"value\" : (($a ~> $filter (function($v1, $i1, $a1) { $i1 >= $i-$x+1 and $i1 <= $i})).value\t ~> $sum())/$x\t })\t })~> $filter (function($v, $i, $a) { $i>=$x-1})\t}\t)\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":890,"y":1760,"wires":[["78583155.8806b","fcf148a7.c73a08"]]},{"id":"9861bbd0.14ad18","type":"debug","z":"da7d3608.233f08","name":"running average location2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"location2","targetType":"msg","x":1190,"y":1680,"wires":[]},{"id":"cc025d1e.8ac83","type":"change","z":"da7d3608.233f08","name":"China","rules":[{"t":"set","p":"payload","pt":"msg","to":"China","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":690,"y":1080,"wires":[["178a0b6e.a40255"]]},{"id":"572424cb.d7435c","type":"change","z":"da7d3608.233f08","name":"Belgium","rules":[{"t":"set","p":"payload","pt":"msg","to":"Belgium","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":700,"y":1120,"wires":[["4c4cf2d5.a478fc"]]},{"id":"27e465f3.ab346a","type":"change","z":"da7d3608.233f08","name":"1/23/2020","rules":[{"t":"set","p":"payload","pt":"msg","to":"1/23/2020","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":630,"y":1380,"wires":[["1740dc.434d3f25"]]},{"id":"657155ef.49631c","type":"change","z":"da7d3608.233f08","name":"3/12/2020","rules":[{"t":"set","p":"payload","pt":"msg","to":"3/12/2020","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":630,"y":1420,"wires":[["38ff5c00.6b79d4"]]},{"id":"416625a6.320fdc","type":"ui_switch","z":"da7d3608.233f08","name":"","label":"scale","tooltip":"","group":"ce673549.1ea3f8","order":1,"width":"3","height":"1","passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":290,"y":1540,"wires":[["81daa768.259e58"]]},{"id":"81daa768.259e58","type":"change","z":"da7d3608.233f08","name":"","rules":[{"t":"set","p":"scale_location2","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":1540,"wires":[[]]},{"id":"172ae677.eef44a","type":"inject","z":"da7d3608.233f08","name":"","repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":150,"y":1540,"wires":[["416625a6.320fdc"]]},{"id":"1dd21bf5.0e8bd4","type":"switch","z":"da7d3608.233f08","name":"scale location2 ?","property":"scale_location2","propertyType":"flow","rules":[{"t":"false"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":170,"y":2020,"wires":[["ee41cb97.978688"],["f39294ca.4ff928"]]},{"id":"ee41cb97.978688","type":"change","z":"da7d3608.233f08","name":"","rules":[{"t":"set","p":"location2_death_factor","pt":"msg","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":450,"y":2000,"wires":[["f39294ca.4ff928"]]},{"id":"77e237a.be02bc8","type":"switch","z":"da7d3608.233f08","name":"loc2 = Hubei","property":"location_id2","propertyType":"msg","rules":[{"t":"eq","v":"China:Hubei","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":310,"y":1680,"wires":[["19d0e3c.380f21c"],["4bf2c7f8.12a208"]]},{"id":"19d0e3c.380f21c","type":"change","z":"da7d3608.233f08","name":"fix Hubei confirmed cases","rules":[{"t":"set","p":"location2","pt":"msg","to":"/* correction for Hubei:\t 1. we have assumed that on 12,13,14 February the actual number of \t confirmed cases is 1700, 1750 and 1800 instead of 0, 14840 and 6200 \t 2. we ignored the 1290 extra deaths reported at 17the april\t the 325 extra confirmed cases reported at 17the april */\t{\t \"total_deaths\" : $map(location2.total_deaths,\t function ($v,$i,$a){ {\t \"date\" : $v.date,\t \"date_ms\" : $v.date_ms,\t \"value\" : ( $v.date_ms < $toMillis('2020-04-17') ? $v.value :\t $v.value - 1290 )\t } }\t ),\t \"total_confirmed_cases\" : $map(location2.total_confirmed_cases, \t function ($v,$i,$a){ {\t \"date\" : $v.date,\t \"date_ms\" : $v.date_ms,\t \"value\" : ( $v.date_ms < 1581465600000 ? $v.value :\t $v.date = \"2/12/2020\" ? $v.value+1700 :\t \t $v.date = \"2/13/2020\" ? $v.value+1700+1750-14840 :\t $v.date_ms < $toMillis('2020-04-17') ? $v.value+1700+1750+1800-(14840+6200) :\t $v.value+1700+1750+1800-(14840+6200)-325)\t } }\t )\t}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":1660,"wires":[["4bf2c7f8.12a208"]]},{"id":"bffa99f3.65b278","type":"switch","z":"da7d3608.233f08","name":"loc1 = Hubei","property":"location_id1","propertyType":"msg","rules":[{"t":"eq","v":"China:Hubei","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":310,"y":1760,"wires":[["97681950.d046d8"],["c7394d09.25a65"]]},{"id":"97681950.d046d8","type":"change","z":"da7d3608.233f08","name":"fix Hubei confirmed cases","rules":[{"t":"set","p":"location1","pt":"msg","to":"/* correction for Hubei:\t 1. we have assumed that on 12,13,14 February the actual number of \t confirmed cases is 1700, 1750 and 1800 instead of 0, 14840 and 6200 \t 2. we ignored the 1290 extra deaths reported at 17the april\t the 325 extra confirmed cases reported at 17the april */\t{\t \"total_deaths\" : $map(location2.total_deaths,\t function ($v,$i,$a){ {\t \"date\" : $v.date,\t \"date_ms\" : $v.date_ms,\t \"value\" : ( $v.date_ms < $toMillis('2020-04-17') ? $v.value :\t $v.value - 1290 )\t } }\t ),\t \"total_confirmed_cases\" : $map(location2.total_confirmed_cases, \t function ($v,$i,$a){ {\t \"date\" : $v.date,\t \"date_ms\" : $v.date_ms,\t \"value\" : ( $v.date_ms < 1581465600000 ? $v.value :\t $v.date = \"2/12/2020\" ? $v.value+1700 :\t \t $v.date = \"2/13/2020\" ? $v.value+1700+1750-14840 :\t $v.date_ms < $toMillis('2020-04-17') ? $v.value+1700+1750+1800-(14840+6200) :\t $v.value+1700+1750+1800-(14840+6200)-325)\t } }\t )\t}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":570,"y":1740,"wires":[["c7394d09.25a65"]]},{"id":"d16e1ae4.7805c8","type":"link out","z":"da7d3608.233f08","name":"updating charts","links":["63aa89ef.dc8eb8"],"x":815,"y":1580,"wires":[]},{"id":"1ca695c6.a9f68a","type":"ui_text","z":"da7d3608.233f08","group":"6b90da1c.04f984","order":1,"width":0,"height":0,"name":"","label":"location_id","format":"{{msg.location_id1}}","layout":"row-spread","x":490,"y":2420,"wires":[]},{"id":"4a8c42.5a20a3c","type":"inject","z":"da7d3608.233f08","name":"init","repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":150,"y":2640,"wires":[["f496c1cb.c98b6"]]},{"id":"f496c1cb.c98b6","type":"change","z":"da7d3608.233f08","name":"","rules":[{"t":"set","p":"enabled","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":2640,"wires":[["d31b56fc.45d158"]]},{"id":"83a548db.2ed118","type":"link out","z":"da7d3608.233f08","name":"manual data added","links":["cf6b1622.6bdee8"],"x":1075,"y":2600,"wires":[]},{"id":"cf6b1622.6bdee8","type":"link in","z":"da7d3608.233f08","name":"updating charts","links":["83a548db.2ed118"],"x":360,"y":1580,"wires":[["c230e5ba.f6a238"]]},{"id":"377835de.682faa","type":"change","z":"da7d3608.233f08","name":"","rules":[{"t":"set","p":"enabled","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":2700,"wires":[["d31b56fc.45d158"]]},{"id":"e83cf31a.6a0c","type":"exec","z":"da7d3608.233f08","command":"curl -L https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-states.csv","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"get time_series us-states","x":230,"y":440,"wires":[["2e4b80c0.575e"],[],[]]},{"id":"2e4b80c0.575e","type":"switch","z":"da7d3608.233f08","name":"return code ok ?","property":"rc.code","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":500,"y":440,"wires":[["8634d522.229b98","66d78369.df5eac"]]},{"id":"8634d522.229b98","type":"csv","z":"da7d3608.233f08","name":"csv2array","sep":",","hdrin":true,"hdrout":"","multi":"mult","ret":"\\n","temp":"","skip":"0","strings":true,"x":480,"y":480,"wires":[["5828440d.a7fa2c","379bc576.a30dfa","75c5be17.eb801"]]},{"id":"1e88bdb2.1b0ff2","type":"inject","z":"da7d3608.233f08","name":"","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":100,"y":380,"wires":[["e83cf31a.6a0c"]]},{"id":"5828440d.a7fa2c","type":"debug","z":"da7d3608.233f08","name":"us states","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":700,"y":480,"wires":[]},{"id":"379bc576.a30dfa","type":"change","z":"da7d3608.233f08","name":"extend with US states","rules":[{"t":"set","p":"total_confirmed_cases","pt":"msg","to":"total_confirmed_cases ~> $append((\t $states := payload.state ~> $distinct();\t $payload := payload;\t $states@$st.{ \t \"location_id\" : ( \"US\" & \":\" & $st ),\t \"country_region\" : \"US\",\t \"province_state\" : $st,\t \"history\" : $payload[state = $st].{\t \"date\" : $fromMillis($toMillis(date),\"[M]/[D]/[Y]\"),\t \"date_ms\" : $toMillis(date),\t \"value\" : cases\t }\t }\t))\t\t/*\t\t example input\t \t {\t \"payload\": [\t {\t \"date\": \"2020-01-21\",\t \"state\": \"Washington\",\t \"fips\": 53,\t \"cases\": 1,\t \"deaths\": 8\t },\t {\t \"date\": \"2020-01-22\",\t \"state\": \"Washington\",\t \"fips\": 53,\t \"cases\": 1,\t \"deaths\": 11\t },\t {\t \"date\": \"2020-01-23\",\t \"state\": \"Washington\",\t \"fips\": 53,\t \"cases\": 1,\t \"deaths\": 0\t },\t {\t \"date\": \"2020-01-24\",\t \"state\": \"Illinois\",\t \"fips\": 17,\t \"cases\": 1,\t \"deaths\": 0\t },\t {\t \"date\": \"2020-01-24\",\t \"state\": \"Washington\",\t \"fips\": 53,\t \"cases\": 1,\t \"deaths\": 0\t },\t {\t \"date\": \"2020-01-25\",\t \"state\": \"California\",\t \"fips\": \"06\",\t \"cases\": 1,\t \"deaths\": 0\t },\t {\t \"date\": \"2020-01-25\",\t \"state\": \"Illinois\",\t \"fips\": 17,\t \"cases\": 1,\t \"deaths\": 0\t },\t {\t \"date\": \"2020-01-25\",\t \"state\": \"Washington\",\t \"fips\": 53,\t \"cases\": 1,\t \"deaths\": 0\t },\t {\t \"date\": \"2020-01-26\",\t \"state\": \"Arizona\",\t \"fips\": \"04\",\t \"cases\": 1,\t \"deaths\": 0\t }\t ]\t}\t*/","tot":"jsonata"},{"t":"set","p":"total_deaths","pt":"msg","to":"total_deaths ~> $append((\t $states := payload.state ~> $distinct();\t $payload := payload;\t $states@$st.{ \t \"location_id\" : ( \"US\" & \":\" & $st ),\t \"country_region\" : \"US\",\t \"province_state\" : $st,\t \"history\" : $payload[state = $st].{\t \"date\" : $fromMillis($toMillis(date),\"[M]/[D]/[Y]\"),\t \"date_ms\" : $toMillis(date),\t \"value\" : deaths\t }\t }\t))\t\t/*\t\texample input\t\t{\t \"total_deaths\" : [ \"death_array\"],\t \"total_confirmed_cases\" : [ \"conf_array\"],\t \"payload\": [\t {\t \"date\": \"2020-01-21\",\t \"state\": \"Washington\",\t \"fips\": 53,\t \"cases\": 1,\t \"deaths\": 8\t },\t {\t \"date\": \"2020-01-22\",\t \"state\": \"Washington\",\t \"fips\": 53,\t \"cases\": 4,\t \"deaths\": 11\t },\t {\t \"date\": \"2020-01-23\",\t \"state\": \"Washington\",\t \"fips\": 53,\t \"cases\": 1,\t \"deaths\": 0\t },\t {\t \"date\": \"2020-01-24\",\t \"state\": \"Illinois\",\t \"fips\": 17,\t \"cases\": 1,\t \"deaths\": 0\t },\t {\t \"date\": \"2020-01-24\",\t \"state\": \"Washington\",\t \"fips\": 53,\t \"cases\": 1,\t \"deaths\": 0\t },\t {\t \"date\": \"2020-01-25\",\t \"state\": \"California\",\t \"fips\": \"06\",\t \"cases\": 1,\t \"deaths\": 0\t },\t {\t \"date\": \"2020-01-25\",\t \"state\": \"Illinois\",\t \"fips\": 17,\t \"cases\": 1,\t \"deaths\": 0\t },\t {\t \"date\": \"2020-01-25\",\t \"state\": \"Washington\",\t \"fips\": 53,\t \"cases\": 1,\t \"deaths\": 0\t },\t {\t \"date\": \"2020-01-26\",\t \"state\": \"Arizona\",\t \"fips\": \"04\",\t \"cases\": 1,\t \"deaths\": 0\t }\t ]\t}\t\t*/","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":520,"wires":[["4c3905b.93aedfc","b96ef28a.4e6d4","b67e244.b2d07d8"]]},{"id":"4c3905b.93aedfc","type":"debug","z":"da7d3608.233f08","name":"extended with US states","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":890,"y":500,"wires":[]},{"id":"b67e244.b2d07d8","type":"change","z":"da7d3608.233f08","name":"10...","rules":[{"t":"set","p":"payload","pt":"msg","to":"10. storing in file ...","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1270,"y":520,"wires":[["19002c0a.7a7d24"]]},{"id":"66d78369.df5eac","type":"change","z":"da7d3608.233f08","name":"8...","rules":[{"t":"set","p":"payload","pt":"msg","to":"8. converting csv to array ... ","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1270,"y":420,"wires":[["19002c0a.7a7d24"]]},{"id":"75c5be17.eb801","type":"change","z":"da7d3608.233f08","name":"9....","rules":[{"t":"set","p":"payload","pt":"msg","to":"9. convert us states to proper json ...","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1270,"y":460,"wires":[["19002c0a.7a7d24"]]},{"id":"68343611.dcc4c8","type":"change","z":"da7d3608.233f08","name":"","rules":[{"t":"set","p":"running_average_days","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1250,"y":880,"wires":[[]]},{"id":"76caa84.13b7458","type":"change","z":"da7d3608.233f08","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"7","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":880,"wires":[["d7e66681.c9da08"]]},{"id":"d7e66681.c9da08","type":"ui_numeric","z":"da7d3608.233f08","name":"","label":"running average","tooltip":"","group":"ce673549.1ea3f8","order":2,"width":"4","height":"1","wrap":false,"passthru":true,"topic":"","format":"{{value}} days","min":"1","max":"20","step":1,"x":800,"y":880,"wires":[["68343611.dcc4c8"]]},{"id":"f2c7001a.ad7cc","type":"change","z":"da7d3608.233f08","name":"prepare reprod rate chart","rules":[{"t":"set","p":"payload","pt":"msg","to":"(\t /* graph starts from (lock_down_date - 1 week) */\t $location2_timeshift_ms := location2_timeshift_ms;\t $location2_death_factor := location2_death_factor;\t $start_x := $toMillis(lock_down_date1,\"[M]/[D]/[Y]\")-(7*24*60*60*1000);\t [{ \t \"series\": [ \"limit\", location_id1, location_id2 \t & (($location2_timeshift_ms !=0) ?'- shifted':'')],\t \"data\" : [ \t [$map(location1.new_confirmed_cases,\t function($v, $i, $a) { { \"x\": $v.date_ms, \t \"y\": ( ($a[$i+7].value>10) and ($v.value>10) ?\t 1 :\t -1) } } )[(x >= $start_x) and (y >= 0)] ],\t [$map(location1.new_confirmed_cases,\t function($v, $i, $a) { { \"x\": $v.date_ms, \t \"y\": ( ($a[$i+7].value>10) and ($v.value>10) ?\t $a[$i+7].value/$v.value :\t -1) } } )[(x >= $start_x) and (y >= 0)] ],\t [$map(location2.new_confirmed_cases,\t function($v, $i, $a) { { \"x\": $v.date_ms + $location2_timeshift_ms, \t \"y\":( ($a[$i+7].value>10) and ($v.value>10) ?\t $a[$i+7].value/$v.value :\t -1) }} )[(x >= $start_x) and (y >= 0)]]\t ],\t \"labels\": [\"\"]\t }]\t)\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":2300,"wires":[["46f8ffea.a0292","86892c8a.67f27"]]},{"id":"46f8ffea.a0292","type":"ui_chart","z":"da7d3608.233f08","name":"","group":"a31f3c67.3e6a2","order":2,"width":9,"height":7,"label":"reproduction rate (based on new conf cases)","chartType":"line","legend":"true","xformat":"D/M","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"5","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#ff2600","#008f00","#0433ff","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":990,"y":2240,"wires":[[]]},{"id":"fcf148a7.c73a08","type":"debug","z":"da7d3608.233f08","name":"running average location1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"location1","targetType":"msg","x":1190,"y":1760,"wires":[]},{"id":"86892c8a.67f27","type":"debug","z":"da7d3608.233f08","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":830,"y":2320,"wires":[]},{"id":"898c2956.2aa3b8","type":"change","z":"da7d3608.233f08","name":"prepare infection fatality rate chart","rules":[{"t":"set","p":"payload","pt":"msg","to":"(\t /* graph starts from (lock_down_date - 1 week) */\t $location2_timeshift_ms := location2_timeshift_ms;\t $location2_death_factor := location2_death_factor;\t $location1_new_deaths := location1.new_deaths;\t $location2_new_deaths := location2.new_deaths;\t $start_x := $toMillis(lock_down_date1,\"[M]/[D]/[Y]\")-(7*24*60*60*1000);\t /* graph stops at ( current date + 1 week) */\t $end_x := $toMillis($now())+ (7*24*60*60*1000);\t [{ \t\"series\": [ location_id1, location_id2 \t & (($location2_timeshift_ms !=0)?'- shifted':'')],\t \"data\" : [ \t [$map(location1.new_confirmed_cases,\t function($v, $i, $a) { { \"x\": $v.date_ms, \t \"y\": ( \t $new_deaths_plus_8 := $location1_new_deaths[$i+8].value;\t $new_deaths_plus_8 *100 / $v.value\t ) } } )[(x >= $start_x) and (y >= 0)]]\t ,\t [$map(location2.new_confirmed_cases,\t function($v, $i, $a) { { \"x\": $v.date_ms + $location2_timeshift_ms, \t \"y\": ( \t $new_deaths_plus_8 := $location2_new_deaths[$i+8].value;\t $new_deaths_plus_8 * 100 / $v.value\t ) \t } } )[(x >= $start_x) and (y >= 0)]]\t ],\t \"labels\": [\"\"]\t }]\t)\t/*\t[{\t\"series\": [\"A\", \"B\", \"C\"],\t\"data\": [\t [{ \"x\": 1504029632890, \"y\": 5 },\t { \"x\": 1504029636001, \"y\": 4 },\t { \"x\": 1504029638656, \"y\": 2 }\t ],\t [{ \"x\": 1504029633514, \"y\": 6 },\t { \"x\": 1504029636622, \"y\": 7 },\t { \"x\": 1504029639539, \"y\": 6 }\t ],\t [{ \"x\": 1504029634400, \"y\": 7 },\t { \"x\": 1504029637959, \"y\": 7 },\t { \"x\": 1504029640317, \"y\": 7 }\t ]\t],\t\"labels\": [\"\"]\t}]\t\texample input message\t\t*/","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":2200,"wires":[["a3fff518.6ad538","f2c7001a.ad7cc"]]},{"id":"2052e0bf.129c5","type":"debug","z":"da7d3608.233f08","name":"prepare new deaths chart","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1350,"y":2100,"wires":[]},{"id":"6a5c7199.1a264","type":"staticMarkdown","z":"eb3e18e.d4e24e8","name":"","topic":"","url":"docs/","source":"/data/docs","x":230,"y":40,"wires":[]}]