class Anthropometry(CrfModelMixin, BaseUuidModel): weight = edc_models.WeightField() height = edc_models.HeightField() bmi = models.DecimalField( verbose_name="BMI", decimal_places=1, max_digits=7, help_text="kg/mm^2 (Note: this field is read only. The value is calculated)", ) waist_circumference = edc_models.WaistCircumferenceField() sys_blood_pressure_r1 = edc_models.SystolicPressureField(null=True, blank=False,) dia_blood_pressure_r1 = edc_models.DiastolicPressureField(null=True, blank=False,) sys_blood_pressure_r2 = edc_models.SystolicPressureField(null=True, blank=False,) dia_blood_pressure_r2 = edc_models.DiastolicPressureField(null=True, blank=False,) def save(self, *args, **kwargs): self.bmi = round((float(self.weight) / (float(self.height) / 100.0)), 2) super().save(*args, **kwargs) class Meta(CrfModelMixin.Meta): verbose_name = "Anthropometry" verbose_name_plural = "Anthropometry"
class Indicators(CrfModelMixin, BaseUuidModel): weight = edc_models.WeightField( validators=[MinValueValidator(25), MaxValueValidator(200)], null=True, blank=True, ) height = edc_models.HeightField( null=True, blank=True, ) r1_taken = models.CharField( verbose_name=mark_safe("Was a blood pressure reading taken"), max_length=15, choices=YES_NO, default=YES, ) r1_reason_not_taken = models.TextField( verbose_name="reason not taken", max_length=250, null=True, blank=True ) sys_blood_pressure_r1 = edc_models.SystolicPressureField(null=True, blank=True) dia_blood_pressure_r1 = edc_models.DiastolicPressureField(null=True, blank=True) r2_taken = models.CharField( verbose_name=mark_safe("Was a <u>second</u> blood pressure reading taken"), max_length=15, choices=YES_NO_NOT_REQUIRED, default=NOT_REQUIRED, ) r2_reason_not_taken = models.TextField(max_length=250, null=True, blank=True) sys_blood_pressure_r2 = edc_models.SystolicPressureField(null=True, blank=True) dia_blood_pressure_r2 = edc_models.DiastolicPressureField(null=True, blank=True) class Meta(CrfModelMixin.Meta, edc_models.BaseUuidModel.Meta): verbose_name = "Indicators" verbose_name_plural = "Indicators"
class VitalsFieldMixin(models.Model): weight = edc_models.WeightField() # 9 sys_blood_pressure = edc_models.SystolicPressureField( null=True, blank=False, ) # 9 dia_blood_pressure = edc_models.DiastolicPressureField( null=True, blank=False, ) # 10 heart_rate = models.IntegerField( verbose_name="Heart rate:", validators=[MinValueValidator(30), MaxValueValidator(200)], help_text="BPM", ) # 11 respiratory_rate = models.IntegerField( verbose_name="Respiratory rate:", validators=[MinValueValidator(6), MaxValueValidator(50)], help_text="breaths/min", null=True, ) # 12 oxygen_saturation = models.IntegerField( verbose_name="Oxygen saturation:", validators=[MinValueValidator(1), MaxValueValidator(999)], help_text="%", null=True, ) temperature = models.DecimalField( verbose_name="Temperature:", validators=[MinValueValidator(30), MaxValueValidator(45)], decimal_places=1, max_digits=3, help_text="in degrees Celcius", ) class Meta: abstract = True
class IndicatorsModelMixin(models.Model): weight = edc_models.WeightField(null=True, blank=True) waist_circumference = models.DecimalField( verbose_name="Waist circumference", max_digits=5, decimal_places=1, validators=[MinValueValidator(50.0), MaxValueValidator(175.0)], help_text="in centimeters", null=True, blank=True, ) sys_blood_pressure = edc_models.SystolicPressureField(null=True, blank=True) dia_blood_pressure = edc_models.DiastolicPressureField(null=True, blank=True) glucose = models.DecimalField( verbose_name="Blood Glucose", max_digits=8, decimal_places=4, null=True, blank=True, ) glucose_units = models.CharField( verbose_name="Blood Glucose Units", max_length=15, choices=( (MILLIGRAMS_PER_DECILITER, MILLIGRAMS_PER_DECILITER), (MILLIMOLES_PER_LITER, MILLIMOLES_PER_LITER), ), null=True, blank=True, ) glucose_fasting = models.CharField( verbose_name="Was this a fasting or random blood glucose?", max_length=25, choices=FASTING_CHOICES, null=True, blank=True, ) class Meta: abstract = True
class HtnReview(ReviewModelMixin, CrfModelMixin, edc_models.BaseUuidModel): test_date = models.DateField( verbose_name="Date tested for Hypertension", null=True, blank=True, editable=False, help_text="", ) dx = models.CharField( verbose_name="Has the patient been diagnosed with Hypertension?", max_length=15, choices=YES_NO_NA, default=NOT_APPLICABLE, ) sys_blood_pressure = edc_models.SystolicPressureField(null=True, blank=True) dia_blood_pressure = edc_models.DiastolicPressureField(null=True, blank=True) managed_by = models.CharField( verbose_name="How will the patient's hypertension be managed going forward?", max_length=25, choices=HTN_MANAGEMENT, default=NOT_APPLICABLE, ) care_start_date = models.DateField( verbose_name="Date clinical management started", null=True, blank=True, ) class Meta(CrfModelMixin.Meta, edc_models.BaseUuidModel.Meta): verbose_name = "Hypertension Review" verbose_name_plural = "Hypertension Review"
class CoronaKapDiseaseModelMixin(models.Model): # Disease burden hiv_pos = models.CharField( verbose_name=mark_safe("Does the patient have <u>HIV</u> infection?"), max_length=25, choices=YES_NO_UNKNOWN, ) hiv_pos_year = models.IntegerField( verbose_name=mark_safe( "If 'Yes', what year did you first test positive?"), validators=[MinValueValidator(1950), MaxValueValidator(2020)], null=True, blank=True, help_text="format YYYY", ) hiv_year_started_art = models.IntegerField( verbose_name= "If 'Yes', what year did you <u>start antiretroviral therapy</u>?", validators=[MinValueValidator(0)], null=True, blank=True, help_text="format YYYY", ) hiv_missed_doses = models.IntegerField( verbose_name=mark_safe( "If 'Yes', in the last month <u>how many days</u> did you miss " "taking your <u>ART</u> medications?"), null=True, blank=True, ) diabetic = models.CharField( verbose_name=mark_safe( "Have you been diagnosed with <u>diabetes</u>?"), max_length=25, choices=YES_NO_UNKNOWN, ) diabetic_dx_year = models.IntegerField( verbose_name=mark_safe( "If 'Yes', what year did you first learn you had <u>diabetes</u>?" ), validators=[MinValueValidator(1950), MaxValueValidator(2020)], null=True, blank=True, help_text="format YYYY", ) diabetic_on_meds = models.CharField( verbose_name=mark_safe( "If 'Yes', are you taking medications to control your <u>diabetes</u>?" ), max_length=25, choices=YES_NO_NA, default=NOT_APPLICABLE, ) diabetic_missed_doses = models.IntegerField( verbose_name=mark_safe( "If 'Yes', in the last month <u>how many days</u> did you miss " "taking your <u>diabetes</u> medications?"), null=True, blank=True, ) hypertensive = models.CharField( verbose_name=mark_safe( "Have you been diagnosed with <u>hypertension</u>?"), max_length=25, choices=YES_NO_UNKNOWN, ) hypertensive_dx_year = models.IntegerField( verbose_name=mark_safe( "If 'Yes', what year did you first learn you had <u>hypertension</u>?" ), validators=[MinValueValidator(1950), MaxValueValidator(2020)], null=True, blank=True, help_text="format YYYY", ) hypertensive_on_meds = models.CharField( verbose_name=mark_safe( "If 'Yes', are you taking medications to control your <u>hypertension</u>?" ), max_length=25, choices=YES_NO_NA, default=NOT_APPLICABLE, ) hypertensive_missed_doses = models.IntegerField( verbose_name=mark_safe( "If 'Yes', in the last month <u>how many days</u> did you miss " "taking your <u>hypertension</u> medications?"), null=True, blank=True, ) weight = edc_models.WeightField(null=True, blank=True) height = edc_models.HeightField(null=True, blank=True) sys_blood_pressure = edc_models.SystolicPressureField(null=True, blank=True) dia_blood_pressure = edc_models.DiastolicPressureField(null=True, blank=True) class Meta: abstract = True
class PartThreeFieldsModelMixin( FastingModelMixin, IfgModelMixin, OgttModelMixin, CreatinineModelFieldsMixin, models.Model, ): part_three_report_datetime = models.DateTimeField( verbose_name="Second stage report date and time", null=True, blank=False, help_text="Date and time of report.", ) sys_blood_pressure = edc_models.SystolicPressureField( null=True, blank=True, ) dia_blood_pressure = edc_models.DiastolicPressureField( null=True, blank=True, ) weight = edc_models.WeightField(null=True, blank=True) height = edc_models.HeightField(null=True, blank=True) waist_circumference = models.DecimalField( verbose_name="Waist circumference", max_digits=5, decimal_places=1, validators=[MinValueValidator(50.0), MaxValueValidator(175.0)], null=True, blank=True, help_text="in centimeters", ) hba1c_performed = models.CharField( verbose_name="Was the HbA1c performed?", max_length=15, choices=YES_NO, default=NO, help_text="", ) hba1c_value = models.DecimalField( verbose_name="HbA1c", max_digits=8, decimal_places=2, null=True, blank=True, help_text="in %", ) creatinine_performed = models.CharField( verbose_name="Was the serum creatinine performed?", max_length=15, choices=YES_NO, default=NO, help_text="", ) class Meta: abstract = True
class PartThreeFieldsModelMixin(CreatinineModelFieldsMixin, models.Model): part_three_report_datetime = models.DateTimeField( verbose_name="Second stage report date and time", null=True, blank=False, help_text="Date and time of report.", ) sys_blood_pressure = edc_models.SystolicPressureField( null=True, blank=True, ) dia_blood_pressure = edc_models.DiastolicPressureField( null=True, blank=True, ) weight = edc_models.WeightField(null=True, blank=True) height = edc_models.HeightField(null=True, blank=True) waist_circumference = models.DecimalField( verbose_name="Waist circumference", max_digits=5, decimal_places=1, validators=[MinValueValidator(50.0), MaxValueValidator(175.0)], null=True, blank=True, help_text="in centimeters", ) fasted = models.CharField( verbose_name="Has the participant fasted?", max_length=15, choices=YES_NO, null=True, blank=False, ) fasted_duration_str = models.CharField( verbose_name="How long have they fasted in hours and/or minutes?", max_length=8, validators=[hm_validator], null=True, blank=True, help_text= "Duration of fast. Format is `HHhMMm`. For example 1h23m, 12h7m, etc", ) fasted_duration_minutes = models.IntegerField( null=True, help_text="system calculated value") hba1c_performed = models.CharField( verbose_name="Was the HbA1c performed?", max_length=15, choices=YES_NO, default=NO, help_text="", ) hba1c = models.DecimalField( verbose_name="HbA1c", max_digits=8, decimal_places=2, null=True, blank=True, help_text="in %", ) creatinine_performed = models.CharField( verbose_name="Was the serum creatinine performed?", max_length=15, choices=YES_NO, default=NO, help_text="", ) # IFG fasting_glucose = models.DecimalField( verbose_name=mark_safe("Fasting glucose <u>level</u>"), max_digits=8, decimal_places=2, null=True, blank=True, ) fasting_glucose_quantifier = models.CharField( max_length=10, choices=RESULT_QUANTIFIER, default=EQ, ) fasting_glucose_units = models.CharField( verbose_name="Units (fasting glucose)", max_length=15, choices=GLUCOSE_UNITS, blank=True, null=True, ) fasting_glucose_datetime = models.DateTimeField( verbose_name=mark_safe( "<u>Time</u> fasting glucose <u>level</u> measured"), null=True, blank=True, ) ogtt_base_datetime = models.DateTimeField( verbose_name=mark_safe("<u>Time</u> oral glucose solution was given"), null=True, blank=True, help_text="(glucose solution given)", ) ogtt_two_hr = models.DecimalField( verbose_name=mark_safe("Blood glucose <u>level</u> 2-hours " "after oral glucose solution given"), max_digits=8, decimal_places=2, null=True, blank=True, ) ogtt_two_hr_quantifier = models.CharField( max_length=10, choices=RESULT_QUANTIFIER, default=EQ, ) ogtt_two_hr_units = models.CharField( verbose_name="Units (Blood glucose 2hrs after...)", max_length=15, choices=GLUCOSE_UNITS, blank=True, null=True, ) ogtt_two_hr_datetime = models.DateTimeField( verbose_name=mark_safe("<u>Time</u> blood glucose measured 2-hours " "after oral glucose solution given"), blank=True, null=True, help_text="(2 hours after glucose solution given)", ) class Meta: abstract = True