Skip to content

Instantly share code, notes, and snippets.

@snahor
Created February 28, 2011 23:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save snahor/848280 to your computer and use it in GitHub Desktop.
Save snahor/848280 to your computer and use it in GitHub Desktop.
def edad_gestacional_fur(self):
if self.ultima_menstruacion:
# 40 semanas
days = (date.today() - self.ultima_menstruacion).days
return '{0} {1}/7'.format(days / 7, days % 7)
return None
def edad_gestacional_1eco(self):
"""Retorna la edad gestacional segun la primera ecografia."""
if self.primera_ecografia:
return self.primera_ecografia.get_edad_gestacional_actual_display()
return None
def edad_gestacional_au(self):
"""Retorna la edad gestacional por altura uterina."""
values = {
'8.0': 13, '8.5': 13, '9.0': 13, '9.5': 13, '10.0': 13,
'10.5': 13, '11.0': 14, '11.5': 14, '12.0': 15, '12.5': 15,
'13.0': 15, '13.5': 16, '14.0': 16, '14.5': 17, '15.0': 17,
'15.5': 17, '16.0': 18, '16.5': 18, '17.0': 19, '17.5': 19,
'18.0': 20, '18.5': 20, '19.0': 21, '19.5': 21, '20.0': 22,
'20.5': 22, '21.0': 23, '21.5': 23, '22.0': 24, '22.5': 25,
'23.0': 26, '23.5': 27, '24.0': 27, '24.5': 28, '25.0': 28,
'25.5': 29, '26.0': 29, '26.5': 30, '27.0': 31, '27.5': 31,
'28.0': 32, '28.5': 32, '29.0': 33, '29.5': 34, '30.0': 34,
'30.5': 35, '31.0': 36, '31.5': 37, '32.0': 37, '32.5': 38,
'33.0': 38, '33.5': 39, '34.0': 39, '34.5': 40
}
if not self.altura_uterina:
return None
# La altura uterina se multiplica por 10, y luego se aproxima al
# entero proximo a su izquierda.
x = int(self.altura_uterina * 10)
x = x - (x % 5)
# Se iguala a 345 si excede del mismo para tomar el ultimo valor de values.
if x > 345:
x = 345
return values[str(x / 10.)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment