Logic to include CERN Covid Scale warnings implementation fix #173
This commit is contained in:
parent
d11e511d64
commit
1e3e7f86cd
3 changed files with 58 additions and 2 deletions
|
|
@ -276,6 +276,29 @@ def comparison_report(scenarios: typing.Dict[str, models.ExposureModel]):
|
|||
'stats': statistics,
|
||||
}
|
||||
|
||||
def get_level_warning(scale_warning, incidence_rate, onsite_access, threshold) -> dict:
|
||||
if scale_warning == 'Green - 1':
|
||||
scale_level = {
|
||||
'level': 1,
|
||||
'display_text': f'Note: the current CERN COVID Scale is <b>Green - 1</b>, which means the incidence rate in the local community is <b>{incidence_rate}</b>. Align your risk assessment with the guidance and instructions provided by the HSE Unit.'
|
||||
}
|
||||
elif scale_warning == 'Yellow - 2':
|
||||
scale_level = {
|
||||
'level': 2,
|
||||
'display_text': f'Note: the current CERN COVID Scale is <b>Yellow - 2</b>, which means the incidence rate in the local community is <b>{incidence_rate}</b>. There is a reduced chance that asymptomatic or pre-symptomatic infected individuals circulate within the CERN site which, during this stage, corresponds to an average daily on-site access <b>{onsite_access}</b>. See with your supervisor if this scenario is acceptable.'
|
||||
}
|
||||
elif scale_warning == 'Orange - 3':
|
||||
scale_level = {
|
||||
'level': 3,
|
||||
'display_text': f'Warning: the current CERN COVID Scale is <b>Orange - 3</b>, which means the incidence rate in the local community is <b>{incidence_rate}</b>. There is a slight chance that asymptomatic or pre-symptomatic infected individuals circulate within the CERN site which, during this stage, corresponds to an average daily on-site access <b>{onsite_access}</b>. See with your supervisor if any additional measures can be applied (ALARA).'
|
||||
}
|
||||
elif scale_warning == 'Red - 4':
|
||||
scale_level = {
|
||||
'level': 4,
|
||||
'display_text': f'Warning: the current CERN COVID Scale is <b>Red - 4</b>, which means the incidence rate in the local community is <b>{incidence_rate}</b>. There is a strong chance that asymptomatic or pre-symptomatic infected individuals circulate within the CERN site which, during this stage, corresponds to an average daily on-site access <b>{onsite_access}</b>. Please reduce the value below the threshold of <b>{threshold}</b>.'
|
||||
}
|
||||
return scale_level
|
||||
|
||||
|
||||
@dataclasses.dataclass
|
||||
class ReportGenerator:
|
||||
|
|
@ -291,10 +314,35 @@ class ReportGenerator:
|
|||
now = datetime.utcnow().astimezone()
|
||||
time = now.strftime("%Y-%m-%d %H:%M:%S UTC")
|
||||
|
||||
#Specify here the CERN COVID Scale, as well as its incidence_rate, on-site access and threshold
|
||||
'''
|
||||
Green - 1:
|
||||
covid_scale = 'Green - 1'
|
||||
incidence_rate = 'considered negligible'
|
||||
onsite_access = ''
|
||||
threshold = ''
|
||||
Yellow - 2:
|
||||
covid_scale = 'Yellow - 2'
|
||||
incidence_rate = 'lower than 25 new cases per 100 000 inhabitants'
|
||||
onsite_access = 'of about 8000'
|
||||
threshold = NA
|
||||
Orange - 3:
|
||||
covid_scale = 'Orange - 3'
|
||||
incidence_rate = 'somewhere in between 25 and 100 new cases per 100 000 inhabitants'
|
||||
onsite_access = 'of about 5000'
|
||||
threshold = ''
|
||||
Red - 4:
|
||||
covid_scale = 'Red - 4'
|
||||
incidence_rate = 'higher or equal to 100 new cases per 100 000 inhabitants'
|
||||
onsite_access = 'lower than 4000'
|
||||
threshold = '5%'
|
||||
'''
|
||||
scale_warning = get_level_warning(scale_warning = 'Green - 1', incidence_rate = 'higher or equal to 100 new cases per 100 000 inhabitants', onsite_access = 'lower than 4000', threshold = '')
|
||||
|
||||
context = {
|
||||
'model': model,
|
||||
'form': form,
|
||||
'creation_date': time,
|
||||
'creation_date': time
|
||||
}
|
||||
|
||||
context.update(calculate_report_data(model))
|
||||
|
|
@ -302,6 +350,7 @@ class ReportGenerator:
|
|||
context['alternative_scenarios'] = comparison_report(alternative_scenarios)
|
||||
context['qr_code'] = generate_qr_code(base_url, self.calculator_prefix, form)
|
||||
context['calculator_prefix'] = self.calculator_prefix
|
||||
context['scale_warning'] = scale_warning
|
||||
return context
|
||||
|
||||
def _template_environment(self) -> jinja2.Environment:
|
||||
|
|
|
|||
|
|
@ -67,4 +67,4 @@ p.notes {
|
|||
color: #000000;
|
||||
background-color: #90EE90;
|
||||
text-decoration: none;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -212,6 +212,13 @@
|
|||
<p class="data_text">
|
||||
{% block report_summary %}
|
||||
Taking into account the uncertainties tied to the model variables, in this scenario, the <b>probability of one exposed occupant getting infected is {{ prob_inf | non_zero_percentage }}</b><a href="#section1">[*]</a> and the <b>expected number of new cases is {{ expected_new_cases | float_format }}</b>.
|
||||
|
||||
{% if (prob_inf > 5) %}
|
||||
<div class="alert alert-dark" role="alert" style="width: 50%">
|
||||
{{scale_warning.display_text}}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<p id="section1">[*] The results are based on the parameters and assumptions published in the CERN Open Report <a href="https://cds.cern.ch/record/2756083"> CERN-OPEN-2021-004</a></p>
|
||||
{% endblock report_summary %}
|
||||
</p>
|
||||
|
|
|
|||
Loading…
Reference in a new issue