Project

General

Profile

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

calebasse / calebasse / dossiers / transport.py @ 6188a681

1 0ea528a4 Mikaël Ates
import os
2
3
from transport_template import TransportTemplate
4
5
6 07b0577e Mikaël Ates
def render_transport(patient, address, data={}):
7 0ea528a4 Mikaël Ates
    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 07b0577e Mikaël Ates
    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 0ea528a4 Mikaël Ates
        }
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 07b0577e Mikaël Ates
        ctx['NOM_ASSURE'] = policy_holder_full_name
53 0ea528a4 Mikaël Ates
    if patient.policyholder.social_security_id:
54
        ctx['NIR_ASSURE'] = \
55 b461522f Thomas NOEL
            u' '.join(patient.policyholder.social_security_id)
56 7c95a63e Mikaël Ates
        key = str(patient.policyholder.get_control_key())
57
        if len(key) == 1:
58
            key = '0' + key
59 0ea528a4 Mikaël Ates
        ctx['NIR_KEY_ASSURE'] = \
60 b461522f Thomas NOEL
            u' '.join(key)
61 0ea528a4 Mikaël Ates
    if patient.policyholder.health_center:
62
        ctx['CODE_ORGANISME_1'] = \
63 b461522f Thomas NOEL
            u' '.join(patient.policyholder.health_center.large_regime.code)
64 0ea528a4 Mikaël Ates
        ctx['CODE_ORGANISME_2'] = \
65 b461522f Thomas NOEL
            u' '.join(patient.policyholder.health_center.dest_organism)
66 0ea528a4 Mikaël Ates
        ctx['CODE_ORGANISME_3'] = \
67 b461522f Thomas NOEL
            u' '.join(patient.policyholder.other_health_center
68 0ea528a4 Mikaël Ates
                or patient.policyholder.health_center.code)
69
    if address:
70 07b0577e Mikaël Ates
        ctx['ADRESSE_BENEFICIAIRE'] = address.display_name
71 0ea528a4 Mikaël Ates
    return tpl.generate(ctx)