def cal_table(file_number, mammo_breast):
    import helper_function.pccm_names as pccm_names
    table = "calcification_mammography"
    mass_number = gf.get_number_lt(1, 3)
    try:
        number_calc = int(mass_number)
    except ValueError:
        number_calc = 1
    location, calc_type, calicification_comments = [list([]) for _ in range(3)]
    for index in range(0, number_calc):
        mass_id = index + 1
        if mammo_breast == "Bilateral":
            mass_location = gf.get_choice(["Right Breast", "Left Breast"])
        else:
            mass_location = mammo_breast
        location.append(mass_location)
        mammo_calcification = gf.get_choice([
            "Skin", "Vascular", "Coarse or 'Popcorn-like'", "Large Rod-like",
            "Round and punctate", "Eggshell or Rim", "Dystrophic", "Suture",
            "Amorphous", "Coarse Heterogeneous", "Fine Pleomorphic",
            "Fine Linear or Fine Linear Branching", "Other"
        ])
        calc_type.append(mammo_calcification)
        mass_id = "Group " + str(index + 1)
        comment = 'na'
        calicification_comments.append(comment)
        data_list = [
            file_number, mass_id,
            str(mass_location), mammo_calcification, comment
        ]
        col_list = pccm_names.names_radio_mass(table)
    all_data = [[str(mass_number)], location, calc_type,
                calicification_comments]
    data_return = ask.join_lists(all_data, "; ")
    return tuple(data_return)
def birads():
    birad_list = [i for i in Radio.birads]
    mammo_birads = gf.get_choice(birad_list)
    mammo_birads_det = Radio.birads.get(mammo_birads)
    birad = mammo_birads + ": " + mammo_birads_det
    data_list = birad
    return data_list
def bio_info(file_number):
    module_name = "bio_info"
    mr_number = gf.get_number_lt(500, 2000)
    name = names.get_full_name(gender='female')
    aadhaar_card = 'data_not_available'
    date_first = gf.gen_date(base_date='2010-12-12')
    permanent_address = 'data_not_available'
    current_address = permanent_address
    phone = gf.get_number_lt(900000000, 999999999)
    email_id = 'data_not_available'
    gender = gf.get_choice(["Female", "Male"])
    date_of_birth = gf.get_dob()
    age_yrs = gf.get_age(date_of_birth)
    age_diag = gf.get_years(date_of_birth, date_first)
    place_birth = 'data_not_available'
    height_cm = gf.get_number_lt(140, 180)
    weight_kg = gf.get_number_lt(50, 90)
    weight = float(weight_kg)
    height = float(height_cm) / 100
    bmi = str(round(weight / (height * height)))
    columns_list = pccm_names.names_info(module_name)
    new_data = [
        mr_number, name, aadhaar_card, date_first, permanent_address,
        current_address, phone, email_id, gender, age_yrs, age_diag,
        date_of_birth, place_birth, height_cm, weight_kg, bmi
    ]
    return (age_diag, tuple(new_data))
def physical_activity_table(file_number):
    # def physical_activity_table(file_number):
    table_act = "physical_activity"
    columns = ", ".join(pccm_names.names_info("phys_act_table"))
    type_phys_list, freq_phys_list = [], []
    type_phys_act = gf.get_choice(options=PatientInfo.phys_act)
    type_phys_list.append(type_phys_act)
    freq_phys_act = gf.get_choice(options=PatientInfo.frequency)
    freq_phys_list.append(freq_phys_act)
    type_phys_act = gf.get_choice(options=PatientInfo.phys_act)
    type_phys_list.append(type_phys_act)
    freq_phys_act = gf.get_choice(options=PatientInfo.frequency)
    freq_phys_list.append(freq_phys_act)
    type_phys = '; '.join(type_phys_list)
    freq_phys = '; '.join(freq_phys_list)
    return (type_phys, freq_phys)
