From 5e26e0196e4e1b60705e00de474e5017df0cec1b Mon Sep 17 00:00:00 2001 From: gaazzopa Date: Tue, 10 Nov 2020 16:32:34 +0100 Subject: [PATCH] Added mask option and fixed display in report --- cara/apps/calculator/model_generator.py | 9 +++++++-- cara/apps/calculator/static/js/form.js | 17 ++++++++++++----- .../templates/calculator.form.html.j2 | 18 ++++++++++++------ cara/apps/calculator/templates/report.html.j2 | 9 ++++++--- cara/models.py | 5 +++++ 5 files changed, 42 insertions(+), 16 deletions(-) diff --git a/cara/apps/calculator/model_generator.py b/cara/apps/calculator/model_generator.py index 2d65089b..a0acb095 100644 --- a/cara/apps/calculator/model_generator.py +++ b/cara/apps/calculator/model_generator.py @@ -27,6 +27,7 @@ class FormData: hepa_option: bool infected_people: int lunch_option: bool + mask_type: str mask_wearing: str mechanical_ventilation_type: str opening_distance: float @@ -58,6 +59,7 @@ class FormData: validation_tuples = [('activity_type', ACTIVITY_TYPES), ('event_type', EVENT_TYPES), ('mechanical_ventilation_type', MECHANICAL_VENTILATION_TYPES), + ('mask_type', MASK_TYPES), ('mask_wearing', MASK_WEARING), ('ventilation_type', VENTILATION_TYPES), ('volume_type', VOLUME_TYPES), @@ -94,6 +96,7 @@ class FormData: lunch_finish=time_string_to_minutes(form_data['lunch_finish']), lunch_option=(form_data['lunch_option'] == '1'), lunch_start=time_string_to_minutes(form_data['lunch_start']), + mask_type=form_data['mask_type'], mask_wearing=form_data['mask_wearing'], mechanical_ventilation_type=form_data['mechanical_ventilation_type'], opening_distance=float(form_data['opening_distance']), @@ -228,9 +231,9 @@ def model_from_form(form: FormData) -> models.Model: # Initializes the virus as SARS_Cov_2 virus = models.Virus.types['SARS_CoV_2'] - # Initializes a mask of type 1 if mask wearing is "continuous", otherwise instantiates the mask attribute as + # Initializes the mask type if mask wearing is "continuous", otherwise instantiates the mask attribute as # the "No mask"-mask - mask = models.Mask.types['Type I' if form.mask_wearing == "continuous" else 'No mask'] + mask = models.Mask.types[form.mask_type if form.mask_wearing == "continuous" else 'No mask'] # A dictionary containing the mapping of activities listed in the UI to the activity level and expiration level # of the infected and exposed occupants respectively. @@ -286,6 +289,7 @@ def baseline_raw_form_data(): 'lunch_finish': '13:30', 'lunch_option': '1', 'lunch_start': '12:30', + 'mask_type': 'type1', 'mask_wearing': 'removed', 'mechanical_ventilation_type': '', 'opening_distance': '0.2', @@ -307,6 +311,7 @@ def baseline_raw_form_data(): ACTIVITY_TYPES = {'office', 'training', 'workshop'} EVENT_TYPES = {'single_event', 'recurrent_event'} MECHANICAL_VENTILATION_TYPES = {'air_changes', 'air_supply', 'not-applicable'} +MASK_TYPES = {'Type I', 'FFP2'} MASK_WEARING = {'continuous', 'removed'} VENTILATION_TYPES = {'natural', 'mechanical', 'no-ventilation'} VOLUME_TYPES = {'room_volume', 'room_dimensions'} diff --git a/cara/apps/calculator/static/js/form.js b/cara/apps/calculator/static/js/form.js index 33106522..39625947 100644 --- a/cara/apps/calculator/static/js/form.js +++ b/cara/apps/calculator/static/js/form.js @@ -15,7 +15,6 @@ function on_ventilation_type_change() { }); } - function getChildElement(elem) { // Get the element named in the given element's data-enables attribute. return $("#" + elem.data("enables")); @@ -63,6 +62,12 @@ function require_fields(obj) { case "lunch_option_yes": require_lunch(true); break; + case "mask_on": + require_mask(true); + break; + case "mask_off": + require_mask(false); + break; default: break; } @@ -122,6 +127,11 @@ function require_recurrent_event(option) { function require_lunch(option) { $("#lunch_start").prop('required', option); + $("#mask_ffp2").prop('required', option); +} + +function require_lunch(option) { + $("#mask_type1").prop('required', option); $("#lunch_finish").prop('required', option); } @@ -136,7 +146,6 @@ $(function () { }); }); - function show_disclaimer() { var dots = document.getElementById("dots"); var moreText = document.getElementById("more"); @@ -203,8 +212,7 @@ function parseValToNumber(obj) { return parseInt(obj.val().replace(':',''), 10); } -/* ------ On Load ---------- */ - +/* -------On Load------- */ $(document).ready(function () { // When the document is ready, deal with the fact that we may be here // as a result of a forward/back browser action. If that is the case, update @@ -230,7 +238,6 @@ $(document).ready(function () { if (radioValue.val()) { require_fields(radioValue.get(0)); } - }); /* -------Debugging------- */ diff --git a/cara/apps/calculator/templates/calculator.form.html.j2 b/cara/apps/calculator/templates/calculator.form.html.j2 index d255f814..0fee0598 100644 --- a/cara/apps/calculator/templates/calculator.form.html.j2 +++ b/cara/apps/calculator/templates/calculator.form.html.j2 @@ -69,6 +69,15 @@ Beta v1.0.0 Please send feedback to
+ + Face masks:
+ Are masks worn when occupants are at workstations? + Yes + No
+ Type of masks used: + Type 1 + FFP2
+
@@ -79,6 +88,7 @@ Beta v1.0.0 Please send feedback to Total number of occupants:
Number of infected people:

+ Activity type:    Finish:
-
+ When is the event?
   @@ -116,6 +126,7 @@ Beta v1.0.0 Please send feedback to

+ Lunch break: @@ -147,13 +158,8 @@ Beta v1.0.0 Please send feedback to
Coffee breaks are spread evenly throughout the day. -

- Face masks:
- Are masks worn when occupants are at workstations?
- Yes - No
diff --git a/cara/apps/calculator/templates/report.html.j2 b/cara/apps/calculator/templates/report.html.j2 index aab7f3dc..f5f714cc 100644 --- a/cara/apps/calculator/templates/report.html.j2 +++ b/cara/apps/calculator/templates/report.html.j2 @@ -113,9 +113,12 @@

Mask wearing:

  • Masks worn at workstations? - {{ "No" if form.mask_wearing == "removed" else "Yes" }} -

  • -
  • Mask type: Type 1

  • + {% if form.mask_wearing == "continuous" %} + Yes

    +
  • Mask type: {{ form.mask_type }}

  • + {% else %} + No

    + {% endif %}

Results:

diff --git a/cara/models.py b/cara/models.py index 61a2182d..10ff25c8 100644 --- a/cara/models.py +++ b/cara/models.py @@ -338,6 +338,11 @@ Mask.types = { η_leaks=0.15, # (Huang 2007) η_inhale=0.3, # (Browen 2010) ), + 'FFP2': Mask( + η_exhale=0.95, # (same outward effect as type 1 - Asadi 2020) + η_leaks=0.15, # (same outward effect as type 1 - Asadi 2020) + η_inhale=0.865, # (94% penetration efficiency + 8% max inward leakage -> EN 149) + ), }