1
|
function add_datepickers(that) {
|
2
|
$('input#id_birthdate', that).datepicker({dateFormat: 'd/m/yy', showOn: 'button',
|
3
|
changeMonth: true, changeYear: true, yearRange: 'c-80:c+2' });
|
4
|
$('input#id_start_date', that).datepicker({dateFormat: 'd/m/yy', showOn: 'button' });
|
5
|
$('input#id_request_date', that).datepicker({dateFormat: 'd/m/yy', showOn: 'button' });
|
6
|
$('input#id_agree_date', that).datepicker({dateFormat: 'd/m/yy', showOn: 'button' });
|
7
|
$('input#id_insist_date', that).datepicker({dateFormat: 'd/m/yy', showOn: 'button' });
|
8
|
$('input#id_end_date', that).datepicker({dateFormat: 'd/m/yy', showOn: 'button' });
|
9
|
$('input#id_date_selected', that).datepicker({dateFormat: 'd/m/yy', showOn: 'button' });
|
10
|
$('input#id_prolongation_date', that).datepicker({dateFormat: 'd/m/yy', showOn: 'button' });
|
11
|
}
|
12
|
|
13
|
function load_add_address_dialog() {
|
14
|
var str = $("#contactform").serialize();
|
15
|
$.cookie('contactform', str, { path: window.location.pathname });
|
16
|
generic_ajaxform_dialog('address/new', 'Ajouter une adresse',
|
17
|
'#address-dlg', '600px', 'Ajouter');
|
18
|
}
|
19
|
|
20
|
function state_dialog(url, state_title, state_type) {
|
21
|
$('#change-record').load(url,
|
22
|
function () {
|
23
|
var patient_id = $(this).data('id');
|
24
|
var service_id = $(this).data('service-id');
|
25
|
function onsuccess(response, status, xhr, form) {
|
26
|
var parse = $(response);
|
27
|
if ($('.errorlist', parse).length != 0) {
|
28
|
$('#change-record').html(response);
|
29
|
$('#change-record form').ajaxForm({
|
30
|
success: onsuccess,
|
31
|
data: { patient_id: patient_id, state_type: state_type, service_id: service_id }
|
32
|
});
|
33
|
} else {
|
34
|
window.location.reload(true);
|
35
|
}
|
36
|
}
|
37
|
if (state_type == 'CLOS_RDV') {
|
38
|
var message = $('p.message')
|
39
|
message.append($('<span id="highlight">Attention ce patient a encore des rendez-vous de planifiés !</span>'));
|
40
|
state_type = 'CLOS';
|
41
|
}
|
42
|
$('input.date', this).datepicker({dateFormat: 'd/m/yy', showOn: 'button' });
|
43
|
$('form', this).ajaxForm({
|
44
|
success: onsuccess,
|
45
|
data: { patient_id: patient_id, state_type: state_type, service_id: service_id }
|
46
|
});
|
47
|
$(this).dialog({title: "Changement - " + state_title,
|
48
|
width: '500px',
|
49
|
buttons: [ { text: "Annuler",
|
50
|
click: function() { $(this).dialog("close"); } },
|
51
|
{ text: "Valider",
|
52
|
click: function() { $("#change-record form").submit(); } }]});
|
53
|
});
|
54
|
}
|
55
|
|
56
|
function load_tab1_general() {
|
57
|
$('#update-paper-id-btn').click(function() {
|
58
|
generic_ajaxform_dialog('update/paper_id', 'Modifier le numéro du dossier papier',
|
59
|
'#ajax-dlg', '500px', 'Modifier');
|
60
|
});
|
61
|
$('#close-patientrecord').click(function() {
|
62
|
state_dialog('update-state', 'Clore', 'CLOS');
|
63
|
});
|
64
|
$('#close-rdv-patientrecord').click(function() {
|
65
|
state_dialog('update-state', 'Clore', 'CLOS_RDV');
|
66
|
});
|
67
|
$('#reopen-patientrecord').click(function() {
|
68
|
state_dialog('update-state', 'Réaccueil', 'ACCUEIL');
|
69
|
});
|
70
|
$('#diagnostic-patientrecord').click(function() {
|
71
|
state_dialog('update-state', 'Diagnostic', 'DIAGNOSTIC');
|
72
|
});
|
73
|
$('#traitement-patientrecord').click(function() {
|
74
|
state_dialog('update-state', 'Traitement', 'TRAITEMENT');
|
75
|
});
|
76
|
$('#finaccueil-patientrecord').click(function() {
|
77
|
state_dialog('update-state', "Fin d'accueil", 'FIN_ACCUEIL');
|
78
|
});
|
79
|
$('#bilan-patientrecord').click(function() {
|
80
|
state_dialog('update-state', 'Bilan', 'BILAN');
|
81
|
});
|
82
|
$('#surveillance-patientrecord').click(function() {
|
83
|
state_dialog('update-state', 'Surveillance', 'SURVEILLANCE');
|
84
|
});
|
85
|
$('#suivi-patientrecord').click(function() {
|
86
|
state_dialog('update-state', 'Suivi', 'SUIVI');
|
87
|
});
|
88
|
$('#patientrecord-history').click(function() {
|
89
|
$('#dossier-histo-dlg').dialog({title: 'Historique dossier',
|
90
|
width: '500px',
|
91
|
buttons: [ { text: "Fermer",
|
92
|
click: function() { $(this).dialog("close"); } }]}
|
93
|
);
|
94
|
});
|
95
|
if (location.hash.indexOf('histo') != -1) {
|
96
|
$('#patientrecord-history').click();
|
97
|
location.hash = '';
|
98
|
}
|
99
|
$('#id_pause').click(function() {
|
100
|
$('#general-form').submit();
|
101
|
});
|
102
|
$('#id_confidential').click(function() {
|
103
|
$('#general-form').submit();
|
104
|
});
|
105
|
}
|
106
|
|
107
|
function load_tab2_adm() {
|
108
|
init_magic_dialog();
|
109
|
$('#prescription-transport-btn').click(function() {
|
110
|
$('#ajax-dlg').load('prescription-transport',
|
111
|
function () {
|
112
|
$(this).dialog({title: 'Prescription de transport', width: '800px',
|
113
|
buttons: [ { text: "Fermer",
|
114
|
click: function() { $(this).dialog("close"); } },
|
115
|
{ text: "Prescrire",
|
116
|
click: function() { $("#ajax-dlg form").submit(); $(this).dialog("close"); } }]});
|
117
|
$('.addresses input[type=radio]').first().click();
|
118
|
});
|
119
|
return false;
|
120
|
});
|
121
|
$('#new-protection-btn').click(function() {
|
122
|
generic_ajaxform_dialog('protection/new', 'Ajouter une mesure de protection',
|
123
|
'#ajax-dlg', '800px', 'Ajouter', null, add_datepickers);
|
124
|
});
|
125
|
$('.update-protection-btn').click(function() {
|
126
|
generic_ajaxform_dialog('protection/' + $(this).data('id') + '/update', 'Modifier une mesure de protection',
|
127
|
'#ajax-dlg', '800px', 'Modifier', null, add_datepickers);
|
128
|
});
|
129
|
$('.del-protection').click(function() {
|
130
|
generic_ajaxform_dialog('protection/' + $(this).data('id') + '/del', 'Supprimer une mesure de protection',
|
131
|
'#ajax-dlg', '500px', 'Supprimer');
|
132
|
});
|
133
|
$('input#id_id-birthdate').datepicker({dateFormat: 'd/m/yy', showOn: 'button' });
|
134
|
calebasse_ajax_form('#tabs-2');
|
135
|
}
|
136
|
|
137
|
function load_tab3_addresses() {
|
138
|
function nir_check(that) {
|
139
|
add_datepickers($(that));
|
140
|
$(that).find('#social-security-id input').keyup(function() {
|
141
|
if ($(this).val().length < 13) {
|
142
|
$('p#nir-key span').removeAttr('id')
|
143
|
$('p#nir-key span').text('-');
|
144
|
} else {
|
145
|
$('p#nir-key span').attr('id', 'highlight')
|
146
|
var nir = $(this).val();
|
147
|
var minus = 0;
|
148
|
if (nir.charAt(6) == 'A'){
|
149
|
nir = nir.replace('A', '0');
|
150
|
minus = 1000000;
|
151
|
}
|
152
|
if (nir.charAt(6) == 'B'){
|
153
|
nir = nir.replace('B', '0');
|
154
|
minus = 2000000;
|
155
|
}
|
156
|
nir = parseInt(nir, 10);
|
157
|
nir = nir - minus;
|
158
|
var key = 97 - (nir % 97);
|
159
|
if (isNaN(key)) {
|
160
|
$('p#nir-key span').text('NIR invalide');
|
161
|
} else {
|
162
|
$('p#nir-key span').text(key);
|
163
|
}
|
164
|
}
|
165
|
});
|
166
|
}
|
167
|
$('.policyholder-radio').click(function() {
|
168
|
$("#policyholder-form").submit();
|
169
|
});
|
170
|
$('#new-contact-btn').click(function() {
|
171
|
generic_ajaxform_dialog('contact/new', 'Ajouter un contact',
|
172
|
'#ajax-dlg', '900px', 'Ajouter', null, nir_check, 850);
|
173
|
});
|
174
|
$('.update-contact-btn').click(function() {
|
175
|
generic_ajaxform_dialog('contact/' + $(this).data('id') + '/update', 'Modifier un contact',
|
176
|
'#ajax-dlg', '800px', 'Modifier', null, nir_check);
|
177
|
});
|
178
|
$('.del-contact').click(function() {
|
179
|
generic_ajaxform_dialog('contact/' + $(this).data('id') + '/del?address=' + $(this).data('address-id'),
|
180
|
'Supprimer un contact', '#ajax-dlg', '500px', 'Supprimer');
|
181
|
});
|
182
|
$('#new-address-btn').click(function() {
|
183
|
generic_ajaxform_dialog('address/new', 'Ajouter une adresse',
|
184
|
'#ajax-dlg', '600px', 'Ajouter');
|
185
|
});
|
186
|
$('.update-address-btn').click(function() {
|
187
|
generic_ajaxform_dialog('address/' + $(this).data('id') + '/update', 'Modifier une adresse',
|
188
|
'#ajax-dlg', '600px', 'Modifier');
|
189
|
});
|
190
|
$('.del-address').click(function() {
|
191
|
generic_ajaxform_dialog('address/' + $(this).data('id') + '/del', 'Supprimer une addresse',
|
192
|
'#ajax-dlg', '500px', 'Supprimer');
|
193
|
});
|
194
|
|
195
|
|
196
|
$('.place_of_life').click(function() {
|
197
|
if ((this.checked) == true) {
|
198
|
var value = "true";
|
199
|
} else {
|
200
|
var value = "false";
|
201
|
}
|
202
|
var prev = $(this).prev();
|
203
|
$.ajax({
|
204
|
url: '/api/v1/patientaddress/' + $(this).data("id") + '/?format=json',
|
205
|
type: 'PATCH',
|
206
|
async: false,
|
207
|
contentType: 'application/json',
|
208
|
data: '{"place_of_life": ' + value + '}',
|
209
|
success: function(data) {
|
210
|
(prev).show();
|
211
|
(prev).html('<li>Modification appliquée avec succés</li>');
|
212
|
$('.ajax_messages').delay(1500).fadeOut('slow');
|
213
|
location.reload();
|
214
|
}
|
215
|
});
|
216
|
});
|
217
|
$('.social-security-label').click(function() {
|
218
|
var label = $(this).html();
|
219
|
var data = $(this).next();
|
220
|
if (($(data).is(':hidden'))) {
|
221
|
$(this).html(label.replace('+', '-'));
|
222
|
$(this).css("font-weight", "bold");
|
223
|
} else {
|
224
|
$(this).html(label.replace('-', '+'));
|
225
|
$(this).css("font-weight", "");
|
226
|
}
|
227
|
$(data).toggle();
|
228
|
});
|
229
|
var hashes = location.hash.split('&');
|
230
|
for (i in hashes) {
|
231
|
if (hashes[i] == "newcontact") {
|
232
|
var form = $.cookie('contactform');
|
233
|
generic_ajaxform_dialog('contact/new?'+ form, 'Ajouter un contact',
|
234
|
'#ajax-dlg', '900px', 'Ajouter', null, nir_check, 850);
|
235
|
$.removeCookie('contactform', { path: window.location.pathname });
|
236
|
}
|
237
|
}
|
238
|
location.hash = hashes[0];
|
239
|
}
|
240
|
|
241
|
function load_tab4_notifs() {
|
242
|
$('#new-hctrait-btn').click(function() {
|
243
|
generic_ajaxform_dialog('healthcare_treatment/new', 'Ajouter une prise en charge de traitement',
|
244
|
'#ajax-dlg', '600px', 'Ajouter', null, add_datepickers);
|
245
|
});
|
246
|
$('#new-hcdiag-btn').click(function() {
|
247
|
generic_ajaxform_dialog('healthcare_diagnostic/new', 'Ajouter une prise en charge de diagnostic',
|
248
|
'#ajax-dlg', '600px', 'Ajouter', null, add_datepickers);
|
249
|
});
|
250
|
$('#new-notification-btn').click(function() {
|
251
|
generic_ajaxform_dialog('healthcare_notification/new', 'Ajouter une notification',
|
252
|
'#ajax-dlg', '600px', 'Ajouter', null, add_datepickers);
|
253
|
});
|
254
|
$('.update-hctrait-btn').click(function() {
|
255
|
generic_ajaxform_dialog('healthcare_treatment/' + $(this).data('id') + '/update', 'Modifier une prise en charge de traitement',
|
256
|
'#ajax-dlg', '800px', 'Modifier', null, add_datepickers);
|
257
|
});
|
258
|
$('.update-hcdiag-btn').click(function() {
|
259
|
generic_ajaxform_dialog('healthcare_diagnostic/' + $(this).data('id') + '/update', 'Modifier une prise en charge de diagnostic',
|
260
|
'#ajax-dlg', '800px', 'Modifier', null, add_datepickers);
|
261
|
});
|
262
|
$('.update-notification-btn').click(function() {
|
263
|
generic_ajaxform_dialog('healthcare_notification/' + $(this).data('id') + '/update', 'Modifier une notification',
|
264
|
'#ajax-dlg', '800px', 'Modifier', null, add_datepickers);
|
265
|
});
|
266
|
$('.del-hctrait').click(function() {
|
267
|
generic_ajaxform_dialog('healthcare_treatment/' + $(this).data('id') + '/del', 'Supprimer une prise en charge de traitement',
|
268
|
'#ajax-dlg', '500px', 'Supprimer');
|
269
|
});
|
270
|
$('.del-hcdiag').click(function() {
|
271
|
generic_ajaxform_dialog('healthcare_diagnostic/' + $(this).data('id') + '/del', 'Supprimer une prise en charge de diagnostic',
|
272
|
'#ajax-dlg', '500px', 'Supprimer');
|
273
|
});
|
274
|
$('.del-notification').click(function() {
|
275
|
generic_ajaxform_dialog('healthcare_notification/' + $(this).data('id') + '/del', 'Supprimer une notification',
|
276
|
'#ajax-dlg', '500px', 'Supprimer');
|
277
|
});
|
278
|
|
279
|
}
|
280
|
|
281
|
function load_tab5_last_acts() {
|
282
|
}
|
283
|
|
284
|
function load_tab6_next_rdv() {
|
285
|
}
|
286
|
|
287
|
function load_tab7_socialisation() {
|
288
|
$('#new-socialisation-duration-btn').click(function() {
|
289
|
generic_ajaxform_dialog('socialisation/new', 'Ajouter une période de socialisation',
|
290
|
'#ajax-dlg', '800px', 'Ajouter', null, add_datepickers);
|
291
|
});
|
292
|
$('.update-duration-btn').click(function() {
|
293
|
generic_ajaxform_dialog('socialisation/' + $(this).data('id') + '/update', 'Modifier une période de socialisation',
|
294
|
'#ajax-dlg', '800px', 'Modifier', null, add_datepickers);
|
295
|
});
|
296
|
$('.del-duration').click(function() {
|
297
|
generic_ajaxform_dialog('socialisation/' + $(this).data('id') + '/del', 'Supprimer une période de socialisation',
|
298
|
'#ajax-dlg', '500px', 'Supprimer');
|
299
|
});
|
300
|
$('#new-mdph-request-btn').click(function() {
|
301
|
generic_ajaxform_dialog('mdph_request/new', 'Ajouter une demande MDPH',
|
302
|
'#ajax-dlg', '800px', 'Ajouter', null, add_datepickers);
|
303
|
});
|
304
|
$('.update-mdph-request-btn').click(function() {
|
305
|
generic_ajaxform_dialog('mdph_request/' + $(this).data('id') + '/update', 'Modifier une demande MDPH',
|
306
|
'#ajax-dlg', '800px', 'Modifier', null, add_datepickers);
|
307
|
});
|
308
|
$('.del-mdph-request').click(function() {
|
309
|
generic_ajaxform_dialog('mdph_request/' + $(this).data('id') + '/del', 'Supprimer une demande MDPH',
|
310
|
'#ajax-dlg', '500px', 'Supprimer');
|
311
|
});
|
312
|
$('#new-mdph-response-btn').click(function() {
|
313
|
generic_ajaxform_dialog('mdph_response/new', 'Ajouter une réponse MDPH',
|
314
|
'#ajax-dlg', '800px', 'Ajouter', null, add_datepickers);
|
315
|
});
|
316
|
$('.update-mdph-response-btn').click(function() {
|
317
|
generic_ajaxform_dialog('mdph_response/' + $(this).data('id') + '/update', 'Modifier une réponse MDPH',
|
318
|
'#ajax-dlg', '800px', 'Modifier', null, add_datepickers);
|
319
|
});
|
320
|
$('.del-mdph-response').click(function() {
|
321
|
generic_ajaxform_dialog('mdph_response/' + $(this).data('id') + '/del', 'Supprimer une réponse MDPH',
|
322
|
'#ajax-dlg', '500px', 'Supprimer');
|
323
|
});
|
324
|
}
|
325
|
|
326
|
function load_tab8_medical() {
|
327
|
calebasse_ajax_form('#tabs-8');
|
328
|
SelectFilter.init("id_mises_1", "Catégorie", 0, "/static/admin/");
|
329
|
SelectFilter.init("id_mises_2", "Catégorie", 0, "/static/admin/");
|
330
|
SelectFilter.init("id_mises_3", "Catégorie", 0, "/static/admin/");
|
331
|
}
|
332
|
|
333
|
|
334
|
(function($) {
|
335
|
$(function() {
|
336
|
var $tabs = $('#tabs').tabs({
|
337
|
load: function(event, ui) {
|
338
|
var tabid = $(ui.tab).attr('id');
|
339
|
if (tabid == "ui-id-1")
|
340
|
load_tab1_general();
|
341
|
else if (tabid == "ui-id-2")
|
342
|
load_tab2_adm();
|
343
|
else if (tabid == "ui-id-3")
|
344
|
load_tab3_addresses();
|
345
|
else if (tabid == "ui-id-4")
|
346
|
load_tab4_notifs();
|
347
|
else if (tabid == "ui-id-7")
|
348
|
load_tab7_socialisation();
|
349
|
else if (tabid == "ui-id-8")
|
350
|
load_tab8_medical();
|
351
|
},
|
352
|
selected: -1,
|
353
|
collapsible: true,
|
354
|
});
|
355
|
|
356
|
|
357
|
$('.atabs').click(function() {
|
358
|
location.hash = 'tab=' + $(this).data('id');
|
359
|
});
|
360
|
|
361
|
$('#btn_all_state').click(function() {
|
362
|
$('.checkbox_state').attr('checked', true);
|
363
|
});
|
364
|
$('#btn_none_state').click(function() {
|
365
|
$('.checkbox_state').attr('checked', false);
|
366
|
});
|
367
|
$('.checkbox_state').click(function() {
|
368
|
$("#search").click();
|
369
|
});
|
370
|
|
371
|
$('.pr-line').click(function() {
|
372
|
window.open($(this).data('link'), $(this).data('link'));
|
373
|
});
|
374
|
$('button#reset').click(function() {
|
375
|
window.location.href = window.location.pathname;
|
376
|
return false;
|
377
|
});
|
378
|
$('#print-button').click(function() {
|
379
|
var button = $(this);
|
380
|
var title = button.html();
|
381
|
button.html('Préparation de l\'impression en cours');
|
382
|
button.attr({disabled: 'disabled'});
|
383
|
button.toggleClass('icon-wip');
|
384
|
$('.pagination').next().remove();
|
385
|
$.get(window.location + '&all', function(data) {
|
386
|
button.toggleClass('icon-wip');
|
387
|
button.removeAttr('disabled');
|
388
|
button.html(title);
|
389
|
$('.content').append(data);
|
390
|
window.print();
|
391
|
});
|
392
|
});
|
393
|
|
394
|
$('#new-patientrecord').click(function() {
|
395
|
generic_ajaxform_dialog('new', 'Nouveau dossier',
|
396
|
'#dossier-dlg', '700px', 'Ajouter', false, function(that) {
|
397
|
$('input#id_date_selected', that).datepicker({dateFormat: 'd/m/yy', showOn: 'button' });
|
398
|
$(that).find('#id_last_name').keyup(function() {
|
399
|
var val = $(this).val();
|
400
|
if (val.length < 3) {
|
401
|
$(that).find('#last_name_matches').empty();
|
402
|
return;
|
403
|
}
|
404
|
$.ajax({
|
405
|
url: "/lookups/ajax_lookup/patientrecord?term=" + val,
|
406
|
success: function(json) {
|
407
|
var list = $(that).find('#last_name_matches');
|
408
|
list.empty();
|
409
|
$(eval(json)).each(function(a, b) {
|
410
|
list.append($('<li><a href="' + b.pk + '/view" target="new">' + b.value + '</a></li>'));
|
411
|
});
|
412
|
}
|
413
|
});
|
414
|
});
|
415
|
});
|
416
|
});
|
417
|
$('#patientrecord-delete').click(function() {
|
418
|
generic_ajaxform_dialog('delete', 'Supprimer le dossier',
|
419
|
'#ajax-dlg', '500px', 'Oui', '..');
|
420
|
});
|
421
|
|
422
|
|
423
|
$('.update-patient-state-btn').click(function() {
|
424
|
generic_ajaxform_dialog('state/' + $(this).data('id') + '/update', 'Modifier un état',
|
425
|
'#ajax-dlg', '500px', 'Modifier', '#histo', add_datepickers);
|
426
|
});
|
427
|
$('.del-patient-state-btn').click(function() {
|
428
|
generic_ajaxform_dialog('state/' + $(this).data('id') + '/del', 'Supprimer un état',
|
429
|
'#ajax-dlg', '500px', 'Supprimer', '#histo');
|
430
|
});
|
431
|
|
432
|
$('button.blind').next().hide();
|
433
|
$('button.blind').click(function() {
|
434
|
$(this).next().toggle('blind');
|
435
|
});
|
436
|
var tabid = $.url($(location).attr('href')).fparam('tab');
|
437
|
if (tabid) {
|
438
|
$tabs.tabs('select', parseInt(tabid));
|
439
|
}
|
440
|
else {
|
441
|
$tabs.tabs('select', 0);
|
442
|
}
|
443
|
});
|
444
|
|
445
|
})(window.jQuery)
|
446
|
|