agenda/dossier: display on appointments when a participant is missing (fixes #2039).
This commit is contained in:
parent
c5f8a9198c
commit
e6b125bd62
|
@ -70,8 +70,10 @@ class Appointment(object):
|
|||
self.description = event.description
|
||||
self.workers_initial = ""
|
||||
self.workers_code = []
|
||||
self.workers = event.participants.all()
|
||||
self.len_workers = event.participants.count()
|
||||
self.workers_absent = event.get_missing_participants()
|
||||
if event.event_type.id == 1:
|
||||
self.workers = event.participants.all()
|
||||
self.convocation_sent = event.convocation_sent
|
||||
self.patient = event.patient
|
||||
self.patient_record_id = event.patient.id
|
||||
|
@ -96,12 +98,6 @@ class Appointment(object):
|
|||
if event.title:
|
||||
self.title += ' - %s' % event.title
|
||||
self.event_type = event.event_type
|
||||
self.workers = event.participants.all()
|
||||
if len(self.workers) > 4 :
|
||||
self.workers_initial = '%d inter.' % len(self.workers)
|
||||
else:
|
||||
for worker in self.workers:
|
||||
self.workers_initial += " " + worker.worker.initials
|
||||
for worker in self.workers:
|
||||
self.workers_code.append("%s-%s" % (worker.id, worker.last_name.upper()))
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ from django import forms
|
|||
|
||||
from calebasse.agenda import managers
|
||||
from calebasse.utils import weeks_since_epoch, weekday_ranks
|
||||
from calebasse.personnes.models import Holiday
|
||||
from interval import Interval
|
||||
|
||||
__all__ = (
|
||||
|
@ -384,6 +385,17 @@ class Event(models.Model):
|
|||
def is_event_absence(self):
|
||||
return False
|
||||
|
||||
def get_missing_participants(self):
|
||||
missing_participants = []
|
||||
for participant in self.participants.all():
|
||||
holidays = None
|
||||
worker = participant.worker
|
||||
holidays = Holiday.objects.for_worker(worker) \
|
||||
.for_timed_period(self.start_datetime.date(), self.start_datetime.time(), self.end_datetime.time())
|
||||
if holidays:
|
||||
missing_participants.append(participant)
|
||||
return missing_participants
|
||||
|
||||
RECURRENCE_DESCRIPTION = [
|
||||
u'Tous les %s', #(1, None, None),
|
||||
u'Un %s sur deux', #(2, None, None),
|
||||
|
@ -426,10 +438,6 @@ class Event(models.Model):
|
|||
parts.append(self.recurrence_end_date.strftime('%d/%m/%Y'))
|
||||
return u' '.join(parts)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def __unicode__(self):
|
||||
return self.title
|
||||
|
||||
|
|
|
@ -9,10 +9,27 @@
|
|||
<span class="length">{% if appointment.length %}{% if appointment.length|str_length_lt:3 %} {% endif %}{{ appointment.length }} mn{% endif %}</span>
|
||||
<span class="title">{% if appointment.title %}{{ appointment.title }}{% endif %}
|
||||
{% if appointment.patient.paper_id %} {{ appointment.patient.paper_id }} {% endif %}</span>
|
||||
<span class="participants">{% if appointment.workers_initial %}{{ appointment.workers_initial }}{% endif %}</span>
|
||||
<span class="participants">
|
||||
{% if appointment.len_workers > 4 %}
|
||||
{% if appointment.workers_absent %}<span class="absent" title="Au moins un intervenant est absent">{% endif %}
|
||||
{{ appointment.len_workers }} inter.
|
||||
{% if appointment.workers_absent %}</span>{% endif %}
|
||||
{% else %}
|
||||
{% if appointment.workers %}
|
||||
{% for worker in appointment.workers %}
|
||||
{% if worker in appointment.workers_absent %}<span class="absent" title="Absent">{% endif %}
|
||||
{{ worker.worker.initials }}{% if not forloop.last %} {% endif %}
|
||||
{% if worker in appointment.workers_absent %}</span>{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</span>
|
||||
<span class="act_type">{% if appointment.act_type %}{{ appointment.act_type|trunc_act_type }}{% endif %}</span>
|
||||
<span class="room">{% if appointment.room %}{{ appointment.room }}{% endif %}</span>
|
||||
<span class="right">
|
||||
{% if appointment.workers_absent %}
|
||||
<span title="Au moins un intervenant est absent" class="icon-warning-sign absent"></span>
|
||||
{% endif %}
|
||||
{% for service_name in appointment.other_services_names %}
|
||||
<span class="box {{ service_name }}" title="{{ service_name }}"></span>
|
||||
{% endfor %}
|
||||
|
@ -53,7 +70,9 @@
|
|||
<p class="workers">
|
||||
Intervenants :
|
||||
{% for worker in appointment.workers %}
|
||||
{% if worker in appointment.workers_absent %}<span class="absent" title="Absent">{% endif %}
|
||||
{{ worker.first_name }} <span class="lastname">{{ worker.last_name }}</span>{% if forloop.last %}.{% else %}, {% endif %}
|
||||
{% if worker in appointment.workers_absent %}</span>{% endif %}
|
||||
{% endfor %}
|
||||
</p>
|
||||
{% endif %}
|
||||
|
|
|
@ -24,15 +24,19 @@
|
|||
{% if forloop.counter != 1 %}
|
||||
<tr>
|
||||
{% endif %}
|
||||
<td {% if appointment.type == 2 %}colspan="2"{% endif %}>{{ appointment.label }}{% if appointment.paper_id %} - {{ appointment.paper_id }} {% endif %}</td>
|
||||
<td {% if appointment.type == 2 %}colspan="2"{% endif %}>{{ appointment.label }}{% if appointment.paper_id %} - {{ appointment.paper_id }} {% endif %}{% if appointment.workers_absent %} <span title="Au moins un intervenant est absent" class="icon-warning-sign absent"></span>{% endif %}</td>
|
||||
<td>{% if appointment.absent %}{{ appointment.state }}{% endif %}</td>
|
||||
{% if appointment.type != 2 %}<td>{{ appointment.act }}</td>{% endif %}
|
||||
<td>
|
||||
{% if appointment.len_participants > 10 %}
|
||||
{{ appointment.len_participants }} intervenants
|
||||
{% if appointment.workers_absent %}<span class="absent" title="Absents : {% for participant in appointment.workers_absent %}{{ participant.last_name }} {{ participant.first_name }} {% endfor %}">{% endif %}
|
||||
{{ appointment.len_participants }} intervenants
|
||||
{% if appointment.workers_absent %}</span>{% endif %}
|
||||
{% else %}
|
||||
{% for participant in appointment.participants %}
|
||||
{% if participant in appointment.workers_absent %}<span class="absent" title="Absent">{% endif %}
|
||||
<span class="lastname">{{ participant.last_name }}</span> {{ participant.first_name }}<br/>
|
||||
{% if participant in appointment.workers_absent %}</span>{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</td>
|
||||
|
|
|
@ -116,6 +116,7 @@ class AgendaServiceActivityView(TemplateView):
|
|||
event.title)
|
||||
appointment['participants'] = event.participants.filter(worker__enabled=True)
|
||||
appointment['len_participants'] = len(appointment['participants'])
|
||||
appointment['workers_absent'] = event.get_missing_participants()
|
||||
appointments_times[start_datetime]['row'] += 1
|
||||
appointments_times[start_datetime]['appointments'].append(appointment)
|
||||
context['appointments_times'] = sorted(appointments_times.items())
|
||||
|
@ -566,6 +567,7 @@ class AjaxWorkerTabView(TemplateView):
|
|||
context['worker_agenda'] = {'worker': worker,
|
||||
'appointments': get_daily_appointments(context['date'], worker, self.service,
|
||||
time_tables_worker, events, holidays_worker)}
|
||||
|
||||
if settings.RTF_TEMPLATES_DIRECTORY:
|
||||
context['mail'] = True
|
||||
return context
|
||||
|
|
|
@ -487,13 +487,15 @@ $('.messages').delay(1000*(1+{{ messages|length }})).fadeOut('slow');
|
|||
<tr> <th>Date</th> <th>Pointage</th> <th>Type d'acte</th> <th>Intervenants</th> <th>Commentaire</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for act, state in last_rdvs %}
|
||||
{% for act, state, missing_workers in last_rdvs %}
|
||||
<tr>
|
||||
<td>{{ act.date|date:"SHORT_DATE_FORMAT" }} {{ act.time|date:"H:i" }}</td>
|
||||
<td>{{ act.date|date:"SHORT_DATE_FORMAT" }} {{ act.time|date:"H:i" }}{% if missing_workers %} <span title="Au moins un intervenant est absent" class="icon-warning-sign absent"></span>{% endif %}</td>
|
||||
<td>{% if state %}{% if act.is_absent %}<strong>{% endif %}{{ state }}{% if act.is_absent %}</strong>{% endif %}{% else %}Non pointé.{% endif %}</td>
|
||||
<td>{{ act.act_type }}</td>
|
||||
<td class="width-limited">{% for doctor in act.doctors.all %}
|
||||
{% if doctor in missing_workers %}<span class="absent" title="Absent">{% endif %}
|
||||
{{ doctor.first_name }} <span class="lastname">{{ doctor.last_name }}</span>
|
||||
{% if doctor in missing_workers %}</span>{% endif %}
|
||||
{% endfor %}</td>
|
||||
<td class="width-limited">{% if act.comment %}{{ act.comment }}{% endif %}</td>
|
||||
</tr>
|
||||
|
@ -511,14 +513,16 @@ $('.messages').delay(1000*(1+{{ messages|length }})).fadeOut('slow');
|
|||
<tr> <th>Date</th> <th>Pointage</th> <th>Type d'acte</th> <th>Intervenants</th> <th>Commentaire</th> </tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for event, state in next_rdvs %}
|
||||
{% for event, state, missing_participants in next_rdvs %}
|
||||
<tr>
|
||||
<td>{% firstof event.start_datetime|date:"l d/m/y H:i"|title %}</td>
|
||||
<td>{% firstof event.start_datetime|date:"l d/m/y H:i"|title %}{% if missing_participants %} <span title="Au moins un intervenant est absent" class="icon-warning-sign absent"></span>{% endif %}</td>
|
||||
<td>{% if state %}{% if state.state_name != 'VALIDE' %}<strong>{% endif %}{{ state }}{% if state.state_name != 'VALIDE' %}</strong>{% endif %}{% else %}Non pointé.{% endif %}</td>
|
||||
<td>{{ event.act_type }}</td>
|
||||
<td class="width-limited">{% for doctor in event.participants.all %}
|
||||
{{ doctor.first_name }} <span class="lastname">{{ doctor.last_name }}</span>
|
||||
{% endfor %}</td>
|
||||
<td class="width-limited">{% for participant in event.participants.all %}
|
||||
{% if participant in missing_participants %}<span class="absent" title="Absent">{% endif %}
|
||||
{{ participant.first_name }} <span class="lastname">{{ participant.last_name }}</span>
|
||||
{% if participant in missing_participants %}</span>{% endif %}
|
||||
{% endfor %}</td>
|
||||
<td class="width-limited">{{ event.description }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
|
|
@ -307,7 +307,7 @@ class PatientRecordView(cbv.ServiceViewMixin, cbv.MultiUpdateView):
|
|||
state = event.act.get_state()
|
||||
if state and not state.previous_state and state.state_name == 'NON_VALIDE':
|
||||
state = None
|
||||
ctx['next_rdvs'].append((event, state))
|
||||
ctx['next_rdvs'].append((event, state, event.get_missing_participants()))
|
||||
if ctx['next_rdvs']:
|
||||
ctx['next_rdv'] = ctx['next_rdvs'][0][0]
|
||||
ctx['last_rdvs'] = []
|
||||
|
@ -315,7 +315,12 @@ class PatientRecordView(cbv.ServiceViewMixin, cbv.MultiUpdateView):
|
|||
state = act.get_state()
|
||||
if state and not state.previous_state and state.state_name == 'NON_VALIDE':
|
||||
state = None
|
||||
ctx['last_rdvs'].append((act, state))
|
||||
missing_workers = []
|
||||
try:
|
||||
missing_workers = [participant.worker for participant in act.event.get_missing_participants()]
|
||||
except:
|
||||
pass
|
||||
ctx['last_rdvs'].append((act, state, missing_workers))
|
||||
history = []
|
||||
i = 0
|
||||
for state in ctx['object'].filestate_set.order_by('-date_selected'):
|
||||
|
|
|
@ -380,6 +380,19 @@ class HolidayQuerySet(query.QuerySet):
|
|||
def for_period(self, start_date, end_date):
|
||||
return self.filter(start_date__lte=end_date, end_date__gte=start_date)
|
||||
|
||||
def for_timed_period(self, date, start_time, end_time):
|
||||
filter_query = models.Q(start_date__lt=date, end_date__gt=date) \
|
||||
| models.Q(start_date=date, start_time__isnull=True, end_date__gt=date) \
|
||||
| models.Q(start_date=date, start_time__lt=end_time, end_date__gt=date) \
|
||||
| models.Q(start_date__lt=date, end_date=date, end_time__isnull=True) \
|
||||
| models.Q(start_date__lt=date, end_date=date, end_time__gt=start_time) \
|
||||
| models.Q(start_date=date, end_date=date, start_time__isnull=True, end_time__isnull=True) \
|
||||
| models.Q(start_date=date, end_date=date, start_time__isnull=True, end_time__gt=start_time) \
|
||||
| models.Q(start_date=date, end_date=date, start_time__lt=end_time, end_time__isnull=True) \
|
||||
| models.Q(start_date=date, end_date=date, start_time__lte=start_time, end_time__gt=start_time) \
|
||||
| models.Q(start_date=date, end_date=date, start_time__lt=end_time, end_time__gte=end_time)
|
||||
return self.filter(filter_query)
|
||||
|
||||
def time2french(time):
|
||||
if time.minute:
|
||||
return '{0}h{1}'.format(time.hour, time.minute)
|
||||
|
|
|
@ -492,6 +492,11 @@ td.busy {
|
|||
background: red;
|
||||
}
|
||||
|
||||
span.absent{
|
||||
color: red;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
td#agendas {
|
||||
vertical-align: top;
|
||||
width: 100%;
|
||||
|
@ -1400,6 +1405,7 @@ div.pagination {
|
|||
.icon-user-space:before { content: "\f007 "; }
|
||||
.icon-circle-arrow-left:before { content: "\f0a8"; }
|
||||
.icon-circle-arrow-right:before { content: "\f0a9"; }
|
||||
.icon-warning-sign:before { content: "\f071" }
|
||||
|
||||
/* periodic event search form */
|
||||
|
||||
|
|
Reference in New Issue