age.patch
calebasse/dossiers/models.py | ||
---|---|---|
21 | 21 |
from calebasse.actes.models import Act |
22 | 22 | |
23 | 23 |
from ..middleware.request import get_request |
24 |
from ..utils import get_service_setting |
|
24 | 25 | |
25 | 26 |
DEFAULT_ACT_NUMBER_DIAGNOSTIC = 6 |
26 | 27 |
DEFAULT_ACT_NUMBER_TREATMENT = 30 |
... | ... | |
371 | 372 |
def age(self): |
372 | 373 |
if not self.birthdate: |
373 | 374 |
return 'inconnu' |
375 |
age_format = get_service_setting('age_format') |
|
374 | 376 |
now = datetime.today().date() |
375 | 377 |
age = relativedelta(now, self.birthdate) |
376 |
if age.years < 2: |
|
377 |
# for children < 2 years, return the number of months |
|
378 |
# by default we return the number of months for children < 2 years, but |
|
379 |
# there's a service setting to have it always displayed that way. |
|
380 |
if age.years < 2 or age_format == 'months_only': |
|
378 | 381 |
months = age.years * 12 + age.months |
379 | 382 |
if months: |
383 |
if months < 3 and age.days: |
|
384 |
return '%s mois et %s jour%s' % \ |
|
385 |
(months, age.days, "s"[age.days==1:]) |
|
380 | 386 |
return '%s mois' % months |
381 |
return '%s jours' % age.days |
|
387 |
return '%s jour%s' % (age.days, "s"[age.days==1:]) |
|
388 |
if age.months: |
|
389 |
return '%s ans et %s mois' % (age.years, age.months) |
|
382 | 390 |
return '%s ans' % age.years |
383 | 391 | |
384 | 392 | |
... | ... | |
1044 | 1052 | |
1045 | 1053 |
PatientRecord.DEFICIENCY_FIELDS = [field for field in PatientRecord._meta.get_all_field_names() if field.startswith('deficiency_')] |
1046 | 1054 |
PatientRecord.MISES_FIELDS = [field for field in PatientRecord._meta.get_all_field_names() if field.startswith('mises_')] |
1047 |