Skip to content

Commit

Permalink
Issue #60 : add support to export patients and examinations as CSV files
Browse files Browse the repository at this point in the history
  • Loading branch information
Garthylou Jean-Baptiste Gury committed Apr 23, 2016
1 parent 168ca98 commit 5ada693
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 20 deletions.
8 changes: 8 additions & 0 deletions libreosteoweb/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ class Meta:
)
]

class PatientExportSerializer (serializers.ModelSerializer):
birth_date = serializers.DateField(label=_('Birth date'),)

class Meta:
model = Patient
fields = ('family_name', 'first_name', 'original_name', 'birth_date')

class UserInfoSerializer(serializers.ModelSerializer):
def validate_last_name(self, value):
return get_name_filters().filter(value)
Expand Down Expand Up @@ -76,6 +83,7 @@ def get_nb_comments(self, obj):
class ExaminationSerializer(serializers.ModelSerializer):
invoice_number = serializers.CharField(source="invoice.number", required=False, allow_null=True, read_only=True)
therapeut_detail = UserInfoSerializer(source="therapeut", required=False, allow_null=True, read_only=True)
patient_detail = PatientExportSerializer(source="patient", required=False, allow_null=True, read_only=True)
class Meta:
model = Examination

Expand Down
5 changes: 4 additions & 1 deletion libreosteoweb/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,15 @@ def get_context_data(self, **kwargs):




from rest_framework.settings import api_settings
from rest_framework_csv import renderers as r


class PatientViewSet(viewsets.ModelViewSet):
model = models.Patient
serializer_class = apiserializers.PatientSerializer
queryset = models.Patient.objects.all()
renderer_classes = api_settings.DEFAULT_RENDERER_CLASSES + [r.CSVRenderer, ]

@detail_route(methods=['GET'])
def examinations(self, request, pk=None):
Expand Down Expand Up @@ -140,6 +142,7 @@ class ExaminationViewSet(viewsets.ModelViewSet):
model = models.Examination
queryset = models.Examination.objects.all()
serializer_class = apiserializers.ExaminationSerializer
renderer_classes = api_settings.DEFAULT_RENDERER_CLASSES + [r.CSVRenderer, ]


@detail_route(methods=['POST'])
Expand Down
Binary file modified locale/fr/LC_MESSAGES/django.mo
Binary file not shown.
53 changes: 34 additions & 19 deletions locale/fr/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Libreosteo 1.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-04-23 17:01+0200\n"
"PO-Revision-Date: 2016-04-23 15:15+0200\n"
"POT-Creation-Date: 2016-04-23 21:38+0200\n"
"PO-Revision-Date: 2016-04-23 21:40+0200\n"
"Last-Translator: GURY <[email protected]>\n"
"Language-Team: France <[email protected]>\n"
"Language: fr\n"
Expand Down Expand Up @@ -38,19 +38,19 @@ msgstr "Impossible de reconnaître le fichier patient"
msgid "Cannot read the content file. Check the encoding."
msgstr "Impossible de lire le contenu du fichier. Vérifiez l'encodage."

#: libreosteoweb/api/file_integrator.py:418
#: libreosteoweb/api/file_integrator.py:392
msgid "Missing patient file to integrate it."
msgstr "Il manque le fichier patient pour intégrer."

#: libreosteoweb/api/file_integrator.py:444
#: libreosteoweb/api/file_integrator.py:418
msgid "Imported examination"
msgstr "Consultations importées"

#: libreosteoweb/api/file_integrator.py:457
#: libreosteoweb/api/file_integrator.py:431
msgid "There is a problem when reading this line :"
msgstr "Il y a un problème lors de la lecture de la ligne :"

#: libreosteoweb/api/file_integrator.py:460
#: libreosteoweb/api/file_integrator.py:434
msgid "There is a problem when reading this line."
msgstr "Il y a un problème lors de la lecture de la ligne."

Expand All @@ -70,29 +70,29 @@ msgstr "Nouvelle consultation"
msgid "Birth date is invalid"
msgstr "La date de naissance est invalide"

#: libreosteoweb/api/serializers.py:25 libreosteoweb/models.py:41
#: libreosteoweb/models.py:92
#: libreosteoweb/api/serializers.py:25 libreosteoweb/api/serializers.py:47
#: libreosteoweb/models.py:41 libreosteoweb/models.py:92
msgid "Birth date"
msgstr "Date de naissance"

#: libreosteoweb/api/serializers.py:42
msgid "This patient already exists"
msgstr "Ce patient existe déjà"

