Skip to content

Commit

Permalink
Add Australian COVID Vaccination up-to-date and elibility and work ro…
Browse files Browse the repository at this point in the history
…le mandates.
  • Loading branch information
DavidPratten committed Jan 4, 2023
1 parent a5755ee commit 06cfab0
Show file tree
Hide file tree
Showing 8 changed files with 1,257 additions and 8 deletions.
243 changes: 243 additions & 0 deletions COVID_vaccinations.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,243 @@
{
"cells": [
{
"cell_type": "markdown",
"source": [
"# Australian COVID Vaccination eligibility and up-to-date (circa mid-2022)\n",
"This example explores the COVID vaccination eligibility and up-to-date regime in place in the middle of 2022.\n",
"\n",
"The relation (table) containing the rules has the following columns:\n",
"```\n",
" covid_vaccinations(age,\n",
" recommended_doses,\n",
" booster_doses,\n",
" vaccine_doses,\n",
" immunocompromised_disability,\n",
" months_since_last_dose_at_least,\n",
" covid_vaccination_eligibility,\n",
" covid_vaccination_up_to_date)\n",
"```\n",
"\n",
"Here are some examples:\n",
"\n",
"If a person's last COVID vaccination was 5 months ago, are 29, and have had four COVID Vaccinations. Are they up-to-date?"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": 30,
"outputs": [],
"source": [
"%reload_ext jetisu.query_idr_magic"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": 31,
"outputs": [
{
"data": {
"text/plain": "<IPython.core.display.Markdown object>",
"text/markdown": "|covid_vaccination_up_to_date|covid_vaccination_eligibility|\n|----|----|\n|True|False|"
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%%jetisu_query\n",
"select distinct covid_vaccination_up_to_date, covid_vaccination_eligibility from covid_vaccinations where months_since_last_dose_at_least = 5 and age=29 and vaccine_doses = 4;"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "markdown",
"source": [
"However, if the person's age was 70 then the answer is mixed, the query shows that the answer is maybe yes, maybe no."
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": 32,
"outputs": [
{
"data": {
"text/plain": "<IPython.core.display.Markdown object>",
"text/markdown": "|covid_vaccination_up_to_date|covid_vaccination_eligibility|\n|----|----|\n|False|True|\n|True|False|"
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%%jetisu_query\n",
"select distinct covid_vaccination_up_to_date, covid_vaccination_eligibility from covid_vaccinations where months_since_last_dose_at_least = 5 and age=70 and vaccine_doses = 4;"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "markdown",
"source": [
"If we show all the columns in the table, we can see which factor makes the difference the True/ False outcomes. The following table shows that it is ```immunocompromised_disability```, which lifts the ```recommended_doses``` to 3, which along with the ```booster_doses``` gives a total of 5 being recommended."
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": 33,
"outputs": [
{
"data": {
"text/plain": "<IPython.core.display.Markdown object>",
"text/markdown": "|age|recommended_doses|booster_doses|vaccine_doses|immunocompromised_disability|months_since_last_dose_at_least|covid_vaccination_eligibility|covid_vaccination_up_to_date|\n|----|----|----|----|----|----|----|----|\n|70.0|2|2|4.0|False|5.0|False|True|\n|70.0|3|2|4.0|True|5.0|True|False|"
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%%jetisu_query\n",
"select distinct * from covid_vaccinations where months_since_last_dose_at_least = 5 and age=70 and vaccine_doses = 4;"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "markdown",
"source": [
"So, now we can see that the 70 year old is not up-to-date if immunocompromised:"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": 34,
"outputs": [
{
"data": {
"text/plain": "<IPython.core.display.Markdown object>",
"text/markdown": "|covid_vaccination_up_to_date|covid_vaccination_eligibility|\n|----|----|\n|False|True|"
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%%jetisu_query\n",
"select distinct covid_vaccination_up_to_date, covid_vaccination_eligibility from covid_vaccinations where immunocompromised_disability and months_since_last_dose_at_least = 5 and age=70 and vaccine_doses = 4;"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "markdown",
"source": [
"And if the 70 year old had had their last dose, just 2 months ago, they would get a different response. The person is not up to date, and neither are they eligible!"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": 35,
"outputs": [
{
"data": {
"text/plain": "<IPython.core.display.Markdown object>",
"text/markdown": "|covid_vaccination_up_to_date|covid_vaccination_eligibility|\n|----|----|\n|False|False|"
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%%jetisu_query\n",
"select distinct covid_vaccination_up_to_date, covid_vaccination_eligibility from covid_vaccinations where immunocompromised_disability and months_since_last_dose_at_least = 2 and age=70 and vaccine_doses = 4;"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "markdown",
"source": [
"## Definition in MiniZinc"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": 36,
"outputs": [
{
"data": {
"text/plain": "<IPython.core.display.Markdown object>",
"text/markdown": "```\n\npredicate covid_vaccinations(var int: age,\n var int: recommended_doses,\n var int: booster_doses,\n var int: vaccine_doses,\n var bool: immunocompromised_disability,\n var int: months_since_last_dose_at_least,\n var bool: covid_vaccination_eligibility,\n var bool: covid_vaccination_up_to_date\n ) =\nlet {\n par int: highest_number_of_months_since_last_dose_that_we_care_about = 6;\n par int: highest_number_of_vaccine_doses_that_we_care_about = 5;\n\n constraint age >= 0 /\\ age <=115;\n constraint vaccine_doses >= 0 /\\ vaccine_doses <= highest_number_of_vaccine_doses_that_we_care_about;\n constraint vaccine_doses = 0 -> months_since_last_dose_at_least = highest_number_of_months_since_last_dose_that_we_care_about;\n constraint covid_vaccination_up_to_date -> not covid_vaccination_eligibility;\n constraint months_since_last_dose_at_least >= 0 /\\ months_since_last_dose_at_least <=highest_number_of_months_since_last_dose_that_we_care_about;\n constraint recommended_doses = if age < 5 then 0\n elseif age >= 5 /\\ age <= 11 then 2 + if immunocompromised_disability then 1 else 0 endif\n elseif age >= 12 /\\ age <= 15 then 2 + if immunocompromised_disability then 1 else 0 endif\n elseif age >= 16 /\\ age <= 29 then 2 + if immunocompromised_disability then 1 else 0 endif\n elseif age >= 30 /\\ age <= 49 then 2 + if immunocompromised_disability then 1 else 0 endif\n else 2 + if immunocompromised_disability then 1 else 0 endif\n endif;\nconstraint booster_doses = if age < 5 then 0\n elseif age >= 5 /\\ age <= 11 then 0\n elseif age >= 12 /\\ age <= 15 then 0\n elseif age >= 16 /\\ age <= 29 then 1\n elseif age >= 30 /\\ age <= 49 then 1\n else 2\n endif;\n\nconstraint covid_vaccination_eligibility = (months_since_last_dose_at_least >= 3 /\\ (recommended_doses+booster_doses > vaccine_doses));\nconstraint covid_vaccination_up_to_date = (recommended_doses + booster_doses <= vaccine_doses) /\\ ((recommended_doses + booster_doses > vaccine_doses) -> (months_since_last_dose_at_least <= 6));\n} in true;\n```"
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%%jetisu_show\n",
"covid_vaccinations"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "markdown",
"source": [
"## Test Cases\n",
"In addition to these examples, the ```covid_vaccinations``` intensionally defined relation passes an additional 66 tests in ```test_covid_vaccinations.py```"
],
"metadata": {
"collapsed": false
}
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Loading

0 comments on commit 06cfab0

Please sign in to comment.