From f09d41b0127488392ed762e4d5e721b7f75c2911 Mon Sep 17 00:00:00 2001 From: Jamie Gilbert Date: Mon, 15 Jan 2024 11:07:18 -0800 Subject: [PATCH 1/8] Created first draft of study json schema object --- inst/analysis-specification-schema.json | 169 ++++++++++++++++++++++++ 1 file changed, 169 insertions(+) create mode 100644 inst/analysis-specification-schema.json diff --git a/inst/analysis-specification-schema.json b/inst/analysis-specification-schema.json new file mode 100644 index 00000000..ef605ed7 --- /dev/null +++ b/inst/analysis-specification-schema.json @@ -0,0 +1,169 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "apiVersion": { + "type": "string" + }, + "sharedResources": { + "type": "array", + "items": { + "oneOf": [ + { + "type": "object", + "properties": { + "cohortDefinitionSet": { + "type": "object", + "properties": { + "cohortDefinitions": { + "type": "array", + "items": { + "oneOf": [ + { + "type": "object", + "properties": { + "_links": { + "type": "object", + "properties": { + "self": { + "type": "object", + "properties": { + "href": { + "type": "string" + } + } + } + }, + "required": ["self"] + }, + "cohortName": { + "type": "string" + }, + "cohortDefinitionId": { + "type": "integer" + } + }, + "required": ["_links", "cohortName", "cohortDefinitionId"] + }, + { + "type": "object", + "properties": { + "cohortDefinitionId": {"type": "integer"}, + "targetCohortDefinitionId": {"type": "integer"}, + "subsetDefinitionId": {"type": "integer"}, + "cohortName": { + "type": "string" + } + }, + "required": ["cohortDefinitionId", "targetCohortDefinitionId", "subsetDefinitionId"] + } + ] + } + }, + "subsetDefinitions": { + "type": "array", + "items": { + "type": "object", + "properties": { + "_links": { + "type": "object", + "properties": { + "self": {"type": "object", "properties": {"href": {"type": "string"}}} + }, + "required": ["self"] + }, + "subsetDefinitionName": {"type": "string"}, + "subsetDefinitionId": {"type": "integer"} + }, + "required": ["_links", "subsetDefinitionName", "subsetDefinitionId"] + } + } + }, + "required": ["cohortDefinitions", "subsetDefinitions"] + } + }, + "required": ["cohortDefinitionSet"] + }, + { + "type": "object", + "properties": { + "conceptSetDefinition": { + "type": "object", + "properties": { + "id": {"type": "integer"}, + "conceptSetName": {"type": "string"}, + "isNegativeControlConceptSet": {"type": "boolean"}, + "concepts": { + "type": "array", + "items": { + "type": "object", + "properties": { + "conceptId": {"type": "integer"}, + "conceptName": {"type": "string"}, + "standardConcept": {"type": "boolean"}, + "standardConceptCaption": {"type": "string"}, + "invalidReason": {"type": "string"}, + "invalidReasonCaption": {"type": "string"}, + "conceptCode": {"type": "string"}, + "domainId": {"type": "integer"}, + "vocabularyId": {"type": "integer"}, + "conceptClassId": {"type": "integer"}, + "validStartDate": {"type": "string", "format": "date"}, + "validEndDate": {"type": "string", "format": "date"}, + "cohortDefinitionId": {"type": "integer"} + }, + "required": ["conceptId", "conceptName", "standardConcept", "standardConceptCaption", "invalidReason", "invalidReasonCaption", "conceptCode", "domainId", "vocabularyId", "conceptClassId", "validStartDate", "validEndDate"] + } + } + }, + "required": ["id", "conceptSetName", "concepts"] + } + }, + "required": ["conceptSetDefinition"] + }, + { + "type": "object", + "properties": { + "sharedResource": { + "type": "object", + "properties": { + "name": {"type": "string"}, + "schemaRef": {"type": "string", "format": "uri"} + }, + "required": ["name", "schemaRef"] + } + }, + "required": ["sharedResource"] + } + ] + } + }, + "renv": { + "type": "object", + "properties": { + "_links": { + "type": "object", + "properties": { + "self": {"type": "object", "properties": {"href": {"type": "string"}}} + }, + "required": ["self"] + } + }, + "required": ["_links"] + }, + "modules": { + "type": "array", + "items": { + "type": "object", + "properties": { + "module": {"type": "string"}, + "version": {"type": "string"}, + "schemaRef": {"type": "string", "format": "uri"}, + "settings": {"$ref": "#"} + }, + "required": ["module", "version", "schemaRef", "settings"] + } + } + }, + "required": ["apiVersion", "sharedResources", "renv", "modules"] +} From 5df2bb99b3f7189a019e445a1088aaa3eb25dfe7 Mon Sep 17 00:00:00 2001 From: Jamie Gilbert Date: Mon, 15 Jan 2024 11:33:01 -0800 Subject: [PATCH 2/8] Changes to allow modules to have internal renvs --- inst/analysis-specification-schema.json | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/inst/analysis-specification-schema.json b/inst/analysis-specification-schema.json index ef605ed7..afd06c12 100644 --- a/inst/analysis-specification-schema.json +++ b/inst/analysis-specification-schema.json @@ -100,7 +100,7 @@ "properties": { "conceptId": {"type": "integer"}, "conceptName": {"type": "string"}, - "standardConcept": {"type": "boolean"}, + "standardConcept": {"type": "string", "enum": ["S", "NS"]}, "standardConceptCaption": {"type": "string"}, "invalidReason": {"type": "string"}, "invalidReasonCaption": {"type": "string"}, @@ -159,7 +159,25 @@ "module": {"type": "string"}, "version": {"type": "string"}, "schemaRef": {"type": "string", "format": "uri"}, - "settings": {"$ref": "#"} + "settings": {"$ref": "#"}, + "renv" : { + "type": "object", + "properties": { + "_links": { + "type": "object", + "properties": { + "self": { + "type": "object", + "properties": { + "href": { + "type": "string" + } + } + } + }, + "required": ["self"] + } + } }, "required": ["module", "version", "schemaRef", "settings"] } From f6ddaf3681c53a0deff12c081161daab425182b7 Mon Sep 17 00:00:00 2001 From: Jamie Gilbert Date: Mon, 15 Jan 2024 11:43:19 -0800 Subject: [PATCH 3/8] Name and description fields and study name and study description fields --- inst/analysis-specification-schema.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/inst/analysis-specification-schema.json b/inst/analysis-specification-schema.json index afd06c12..e98778ac 100644 --- a/inst/analysis-specification-schema.json +++ b/inst/analysis-specification-schema.json @@ -1,10 +1,14 @@ { - "$schema": "http://json-schema.org/draft-07/schema#", + "$schema": "https://json-schema.org/draft/2020-12/schema", "type": "object", + "title": "OHDSI study specification", + "description": "A study definition for an OHDSI study", "properties": { "apiVersion": { "type": "string" }, + "studyName": {"type" : "string"}, + "studyDescription": {"type" : "string"}, "sharedResources": { "type": "array", "items": { From 8794d1a5007c4705e74da506d5dc1aa0534a070a Mon Sep 17 00:00:00 2001 From: Jamie Gilbert Date: Mon, 15 Jan 2024 12:59:29 -0800 Subject: [PATCH 4/8] formatting --- inst/analysis-specification-schema.json | 249 +++++++++++++++++++----- 1 file changed, 195 insertions(+), 54 deletions(-) diff --git a/inst/analysis-specification-schema.json b/inst/analysis-specification-schema.json index e98778ac..518bb583 100644 --- a/inst/analysis-specification-schema.json +++ b/inst/analysis-specification-schema.json @@ -7,8 +7,12 @@ "apiVersion": { "type": "string" }, - "studyName": {"type" : "string"}, - "studyDescription": {"type" : "string"}, + "studyName": { + "type": "string" + }, + "studyDescription": { + "type": "string" + }, "sharedResources": { "type": "array", "items": { @@ -38,7 +42,9 @@ } } }, - "required": ["self"] + "required": [ + "self" + ] }, "cohortName": { "type": "string" @@ -47,19 +53,33 @@ "type": "integer" } }, - "required": ["_links", "cohortName", "cohortDefinitionId"] + "required": [ + "_links", + "cohortName", + "cohortDefinitionId" + ] }, { "type": "object", "properties": { - "cohortDefinitionId": {"type": "integer"}, - "targetCohortDefinitionId": {"type": "integer"}, - "subsetDefinitionId": {"type": "integer"}, - "cohortName": { + "cohortDefinitionId": { + "type": "integer" + }, + "targetCohortDefinitionId": { + "type": "integer" + }, + "subsetDefinitionId": { + "type": "integer" + }, + "cohortName": { "type": "string" } }, - "required": ["cohortDefinitionId", "targetCohortDefinitionId", "subsetDefinitionId"] + "required": [ + "cohortDefinitionId", + "targetCohortDefinitionId", + "subsetDefinitionId" + ] } ] } @@ -72,21 +92,43 @@ "_links": { "type": "object", "properties": { - "self": {"type": "object", "properties": {"href": {"type": "string"}}} + "self": { + "type": "object", + "properties": { + "href": { + "type": "string" + } + } + } }, - "required": ["self"] + "required": [ + "self" + ] + }, + "subsetDefinitionName": { + "type": "string" }, - "subsetDefinitionName": {"type": "string"}, - "subsetDefinitionId": {"type": "integer"} + "subsetDefinitionId": { + "type": "integer" + } }, - "required": ["_links", "subsetDefinitionName", "subsetDefinitionId"] + "required": [ + "_links", + "subsetDefinitionName", + "subsetDefinitionId" + ] } } }, - "required": ["cohortDefinitions", "subsetDefinitions"] + "required": [ + "cohortDefinitions", + "subsetDefinitions" + ] } }, - "required": ["cohortDefinitionSet"] + "required": [ + "cohortDefinitionSet" + ] }, { "type": "object", @@ -94,36 +136,93 @@ "conceptSetDefinition": { "type": "object", "properties": { - "id": {"type": "integer"}, - "conceptSetName": {"type": "string"}, - "isNegativeControlConceptSet": {"type": "boolean"}, + "id": { + "type": "integer" + }, + "conceptSetName": { + "type": "string" + }, + "isNegativeControlConceptSet": { + "type": "boolean" + }, "concepts": { "type": "array", "items": { "type": "object", "properties": { - "conceptId": {"type": "integer"}, - "conceptName": {"type": "string"}, - "standardConcept": {"type": "string", "enum": ["S", "NS"]}, - "standardConceptCaption": {"type": "string"}, - "invalidReason": {"type": "string"}, - "invalidReasonCaption": {"type": "string"}, - "conceptCode": {"type": "string"}, - "domainId": {"type": "integer"}, - "vocabularyId": {"type": "integer"}, - "conceptClassId": {"type": "integer"}, - "validStartDate": {"type": "string", "format": "date"}, - "validEndDate": {"type": "string", "format": "date"}, - "cohortDefinitionId": {"type": "integer"} + "conceptId": { + "type": "integer" + }, + "conceptName": { + "type": "string" + }, + "standardConcept": { + "type": "string", + "enum": [ + "S", + "NS" + ] + }, + "standardConceptCaption": { + "type": "string" + }, + "invalidReason": { + "type": "string" + }, + "invalidReasonCaption": { + "type": "string" + }, + "conceptCode": { + "type": "string" + }, + "domainId": { + "type": "integer" + }, + "vocabularyId": { + "type": "integer" + }, + "conceptClassId": { + "type": "integer" + }, + "validStartDate": { + "type": "string", + "format": "date" + }, + "validEndDate": { + "type": "string", + "format": "date" + }, + "cohortDefinitionId": { + "type": "integer" + } }, - "required": ["conceptId", "conceptName", "standardConcept", "standardConceptCaption", "invalidReason", "invalidReasonCaption", "conceptCode", "domainId", "vocabularyId", "conceptClassId", "validStartDate", "validEndDate"] + "required": [ + "conceptId", + "conceptName", + "standardConcept", + "standardConceptCaption", + "invalidReason", + "invalidReasonCaption", + "conceptCode", + "domainId", + "vocabularyId", + "conceptClassId", + "validStartDate", + "validEndDate" + ] } } }, - "required": ["id", "conceptSetName", "concepts"] + "required": [ + "id", + "conceptSetName", + "concepts" + ] } }, - "required": ["conceptSetDefinition"] + "required": [ + "conceptSetDefinition" + ] }, { "type": "object", @@ -131,13 +230,23 @@ "sharedResource": { "type": "object", "properties": { - "name": {"type": "string"}, - "schemaRef": {"type": "string", "format": "uri"} + "name": { + "type": "string" + }, + "schemaRef": { + "type": "string", + "format": "uri" + } }, - "required": ["name", "schemaRef"] + "required": [ + "name", + "schemaRef" + ] } }, - "required": ["sharedResource"] + "required": [ + "sharedResource" + ] } ] } @@ -148,23 +257,43 @@ "_links": { "type": "object", "properties": { - "self": {"type": "object", "properties": {"href": {"type": "string"}}} + "self": { + "type": "object", + "properties": { + "href": { + "type": "string" + } + } + } }, - "required": ["self"] + "required": [ + "self" + ] } }, - "required": ["_links"] + "required": [ + "_links" + ] }, "modules": { "type": "array", "items": { "type": "object", "properties": { - "module": {"type": "string"}, - "version": {"type": "string"}, - "schemaRef": {"type": "string", "format": "uri"}, - "settings": {"$ref": "#"}, - "renv" : { + "module": { + "type": "string" + }, + "version": { + "type": "string" + }, + "schemaRef": { + "type": "string", + "format": "uri" + }, + "settings": { + "$ref": "#" + }, + "renv": { "type": "object", "properties": { "_links": { @@ -179,13 +308,25 @@ } } }, - "required": ["self"] + "required": [ + "self" + ] } } - }, - "required": ["module", "version", "schemaRef", "settings"] + }, + "required": [ + "module", + "version", + "schemaRef", + "settings" + ] + } } - } - }, - "required": ["apiVersion", "sharedResources", "renv", "modules"] -} + }, + "required": [ + "apiVersion", + "sharedResources", + "renv", + "modules" + ] + } From 561046991a1596b231eba3d79b1bd7bee5deb85c Mon Sep 17 00:00:00 2001 From: Jamie Gilbert Date: Mon, 15 Jan 2024 12:59:51 -0800 Subject: [PATCH 5/8] fixed broken end tag --- inst/analysis-specification-schema.json | 1 + 1 file changed, 1 insertion(+) diff --git a/inst/analysis-specification-schema.json b/inst/analysis-specification-schema.json index 518bb583..f845a7d7 100644 --- a/inst/analysis-specification-schema.json +++ b/inst/analysis-specification-schema.json @@ -330,3 +330,4 @@ "modules" ] } +} From 90afc6a6c4c3359742bedcdb838bfa7be1482919 Mon Sep 17 00:00:00 2001 From: Jamie Gilbert Date: Mon, 15 Jan 2024 13:31:44 -0800 Subject: [PATCH 6/8] Added an optional calling function argument to modules --- inst/analysis-specification-schema.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/inst/analysis-specification-schema.json b/inst/analysis-specification-schema.json index f845a7d7..31f12cab 100644 --- a/inst/analysis-specification-schema.json +++ b/inst/analysis-specification-schema.json @@ -293,6 +293,10 @@ "settings": { "$ref": "#" }, + "callingFunction": { + "type": "string", + "description": "calling function within package to pass settings to (e.g executeAnalyses). Defaults to `execute`" + }, "renv": { "type": "object", "properties": { From 3e4f2cd962a3be9452941c549f8bd03e9cd7747d Mon Sep 17 00:00:00 2001 From: Jamie Gilbert Date: Wed, 17 Jan 2024 09:57:52 -0800 Subject: [PATCH 7/8] Added resource names for run time validation of module requirements --- inst/analysis-specification-schema.json | 119 +++++++++++++++++++++++- 1 file changed, 114 insertions(+), 5 deletions(-) diff --git a/inst/analysis-specification-schema.json b/inst/analysis-specification-schema.json index 31f12cab..46ece560 100644 --- a/inst/analysis-specification-schema.json +++ b/inst/analysis-specification-schema.json @@ -20,6 +20,10 @@ { "type": "object", "properties": { + "resourceName" : { + "type": "string", + "description": "unique name for resource" + }, "cohortDefinitionSet": { "type": "object", "properties": { @@ -133,6 +137,10 @@ { "type": "object", "properties": { + "resourceName" : { + "type": "string", + "description": "unique name for resource" + }, "conceptSetDefinition": { "type": "object", "properties": { @@ -142,9 +150,6 @@ "conceptSetName": { "type": "string" }, - "isNegativeControlConceptSet": { - "type": "boolean" - }, "concepts": { "type": "array", "items": { @@ -224,6 +229,102 @@ "conceptSetDefinition" ] }, + { + "type": "object", + "properties": { + "resourceName" : { + "type": "string", + "description": "unique name for resource" + }, + "negativeControlConceptSetDefinition": { + "type": "object", + "properties": { + "id": { + "type": "integer" + }, + "conceptSetName": { + "type": "string" + }, + "concepts": { + "type": "array", + "items": { + "type": "object", + "properties": { + "conceptId": { + "type": "integer" + }, + "conceptName": { + "type": "string" + }, + "standardConcept": { + "type": "string", + "enum": [ + "S", + "NS" + ] + }, + "standardConceptCaption": { + "type": "string" + }, + "invalidReason": { + "type": "string" + }, + "invalidReasonCaption": { + "type": "string" + }, + "conceptCode": { + "type": "string" + }, + "domainId": { + "type": "integer" + }, + "vocabularyId": { + "type": "integer" + }, + "conceptClassId": { + "type": "integer" + }, + "validStartDate": { + "type": "string", + "format": "date" + }, + "validEndDate": { + "type": "string", + "format": "date" + }, + "cohortDefinitionId": { + "type": "integer" + } + }, + "required": [ + "conceptId", + "conceptName", + "standardConcept", + "standardConceptCaption", + "invalidReason", + "invalidReasonCaption", + "conceptCode", + "domainId", + "vocabularyId", + "conceptClassId", + "validStartDate", + "validEndDate", + "cohortDefinitionId" + ] + } + } + }, + "required": [ + "id", + "conceptSetName", + "concepts" + ] + } + }, + "required": [ + "negativeControlConceptSetDefinition" + ] + }, { "type": "object", "properties": { @@ -293,9 +394,16 @@ "settings": { "$ref": "#" }, + "requiredSharedResources" : { + "type": "array", + "description": "Shared resource labels required for this object", + "items": { + "type": "string" + } + }, "callingFunction": { "type": "string", - "description": "calling function within package to pass settings to (e.g executeAnalyses). Defaults to `execute`" + "description": "Optional calling function within package to pass settings to (e.g executeAnalyses). Defaults to `execute`" }, "renv": { "type": "object", @@ -322,7 +430,8 @@ "module", "version", "schemaRef", - "settings" + "settings", + "requiredSharedResources" ] } } From a31486fd6882322252a01119d9e7d42b99ca3b8a Mon Sep 17 00:00:00 2001 From: Jamie Gilbert Date: Thu, 18 Jan 2024 10:29:21 -0800 Subject: [PATCH 8/8] Removed renv from modules and calling function to simplify design --- inst/analysis-specification-schema.json | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/inst/analysis-specification-schema.json b/inst/analysis-specification-schema.json index 46ece560..b38e7548 100644 --- a/inst/analysis-specification-schema.json +++ b/inst/analysis-specification-schema.json @@ -401,31 +401,6 @@ "type": "string" } }, - "callingFunction": { - "type": "string", - "description": "Optional calling function within package to pass settings to (e.g executeAnalyses). Defaults to `execute`" - }, - "renv": { - "type": "object", - "properties": { - "_links": { - "type": "object", - "properties": { - "self": { - "type": "object", - "properties": { - "href": { - "type": "string" - } - } - } - }, - "required": [ - "self" - ] - } - } - }, "required": [ "module", "version",