func (r Result) PhenotypeAgeCensor() (bigquery.NullFloat64, error) {
	if !r.BirthDate.Valid || !r.PhenotypeDateCensor.Valid {
		return bigquery.NullFloat64{}, nil
	}

	birthTime, err := time.Parse("2006-01-02", r.BirthDate.Date.String())
	if err != nil {
		return bigquery.NullFloat64{}, fmt.Errorf("Error parsing BirthDate '%s': %s", r.BirthDate, err.Error())
	}

	phenoTime, err := time.Parse("2006-01-02", r.PhenotypeDateCensor.Date.String())
	if err != nil {
		return bigquery.NullFloat64{}, fmt.Errorf("Error parsing PhenotypeDateCensor '%s': %s", r.PhenotypeDateCensor, err.Error())
	}

	stringYears := TimesToFractionalYears(birthTime, phenoTime)

	floatYears, err := strconv.ParseFloat(stringYears, 64)
	if err != nil {
		return bigquery.NullFloat64{}, fmt.Errorf("Error parsing duration from BirthDate '%s' and PhenotypeDateCensor '%s' : %s", r.BirthDate, r.PhenotypeDateCensor, err.Error())
	}

	return bigquery.NullFloat64{Float64: floatYears, Valid: true}, nil
}
// PhenotypeAgeCensor computes a proper (leap-year aware) age at phenotype onset
// (or censoring), rather than the heuristic age extracted from the database
// which assumes each year to be the same length.
PhenotypeAgeCensor computes a proper (leap-year aware) age at phenotype onset
(or censoring), rather than the heuristic age extracted from the database
which assumes each year to be the same length.
// PhenotypeAgeCensor computes a proper ( leap - year aware ) age at phenotype onset // ( or censoring ) rather than the heuristic age extracted from the database // which assumes each year to be the same length .
func (r Result) PhenotypeAgeCensor() (bigquery.NullFloat64, error) {
	if !r.BirthDate.Valid || !r.PhenotypeDateCensor.Valid {
		return bigquery.NullFloat64{}, nil
	}
	birthTime, err := time.Parse("2006-01-02", r.BirthDate.Date.String())
	if err != nil {
		return bigquery.NullFloat64{}, fmt.Errorf("Error parsing BirthDate '%s': %s", r.BirthDate, err.Error())
	}
	phenoTime, err := time.Parse("2006-01-02", r.PhenotypeDateCensor.Date.String())
	if err != nil {
		return bigquery.NullFloat64{}, fmt.Errorf("Error parsing PhenotypeDateCensor '%s': %s", r.PhenotypeDateCensor, err.Error())
	}
	stringYears := TimesToFractionalYears(birthTime, phenoTime)
	floatYears, err := strconv.ParseFloat(stringYears, 64)
	if err != nil {
		return bigquery.NullFloat64{}, fmt.Errorf("Error parsing duration from BirthDate '%s' and PhenotypeDateCensor '%s' : %s", r.BirthDate, r.PhenotypeDateCensor, err.Error())
	}
	return bigquery.NullFloat64{Float64: floatYears, Valid: true}, nil
}
func ( r Result ) PhenotypeAgeCensor ( ) ( bigquery . NullFloat64 , error ) { if ! r . BirthDate . Valid || ! r . PhenotypeDateCensor . Valid { return bigquery . NullFloat64 { } , nil } birthTime , err := time . Parse ( " " , r . BirthDate . Date . String ( ) ) if err != nil { return bigquery . NullFloat64 { } , fmt . Errorf ( " " , r . BirthDate , err . Error ( ) ) } phenoTime , err := time . Parse ( " " , r . PhenotypeDateCensor . Date . String ( ) ) if err != nil { return bigquery . NullFloat64 { } , fmt . Errorf ( " " , r . PhenotypeDateCensor , err . Error ( ) ) } stringYears := TimesToFractionalYears ( birthTime , phenoTime ) floatYears , err := strconv . ParseFloat ( stringYears , 64 ) if err != nil { return bigquery . NullFloat64 { } , fmt . Errorf ( " " , r . BirthDate , r . PhenotypeDateCensor , err . Error ( ) ) } return bigquery . NullFloat64 { Float64 : floatYears , Valid : true } , nil }
PhenotypeAgeCensor computes a proper (leap-year aware) age at phenotype onset
(or censoring), rather than the heuristic age extracted from the database
which assumes each year to be the same length.
PhenotypeAgeCensor computes a proper ( leap - year aware ) age at phenotype onset ( or censoring ) rather than the heuristic age extracted from the database which assumes each year to be the same length .