Skip to content
This repository has been archived by the owner on Nov 24, 2021. It is now read-only.

api: Start to explore major changes we may need to make to the model input API. #53

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@covid-modeling/api",
"version": "0.10.0",
"version": "0.11.0",
"main": "dist/src/index",
"types": "dist/src/index.d.ts",
"scripts": {
Expand Down
130 changes: 106 additions & 24 deletions packages/api/schema/input.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,66 @@
"$ref": "#/definitions/ModelInput",
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"Actual": {
"additionalProperties": false,
"properties": {
"cases": {
"type": "number"
},
"cumulativeCases": {
"type": "number"
},
"cumulativeDeaths": {
"type": "number"
},
"date": {
"$ref": "#/definitions/ISODate"
},
"deaths": {
"type": "number"
},
"mobility": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is mobility just a single number? Or do we need something more complex than this?

"type": "number"
}
},
"required": [
"date",
"cases",
"cumulativeCases",
"deaths",
"cumulativeDeaths"
],
"type": "object"
},
"HistoricalData": {
"additionalProperties": false,
"properties": {
"actuals": {
"items": {
"$ref": "#/definitions/Actual"
},
"type": "array"
},
"endDate": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the last date for which we have data?

"$ref": "#/definitions/ISODate"
},
"totalCases": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is totalCases different from cumulativeCases? Could we just assume that endDate is the latest date in the actuals array?

"description": "The total number of confirmed cases in the region before the calibration date.",
"type": "number"
},
"totalDeaths": {
"description": "The total number of deaths in the region before the calibration date.",
"type": "number"
}
},
"required": [
"endDate",
"totalCases",
"totalDeaths",
"actuals"
],
"type": "object"
},
"ISODate": {
"type": "string"
},
Expand All @@ -13,40 +73,68 @@
],
"type": "string"
},
"InterventionPeriod": {
"Intervention": {
"additionalProperties": false,
"properties": {
"caseIsolation": {
"$ref": "#/definitions/Intensity",
"description": "The level to which individuals with symptoms self-isolate."
"intensity": {
"$ref": "#/definitions/Intensity"
},
"reductionPopulationContact": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A little confused how this will work if the reductionPopulationContact is associated with an intervention, rather than an interventionPeriod. Are we expecting that everything is additive?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or...I think this should just be removed...

"description": "The estimated reduction in population contact resulting from\nall of the above interventions. Some models require this generalized\nparameter instead of the individual interventions.",
"type": "number"
},
"schoolClosure": {
"$ref": "#/definitions/Intensity",
"description": "The level of school closure in the region."
"type": {
"$ref": "#/definitions/InterventionType"
}
},
"required": [
"type"
],
"type": "object"
},
"InterventionPeriod": {
"additionalProperties": false,
"properties": {
"endDate": {
"$ref": "#/definitions/ISODate"
},
"socialDistancing": {
"$ref": "#/definitions/Intensity",
"description": "The level of social distancing in the region."
"inteventions": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"inteventions": {
"interventions": {

"items": {
"$ref": "#/definitions/Intervention"
},
"type": "array"
},
"reductionPopulationContact": {
"description": "The estimated reduction in population contact resulting from\nall of the above interventions. Some models require this generalized\nparameter instead of the individual interventions.",
"type": "number"
},
"startDate": {
"$ref": "#/definitions/ISODate",
"description": "An ISO-8601 string encoding the date that these interventions begin."
},
"voluntaryHomeQuarantine": {
"$ref": "#/definitions/Intensity",
"description": "The level to which entire households self-isolate when one member\nof the household has symptoms."
}
},
"required": [
"startDate",
"endDate",
"inteventions",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"inteventions",
"interventions",

"reductionPopulationContact"
],
"type": "object"
},
"InterventionType": {
"enum": [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use text instead of numbers here?

0,
1,
2,
3,
4,
5,
6,
7,
8,
9
],
"type": "number"
},
"ModelInput": {
"additionalProperties": false,
"description": "A generalized description of the input to an epidemiological model.",
Expand All @@ -70,18 +158,13 @@
"ModelParameters": {
"additionalProperties": false,
"properties": {
"calibrationCaseCount": {
"description": "The total number of confirmed cases in the region before the calibration date.",
"type": "number"
"calibrationData": {
"$ref": "#/definitions/HistoricalData"
},
"calibrationDate": {
"$ref": "#/definitions/ISODate",
"description": "An ISO-8601 string encoding the date of the most recent case data in the region."
},
"calibrationDeathCount": {
"description": "The total number of deaths in the region before the calibration date.",
"type": "number"
},
"interventionPeriods": {
"description": "A list of time periods, each with a different set of interventions.",
"items": {
Expand All @@ -99,8 +182,7 @@
},
"required": [
"calibrationDate",
"calibrationCaseCount",
"calibrationDeathCount",
"calibrationData",
"r0",
"interventionPeriods"
],
Expand Down
130 changes: 106 additions & 24 deletions packages/api/schema/output.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,66 @@
"$ref": "#/definitions/ModelOutput",
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"Actual": {
"additionalProperties": false,
"properties": {
"cases": {
"type": "number"
},
"cumulativeCases": {
"type": "number"
},
"cumulativeDeaths": {
"type": "number"
},
"date": {
"$ref": "#/definitions/ISODate"
},
"deaths": {
"type": "number"
},
"mobility": {
"type": "number"
}
},
"required": [
"date",
"cases",
"cumulativeCases",
"deaths",
"cumulativeDeaths"
],
"type": "object"
},
"HistoricalData": {
"additionalProperties": false,
"properties": {
"actuals": {
"items": {
"$ref": "#/definitions/Actual"
},
"type": "array"
},
"endDate": {
"$ref": "#/definitions/ISODate"
},
"totalCases": {
"description": "The total number of confirmed cases in the region before the calibration date.",
"type": "number"
},
"totalDeaths": {
"description": "The total number of deaths in the region before the calibration date.",
"type": "number"
}
},
"required": [
"endDate",
"totalCases",
"totalDeaths",
"actuals"
],
"type": "object"
},
"ISODate": {
"type": "string"
},
Expand All @@ -13,40 +73,68 @@
],
"type": "string"
},
"InterventionPeriod": {
"Intervention": {
"additionalProperties": false,
"properties": {
"caseIsolation": {
"$ref": "#/definitions/Intensity",
"description": "The level to which individuals with symptoms self-isolate."
"intensity": {
"$ref": "#/definitions/Intensity"
},
"reductionPopulationContact": {
"description": "The estimated reduction in population contact resulting from\nall of the above interventions. Some models require this generalized\nparameter instead of the individual interventions.",
"type": "number"
},
"schoolClosure": {
"$ref": "#/definitions/Intensity",
"description": "The level of school closure in the region."
"type": {
"$ref": "#/definitions/InterventionType"
}
},
"required": [
"type"
],
"type": "object"
},
"InterventionPeriod": {
"additionalProperties": false,
"properties": {
"endDate": {
"$ref": "#/definitions/ISODate"
},
"socialDistancing": {
"$ref": "#/definitions/Intensity",
"description": "The level of social distancing in the region."
"inteventions": {
"items": {
"$ref": "#/definitions/Intervention"
},
"type": "array"
},
"reductionPopulationContact": {
"description": "The estimated reduction in population contact resulting from\nall of the above interventions. Some models require this generalized\nparameter instead of the individual interventions.",
"type": "number"
},
"startDate": {
"$ref": "#/definitions/ISODate",
"description": "An ISO-8601 string encoding the date that these interventions begin."
},
"voluntaryHomeQuarantine": {
"$ref": "#/definitions/Intensity",
"description": "The level to which entire households self-isolate when one member\nof the household has symptoms."
}
},
"required": [
"startDate",
"endDate",
"inteventions",
"reductionPopulationContact"
],
"type": "object"
},
"InterventionType": {
"enum": [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9
],
"type": "number"
},
"ModelInput": {
"additionalProperties": false,
"description": "A generalized description of the input to an epidemiological model.",
Expand Down Expand Up @@ -132,18 +220,13 @@
"ModelParameters": {
"additionalProperties": false,
"properties": {
"calibrationCaseCount": {
"description": "The total number of confirmed cases in the region before the calibration date.",
"type": "number"
"calibrationData": {
"$ref": "#/definitions/HistoricalData"
},
"calibrationDate": {
"$ref": "#/definitions/ISODate",
"description": "An ISO-8601 string encoding the date of the most recent case data in the region."
},
"calibrationDeathCount": {
"description": "The total number of deaths in the region before the calibration date.",
"type": "number"
},
"interventionPeriods": {
"description": "A list of time periods, each with a different set of interventions.",
"items": {
Expand All @@ -161,8 +244,7 @@
},
"required": [
"calibrationDate",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we remove this too, since calibrationData has a sequence of dates? Then models can choose the relevant date to calibrate against.

"calibrationCaseCount",
"calibrationDeathCount",
"calibrationData",
"r0",
"interventionPeriods"
],
Expand Down
Loading