1 |
786f0c97
|
Mikaël Ates
|
# -*- coding: utf-8 -*-
|
2 |
b958a9ad
|
Mikaël Ates
|
import time
|
3 |
|
|
from datetime import datetime, date
|
4 |
786f0c97
|
Mikaël Ates
|
from dateutil import rrule
|
5 |
b958a9ad
|
Mikaël Ates
|
from dateutil.relativedelta import relativedelta
|
6 |
fd0f45e5
|
Benjamin Dauvergne
|
|
7 |
|
|
from django.test import TestCase
|
8 |
786f0c97
|
Mikaël Ates
|
from django.contrib.auth.models import User
|
9 |
|
|
|
10 |
|
|
from calebasse.actes.validation import automated_validation, \
|
11 |
|
|
are_all_acts_of_the_day_locked, \
|
12 |
|
|
get_days_with_acts_not_locked
|
13 |
76974b6f
|
Benjamin Dauvergne
|
from calebasse.actes.models import Act
|
14 |
|
|
from calebasse.agenda.models import EventWithAct
|
15 |
bcbe20d1
|
Jérôme Schneider
|
from calebasse.dossiers.models import create_patient, PatientRecord, \
|
16 |
786f0c97
|
Mikaël Ates
|
SessadHealthCareNotification, CmppHealthCareTreatment, CmppHealthCareDiagnostic
|
17 |
afb93074
|
Mikaël Ates
|
from calebasse.dossiers.models import Status
|
18 |
786f0c97
|
Mikaël Ates
|
from calebasse.ressources.models import ActType, Service, WorkerType
|
19 |
|
|
from calebasse.personnes.models import Worker
|
20 |
|
|
|
21 |
b958a9ad
|
Mikaël Ates
|
from list_acts import (list_acts_for_billing_CAMSP,
|
22 |
|
|
list_acts_for_billing_SESSAD, list_acts_for_billing_CMPP,
|
23 |
523c5aaf
|
Mikaël Ates
|
list_acts_for_billing_CMPP)
|
24 |
b958a9ad
|
Mikaël Ates
|
|
25 |
139bba80
|
Frédéric Péters
|
from models import PricePerAct, Invoicing
|
26 |
786f0c97
|
Mikaël Ates
|
|
27 |
|
|
|
28 |
|
|
class FacturationTest(TestCase):
|
29 |
96692361
|
Benjamin Dauvergne
|
fixtures = ['services', 'filestates']
|
30 |
786f0c97
|
Mikaël Ates
|
def setUp(self):
|
31 |
|
|
self.creator = User.objects.create(username='John')
|
32 |
|
|
|
33 |
|
|
self.wtype = WorkerType.objects.create(name='ElDoctor', intervene=True)
|
34 |
|
|
self.therapist1 = Worker.objects.create(first_name='Bob', last_name='Leponge', type=self.wtype)
|
35 |
|
|
self.therapist2 = Worker.objects.create(first_name='Jean', last_name='Valjean', type=self.wtype)
|
36 |
|
|
self.therapist3 = Worker.objects.create(first_name='Pierre', last_name='PaulJacques', type=self.wtype)
|
37 |
|
|
self.act_type = ActType.objects.create(name='trepanation')
|
38 |
|
|
|
39 |
|
|
def test_facturation_camsp(self):
|
40 |
afb93074
|
Mikaël Ates
|
service_camsp = Service.objects.get(name='CAMSP')
|
41 |
786f0c97
|
Mikaël Ates
|
|
42 |
|
|
patient_a = create_patient('a', 'A', service_camsp, self.creator, date_selected=datetime(2020, 10, 5))
|
43 |
76974b6f
|
Benjamin Dauvergne
|
act0 = EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient_a, [self.therapist3],
|
44 |
786f0c97
|
Mikaël Ates
|
self.act_type, service_camsp, start_datetime=datetime(2020, 10, 6, 10, 15),
|
45 |
|
|
end_datetime=datetime(2020, 10, 6, 12, 20))
|
46 |
afb93074
|
Mikaël Ates
|
status_suivi = Status.objects.filter(services__name='CAMSP').filter(type='SUIVI')[0]
|
47 |
|
|
patient_a.set_state(status_suivi, self.creator, date_selected=datetime(2020, 10, 7))
|
48 |
76974b6f
|
Benjamin Dauvergne
|
act1 = EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient_a, [self.therapist3],
|
49 |
786f0c97
|
Mikaël Ates
|
self.act_type, service_camsp, start_datetime=datetime(2020, 10, 7, 10, 15),
|
50 |
|
|
end_datetime=datetime(2020, 10, 7, 12, 20))
|
51 |
76974b6f
|
Benjamin Dauvergne
|
act2 = EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient_a, [self.therapist3],
|
52 |
786f0c97
|
Mikaël Ates
|
self.act_type, service_camsp, start_datetime=datetime(2020, 10, 7, 14, 15),
|
53 |
|
|
end_datetime=datetime(2020, 10, 7, 16, 20))
|
54 |
76974b6f
|
Benjamin Dauvergne
|
act3 = EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient_a, [self.therapist3],
|
55 |
786f0c97
|
Mikaël Ates
|
self.act_type, service_camsp, start_datetime=datetime(2020, 10, 7, 16, 20),
|
56 |
|
|
end_datetime=datetime(2020, 10, 7, 17, 20))
|
57 |
afb93074
|
Mikaël Ates
|
status_clos = Status.objects.filter(services__name='CAMSP').filter(type='CLOS')[0]
|
58 |
|
|
patient_a.set_state(status_clos, self.creator, date_selected=datetime(2020, 10, 8))
|
59 |
76974b6f
|
Benjamin Dauvergne
|
act4 = EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient_a, [self.therapist3],
|
60 |
786f0c97
|
Mikaël Ates
|
self.act_type, service_camsp, start_datetime=datetime(2020, 10, 8, 10, 15),
|
61 |
|
|
end_datetime=datetime(2020, 10, 8, 12, 20))
|
62 |
|
|
|
63 |
|
|
patient_b = create_patient('b', 'B', service_camsp, self.creator, date_selected=datetime(2020, 10, 4))
|
64 |
76974b6f
|
Benjamin Dauvergne
|
act5 = EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient_b, [self.therapist3],
|
65 |
786f0c97
|
Mikaël Ates
|
self.act_type, service_camsp, start_datetime=datetime(2020, 10, 4, 10, 15),
|
66 |
|
|
end_datetime=datetime(2020, 10, 4, 12, 20))
|
67 |
76974b6f
|
Benjamin Dauvergne
|
act6 = EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient_b, [self.therapist3],
|
68 |
786f0c97
|
Mikaël Ates
|
self.act_type, service_camsp, start_datetime=datetime(2020, 10, 5, 10, 15),
|
69 |
|
|
end_datetime=datetime(2020, 10, 5, 12, 20))
|
70 |
801caa14
|
Benjamin Dauvergne
|
act6.act.set_state('ABS_EXC', self.creator)
|
71 |
76974b6f
|
Benjamin Dauvergne
|
act7 = EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient_b, [self.therapist3],
|
72 |
786f0c97
|
Mikaël Ates
|
self.act_type, service_camsp, start_datetime=datetime(2020, 10, 5, 10, 15),
|
73 |
|
|
end_datetime=datetime(2020, 10, 5, 12, 20))
|
74 |
|
|
act7.switch_billable = True
|
75 |
|
|
act7.save()
|
76 |
afb93074
|
Mikaël Ates
|
patient_b.set_state(status_suivi, self.creator, date_selected=datetime(2020, 10, 6))
|
77 |
76974b6f
|
Benjamin Dauvergne
|
act8 = EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient_b, [self.therapist3],
|
78 |
786f0c97
|
Mikaël Ates
|
self.act_type, service_camsp, start_datetime=datetime(2020, 10, 7, 10, 15),
|
79 |
|
|
end_datetime=datetime(2020, 10, 7, 12, 20))
|
80 |
76974b6f
|
Benjamin Dauvergne
|
act9 = EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient_b, [self.therapist3],
|
81 |
786f0c97
|
Mikaël Ates
|
self.act_type, service_camsp, start_datetime=datetime(2020, 10, 7, 14, 15),
|
82 |
|
|
end_datetime=datetime(2020, 10, 7, 16, 20))
|
83 |
76974b6f
|
Benjamin Dauvergne
|
act10 = EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient_b, [self.therapist3],
|
84 |
786f0c97
|
Mikaël Ates
|
self.act_type, service_camsp, start_datetime=datetime(2020, 10, 7, 16, 20),
|
85 |
|
|
end_datetime=datetime(2020, 10, 7, 17, 20))
|
86 |
76974b6f
|
Benjamin Dauvergne
|
act11 = EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient_b, [self.therapist3],
|
87 |
786f0c97
|
Mikaël Ates
|
self.act_type, service_camsp, start_datetime=datetime(2020, 10, 8, 10, 15),
|
88 |
|
|
end_datetime=datetime(2020, 10, 8, 12, 20))
|
89 |
afb93074
|
Mikaël Ates
|
patient_b.set_state(status_clos, self.creator, date_selected=datetime(2020, 10, 9))
|
90 |
786f0c97
|
Mikaël Ates
|
|
91 |
|
|
automated_validation(datetime(2020, 10, 5), service_camsp, self.creator)
|
92 |
|
|
automated_validation(datetime(2020, 10, 6), service_camsp, self.creator)
|
93 |
|
|
automated_validation(datetime(2020, 10, 7), service_camsp, self.creator)
|
94 |
|
|
automated_validation(datetime(2020, 10, 8), service_camsp, self.creator)
|
95 |
|
|
|
96 |
81066065
|
Mikaël Ates
|
not_locked, days_not_locked, not_valide, not_billable, acts_pause, rejected, selected = \
|
97 |
786f0c97
|
Mikaël Ates
|
list_acts_for_billing_CAMSP(datetime(2020, 10, 4), datetime(2020, 10, 8), service_camsp)
|
98 |
|
|
|
99 |
|
|
self.assertEqual(len(days_not_locked), 1)
|
100 |
|
|
|
101 |
9c9213df
|
Benjamin Dauvergne
|
self.assertTrue(act1.act in selected[patient_a])
|
102 |
|
|
self.assertTrue(act2.act in selected[patient_a])
|
103 |
|
|
self.assertTrue(act3.act in selected[patient_a])
|
104 |
786f0c97
|
Mikaël Ates
|
acts_rejected = [x[0] for x in rejected[patient_a]]
|
105 |
9c9213df
|
Benjamin Dauvergne
|
self.assertTrue(act0.act in acts_rejected)
|
106 |
|
|
self.assertTrue(act4.act in acts_rejected)
|
107 |
786f0c97
|
Mikaël Ates
|
|
108 |
|
|
acts_not_locked = [x[0] for x in not_locked[patient_b]]
|
109 |
9c9213df
|
Benjamin Dauvergne
|
self.assertTrue(act5.act in acts_not_locked)
|
110 |
786f0c97
|
Mikaël Ates
|
acts_not_valide = [x[0] for x in not_valide[patient_b]]
|
111 |
9c9213df
|
Benjamin Dauvergne
|
self.assertTrue(act6.act in acts_not_valide)
|
112 |
|
|
print not_billable
|
113 |
|
|
self.assertTrue(act7.act in not_billable[patient_b])
|
114 |
|
|
self.assertTrue(act8.act in selected[patient_b])
|
115 |
|
|
self.assertTrue(act9.act in selected[patient_b])
|
116 |
|
|
self.assertTrue(act10.act in selected[patient_b])
|
117 |
|
|
self.assertTrue(act11.act in selected[patient_b])
|
118 |
fd0f45e5
|
Benjamin Dauvergne
|
|
119 |
786f0c97
|
Mikaël Ates
|
states = patient_b.get_states_history()
|
120 |
|
|
patient_b.change_day_selected_of_state(states[2], datetime(2020, 10, 7))
|
121 |
81066065
|
Mikaël Ates
|
not_locked, days_not_locked, not_valide, not_billable, acts_pause, rejected, selected = \
|
122 |
786f0c97
|
Mikaël Ates
|
list_acts_for_billing_CAMSP(datetime(2020, 10, 4), datetime(2020, 10, 8), service_camsp)
|
123 |
|
|
acts_not_locked = [x[0] for x in not_locked[patient_b]]
|
124 |
9c9213df
|
Benjamin Dauvergne
|
self.assertTrue(act5.act in acts_not_locked)
|
125 |
786f0c97
|
Mikaël Ates
|
acts_not_valide = [x[0] for x in not_valide[patient_b]]
|
126 |
9c9213df
|
Benjamin Dauvergne
|
self.assertTrue(act6.act in acts_not_valide)
|
127 |
|
|
self.assertTrue(act7.act in not_billable[patient_b])
|
128 |
786f0c97
|
Mikaël Ates
|
acts_rejected = [x[0] for x in rejected[patient_b]]
|
129 |
9c9213df
|
Benjamin Dauvergne
|
self.assertTrue(act8.act in acts_rejected)
|
130 |
|
|
self.assertTrue(act9.act in acts_rejected)
|
131 |
|
|
self.assertTrue(act10.act in acts_rejected)
|
132 |
|
|
self.assertTrue(act11.act in acts_rejected)
|
133 |
fd0f45e5
|
Benjamin Dauvergne
|
|
134 |
786f0c97
|
Mikaël Ates
|
states = patient_b.get_states_history()
|
135 |
|
|
patient_b.change_day_selected_of_state(states[2], datetime(2020, 10, 9))
|
136 |
|
|
patient_b.change_day_selected_of_state(states[1], datetime(2020, 10, 8))
|
137 |
81066065
|
Mikaël Ates
|
not_locked, days_not_locked, not_valide, not_billable, acts_pause, rejected, selected = \
|
138 |
786f0c97
|
Mikaël Ates
|
list_acts_for_billing_CAMSP(datetime(2020, 10, 4), datetime(2020, 10, 8), service_camsp)
|
139 |
|
|
acts_not_locked = [x[0] for x in not_locked[patient_b]]
|
140 |
9c9213df
|
Benjamin Dauvergne
|
self.assertTrue(act5.act in acts_not_locked)
|
141 |
786f0c97
|
Mikaël Ates
|
acts_not_valide = [x[0] for x in not_valide[patient_b]]
|
142 |
9c9213df
|
Benjamin Dauvergne
|
self.assertTrue(act6.act in acts_not_valide)
|
143 |
|
|
self.assertTrue(act7.act in not_billable[patient_b])
|
144 |
786f0c97
|
Mikaël Ates
|
acts_rejected = [x[0] for x in rejected[patient_b]]
|
145 |
9c9213df
|
Benjamin Dauvergne
|
self.assertTrue(act8.act in acts_rejected)
|
146 |
|
|
self.assertTrue(act9.act in acts_rejected)
|
147 |
|
|
self.assertTrue(act10.act in acts_rejected)
|
148 |
|
|
self.assertTrue(act11.act in selected[patient_b])
|
149 |
355359bb
|
Mikaël Ates
|
|
150 |
|
|
def test_facturation_sessad(self):
|
151 |
afb93074
|
Mikaël Ates
|
service_sessad = Service.objects.get(name='SESSAD DYS')
|
152 |
355359bb
|
Mikaël Ates
|
|
153 |
|
|
patient_a = create_patient('a', 'A', service_sessad, self.creator, date_selected=datetime(2020, 10, 5))
|
154 |
76974b6f
|
Benjamin Dauvergne
|
act0 = EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient_a, [self.therapist3],
|
155 |
355359bb
|
Mikaël Ates
|
self.act_type, service_sessad, start_datetime=datetime(2020, 10, 6, 10, 15),
|
156 |
|
|
end_datetime=datetime(2020, 10, 6, 12, 20))
|
157 |
afb93074
|
Mikaël Ates
|
status_traitement = Status.objects.filter(services__name='SESSAD DYS').filter(type='TRAITEMENT')[0]
|
158 |
|
|
patient_a.set_state(status_traitement, self.creator, date_selected=datetime(2020, 10, 7))
|
159 |
76974b6f
|
Benjamin Dauvergne
|
act1 = EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient_a, [self.therapist3],
|
160 |
355359bb
|
Mikaël Ates
|
self.act_type, service_sessad, start_datetime=datetime(2020, 10, 7, 10, 15),
|
161 |
|
|
end_datetime=datetime(2020, 10, 7, 12, 20))
|
162 |
76974b6f
|
Benjamin Dauvergne
|
act2 = EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient_a, [self.therapist3],
|
163 |
355359bb
|
Mikaël Ates
|
self.act_type, service_sessad, start_datetime=datetime(2020, 10, 7, 14, 15),
|
164 |
|
|
end_datetime=datetime(2020, 10, 7, 16, 20))
|
165 |
76974b6f
|
Benjamin Dauvergne
|
act3 = EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient_a, [self.therapist3],
|
166 |
355359bb
|
Mikaël Ates
|
self.act_type, service_sessad, start_datetime=datetime(2020, 10, 7, 16, 20),
|
167 |
|
|
end_datetime=datetime(2020, 10, 7, 17, 20))
|
168 |
afb93074
|
Mikaël Ates
|
status_clos = Status.objects.filter(services__name='SESSAD DYS').filter(type='CLOS')[0]
|
169 |
|
|
patient_a.set_state(status_clos, self.creator, date_selected=datetime(2020, 10, 8))
|
170 |
76974b6f
|
Benjamin Dauvergne
|
act4 = EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient_a, [self.therapist3],
|
171 |
355359bb
|
Mikaël Ates
|
self.act_type, service_sessad, start_datetime=datetime(2020, 10, 8, 10, 15),
|
172 |
|
|
end_datetime=datetime(2020, 10, 8, 12, 20))
|
173 |
|
|
|
174 |
|
|
automated_validation(datetime(2020, 10, 6), service_sessad, self.creator)
|
175 |
|
|
automated_validation(datetime(2020, 10, 7), service_sessad, self.creator)
|
176 |
|
|
automated_validation(datetime(2020, 10, 8), service_sessad, self.creator)
|
177 |
|
|
|
178 |
81066065
|
Mikaël Ates
|
not_locked, days_not_locked, not_valide, not_billable, acts_pause, rejected, missing_valid_notification, selected = \
|
179 |
355359bb
|
Mikaël Ates
|
list_acts_for_billing_SESSAD(datetime(2020, 10, 4), datetime(2020, 10, 8), service_sessad)
|
180 |
|
|
self.assertEqual(not_locked, {})
|
181 |
|
|
self.assertEqual(not_valide, {})
|
182 |
|
|
self.assertEqual(not_billable, {})
|
183 |
|
|
self.assertEqual(len(rejected[patient_a]), 2)
|
184 |
|
|
self.assertEqual(len(missing_valid_notification[patient_a]), 3)
|
185 |
|
|
self.assertEqual(selected, {})
|
186 |
|
|
|
187 |
|
|
SessadHealthCareNotification(patient=patient_a, author=self.creator, start_date=datetime(2020,10,7), end_date=datetime(2021,10,6)).save()
|
188 |
81066065
|
Mikaël Ates
|
not_locked, days_not_locked, not_valide, not_billable, acts_pause, rejected, missing_valid_notification, selected = \
|
189 |
355359bb
|
Mikaël Ates
|
list_acts_for_billing_SESSAD(datetime(2020, 10, 4), datetime(2020, 10, 8), service_sessad)
|
190 |
|
|
self.assertEqual(not_locked, {})
|
191 |
|
|
self.assertEqual(not_valide, {})
|
192 |
|
|
self.assertEqual(not_billable, {})
|
193 |
|
|
self.assertEqual(len(rejected[patient_a]), 2)
|
194 |
|
|
self.assertEqual(missing_valid_notification, {})
|
195 |
|
|
self.assertEqual(len(selected[patient_a]), 3)
|
196 |
9532290e
|
Mikaël Ates
|
|
197 |
|
|
def test_facturation_cmpp(self):
|
198 |
afb93074
|
Mikaël Ates
|
service_cmpp = Service.objects.get(name='CMPP')
|
199 |
9532290e
|
Mikaël Ates
|
|
200 |
|
|
patient_a = create_patient('a', 'A', service_cmpp, self.creator, date_selected=datetime(2020, 10, 1))
|
201 |
76974b6f
|
Benjamin Dauvergne
|
acts = [ EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient_a, [self.therapist3],
|
202 |
9532290e
|
Mikaël Ates
|
self.act_type, service_cmpp, start_datetime=datetime(2020, 10, i, 10, 15),
|
203 |
|
|
end_datetime=datetime(2020, 10, i, 12, 20)) for i in range (1, 32)]
|
204 |
afb93074
|
Mikaël Ates
|
status_accueil = Status.objects.filter(services__name='CMPP').filter(type='ACCUEIL')[0]
|
205 |
|
|
status_diagnostic = Status.objects.filter(services__name='CMPP').filter(type='DIAGNOSTIC')[0]
|
206 |
|
|
status_traitement = Status.objects.filter(services__name='CMPP').filter(type='TRAITEMENT')[0]
|
207 |
|
|
|
208 |
|
|
self.assertEqual(patient_a.get_state().status, status_accueil)
|
209 |
9532290e
|
Mikaël Ates
|
automated_validation(datetime(2020, 10, 1), service_cmpp, self.creator)
|
210 |
bcbe20d1
|
Jérôme Schneider
|
patient_a = PatientRecord.objects.get(id=patient_a.id)
|
211 |
afb93074
|
Mikaël Ates
|
self.assertEqual(patient_a.get_state().status, status_diagnostic)
|
212 |
9532290e
|
Mikaël Ates
|
automated_validation(datetime(2020, 10, 2), service_cmpp, self.creator)
|
213 |
bcbe20d1
|
Jérôme Schneider
|
patient_a = PatientRecord.objects.get(id=patient_a.id)
|
214 |
afb93074
|
Mikaël Ates
|
self.assertEqual(patient_a.get_state().status, status_diagnostic)
|
215 |
9532290e
|
Mikaël Ates
|
automated_validation(datetime(2020, 10, 3), service_cmpp, self.creator)
|
216 |
bcbe20d1
|
Jérôme Schneider
|
patient_a = PatientRecord.objects.get(id=patient_a.id)
|
217 |
afb93074
|
Mikaël Ates
|
self.assertEqual(patient_a.get_state().status, status_diagnostic)
|
218 |
9532290e
|
Mikaël Ates
|
automated_validation(datetime(2020, 10, 4), service_cmpp, self.creator)
|
219 |
bcbe20d1
|
Jérôme Schneider
|
patient_a = PatientRecord.objects.get(id=patient_a.id)
|
220 |
afb93074
|
Mikaël Ates
|
self.assertEqual(patient_a.get_state().status, status_diagnostic)
|
221 |
9532290e
|
Mikaël Ates
|
automated_validation(datetime(2020, 10, 5), service_cmpp, self.creator)
|
222 |
bcbe20d1
|
Jérôme Schneider
|
patient_a = PatientRecord.objects.get(id=patient_a.id)
|
223 |
afb93074
|
Mikaël Ates
|
self.assertEqual(patient_a.get_state().status, status_diagnostic)
|
224 |
9532290e
|
Mikaël Ates
|
automated_validation(datetime(2020, 10, 6), service_cmpp, self.creator)
|
225 |
bcbe20d1
|
Jérôme Schneider
|
patient_a = PatientRecord.objects.get(id=patient_a.id)
|
226 |
afb93074
|
Mikaël Ates
|
self.assertEqual(patient_a.get_state().status, status_diagnostic)
|
227 |
9532290e
|
Mikaël Ates
|
automated_validation(datetime(2020, 10, 7), service_cmpp, self.creator)
|
228 |
bcbe20d1
|
Jérôme Schneider
|
patient_a = PatientRecord.objects.get(id=patient_a.id)
|
229 |
afb93074
|
Mikaël Ates
|
self.assertEqual(patient_a.get_state().status, status_traitement)
|
230 |
9532290e
|
Mikaël Ates
|
automated_validation(datetime(2020, 10, 8), service_cmpp, self.creator)
|
231 |
bcbe20d1
|
Jérôme Schneider
|
patient_a = PatientRecord.objects.get(id=patient_a.id)
|
232 |
afb93074
|
Mikaël Ates
|
self.assertEqual(patient_a.get_state().status, status_traitement)
|
233 |
9532290e
|
Mikaël Ates
|
automated_validation(datetime(2020, 10, 9), service_cmpp, self.creator)
|
234 |
bcbe20d1
|
Jérôme Schneider
|
patient_a = PatientRecord.objects.get(id=patient_a.id)
|
235 |
afb93074
|
Mikaël Ates
|
self.assertEqual(patient_a.get_state().status, status_traitement)
|
236 |
9532290e
|
Mikaël Ates
|
for i in range(10, 32):
|
237 |
|
|
automated_validation(datetime(2020, 10, i), service_cmpp, self.creator)
|
238 |
bcbe20d1
|
Jérôme Schneider
|
patient_a = PatientRecord.objects.get(id=patient_a.id)
|
239 |
afb93074
|
Mikaël Ates
|
self.assertEqual(patient_a.get_state().status, status_traitement)
|
240 |
9532290e
|
Mikaël Ates
|
|
241 |
76974b6f
|
Benjamin Dauvergne
|
acts_2 = [ EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient_a, [self.therapist3],
|
242 |
9532290e
|
Mikaël Ates
|
self.act_type, service_cmpp, start_datetime=datetime(2020, 11, i, 10, 15),
|
243 |
|
|
end_datetime=datetime(2020, 11, i, 12, 20)) for i in range (1, 31)]
|
244 |
|
|
for i in range(1, 31):
|
245 |
|
|
automated_validation(datetime(2020, 11, i), service_cmpp, self.creator)
|
246 |
bcbe20d1
|
Jérôme Schneider
|
patient_a = PatientRecord.objects.get(id=patient_a.id)
|
247 |
afb93074
|
Mikaël Ates
|
self.assertEqual(patient_a.get_state().status, status_traitement)
|
248 |
9532290e
|
Mikaël Ates
|
|
249 |
|
|
self.assertEqual(get_days_with_acts_not_locked(datetime(2020, 10, 1), datetime(2020, 11, 30)), [])
|
250 |
|
|
|
251 |
|
|
acts = acts + acts_2
|
252 |
|
|
|
253 |
|
|
hct = CmppHealthCareTreatment(patient=patient_a, start_date=datetime(2020, 10, 7), author=self.creator)
|
254 |
|
|
hct.save()
|
255 |
|
|
hct.add_prolongation()
|
256 |
b958a9ad
|
Mikaël Ates
|
|
257 |
523c5aaf
|
Mikaël Ates
|
billing_cmpp = list_acts_for_billing_CMPP(datetime(2020, 11, 30), service_cmpp)
|
258 |
b958a9ad
|
Mikaël Ates
|
|
259 |
81066065
|
Mikaël Ates
|
self.assertEqual(len(billing_cmpp[5][patient_a]), 6)
|
260 |
|
|
self.assertEqual(len(billing_cmpp[6][patient_a]), 40)
|
261 |
|
|
self.assertEqual(len(billing_cmpp[7][patient_a]), 15)
|
262 |
afb93074
|
Mikaël Ates
|
|
263 |
b958a9ad
|
Mikaël Ates
|
|
264 |
afb93074
|
Mikaël Ates
|
def test_prices(self):
|
265 |
81066065
|
Mikaël Ates
|
price_o = add_price(120, date(2012, 10, 1))
|
266 |
b958a9ad
|
Mikaël Ates
|
self.assertEqual(PricePerAct.get_price(), 120)
|
267 |
|
|
price_o = add_price(130, date.today())
|
268 |
|
|
self.assertEqual(PricePerAct.get_price(date.today() + relativedelta(days=-1)), 120)
|
269 |
|
|
self.assertEqual(PricePerAct.get_price(date.today()), 130)
|
270 |
|
|
self.assertEqual(PricePerAct.get_price(date.today() + relativedelta(days=1)), 130)
|
271 |
|
|
# price_o = add_price(140, date(day=27, month=11, year=2012))
|
272 |
|
|
price_o = add_price(140, date.today() + relativedelta(days=1))
|
273 |
|
|
self.assertEqual(PricePerAct.get_price(date.today() + relativedelta(days=-1)), 120)
|
274 |
|
|
self.assertEqual(PricePerAct.get_price(date.today()), 130)
|
275 |
|
|
self.assertEqual(PricePerAct.get_price(date.today() + relativedelta(days=1)), 140)
|
276 |
|
|
self.assertEqual(PricePerAct.get_price(date.today() + relativedelta(days=2)), 140)
|
277 |
|
|
|
278 |
|
|
def test_invoicing(self):
|
279 |
|
|
service_cmpp = Service.objects.get(name='CMPP')
|
280 |
81066065
|
Mikaël Ates
|
price_o = add_price(120, date(2012, 10, 1))
|
281 |
b958a9ad
|
Mikaël Ates
|
|
282 |
|
|
|
283 |
|
|
patients = []
|
284 |
|
|
for j in range(2):
|
285 |
81066065
|
Mikaël Ates
|
patients.append(create_patient(str(j), str(j), service_cmpp, self.creator, date_selected=datetime(2012, 10, 1)))
|
286 |
76974b6f
|
Benjamin Dauvergne
|
acts = [ EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patients[j], [self.therapist3],
|
287 |
81066065
|
Mikaël Ates
|
self.act_type, service_cmpp, start_datetime=datetime(2012, 10, i, 10, 15),
|
288 |
|
|
end_datetime=datetime(2012, 10, i, 12, 20)) for i in range (1, 32)]
|
289 |
76974b6f
|
Benjamin Dauvergne
|
acts_2 = [ EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patients[j], [self.therapist3],
|
290 |
81066065
|
Mikaël Ates
|
self.act_type, service_cmpp, start_datetime=datetime(2012, 11, i, 10, 15),
|
291 |
|
|
end_datetime=datetime(2012, 11, i, 12, 20)) for i in range (1, 31)]
|
292 |
|
|
hct = CmppHealthCareTreatment(patient=patients[j], start_date=datetime(2012, 10, 7), author=self.creator)
|
293 |
b958a9ad
|
Mikaël Ates
|
hct.save()
|
294 |
|
|
hct.add_prolongation()
|
295 |
|
|
|
296 |
|
|
for i in range(1, 32):
|
297 |
81066065
|
Mikaël Ates
|
automated_validation(datetime(2012, 10, i), service_cmpp, self.creator)
|
298 |
b958a9ad
|
Mikaël Ates
|
for i in range(1, 31):
|
299 |
81066065
|
Mikaël Ates
|
automated_validation(datetime(2012, 11, i), service_cmpp, self.creator)
|
300 |
b958a9ad
|
Mikaël Ates
|
|
301 |
81066065
|
Mikaël Ates
|
self.assertEqual(get_days_with_acts_not_locked(datetime(2012, 10, 1), datetime(2012, 11, 30)), [])
|
302 |
b958a9ad
|
Mikaël Ates
|
invoicing = Invoicing.objects.create(service=service_cmpp, seq_id=666, start_date=date.today())
|
303 |
|
|
(len_patients, len_invoices, len_invoices_hors_pause,
|
304 |
81066065
|
Mikaël Ates
|
len_acts_invoiced, len_acts_invoiced_hors_pause,
|
305 |
|
|
len_patient_invoiced, len_patient_invoiced_hors_pause,
|
306 |
|
|
len_acts_lost, len_patient_with_lost_acts, patients_stats,
|
307 |
|
|
days_not_locked, len_patient_acts_paused,
|
308 |
|
|
len_acts_paused) = invoicing.get_stats_or_validate()
|
309 |
b958a9ad
|
Mikaël Ates
|
|
310 |
|
|
self.assertEqual(len_patients, 2)
|
311 |
|
|
self.assertEqual(len_invoices, 4)
|
312 |
|
|
self.assertEqual(len_invoices_hors_pause, 4)
|
313 |
|
|
self.assertEqual(len_acts_invoiced, 92) # tous les actes billed
|
314 |
|
|
self.assertEqual(len_acts_invoiced_hors_pause, 92) # tous les actes billed - les acts qui ne seront pas billed à cause de la pause facturation
|
315 |
|
|
self.assertEqual(len_patient_invoiced, 2)
|
316 |
|
|
self.assertEqual(len_patient_invoiced_hors_pause, 2)
|
317 |
|
|
self.assertEqual(len_acts_lost, 30)
|
318 |
|
|
self.assertEqual(len_patient_with_lost_acts, 2)
|
319 |
|
|
|
320 |
|
|
patients[1].pause = True
|
321 |
|
|
patients[1].save()
|
322 |
|
|
|
323 |
|
|
(len_patients, len_invoices, len_invoices_hors_pause,
|
324 |
81066065
|
Mikaël Ates
|
len_acts_invoiced, len_acts_invoiced_hors_pause,
|
325 |
|
|
len_patient_invoiced, len_patient_invoiced_hors_pause,
|
326 |
|
|
len_acts_lost, len_patient_with_lost_acts, patients_stats,
|
327 |
|
|
days_not_locked, len_patient_acts_paused,
|
328 |
|
|
len_acts_paused) = invoicing.get_stats_or_validate()
|
329 |
b958a9ad
|
Mikaël Ates
|
|
330 |
|
|
self.assertEqual(len_patients, 2)
|
331 |
|
|
self.assertEqual(len_invoices, 4)
|
332 |
|
|
self.assertEqual(len_invoices_hors_pause, 2)
|
333 |
|
|
self.assertEqual(len_acts_invoiced, 92) # tous les actes billed
|
334 |
|
|
self.assertEqual(len_acts_invoiced_hors_pause, 46) # tous les actes billed - les acts qui ne seront pas billed à cause de la pause facturation
|
335 |
|
|
self.assertEqual(len_patient_invoiced, 2)
|
336 |
|
|
self.assertEqual(len_patient_invoiced_hors_pause, 1)
|
337 |
|
|
self.assertEqual(len_acts_lost, 30)
|
338 |
|
|
self.assertEqual(len_patient_with_lost_acts, 2)
|
339 |
|
|
|
340 |
81066065
|
Mikaël Ates
|
invoicing_next = invoicing.close(date(day=30, month=11, year=2012))
|
341 |
b958a9ad
|
Mikaël Ates
|
|
342 |
|
|
(len_patients, len_invoices, len_invoices_hors_pause,
|
343 |
81066065
|
Mikaël Ates
|
len_acts_invoiced, len_acts_invoiced_hors_pause,
|
344 |
|
|
len_patient_invoiced, len_patient_invoiced_hors_pause,
|
345 |
|
|
len_acts_lost, len_patient_with_lost_acts, patients_stats,
|
346 |
|
|
days_not_locked, len_patient_acts_paused,
|
347 |
|
|
len_acts_paused) = invoicing.get_stats_or_validate(commit=True)
|
348 |
b958a9ad
|
Mikaël Ates
|
|
349 |
|
|
(len_patients, len_invoices, len_invoices_hors_pause,
|
350 |
81066065
|
Mikaël Ates
|
len_acts_invoiced, len_acts_invoiced_hors_pause,
|
351 |
|
|
len_patient_invoiced, len_patient_invoiced_hors_pause,
|
352 |
|
|
len_acts_lost, len_patient_with_lost_acts, patients_stats,
|
353 |
|
|
days_not_locked, len_patient_acts_paused,
|
354 |
|
|
len_acts_paused) = invoicing.get_stats_or_validate()
|
355 |
b958a9ad
|
Mikaël Ates
|
|
356 |
|
|
self.assertEqual(len_patients, 1)
|
357 |
|
|
self.assertEqual(len_invoices, 2)
|
358 |
|
|
self.assertEqual(len_acts_invoiced, 46)
|
359 |
|
|
|
360 |
|
|
patients[1].pause = False
|
361 |
|
|
patients[1].save()
|
362 |
81066065
|
Mikaël Ates
|
invoicing_next.close(date(day=2, month=12, year=2012))
|
363 |
b958a9ad
|
Mikaël Ates
|
|
364 |
|
|
(len_patients, len_invoices, len_invoices_hors_pause,
|
365 |
81066065
|
Mikaël Ates
|
len_acts_invoiced, len_acts_invoiced_hors_pause,
|
366 |
|
|
len_patient_invoiced, len_patient_invoiced_hors_pause,
|
367 |
|
|
len_acts_lost, len_patient_with_lost_acts, patients_stats,
|
368 |
|
|
days_not_locked, len_patient_acts_paused,
|
369 |
|
|
len_acts_paused) = invoicing_next.get_stats_or_validate()
|
370 |
b958a9ad
|
Mikaël Ates
|
|
371 |
|
|
self.assertEqual(len_patients, 2)
|
372 |
|
|
self.assertEqual(len_invoices, 2)
|
373 |
|
|
self.assertEqual(len_acts_invoiced, 46)
|
374 |
d5f10ddd
|
Mikaël Ates
|
|
375 |
|
|
def test_invoicing2(self):
|
376 |
|
|
service_cmpp = Service.objects.get(name='CMPP')
|
377 |
|
|
price_o = add_price(120, date(2012, 10, 1))
|
378 |
|
|
|
379 |
|
|
|
380 |
|
|
patient = create_patient('A', 'a', service_cmpp, self.creator, date_selected=datetime(2012, 10, 1))
|
381 |
76974b6f
|
Benjamin Dauvergne
|
acts = [ EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient, [self.therapist3],
|
382 |
d5f10ddd
|
Mikaël Ates
|
self.act_type, service_cmpp, start_datetime=datetime(2012, 10, i, 10, 15),
|
383 |
|
|
end_datetime=datetime(2012, 10, i, 12, 20)) for i in range (1, 32)]
|
384 |
|
|
hct = CmppHealthCareTreatment(patient=patient, start_date=datetime(2011, 11, 7), author=self.creator)
|
385 |
|
|
hct.save()
|
386 |
|
|
hct.add_prolongation()
|
387 |
|
|
|
388 |
|
|
for i in range(1, 32):
|
389 |
|
|
automated_validation(datetime(2012, 10, i), service_cmpp, self.creator)
|
390 |
|
|
|
391 |
|
|
self.assertEqual(get_days_with_acts_not_locked(datetime(2012, 10, 1), datetime(2012, 11, 30)), [])
|
392 |
|
|
invoicing = Invoicing.objects.create(service=service_cmpp, seq_id=666, start_date=date.today())
|
393 |
|
|
invoicing_next = invoicing.close(date(day=1, month=11, year=2012))
|
394 |
|
|
(len_patients, len_invoices, len_invoices_hors_pause,
|
395 |
|
|
len_acts_invoiced, len_acts_invoiced_hors_pause,
|
396 |
|
|
len_patient_invoiced, len_patient_invoiced_hors_pause,
|
397 |
|
|
len_acts_lost, len_patient_with_lost_acts, patients_stats,
|
398 |
|
|
days_not_locked, len_patient_acts_paused,
|
399 |
|
|
len_acts_paused) = invoicing.get_stats_or_validate(commit=True)
|
400 |
|
|
|
401 |
|
|
self.assertEqual(len_patients, 1)
|
402 |
|
|
self.assertEqual(len_invoices, 2)
|
403 |
|
|
self.assertEqual(len_invoices_hors_pause, 2)
|
404 |
|
|
self.assertEqual(len_acts_invoiced, 31) # tous les actes billed
|
405 |
|
|
self.assertEqual(len_acts_invoiced_hors_pause, 31) # tous les actes billed - les acts qui ne seront pas billed à cause de la pause facturation
|
406 |
|
|
self.assertEqual(len_patient_invoiced, 1)
|
407 |
|
|
self.assertEqual(len_patient_invoiced_hors_pause, 1)
|
408 |
|
|
self.assertEqual(len_acts_lost, 0)
|
409 |
|
|
self.assertEqual(len_patient_with_lost_acts, 0)
|
410 |
|
|
|
411 |
|
|
|
412 |
76974b6f
|
Benjamin Dauvergne
|
acts_2 = [ EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient, [self.therapist3],
|
413 |
d5f10ddd
|
Mikaël Ates
|
self.act_type, service_cmpp, start_datetime=datetime(2012, 11, i, 10, 15),
|
414 |
|
|
end_datetime=datetime(2012, 11, i, 12, 20)) for i in range (1, 31)]
|
415 |
|
|
|
416 |
|
|
for i in range(1, 31):
|
417 |
|
|
automated_validation(datetime(2012, 11, i), service_cmpp, self.creator)
|
418 |
|
|
|
419 |
|
|
hct = CmppHealthCareTreatment(patient=patient, start_date=datetime(2012, 11, 7), author=self.creator)
|
420 |
|
|
hct.save()
|
421 |
|
|
|
422 |
|
|
# 6 sur hct 1
|
423 |
|
|
# 24 sur hct 2
|
424 |
|
|
|
425 |
|
|
(len_patients, len_invoices, len_invoices_hors_pause,
|
426 |
|
|
len_acts_invoiced, len_acts_invoiced_hors_pause,
|
427 |
|
|
len_patient_invoiced, len_patient_invoiced_hors_pause,
|
428 |
|
|
len_acts_lost, len_patient_with_lost_acts, patients_stats,
|
429 |
|
|
days_not_locked, len_patient_acts_paused,
|
430 |
|
|
len_acts_paused) = invoicing_next.get_stats_or_validate(commit=True)
|
431 |
|
|
|
432 |
|
|
self.assertEqual(len_patients, 1)
|
433 |
|
|
self.assertEqual(len_invoices, 1)
|
434 |
|
|
self.assertEqual(len_invoices_hors_pause, 1)
|
435 |
|
|
self.assertEqual(len_acts_invoiced, 30) # tous les actes billed
|
436 |
|
|
self.assertEqual(len_acts_invoiced_hors_pause, 30) # tous les actes billed - les acts qui ne seront pas billed à cause de la pause facturation
|
437 |
|
|
self.assertEqual(len_patient_invoiced, 1)
|
438 |
|
|
self.assertEqual(len_patient_invoiced_hors_pause, 1)
|
439 |
|
|
self.assertEqual(len_acts_lost, 0)
|
440 |
|
|
self.assertEqual(len_patient_with_lost_acts, 0)
|
441 |
42acd775
|
Mikaël Ates
|
|
442 |
|
|
|
443 |
|
|
def test_change_state(self):
|
444 |
|
|
service_cmpp = Service.objects.get(name='CMPP')
|
445 |
|
|
price_o = add_price(120, date(2012, 10, 1))
|
446 |
|
|
|
447 |
|
|
|
448 |
|
|
patient = create_patient('A', 'a', service_cmpp, self.creator, date_selected=datetime(2012, 10, 1))
|
449 |
|
|
|
450 |
|
|
self.assertEqual(patient.last_state.status.type, "ACCUEIL")
|
451 |
|
|
|
452 |
76974b6f
|
Benjamin Dauvergne
|
EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient, [self.therapist3],
|
453 |
42acd775
|
Mikaël Ates
|
self.act_type, service_cmpp, start_datetime=datetime(2012, 10, 1, 10, 15),
|
454 |
|
|
end_datetime=datetime(2012, 10, 1, 12, 20))
|
455 |
|
|
|
456 |
|
|
automated_validation(datetime(2012, 10, 1), service_cmpp, self.creator)
|
457 |
|
|
patient = PatientRecord.objects.get(id=patient.id)
|
458 |
|
|
|
459 |
|
|
self.assertEqual(patient.last_state.status.type, "DIAGNOSTIC")
|
460 |
|
|
self.assertEqual(patient.last_state.date_selected, datetime(2012, 10, 1, 0, 0))
|
461 |
|
|
|
462 |
76974b6f
|
Benjamin Dauvergne
|
acts = [ EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient, [self.therapist3],
|
463 |
42acd775
|
Mikaël Ates
|
self.act_type, service_cmpp, start_datetime=datetime(2012, 10, i, 10, 15),
|
464 |
|
|
end_datetime=datetime(2012, 10, i, 12, 20)) for i in range (2, 32)]
|
465 |
|
|
|
466 |
|
|
for i in range(2, 32):
|
467 |
|
|
automated_validation(datetime(2012, 10, i), service_cmpp, self.creator)
|
468 |
|
|
|
469 |
|
|
patient = PatientRecord.objects.get(id=patient.id)
|
470 |
|
|
self.assertEqual(patient.last_state.status.type, "TRAITEMENT")
|
471 |
|
|
self.assertEqual(patient.last_state.date_selected, datetime(2012, 10, 7, 0, 0))
|
472 |
|
|
|
473 |
|
|
patient = create_patient('B', 'b', service_cmpp, self.creator, date_selected=datetime(2012, 10, 1))
|
474 |
|
|
|
475 |
|
|
self.assertEqual(patient.last_state.status.type, "ACCUEIL")
|
476 |
|
|
|
477 |
76974b6f
|
Benjamin Dauvergne
|
EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient, [self.therapist3],
|
478 |
42acd775
|
Mikaël Ates
|
self.act_type, service_cmpp, start_datetime=datetime(2012, 10, 1, 10, 15),
|
479 |
|
|
end_datetime=datetime(2012, 10, 1, 12, 20))
|
480 |
|
|
|
481 |
|
|
automated_validation(datetime(2012, 10, 1), service_cmpp, self.creator)
|
482 |
|
|
patient = PatientRecord.objects.get(id=patient.id)
|
483 |
|
|
|
484 |
|
|
self.assertEqual(patient.last_state.status.type, "DIAGNOSTIC")
|
485 |
|
|
self.assertEqual(patient.last_state.date_selected, datetime(2012, 10, 1, 0, 0))
|
486 |
|
|
|
487 |
|
|
status = Status.objects.filter(type="CLOS").\
|
488 |
|
|
filter(services__name='CMPP')[0]
|
489 |
|
|
patient.set_state(status, self.creator, date_selected=datetime(2012, 12, 9, 0, 0))
|
490 |
|
|
|
491 |
|
|
self.assertEqual(patient.last_state.status.type, "CLOS")
|
492 |
|
|
self.assertEqual(patient.last_state.date_selected, datetime(2012, 12, 9, 0, 0))
|
493 |
|
|
|
494 |
76974b6f
|
Benjamin Dauvergne
|
acts = [ EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient, [self.therapist3],
|
495 |
42acd775
|
Mikaël Ates
|
self.act_type, service_cmpp, start_datetime=datetime(2012, 10, i, 10, 15),
|
496 |
|
|
end_datetime=datetime(2012, 10, i, 12, 20)) for i in range (2, 32)]
|
497 |
|
|
|
498 |
|
|
for i in range(2, 32):
|
499 |
|
|
automated_validation(datetime(2012, 10, i), service_cmpp, self.creator)
|
500 |
|
|
|
501 |
|
|
patient = PatientRecord.objects.get(id=patient.id)
|
502 |
|
|
self.assertEqual(patient.last_state.status.type, "CLOS")
|
503 |
|
|
self.assertEqual(patient.last_state.date_selected, datetime(2012, 12, 9, 0, 0))
|
504 |
32dfc9e2
|
Mikaël Ates
|
|
505 |
|
|
def test_change_hc_number(self):
|
506 |
|
|
service_cmpp = Service.objects.get(name='CMPP')
|
507 |
|
|
price_o = add_price(120, date(2012, 10, 1))
|
508 |
|
|
|
509 |
|
|
patient = create_patient('A', 'a', service_cmpp, self.creator, date_selected=datetime(2012, 10, 1))
|
510 |
76974b6f
|
Benjamin Dauvergne
|
acts = [ EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient, [self.therapist3],
|
511 |
32dfc9e2
|
Mikaël Ates
|
self.act_type, service_cmpp, start_datetime=datetime(2012, 10, i, 10, 15),
|
512 |
|
|
end_datetime=datetime(2012, 10, i, 12, 20)) for i in range (1, 4)]
|
513 |
|
|
|
514 |
|
|
for i in range(1, 4):
|
515 |
|
|
automated_validation(datetime(2012, 10, i), service_cmpp, self.creator)
|
516 |
|
|
|
517 |
|
|
invoicing = Invoicing.objects.create(service=service_cmpp, seq_id=666, start_date=date.today())
|
518 |
|
|
invoicing_next = invoicing.close(date(day=4, month=10, year=2012))
|
519 |
|
|
(len_patients, len_invoices, len_invoices_hors_pause,
|
520 |
|
|
len_acts_invoiced, len_acts_invoiced_hors_pause,
|
521 |
|
|
len_patient_invoiced, len_patient_invoiced_hors_pause,
|
522 |
|
|
len_acts_lost, len_patient_with_lost_acts, patients_stats,
|
523 |
|
|
days_not_locked, len_patient_acts_paused,
|
524 |
|
|
len_acts_paused) = invoicing.get_stats_or_validate(commit=True)
|
525 |
|
|
|
526 |
|
|
self.assertEqual(len_patients, 1)
|
527 |
|
|
self.assertEqual(len_invoices, 1)
|
528 |
|
|
self.assertEqual(len_invoices_hors_pause, 1)
|
529 |
|
|
self.assertEqual(len_acts_invoiced, 3) # tous les actes billed
|
530 |
|
|
self.assertEqual(len_acts_invoiced_hors_pause, 3) # tous les actes billed - les acts qui ne seront pas billed à cause de la pause facturation
|
531 |
|
|
self.assertEqual(len_patient_invoiced, 1)
|
532 |
|
|
self.assertEqual(len_patient_invoiced_hors_pause, 1)
|
533 |
|
|
self.assertEqual(len_acts_lost, 0)
|
534 |
|
|
self.assertEqual(len_patient_with_lost_acts, 0)
|
535 |
|
|
|
536 |
|
|
hcd = CmppHealthCareDiagnostic.objects.\
|
537 |
|
|
filter(patient=patient).latest('start_date')
|
538 |
|
|
|
539 |
|
|
self.assertEqual(hcd.get_nb_acts_cared(), 3)
|
540 |
|
|
|
541 |
|
|
try:
|
542 |
|
|
hcd.set_act_number(2)
|
543 |
|
|
raise
|
544 |
|
|
except:
|
545 |
|
|
pass
|
546 |
|
|
|
547 |
|
|
hcd.set_act_number(5)
|
548 |
|
|
|
549 |
76974b6f
|
Benjamin Dauvergne
|
acts = [ EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient, [self.therapist3],
|
550 |
32dfc9e2
|
Mikaël Ates
|
self.act_type, service_cmpp, start_datetime=datetime(2012, 10, i, 10, 15),
|
551 |
|
|
end_datetime=datetime(2012, 10, i, 12, 20)) for i in range (4, 32)]
|
552 |
|
|
|
553 |
|
|
for i in range(4, 32):
|
554 |
|
|
automated_validation(datetime(2012, 10, i), service_cmpp, self.creator)
|
555 |
|
|
|
556 |
|
|
invoicing = Invoicing.objects.create(service=service_cmpp, start_date=date.today())
|
557 |
|
|
invoicing_next = invoicing.close(date(day=1, month=11, year=2012))
|
558 |
|
|
(len_patients, len_invoices, len_invoices_hors_pause,
|
559 |
|
|
len_acts_invoiced, len_acts_invoiced_hors_pause,
|
560 |
|
|
len_patient_invoiced, len_patient_invoiced_hors_pause,
|
561 |
|
|
len_acts_lost, len_patient_with_lost_acts, patients_stats,
|
562 |
|
|
days_not_locked, len_patient_acts_paused,
|
563 |
|
|
len_acts_paused) = invoicing.get_stats_or_validate(commit=True)
|
564 |
|
|
|
565 |
|
|
self.assertEqual(len_patients, 1)
|
566 |
|
|
self.assertEqual(len_invoices, 1)
|
567 |
|
|
self.assertEqual(len_invoices_hors_pause, 1)
|
568 |
|
|
self.assertEqual(len_acts_invoiced, 2) # tous les actes billed
|
569 |
|
|
self.assertEqual(len_acts_invoiced_hors_pause, 2) # tous les actes billed - les acts qui ne seront pas billed à cause de la pause facturation
|
570 |
|
|
self.assertEqual(len_patient_invoiced, 1)
|
571 |
|
|
self.assertEqual(len_patient_invoiced_hors_pause, 1)
|
572 |
|
|
self.assertEqual(len_acts_lost, 26)
|
573 |
|
|
self.assertEqual(len_patient_with_lost_acts, 1)
|
574 |
|
|
|
575 |
|
|
hct = CmppHealthCareTreatment(patient=patient, start_date=datetime(2012, 10, 1), author=self.creator)
|
576 |
|
|
hct.save()
|
577 |
|
|
|
578 |
|
|
invoicing = Invoicing.objects.create(service=service_cmpp, start_date=date.today())
|
579 |
|
|
invoicing_next = invoicing.close(date(day=2, month=11, year=2012))
|
580 |
|
|
(len_patients, len_invoices, len_invoices_hors_pause,
|
581 |
|
|
len_acts_invoiced, len_acts_invoiced_hors_pause,
|
582 |
|
|
len_patient_invoiced, len_patient_invoiced_hors_pause,
|
583 |
|
|
len_acts_lost, len_patient_with_lost_acts, patients_stats,
|
584 |
|
|
days_not_locked, len_patient_acts_paused,
|
585 |
|
|
len_acts_paused) = invoicing.get_stats_or_validate(commit=True)
|
586 |
|
|
|
587 |
|
|
self.assertEqual(len_patients, 1)
|
588 |
|
|
self.assertEqual(len_invoices, 1)
|
589 |
|
|
self.assertEqual(len_invoices_hors_pause, 1)
|
590 |
|
|
self.assertEqual(len_acts_invoiced, 26) # tous les actes billed
|
591 |
|
|
self.assertEqual(len_acts_invoiced_hors_pause, 26) # tous les actes billed - les acts qui ne seront pas billed à cause de la pause facturation
|
592 |
|
|
self.assertEqual(len_patient_invoiced, 1)
|
593 |
|
|
self.assertEqual(len_patient_invoiced_hors_pause, 1)
|
594 |
|
|
self.assertEqual(len_acts_lost, 0)
|
595 |
|
|
self.assertEqual(len_patient_with_lost_acts, 0)
|
596 |
|
|
|
597 |
|
|
try:
|
598 |
|
|
hct.set_act_number(24)
|
599 |
|
|
raise
|
600 |
|
|
except:
|
601 |
|
|
pass
|
602 |
|
|
|
603 |
|
|
hct.set_act_number(28)
|
604 |
|
|
|
605 |
76974b6f
|
Benjamin Dauvergne
|
acts = [ EventWithAct.objects.create_patient_appointment(self.creator, 'RDV', patient, [self.therapist3],
|
606 |
32dfc9e2
|
Mikaël Ates
|
self.act_type, service_cmpp, start_datetime=datetime(2012, 11, i, 10, 15),
|
607 |
|
|
end_datetime=datetime(2012, 11, i, 12, 20)) for i in range (1, 4)]
|
608 |
|
|
|
609 |
|
|
for i in range(1, 4):
|
610 |
|
|
automated_validation(datetime(2012, 11, i), service_cmpp, self.creator)
|
611 |
|
|
|
612 |
|
|
invoicing = Invoicing.objects.create(service=service_cmpp, start_date=date.today())
|
613 |
|
|
invoicing_next = invoicing.close(date(day=3, month=11, year=2012))
|
614 |
|
|
(len_patients, len_invoices, len_invoices_hors_pause,
|
615 |
|
|
len_acts_invoiced, len_acts_invoiced_hors_pause,
|
616 |
|
|
len_patient_invoiced, len_patient_invoiced_hors_pause,
|
617 |
|
|
len_acts_lost, len_patient_with_lost_acts, patients_stats,
|
618 |
|
|
days_not_locked, len_patient_acts_paused,
|
619 |
|
|
len_acts_paused) = invoicing.get_stats_or_validate(commit=True)
|
620 |
|
|
|
621 |
|
|
self.assertEqual(len_patients, 1)
|
622 |
|
|
self.assertEqual(len_invoices, 1)
|
623 |
|
|
self.assertEqual(len_invoices_hors_pause, 1)
|
624 |
|
|
self.assertEqual(len_acts_invoiced, 2) # tous les actes billed
|
625 |
|
|
self.assertEqual(len_acts_invoiced_hors_pause, 2) # tous les actes billed - les acts qui ne seront pas billed à cause de la pause facturation
|
626 |
|
|
self.assertEqual(len_patient_invoiced, 1)
|
627 |
|
|
self.assertEqual(len_patient_invoiced_hors_pause, 1)
|
628 |
|
|
self.assertEqual(len_acts_lost, 1)
|
629 |
|
|
self.assertEqual(len_patient_with_lost_acts, 1)
|