Add interface to configure the minimal durations of the simple alert profile.
This commit is contained in:
parent
aa69741650
commit
2b93e04ccd
|
@ -57,6 +57,22 @@ class SimpleAlertProfileForm(forms.ModelForm):
|
|||
t_min_dangerous = forms.DecimalField(
|
||||
label=_(u'Minimum dangerous temperature'),
|
||||
max_digits=5, decimal_places=2, localize=True,required=False)
|
||||
duration_hr_max_critical = forms.IntegerField(
|
||||
label=_(u'Minimal duration'), required=False)
|
||||
duration_hr_min_critical = forms.IntegerField(
|
||||
label=_(u'Minimal duration'), required=False)
|
||||
duration_hr_max_dangerous = forms.IntegerField(
|
||||
label=_(u'Minimal duration'), required=False)
|
||||
duration_hr_min_dangerous = forms.IntegerField(
|
||||
label=_(u'Minimal duration'), required=False)
|
||||
duration_t_max_critical = forms.DecimalField(
|
||||
label=_(u'Minimal duration'), required=False)
|
||||
duration_t_min_critical = forms.DecimalField(
|
||||
label=_(u'Minimal duration'), required=False)
|
||||
duration_t_max_dangerous = forms.DecimalField(
|
||||
label=_(u'Minimal duration'), required=False)
|
||||
duration_t_min_dangerous = forms.DecimalField(
|
||||
label=_(u'Minimal duration'), required=False)
|
||||
|
||||
class Meta:
|
||||
model = models.Patient
|
||||
|
|
|
@ -100,11 +100,14 @@ class Watcher:
|
|||
duration = self.default_episode_duration
|
||||
data_needed_count = self.data_needed_count
|
||||
if len(definition) > 4:
|
||||
duration = int(definition[4])
|
||||
data_needed_count = \
|
||||
(duration / self.reception_period) * self.data_needed_rate
|
||||
if data_needed_count < 2:
|
||||
data_needed_count = 2
|
||||
try:
|
||||
duration = int(definition[4])
|
||||
data_needed_count = \
|
||||
(duration / self.reception_period) * self.data_needed_rate
|
||||
if data_needed_count < 2:
|
||||
data_needed_count = 2
|
||||
except:
|
||||
pass
|
||||
backend = whisper_backend.WhisperBackend(str(patient_id),
|
||||
settings.SENSOR_MAPPING[definition[1]])
|
||||
data = backend.get_timestamped_data(duration + self.reception_period, None)
|
||||
|
@ -157,17 +160,21 @@ class Watcher:
|
|||
if sap:
|
||||
for k in settings.SENSOR_MAPPING:
|
||||
value = sap.get(k.lower() + '_max_critical', None)
|
||||
duration = sap.get('duration_' + k.lower() + '_max_critical', None)
|
||||
if value:
|
||||
l.append(('CRITICAL', k, '>', value))
|
||||
l.append(('CRITICAL', k, '>', value, duration))
|
||||
value = sap.get(k.lower() + '_min_critical', None)
|
||||
duration = sap.get('duration_' + k.lower() + '_min_critical', None)
|
||||
if value:
|
||||
l.append(('CRITICAL', k, '<', value))
|
||||
l.append(('CRITICAL', k, '<', value, duration))
|
||||
value = sap.get(k.lower() + '_max_dangerous', None)
|
||||
duration = sap.get('duration_' + k.lower() + '_max_dangerous', None)
|
||||
if value:
|
||||
l.append(('DANGEROUS', k, '>', value))
|
||||
l.append(('DANGEROUS', k, '>', value, duration))
|
||||
value = sap.get(k.lower() + '_min_dangerous', None)
|
||||
duration = sap.get('duration_' + k.lower() + '_min_dangerous', None)
|
||||
if value:
|
||||
l.append(('DANGEROUS', k, '<', value))
|
||||
l.append(('DANGEROUS', k, '<', value, duration))
|
||||
return l
|
||||
|
||||
def simple_episode_watcher(self):
|
||||
|
|
|
@ -828,7 +828,7 @@ color: purple;
|
|||
div.sap-metric {
|
||||
color: #FFF;
|
||||
border-color: rgba(255, 255, 255, 0.12);
|
||||
width: 370px;
|
||||
width: 456px;
|
||||
font-size: 13px;
|
||||
background: none repeat scroll 0% 0% rgba(255, 255, 255, 0.1);
|
||||
border-radius: 3px;
|
||||
|
@ -839,23 +839,40 @@ padding: 12px 24px;
|
|||
margin: 20px;
|
||||
}
|
||||
|
||||
div.sap-metric div{
|
||||
display:inline-block;
|
||||
}
|
||||
|
||||
div.sap-metric div.title{
|
||||
display:block;
|
||||
}
|
||||
|
||||
|
||||
div.sap-metric div label {
|
||||
font-weight: 600;
|
||||
display:block;
|
||||
}
|
||||
|
||||
div.sap-metric div input{
|
||||
color: #FFF;
|
||||
border-color: rgba(255, 255, 255, 0.12);
|
||||
width: 346px;
|
||||
width: 280px;
|
||||
font-size: 13px;
|
||||
height: 32px;
|
||||
background: none repeat scroll 0% 0% rgba(255, 255, 255, 0.1);
|
||||
font-weight: 400;
|
||||
border-radius: 3px;
|
||||
vertical-align: middle;
|
||||
display:inline-block;
|
||||
box-shadow: none;
|
||||
padding: 6px 12px;
|
||||
margin-bottom: 10px;
|
||||
transition: border-color 0.15s ease-in-out 0s, box-shadow 0.15s ease-in-out 0s;
|
||||
}
|
||||
|
||||
div.sap-metric div:nth-child(odd) input{
|
||||
width: 120px;
|
||||
}
|
||||
|
||||
div.sap-metric div.critical input{
|
||||
border: 1px solid red;
|
||||
}
|
||||
|
@ -869,10 +886,6 @@ border: 1px solid white;
|
|||
box-shadow: 0px 1px rgba(255, 255, 255, 0.1) inset, -1px 0px rgba(0, 0, 0, 0.1) inset, 1px 0px rgba(0, 0, 0, 0.1) inset, 0px -1px rgba(0, 0, 0, 0.6) inset;
|
||||
}
|
||||
|
||||
div.sap-metric div label {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
div.sap-metric input[type=submit]{
|
||||
border: none;
|
||||
background: #0972a5;
|
||||
|
|
|
@ -119,51 +119,91 @@
|
|||
<form action="" method="post" id="patient-alert-profile-form">{% csrf_token %}
|
||||
{{ forms.simple_alert_profile.non_field_errors }}
|
||||
<div class="sap-metric">
|
||||
<i class="fa fa-heart"></i> {% trans "Heartrate" %}
|
||||
<div class="title"><i class="fa fa-heart"></i> {% trans "Heartrate" %}</div>
|
||||
<div class="critical">
|
||||
{{ forms.simple_alert_profile.hr_max_critical.errors }}
|
||||
{{ forms.simple_alert_profile.hr_max_critical.label_tag }}
|
||||
{{ forms.simple_alert_profile.hr_max_critical }}
|
||||
</div>
|
||||
<div class="critical">
|
||||
{{ forms.simple_alert_profile.duration_hr_max_critical.errors }}
|
||||
{{ forms.simple_alert_profile.duration_hr_max_critical.label_tag }}
|
||||
{{ forms.simple_alert_profile.duration_hr_max_critical }}
|
||||
</div>
|
||||
<div class="critical">
|
||||
{{ forms.simple_alert_profile.hr_min_critical.errors }}
|
||||
{{ forms.simple_alert_profile.hr_min_critical.label_tag }}
|
||||
{{ forms.simple_alert_profile.hr_min_critical }}
|
||||
</div>
|
||||
<div class="critical">
|
||||
{{ forms.simple_alert_profile.duration_hr_min_critical.errors }}
|
||||
{{ forms.simple_alert_profile.duration_hr_min_critical.label_tag }}
|
||||
{{ forms.simple_alert_profile.duration_hr_min_critical }}
|
||||
</div>
|
||||
<div class="dangerous">
|
||||
{{ forms.simple_alert_profile.hr_max_dangerous.errors }}
|
||||
{{ forms.simple_alert_profile.hr_max_dangerous.label_tag }}
|
||||
{{ forms.simple_alert_profile.hr_max_dangerous }}
|
||||
</div>
|
||||
<div class="dangerous">
|
||||
{{ forms.simple_alert_profile.duration_hr_max_dangerous.errors }}
|
||||
{{ forms.simple_alert_profile.duration_hr_max_dangerous.label_tag }}
|
||||
{{ forms.simple_alert_profile.duration_hr_max_dangerous }}
|
||||
</div>
|
||||
<div class="dangerous">
|
||||
{{ forms.simple_alert_profile.hr_min_dangerous.errors }}
|
||||
{{ forms.simple_alert_profile.hr_min_dangerous.label_tag }}
|
||||
{{ forms.simple_alert_profile.hr_min_dangerous }}
|
||||
</div>
|
||||
<div class="dangerous">
|
||||
{{ forms.simple_alert_profile.duration_hr_min_dangerous.errors }}
|
||||
{{ forms.simple_alert_profile.duration_hr_min_dangerous.label_tag }}
|
||||
{{ forms.simple_alert_profile.duration_hr_min_dangerous }}
|
||||
</div>
|
||||
<input type="submit" value="{% trans "Validate" %}"/>
|
||||
</div>
|
||||
<div class="sap-metric">
|
||||
<i class="wi wi-thermometer-exterior"></i> {% trans "Temperature" %}
|
||||
<div class="title"><i class="wi wi-thermometer-exterior"></i> {% trans "Temperature" %}</div>
|
||||
<div class="critical">
|
||||
{{ forms.simple_alert_profile.t_max_critical.errors }}
|
||||
{{ forms.simple_alert_profile.t_max_critical.label_tag }}
|
||||
{{ forms.simple_alert_profile.t_max_critical }}
|
||||
</div>
|
||||
<div class="critical">
|
||||
{{ forms.simple_alert_profile.duration_t_max_critical.errors }}
|
||||
{{ forms.simple_alert_profile.duration_t_max_critical.label_tag }}
|
||||
{{ forms.simple_alert_profile.duration_t_max_critical }}
|
||||
</div>
|
||||
<div class="critical">
|
||||
{{ forms.simple_alert_profile.t_min_critical.errors }}
|
||||
{{ forms.simple_alert_profile.t_min_critical.label_tag }}
|
||||
{{ forms.simple_alert_profile.t_min_critical }}
|
||||
</div>
|
||||
<div class="critical">
|
||||
{{ forms.simple_alert_profile.duration_t_min_critical.errors }}
|
||||
{{ forms.simple_alert_profile.duration_t_min_critical.label_tag }}
|
||||
{{ forms.simple_alert_profile.duration_t_min_critical }}
|
||||
</div>
|
||||
<div class="dangerous">
|
||||
{{ forms.simple_alert_profile.t_max_dangerous.errors }}
|
||||
{{ forms.simple_alert_profile.t_max_dangerous.label_tag }}
|
||||
{{ forms.simple_alert_profile.t_max_dangerous }}
|
||||
</div>
|
||||
<div class="dangerous">
|
||||
{{ forms.simple_alert_profile.duration_t_max_dangerous.errors }}
|
||||
{{ forms.simple_alert_profile.duration_t_max_dangerous.label_tag }}
|
||||
{{ forms.simple_alert_profile.duration_t_max_dangerous }}
|
||||
</div>
|
||||
<div class="dangerous">
|
||||
{{ forms.simple_alert_profile.t_min_dangerous.errors }}
|
||||
{{ forms.simple_alert_profile.t_min_dangerous.label_tag }}
|
||||
{{ forms.simple_alert_profile.t_min_dangerous }}
|
||||
</div>
|
||||
<div class="dangerous">
|
||||
{{ forms.simple_alert_profile.duration_t_min_dangerous.errors }}
|
||||
{{ forms.simple_alert_profile.duration_t_min_dangerous.label_tag }}
|
||||
{{ forms.simple_alert_profile.duration_t_min_dangerous }}
|
||||
</div>
|
||||
<input type="submit" value="{% trans "Validate" %}"/>
|
||||
</div>
|
||||
{% if display_alert_profile %}<div class="sap-metric">
|
||||
|
|
Reference in New Issue