def lesion_location(lesion, option=MultiTest.breast_cancer):
    lesion_data = {}
    category = [
        "Location on right_breast", "Location on left_breast", 'Other Location'
    ]
    if lesion in {"right_breast", "bilateral"}:
        lesion_rb = gf.get_choice(option)
        lesion_rb_data = "RB-" + lesion_rb
        lesion_data.append(lesion_rb_data)
    if lesion in {"right_breast", "bilateral"}:
        lesion_lb = gf.get_choice(option)
        lesion_lb_data = "LB-" + lesion_lb
        lesion_data.append(lesion_lb_data)
    if lesion not in {MultiTest.breast_cancer}:
        lesion_other = str.lower(str.replace(lesion, ' ', '_'))
        lesion_data.append(lesion_other)
    lesion_data = "|".join(lesion_data)
    return lesion_data
def det_by(file_number):
    module_name = "det_by"
    options = ["Self", "Physician", "Screening Camp", "Other"]
    determined_by = gf.get_choice(options)
    if determined_by == "Screening Camp":
        sc_id = gf.get_number(5)
        determined_by = "Screening Camp ID " + str(sc_id)
    det_date = gf.gen_date(datetime.now().strftime("%Y-%m-%d"))
    data_list = [determined_by, det_date]
    return (tuple(data_list))
 def mammo_mass(self, mass_id):
     data_list = ask.default_data_list(self.col_list)
     mass_location = self.mammo_breast
     if self.mammo_breast == "bilateral":
         mass_location = gf.get_choice(RadioTables.breast)
     mass_quadrant = gf.get_choice(Radio.lesion_quadrant)
     mammo_mass_shape = gf.get_choice(RadioTables.mass_shape)
     mammo_mass_margin = gf.get_choice(RadioTables.mass_margin)
     mass_nipple = gf.get_number(10)
     size_input = gf.get_choice(['3d', '2d'])
     x = gf.get_number_lt(1, 10)
     y = gf.get_number_lt(1, 10)
     z = gf.get_number_lt(1, 10)
     if size_input == '3d':
         mass_dimension = [str(x) + ' x ' + str(y) + ' x ' + str(z)]
         mass_longest_dimension = max([x, y, z])
     elif size_input == '2d':
         mass_dimension = [str(x) + ' x ' + str(y)]
         mass_longest_dimension = max([x, y])
     mass_size_unit = gf.get_choice(RadioTables.mass_units)
     mass_name = "lesion_" + str(mass_id)
     modality = self.table
     data_list = [
         self.file_number, mass_location, mass_name, mass_quadrant,
         mammo_mass_shape, mammo_mass_margin, mass_nipple, mass_dimension,
         mass_longest_dimension, mass_size_unit, modality
     ]
     data_list = data_list + [self.user_name, sql.last_update()]
     return data_list
