Project

General

Profile

Download (2.97 KB) Statistics
| Branch: | Tag: | Revision:

calebasse / calebasse / dossiers / transport.py @ 017f4158

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_NUMBER': data.get('trajet_number', ''),
33
        'PC_CHOICE_1': 'pc_choice_1' in data,
34
        'PC_CHOICE_2': 'pc_choice_2' in data,
35
        'MODE_CHOICE_1': 'mode_choice_1' in data,
36
        'MODE_CHOICE_2': 'mode_choice_2' in data,
37
        'MODE_CHOICE_3': 'mode_choice_3' in data,
38
        'MODE_CHOICE_4': 'mode_choice_4' in data,
39
        'MODE_CHOICE_5': 'mode_choice_5' in data,
40
        'MODE_CHOICE_6': 'mode_choice_6' in data,
41
        'CDTS_CHOICE_1': 'cdts_choice_1' in data,
42
        'CDTS_CHOICE_2': 'cdts_choice_2' in data,
43
        }
44
    if patient.policyholder.id != patient.id:
45
        policy_holder_full_name = ''
46
        if patient.policyholder.last_name.upper:
47
            policy_holder_full_name = \
48
                patient.policyholder.last_name.upper() + ' '
49
        if patient.policyholder.first_name:
50
            policy_holder_full_name += patient.policyholder.first_name
51
        ctx['NOM_ASSURE'] = policy_holder_full_name
52
    if patient.policyholder.social_security_id:
53
        ctx['NIR_ASSURE'] = \
54
            u' '.join(patient.policyholder.social_security_id)
55
        key = str(patient.policyholder.get_control_key())
56
        if len(key) == 1:
57
            key = '0' + key
58
        ctx['NIR_KEY_ASSURE'] = \
59
            u' '.join(key)
60
    if patient.policyholder.health_center:
61
        ctx['CODE_ORGANISME_1'] = \
62
            u' '.join(patient.policyholder.health_center.large_regime.code)
63
        ctx['CODE_ORGANISME_2'] = \
64
            u' '.join(patient.policyholder.health_center.dest_organism)
65
        ctx['CODE_ORGANISME_3'] = \
66
            u' '.join(patient.policyholder.other_health_center
67
                or patient.policyholder.health_center.code)
68
    if address:
69
        ctx['ADRESSE_BENEFICIAIRE'] = address.display_name
70
    return tpl.generate(ctx)
(8-8/12)