Пример #1
0
    def get_EDC(self, lmp=None, nullipara=True):

        result = cClinicalResult(_('unknown EDC'))
        result.formula_name = u'EDC (Mittendorf 1990)'
        result.formula_source = u'Mittendorf, R. et al., "The length of uncomplicated human gestation," OB/GYN, Vol. 75, No., 6 June, 1990, pp. 907-932.'

        if lmp is None:
            result.message = _('EDC: unknown LMP')
            return result

        result.variables['LMP'] = lmp
        result.variables['nullipara'] = nullipara
        if nullipara:
            result.variables['parity_offset'] = 15  # days
        else:
            result.variables['parity_offset'] = 10  # days

        now = gmDateTime.pydt_now_here()
        if lmp > now:
            result.warnings.append(_(u'LMP in the future'))

        if self.__patient is None:
            result.warnings.append(_(u'cannot run sanity checks, no patient'))
        else:
            if self.__patient['dob'] is None:
                result.warnings.append(_(u'cannot run sanity checks, no DOB'))
            else:
                years, months, days, hours, minutes, seconds = gmDateTime.calculate_apparent_age(
                    start=self.__patient['dob'])
                # 5 years -- Myth ?
                # http://www.mirror.co.uk/news/uk-news/top-10-crazy-amazing-and-world-789842
                if years < 10:
                    result.warnings.append(
                        _(u'patient less than 10 years old'))
            if self.__patient['gender'] in [None, u'm']:
                result.warnings.append(
                    _(u'atypical gender for pregnancy: %s') %
                    self.__patient.gender_string)
            if self.__patient['deceased'] is not None:
                result.warnings.append(_(u'patient already passed away'))

        if lmp.month > 3:
            edc_month = lmp.month - 3
            edc_year = lmp.year + 1
        else:
            edc_month = lmp.month + 9
            edc_year = lmp.year

        result.numeric_value = gmDateTime.pydt_replace(
            dt=lmp, year=edc_year, month=edc_month,
            strict=False) + pydt.timedelta(
                days=result.variables['parity_offset'])

        result.message = _('EDC: %s') % gmDateTime.pydt_strftime(
            result.numeric_value, format='%Y %b %d')
        result.date_valid = now

        _log.debug(u'%s' % result)

        return result
Пример #2
0
	def get_EDC(self, lmp=None, nullipara=True):

		result = cClinicalResult(_('unknown EDC'))
		result.formula_name = 'EDC (Mittendorf 1990)'
		result.formula_source = 'Mittendorf, R. et al., "The length of uncomplicated human gestation," OB/GYN, Vol. 75, No., 6 June, 1990, pp. 907-932.'

		if lmp is None:
			result.message = _('EDC: unknown LMP')
			return result

		result.variables['LMP'] = lmp
		result.variables['nullipara'] = nullipara
		if nullipara:
			result.variables['parity_offset'] = 15		# days
		else:
			result.variables['parity_offset'] = 10		# days

		now = gmDateTime.pydt_now_here()
		if lmp > now:
			result.warnings.append(_('LMP in the future'))

		if self.__patient is None:
			result.warnings.append(_('cannot run sanity checks, no patient'))
		else:
			if self.__patient['dob'] is None:
				result.warnings.append(_('cannot run sanity checks, no DOB'))
			else:
				years, months, days, hours, minutes, seconds = gmDateTime.calculate_apparent_age(start = self.__patient['dob'])
				# 5 years -- Myth ?
				# http://www.mirror.co.uk/news/uk-news/top-10-crazy-amazing-and-world-789842
				if years < 10:
					result.warnings.append(_('patient less than 10 years old'))
			if self.__patient['gender'] in [None, 'm']:
				result.warnings.append(_('atypical gender for pregnancy: %s') % self.__patient.gender_string)
			if self.__patient['deceased'] is not None:
				result.warnings.append(_('patient already passed away'))

		if lmp.month > 3:
			edc_month = lmp.month - 3
			edc_year = lmp.year + 1
		else:
			edc_month = lmp.month + 9
			edc_year = lmp.year

		result.numeric_value = gmDateTime.pydt_replace(dt = lmp, year = edc_year, month = edc_month, strict = False) + pydt.timedelta(days = result.variables['parity_offset'])

		result.message = _('EDC: %s') % gmDateTime.pydt_strftime (
			result.numeric_value,
			format = '%Y %b %d'
		)
		result.date_valid = now

		_log.debug('%s' % result)

		return result