From 0c8c6aeb74002c0326c4c423fab9f221693faf97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Wed, 9 Jul 2014 14:05:50 +0200 Subject: [PATCH] display age next to birthdate in dossier main page (#3429) --- calebasse/dossiers/models.py | 13 +++++++++++++ .../templates/dossiers/patientrecord_tab1_general.html | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/calebasse/dossiers/models.py b/calebasse/dossiers/models.py index f51029a..2d9a387 100644 --- a/calebasse/dossiers/models.py +++ b/calebasse/dossiers/models.py @@ -371,6 +371,19 @@ class PatientContact(People): return None return None + def age(self): + if not self.birthdate: + return 'inconnu' + now = datetime.today().date() + age = relativedelta(now, self.birthdate) + if age.years < 2: + # for children < 2 years, return the number of months + months = age.years * 12 + age.months + if months: + return '%s mois' % months + return '%s jours' % age.days + return '%s ans' % age.years + class PatientRecordManager(models.Manager): def for_service(self, service): diff --git a/calebasse/dossiers/templates/dossiers/patientrecord_tab1_general.html b/calebasse/dossiers/templates/dossiers/patientrecord_tab1_general.html index 656aa57..78f32f7 100644 --- a/calebasse/dossiers/templates/dossiers/patientrecord_tab1_general.html +++ b/calebasse/dossiers/templates/dossiers/patientrecord_tab1_general.html @@ -8,7 +8,7 @@
  • {{ object.last_name }}
  • {{ object.first_name }}
  • {{ object.get_gender_display|default_if_none:"Non renseigné" }}
  • -
  • {% if object.birthdate %}{{ object.birthdate|date:"d/m/Y" }}{% else %}Non renseignée{% endif %}
  • +
  • {% if object.birthdate %}{{ object.birthdate|date:"d/m/Y" }} ({{ object.age }}){% else %}Non renseignée{% endif %}
  • {% if nb_place_of_lifes == 1 %} -- 2.0.1