Revision b4310641
Added by Mikaël Ates almost 12 years ago
calebasse/dossiers/forms.py | ||
---|---|---|
355 | 355 |
class GenerateRtfForm(Form): |
356 | 356 |
template_filename = forms.ChoiceField(choices=AvailableRtfTemplates()) |
357 | 357 |
address = forms.CharField(widget=forms.Textarea(attrs={'rows':5}), required=False) |
358 |
first_name = forms.CharField(required=False) |
|
359 |
last_name = forms.CharField(required=False) |
|
360 |
birthdate = forms.CharField(required=False) |
|
361 |
appointment_date = forms.CharField(required=False) |
|
362 |
appointment_begin_hour = forms.CharField(required=False) |
|
363 |
appointment_intervenants = forms.CharField(required=False) |
|
358 |
phone_address = forms.CharField(required=False) |
|
364 | 359 |
|
365 | 360 |
class QuotationsForm(Form): |
366 | 361 |
|
calebasse/dossiers/templates/dossiers/generate_rtf_form.html | ||
---|---|---|
16 | 16 |
|
17 | 17 |
<h3>Patient</h3> |
18 | 18 |
|
19 |
<input type="hidden" name="first_name" value="{{ object.first_name }}" /> |
|
20 |
<input type="hidden" name="last_name" value="{{ object.last_name }}" /> |
|
21 |
<input type="hidden" name="birthdate" value="{{ object.birthdate|date:"d/m/Y" }}" /> |
|
22 |
|
|
23 | 19 |
<ul> |
24 | 20 |
<li>{{ object.first_name }} <span class="lastname">{{ object.last_name }}</span></li> |
25 | 21 |
{% if object.birthdate %} |
... | ... | |
31 | 27 |
|
32 | 28 |
<ul class="addresses"> |
33 | 29 |
{% for address in object.addresses.all %} |
34 |
{% if address.place_of_life %}<li>{{ address.display_name }} |
|
30 |
{% if address.place_of_life %}<li>{{ address.display_name }}{% if address.phone %}(Tél : {{ address.phone }}){% endif %}
|
|
35 | 31 |
<ul> |
36 | 32 |
{% for contact in address.patientcontact_set.all %} |
37 | 33 |
<li><input type="radio" name="contact" id="contact_{{ address.id }}_{{ contact.id }}" |
... | ... | |
40 | 36 |
{% if address.address_complement %}data-address-address-complement="{{ address.address_complement }}"{% endif %} |
41 | 37 |
{% if address.zip_code %}data-address-zip-code="{{ address.zip_code }}"{% endif %} |
42 | 38 |
{% if address.city %}data-address-city="{{ address.city }}"{% endif %} |
39 |
{% if address.phone %}data-address-phone="{{ address.phone }}"{% endif %} |
|
43 | 40 |
{% if contact.gender %}data-contact-gender={% if contact.gender == 1 %}"Monsieur"{% elif contact.gender == 2 %}"Madame"{% endif %}{% endif %} |
44 | 41 |
{% if contact.first_name %}data-contact-first-name="{{ contact.first_name }}"{% endif %} |
45 | 42 |
{% if contact.last_name %}data-contact-last-name="{{ contact.last_name }}"{% endif %} |
46 |
><label for="contact_{{ address.id }}_{{ contact.id }}">{% if contact.gender == 1 %}M. {% elif contact.gender == 2 %}Mme {% endif %}{% if contact.first_name %}{{ contact.first_name }} {% endif %}<span class="lastname">{{ contact.last_name }}</span> {% if contact.id == object.id %} (PATIENT){% endif %}</label></input></li>
|
|
43 |
><label for="contact_{{ address.id }}_{{ contact.id }}">{% if contact.gender == 1 %}M. {% elif contact.gender == 2 %}Mme {% endif %}{% if contact.first_name %}{{ contact.first_name }} {% endif %}<span class="lastname">{{ contact.last_name }}</span>{% if contact.mobile %} (Perso : {{ contact.mobile }}){% endif %}{% if contact.phone %} (Pro : {{ contact.phone }}){% endif %}{% if contact.id == object.id %} (PATIENT){% endif %}{% if object.policyholder.id == contact.id %} (ASSURE){% endif %}</label></input></li>
|
|
47 | 44 |
{% endfor %} |
48 | 45 |
</ul> |
49 | 46 |
</li>{% endif %} |
... | ... | |
52 | 49 |
|
53 | 50 |
{{ form.address }} |
54 | 51 |
|
52 |
<p><label>Téléphone : </label><input id="id_phone_address" type="text" name="phone_address" value=""/></p> |
|
53 |
|
|
55 | 54 |
{% if appointment %} |
56 | 55 |
<h3>Rendez-vous</h3> |
57 | 56 |
|
58 |
<input type="hidden" name="appointment_date" value="{{ appointment.date }}" /> |
|
59 |
<input type="hidden" name="appointment_begin_hour" value="{{ appointment.begin_hour }}" /> |
|
60 |
<input type="hidden" name="appointment_intervenants" value="{% for worker in appointment.workers %}{{ worker.first_name }} {{ worker.last_name }}{% if forloop.last %}{% else %}, {% endif %}{% endfor %}" /> |
|
61 |
|
|
62 | 57 |
<ul> |
63 | 58 |
<li>Date : {{ appointment.date }}</li> |
64 | 59 |
<li>Heure : {{ appointment.begin_hour }}</li> |
calebasse/dossiers/views.py | ||
---|---|---|
734 | 734 |
ctx['appointment'] = appointment |
735 | 735 |
return ctx |
736 | 736 |
|
737 |
def form_valid(self, form): |
|
738 |
patient = PatientRecord.objects.get(id=self.kwargs['patientrecord_id']) |
|
737 |
def form_valid(self, form, **kwargs): |
|
738 |
ctx = self.get_context_data(**kwargs) |
|
739 |
patient = ctx['object'] |
|
740 |
appointment = ctx['appointment'] |
|
739 | 741 |
template_filename = form.cleaned_data.get('template_filename') |
740 | 742 |
dest_filename = datetime.now().strftime('%Y-%m-%d--%H:%M:%S') + '--' + template_filename |
741 | 743 |
from_path = os.path.join(settings.RTF_TEMPLATES_DIRECTORY, template_filename) |
... | ... | |
753 | 755 |
# else : use temporary files |
754 | 756 |
persistent = False |
755 | 757 |
to_path = dest_filename |
756 |
vars = {'AD11': '', 'AD12': '', 'AD13': '', 'AD14': '', 'AD15': '', |
|
757 |
'JOU1': datetime.today().strftime('%d/%m/%Y'), |
|
758 |
'VIL1': u'Saint-Étienne', |
|
759 |
'PRE1': form.cleaned_data.get('first_name'), |
|
760 |
'NOM1': form.cleaned_data.get('last_name'), |
|
761 |
'DPA1': form.cleaned_data.get('appointment_intervenants') |
|
762 |
} |
|
758 |
variables = {'AD11': '', 'AD12': '', 'AD13': '', 'AD14': '', |
|
759 |
'AD15': '', 'AD18': '', |
|
760 |
'JOU1': datetime.today().strftime('%d/%m/%Y'), |
|
761 |
'VIL1': u'Saint-Étienne', |
|
762 |
'RDV1': '', 'HEU1': '', 'THE1': '', 'DPA1': '', |
|
763 |
'NOM1': '', 'PRE1': '', 'NAI1': '', 'NUM2': '', |
|
764 |
'NOM2': '', 'PRE2': '', 'TPA1': '', 'NSS1': '', |
|
765 |
'TR01': '', 'TR02': '', 'TR03': '', 'TR04': '', 'TR05': '', |
|
766 |
'AD16': '', 'AD17': '', 'AD19': '', |
|
767 |
'AD21': '', 'AD22': '', 'AD23': '', 'AD24': '', 'AD25': '', |
|
768 |
'AD26': '', 'AD27': '', 'AD28': '', 'AD29': '', |
|
769 |
} |
|
770 |
if appointment: |
|
771 |
variables['RDV1'] = appointment.date |
|
772 |
variables['HEU1'] = appointment.begin_hour |
|
773 |
variables['THE1'] = ' '.join([str(i) for i in appointment.workers])# ou DPA1? |
|
774 |
variables['DPA1'] = variables['THE1'] |
|
775 |
if patient: |
|
776 |
variables['NOM1'] = patient.last_name |
|
777 |
variables['PRE1'] = patient.first_name |
|
778 |
if patient.birthdate : |
|
779 |
variables['NAI1'] = patient.birthdate.strftime('%d/%m/%Y') |
|
780 |
variables['NUM2'] = patient.paper_id |
|
781 |
if patient.policyholder: |
|
782 |
variables['NOM2'] = patient.policyholder.last_name |
|
783 |
variables['PRE2'] = patient.policyholder.first_name |
|
784 |
variables['TPA1'] = patient.policyholder.health_center.name |
|
785 |
if patient.policyholder.social_security_id: |
|
786 |
key = str(patient.policyholder.get_control_key()) |
|
787 |
if len(key) == 1: |
|
788 |
key = '0' + key |
|
789 |
variables['NSS1'] = \ |
|
790 |
' '.join([patient.policyholder.social_security_id, |
|
791 |
key]) |
|
792 |
if patient.transportcompany: |
|
793 |
variables['TR01'] = patient.transportcompany.name |
|
794 |
variables['TR02'] = patient.transportcompany.address |
|
795 |
variables['TR03'] = patient.transportcompany.address_complement |
|
796 |
variables['TR04'] = patient.transportcompany.zip_code |
|
797 |
variables['TR05'] = patient.transportcompany.city |
|
798 |
variables['AD18'] = form.cleaned_data.get('phone_address') or '' |
|
763 | 799 |
for i, line in enumerate(form.cleaned_data.get('address').splitlines()): |
764 |
vars['AD%d' % (11+i)] = line |
|
800 |
variables['AD%d' % (11+i)] = line
|
|
765 | 801 |
if i == 4: |
766 | 802 |
break |
767 |
filename = make_doc_from_template(from_path, to_path, vars, persistent) |
|
803 |
|
|
804 |
filename = make_doc_from_template(from_path, to_path, variables, |
|
805 |
persistent) |
|
768 | 806 |
|
769 | 807 |
client_dir = patient.get_client_side_directory(self.service.name) |
770 | 808 |
if not client_dir: |
calebasse/static/js/calebasse.agenda.js | ||
---|---|---|
125 | 125 |
if ($(this).data('address-zip-code')){address += $(this).data('address-zip-code') + ' ';} |
126 | 126 |
if ($(this).data('address-city')){address += $(this).data('address-city') + '\n';} |
127 | 127 |
$('#id_address').val(address); |
128 |
$('#id_phone_address').val($(this).attr('data-address-phone')); |
|
128 | 129 |
}); |
129 | 130 |
$('.addresses input[type=radio]').first().click(); |
130 | 131 |
}); |
Also available in: Unified diff
Complete variables for template-based document generation.