Projet

Général

Profil

Télécharger (3,02 ko) Statistiques
| Branche: | Tag: | Révision:

calebasse / calebasse / dossiers / transport.py @ 54318d2c

1
import os
2

    
3
from transport_template import TransportTemplate
4

    
5

    
6
def render_transport(patient, address, data={}):
7
    template_path = os.path.join(
8
            os.path.dirname(__file__),
9
            'static',
10
            'dossiers',
11
            'cerfa_50742_03_prescription_transport.pdf')
12
    tpl = TransportTemplate(
13
            template_path=template_path,
14
            prefix='transport_filled', suffix='.pdf')
15
    name = ''
16
    if patient.last_name:
17
        name = patient.last_name.upper()
18
    ctx = {'NOM_BENEFICIAIRE': name,
19
        'PRENOM_BENEFICIAIRE': patient.first_name or '',
20
        'DATE': data.get('date', ''),
21
        'LIEU': data.get('lieu', ''),
22
        'IDENTIFICATION_ETABLISSEMENT': data.get('id_etab', ''),
23
        'SITUATION_CHOICE_1': 'situation_choice_1' in data,
24
        'SITUATION_CHOICE_2': 'situation_choice_2' in data,
25
        'SITUATION_CHOICE_3': 'situation_choice_3' in data,
26
        'SITUATION_CHOICE_4': 'situation_choice_4' in data,
27
        'SITUATION_DATE': data.get('situation_date', ''),
28
        'TRAJET_TEXT': data.get('trajet_text', ''),
29
        'TRAJET_CHOICE_1': 'trajet_choice_1' in data,
30
        'TRAJET_CHOICE_2': 'trajet_choice_2' in data,
31
        'TRAJET_CHOICE_3': 'trajet_choice_3' in data,
32
        'TRAJET_CHOICE_4': 'trajet_choice_4' in data,
33
        'TRAJET_NUMBER': data.get('trajet_number', ''),
34
        'PC_CHOICE_1': 'pc_choice_1' in data,
35
        'PC_CHOICE_2': 'pc_choice_2' in data,
36
        'MODE_CHOICE_1': 'mode_choice_1' in data,
37
        'MODE_CHOICE_2': 'mode_choice_2' in data,
38
        'MODE_CHOICE_3': 'mode_choice_3' in data,
39
        'MODE_CHOICE_4': 'mode_choice_4' in data,
40
        'MODE_CHOICE_5': 'mode_choice_5' in data,
41
        'MODE_CHOICE_6': 'mode_choice_6' in data,
42
        'CDTS_CHOICE_1': 'cdts_choice_1' in data,
43
        'CDTS_CHOICE_2': 'cdts_choice_2' in data,
44
        }
45
    if patient.policyholder.id != patient.id:
46
        policy_holder_full_name = ''
47
        if patient.policyholder.last_name.upper:
48
            policy_holder_full_name = \
49
                patient.policyholder.last_name.upper() + ' '
50
        if patient.policyholder.first_name:
51
            policy_holder_full_name += patient.policyholder.first_name
52
        ctx['NOM_ASSURE'] = policy_holder_full_name
53
    if patient.policyholder.social_security_id:
54
        ctx['NIR_ASSURE'] = \
55
            u' '.join(patient.policyholder.social_security_id)
56
        key = str(patient.policyholder.get_control_key())
57
        if len(key) == 1:
58
            key = '0' + key
59
        ctx['NIR_KEY_ASSURE'] = \
60
            u' '.join(key)
61
    if patient.policyholder.health_center:
62
        ctx['CODE_ORGANISME_1'] = \
63
            u' '.join(patient.policyholder.health_center.large_regime.code)
64
        ctx['CODE_ORGANISME_2'] = \
65
            u' '.join(patient.policyholder.health_center.dest_organism)
66
        ctx['CODE_ORGANISME_3'] = \
67
            u' '.join(patient.policyholder.other_health_center
68
                or patient.policyholder.health_center.code)
69
    if address:
70
        ctx['ADRESSE_BENEFICIAIRE'] = address.display_name
71
    return tpl.generate(ctx)
(8-8/12)