def habits(file_number, age):
    module_name = "habits"
    diet = gf.get_choice(PatientInfo.diet)
    alcohol = gf.get_yes_no_na()
    if alcohol == 'yes':
        alcohol_consump = "Alcohol Consumption"
        alcohol_age = gf.get_number_lt(21, age)
        alcohol_quant = gf.get_number_lt(1, 10)
        alcohol_duration = gf.get_choice(PatientInfo.frequency)
        alcohol_comments = 'na'
    elif alcohol == 'no':
        alcohol_consump = "No Alcohol Consumption"
        alcohol_age, alcohol_quant, alcohol_duration, alcohol_comments = (
            "No Alcohol Consumption", ) * 4
    else:
        alcohol_consump, alcohol_age, alcohol_quant, alcohol_duration, alcohol_comments = (
            alcohol, ) * 5
    data_list_alc = [
        diet, alcohol_consump, alcohol_age, alcohol_quant, alcohol_duration,
        alcohol_comments
    ]
    tobacco = gf.get_yes_no_na()
    if tobacco == 'yes':
        tobacco = "Tobacco consumption"
        exposure_type = gf.get_choice(PatientInfo.tobacco_exposure)
        if exposure_type == "Passive":
            tobacco_type_partic = gf.get_choice(PatientInfo.passive_tobacco)
            if tobacco_type_partic == "Home":
                tobacco_type_who = 'family member'
                tobacco_passive = tobacco_type_partic + (
                    " : ") + tobacco_type_who

            else:
                tobacco_passive = tobacco_type_partic
        else:
            tobacco_passive = "NA"
        tobacco_type = gf.get_choice(PatientInfo.type_tobacco)
        tobacco_age = gf.get_number_lt(15, age)
        tobacco_freq = gf.get_choice(PatientInfo.frequency)
        tobacco_quant = gf.get_number(5)
        tobacco_duration = age - tobacco_age
        tobacco_comments = 'na'
    elif tobacco == 'no':
        tobacco = "No Tobacco Consumption"
        exposure_type, tobacco_type, tobacco_passive, tobacco_age, tobacco_freq, tobacco_quant, tobacco_duration, \
        tobacco_comments = ("No Tobacco Consumption",) * 8
    else:
        exposure_type, tobacco_type, tobacco_passive, tobacco_age, tobacco_freq, tobacco_quant, tobacco_duration, \
        tobacco_comments = (tobacco,) * 8
    other_del_habits = 'na'
    data_list_tob = [
        tobacco, exposure_type, tobacco_passive, tobacco_type, tobacco_age,
        tobacco_freq, tobacco_quant, tobacco_duration, tobacco_comments,
        other_del_habits
    ]
    data_list = data_list_alc + data_list_tob
    return tuple(data_list)
def feed_duration(file_number, children_number):
    table = "breast_feeding"
    child_list, feeding_duration_list, feeding_details_list = [], [], []
    child_number = int(children_number)
    for index in range(0, child_number):
        kid = str(index + 1)
        kid_add = "Child " + kid
        child_list.append(kid_add)
        feeding_duration = str(gf.get_number_lt(1, 36))
        feeding_duration_list.append(feeding_duration)
        feeding_details = gf.get_choice(PatientInfo.breast_feeding)
        feeding_details_list.append(feeding_details)
    data_list = [child_list, feeding_duration_list, feeding_details_list]
    data_return = join_lists(data_list, "; ")
    return (data_return)
def family_cancer_table(file_number):
    type_cancer_list, relation_degree_list, type_relation_list, age_detect_list = [], [], [], []
    all_data = []
    type_of_cancer = 'data_not_available'
    type_cancer_list.append(type_of_cancer)
    relation_to_patient = gf.get_choice(PatientInfo.family)
    relation_degree_list.append(relation_to_patient)
    type_relation = 'data_not_available'
    type_relation_list.append(type_relation)
    age_at_detection_yrs = str(gf.get_number_lt(15, 80))
    age_detect_list.append(age_at_detection_yrs)
    family_history = file_number, type_of_cancer, relation_to_patient, type_relation, age_at_detection_yrs
    family_history_list = "; ".join([
        type_of_cancer, relation_to_patient, type_relation,
        age_at_detection_yrs
    ])
    all_data.append(family_history_list)
    all_data_flat = "|".join(all_data)
    return (all_data_flat)
