Projet

Général

Profil

« Précédent | Suivant » 

Révision 3b4bba4a

Ajouté par Serghei Mihai (congés, retour 15/05) il y a plus de 9 ans

dossiers: printing the whole patient record in pdf format

Closes #3109

Voir les différences:

calebasse/dossiers/views.py
32 32
from calebasse.ressources.models import (Service,
33 33
    SocialisationDuration, MDPHRequest, MDPHResponse)
34 34
from calebasse.facturation.list_acts import list_acts_for_billing_CMPP_per_patient
35
from calebasse.facturation.invoice_header import render_to_pdf_file
35 36

  
36 37
from calebasse.decorators import validator_only
37 38

  
......
262 263

  
263 264
patient_record = PatientRecordView.as_view()
264 265

  
266
class PatientRecordPrint(cbv.DetailView):
267
    model = PatientRecord
268
    content_type = 'application/pdf'
269
    template_name = 'dossiers/patientrecord_print.html'
270

  
271
    def get_context_data(self, *args, **kwargs):
272
        context = super(PatientRecordPrint, self).get_context_data(*args, **kwargs)
273
        for view in (PatientRecordGeneralView, PatientRecordAdmView,
274
                     PatientRecordAddrView, PatientRecordNotifsView, PatientRecordOldActs,
275
                     PatientRecordNextAppointmentsView, PatientRecordSocialisationView):
276
            view_instance = view(request=self.request, object=self.object,
277
                                 service=self.service)
278
            context.update(view_instance.get_context_data(object=self.object))
279
        return context
280

  
281
    def get(self, request, *args, **kwargs):
282
        self.object = self.get_object()
283
        path = render_to_pdf_file([self.template_name],
284
                                  self.get_context_data(object = self.object))
285
        content = File(file(path))
286
        response = HttpResponse(content, self.content_type)
287
        response['Content-Length'] = content.size
288
        output = 'dossier_%s.pdf' % self.object.id
289
        response['Content-Disposition'] = \
290
            'attachment; filename="%s"' % output
291
        return response
292

  
293
patient_record_print = PatientRecordPrint.as_view()
294

  
265 295
class PatientRecordGeneralView(cbv.UpdateView):
266 296
    model = PatientRecord
267 297
    form_class = forms.GeneralForm

Formats disponibles : Unified diff