Revision 76974b6f
Added by Benjamin Dauvergne almost 12 years ago
calebasse/agenda/appointments.py | ||
---|---|---|
23 | 23 |
self.patient_record_paper_id = None |
24 | 24 |
self.event_id = None |
25 | 25 |
self.event_type = None |
26 |
self.occurrence_id = None
|
|
26 |
self.event_id = None
|
|
27 | 27 |
self.workers = None |
28 | 28 |
self.workers_initial = None |
29 | 29 |
self.workers_codes = None |
... | ... | |
41 | 41 |
else: |
42 | 42 |
self.begin_hour = None |
43 | 43 |
|
44 |
def init_from_occurrence(self, occurrence, service):
|
|
44 |
def init_from_event(self, event, service):
|
|
45 | 45 |
""" """ |
46 |
delta = occurrence.end_time - occurrence.start_time
|
|
47 |
self.occurrence_id = occurrence.id
|
|
46 |
delta = event.end_datetime - event.start_datetime
|
|
47 |
self.event_id = event.id
|
|
48 | 48 |
self.length = delta.seconds / 60 |
49 |
self.title = occurrence.title
|
|
50 |
services = occurrence.event.services.all()
|
|
51 |
self.date = occurrence.start_time.date()
|
|
52 |
self.__set_time(time(occurrence.start_time.hour, occurrence.start_time.minute))
|
|
49 |
self.title = event.title
|
|
50 |
services = event.services.all() |
|
51 |
self.date = event.start_datetime.date()
|
|
52 |
self.__set_time(time(event.start_datetime.hour, event.start_datetime.minute))
|
|
53 | 53 |
for e_service in services: |
54 | 54 |
if e_service != service: |
55 | 55 |
name = e_service.name.lower().replace(' ', '-') |
... | ... | |
58 | 58 |
self.type = "busy-here" |
59 | 59 |
else: |
60 | 60 |
self.type = "busy-elsewhere" |
61 |
self.event_id = occurrence.event.id
|
|
62 |
if occurrence.event.room:
|
|
63 |
self.room = occurrence.event.room.name
|
|
64 |
self.description = occurrence.event.description
|
|
65 |
if occurrence.event.event_type.id == 1:
|
|
66 |
event_act = occurrence.event.eventact
|
|
67 |
workers = event_act.participants.all()
|
|
61 |
self.event_id = event.id |
|
62 |
if event.room: |
|
63 |
self.room = event.room.name |
|
64 |
self.description = event.description |
|
65 |
if event.event_type.id == 1: |
|
66 |
event_act = event.act
|
|
67 |
workers = event_act.doctors.all()
|
|
68 | 68 |
self.convocation_sent = event_act.convocation_sent |
69 | 69 |
self.patient = event_act.patient |
70 | 70 |
self.patient_record_id = event_act.patient.id |
... | ... | |
93 | 93 |
validation_states.pop('ACT_DOUBLE') |
94 | 94 |
self.validation = (event_act, state, display_name, validation_states) |
95 | 95 |
else: |
96 |
self.event_type = occurrence.event.event_type
|
|
96 |
self.event_type = event.event_type |
|
97 | 97 |
|
98 | 98 |
def init_free_time(self, length, begin_time): |
99 | 99 |
""" """ |
... | ... | |
116 | 116 |
self.title = title |
117 | 117 |
self.__set_time(time) |
118 | 118 |
|
119 |
def get_daily_appointments(date, worker, service, time_tables, occurrences, holidays):
|
|
119 |
def get_daily_appointments(date, worker, service, time_tables, events, holidays):
|
|
120 | 120 |
""" |
121 | 121 |
""" |
122 | 122 |
appointments = [] |
123 | 123 |
|
124 | 124 |
timetables_set = IntervalSet((t.to_interval(date) for t in time_tables)) |
125 |
occurrences_set = IntervalSet((o.to_interval() for o in occurrences))
|
|
125 |
events_set = IntervalSet((o.to_interval() for o in events))
|
|
126 | 126 |
holidays_set = IntervalSet((h.to_interval(date) for h in holidays)) |
127 |
busy_occurrences_set = IntervalSet((o.to_interval() for o in occurrences if not o.is_event_absence()))
|
|
127 |
busy_occurrences_set = IntervalSet((o.to_interval() for o in events_set if not o.is_event_absence()))
|
|
128 | 128 |
for free_time in timetables_set - (busy_occurrences_set+holidays_set): |
129 | 129 |
if free_time: |
130 | 130 |
delta = free_time.upper_bound - free_time.lower_bound |
... | ... | |
133 | 133 |
appointment.init_free_time(delta_minutes, |
134 | 134 |
time(free_time.lower_bound.hour, free_time.lower_bound.minute)) |
135 | 135 |
appointments.append(appointment) |
136 |
for occurrence in occurrences:
|
|
136 |
for event in events:
|
|
137 | 137 |
appointment = Appointment() |
138 |
appointment.init_from_occurrence(occurrence, service)
|
|
138 |
appointment.init_from_event(event, service)
|
|
139 | 139 |
appointments.append(appointment) |
140 | 140 |
for holiday in holidays: |
141 | 141 |
interval = holiday.to_interval(date) |
Also available in: Unified diff
agenda/actes/dossiers: move Occurence fields into Event, add recurring events support