Example #11
0
 def report(self):
     data_list = ask.default_data_list(self.col_list_all[1:])
     check_mammo = gf.get_choice(MultiTest.test_reason)
     reason_report = check_mammo
     mammo = gf.get_bool()
     if mammo:
         tomo = gf.get_bool()
         if tomo:
             tomography_y_n = "Yes"
         else:
             tomography_y_n = "No"
         report_date = gf.gen_date('2019-03-13')
         mammo_place = gf.get_choice(["PCCM", "Outside"])
         if mammo_place == "Outside":
             mammography_place = names.get_full_name()
         else:
             mammography_place = mammo_place
         mammography_indication = gf.get_choice(Radiology.mammo_indication)
         mammography_breast = gf.get_choice(MultiTest.breast_cancer)
         mammo_mass = gf.get_bool()
         mass_all = []
         mass_data = ['no_mass_detected']
         mass_all.append(mass_data)
         mammography_massnumber = "No mass detected"
         mammography_masslocation = "No mass detected"
         mammography_massshape = "No mass detected"
         mammography_massmargin = "No mass detected"
         mammography_massnipple_cm = "No mass detected"
         mammography_masssize = "No mass detected"
         mammography_masssize_unit = "No mass detected"
         mass_longest_dimension = 'na'
         if mammo_mass:
             mass_breast = gf.get_choice(MultiTest.breast_cancer)
             mass = radio_tables.MassCalcification(self.table, mass_breast,
                                                   self.file_number,
                                                   self.user_name)
             mammography_massnumber, mass_dat = mass.multiple_mass()
             [
                 mammography_masslocation, mass_name, mass_quadrant,
                 mammography_massshape, mammography_massmargin,
                 mammography_massnipple_cm, mammography_masssize,
                 mass_longest_dimension, mammography_masssize_unit, modality
             ] = mass_dat[1:]
         mammography_calcificationnumber = "No Calcification detected"
         mammography_calcificationlocation = "No Calcification detected"
         mammography_calcificationtype = "No Calcification detected"
         mammography_calcification_comments = "No Calcification detected"
         calc = gf.get_bool()
         if calc:
             mammography_calcification = radio_tables.cal_table(
                 self.file_number, mammography_breast)
             (mammography_calcificationnumber,
              mammography_calcificationlocation,
              mammography_calcificationtype,
              mammography_calcification_comments
              ) = mammography_calcification
         mammography_skin_involvement = gf.get_choice(
             Radiology.skin_involvement)
         mammography_node_description = 'nodes_not_described'
         mammography_node_size = 'nodes_not_described'
         mammography_node_size_unit = 'nodes_not_described'
         node_description = gf.get_bool()
         if node_description:
             mammography_node_description = gf.get_choice(
                 Radiology.node_description)
             mammography_node_size = gf.get_number_lt(3, 10)
             mammography_node_size_unit = 'cm'
         mammo_birad = gf.get_bool()
         if mammo_birad:
             mammography_birad = radio_tables.birads()
         else:
             mammography_birad = "BI-RAD not assigned in report"
         mammography_impression = gf.get_choice(Radiology.impression)
         data_list = [
             reason_report, report_date, mammography_place,
             mammography_indication, mammography_breast,
             mammography_massnumber, mammography_masslocation,
             mammography_massshape, mammography_massmargin,
             mammography_massnipple_cm, mammography_masssize[0],
             mammography_masssize_unit, mammography_calcificationnumber,
             mammography_calcificationlocation,
             mammography_calcificationtype,
             mammography_calcification_comments,
             mammography_skin_involvement, mammography_node_description,
             mammography_node_size, mammography_node_size_unit,
             mammography_birad, mammography_impression, tomography_y_n
         ]
         data_list = [str(dat) for dat in data_list]
     data_list = [self.file_number] + data_list + [
         self.user_name, sql.last_update()
     ]
     return data_list
