├── sql ├── TestData_Errors.log ├── TestData.sql └── usamap.sql ├── .dockerignore ├── .gitignore ├── .gitattributes ├── .infra ├── terraform │ ├── regional-ip.tf │ ├── terraform.tf │ └── gke.tf ├── kubernetes │ ├── iris-claim0-persistentvolumeclaim.yaml │ ├── iris-ingress.yaml │ ├── iris-service.yaml │ └── iris-deployment.yaml └── cert-manager │ ├── lets-encrypt-production.yaml │ └── lets-encrypt-staging.yaml ├── memo.md ├── src ├── Covid19 │ ├── UpdateTask.cls │ ├── WorldKPI.cls │ ├── Place.cls │ ├── Day.cls │ ├── CovidDays.cls │ ├── Utils.cls │ └── Countries.cls ├── User │ ├── CT │ │ ├── EventType.cls │ │ └── CodeDescAbstract.cls │ ├── Utils.cls │ ├── Cube │ │ └── SleepRecordCube.cls │ ├── SleepStudy.cls │ └── SleepRecord.cls ├── USA │ ├── City.cls │ ├── BI │ │ ├── Elections.cls │ │ ├── USCube.cls │ │ └── CovidCube.cls │ ├── Elections.cls │ ├── Parameter.cls │ ├── Area.cls │ ├── ParameterValue.cls │ ├── Region.cls │ ├── Covid.cls │ └── Borders.cls ├── AnalyzeThis │ ├── GenerateImportCSV.cls │ └── Generated │ │ ├── covid03162020Cube.cls │ │ └── covid03162020.cls ├── dfi │ ├── Test │ │ └── heatmap.dashboard.xml │ └── Covid19 │ │ ├── bubble chart.dashboard.xml │ │ ├── Deaths.pivot.xml │ │ ├── Confirmed.pivot.xml │ │ ├── Recovered.pivot.xml │ │ ├── Worldmap.dashboard.xml │ │ ├── DailyDeaths.pivot.xml │ │ ├── DailyConfirmed.pivot.xml │ │ ├── CountryConfirmed.pivot.xml │ │ ├── Daily.pivot.xml │ │ ├── Figures.pivot.xml │ │ ├── Countries.dashboard.xml │ │ ├── DeathsTotal.pivot.xml │ │ ├── ConfirmedTotal.pivot.xml │ │ ├── USA.dashboard.xml │ │ ├── Worldmap.pivot.xml │ │ ├── Status.pivot.xml │ │ ├── Daily.dashboard.xml │ │ ├── Countries_bubble.pivot.xml │ │ ├── USA Map Details.pivot.xml │ │ ├── Countries.pivot.xml │ │ └── USA │ │ ├── DeathsOnMap.pivot.xml │ │ └── ConfirmedOnMap.pivot.xml └── gbl │ └── DeepSee │ └── TermList.GBL.xml ├── docker-compose.yml ├── irissession.sh ├── .vscode ├── launch.json └── settings.json ├── iris.script ├── dev.md ├── Installer.cls ├── LICENSE ├── Dockerfile ├── dsw ├── irisapp_old.json └── irisapp.json ├── Terraform.md ├── README.md └── .github └── workflows └── irisapp.yaml /sql/TestData_Errors.log: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | **/.DS_Store 2 | .git -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | 3 | 4 | github-covid19.json 5 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.sh text eol=lf 2 | *.cls text eol=lf 3 | *.mac text eol=lf 4 | *.int text eol=lf 5 | Dockerfil* text eol=lf -------------------------------------------------------------------------------- /.infra/terraform/regional-ip.tf: -------------------------------------------------------------------------------- 1 | resource "google_compute_address" "scope" { 2 | name = "covid19-regional" 3 | region = "europe-west2" 4 | } 5 | -------------------------------------------------------------------------------- /memo.md: -------------------------------------------------------------------------------- 1 | ## COVID19 Pandemia Stats 2 | ### LAST UPDATED 3 | 19 March 2020 4 | ### Data Source 5 | [John Hopkins](https://github.com/CSSEGISandData/COVID-19) 6 | -------------------------------------------------------------------------------- /src/Covid19/UpdateTask.cls: -------------------------------------------------------------------------------- 1 | Class Covid19.UpdateTask Extends %SYS.Task.Definition 2 | { 3 | 4 | Method OnTask() As %Status 5 | { 6 | return ##class(Covid19.Utils).DailyUpdate() 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.6' 2 | services: 3 | iris: 4 | build: 5 | context: . 6 | dockerfile: Dockerfile 7 | restart: always 8 | ports: 9 | - 51773 10 | - 32916:52773 11 | - 53773 12 | volumes: 13 | - ./:/irisdev/app -------------------------------------------------------------------------------- /.infra/terraform/terraform.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.12" 3 | backend "gcs" { 4 | bucket = "terraform-covid2019-analytics" 5 | prefix = "covid19-state" 6 | } 7 | } 8 | 9 | provider "google" { 10 | version = "3.41.0" 11 | project = "covid2019-analytics" 12 | region = "europe-west2" 13 | } 14 | 15 | -------------------------------------------------------------------------------- /.infra/kubernetes/iris-claim0-persistentvolumeclaim.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: PersistentVolumeClaim 3 | metadata: 4 | creationTimestamp: null 5 | labels: 6 | io.kompose.service: iris-claim0 7 | name: iris-claim0 8 | spec: 9 | accessModes: 10 | - ReadWriteOnce 11 | resources: 12 | requests: 13 | storage: 100Mi 14 | status: {} 15 | -------------------------------------------------------------------------------- /.infra/cert-manager/lets-encrypt-production.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: cert-manager.io/v1 2 | kind: ClusterIssuer 3 | metadata: 4 | name: lets-encrypt-production 5 | spec: 6 | acme: 7 | email: mvhoma@gmail.com 8 | server: https://acme-v02.api.letsencrypt.org/directory 9 | privateKeySecretRef: 10 | name: lets-encrypt-production 11 | solvers: 12 | - http01: 13 | ingress: 14 | class: nginx 15 | 16 | -------------------------------------------------------------------------------- /.infra/cert-manager/lets-encrypt-staging.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: cert-manager.io/v1 2 | kind: ClusterIssuer 3 | metadata: 4 | name: lets-encrypt-staging 5 | spec: 6 | acme: 7 | email: mvhoma@gmail.com 8 | server: https://acme-staging-v02.api.letsencrypt.org/directory 9 | privateKeySecretRef: 10 | name: lets-encrypt-staging 11 | solvers: 12 | - http01: 13 | ingress: 14 | class: nginx 15 | 16 | -------------------------------------------------------------------------------- /irissession.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | iris start $ISC_PACKAGE_INSTANCENAME quietly 4 | 5 | cat << EOF | iris session $ISC_PACKAGE_INSTANCENAME -U %SYS 6 | do ##class(%SYSTEM.Process).CurrentDirectory("$PWD") 7 | $@ 8 | if '\$Get(sc) do ##class(%SYSTEM.Process).Terminate(, 1) 9 | zn "%SYS" 10 | do ##class(SYS.Container).QuiesceForBundling() 11 | Do ##class(Security.Users).UnExpireUserPasswords("*") 12 | halt 13 | EOF 14 | 15 | exit=$? 16 | 17 | iris stop $ISC_PACKAGE_INSTANCENAME quietly 18 | 19 | exit $exit -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "type": "objectscript", 6 | "request": "launch", 7 | "name": "ObjectScript Debug Class", 8 | "program": "##class(PackageSample.ObjectScript).Test()", 9 | }, 10 | { 11 | "type": "objectscript", 12 | "request": "attach", 13 | "name": "ObjectScript Attach", 14 | "processId": "${command:PickProcess}", 15 | "system": true 16 | } 17 | ] 18 | } -------------------------------------------------------------------------------- /.infra/kubernetes/iris-ingress.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: networking.k8s.io/v1beta1 2 | kind: Ingress 3 | metadata: 4 | name: iris 5 | annotations: 6 | kubernetes.io/ingress.class: nginx 7 | cert-manager.io/cluster-issuer: lets-encrypt-production 8 | spec: 9 | rules: 10 | - host: covid19.myardyas.club 11 | http: 12 | paths: 13 | - backend: 14 | serviceName: iris 15 | servicePort: 52773 16 | path: / 17 | tls: 18 | - hosts: 19 | - covid19.myardyas.club 20 | secretName: covid19.myardyas.club -------------------------------------------------------------------------------- /iris.script: -------------------------------------------------------------------------------- 1 | zn "%SYS" 2 | Do ##class(Security.Users).UnExpireUserPasswords("*") 3 | do $SYSTEM.OBJ.Load("/opt/irisapp/Installer.cls", "ck") 4 | set sc = ##class(App.Installer).setup() 5 | zn "IRISAPP" 6 | zpm "install sslclient" 7 | zpm "install csvgen" 8 | do ##class(Covid19.Utils).ImportData() 9 | do ##class(Covid19.Utils).BISetup() 10 | do ##class(Covid19.Utils).CreateTask() 11 | do ##class(User.Utils).Setup() 12 | zpm "install dsw" 13 | zpm "install isc-dev" 14 | do ##class(dev.code).workdir("/irisdev/app/src") 15 | do EnableDeepSee^%SYS.cspServer("/csp/irisapp/") 16 | do ##class(Covid19.Utils).OpenToPublic() 17 | halt 18 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | 4 | "Dockerfile*": "dockerfile", 5 | "*.script":"objectscript" 6 | }, 7 | "objectscript.conn" :{ 8 | "username": "_SYSTEM", 9 | "password": "SYS", 10 | "ns": "IRISAPP", 11 | "active": true, 12 | "docker-compose": { 13 | "service": "iris", 14 | "internalPort": 52773 15 | },"links": { 16 | "COVID-19 Analytics": "http://localhost:${port}/dsw/index.html#!/?ns=IRISAPP", 17 | "Architect": "http://localhost:${port}/csp/irisapp/_DeepSee.UI.Architect.zen?$NAMESPACE=IRISAPP" 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /.infra/kubernetes/iris-service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | annotations: 5 | kompose.cmd: kompose convert -f docker-compose.yml -o .infra/kubernetes/ 6 | kompose.version: 1.19.0 (f63a961c) 7 | creationTimestamp: null 8 | labels: 9 | io.kompose.service: iris 10 | name: iris 11 | spec: 12 | ports: 13 | - name: "51773" 14 | port: 51773 15 | targetPort: 51773 16 | - name: "52773" 17 | port: 52773 18 | targetPort: 52773 19 | - name: "53773" 20 | port: 53773 21 | targetPort: 53773 22 | selector: 23 | io.kompose.service: iris 24 | type: ClusterIP 25 | status: 26 | loadBalancer: {} 27 | -------------------------------------------------------------------------------- /dev.md: -------------------------------------------------------------------------------- 1 | # useful commands 2 | ## build container with no cache 3 | ``` 4 | docker-compose build --no-cache 5 | ``` 6 | ## open terminal to docker 7 | ``` 8 | docker-compose exec iris iris session iris -U IRISAPP 9 | ``` 10 | ## export IRIS Analytics artifacts 11 | ``` 12 | d ##class(dev.code).export("*.DFI") 13 | ``` 14 | 15 | ## import countries 16 | ``` 17 | d ##class(community.csvgen).GenerateFromURL("https://raw.githubusercontent.com/datasciencedojo/datasets/master/WorldDBTables/CountryTable.csv",",","Covid19.Countries") 18 | ``` 19 | 20 | ## sql error handling 21 | ``` 22 | &sql() 23 | if SQLCODE < 0 throw ##class(%Exception.SQL).CreateFromSQLCODE(SQLCODE,"Context") 24 | ``` 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/User/CT/EventType.cls: -------------------------------------------------------------------------------- 1 | Class User.CT.EventType Extends (%Persistent, CodeDescAbstract) 2 | { 3 | 4 | Storage Default 5 | { 6 | 7 | 8 | %%CLASSNAME 9 | 10 | 11 | Active 12 | 13 | 14 | Code 15 | 16 | 17 | Description 18 | 19 | 20 | ^User.CT.EventTypeD 21 | EventTypeDefaultData 22 | ^User.CT.EventTypeD 23 | ^User.CT.EventTypeI 24 | ^User.CT.EventTypeS 25 | %Storage.Persistent 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /.infra/terraform/gke.tf: -------------------------------------------------------------------------------- 1 | resource "google_container_cluster" "scope" { 2 | name = "covid19" 3 | location = "europe-west2-b" 4 | remove_default_node_pool = true 5 | initial_node_count = 1 6 | min_master_version = "1.17" 7 | } 8 | 9 | resource "google_container_node_pool" "scope" { 10 | name = "covid19-node-pool" 11 | location = "europe-west2-b" 12 | cluster = google_container_cluster.scope.name 13 | node_count = 2 14 | version = "1.17.12-gke.500" 15 | 16 | node_config { 17 | preemptible = false 18 | machine_type = "n1-standard-1" 19 | oauth_scopes = [ 20 | "storage-ro", 21 | "logging-write", 22 | "monitoring" 23 | ] 24 | } 25 | 26 | management { 27 | auto_repair = true 28 | auto_upgrade = false 29 | } 30 | } 31 | 32 | -------------------------------------------------------------------------------- /src/Covid19/WorldKPI.cls: -------------------------------------------------------------------------------- 1 | /// Use or operation of this code is subject to acceptance of the license available in the code repository for this code. 2 | /// Example KPI definition using SQL statements against the HoleFoods transaction data. 3 | Class Covid19.WorldKPI Extends %DeepSee.KPI 4 | { 5 | 6 | /// This XData definition defines the KPI. 7 | XData KPI [ XMLNamespace = "http://www.intersystems.com/deepsee/kpi" ] 8 | { 9 | 15 | 16 | 17 | 18 | 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/USA/City.cls: -------------------------------------------------------------------------------- 1 | Class USA.City Extends Area 2 | { 3 | 4 | /// County 5 | Relationship Region As Region(XMLPROJECTION = "XELEMENT", XMLREFERENCE = "ID") [ Cardinality = one, Inverse = Cities ]; 6 | 7 | /// 1 - capital of state or county, 0-ordinary city 8 | Property SpecialIcon As %Boolean [ Required ]; 9 | 10 | Property Latitude As %Float [ Required ]; 11 | 12 | Property Longitude As %Float [ Required ]; 13 | 14 | Index RegionIdx On Region; 15 | 16 | Storage Default 17 | { 18 | 19 | "City" 20 | 21 | Region 22 | 23 | 24 | Latitude 25 | 26 | 27 | Longitude 28 | 29 | 30 | SpecialIcon 31 | 32 | 33 | CityDefaultData 34 | %Storage.Persistent 35 | } 36 | 37 | } 38 | 39 | -------------------------------------------------------------------------------- /src/USA/BI/Elections.cls: -------------------------------------------------------------------------------- 1 | Class USA.Elections Extends %Persistent 2 | { 3 | 4 | Property RegionName As %String; 5 | 6 | Property Guid As %String; 7 | 8 | Property Trump As %Integer; 9 | 10 | Property Clinton As %Integer; 11 | 12 | Index GuidIdx On Guid [ Unique ]; 13 | 14 | Storage Default 15 | { 16 | 17 | 18 | %%CLASSNAME 19 | 20 | 21 | RegionName 22 | 23 | 24 | Guid 25 | 26 | 27 | Trump 28 | 29 | 30 | Clinton 31 | 32 | 33 | ^USA.ElectionsD 34 | ElectionsDefaultData 35 | ^USA.ElectionsD 36 | ^USA.ElectionsI 37 | ^USA.ElectionsS 38 | %Library.CacheStorage 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/USA/Elections.cls: -------------------------------------------------------------------------------- 1 | Class USA.Elections Extends %Persistent 2 | { 3 | 4 | Property RegionName As %String; 5 | 6 | Property Guid As %String; 7 | 8 | Property Trump As %Integer; 9 | 10 | Property Clinton As %Integer; 11 | 12 | Index GuidIdx On Guid [ Unique ]; 13 | 14 | Storage Default 15 | { 16 | 17 | 18 | %%CLASSNAME 19 | 20 | 21 | RegionName 22 | 23 | 24 | Guid 25 | 26 | 27 | Trump 28 | 29 | 30 | Clinton 31 | 32 | 33 | ^USA.ElectionsD 34 | ElectionsDefaultData 35 | ^USA.ElectionsD 36 | ^USA.ElectionsI 37 | ^USA.ElectionsS 38 | %Storage.Persistent 39 | } 40 | 41 | } 42 | 43 | -------------------------------------------------------------------------------- /src/Covid19/Place.cls: -------------------------------------------------------------------------------- 1 | Class Covid19.Place Extends %Persistent 2 | { 3 | 4 | Property CountryRegion As %String(MAXLEN = ""); 5 | 6 | Property Latitude As %String(MAXLEN = ""); 7 | 8 | Property Longitude As %String(MAXLEN = ""); 9 | 10 | Property ProvinceState As %String(MAXLEN = ""); 11 | 12 | Storage Default 13 | { 14 | 15 | 16 | %%CLASSNAME 17 | 18 | 19 | CountryRegion 20 | 21 | 22 | Latitude 23 | 24 | 25 | Longitude 26 | 27 | 28 | ProvinceState 29 | 30 | 31 | ^Covid19.PlaceD 32 | PlaceDefaultData 33 | ^Covid19.PlaceD 34 | ^Covid19.PlaceI 35 | ^Covid19.PlaceS 36 | %Storage.Persistent 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/USA/Parameter.cls: -------------------------------------------------------------------------------- 1 | Class USA.Parameter Extends (%Persistent, %XML.Adaptor) 2 | { 3 | 4 | Property Name As %String [ Required ]; 5 | 6 | Property UnitName As %String; 7 | 8 | Relationship Values As ParameterValue [ Cardinality = many, Inverse = Parameter ]; 9 | 10 | ClassMethod GetIdByName(name As %String) As %String 11 | { 12 | set id=0 13 | &sql(SELECT ID INTO :id FROM USA.Parameter WHERE Name = :name) 14 | quit id 15 | } 16 | 17 | Storage Default 18 | { 19 | 20 | 21 | %%CLASSNAME 22 | 23 | 24 | Name 25 | 26 | 27 | UnitName 28 | 29 | 30 | ^USA.ParameterD 31 | ParameterDefaultData 32 | 100000 33 | ^USA.ParameterD 34 | ^USA.ParameterI 35 | ^USA.ParameterS 36 | %Storage.Persistent 37 | } 38 | 39 | } 40 | 41 | -------------------------------------------------------------------------------- /src/User/Utils.cls: -------------------------------------------------------------------------------- 1 | Class User.Utils 2 | { 3 | 4 | ClassMethod Setup() 5 | { 6 | do ..ImportData() 7 | do ##class(%DeepSee.Utils).%BuildCube("SleepRecord") 8 | } 9 | 10 | ClassMethod ImportData() As %Status 11 | { 12 | set fn="/opt/irisapp/sql/TestData.sql" 13 | set str=$System.SQL.DDLImport("IRIS",$Username,fn,"/tmp/sql_err.log",,,";") 14 | q $$$OK 15 | } 16 | 17 | ClassMethod ImportDataClassic() As %Status 18 | { 19 | set fn="/irisdev/app/sql/TestData.sql" 20 | set stream=..GetStreamFromFile(fn) 21 | 22 | while 'stream.AtEnd { 23 | set line=stream.ReadLine() 24 | 25 | } 26 | 27 | set sc = st.%Prepare(sql) 28 | quit:$$$ISERR(sc) sc 29 | 30 | #dim result As %SQL.StatementResult 31 | set result = st.%Execute(args...) 32 | } 33 | 34 | ClassMethod GetStreamFromFile(fn As %String) As %Stream 35 | { 36 | set stream = ##Class(%Stream.FileCharacter).%New() 37 | set stream.LineTerminator = $Char(13,10) 38 | $$$TOE(sc,stream.LinkToFile(fn)) 39 | //TBD check for sc 40 | return stream 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/AnalyzeThis/GenerateImportCSV.cls: -------------------------------------------------------------------------------- 1 | Class AnalyzeThis.GenerateImportCSV 2 | { 3 | 4 | // 1. Delete class AnalyzeThis.Generated.covid03162020 on the server 5 | 6 | // 2 call Run method which will generated together with Import method 7 | 8 | // 3. Export class AnalyzeThis.Generated.covid03162020 and copy-n-paste properties from repo from the same class 9 | 10 | // 4. Use method Import to import the data from file 11 | 12 | ClassMethod Run() As %Status 13 | { 14 | s pfile="/irisdev/app/data/covid-03-16-2020.csv" 15 | s rowtype="ProvinceState VARCHAR(100),CountryRegion VARCHAR(100),LastUpdate DATE,Confirmed INTEGER,Deaths INTEGER,Recovered INTEGER,Latitude VARCHAR(50),Longitude VARCHAR(50)" 16 | s pclass="AnalyzeThis.Generated.covid03162020" 17 | do ##class(%SQL.Util.Procedures).CSVTOCLASS(, rowtype, pfile,",", ,1, pclass,,) 18 | q $$$OK 19 | } 20 | 21 | ClassMethod Import() As %Status 22 | { 23 | s pfile="/irisdev/app/data/covid-03-23-2020.csv" 24 | s rc=0 25 | do ##class(AnalyzeThis.Generated.covid03162020).Import(,pfile,",", ,1, rc) 26 | w rc 27 | q $$$OK 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/USA/Area.cls: -------------------------------------------------------------------------------- 1 | /// Region, County, City 2 | Class USA.Area Extends (%Persistent, %XML.Adaptor) 3 | { 4 | 5 | /// Name of state|county|city 6 | Property Name As %String(MAXLEN = 500) [ Required ]; 7 | 8 | /// Guid for polygons in js file 9 | Property Guid As %String [ Required ]; 10 | 11 | /// Link to Wiki article 12 | Property DataUrl As %String(MAXLEN = 500); 13 | 14 | /// All values 15 | Relationship Parameters As ParameterValue [ Cardinality = many, Inverse = Area ]; 16 | 17 | Index GuidIdx On Guid [ IdKey, Unique ]; 18 | 19 | Storage Default 20 | { 21 | 22 | 23 | %%CLASSNAME 24 | 25 | 26 | Name 27 | 28 | 29 | DataUrl 30 | 31 | 32 | ^USA.AreaD 33 | AreaDefaultData 34 | 100000 35 | ^USA.AreaD 36 | ^USA.AreaI 37 | ^USA.AreaS 38 | %Storage.Persistent 39 | } 40 | 41 | } 42 | 43 | -------------------------------------------------------------------------------- /Installer.cls: -------------------------------------------------------------------------------- 1 | Class App.Installer 2 | { 3 | 4 | XData setup 5 | { 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 21 | 22 | 23 | 24 | } 25 | 26 | ClassMethod setup(ByRef pVars, pLogLevel As %Integer = 3, pInstaller As %Installer.Installer, pLogger As %Installer.AbstractLogger) As %Status [ CodeMode = objectgenerator, Internal ] 27 | { 28 | #; Let XGL document generate code for this method. 29 | Quit ##class(%Installer.Manifest).%Generate(%compiledclass, %code, "setup") 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 InterSystems Developer Community 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | ARG IMAGE=store/intersystems/irishealth:2019.3.0.308.0-community 2 | ARG IMAGE=store/intersystems/iris-community:2019.3.0.309.0 3 | ARG IMAGE=store/intersystems/iris-community:2019.4.0.379.0 4 | ARG IMAGE=store/intersystems/iris-community:2020.1.0.199.0 5 | ARG IMAGE=intersystemsdc/iris-community:2019.4.0.383.0-zpm 6 | ARG IMAGE=intersystemsdc/iris-community:2020.1.0.209.0-zpm 7 | ARG IMAGE=intersystemsdc/iris-community:2020.3.0.200.0-zpm 8 | ARG IMAGE=intersystemsdc/iris-community:2020.2.0.196.0-zpm 9 | FROM $IMAGE 10 | 11 | USER root 12 | 13 | WORKDIR /opt/irisapp 14 | RUN chown ${ISC_PACKAGE_MGRUSER}:${ISC_PACKAGE_IRISGROUP} /opt/irisapp 15 | 16 | USER irisowner 17 | 18 | COPY Installer.cls . 19 | COPY src src 20 | COPY data files 21 | COPY sql sql 22 | COPY js /usr/irissys/csp/irisapp 23 | COPY iris.script /tmp/iris.script 24 | 25 | RUN iris start IRIS \ 26 | && iris session IRIS < /tmp/iris.script \ 27 | && iris stop IRIS quietly 28 | 29 | COPY /dsw/irisapp.json /usr/irissys/csp/dsw/configs/ 30 | COPY /dsw/DSW.WorldMap.js /usr/irissys/csp/dsw/addons/ 31 | COPY /dsw/heatmapChart.js /usr/irissys/csp/dsw/addons/ 32 | # USER root 33 | # RUN chmod 777 /usr/irissys/csp/dsw/addons/worldmap.js 34 | # USER irisowner 35 | 36 | -------------------------------------------------------------------------------- /src/Covid19/Day.cls: -------------------------------------------------------------------------------- 1 | Class Covid19.Day Extends %Persistent 2 | { 3 | 4 | Property Confirmed As %Integer; 5 | 6 | Property ConfirmedNew As %Integer; 7 | 8 | Property Deaths As %Integer; 9 | 10 | Property DeathsNew As %Integer; 11 | 12 | Property Day As %Date; 13 | 14 | Property Recovered As %Integer; 15 | 16 | Property Place As Place; 17 | 18 | Storage Default 19 | { 20 | 21 | 22 | %%CLASSNAME 23 | 24 | 25 | Confirmed 26 | 27 | 28 | Deaths 29 | 30 | 31 | Day 32 | 33 | 34 | Recovered 35 | 36 | 37 | Place 38 | 39 | 40 | ConfirmedDelta 41 | 42 | 43 | ConfirmedNew 44 | 45 | 46 | DeathsNew 47 | 48 | 49 | ^Covid19.DayD 50 | DayDefaultData 51 | ^Covid19.DayD 52 | ^Covid19.DayI 53 | ^Covid19.DayS 54 | %Storage.Persistent 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /.infra/kubernetes/iris-deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | annotations: 5 | kompose.cmd: kompose convert -f docker-compose.yml -o .infra/kubernetes/ 6 | kompose.version: 1.19.0 (f63a961c) 7 | creationTimestamp: null 8 | labels: 9 | io.kompose.service: iris 10 | name: iris 11 | spec: 12 | replicas: 1 13 | strategy: 14 | type: Recreate 15 | selector: 16 | matchLabels: 17 | io.kompose.service: iris 18 | template: 19 | metadata: 20 | annotations: 21 | kompose.cmd: kompose convert -f docker-compose.yml -o .infra/kubernetes/ 22 | kompose.version: 1.19.0 (f63a961c) 23 | creationTimestamp: null 24 | labels: 25 | io.kompose.service: iris 26 | spec: 27 | shareProcessNamespace: true 28 | containers: 29 | - image: iris 30 | name: iris 31 | ports: 32 | - containerPort: 51773 33 | - containerPort: 52773 34 | - containerPort: 53773 35 | resources: {} 36 | volumeMounts: 37 | - mountPath: /irisdev/app 38 | name: iris-claim0 39 | restartPolicy: Always 40 | volumes: 41 | - name: iris-claim0 42 | persistentVolumeClaim: 43 | claimName: iris-claim0 44 | status: {} 45 | -------------------------------------------------------------------------------- /src/USA/ParameterValue.cls: -------------------------------------------------------------------------------- 1 | Class USA.ParameterValue Extends (%Persistent, %XML.Adaptor) 2 | { 3 | 4 | /// State, county or city 5 | Relationship Area As Area(XMLPROJECTION = "XELEMENT", XMLREFERENCE = "ID") [ Cardinality = one, Inverse = Parameters ]; 6 | 7 | /// Parameter 8 | Relationship Parameter As Parameter(XMLPROJECTION = "XELEMENT", XMLREFERENCE = "ID") [ Cardinality = one, Inverse = Values ]; 9 | 10 | /// Value for region|county|city 11 | Property Value As %Float [ Required ]; 12 | 13 | Index PVIdx On (Area, Parameter); 14 | 15 | Index RegionParameterIndex On (Area, Parameter) [ Unique ]; 16 | 17 | Storage Default 18 | { 19 | 20 | 21 | %%CLASSNAME 22 | 23 | 24 | Area 25 | 26 | 27 | Parameter 28 | 29 | 30 | Value 31 | 32 | 33 | ^USA.ParameterValueD 34 | ParameterValueDefaultData 35 | 100000 36 | ^USA.ParameterValueD 37 | ^USA.ParameterValueI 38 | ^USA.ParameterValueS 39 | %Storage.Persistent 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/USA/Region.cls: -------------------------------------------------------------------------------- 1 | /// State or county 2 | Class USA.Region Extends Area 3 | { 4 | 5 | /// Capital for state. seat - for county 6 | Property Capital As City(XMLREFERENCE = "ID"); 7 | 8 | /// DefaultZoom 9 | Property DefaultZoom As %Integer; 10 | 11 | /// Level in the hierarchy 12 | Property HLevel As %Integer [ Required ]; 13 | 14 | /// Parent of region. For state=null, for county=state 15 | Relationship ParentRegion As Region(XMLPROJECTION = "XELEMENT", XMLREFERENCE = "ID") [ Cardinality = one, Inverse = ChildrenRegions ]; 16 | 17 | /// Region childrens. For state=counties, for county=0 18 | Relationship ChildrenRegions As Region [ Cardinality = many, Inverse = ParentRegion ]; 19 | 20 | /// Cities in county 21 | Relationship Cities As City [ Cardinality = many, Inverse = Region ]; 22 | 23 | Index ParentRegionIdx On ParentRegion; 24 | 25 | Storage Default 26 | { 27 | 28 | "Region" 29 | 30 | Capital 31 | 32 | 33 | DefaultZoom 34 | 35 | 36 | HLevel 37 | 38 | 39 | ParentRegion 40 | 41 | 42 | RegionDefaultData 43 | %Storage.Persistent 44 | } 45 | 46 | } 47 | 48 | -------------------------------------------------------------------------------- /dsw/irisapp_old.json: -------------------------------------------------------------------------------- 1 | {"app":{"themeColors":{"themes/contrast.css":{"hcColors":["#7cb5ec","#434348","#90ed7d","#f7a35c","#8085e9","#f15c80","#e4d354","#2b908f","#f45b5b","#91e8e1"]}},"language":"en","hideFolders":false,"showImages":false,"theme":"themes/contrast.css","isSaveFilters":false,"isRelatedFilters":true,"colCount":12},"ns":{"widgets":{"Covid19/Countries.dashboard":{"Widget1":{"sizeX":7,"sizeY":6,"row":6,"col":5},"Widget5":{"sizeX":5,"sizeY":6,"series":{"0":false,"1":false,"2":false,"3":false},"isTop":true,"showValues":true,"col":0},"emptyWidget":{"sizeX":3,"row":4,"col":9},"Widget6":{"row":0,"col":9,"sizeX":3,"sizeY":2},"Widget4":{"row":0}},"Covid19/Daily.dashboard":{"Widget1":{"sizeX":9,"sizeY":5,"series":{},"showValues":true,"row":0,"isLegend":false},"_filters":[{"targetProperty":"[Day].[H1].[Month]","value":"&[202003]","isExclude":false,"isInterval":false}],"Widget2":{"col":0,"row":5,"sizeX":9,"sizeY":5,"showValues":true,"isLegend":false,"themeColors":{"themes/contrast.css":{"hcColors":["rgb(18, 19, 19)","#434348","#90ed7d","#f7a35c","#8085e9","#f15c80","#e4d354","#2b908f","#f45b5b","#91e8e1"]}}},"Widget3":{"col":9,"sizeX":3,"sizeY":5},"Widget4":{"col":9,"sizeX":3,"sizeY":5}},"Covid19/USA.dashboard":{"W3":{"col":6},"W4":{"col":6},"uspolygons":{"sizeX":6,"sizeY":8,"row":0},"W2":{"col":0,"sizeX":6,"sizeY":4,"row":8}},"Test/Worldmap.dashboard":{"Widget2":{"sizeX":7,"sizeY":6,"row":0},"Widget1":{"col":7,"sizeX":5},"Widget3":{"col":7,"sizeX":5},"Widget4":{"sizeX":7,"sizeY":5}},"Covid19/Worldmap.dashboard":{"Widget1":{"col":8,"sizeY":6},"Widget3":{"col":8},"Widget2":{"sizeX":8,"sizeY":10}},"Covid19/bubble chart.dashboard":{"Widget2":{"sizeX":5,"sizeY":6},"Widget1":{"series":{"0":false,"1":false,"2":false}}}}}} -------------------------------------------------------------------------------- /src/dfi/Test/heatmap.dashboard.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /sql/TestData.sql: -------------------------------------------------------------------------------- 1 | 2 | INSERT INTO User_CT.EventType (Code,Description) VALUES ('1','Sleep'); 3 | INSERT INTO User_CT.EventType (Code,Description) VALUES ('2','Lights turned off'); 4 | INSERT INTO User_CT.EventType (Code,Description) VALUES ('3','Awakening'); 5 | 6 | INSERT INTO SQLUser.SleepStudy (DateRequested,StartDate,EndDate,RequestingID,RequestingFacility,MPIID,Status) VALUES ({d '2020-05-27'},{d '2020-06-01'},{d '2020-06-08'},'1','1','1','In Progress'); 7 | 8 | INSERT INTO SQLUser.SleepRecord (RecordDate,EventType,Study,TimeFrom,TimeTo) VALUES ({d '2020-06-01'},1,1,{t '15:00:00'},{t '17:00:00'}); 9 | INSERT INTO SQLUser.SleepRecord (RecordDate,EventType,Study,TimeFrom,TimeTo) VALUES ({d '2020-06-01'},1,1,{t '23:45:00'},{t '08:30:00'}); 10 | INSERT INTO SQLUser.SleepRecord (RecordDate,EventType,Study,TimeFrom,TimeTo) VALUES ({d '2020-06-02'},1,1,{t '23:00:00'},{t '09:00:00'}); 11 | INSERT INTO SQLUser.SleepRecord (RecordDate,EventType,Study,TimeFrom,TimeTo) VALUES ({d '2020-06-03'},1,1,{t '15:15:00'},{t '17:30:00'}); 12 | INSERT INTO SQLUser.SleepRecord (RecordDate,EventType,Study,TimeFrom,TimeTo) VALUES ({d '2020-06-04'},1,1,{t '01:15:00'},{t '11:30:00'}); 13 | INSERT INTO SQLUser.SleepRecord (RecordDate,EventType,Study,TimeFrom,TimeTo) VALUES ({d '2020-06-04'},1,1,{t '23:15:00'},{t '08:15:00'}); 14 | INSERT INTO SQLUser.SleepRecord (RecordDate,EventType,Study,TimeFrom,TimeTo) VALUES ({d '2020-06-05'},1,1,{t '14:15:00'},{t '16:00:00'}); 15 | INSERT INTO SQLUser.SleepRecord (RecordDate,EventType,Study,TimeFrom,TimeTo) VALUES ({d '2020-06-05'},1,1,{t '23:45:00'},{t '09:30:00'}); 16 | INSERT INTO SQLUser.SleepRecord (RecordDate,EventType,Study,TimeFrom,TimeTo) VALUES ({d '2020-06-06'},1,1,{t '12:45:00'},{t '13:30:00'}); 17 | INSERT INTO SQLUser.SleepRecord (RecordDate,EventType,Study,TimeFrom,TimeTo) VALUES ({d '2020-06-06'},1,1,{t '22:45:00'},{t '07:30:00'}); 18 | INSERT INTO SQLUser.SleepRecord (RecordDate,EventType,Study,TimeFrom,TimeTo) VALUES ({d '2020-06-07'},1,1,{t '14:30:00'},{t '16:15:00'}); 19 | INSERT INTO SQLUser.SleepRecord (RecordDate,EventType,Study,TimeFrom,TimeTo) VALUES ({d '2020-06-07'},1,1,{t '23:30:00'},{t '09:00:00'}); -------------------------------------------------------------------------------- /src/dfi/Covid19/bubble chart.dashboard.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/gbl/DeepSee/TermList.GBL.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ^DeepSee.TermList 5 | COVID19 USA 6 | data 7 | Confirmed 8 | VALUE 9 | Covid19/USA/ConfirmedOnMap.pivot 10 | 11 | 12 | Deaths 13 | VALUE 14 | Covid19/USA/DeathsOnMap.pivot 15 | 16 | 17 | 18 | modDate 19 | 2020-04-09 16:52:13 20 | 21 | name 22 | Covid19 USA 23 | 24 | 25 | COVIDUSA 26 | caption 27 | COVID 28 | 29 | data 30 | Confirmed 31 | VALUE 32 | USA/USMapArea.pivot 33 | 34 | 35 | Deaths 36 | VALUE 37 | USA/USMapDensity.pivot 38 | 39 | 40 | 41 | modDate 42 | 2016-11-30 15:56:38 43 | 44 | name 45 | Election Votes 46 | 47 | 48 | ELECTION VOTES 49 | data 50 | Votes Temperature 51 | VALUE 52 | USA/Elections.pivot 53 | 54 | 55 | Winner Takes All 56 | VALUE 57 | USA/Elections2.pivot 58 | 59 | 60 | 61 | modDate 62 | 2016-11-30 15:56:38 63 | 64 | name 65 | Election Votes 66 | 67 | 68 | USMAPSOURCES 69 | caption 70 | Map Sources 71 | 72 | data 73 | Area 74 | VALUE 75 | USA/USMapArea.pivot 76 | 77 | 78 | Density 79 | VALUE 80 | USA/USMapDensity.pivot 81 | 82 | 83 | Population 84 | VALUE 85 | USA/US Map Population.pivot 86 | 87 | 88 | 89 | modDate 90 | 2016-03-11 01:36:04 91 | 92 | name 93 | USMapSources 94 | 95 | 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /dsw/irisapp.json: -------------------------------------------------------------------------------- 1 | {"app":{"themeColors":{"themes/contrast.css":{"hcColors":["#7cb5ec","#434348","#90ed7d","#f7a35c","#8085e9","#f15c80","#e4d354","#2b908f","#f45b5b","#91e8e1"]}},"language":"en","hideFolders":false,"showImages":false,"theme":"themes/contrast.css","isSaveFilters":false,"isRelatedFilters":true,"colCount":12},"ns":{"widgets":{"Covid19/Countries.dashboard":{"Widget1":{"sizeX":10,"sizeY":5,"row":8,"col":0},"Widget5":{"sizeX":10,"sizeY":8,"series":{"0":false,"1":false,"2":false,"3":false},"isTop":true,"showValues":true,"col":0,"row":0,"chartConfig":true,"themeColors":{"themes/contrast.css":{"hcColors":["#7cb5ec","#434348","#90ed7d","#583619","#8085e9","#f15c80","#e4d354","#2b908f","#f45b5b","#91e8e1"],"hcTextColor":"#333333","hcBackground":"#ffffff","hcBorderColor":"","hcLineColor":"#FFFFFF"}}},"emptyWidget":{"sizeX":2,"row":0,"col":10,"sizeY":1},"Widget6":{"row":0,"col":9,"sizeX":3,"sizeY":2},"Widget4":{"row":9,"col":10,"sizeX":2,"sizeY":4},"Widget2":{"col":10,"row":1,"sizeX":2,"sizeY":4},"Widget3":{"col":10,"row":5,"sizeX":2,"sizeY":4}},"Covid19/Daily.dashboard":{"Widget1":{"sizeX":9,"sizeY":7,"series":{},"showValues":true,"row":0,"isLegend":false,"col":0,"chartConfig":true,"themeColors":{"themes/contrast.css":{"hcColors":["#7cb5ec","#434348","#90ed7d","#f7a35c","#8085e9","#f15c80","#e4d354","#2b908f","#f45b5b","#91e8e1"],"hcTextColor":"#333333","hcBackground":"#ffffff","hcBorderColor":"#241d1d","hcLineColor":"#FFFFFF"}}},"_filters":[{"targetProperty":"[Day].[H1].[Month]","value":"&[202003]","isExclude":false,"isInterval":false}],"Widget2":{"col":0,"row":7,"sizeX":9,"sizeY":8,"showValues":true,"isLegend":false,"themeColors":{"themes/contrast.css":{"hcColors":["rgb(18, 19, 19)","#434348","#90ed7d","#f7a35c","#8085e9","#f15c80","#e4d354","#2b908f","#f45b5b","#91e8e1"]}}},"Widget3":{"col":9,"sizeX":3,"sizeY":5,"row":5},"Widget4":{"col":9,"sizeX":3,"sizeY":5,"row":0}},"Covid19/USA.dashboard":{"W3":{"col":7,"row":0,"sizeX":5,"sizeY":10,"showValues":false,"isLegend":false},"W4":{"col":5,"row":8,"sizeX":2,"sizeY":4},"uspolygons":{"sizeX":7,"sizeY":8,"row":0,"col":0},"W2":{"col":0,"sizeX":5,"sizeY":4,"row":8}},"Test/Worldmap.dashboard":{"Widget2":{"sizeX":7,"sizeY":6,"row":0},"Widget1":{"col":7,"sizeX":5},"Widget3":{"col":7,"sizeX":5},"Widget4":{"sizeX":7,"sizeY":5}},"Covid19/Worldmap.dashboard":{"Widget1":{"col":8,"sizeY":6},"Widget3":{"col":8,"row":6,"sizeX":4,"sizeY":4},"Widget2":{"sizeX":8,"sizeY":10}},"Covid19/bubble chart.dashboard":{"Widget2":{"sizeX":9,"sizeY":5,"col":0,"row":8},"Widget1":{"series":{"0":false,"1":false,"2":false},"col":0,"row":0,"sizeX":9,"sizeY":8}}}}} -------------------------------------------------------------------------------- /src/USA/Covid.cls: -------------------------------------------------------------------------------- 1 | Class USA.Covid Extends %Persistent 2 | { 3 | 4 | Property RegionName As %String; 5 | 6 | Property Guid As %String; 7 | 8 | Property Confirmed As %Integer; 9 | 10 | Property Deaths As %Integer; 11 | 12 | Property Recovered As %Integer; 13 | 14 | Index GuidIdx On Guid [ Unique ]; 15 | 16 | ClassMethod ImportData() As %Status 17 | { 18 | d ..%KillExtent() 19 | &sql( 20 | insert into USA.Covid(RegionName, Guid, Confirmed, Deaths) 21 | select Name, Guid, Confirmed, Deaths from (SELECT 22 | ProvinceState as name, Null as ParentName, sum(Confirmed) as Confirmed, sum(Deaths) as Deaths, reg.Guid, Null as ParentRegion 23 | FROM AnalyzeThis_Generated.covid03162020 cov 24 | LEFT OUTER JOIN USA.Region reg ON cov.ProvinceState = reg.Name AND reg.ParentRegion IS NULL 25 | Where CountryRegion='United States of America' 26 | group by ProvinceState 27 | 28 | union 29 | 30 | SELECT 31 | City as Name, state.Name as ParentName, Confirmed, Deaths, county.Guid, state.Guid as ParentRegion 32 | FROM AnalyzeThis_Generated.covid03162020 cov 33 | LEFT OUTER JOIN ( 34 | SELECT 35 | ProvinceState as name, reg.Guid as guid 36 | FROM AnalyzeThis_Generated.covid03162020 cov2 37 | LEFT OUTER JOIN USA.Region reg ON cov2.ProvinceState = reg.Name AND reg.ParentRegion IS NULL 38 | Where CountryRegion='United States of America' 39 | group by ProvinceState 40 | ) as state ON state.name = cov.ProvinceState 41 | LEFT OUTER JOIN USA.Region county ON cov.City = county.Name AND county.parentregion = state.guid 42 | Where CountryRegion='United States of America' ) 43 | where guid is not NULL 44 | Order by Name 45 | ) 46 | q $$$OK 47 | } 48 | 49 | ClassMethod GrantSQLAccess() As %Status 50 | { 51 | &sql(GRANT SELECT,UPDATE ON AnalyzeThis_Generated.covid03162020 TO UnknownUser) 52 | q $$$OK 53 | } 54 | 55 | Storage Default 56 | { 57 | 58 | 59 | %%CLASSNAME 60 | 61 | 62 | RegionName 63 | 64 | 65 | Guid 66 | 67 | 68 | Confirmed 69 | 70 | 71 | Deaths 72 | 73 | 74 | Recovered 75 | 76 | 77 | ^USA.CovidD 78 | CovidDefaultData 79 | ^USA.CovidD 80 | ^USA.CovidI 81 | ^USA.CovidS 82 | %Storage.Persistent 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /src/User/CT/CodeDescAbstract.cls: -------------------------------------------------------------------------------- 1 | Class User.CT.CodeDescAbstract Extends (%Persistent, %XML.Adaptor, %ZEN.DataModel.Adaptor) [ NoExtent ] 2 | { 3 | 4 | /// Activo 5 | Property Active As %Boolean(ZENATTRS = "controlClass:PortalText|labelClass:PortalLabel|caption:", ZENLABEL = "Activo") [ InitialExpression = 1, Required ]; 6 | 7 | /// Código 8 | Property Code As %String(ZENATTRS = "controlClass:PortalText|labelClass:PortalLabel|controlStyle:width:50px", ZENLABEL = "Código") [ Required ]; 9 | 10 | /// Descripción 11 | Property Description As %String(MAXLEN = 250, ZENATTRS = "controlClass:PortalText|labelClass:PortalLabel|controlStyle:width:300px", ZENLABEL = "Descripción") [ Required ]; 12 | 13 | /// DEBE SER REDEFINIDO EN LA CLASE HIJA!!!! 14 | Index CodeIndex On Code; 15 | 16 | ClassMethod Create(pCode As %String, pDescription As %String, Output pNewObj As %Persistent) As %Status 17 | { 18 | Set tSC = $System.Status.OK() 19 | Try 20 | { 21 | Set pNewObj = ..%New() 22 | Set pNewObj.Code = pCode 23 | Set pNewObj.Description = pDescription 24 | } 25 | Catch (tException) 26 | { 27 | Set tSC = tException.AsStatus() 28 | } 29 | 30 | Quit tSC 31 | } 32 | 33 | ClassMethod OpenByCode(pCode As %String, pSC As %Status) As %Persistent [ CodeMode = objectgenerator ] 34 | { 35 | Do %code.WriteLine(" Set tRS = ##class(%ResultSet).%New()") 36 | Do %code.WriteLine(" Set pSC=$System.Status.OK()") 37 | //Set tLen=$Length(%class.Name,".") 38 | //Set tTableName = $Translate($Piece(%class.Name,".",1,tLen-1),".","_")_"."_$Piece(%class.Name,".",tLen) 39 | Set tTableName = %compiledclass.SqlSchemaName_"."_%compiledclass.SqlTableName 40 | Do %code.WriteLine(" Set pSC = tRS.Prepare(""select %ID from "_tTableName_" where Code=?"")") 41 | Do %code.WriteLine(" Quit:$System.Status.IsError(pSC) """"") 42 | Do %code.WriteLine(" Set pSC = tRS.Execute(pCode)") 43 | Do %code.WriteLine(" Quit:$System.Status.IsError(pSC) """"") 44 | Do %code.WriteLine(" If tRS.Next() Quit ..%OpenId(tRS.GetData(1))") 45 | Do %code.WriteLine(" Quit """"") 46 | 47 | Quit $$$OK 48 | } 49 | 50 | ClassMethod OpenOrCreate(pCode As %String, pDescription As %String, pSC As %Status) As %Persistent 51 | { 52 | Set pSC = $System.Status.OK() 53 | Set pObj = "" 54 | Try 55 | { 56 | Set pObj = ..OpenByCode(pCode, .pSC) 57 | Quit:$System.Status.IsError(pSC) 58 | 59 | If '$IsObject(pObj) 60 | { 61 | Set pObj = ..%New() 62 | Set pObj.Code=pCode 63 | Set pObj.Description=pDescription 64 | Set pObj.Active=1 65 | Set pSC = pObj.%Save(0) 66 | } 67 | } 68 | Catch (tException) 69 | { 70 | Set pSC = tException.AsStatus() 71 | } 72 | 73 | Quit pObj 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /src/User/Cube/SleepRecordCube.cls: -------------------------------------------------------------------------------- 1 | /// 2 | Class User.Cube.SleepRecordCube Extends %DeepSee.CubeDefinition [ DependsOn = User.SleepRecord, ProcedureBlock ] 3 | { 4 | 5 | /// Cube definition from Architect. 6 | XData Cube [ XMLNamespace = "http://www.intersystems.com/deepsee" ] 7 | { 8 | 9 | 15 | 25 | 33 | 35 | 36 | } 37 | 38 | Parameter DOMAIN; 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/Covid19/CovidDays.cls: -------------------------------------------------------------------------------- 1 | /// 2 | Class Covid19.CovidDays Extends %DeepSee.CubeDefinition [ DependsOn = Covid19.Day, ProcedureBlock ] 3 | { 4 | 5 | /// Cube definition from Architect. 6 | XData Cube [ XMLNamespace = "http://www.intersystems.com/deepsee" ] 7 | { 8 | 9 | 17 | 23 | 29 | 31 | 33 | 34 | 35 | 36 | } 37 | 38 | Parameter DOMAIN; 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/User/SleepStudy.cls: -------------------------------------------------------------------------------- 1 | Class User.SleepStudy Extends (%Persistent, %XML.Adaptor, %ZEN.DataModel.Adaptor) 2 | { 3 | 4 | Property MPIID As %String; 5 | 6 | Property StartDate As %Date; 7 | 8 | Property EndDate As %Date; 9 | 10 | Property Status As %String; 11 | 12 | Property RequestingID As %String; 13 | 14 | Property RequestingFacility As %String; 15 | 16 | Property DateRequested As %Date; 17 | 18 | Index PatientIndex On MPIID [ Unique ]; 19 | 20 | Index StartDateIndex On StartDate; 21 | 22 | ClassMethod AddTestStudy(pDateFrom As %String, pDateTo As %String) As %Status 23 | { 24 | 25 | Set tSC = $System.Status.OK() 26 | 27 | Set tSC = ..CreateSleepStudy(1,$zdateh(pDateFrom,4),$zdateh(pDateTo,4), "In Corso", "1", "1", $p($h,",")) 28 | 29 | Quit tSC 30 | } 31 | 32 | ClassMethod CreateSleepStudy(pMPIID As %Integer, pStartDate As %Date, pEndDate As %Date, pStatus As %String, pRequestingID As %String, pRequestingFacility As %String, pDateRequested As %Date) As %Status 33 | { 34 | 35 | Set tSC = $System.Status.OK() 36 | Try 37 | { 38 | //First let's opend referenced objects 39 | 40 | // Validate Patient's MPIID >> TBD 41 | 42 | //Now we've got everything, let's instance a new object 43 | Set pNewObj = ..%New() 44 | Set pNewObj.MPIID = pMPIID 45 | Set pNewObj.StartDate = pStartDate 46 | Set pNewObj.EndDate = pEndDate 47 | Set pNewObj.Status = pStatus 48 | Set pNewObj.RequestingID = pRequestingID 49 | Set pNewObj.RequestingFacility = pRequestingFacility 50 | Set pNewObj.DateRequested = pDateRequested 51 | 52 | Set tSC = pNewObj.%Save() 53 | 54 | } 55 | Catch (tException) 56 | { 57 | w !,"Error creating SleepStudy object! "_tException,! 58 | Set tSC = tException.AsStatus() 59 | } 60 | 61 | Quit tSC 62 | } 63 | 64 | Storage Default 65 | { 66 | 67 | 68 | %%CLASSNAME 69 | 70 | 71 | MPIID 72 | 73 | 74 | StartDate 75 | 76 | 77 | EndDate 78 | 79 | 80 | Status 81 | 82 | 83 | RequestingID 84 | 85 | 86 | RequestingFacility 87 | 88 | 89 | DateRequested 90 | 91 | 92 | ^User.SleepStudyD 93 | SleepStudyDefaultData 94 | ^User.SleepStudyD 95 | ^User.SleepStudyI 96 | ^User.SleepStudyS 97 | %Storage.Persistent 98 | } 99 | 100 | } 101 | -------------------------------------------------------------------------------- /sql/usamap.sql: -------------------------------------------------------------------------------- 1 | SELECT 2 | ID, ProvinceState, sum(Confirmed), sum(Deaths), sum(Recovered) 3 | FROM AnalyzeThis_Generated.covid03162020 4 | LEFT OUTER JOIN 5 | Where CountryRegion='US' 6 | group by ProvinceState 7 | 8 | 9 | SELECT 10 | ProvinceState, sum(Confirmed), sum(Deaths), reg.Guid 11 | FROM AnalyzeThis_Generated.covid03162020 cov 12 | LEFT OUTER JOIN USA.Region reg ON cov.ProvinceState = reg.Name 13 | Where CountryRegion='US' 14 | group by ProvinceState 15 | 16 | 17 | select * from (SELECT 18 | ProvinceState as name, Null as ParentName, sum(Confirmed) as Confirmed, sum(Deaths) as Deaths, reg.Guid, Null as ParentRegion 19 | FROM AnalyzeThis_Generated.covid03162020 cov 20 | LEFT OUTER JOIN USA.Region reg ON cov.ProvinceState = reg.Name 21 | Where CountryRegion='US' 22 | group by ProvinceState 23 | 24 | union 25 | 26 | SELECT 27 | City as Name, state.Name as ParentName, Confirmed, Deaths, county.Guid, state.Guid as ParentRegion 28 | FROM AnalyzeThis_Generated.covid03162020 cov 29 | LEFT OUTER JOIN ( 30 | SELECT 31 | ProvinceState as name, reg.Guid as guid 32 | FROM AnalyzeThis_Generated.covid03162020 cov2 33 | LEFT OUTER JOIN USA.Region reg ON cov2.ProvinceState = reg.Name 34 | Where CountryRegion='US' 35 | group by ProvinceState 36 | ) as state ON state.name = cov.ProvinceState 37 | LEFT OUTER JOIN USA.Region county ON cov.City = county.Name AND county.parentregion = state.guid 38 | Where CountryRegion='US' ) 39 | where guid is not NULL 40 | order by Name 41 | 42 | 43 | 44 | WASHINGTON 296832 13632 027FBB6F-512F-48E7-9BB9-0BEFA254DD22 2 45 | DELAWARE 7812 133 067D221C-A573-4BFF-847C-C922DE4239E0 2 46 | TEXAS 29331 567 116DFADF-40D7-46D6-9E07-820AC8BA98AB 2 47 | INDIANA 11886 406 65A5D506-92CE-4DB2-9CC1-29AF8ADC9F26 2 48 | NEVADA 6777 216 799963A3-40AA-4E90-B739-F1282206FBFA 2 49 | OREGON 50 | 51 | 52 | select * from (SELECT 53 | ProvinceState as name, Null as ParentName, sum(Confirmed) as Confirmed, sum(Deaths) as Deaths, reg.Guid, Null as ParentRegion 54 | FROM AnalyzeThis_Generated.covid03162020 cov 55 | LEFT OUTER JOIN USA.Region reg ON cov.ProvinceState = reg.Name AND reg.ParentRegion IS NULL 56 | Where CountryRegion='US' 57 | group by ProvinceState 58 | 59 | union 60 | 61 | SELECT 62 | City as Name, state.Name as ParentName, Confirmed, Deaths, county.Guid, state.Guid as ParentRegion 63 | FROM AnalyzeThis_Generated.covid03162020 cov 64 | LEFT OUTER JOIN ( 65 | SELECT 66 | ProvinceState as name, reg.Guid as guid 67 | FROM AnalyzeThis_Generated.covid03162020 cov2 68 | LEFT OUTER JOIN USA.Region reg ON cov2.ProvinceState = reg.Name AND reg.ParentRegion IS NULL 69 | Where CountryRegion='US' 70 | group by ProvinceState 71 | ) as state ON state.name = cov.ProvinceState 72 | LEFT OUTER JOIN USA.Region county ON cov.City = county.Name AND county.parentregion = state.guid 73 | Where CountryRegion='US' ) 74 | where guid is not NULL 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /src/User/SleepRecord.cls: -------------------------------------------------------------------------------- 1 | Class User.SleepRecord Extends (%Persistent, %XML.Adaptor, %ZEN.DataModel.Adaptor) 2 | { 3 | 4 | Property Study As User.SleepStudy [ Required ]; 5 | 6 | Property EventType As User.CT.EventType [ Required ]; 7 | 8 | Property RecordDate As %Date [ Required ]; 9 | 10 | Property TimeFrom As %Time [ Required ]; 11 | 12 | Property TimeTo As %Time; 13 | 14 | Property Comments As %String; 15 | 16 | Index RecordDateIndex On RecordDate; 17 | 18 | ClassMethod AddRecord(pDate As %String, pTimeFrom As %String, pTimeTo As %String) As %Status 19 | { 20 | 21 | Set tSC = $System.Status.OK() 22 | 23 | Set tSC = ..CreateRecord(1,1, $zdateh(pDate,4) , $ztimeh(pTimeFrom,2) , $ztimeh(pTimeTo,2) , "") 24 | 25 | Quit tSC 26 | } 27 | 28 | ClassMethod CreateRecord(pStudyID As %Integer, pEventyTypeId As %Integer, pRecordDate As %Date, pTimeFrom As %Time, pTimeTo As %Time, pComments As %String = "") As %Status 29 | { 30 | 31 | Set tSC = $System.Status.OK() 32 | Try 33 | { 34 | //First let's opend referenced objects 35 | 36 | Set oStudy = ##class(User.SleepStudy).%OpenId(pStudyID) 37 | If '$IsObject(oStudy) { 38 | w !,"Could not open referenced Study",! 39 | Quit 40 | } 41 | 42 | Set oEventType = ##class(User.CT.EventType).%OpenId(pEventyTypeId) 43 | If '$IsObject(oEventType) { 44 | w !,"Could not open referenced Event Type",! 45 | Quit 46 | } 47 | 48 | //Now we've got everything, let's instance a new object 49 | Set pNewObj = ..%New() 50 | Set pNewObj.RecordDate = pRecordDate 51 | Set pNewObj.TimeFrom = pTimeFrom 52 | Set pNewObj.TimeTo = pTimeTo 53 | Set pNewObj.Comments = pComments 54 | 55 | Do pNewObj.StudySetObjectId(pStudyID) 56 | Do pNewObj.EventTypeSetObjectId(pEventyTypeId) 57 | 58 | Set tSC = pNewObj.%Save() 59 | 60 | } 61 | Catch (tException) 62 | { 63 | Set tSC = tException.AsStatus() 64 | } 65 | 66 | Quit tSC 67 | } 68 | 69 | ClassMethod Clean() As %Status 70 | { 71 | Set tSC = $System.Status.OK() 72 | Try 73 | { 74 | k ^User.SleepRecordD 75 | k ^User.SleepRecordI 76 | s ^User.SleepRecordD=0 77 | } 78 | Catch (oException) 79 | { 80 | Set tSC = oException.AsStatus() 81 | } 82 | 83 | Quit tSC 84 | } 85 | 86 | Storage Default 87 | { 88 | 89 | 90 | %%CLASSNAME 91 | 92 | 93 | EventType 94 | 95 | 96 | RecordDate 97 | 98 | 99 | TimeFrom 100 | 101 | 102 | TimeTo 103 | 104 | 105 | Comments 106 | 107 | 108 | Study 109 | 110 | 111 | ^User.SleepRecordD 112 | SleepRecordDefaultData 113 | ^User.SleepRecordD 114 | ^User.SleepRecordI 115 | ^User.SleepRecordS 116 | %Storage.Persistent 117 | } 118 | 119 | } 120 | -------------------------------------------------------------------------------- /src/dfi/Covid19/Deaths.pivot.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/dfi/Covid19/Confirmed.pivot.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/dfi/Covid19/Recovered.pivot.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Terraform.md: -------------------------------------------------------------------------------- 1 | ## Prerequisites to run Terraform 2 | 3 | It's better to read [this article](https://community.intersystems.com/post/automating-gke-creation-circleci-builds) at first. But in short: 4 | 5 | #### Create Service Account for Terraform 6 | ``` 7 | $ gcloud init 8 | $ cd 9 | $ mkdir terraform; cd terraform 10 | $ gcloud iam service-accounts create terraform --description "Terraform" --display-name "terraform" 11 | ``` 12 | 13 | #### Add a few roles to it 14 | ``` 15 | $ gcloud projects add-iam-policy-binding \ 16 | --member serviceAccount:terraform@.iam.gserviceaccount.com \ 17 | --role roles/container.admin 18 | 19 | $ gcloud projects add-iam-policy-binding \ 20 | --member serviceAccount:terraform@.iam.gserviceaccount.com \ 21 | --role roles/iam.serviceAccountUser 22 | 23 | $ gcloud projects add-iam-policy-binding \ 24 | --member serviceAccount:terraform@.iam.gserviceaccount.com \ 25 | --role roles/compute.viewer 26 | 27 | $ gcloud projects add-iam-policy-binding \ 28 | --member serviceAccount:terraform@.iam.gserviceaccount.com \ 29 | --role roles/storage.admin 30 | 31 | $ gcloud iam service-accounts keys create account.json \ 32 | --iam-account terraform@.iam.gserviceaccount.com 33 | ``` 34 | Note that the last entry creates your account.json file. Be sure to keep this file secret. 35 | 36 | #### Enable service "Kubernetes Engine" 37 | ``` 38 | $ gcloud projects list 39 | $ gcloud config set project 40 | $ gcloud services list --available | grep 'Kubernetes Engine' 41 | $ gcloud services enable container.googleapis.com 42 | $ gcloud services list --enabled | grep 'Kubernetes Engine' 43 | container.googleapis.com Kubernetes Engine API 44 | ``` 45 | 46 | #### Create Google bucket to store Terraform state 47 | Use the name of your bucket instead of the placeholder . Before bucket creation let’s check if is available as it has to be unique across all GCP: 48 | ``` 49 | $ gsutil acl get gs:// 50 | ``` 51 | 52 | Good answer: 53 | ``` 54 | BucketNotFoundException: 404 gs:// bucket does not exist 55 | ``` 56 | 57 | "Busy" answer means you have to choose another name: 58 | ``` 59 | AccessDeniedException: 403 does not have storage.buckets.get access to 60 | ``` 61 | 62 | Let’s also enable versioning: 63 | ``` 64 | $ gsutil mb -l EU gs:// 65 | $ gsutil versioning get gs:// 66 | gs://: Suspended 67 | 68 | $ gsutil versioning set on gs:// 69 | 70 | $ gsutil versioning get gs:// 71 | gs://: Enabled 72 | ``` 73 | 74 | #### Use your values instead of placeholders in main.tf file 75 | * - GCP project ID. Example: `possible-symbol-254507` 76 | * - Storage for Terraform state/lock—should be unique. Example: `github-gke-terraform-demo` 77 | * \ - Region where resources will be created. Example: `europe-west1` 78 | * \ - Zone where resources will be created. Example: `europe-west1-b` 79 | * - GKE cluster name. Example: `dev-cluster` 80 | * - GKE worker nodes pool name. Example: `dev-cluster-node-pool` 81 | -------------------------------------------------------------------------------- /src/dfi/Covid19/Worldmap.dashboard.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | false 8 | 9 | [Country].[H1].[$name] 10 | 11 | 12 | 13 | false 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/USA/Borders.cls: -------------------------------------------------------------------------------- 1 | /// Borders for polygons 2 | Class USA.Borders Extends %Persistent 3 | { 4 | 5 | /// ParentRegion guid or string-'NULL' if level=0 6 | Property ParentRegion As %String [ Required ]; 7 | 8 | /// Parameter 9 | Property Parameter As USA.Parameter [ Required ]; 10 | 11 | /// Level 12 | Property HLevel As %Integer [ Required ]; 13 | 14 | Property Minimum As %Integer; 15 | 16 | Property Maximum As %Integer; 17 | 18 | Index BordersIdx On (ParentRegion, Parameter, HLevel) [ Unique ]; 19 | 20 | /// Get a set of borders values for polygons whose parent GUID = parentRegionGuid 21 | ClassMethod GetBorders(paramId As %String, hLevel As %Integer, parentRegionGuid As %String) As %String 22 | { 23 | set borderMax = 10000 24 | set borderMin = 0 25 | set unitName = "-" 26 | 27 | if (parentRegionGuid="") set parentRegionGuid = "NULL" 28 | 29 | set border = "" 30 | 31 | try{ 32 | if (..BordersIdxExists(parentRegionGuid, paramId, hLevel) = 1){ 33 | set border = ..BordersIdxOpen(parentRegionGuid, paramId, hLevel) 34 | } 35 | else{ 36 | set minVal=0, maxVal=10000 37 | 38 | if (parentRegionGuid = "NULL"){ 39 | &sql(SELECT Min(Value), Max(Value) INTO :minVal,:maxVal 40 | FROM USA.Region as reg INNER JOIN 41 | USA.ParameterValue as pv ON reg.ID = pv.Area 42 | WHERE reg.HLevel=:hLevel AND pv.Parameter=:paramId ) 43 | } 44 | else{ 45 | &sql(SELECT Min(Value), Max(Value) INTO :minVal,:maxVal 46 | FROM USA.Region as reg INNER JOIN 47 | USA.ParameterValue as pv ON reg.ID = pv.Area 48 | WHERE reg.HLevel=:hLevel AND pv.Parameter=:paramId AND reg.ParentRegion=:parentRegionGuid) 49 | } 50 | 51 | set border = ..%New() 52 | set border.ParentRegion = parentRegionGuid 53 | set border.Parameter = ##class(USA.Parameter).%OpenId(paramId) 54 | set border.HLevel = hLevel 55 | set border.Maximum = maxVal 56 | set border.Minimum = minVal 57 | do border.%Save() 58 | } 59 | 60 | set borderMin = border.Minimum 61 | set borderMax = border.Maximum 62 | set unitName = border.Parameter.UnitName 63 | } 64 | catch 65 | {} 66 | 67 | quit borderMin_";"_borderMax_";"_unitName 68 | } 69 | 70 | /// Update values for border 71 | ClassMethod SetBorders(paramId As %String, level As %Integer, parentRegionGuid As %String, min As %Integer, max As %Integer) As %Status 72 | { 73 | set st = $$$OK 74 | try{ 75 | if (parentRegionGuid="") set parentRegionGuid = "NULL" 76 | set brd = ..BordersIdxOpen(parentRegionGuid, paramId, level) 77 | set brd.Maximum = max 78 | set brd.Minimum = min 79 | set st = brd.%Save() 80 | } 81 | catch(ex){ 82 | set st = ex.AsStatus() 83 | } 84 | quit st 85 | } 86 | 87 | Storage Default 88 | { 89 | 90 | 91 | %%CLASSNAME 92 | 93 | 94 | ParentRegion 95 | 96 | 97 | Parameter 98 | 99 | 100 | HLevel 101 | 102 | 103 | Minimum 104 | 105 | 106 | Maximum 107 | 108 | 109 | ^USA.BordersD 110 | BordersDefaultData 111 | 100000 112 | ^USA.BordersD 113 | ^USA.BordersI 114 | ^USA.BordersS 115 | %Storage.Persistent 116 | } 117 | 118 | } 119 | -------------------------------------------------------------------------------- /src/dfi/Covid19/DailyDeaths.pivot.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/dfi/Covid19/DailyConfirmed.pivot.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/dfi/Covid19/CountryConfirmed.pivot.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Covid-19 analytics 2 | This is an [interactive dashboard](http://34.77.54.254:52773/dsw/index.html#/IRISAPP/Covid19/Countries.dashboard ) on the analytics for covid-19 pandemia. 3 | Screenshot 2020-09-29 at 14 02 39 4 | Another dashboard [shows the timeline](http://34.77.54.254:52773/dsw/index.html#/IRISAPP/Covid19/Daily.dashboard): 5 | Screenshot 2020-09-18 at 10 59 13 6 | 7 | There is also [USA Interactive map](http://34.77.54.254:52773/dsw/index.html#/IRISAPP/Covid19/USA.dashboard) 8 | Screenshot 2020-09-29 at 14 05 59 9 | 10 | And the [World Map](http://34.77.54.254:52773/dsw/index.html#/IRISAPP/Covid19/Worldmap.dashboard) 11 | Screenshot 2020-09-29 at 13 59 11 12 | 13 | Also the [bubble chart of top 10 countries](http://34.77.54.254:52773/dsw/index.html#/IRISAPP/Covid19/bubble%20chart.dashboard) 14 | Screenshot 2020-09-18 at 11 05 28 15 | 16 | 17 | ## data source 18 | The data is taken from [Johns Hopkins repo](https://github.com/CSSEGISandData/COVID-19) 19 | 20 | ## How it works 21 | The dashboard is running on InterSystems IRIS 2019.4 Community Edition 22 | It uses IRIS Analytics module and DSW as a representation layer 23 | It runs in a Kubernetes cluster in GCP 24 | 25 | ## How it was developed 26 | [AnalyzeThis](https://openexchange.intersystems.com/package/AnalyzeThis) module has been used to generate the class and the cube. 27 | Pivots and Dashboards were built manually using [InterSystems IRIS Analytics](https://docs.intersystems.com/irislatest/csp/docbook/Doc.View.cls?KEY=D2GS) 28 | [DSW](https://openexchange.intersystems.com/package/DeepSeeWeb) is used to design representation layer 29 | [ISC-DEV](https://openexchange.intersystems.com/package/ISC-DEV) module was used to export pivot and dashboard. 30 | 31 | To export Pivot and Dashboard changes do: 32 | ``` 33 | IRISAPP> do ##class(dev.code).export("*.DFI") 34 | ``` 35 | This will export pivots and dashboards into /src/dfi folder of the repo. 36 | 37 | ## deployment 38 | It's being deployed by Github Actions using this workflow 39 | Which uses terraform and K8 configuration. 40 | Dockerfile loads sources, pivot and dashboard. It imports data and builds cube. 41 | 42 | ## Installation 43 | 44 | Open terminal and clone/git pull the repo into any local directory 45 | 46 | ``` 47 | $ git clone git@github.com:evshvarov/covid-19.git 48 | ``` 49 | 50 | Open the terminal in this directory and run: 51 | 52 | ``` 53 | $ docker-compose build 54 | ``` 55 | 56 | 57 | ## How to start coding 58 | This repository is ready to code in VSCode with ObjectScript plugin. 59 | Install [VSCode](https://code.visualstudio.com/), [Docker](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-docker) and [ObjectScript](https://marketplace.visualstudio.com/items?itemName=daimor.vscode-objectscript) plugins and open the folder in VSCode. 60 | 61 | Right-click on **docker-compose.yml** file and click Compose Restart 62 | 63 | Once docker will finish starting procedure and show: 64 | 65 | ``` 66 | Creating covid-19_iris_1 ... done 67 | ``` 68 | 69 | Click on the ObjectScript status bar and select Refresh connection in the menu. 70 | Wait for VSCode to make connection and show something like "localhost:32778[IRISAPP] - Connected" 71 | 72 | You can start coding after that. 73 | 74 | Contributions are welcome via Pull Requests 75 | -------------------------------------------------------------------------------- /src/dfi/Covid19/Daily.pivot.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/dfi/Covid19/Figures.pivot.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/dfi/Covid19/Countries.dashboard.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | false 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | true 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/dfi/Covid19/DeathsTotal.pivot.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/dfi/Covid19/ConfirmedTotal.pivot.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/dfi/Covid19/USA.dashboard.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | false 8 | 9 | 10 | false 11 | 12 | 13 | false 14 | 15 | 5 16 | 17 | 18 | 19 | 20 | 21 | false 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/dfi/Covid19/Worldmap.pivot.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/dfi/Covid19/Status.pivot.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/AnalyzeThis/Generated/covid03162020Cube.cls: -------------------------------------------------------------------------------- 1 | /// Generated by Utility 2 | Class AnalyzeThis.Generated.covid03162020Cube Extends %DeepSee.CubeDefinition [ DependsOn = , ProcedureBlock ] 3 | { 4 | 5 | /// Cube definition from Architect. 6 | XData Cube [ XMLNamespace = "http://www.intersystems.com/deepsee" ] 7 | { 8 | 9 | 19 | 29 | 35 | 41 | 51 | 53 | 55 | 57 | 58 | 59 | 60 | } 61 | 62 | Parameter DOMAIN; 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/dfi/Covid19/Daily.dashboard.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | false 8 | 9 | 10 | false 11 | 12 | 13 | false 14 | 15 | 16 | false 17 | 18 | 19 | 20 | 21 | false 22 | 23 | 24 | 25 | #,### 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/dfi/Covid19/Countries_bubble.pivot.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/dfi/Covid19/USA Map Details.pivot.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/dfi/Covid19/Countries.pivot.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/dfi/Covid19/USA/DeathsOnMap.pivot.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/dfi/Covid19/USA/ConfirmedOnMap.pivot.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /.github/workflows/irisapp.yaml: -------------------------------------------------------------------------------- 1 | name: Deploy Covid19-analytics 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | 8 | # Environment variables. 9 | # ${{ secrets }} are taken from GitHub -> Settings -> Secrets 10 | # ${{ github.sha }} is the commit hash 11 | env: 12 | PROJECT_ID: covid2019-analytics 13 | GOOGLE_SERVICE_ACCOUNT_KEY: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_KEY }} 14 | GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_KEY }} # Special Terraform variable 15 | GITHUB_SHA: ${{ github.sha }} 16 | GCR_LOCATION: eu.gcr.io 17 | IMAGE_NAME: covid19 18 | GKE_CLUSTER: covid19 19 | GKE_ZONE: europe-west2-b 20 | 21 | jobs: 22 | build-and-publish-image: 23 | name: Setup gcloud utility, Build image and Publish it to Google Container Registry 24 | runs-on: ubuntu-18.04 25 | steps: 26 | - name: Checkout 27 | uses: actions/checkout@v2 28 | 29 | - name: Setup gcloud cli 30 | uses: GoogleCloudPlatform/github-actions/setup-gcloud@0.1.2 31 | with: 32 | version: '290.0.1' 33 | service_account_key: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_KEY }} 34 | 35 | - name: Configure docker to use the gcloud as a credential helper 36 | run: | 37 | gcloud auth configure-docker 38 | 39 | - name: Build image 40 | run: | 41 | docker build -t ${GCR_LOCATION}/${PROJECT_ID}/${IMAGE_NAME}:${GITHUB_SHA} . 42 | 43 | - name: Publish image to GCR 44 | run: | 45 | docker push ${GCR_LOCATION}/${PROJECT_ID}/${IMAGE_NAME}:${GITHUB_SHA} 46 | 47 | infra-provisioner: 48 | name: Provision infrastructure 49 | runs-on: ubuntu-18.04 50 | defaults: 51 | run: 52 | working-directory: .infra/terraform 53 | 54 | steps: 55 | - name: Checkout 56 | uses: actions/checkout@v2 57 | 58 | - name: Terraform install 59 | uses: hashicorp/setup-terraform@v1.2.0 60 | with: 61 | terraform_version: 0.12.29 62 | 63 | - name: Terraform init 64 | id: init 65 | run: terraform init 66 | 67 | - name: Terraform validate 68 | id: validate 69 | run: terraform validate -no-color 70 | 71 | - name: Terraform plan 72 | id: plan 73 | run: terraform plan -no-color 74 | continue-on-error: true 75 | 76 | - name: Terraform apply 77 | id: apply 78 | run: terraform apply -auto-approve 79 | 80 | packages-install: 81 | name: Deploy packages to provide external access 82 | needs: 83 | - build-and-publish-image 84 | - infra-provisioner 85 | 86 | runs-on: ubuntu-18.04 87 | 88 | steps: 89 | - name: Checkout 90 | uses: actions/checkout@v2 91 | 92 | - name: Install Helm 93 | uses: azure/setup-helm@v1 94 | id: install 95 | with: 96 | version: v3.3.4 97 | 98 | - name: Setup gcloud cli 99 | uses: GoogleCloudPlatform/github-actions/setup-gcloud@0.1.2 100 | with: 101 | version: '290.0.1' 102 | service_account_key: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_KEY }} 103 | 104 | - name: Connect to cluster 105 | run: | 106 | gcloud container clusters get-credentials ${GKE_CLUSTER} --zone ${GKE_ZONE} --project ${PROJECT_ID} 107 | 108 | - name: Install Nginx Ingress controller 109 | run: |- 110 | LOAD_BALANCER_IP=$(gcloud compute addresses list --project ${PROJECT_ID} --filter="name~'${GKE_CLUSTER}-regional'" --format="value(Address)") 111 | echo ${LOAD_BALANCER_IP} 112 | 113 | helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx 114 | kubectl create namespace nginx-ingress --dry-run=client -o yaml | kubectl apply -f - 115 | 116 | helm upgrade nginx-ingress \ 117 | --namespace nginx-ingress \ 118 | ingress-nginx/ingress-nginx \ 119 | --install \ 120 | --atomic \ 121 | --version 3.1.0 \ 122 | --set controller.service.loadBalancerIP=${LOAD_BALANCER_IP} \ 123 | 124 | - name: Install Certification Manager 125 | working-directory: .infra/cert-manager 126 | run: |- 127 | helm repo add jetstack https://charts.jetstack.io 128 | kubectl create namespace cert-manager --dry-run=client -o yaml | kubectl apply -f - 129 | kubectl apply --validate=false -f https://github.com/jetstack/cert-manager/releases/download/v1.0.2/cert-manager.crds.yaml 130 | 131 | helm upgrade cert-manager \ 132 | --namespace cert-manager \ 133 | jetstack/cert-manager \ 134 | --install \ 135 | --atomic \ 136 | --version v1.0.2 137 | 138 | kubectl apply -f lets-encrypt-staging.yaml 139 | kubectl apply -f lets-encrypt-production.yaml 140 | 141 | iris-application-deploy: 142 | name: Deploy IRIS application Kubernetes manifests 143 | needs: 144 | - build-and-publish-image 145 | - infra-provisioner 146 | - packages-install 147 | 148 | runs-on: ubuntu-18.04 149 | defaults: 150 | run: 151 | working-directory: .infra/kubernetes 152 | 153 | steps: 154 | - name: Checkout 155 | uses: actions/checkout@v2 156 | 157 | - name: Set image name 158 | run: | 159 | sed -i "s|image: iris|image: ${GCR_LOCATION}/${PROJECT_ID}/${IMAGE_NAME}:${GITHUB_SHA}|" iris-deployment.yaml 160 | 161 | - name: Setup gcloud cli 162 | uses: GoogleCloudPlatform/github-actions/setup-gcloud@0.1.2 163 | with: 164 | version: '290.0.1' 165 | service_account_key: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_KEY }} 166 | 167 | - name: Apply Kubernetes manifests 168 | run: | 169 | gcloud container clusters get-credentials ${GKE_CLUSTER} --zone ${GKE_ZONE} --project ${PROJECT_ID} 170 | kubectl apply -R -f . 171 | kubectl rollout status deployment/iris -------------------------------------------------------------------------------- /src/USA/BI/USCube.cls: -------------------------------------------------------------------------------- 1 | /// 2 | Class USA.BI.USCube Extends %DeepSee.CubeDefinition [ DependsOn = USA.Region, ProcedureBlock ] 3 | { 4 | 5 | /// Cube definition from Architect. 6 | XData Cube [ XMLNamespace = "http://www.intersystems.com/deepsee" ] 7 | { 8 | 9 | 47 | 48 | } 49 | 50 | ClassMethod GetColor(min, max, value) As %String 51 | { 52 | if ('value) return "rgb(0,0,0)" 53 | 54 | // Крайние границы: красный и зеленый, цвет для середины - желтый 55 | set middle = (max + min) / 2 56 | 57 | if (value <= middle) 58 | { 59 | set redPart = (value - min) / (middle - min) 60 | return "rgb(" _ (255 * redPart\1) _ ",255, 0)" 61 | } 62 | else 63 | { 64 | set greenPart = (max - value) / (max - middle) 65 | return "rgb(255," _(255 * greenPart\1) _ ", 0)" 66 | } 67 | } 68 | 69 | ClassMethod GetValue(guid, type) As %Integer 70 | { 71 | 72 | //b "L" 73 | //type=1 - population 74 | //type=2 - area 75 | // type=4 - Trump 76 | // type=5 - Clinton 77 | // density 78 | s region=##class(USA.Region).%OpenId(guid) 79 | if $IsObject(region) & type<4 { 80 | s parameter=##class(USA.ParameterValue).RegionParameterIndexOpen(region.Guid,type) 81 | if $IsObject(parameter) return parameter.Value} 82 | if (type=4)!(type=5) { 83 | set parameter=##class(USA.Elections).GuidIdxOpen(guid) 84 | if $IsObject(parameter) return $case(type,4:parameter.Trump,5:parameter.Clinton) 85 | } 86 | return "" 87 | } 88 | 89 | ClassMethod TermListSetup() 90 | { 91 | s ^DeepSee.TermList("USMAPSOURCES","caption") = "Map Sources" 92 | s ^DeepSee.TermList("USMAPSOURCES","data","Area","VALUE") = "USA/USMapArea.pivot" 93 | s ^DeepSee.TermList("USMAPSOURCES","data","Density","VALUE") = "USA/USMapDensity.pivot" 94 | s ^DeepSee.TermList("USMAPSOURCES","data","Population","VALUE") = "USA/US Map Population.pivot" 95 | s ^DeepSee.TermList("USMAPSOURCES","modDate") = "2016-03-11 01:36:04" 96 | s ^DeepSee.TermList("USMAPSOURCES","name") = "USMapSources" 97 | s ^DeepSee.TermList("ELECTION VOTES","data","Votes Temperature","VALUE") = "USA/Elections.pivot" 98 | s ^DeepSee.TermList("ELECTION VOTES","data","Winner Takes All","VALUE") = "USA/Elections2.pivot" 99 | s ^DeepSee.TermList("ELECTION VOTES","modDate") = "2016-11-30 15:56:38" 100 | s ^DeepSee.TermList("ELECTION VOTES","name") = "Election Votes" 101 | 102 | quit 103 | } 104 | 105 | Parameter DOMAIN; 106 | 107 | } 108 | 109 | -------------------------------------------------------------------------------- /src/Covid19/Utils.cls: -------------------------------------------------------------------------------- 1 | Class Covid19.Utils 2 | { 3 | 4 | Parameter TSConfirmed = "csse_covid_19_time_series/time_series_covid19_confirmed_global.csv"; 5 | 6 | Parameter TSDeaths = "csse_covid_19_time_series/time_series_covid19_deaths_global.csv"; 7 | 8 | Parameter TSrecovered = "csse_covid_19_time_series/time_series_covid19_recovered_global.csv"; 9 | 10 | Parameter TSYesterdayFile = "csse_covid_19_daily_reports/"; 11 | 12 | ClassMethod ImportCountries() 13 | { 14 | zw ##class(community.csvgen).GenerateFromURL("https://raw.githubusercontent.com/datasciencedojo/datasets/master/WorldDBTables/CountryTable.csv",",","Covid19.Countries") 15 | } 16 | 17 | ClassMethod CleanCountriesData() 18 | { 19 | &sql(Update Covid19.Countries 20 | Set name='Russia' 21 | where name='Russian Federation') 22 | if SQLCODE < 0 throw ##class(%Exception.SQL).CreateFromSQLCODE(SQLCODE,"Change Russia") 23 | 24 | 25 | &sql(Update Covid19.Countries 26 | Set name='United States of America' 27 | where name='united States') 28 | if SQLCODE < 0 throw ##class(%Exception.SQL).CreateFromSQLCODE(SQLCODE,"Change the USA") 29 | } 30 | 31 | ClassMethod UpdatePopulation() 32 | { 33 | &sql( 34 | Update AnalyzeThis_Generated.covid03162020 as t1 35 | SET t1.Population=t2.Population 36 | FROM AnalyzeThis_Generated.covid03162020 as t1 37 | Inner Join Covid19.Countries as t2 on t1.CountryRegion=t2.name) 38 | if SQLCODE < 0 throw ##class(%Exception.SQL).CreateFromSQLCODE(SQLCODE,"Add Population") 39 | } 40 | 41 | ClassMethod DailyUpdate() As %Status 42 | { 43 | set sc=..ImportData() 44 | if $$$ISERR(sc) return sc 45 | set sc=##class(USA.Covid).ImportData() 46 | if $$$ISERR(sc) return sc 47 | set sc=##class(%DeepSee.Utils).%BuildCube("CovidCube") 48 | return sc 49 | } 50 | 51 | ClassMethod ImportData() As %Status 52 | { 53 | set rc=0 54 | set pYesterdayFile=..#TSYesterdayFile_$tr($zd($h-1),"/","-")_".csv" 55 | 56 | set streamYesterday=..GetStreamFromRepo(pYesterdayFile) 57 | do ##class(AnalyzeThis.Generated.covid03162020).ImportFromStream(,streamYesterday,,,1,.rc) 58 | //do ##class(AnalyzeThis.Generated.covid03162020).Import(,pfile,",", ,1,.rc) 59 | 60 | write "imported records: "_rc 61 | do ..ImportCountries() 62 | do ..CleanCountriesData() 63 | do ..UpdatePopulation() 64 | do ##class(%DeepSee.Utils).%BuildCube("covid03162020") 65 | do ..ImportDays() 66 | do ##class(%DeepSee.Utils).%BuildCube("CovidDays") 67 | return $$$OK 68 | } 69 | 70 | ClassMethod BISetup() As %Status 71 | { 72 | do ##class(USA.Utils).Setup() 73 | do ##class(USA.Covid).ImportData() 74 | do ##class(USA.Covid).GrantSQLAccess() 75 | do ##class(%DeepSee.Utils).%BuildCube("CovidCube") 76 | return $$$OK 77 | } 78 | 79 | ClassMethod ImportDays() As %Status 80 | { 81 | s streamConfirmed=..GetStreamFromRepo(..#TSConfirmed) 82 | s streamDeaths=..GetStreamFromRepo(..#TSDeaths) 83 | d ..Import(streamConfirmed,streamDeaths) 84 | return $$$OK 85 | } 86 | 87 | ClassMethod GetStreamFromRepo(fn As %String) As %CharacterStream 88 | { 89 | //set SSLConfig="GitHub" 90 | //do:'##class(Security.SSLConfigs).Exists(SSLConfig) ##class(Security.SSLConfigs).Create(SSLConfig) 91 | Set httprequest = ##class(%Net.HttpRequest).%New() 92 | Set httprequest.Server = "raw.githubusercontent.com" 93 | Set httprequest.Https = 1 94 | Set httprequest.SSLConfiguration = "default" 95 | set urlts="/CSSEGISandData/COVID-19/master/csse_covid_19_data/" 96 | $$$TOE(sc,httprequest.Get(urlts_fn)) 97 | Set stream = httprequest.HttpResponse.Data 98 | 99 | //Reset the HTTP connection, to allow for another connection and not throw a 404 error 100 | Do httprequest.Reset() 101 | 102 | //TBD check for sc 103 | return stream 104 | } 105 | 106 | ClassMethod GetStreamFromFile(fn As %String) As %Stream 107 | { 108 | set stream = ##Class(%Stream.FileCharacter).%New() 109 | set stream.LineTerminator = $Char(13,10) 110 | $$$TOE(sc,stream.LinkToFile(fn)) 111 | //TBD check for sc 112 | return stream 113 | } 114 | 115 | ClassMethod Import(streamConfirmed As %CharacterStream, streamDeaths As %CharacterStream) As %Status 116 | { 117 | // loading days 118 | // format=Province/State,Country/Region,Lat,Long,1/22/20,... 119 | set status=$$$OK 120 | do ##class(Day).%KillExtent() 121 | set line=streamConfirmed.ReadLine() 122 | set lineDeaths=streamDeaths.ReadLine() 123 | set day1h=$zdh("1/22/2020") // day1 in horolog 124 | 125 | while 'streamConfirmed.AtEnd 126 | { 127 | set line=streamConfirmed.ReadLine() 128 | set lineDeaths=streamDeaths.ReadLine() 129 | 130 | set place=##class(Place).%New() 131 | set place.ProvinceState=$p(line,",",1) 132 | set place.CountryRegion=$p(line,",",2) 133 | set place.Latitude=$p(line,",",3) 134 | set place.Longitude=$p(line,",",4) 135 | set status=place.%Save() 136 | 137 | if $$$ISERR(status) 138 | { 139 | do $System.Status.DisplayError(status) 140 | } 141 | set (ConfirmedPrev,DeathsPrev)=0 142 | for i=5:1:$L(line,",") { 143 | set day=##class(Day).%New() 144 | set day.Day=day1h+i-5 145 | if day.Day=+$H Quit 146 | set day.Place=place 147 | set day.Confirmed=$Piece(line,",",i) 148 | set day.ConfirmedNew=day.Confirmed-ConfirmedPrev 149 | set day.Deaths=$Piece(lineDeaths,",",i) 150 | set day.DeathsNew=day.Deaths-DeathsPrev 151 | 152 | set status=day.%Save() 153 | if $$$ISERR(status) do $System.Status.DisplayError(status) 154 | set ConfirmedPrev=day.Confirmed 155 | set DeathsPrev=day.Deaths 156 | 157 | } 158 | } 159 | return status 160 | } 161 | 162 | ClassMethod CreateTask() As %Status 163 | { 164 | Set task=##class(%SYS.Task).%New() 165 | Set task.Name = "Update data" 166 | Set task.NameSpace=$Namespace 167 | Set task.TimePeriod=0 // Daily 168 | Set task.TimePeriodEvery=1 // Every 1 day 169 | Set task.DailyFrequency=1 // Run Several times in a day 170 | Set task.DailyFrequencyTime=0 // Run every x minutes 171 | Set task.DailyIncrement=60 // # of minutes between runs 172 | Set task.DailyStartTime = 0 // Start at 00:00:00 173 | Set task.DailyEndTime = 86399 // End at 23:59:59 174 | Set task.StartDate = $p($H,",",1) // Start today 175 | 176 | Set taskdef = ##class(Covid19.UpdateTask).%New() 177 | Do task.AssignSettings(taskdef) 178 | Set task.TaskClass=$classname(taskdef) 179 | 180 | Set st = task.%Save() 181 | Return:$$$ISERR(st) st 182 | Return ##class(%SYS.Task).RunNow(task.%Id()) 183 | } 184 | 185 | ClassMethod OpenToPublic() 186 | { 187 | n $namespace 188 | s $namespace="%SYS" 189 | write "Modify MDX2JSON application security...",! 190 | set webName = "/mdx2json" 191 | set webProperties("AutheEnabled") = 64 192 | set webProperties("MatchRoles")=":%DB_IRISAPP" 193 | set sc = ##class(Security.Applications).Modify(webName, .webProperties) 194 | if 'sc zw sc 195 | $$$ThrowOnError(sc) 196 | } 197 | 198 | } 199 | -------------------------------------------------------------------------------- /src/USA/BI/CovidCube.cls: -------------------------------------------------------------------------------- 1 | /// 2 | Class USA.BI.CovidCube Extends %DeepSee.CubeDefinition [ DependsOn = USA.Region, ProcedureBlock ] 3 | { 4 | 5 | /// Cube definition from Architect. 6 | XData Cube [ XMLNamespace = "http://www.intersystems.com/deepsee" ] 7 | { 8 | 9 | 61 | 62 | } 63 | 64 | ClassMethod GetColor(min, max, value) As %String 65 | { 66 | if ('value) return "rgb(0,0,0)" 67 | 68 | // Крайние границы: красный и зеленый, цвет для середины - желтый 69 | set middle = (max + min) / 2 70 | 71 | if (value <= middle) 72 | { 73 | set redPart = (value - min) / (middle - min) 74 | return "rgb(" _ (255 * redPart\1) _ ",255, 0)" 75 | } 76 | else 77 | { 78 | set greenPart = (max - value) / (max - middle) 79 | return "rgb(255," _(255 * greenPart\1) _ ", 0)" 80 | } 81 | } 82 | 83 | ClassMethod GetValue(guid, type) As %Integer 84 | { 85 | 86 | //b "L" 87 | //type=1 - population 88 | //type=2 - area 89 | // type=4 - Trump 90 | // type=5 - Clinton 91 | // density 92 | s region=##class(USA.Region).%OpenId(guid) 93 | if $IsObject(region) & type<4 { 94 | s parameter=##class(USA.ParameterValue).RegionParameterIndexOpen(region.Guid,type) 95 | if $IsObject(parameter) return parameter.Value} 96 | if (type=4)!(type=5) { 97 | set parameter=##class(USA.Elections).GuidIdxOpen(guid) 98 | if $IsObject(parameter) return $case(type,4:parameter.Trump,5:parameter.Clinton) 99 | } 100 | if type=6 { 101 | set parameter=##class(USA.Covid).GuidIdxOpen(guid) 102 | if $IsObject(parameter) return parameter.Confirmed 103 | } 104 | if type=7 { 105 | set parameter=##class(USA.Covid).GuidIdxOpen(guid) 106 | if $IsObject(parameter) return parameter.Deaths 107 | } 108 | return "" 109 | } 110 | 111 | ClassMethod TermListSetup() 112 | { 113 | s ^DeepSee.TermList("USMAPSOURCES","caption") = "Map Sources" 114 | s ^DeepSee.TermList("USMAPSOURCES","data","Area","VALUE") = "USA/USMapArea.pivot" 115 | s ^DeepSee.TermList("USMAPSOURCES","data","Density","VALUE") = "USA/USMapDensity.pivot" 116 | s ^DeepSee.TermList("USMAPSOURCES","data","Population","VALUE") = "USA/US Map Population.pivot" 117 | s ^DeepSee.TermList("USMAPSOURCES","modDate") = "2016-03-11 01:36:04" 118 | s ^DeepSee.TermList("USMAPSOURCES","name") = "USMapSources" 119 | s ^DeepSee.TermList("ELECTION VOTES","data","Votes Temperature","VALUE") = "USA/Elections.pivot" 120 | s ^DeepSee.TermList("ELECTION VOTES","data","Winner Takes All","VALUE") = "USA/Elections2.pivot" 121 | s ^DeepSee.TermList("ELECTION VOTES","modDate") = "2016-11-30 15:56:38" 122 | s ^DeepSee.TermList("ELECTION VOTES","name") = "Election Votes" 123 | quit 124 | } 125 | 126 | Parameter DOMAIN; 127 | 128 | } 129 | -------------------------------------------------------------------------------- /src/Covid19/Countries.cls: -------------------------------------------------------------------------------- 1 | Class Covid19.Countries Extends %Library.Persistent [ Not Abstract, DdlAllowed, Not LegacyInstanceContext, ProcedureBlock ] 2 | { 3 | 4 | Property code As %Library.String(MAXLEN = 250) [ SqlColumnNumber = 2 ]; 5 | 6 | Property name As %Library.String(MAXLEN = 250) [ SqlColumnNumber = 3 ]; 7 | 8 | Property continent As %Library.String(MAXLEN = 250) [ SqlColumnNumber = 4 ]; 9 | 10 | Property region As %Library.String(MAXLEN = 250) [ SqlColumnNumber = 5 ]; 11 | 12 | Property surfacearea As %Library.Integer(MAXVAL = 2147483647, MINVAL = -2147483648) [ SqlColumnNumber = 6, SqlFieldName = surface_area ]; 13 | 14 | Property independenceyear As %Library.Integer(MAXVAL = 2147483647, MINVAL = -2147483648) [ SqlColumnNumber = 7, SqlFieldName = independence_year ]; 15 | 16 | Property population As %Library.Integer(MAXVAL = 2147483647, MINVAL = -2147483648) [ SqlColumnNumber = 8 ]; 17 | 18 | Property lifeexpectancy As %Library.Currency [ SqlColumnNumber = 9, SqlFieldName = life_expectancy ]; 19 | 20 | Property gnp As %Library.Double [ SqlColumnNumber = 10 ]; 21 | 22 | Property gnpold As %Library.Integer(MAXVAL = 2147483647, MINVAL = -2147483648) [ SqlColumnNumber = 11, SqlFieldName = gnp_old ]; 23 | 24 | Property localname As %Library.String(MAXLEN = 250) [ SqlColumnNumber = 12, SqlFieldName = local_name ]; 25 | 26 | Property governmentform As %Library.String(MAXLEN = 250) [ SqlColumnNumber = 13, SqlFieldName = government_form ]; 27 | 28 | Property headofstate As %Library.String(MAXLEN = 250) [ SqlColumnNumber = 14, SqlFieldName = head_of_state ]; 29 | 30 | Property capital As %Library.Integer(MAXVAL = 2147483647, MINVAL = -2147483648) [ SqlColumnNumber = 15 ]; 31 | 32 | Property code2 As %Library.String(MAXLEN = 250) [ SqlColumnNumber = 16 ]; 33 | 34 | ClassMethod Import(pSelectMode As %Library.Integer = {$zu(115,5)}, pFileName As %Library.String(MAXLEN=""), pDelimiter As %String = ",", pQuote As %String = """", pHeaders As %Integer = 0, ByRef pRecordCount As %Integer) As %Library.Integer [ SqlProc ] 35 | { 36 | set tStatementId = $SYSTEM.Util.CreateGUID(), tCounter = 0, pRecordCount = 0 37 | set tPreparedStatement = ##class(%SQL.DynamicStatement).Prepare(tStatementId,..#ROWTYPE,pDelimiter,pQuote,,,0,"CSV") 38 | if $Isobject(tPreparedStatement) { 39 | set tImporter = tPreparedStatement.%New(tPreparedStatement,,pFileName,pDelimiter,pQuote) 40 | if $Isobject(tImporter) { 41 | do ..%DeleteExtent(,.tDeleted,.tInstances,1) 42 | // burn the column headers 43 | for tPtr = 1:1:pHeaders { do tImporter.%Next() } 44 | while tImporter.%Next() { 45 | set tMe = ..%New() 46 | if 'pSelectMode { 47 | set tMe.code = tImporter.%GetData(1) 48 | set tMe.name = tImporter.%GetData(2) 49 | set tMe.continent = tImporter.%GetData(3) 50 | set tMe.region = tImporter.%GetData(4) 51 | set tMe.surfacearea = tImporter.%GetData(5) 52 | set tMe.independenceyear = tImporter.%GetData(6) 53 | set tMe.population = tImporter.%GetData(7) 54 | set tMe.lifeexpectancy = tImporter.%GetData(8) 55 | set tMe.gnp = tImporter.%GetData(9) 56 | set tMe.gnpold = tImporter.%GetData(10) 57 | set tMe.localname = tImporter.%GetData(11) 58 | set tMe.governmentform = tImporter.%GetData(12) 59 | set tMe.headofstate = tImporter.%GetData(13) 60 | set tMe.capital = tImporter.%GetData(14) 61 | set tMe.code2 = tImporter.%GetData(15) 62 | } 63 | elseif pSelectMode = 1 { 64 | set tMe.code = $s('$system.CLS.IsMthd("codeOdbcToLogical"):tImporter.%GetData(1),1:tMe.codeOdbcToLogical(tImporter.%GetData(1))) 65 | set tMe.name = $s('$system.CLS.IsMthd("nameOdbcToLogical"):tImporter.%GetData(2),1:tMe.nameOdbcToLogical(tImporter.%GetData(2))) 66 | set tMe.continent = $s('$system.CLS.IsMthd("continentOdbcToLogical"):tImporter.%GetData(3),1:tMe.continentOdbcToLogical(tImporter.%GetData(3))) 67 | set tMe.region = $s('$system.CLS.IsMthd("regionOdbcToLogical"):tImporter.%GetData(4),1:tMe.regionOdbcToLogical(tImporter.%GetData(4))) 68 | set tMe.surfacearea = $s('$system.CLS.IsMthd("surfaceareaOdbcToLogical"):tImporter.%GetData(5),1:tMe.surfaceareaOdbcToLogical(tImporter.%GetData(5))) 69 | set tMe.independenceyear = $s('$system.CLS.IsMthd("independenceyearOdbcToLogical"):tImporter.%GetData(6),1:tMe.independenceyearOdbcToLogical(tImporter.%GetData(6))) 70 | set tMe.population = $s('$system.CLS.IsMthd("populationOdbcToLogical"):tImporter.%GetData(7),1:tMe.populationOdbcToLogical(tImporter.%GetData(7))) 71 | set tMe.lifeexpectancy = $s('$system.CLS.IsMthd("lifeexpectancyOdbcToLogical"):tImporter.%GetData(8),1:tMe.lifeexpectancyOdbcToLogical(tImporter.%GetData(8))) 72 | set tMe.gnp = $s('$system.CLS.IsMthd("gnpOdbcToLogical"):tImporter.%GetData(9),1:tMe.gnpOdbcToLogical(tImporter.%GetData(9))) 73 | set tMe.gnpold = $s('$system.CLS.IsMthd("gnpoldOdbcToLogical"):tImporter.%GetData(10),1:tMe.gnpoldOdbcToLogical(tImporter.%GetData(10))) 74 | set tMe.localname = $s('$system.CLS.IsMthd("localnameOdbcToLogical"):tImporter.%GetData(11),1:tMe.localnameOdbcToLogical(tImporter.%GetData(11))) 75 | set tMe.governmentform = $s('$system.CLS.IsMthd("governmentformOdbcToLogical"):tImporter.%GetData(12),1:tMe.governmentformOdbcToLogical(tImporter.%GetData(12))) 76 | set tMe.headofstate = $s('$system.CLS.IsMthd("headofstateOdbcToLogical"):tImporter.%GetData(13),1:tMe.headofstateOdbcToLogical(tImporter.%GetData(13))) 77 | set tMe.capital = $s('$system.CLS.IsMthd("capitalOdbcToLogical"):tImporter.%GetData(14),1:tMe.capitalOdbcToLogical(tImporter.%GetData(14))) 78 | set tMe.code2 = $s('$system.CLS.IsMthd("code2OdbcToLogical"):tImporter.%GetData(15),1:tMe.code2OdbcToLogical(tImporter.%GetData(15))) 79 | } 80 | elseif pSelectMode = 2 { 81 | set tMe.code = $s('$system.CLS.IsMthd("codeDisplayToLogical"):tImporter.%GetData(1),1:tMe.codeDisplayToLogical(tImporter.%GetData(1))) 82 | set tMe.name = $s('$system.CLS.IsMthd("nameDisplayToLogical"):tImporter.%GetData(2),1:tMe.nameDisplayToLogical(tImporter.%GetData(2))) 83 | set tMe.continent = $s('$system.CLS.IsMthd("continentDisplayToLogical"):tImporter.%GetData(3),1:tMe.continentDisplayToLogical(tImporter.%GetData(3))) 84 | set tMe.region = $s('$system.CLS.IsMthd("regionDisplayToLogical"):tImporter.%GetData(4),1:tMe.regionDisplayToLogical(tImporter.%GetData(4))) 85 | set tMe.surfacearea = $s('$system.CLS.IsMthd("surfaceareaDisplayToLogical"):tImporter.%GetData(5),1:tMe.surfaceareaDisplayToLogical(tImporter.%GetData(5))) 86 | set tMe.independenceyear = $s('$system.CLS.IsMthd("independenceyearDisplayToLogical"):tImporter.%GetData(6),1:tMe.independenceyearDisplayToLogical(tImporter.%GetData(6))) 87 | set tMe.population = $s('$system.CLS.IsMthd("populationDisplayToLogical"):tImporter.%GetData(7),1:tMe.populationDisplayToLogical(tImporter.%GetData(7))) 88 | set tMe.lifeexpectancy = $s('$system.CLS.IsMthd("lifeexpectancyDisplayToLogical"):tImporter.%GetData(8),1:tMe.lifeexpectancyDisplayToLogical(tImporter.%GetData(8))) 89 | set tMe.gnp = $s('$system.CLS.IsMthd("gnpDisplayToLogical"):tImporter.%GetData(9),1:tMe.gnpDisplayToLogical(tImporter.%GetData(9))) 90 | set tMe.gnpold = $s('$system.CLS.IsMthd("gnpoldDisplayToLogical"):tImporter.%GetData(10),1:tMe.gnpoldDisplayToLogical(tImporter.%GetData(10))) 91 | set tMe.localname = $s('$system.CLS.IsMthd("localnameDisplayToLogical"):tImporter.%GetData(11),1:tMe.localnameDisplayToLogical(tImporter.%GetData(11))) 92 | set tMe.governmentform = $s('$system.CLS.IsMthd("governmentformDisplayToLogical"):tImporter.%GetData(12),1:tMe.governmentformDisplayToLogical(tImporter.%GetData(12))) 93 | set tMe.headofstate = $s('$system.CLS.IsMthd("headofstateDisplayToLogical"):tImporter.%GetData(13),1:tMe.headofstateDisplayToLogical(tImporter.%GetData(13))) 94 | set tMe.capital = $s('$system.CLS.IsMthd("capitalDisplayToLogical"):tImporter.%GetData(14),1:tMe.capitalDisplayToLogical(tImporter.%GetData(14))) 95 | set tMe.code2 = $s('$system.CLS.IsMthd("code2DisplayToLogical"):tImporter.%GetData(15),1:tMe.code2DisplayToLogical(tImporter.%GetData(15))) 96 | } 97 | set tStatus = tMe.%Save() 98 | if $$$ISOK(tStatus) { set tCounter = tCounter + 1 } 99 | } 100 | } 101 | } 102 | set %sqlcontext.%SQLCODE = 0 103 | set %sqlcontext.%ROWCOUNT = tCounter 104 | set pRecordCount = tCounter 105 | quit tCounter 106 | } 107 | 108 | Parameter ROWTYPE = "code VARCHAR(250),name VARCHAR(250),continent VARCHAR(250),region VARCHAR(250),surface_area INTEGER,independence_year INTEGER,population INTEGER,life_expectancy MONEY,gnp DOUBLE,gnp_old INTEGER,local_name VARCHAR(250),government_form VARCHAR(250),head_of_state VARCHAR(250),capital INTEGER,code2 VARCHAR(250)"; 109 | 110 | Storage Default 111 | { 112 | 113 | 114 | %%CLASSNAME 115 | 116 | 117 | code 118 | 119 | 120 | name 121 | 122 | 123 | continent 124 | 125 | 126 | region 127 | 128 | 129 | surfacearea 130 | 131 | 132 | independenceyear 133 | 134 | 135 | population 136 | 137 | 138 | lifeexpectancy 139 | 140 | 141 | gnp 142 | 143 | 144 | gnpold 145 | 146 | 147 | localname 148 | 149 | 150 | governmentform 151 | 152 | 153 | headofstate 154 | 155 | 156 | capital 157 | 158 | 159 | code2 160 | 161 | 162 | ^Covid19.CountriesD 163 | CountriesDefaultData 164 | ^Covid19.CountriesD 165 | ^Covid19.CountriesI 166 | ^Covid19.CountriesS 167 | %Storage.Persistent 168 | } 169 | 170 | } 171 | -------------------------------------------------------------------------------- /src/AnalyzeThis/Generated/covid03162020.cls: -------------------------------------------------------------------------------- 1 | Class AnalyzeThis.Generated.covid03162020 Extends %Library.Persistent [ Not Abstract, DdlAllowed, Not LegacyInstanceContext, ProcedureBlock ] 2 | { 3 | 4 | Parameter DEFAULTGLOBAL = "^AnalyzeThis.G.covid03162020"; 5 | 6 | Property Confirmed As %Integer [ SqlColumnNumber = 5 ]; 7 | 8 | Property CountryRegion As %String(MAXLEN = "") [ SqlColumnNumber = 3 ]; 9 | 10 | Property Deaths As %Integer [ SqlColumnNumber = 6 ]; 11 | 12 | Property LastUpdate As %Date [ SqlColumnNumber = 4 ]; 13 | 14 | Property Latitude As %String(MAXLEN = "") [ SqlColumnNumber = 8 ]; 15 | 16 | Property Longitude As %String(MAXLEN = "") [ SqlColumnNumber = 9 ]; 17 | 18 | Property ProvinceState As %String(MAXLEN = "") [ SqlColumnNumber = 2 ]; 19 | 20 | Property Recovered As %Integer [ SqlColumnNumber = 7 ]; 21 | 22 | Property FIPS As %Integer; 23 | 24 | Property City As %String(MAXLEN = ""); 25 | 26 | Property Population As %Integer; 27 | 28 | Method LastUpdateSet(pVal) As %Status 29 | { 30 | Try { Set pVal=+$zdth(pVal,3) } 31 | Catch ex { } 32 | Set i%LastUpdate=pVal 33 | Quit $$$OK 34 | } 35 | 36 | ClassMethod ImportFromStream(pSelectMode As %Library.Integer = {$zu(115,5)}, streamConfirmed As %CharacterStream, pDelimiter As %String = ",", pQuote As %String = """", pHeaders As %Integer = 0, ByRef pRecordCount As %Integer) As %Library.Integer [ SqlProc ] 37 | { 38 | set tStatementId = $SYSTEM.Util.CreateGUID(), tCounter = 0, pRecordCount = 0 39 | do ..%DeleteExtent(,.tDeleted,.tInstances,1) 40 | // burn the column headers 41 | ;for tPtr = 1:1:pHeaders { do tImporter.%Next() } 42 | 43 | set line=streamConfirmed.ReadLine() 44 | while 'streamConfirmed.AtEnd 45 | { 46 | set line=streamConfirmed.ReadLine() 47 | set tMe = ..%New() 48 | if 'pSelectMode { 49 | If (line [ pQuote) { 50 | for pQuoteIter=2:2:$L(line, pQuote) { 51 | Set $P(line,pQuote,pQuoteIter)=$TR($P(line,pQuote,pQuoteIter),",",";") 52 | } 53 | set line =$TR(line,pQuote,"") 54 | } 55 | 56 | set tMe.FIPS = $TR($p(line,",",1),";",",") ;$p(line,",",1) 57 | set tMe.City = $TR($p(line,",",2),";",",") ;$p(line,",",2) 58 | set tMe.ProvinceState = $TR($p(line,",",3),";",",") ;$p(line,",",3) 59 | set tMe.CountryRegion = $TR($p(line,",",4),";",",") ;$p(line,",",4) 60 | set tMe.LastUpdate = $TR($p(line,",",5),";",",") ;$p(line,",",5) 61 | set tMe.Latitude = $TR($p(line,",",6),";",",") ;$p(line,",",6) 62 | set tMe.Longitude = $TR($p(line,",",7),";",",") ;$p(line,",",7) 63 | set tMe.Confirmed = $TR($p(line,",",8),";",",") ;$p(line,",",8) 64 | set tMe.Deaths = $TR($p(line,",",9),";",",") ;$p(line,",",9) 65 | set tMe.Recovered = $TR($p(line,",",10),";",",") ;$p(line,",",10) 66 | } 67 | elseif pSelectMode = 1 { 68 | If (line [ pQuote) { 69 | If ($L(line,pQuote)>0) { 70 | Set pStateCity=$P(line,pQuote,2) 71 | Set pCity=$ZSTRIP($P(pStateCity,",",1),"<>W") 72 | Set pState=$ZSTRIP($P(pStateCity,",",2),"<>W") 73 | Set $P(line,",",1,2)=pState 74 | } 75 | } 76 | set tMe.ProvinceState = $s('$system.CLS.IsMthd("ProvinceStateOdbcToLogical"):$p(line,",",1),1:tMe.ProvinceStateOdbcToLogical($p(line,",",1))) 77 | set tMe.CountryRegion = $s('$system.CLS.IsMthd("CountryRegionOdbcToLogical"):$p(line,",",2),1:tMe.CountryRegionOdbcToLogical($p(line,",",2))) 78 | set tMe.LastUpdate = $s('$system.CLS.IsMthd("LastUpdateOdbcToLogical"):$p(line,",",3),1:tMe.LastUpdateOdbcToLogical($p(line,",",3))) 79 | set tMe.Confirmed = $s('$system.CLS.IsMthd("ConfirmedOdbcToLogical"):$p(line,",",4),1:tMe.ConfirmedOdbcToLogical($p(line,",",4))) 80 | set tMe.Deaths = $s('$system.CLS.IsMthd("DeathsOdbcToLogical"):$p(line,",",5),1:tMe.DeathsOdbcToLogical($p(line,",",5))) 81 | set tMe.Recovered = $s('$system.CLS.IsMthd("RecoveredOdbcToLogical"):$p(line,",",6),1:tMe.RecoveredOdbcToLogical($p(line,",",6))) 82 | set tMe.Latitude = $s('$system.CLS.IsMthd("LatitudeOdbcToLogical"):$p(line,",",7),1:tMe.LatitudeOdbcToLogical($p(line,",",7))) 83 | set tMe.Longitude = $s('$system.CLS.IsMthd("LongitudeOdbcToLogical"):$p(line,",",8),1:tMe.LongitudeOdbcToLogical($p(line,",",8))) 84 | If (""'=pCity) { 85 | set tMe.City = pCity 86 | } 87 | } 88 | elseif pSelectMode = 2 { 89 | If (line [ pQuote) { 90 | 91 | If ($L(line,pQuote)>0) { 92 | Set pStateCity=$P(line,pQuote,2) 93 | Set pCity=$ZSTRIP($P(pStateCity,",",1),"<>W") 94 | Set pState=$ZSTRIP($P(pStateCity,",",2),"<>W") 95 | Set $P(line,",",1,2)=pState 96 | } 97 | } 98 | set tMe.ProvinceState = $s('$system.CLS.IsMthd("ProvinceStateDisplayToLogical"):$p(line,",",1),1:tMe.ProvinceStateDisplayToLogical($p(line,",",1))) 99 | set tMe.CountryRegion = $s('$system.CLS.IsMthd("CountryRegionDisplayToLogical"):$p(line,",",2),1:tMe.CountryRegionDisplayToLogical($p(line,",",2))) 100 | set tMe.LastUpdate = $s('$system.CLS.IsMthd("LastUpdateDisplayToLogical"):$p(line,",",3),1:tMe.LastUpdateDisplayToLogical($p(line,",",3))) 101 | set tMe.Confirmed = $s('$system.CLS.IsMthd("ConfirmedDisplayToLogical"):$p(line,",",4),1:tMe.ConfirmedDisplayToLogical($p(line,",",4))) 102 | set tMe.Deaths = $s('$system.CLS.IsMthd("DeathsDisplayToLogical"):$p(line,",",5),1:tMe.DeathsDisplayToLogical($p(line,",",5))) 103 | set tMe.Recovered = $s('$system.CLS.IsMthd("RecoveredDisplayToLogical"):$p(line,",",6),1:tMe.RecoveredDisplayToLogical($p(line,",",6))) 104 | set tMe.Latitude = $s('$system.CLS.IsMthd("LatitudeDisplayToLogical"):$p(line,",",7),1:tMe.LatitudeDisplayToLogical($p(line,",",7))) 105 | set tMe.Longitude = $s('$system.CLS.IsMthd("LongitudeDisplayToLogical"):$p(line,",",8),1:tMe.LongitudeDisplayToLogical($p(line,",",8))) 106 | If (""'=pCity) { 107 | set tMe.City = pCity 108 | } 109 | } 110 | s tStatus = tMe.%Save() 111 | if $$$ISOK(tStatus) { set tCounter = tCounter + 1 } 112 | 113 | } 114 | set %sqlcontext.%SQLCODE = 0 115 | set %sqlcontext.%ROWCOUNT = tCounter 116 | set pRecordCount = tCounter 117 | 118 | // change 'US'->'United States of America' 119 | &sql(Update AnalyzeThis_Generated.covid03162020 120 | Set CountryRegion='United States of America' 121 | Where CountryRegion='US' 122 | ) 123 | 124 | 125 | quit tCounter 126 | } 127 | 128 | ClassMethod Import(pSelectMode As %Library.Integer = {$zu(115,5)}, pFileName As %Library.String(MAXLEN=""), pDelimiter As %String = ",", pQuote As %String = """", pHeaders As %Integer = 0, ByRef pRecordCount As %Integer) As %Library.Integer [ SqlProc ] 129 | { 130 | set tStatementId = $SYSTEM.Util.CreateGUID(), tCounter = 0, pRecordCount = 0 131 | set tPreparedStatement = ##class(%SQL.DynamicStatement).Prepare(tStatementId,..#ROWTYPE,pDelimiter,pQuote,,,0,"CSV") 132 | if $Isobject(tPreparedStatement) { 133 | set tImporter = tPreparedStatement.%New(tPreparedStatement,,pFileName,pDelimiter,pQuote) 134 | if $Isobject(tImporter) { 135 | do ..%DeleteExtent(,.tDeleted,.tInstances,1) 136 | // burn the column headers 137 | for tPtr = 1:1:pHeaders { do tImporter.%Next() } 138 | while tImporter.%Next() { 139 | set tMe = ..%New() 140 | if 'pSelectMode { 141 | set tMe.FIPS = tImporter.%GetData(1) 142 | set tMe.City = tImporter.%GetData(2) 143 | set tMe.ProvinceState = tImporter.%GetData(3) 144 | set tMe.CountryRegion = tImporter.%GetData(4) 145 | set tMe.LastUpdate = tImporter.%GetData(5) 146 | set tMe.Latitude = tImporter.%GetData(6) 147 | set tMe.Longitude = tImporter.%GetData(7) 148 | set tMe.Confirmed = tImporter.%GetData(8) 149 | set tMe.Deaths = tImporter.%GetData(9) 150 | set tMe.Recovered = tImporter.%GetData(10) 151 | 152 | } 153 | elseif pSelectMode = 1 { 154 | set tMe.ProvinceState = $s('$system.CLS.IsMthd("ProvinceStateOdbcToLogical"):tImporter.%GetData(1),1:tMe.ProvinceStateOdbcToLogical(tImporter.%GetData(1))) 155 | set tMe.CountryRegion = $s('$system.CLS.IsMthd("CountryRegionOdbcToLogical"):tImporter.%GetData(2),1:tMe.CountryRegionOdbcToLogical(tImporter.%GetData(2))) 156 | set tMe.LastUpdate = $s('$system.CLS.IsMthd("LastUpdateOdbcToLogical"):tImporter.%GetData(3),1:tMe.LastUpdateOdbcToLogical(tImporter.%GetData(3))) 157 | set tMe.Confirmed = $s('$system.CLS.IsMthd("ConfirmedOdbcToLogical"):tImporter.%GetData(4),1:tMe.ConfirmedOdbcToLogical(tImporter.%GetData(4))) 158 | set tMe.Deaths = $s('$system.CLS.IsMthd("DeathsOdbcToLogical"):tImporter.%GetData(5),1:tMe.DeathsOdbcToLogical(tImporter.%GetData(5))) 159 | set tMe.Recovered = $s('$system.CLS.IsMthd("RecoveredOdbcToLogical"):tImporter.%GetData(6),1:tMe.RecoveredOdbcToLogical(tImporter.%GetData(6))) 160 | set tMe.Latitude = $s('$system.CLS.IsMthd("LatitudeOdbcToLogical"):tImporter.%GetData(7),1:tMe.LatitudeOdbcToLogical(tImporter.%GetData(7))) 161 | set tMe.Longitude = $s('$system.CLS.IsMthd("LongitudeOdbcToLogical"):tImporter.%GetData(8),1:tMe.LongitudeOdbcToLogical(tImporter.%GetData(8))) 162 | } 163 | elseif pSelectMode = 2 { 164 | set tMe.ProvinceState = $s('$system.CLS.IsMthd("ProvinceStateDisplayToLogical"):tImporter.%GetData(1),1:tMe.ProvinceStateDisplayToLogical(tImporter.%GetData(1))) 165 | set tMe.CountryRegion = $s('$system.CLS.IsMthd("CountryRegionDisplayToLogical"):tImporter.%GetData(2),1:tMe.CountryRegionDisplayToLogical(tImporter.%GetData(2))) 166 | set tMe.LastUpdate = $s('$system.CLS.IsMthd("LastUpdateDisplayToLogical"):tImporter.%GetData(3),1:tMe.LastUpdateDisplayToLogical(tImporter.%GetData(3))) 167 | set tMe.Confirmed = $s('$system.CLS.IsMthd("ConfirmedDisplayToLogical"):tImporter.%GetData(4),1:tMe.ConfirmedDisplayToLogical(tImporter.%GetData(4))) 168 | set tMe.Deaths = $s('$system.CLS.IsMthd("DeathsDisplayToLogical"):tImporter.%GetData(5),1:tMe.DeathsDisplayToLogical(tImporter.%GetData(5))) 169 | set tMe.Recovered = $s('$system.CLS.IsMthd("RecoveredDisplayToLogical"):tImporter.%GetData(6),1:tMe.RecoveredDisplayToLogical(tImporter.%GetData(6))) 170 | set tMe.Latitude = $s('$system.CLS.IsMthd("LatitudeDisplayToLogical"):tImporter.%GetData(7),1:tMe.LatitudeDisplayToLogical(tImporter.%GetData(7))) 171 | set tMe.Longitude = $s('$system.CLS.IsMthd("LongitudeDisplayToLogical"):tImporter.%GetData(8),1:tMe.LongitudeDisplayToLogical(tImporter.%GetData(8))) 172 | } 173 | set tStatus = tMe.%Save() 174 | if $$$ISOK(tStatus) { set tCounter = tCounter + 1 } 175 | } 176 | } 177 | } 178 | set %sqlcontext.%SQLCODE = 0 179 | set %sqlcontext.%ROWCOUNT = tCounter 180 | set pRecordCount = tCounter 181 | quit tCounter 182 | } 183 | 184 | Parameter ROWTYPE = "FIPS INTEGER, CITY VARCHAR(100), ProvinceState VARCHAR(100),CountryRegion VARCHAR(100),LastUpdate DATE,Confirmed INTEGER,Deaths INTEGER,Recovered INTEGER,Latitude VARCHAR(50),Longitude VARCHAR(50)"; 185 | 186 | Storage Default 187 | { 188 | 189 | 190 | %%CLASSNAME 191 | 192 | 193 | Confirmed 194 | 195 | 196 | CountryRegion 197 | 198 | 199 | Deaths 200 | 201 | 202 | LastUpdate 203 | 204 | 205 | Latitude 206 | 207 | 208 | Longitude 209 | 210 | 211 | ProvinceState 212 | 213 | 214 | Recovered 215 | 216 | 217 | FIPS 218 | 219 | 220 | City 221 | 222 | 223 | Population 224 | 225 | 226 | ^AnalyzeThis.G.covid03162020D 227 | covid03162020DefaultData 228 | ^AnalyzeThis.G.covid03162020D 229 | ^AnalyzeThis.G.covid03162020I 230 | ^AnalyzeThis.G.covid03162020S 231 | %Storage.Persistent 232 | } 233 | 234 | } 235 | --------------------------------------------------------------------------------