headfake.field.derived
DateOfBirthField
— Mock date of birth field. Calculates age based on random float selection from a scipy statistical distribution. This is multiplied by 365.25 to get age in days and a delta age (in days) from now is determined. The date is then output according to the date_format property.GenderField
— Field which generates gender values according to a 'male_probability' (default=0.5). Options include male_value (value of male selection), female_value (value of female selection and male_probability (probability that gender is male, default=0.5).NhsNoField
— Mock NHS number field which creates valid NHS numbers with the correct checksum digit. See https://www.closer.ac.uk/wp-content/uploads/CLOSER-NHS-ID-Resource-Report-Apr2018.pdf for details.DeceasedField
— Deceased mock field which uses a list of age range/mortality risk and a simulated patient 'aging' to determine if a patient is deceased and when they died. The ages are specified in a dictionary of the form {"X1-Y1":R1, "X2-Y2":R2}.AgeField
— Calculates age in years from two fields or values. The specified from_value and to_value can be either strings, date objects or Fields. If the former, then it is treated as the name of the field to obtain from the row.
headfake.field.derived.
DateOfBirthField
(
transformers=NOTHING
, final_transformers=NOTHING
, name='field_1'
, hidden=False
, error_value=None
, transform=NOTHING
, distribution
, mean
, sd
, min
, max
, date_format
)
Mock date of birth field. Calculates age based on random float selection from a scipy statistical distribution. This is multiplied by 365.25 to get age in days and a delta age (in days) from now is determined. The date is then output according to the date_format property.
A min and max property are also required to keep the distribution within a particular range.
init_from_fieldset
(
fieldset
)
— Initialises field in fieldset.next_value
(
row
)
(Union(any, dict(str: any))) — Gets next generated value for field.
init_from_fieldset
(
fieldset
)
Initialises field in fieldset.
This is run once all fields have been setup. It is generally used by fields in the fieldset to obtain information from other fields in the fieldset for later use.
fieldset
(headfake.Fieldset) — Fieldset to initialise from
None
next_value
(
row
)
Gets next generated value for field.
Acts as a decorator around the private '_next_value' method. If 'transformers' have been provided in the constructor they will act on the value after it has been generated.
row
(dict(str: any)) — The current data row as a dictionary
Dictionary containing multiple fields OR a single field value
headfake.field.derived.
GenderField
(
transformers=NOTHING
, final_transformers=NOTHING
, name='field_1'
, hidden=False
, error_value=None
, transform=NOTHING
, male_probability=0.5
, male_value
, female_value
)
Field which generates gender values according to a 'male_probability' (default=0.5). Options include male_value (value of male selection), female_value (value of female selection and male_probability (probability that gender is male, default=0.5).
e.g.
field = GenderField(male_value="M",female_value="F", male_probability=0.55)
field.next_value(row)
M
F
M
M
F
init_from_fieldset
(
fieldset
)
— Initialises field in fieldset.next_value
(
row
)
(Union(any, dict(str: any))) — Gets next generated value for field.
init_from_fieldset
(
fieldset
)
Initialises field in fieldset.
This is run once all fields have been setup. It is generally used by fields in the fieldset to obtain information from other fields in the fieldset for later use.
fieldset
(headfake.Fieldset) — Fieldset to initialise from
None
next_value
(
row
)
Gets next generated value for field.
Acts as a decorator around the private '_next_value' method. If 'transformers' have been provided in the constructor they will act on the value after it has been generated.
row
(dict(str: any)) — The current data row as a dictionary
Dictionary containing multiple fields OR a single field value
headfake.field.derived.
NhsNoField
(
transformers=NOTHING
, final_transformers=NOTHING
, name='field_1'
, hidden=False
, error_value=None
, transform=NOTHING
, used_values=NOTHING
)
Mock NHS number field which creates valid NHS numbers with the correct checksum digit. See https://www.closer.ac.uk/wp-content/uploads/CLOSER-NHS-ID-Resource-Report-Apr2018.pdf for details.
init_from_fieldset
(
fieldset
)
— Initialises field in fieldset.next_value
(
row
)
(Union(any, dict(str: any))) — Gets next generated value for field.
init_from_fieldset
(
fieldset
)
Initialises field in fieldset.
This is run once all fields have been setup. It is generally used by fields in the fieldset to obtain information from other fields in the fieldset for later use.
fieldset
(headfake.Fieldset) — Fieldset to initialise from
None
next_value
(
row
)
Gets next generated value for field.
Acts as a decorator around the private '_next_value' method. If 'transformers' have been provided in the constructor they will act on the value after it has been generated.
row
(dict(str: any)) — The current data row as a dictionary
Dictionary containing multiple fields OR a single field value
headfake.field.derived.
DeceasedField
(
transformers=NOTHING
, final_transformers=NOTHING
, name='field_1'
, hidden=False
, error_value=None
, transform=NOTHING
, deceased_true_value=1
, deceased_false_value=0
, dob_field
, deceased_date_field=None
, age_field=None
, risk_of_death
, date_format
, risk_by_age=NOTHING
, end_date=datetime.date(2021, 7, 22)
, end_date_format=None
)
Deceased mock field which uses a list of age range/mortality risk and a simulated patient 'aging' to determine if a patient is deceased and when they died. The ages are specified in a dictionary of the form {"X1-Y1":R1, "X2-Y2":R2}.
The risk is defined as the 1 in R risk of death.
The end date to use to determine the age defaults to today, but can be set using the 'end_date' argument as a date object, a field name or a Field object.
init_from_fieldset
(
fieldset
)
— Initialises field in fieldset.next_value
(
row
)
(Union(any, dict(str: any))) — Gets next generated value for field.
next_value
(
row
)
Gets next generated value for field.
Acts as a decorator around the private '_next_value' method. If 'transformers' have been provided in the constructor they will act on the value after it has been generated.
row
(dict(str: any)) — The current data row as a dictionary
Dictionary containing multiple fields OR a single field value
init_from_fieldset
(
fieldset
)
Initialises field in fieldset.
This is run once all fields have been setup. It is generally used by fields in the fieldset to obtain information from other fields in the fieldset for later use.
fieldset
— Fieldset to initialise from
None
headfake.field.derived.
AgeField
(
transformers=NOTHING
, final_transformers=NOTHING
, name='field_1'
, hidden=False
, error_value=None
, transform=NOTHING
, from_value
, to_value
, from_format=None
, to_format=None
)
Calculates age in years from two fields or values. The specified from_value and to_value can be either strings, date objects or Fields. If the former, then it is treated as the name of the field to obtain from the row.
init_from_fieldset
(
fieldset
)
— Initialises field in fieldset.next_value
(
row
)
(Union(any, dict(str: any))) — Gets next generated value for field.
init_from_fieldset
(
fieldset
)
Initialises field in fieldset.
This is run once all fields have been setup. It is generally used by fields in the fieldset to obtain information from other fields in the fieldset for later use.
fieldset
(headfake.Fieldset) — Fieldset to initialise from
None
next_value
(
row
)
Gets next generated value for field.
Acts as a decorator around the private '_next_value' method. If 'transformers' have been provided in the constructor they will act on the value after it has been generated.
row
(dict(str: any)) — The current data row as a dictionary
Dictionary containing multiple fields OR a single field value