Example #12
0
def family_details(file_number, age_mother):
    module_name = "family_details"
    col_list = pccm_names.names_info(module_name)
    marital_status = 'data_not_available'
    siblings = gf.get_yes_no_na()
    if siblings == 'yes':
        siblings_number = gf.get_number(5)
        sisters = gf.get_number(siblings_number)
        brothers = siblings_number - sisters
    elif siblings == 'no':
        siblings_number, sisters, brothers = "No Siblings", "0", "0"
    else:
        siblings_number, sisters, brothers = (siblings, ) * 3
    children_y_n = gf.get_yes_no_na()
    if children_y_n == 'yes':
        children_number = gf.get_number(5)
        daughters = gf.get_number(children_number)
        sons = children_number - daughters
    elif children_y_n == 'no':
        children_number, daughters, sons = 0, 0, 0
    else:
        children_number, daughters, sons = (children_y_n, ) * 3
    menarche = gf.get_number_lt(11, 20)
    menopause = gf.get_choice(PatientInfo.menopause_status)
    menopause_age = menopause
    if menopause == "Post-Menopausal":
        menopause_age = gf.get_number_lt(menarche, 60)
        lmp = "Last menstrual period " + str(menopause_age) + " yrs"
    else:
        lmp = gf.gen_date(base_date='2020-01-01')
    # category = "Type of Period"
    options = ["Regular", "Irregular", "Other"]
    period_type = gf.get_choice(options)
    number_pregnancy = gf.get_number(8)
    if number_pregnancy == "0":
        age_first_preg = 'No children'
        age_last_preg = 'No children'
        number_term = 'No children'
        number_abortion = 'No children'
        age_first = 'No children'
        age_last = 'No children'
        twice_birth = 'No children'
        breast_feeding_data = 'No children'
        kid_feeding = 'No children'
        duration_feeding = 'No children'
        breast_usage = 'No children'
    elif number_pregnancy == "Requires Follow-up":
        age_first_preg = number_pregnancy
        age_last_preg = number_pregnancy
        number_term = number_pregnancy
        number_abortion = number_pregnancy
        age_first = number_pregnancy
        age_last = number_pregnancy
        twice_birth = number_pregnancy
        breast_feeding_data = number_pregnancy
        kid_feeding = number_pregnancy
        duration_feeding = number_pregnancy
        breast_usage = number_pregnancy
    else:
        number_term = gf.get_number(5)
        number_abortion = gf.get_number(5)
        age_first_preg = gf.get_number_lt(menarche, 55)
        age_last_preg = "NA"
        age_first = gf.get_number_lt(0, age_mother)
        age_last = age_first
        if children_number == 0:
            age_first = children_number
            age_last = children_number
            twice_birth = children_number
            breast_feeding_data = children_number
            kid_feeding = children_number
            duration_feeding = children_number
            breast_usage = children_number
        elif children_y_n == 'yes':
            age_first = gf.get_number_lt(0, age_mother)
            if age_first_preg == "NA":
                age_first_preg = int(age_mother) - int(age_first)
            if int(children_number) > 1:
                age_last = gf.get_number_lt(0, age_first_preg)
                age_last_preg = age_mother - age_last
                if age_last_preg == "NA":
                    age_last_preg = str(int(age_mother) - int(age_last))
                twice_birth = gf.get_choice(
                    ["Two births in a year", "No two births in a year"])
            else:
                age_last = age_first
                age_last_preg = 'NA'
                twice_birth = "NA"
            breast_feeding = gf.get_bool()
            if breast_feeding:
                breast_feeding_data = "Breast feeding"
                feed_details = bct.feed_duration(file_number, children_number)
            else:
                breast_feeding_data = "No Breast feeding"
                feed_details = ("NA", ) * 3
            kid_feeding, duration_feeding, breast_usage = feed_details
        else:
            age_first = str(children_y_n)
            age_last = str(children_y_n)
            twice_birth = str(children_y_n)
            breast_feeding_data = str(children_y_n)
            kid_feeding = str(children_y_n)
            duration_feeding = str(children_y_n)
            breast_usage = str(children_y_n)
    fert_treat_y_n = gf.get_yes_no()
    if fert_treat_y_n == 'yes':
        fert_treat = "Fertility Treatment used"
        type_fert = gf.get_choice(PatientInfo.fert_treat)
        detail_fert = 'data_not_available'
        cycles_fert = gf.get_number_lt(1, 4)
        success_fert = gf.get_choice(
            ["Pregnancy from Treatment", "No pregnancy from treatment"])
    elif fert_treat_y_n == "no":
        fert_treat = "No Fertility Treatment used"
        type_fert = fert_treat
        detail_fert = fert_treat
        cycles_fert = fert_treat
        success_fert = fert_treat
    else:
        fert_treat = str(fert_treat_y_n)
        type_fert = str(fert_treat_y_n)
        detail_fert = str(fert_treat_y_n)
        cycles_fert = str(fert_treat_y_n)
        success_fert = str(fert_treat_y_n)
    birth_control = gf.get_yes_no_na()
    if birth_control == 'yes':
        type_birth_control = gf.get_choice(
            ["Birth control pills", "Copper-T", "Condom"])
        detail_birth_control = 'data_not_available'
        duration_birth_control = gf.get_number(max_no=age_mother)
    elif birth_control == 'no':
        type_birth_control = "No birth control used"
        detail_birth_control = "No birth control used"
        duration_birth_control = "No birth control used" * 3
    else:
        type_birth_control = birth_control
        detail_birth_control = birth_control
        duration_birth_control = birth_control
    data_list = [
        marital_status, siblings_number, sisters, brothers, children_number,
        daughters, sons, menarche, menopause, menopause_age, lmp, period_type,
        number_pregnancy, number_term, number_abortion, age_first,
        age_first_preg, age_last, age_last_preg, twice_birth,
        breast_feeding_data, kid_feeding, duration_feeding, breast_usage,
        fert_treat, type_fert, detail_fert, cycles_fert, success_fert,
        type_birth_control, detail_birth_control, duration_birth_control
    ]
    return tuple(data_list)