#: libreosteoweb/api/serializers.py:101
#: libreosteoweb/api/serializers.py:109
msgid "Reason is mandatory when the examination is not invoiced"
msgstr "La raison est obligatoire lorsque la consultation n'est pas facturée"

#: libreosteoweb/api/serializers.py:104
#: libreosteoweb/api/serializers.py:112
msgid "Amount is invalid"
msgstr "Le montant est invalide"

#: libreosteoweb/api/serializers.py:106
#: libreosteoweb/api/serializers.py:114
msgid "Paiment mode is mandatory when the examination is invoiced"
msgstr ""
"Le mode de paiement est obligatoire lorsque la consultation est facturée"

#: libreosteoweb/api/serializers.py:109
#: libreosteoweb/api/serializers.py:117
msgid "Check information is missing"
msgstr "Les informations de chèque sont manquantes"

Expand Down Expand Up @@ -192,7 +192,7 @@ msgstr "Antécédents familiaux"
msgid "Trauma history"
msgstr "Antécédents traumatiques"

#: libreosteoweb/models.py:60 templates/partials/patient-detail.html:232
#: libreosteoweb/models.py:60 templates/partials/patient-detail.html:230
msgid "Medical reports"
msgstr "Compte-rendus médicaux"

Expand Down Expand Up @@ -585,7 +585,7 @@ msgid "View Details"
msgstr "Afficher les détails"

#: templates/partials/dashboard.html:50
#: templates/partials/patient-detail.html:246
#: templates/partials/patient-detail.html:244
msgid "Examinations"
msgstr "Consultations"

Expand All @@ -594,7 +594,7 @@ msgid "Urgent return"
msgstr "Retour"

#: templates/partials/doctor-modal-add.html:3
#: templates/partials/patient-detail.html:126
#: templates/partials/patient-detail.html:124
msgid "Add a doctor"
msgstr "Ajouter un médecin"

Expand Down Expand Up @@ -740,6 +740,21 @@ msgstr "Erreurs lors de l'importation "
msgid "Export"
msgstr "Exporter"

#: templates/partials/import-file.html:184
msgid ""
"Here you can download the full list of patients and examinations as CSV files"
msgstr ""
"Vous pouvez télécharger ici la liste complète des patients et des "
"consultations sous forme de fichiers CSV."

#: templates/partials/import-file.html:192
msgid "Patients file"
msgstr "Fichier patients"

#: templates/partials/import-file.html:196
msgid "Examinations file"
msgstr "Fichier des consultations"

#: templates/partials/invoice-modal.html:3
#: templates/partials/office-settings.html:70
msgid "Invoicing"
Expand Down Expand Up @@ -825,19 +840,19 @@ msgid "Patient infos"
msgstr "Infos patient"

#: templates/partials/patient-detail.html:26
#: templates/partials/patient-detail.html:124
#: templates/partials/patient-detail.html:122
msgid "not documented"
msgstr "non renseigné"

#: templates/partials/patient-detail.html:106
#: templates/partials/patient-detail.html:113
msgid "Not smoker"
msgstr "Non fumeur"

#: templates/partials/patient-detail.html:176
#: templates/partials/patient-detail.html:174
msgid "History"
msgstr "Antécédents"

#: templates/partials/patient-detail.html:256
#: templates/partials/patient-detail.html:254
msgid "New Examination"
msgstr "Nouvelle consultation"

Expand Down
1 change: 1 addition & 0 deletions requirements/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ django-statici18n==1.1.5
djangorestframework==3.3.2
six==1.10.0
cherrypy
djangorestframework-csv==1.4.1
18 changes: 18 additions & 0 deletions templates/partials/import-file.html
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,25 @@ <h1 class="page-header">
<uib-tab heading="{% trans 'Export'%}" ng-if="{{ request.user.is_staff|yesno:"true,false" }}">
<div class="container-fluid">
<div class="row">
<p>{% blocktrans %}Here you can download the full list of patients and examinations as CSV files{% endblocktrans %}</p>
<div class="col-md-12">

<div class="panel panel-default">
<div class="panel-body">
<div class="row">
<div class="col-md-6">
<i style="font-size:24px" class="fa fa-file-excel-o"></i>
<a href="/api/patients?format=csv">{%trans 'Patients file'%}</a>
</div>
<div class="col-md-6">
<i style="font-size:24px" class="fa fa-file-excel-o"></i>
<a href="/api/examinations?format=csv">{%trans 'Examinations file'%}</a>
</div>
</div>
</div>
</div>

</div>
</div>
</div>
</uib-tab>
Expand Down

0 comments on commit 5ada693

Please sign in to comment.