Revision 76974b6f
Added by Benjamin Dauvergne almost 12 years ago
calebasse/facturation/tests.py | ||
---|---|---|
10 | 10 |
from calebasse.actes.validation import automated_validation, \ |
11 | 11 |
are_all_acts_of_the_day_locked, \ |
12 | 12 |
get_days_with_acts_not_locked |
13 |
from calebasse.actes.models import EventAct |
|
13 |
from calebasse.actes.models import Act |
|
14 |
from calebasse.agenda.models import EventWithAct |
|
14 | 15 |
from calebasse.dossiers.models import create_patient, PatientRecord, \ |
15 | 16 |
SessadHealthCareNotification, CmppHealthCareTreatment, CmppHealthCareDiagnostic |
16 | 17 |
from calebasse.dossiers.models import Status |
... | ... | |
39 | 40 |
service_camsp = Service.objects.get(name='CAMSP') |
40 | 41 |
|
41 | 42 |
patient_a = create_patient('a', 'A', service_camsp, self.creator, date_selected=datetime(2020, 10, 5)) |
42 |
act0 = EventAct.objects.create_patient_appointment(self.creator, 'RDV', patient_a, [self.therapist3], |
|
43 |
act0 = EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient_a, [self.therapist3],
|
|
43 | 44 |
self.act_type, service_camsp, start_datetime=datetime(2020, 10, 6, 10, 15), |
44 | 45 |
end_datetime=datetime(2020, 10, 6, 12, 20)) |
45 | 46 |
status_suivi = Status.objects.filter(services__name='CAMSP').filter(type='SUIVI')[0] |
46 | 47 |
patient_a.set_state(status_suivi, self.creator, date_selected=datetime(2020, 10, 7)) |
47 |
act1 = EventAct.objects.create_patient_appointment(self.creator, 'RDV', patient_a, [self.therapist3], |
|
48 |
act1 = EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient_a, [self.therapist3],
|
|
48 | 49 |
self.act_type, service_camsp, start_datetime=datetime(2020, 10, 7, 10, 15), |
49 | 50 |
end_datetime=datetime(2020, 10, 7, 12, 20)) |
50 |
act2 = EventAct.objects.create_patient_appointment(self.creator, 'RDV', patient_a, [self.therapist3], |
|
51 |
act2 = EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient_a, [self.therapist3],
|
|
51 | 52 |
self.act_type, service_camsp, start_datetime=datetime(2020, 10, 7, 14, 15), |
52 | 53 |
end_datetime=datetime(2020, 10, 7, 16, 20)) |
53 |
act3 = EventAct.objects.create_patient_appointment(self.creator, 'RDV', patient_a, [self.therapist3], |
|
54 |
act3 = EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient_a, [self.therapist3],
|
|
54 | 55 |
self.act_type, service_camsp, start_datetime=datetime(2020, 10, 7, 16, 20), |
55 | 56 |
end_datetime=datetime(2020, 10, 7, 17, 20)) |
56 | 57 |
status_clos = Status.objects.filter(services__name='CAMSP').filter(type='CLOS')[0] |
57 | 58 |
patient_a.set_state(status_clos, self.creator, date_selected=datetime(2020, 10, 8)) |
58 |
act4 = EventAct.objects.create_patient_appointment(self.creator, 'RDV', patient_a, [self.therapist3], |
|
59 |
act4 = EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient_a, [self.therapist3],
|
|
59 | 60 |
self.act_type, service_camsp, start_datetime=datetime(2020, 10, 8, 10, 15), |
60 | 61 |
end_datetime=datetime(2020, 10, 8, 12, 20)) |
61 | 62 |
|
62 | 63 |
patient_b = create_patient('b', 'B', service_camsp, self.creator, date_selected=datetime(2020, 10, 4)) |
63 |
act5 = EventAct.objects.create_patient_appointment(self.creator, 'RDV', patient_b, [self.therapist3], |
|
64 |
act5 = EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient_b, [self.therapist3],
|
|
64 | 65 |
self.act_type, service_camsp, start_datetime=datetime(2020, 10, 4, 10, 15), |
65 | 66 |
end_datetime=datetime(2020, 10, 4, 12, 20)) |
66 |
act6 = EventAct.objects.create_patient_appointment(self.creator, 'RDV', patient_b, [self.therapist3], |
|
67 |
act6 = EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient_b, [self.therapist3],
|
|
67 | 68 |
self.act_type, service_camsp, start_datetime=datetime(2020, 10, 5, 10, 15), |
68 | 69 |
end_datetime=datetime(2020, 10, 5, 12, 20)) |
69 | 70 |
act6.set_state('ABS_EXC', self.creator) |
70 |
act7 = EventAct.objects.create_patient_appointment(self.creator, 'RDV', patient_b, [self.therapist3], |
|
71 |
act7 = EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient_b, [self.therapist3],
|
|
71 | 72 |
self.act_type, service_camsp, start_datetime=datetime(2020, 10, 5, 10, 15), |
72 | 73 |
end_datetime=datetime(2020, 10, 5, 12, 20)) |
73 | 74 |
act7.switch_billable = True |
74 | 75 |
act7.save() |
75 | 76 |
patient_b.set_state(status_suivi, self.creator, date_selected=datetime(2020, 10, 6)) |
76 |
act8 = EventAct.objects.create_patient_appointment(self.creator, 'RDV', patient_b, [self.therapist3], |
|
77 |
act8 = EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient_b, [self.therapist3],
|
|
77 | 78 |
self.act_type, service_camsp, start_datetime=datetime(2020, 10, 7, 10, 15), |
78 | 79 |
end_datetime=datetime(2020, 10, 7, 12, 20)) |
79 |
act9 = EventAct.objects.create_patient_appointment(self.creator, 'RDV', patient_b, [self.therapist3], |
|
80 |
act9 = EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient_b, [self.therapist3],
|
|
80 | 81 |
self.act_type, service_camsp, start_datetime=datetime(2020, 10, 7, 14, 15), |
81 | 82 |
end_datetime=datetime(2020, 10, 7, 16, 20)) |
82 |
act10 = EventAct.objects.create_patient_appointment(self.creator, 'RDV', patient_b, [self.therapist3], |
|
83 |
act10 = EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient_b, [self.therapist3],
|
|
83 | 84 |
self.act_type, service_camsp, start_datetime=datetime(2020, 10, 7, 16, 20), |
84 | 85 |
end_datetime=datetime(2020, 10, 7, 17, 20)) |
85 |
act11 = EventAct.objects.create_patient_appointment(self.creator, 'RDV', patient_b, [self.therapist3], |
|
86 |
act11 = EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient_b, [self.therapist3],
|
|
86 | 87 |
self.act_type, service_camsp, start_datetime=datetime(2020, 10, 8, 10, 15), |
87 | 88 |
end_datetime=datetime(2020, 10, 8, 12, 20)) |
88 | 89 |
patient_b.set_state(status_clos, self.creator, date_selected=datetime(2020, 10, 9)) |
... | ... | |
149 | 150 |
service_sessad = Service.objects.get(name='SESSAD DYS') |
150 | 151 |
|
151 | 152 |
patient_a = create_patient('a', 'A', service_sessad, self.creator, date_selected=datetime(2020, 10, 5)) |
152 |
act0 = EventAct.objects.create_patient_appointment(self.creator, 'RDV', patient_a, [self.therapist3], |
|
153 |
act0 = EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient_a, [self.therapist3],
|
|
153 | 154 |
self.act_type, service_sessad, start_datetime=datetime(2020, 10, 6, 10, 15), |
154 | 155 |
end_datetime=datetime(2020, 10, 6, 12, 20)) |
155 | 156 |
status_traitement = Status.objects.filter(services__name='SESSAD DYS').filter(type='TRAITEMENT')[0] |
156 | 157 |
patient_a.set_state(status_traitement, self.creator, date_selected=datetime(2020, 10, 7)) |
157 |
act1 = EventAct.objects.create_patient_appointment(self.creator, 'RDV', patient_a, [self.therapist3], |
|
158 |
act1 = EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient_a, [self.therapist3],
|
|
158 | 159 |
self.act_type, service_sessad, start_datetime=datetime(2020, 10, 7, 10, 15), |
159 | 160 |
end_datetime=datetime(2020, 10, 7, 12, 20)) |
160 |
act2 = EventAct.objects.create_patient_appointment(self.creator, 'RDV', patient_a, [self.therapist3], |
|
161 |
act2 = EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient_a, [self.therapist3],
|
|
161 | 162 |
self.act_type, service_sessad, start_datetime=datetime(2020, 10, 7, 14, 15), |
162 | 163 |
end_datetime=datetime(2020, 10, 7, 16, 20)) |
163 |
act3 = EventAct.objects.create_patient_appointment(self.creator, 'RDV', patient_a, [self.therapist3], |
|
164 |
act3 = EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient_a, [self.therapist3],
|
|
164 | 165 |
self.act_type, service_sessad, start_datetime=datetime(2020, 10, 7, 16, 20), |
165 | 166 |
end_datetime=datetime(2020, 10, 7, 17, 20)) |
166 | 167 |
status_clos = Status.objects.filter(services__name='SESSAD DYS').filter(type='CLOS')[0] |
167 | 168 |
patient_a.set_state(status_clos, self.creator, date_selected=datetime(2020, 10, 8)) |
168 |
act4 = EventAct.objects.create_patient_appointment(self.creator, 'RDV', patient_a, [self.therapist3], |
|
169 |
act4 = EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient_a, [self.therapist3],
|
|
169 | 170 |
self.act_type, service_sessad, start_datetime=datetime(2020, 10, 8, 10, 15), |
170 | 171 |
end_datetime=datetime(2020, 10, 8, 12, 20)) |
171 | 172 |
|
... | ... | |
196 | 197 |
service_cmpp = Service.objects.get(name='CMPP') |
197 | 198 |
|
198 | 199 |
patient_a = create_patient('a', 'A', service_cmpp, self.creator, date_selected=datetime(2020, 10, 1)) |
199 |
acts = [ EventAct.objects.create_patient_appointment(self.creator, 'RDV', patient_a, [self.therapist3], |
|
200 |
acts = [ EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient_a, [self.therapist3],
|
|
200 | 201 |
self.act_type, service_cmpp, start_datetime=datetime(2020, 10, i, 10, 15), |
201 | 202 |
end_datetime=datetime(2020, 10, i, 12, 20)) for i in range (1, 32)] |
202 | 203 |
status_accueil = Status.objects.filter(services__name='CMPP').filter(type='ACCUEIL')[0] |
... | ... | |
236 | 237 |
patient_a = PatientRecord.objects.get(id=patient_a.id) |
237 | 238 |
self.assertEqual(patient_a.get_state().status, status_traitement) |
238 | 239 |
|
239 |
acts_2 = [ EventAct.objects.create_patient_appointment(self.creator, 'RDV', patient_a, [self.therapist3], |
|
240 |
acts_2 = [ EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient_a, [self.therapist3],
|
|
240 | 241 |
self.act_type, service_cmpp, start_datetime=datetime(2020, 11, i, 10, 15), |
241 | 242 |
end_datetime=datetime(2020, 11, i, 12, 20)) for i in range (1, 31)] |
242 | 243 |
for i in range(1, 31): |
... | ... | |
281 | 282 |
patients = [] |
282 | 283 |
for j in range(2): |
283 | 284 |
patients.append(create_patient(str(j), str(j), service_cmpp, self.creator, date_selected=datetime(2012, 10, 1))) |
284 |
acts = [ EventAct.objects.create_patient_appointment(self.creator, 'RDV', patients[j], [self.therapist3], |
|
285 |
acts = [ EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patients[j], [self.therapist3],
|
|
285 | 286 |
self.act_type, service_cmpp, start_datetime=datetime(2012, 10, i, 10, 15), |
286 | 287 |
end_datetime=datetime(2012, 10, i, 12, 20)) for i in range (1, 32)] |
287 |
acts_2 = [ EventAct.objects.create_patient_appointment(self.creator, 'RDV', patients[j], [self.therapist3], |
|
288 |
acts_2 = [ EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patients[j], [self.therapist3],
|
|
288 | 289 |
self.act_type, service_cmpp, start_datetime=datetime(2012, 11, i, 10, 15), |
289 | 290 |
end_datetime=datetime(2012, 11, i, 12, 20)) for i in range (1, 31)] |
290 | 291 |
hct = CmppHealthCareTreatment(patient=patients[j], start_date=datetime(2012, 10, 7), author=self.creator) |
... | ... | |
376 | 377 |
|
377 | 378 |
|
378 | 379 |
patient = create_patient('A', 'a', service_cmpp, self.creator, date_selected=datetime(2012, 10, 1)) |
379 |
acts = [ EventAct.objects.create_patient_appointment(self.creator, 'RDV', patient, [self.therapist3], |
|
380 |
acts = [ EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient, [self.therapist3],
|
|
380 | 381 |
self.act_type, service_cmpp, start_datetime=datetime(2012, 10, i, 10, 15), |
381 | 382 |
end_datetime=datetime(2012, 10, i, 12, 20)) for i in range (1, 32)] |
382 | 383 |
hct = CmppHealthCareTreatment(patient=patient, start_date=datetime(2011, 11, 7), author=self.creator) |
... | ... | |
407 | 408 |
self.assertEqual(len_patient_with_lost_acts, 0) |
408 | 409 |
|
409 | 410 |
|
410 |
acts_2 = [ EventAct.objects.create_patient_appointment(self.creator, 'RDV', patient, [self.therapist3], |
|
411 |
acts_2 = [ EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient, [self.therapist3],
|
|
411 | 412 |
self.act_type, service_cmpp, start_datetime=datetime(2012, 11, i, 10, 15), |
412 | 413 |
end_datetime=datetime(2012, 11, i, 12, 20)) for i in range (1, 31)] |
413 | 414 |
|
... | ... | |
447 | 448 |
|
448 | 449 |
self.assertEqual(patient.last_state.status.type, "ACCUEIL") |
449 | 450 |
|
450 |
EventAct.objects.create_patient_appointment(self.creator, 'RDV', patient, [self.therapist3], |
|
451 |
EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient, [self.therapist3],
|
|
451 | 452 |
self.act_type, service_cmpp, start_datetime=datetime(2012, 10, 1, 10, 15), |
452 | 453 |
end_datetime=datetime(2012, 10, 1, 12, 20)) |
453 | 454 |
|
... | ... | |
457 | 458 |
self.assertEqual(patient.last_state.status.type, "DIAGNOSTIC") |
458 | 459 |
self.assertEqual(patient.last_state.date_selected, datetime(2012, 10, 1, 0, 0)) |
459 | 460 |
|
460 |
acts = [ EventAct.objects.create_patient_appointment(self.creator, 'RDV', patient, [self.therapist3], |
|
461 |
acts = [ EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient, [self.therapist3],
|
|
461 | 462 |
self.act_type, service_cmpp, start_datetime=datetime(2012, 10, i, 10, 15), |
462 | 463 |
end_datetime=datetime(2012, 10, i, 12, 20)) for i in range (2, 32)] |
463 | 464 |
|
... | ... | |
472 | 473 |
|
473 | 474 |
self.assertEqual(patient.last_state.status.type, "ACCUEIL") |
474 | 475 |
|
475 |
EventAct.objects.create_patient_appointment(self.creator, 'RDV', patient, [self.therapist3], |
|
476 |
EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient, [self.therapist3],
|
|
476 | 477 |
self.act_type, service_cmpp, start_datetime=datetime(2012, 10, 1, 10, 15), |
477 | 478 |
end_datetime=datetime(2012, 10, 1, 12, 20)) |
478 | 479 |
|
... | ... | |
489 | 490 |
self.assertEqual(patient.last_state.status.type, "CLOS") |
490 | 491 |
self.assertEqual(patient.last_state.date_selected, datetime(2012, 12, 9, 0, 0)) |
491 | 492 |
|
492 |
acts = [ EventAct.objects.create_patient_appointment(self.creator, 'RDV', patient, [self.therapist3], |
|
493 |
acts = [ EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient, [self.therapist3],
|
|
493 | 494 |
self.act_type, service_cmpp, start_datetime=datetime(2012, 10, i, 10, 15), |
494 | 495 |
end_datetime=datetime(2012, 10, i, 12, 20)) for i in range (2, 32)] |
495 | 496 |
|
... | ... | |
506 | 507 |
price_o = add_price(120, date(2012, 10, 1)) |
507 | 508 |
|
508 | 509 |
patient = create_patient('A', 'a', service_cmpp, self.creator, date_selected=datetime(2012, 10, 1)) |
509 |
acts = [ EventAct.objects.create_patient_appointment(self.creator, 'RDV', patient, [self.therapist3], |
|
510 |
acts = [ EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient, [self.therapist3],
|
|
510 | 511 |
self.act_type, service_cmpp, start_datetime=datetime(2012, 10, i, 10, 15), |
511 | 512 |
end_datetime=datetime(2012, 10, i, 12, 20)) for i in range (1, 4)] |
512 | 513 |
|
... | ... | |
545 | 546 |
|
546 | 547 |
hcd.set_act_number(5) |
547 | 548 |
|
548 |
acts = [ EventAct.objects.create_patient_appointment(self.creator, 'RDV', patient, [self.therapist3], |
|
549 |
acts = [ EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient, [self.therapist3],
|
|
549 | 550 |
self.act_type, service_cmpp, start_datetime=datetime(2012, 10, i, 10, 15), |
550 | 551 |
end_datetime=datetime(2012, 10, i, 12, 20)) for i in range (4, 32)] |
551 | 552 |
|
... | ... | |
601 | 602 |
|
602 | 603 |
hct.set_act_number(28) |
603 | 604 |
|
604 |
acts = [ EventAct.objects.create_patient_appointment(self.creator, 'RDV', patient, [self.therapist3], |
|
605 |
acts = [ EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient, [self.therapist3],
|
|
605 | 606 |
self.act_type, service_cmpp, start_datetime=datetime(2012, 11, i, 10, 15), |
606 | 607 |
end_datetime=datetime(2012, 11, i, 12, 20)) for i in range (1, 4)] |
607 | 608 |
|
Also available in: Unified diff
agenda/actes/dossiers: move Occurence fields into Event, add recurring events support