Example #13
0
def breast_symptoms(file_number, user_name):
    module_name = "breast_symptoms"
    symp_present = gf.get_bool()
    if symp_present:
        rb_symp_list = []
        rb_dur_list = []
        lb_symp_list = []
        lb_dur_list = []
        for index in PatientInfo.symp_state:
            symp = gf.get_bool()
            if symp:
                RB = gf.get_bool()
                if RB:
                    rb_symp = index
                    rb_dur = str(gf.get_number(5)) + gf.get_choice(
                        ['weeks', 'year', 'months', 'days'])
                    rb_symp_list.append(rb_symp)
                    rb_dur_list.append(rb_dur)
                LB = gf.get_bool()
                if LB:
                    lb_symp = index
                    lb_dur = str(gf.get_number(5)) + gf.get_choice(
                        ['weeks', 'year', 'months', 'days'])
                    lb_symp_list.append(lb_symp)
                    lb_dur_list.append(lb_dur)
        rb_symps = "; ".join(rb_symp_list)
        rb_duration = "; ".join(rb_dur_list)
        lb_symps = "; ".join(lb_symp_list)
        lb_duration = "; ".join(lb_dur_list)
        data_list_symp = [rb_symps, rb_duration, lb_symps, lb_duration]
        for index in range(0, len(data_list_symp)):
            if data_list_symp[index] == '':
                data_list_symp[index] = "NA"
        rb_symp_list = []
        rb_dur_list = []
        lb_symp_list = []
        lb_dur_list = []
        rb_symps_other = "; ".join(rb_symp_list)
        rb_duration_other = "; ".join(rb_dur_list)
        lb_symps_other = "; ".join(lb_symp_list)
        lb_duration_other = "; ".join(lb_dur_list)
        data_list_other = [
            rb_symps_other, rb_duration_other, lb_symps_other,
            lb_duration_other
        ]
        for index in range(0, len(data_list_other)):
            if data_list_other[index] == '':
                data_list_other[index] = "NA"
        met = []
        for symptom in PatientInfo.met_symptoms:
            met_symp = gf.get_bool()
            if met_symp:
                met.append([symptom])
        met_flat = [item for sublist in met for item in sublist]
        data_met = "; ".join(met_flat)
        if met_flat == []:
            data_met = "No Metastatis Symptoms"
    else:
        data_list_other = [
            "Symptoms at presentation not in report",
        ] * 4
        data_list_symp = [
            "Symptoms at presentation not in report",
        ] * 4
        data_met = "Symptoms at presentation not in report"
    columns_list = pccm_names.names_info(module_name)
    data_list = data_list_symp + data_list_other + [data_met]
    return tuple(data_list)