Пример #1
0
def clinical_tests():
    other_tests = {
        'USG Abdomen': ['Abnormal'],
        'CECT Abdomen and Thorax': ['Visceral Metastasis'],
        'PET Scan': ['Visceral Metastasis', 'Skeletal Metastasis'],
        'Bone Scan': ['Skeletal Metastasis']
    }
    test_key = list(other_tests.keys())
    data_list = []
    for test in test_key:
        test_name = test
        test_done = gf.get_bool()
        if test_done:
            test_done = test_name + " done"
            data_list.append(test_done)
            abnormal = other_tests[test]
            for diagnosis in abnormal:
                test_diag = gf.get_bool()
                if test_diag:
                    test_details = 'data_not_available'
                else:
                    diagnosis = 'Normal'
                    test_details = "NA"
                data_list.append(diagnosis)
                data_list.append(test_details)
        else:
            test_done = test_name + "_not_done"
            data_list.append(test_done)
            abnormal = other_tests[test]
            for i in range(2 * len(abnormal)):
                i = 'NA'
                data_list.append(i)
    return data_list
def cancer_table(file_number):
    table_cancer = "previous_cancer_history"
    type_of_cancer_list = []
    year_diagnosis_list = []
    treat_all = []
    type_all = []
    duration_all = []
    data_return = []
    type_of_cancer = 'data_not_available'
    type_of_cancer_list.append(type_of_cancer)
    year_diagnosis = 'data_not_available'
    year_diagnosis_list.append(year_diagnosis)
    col = ("File_number, Type_Cancer, Year_diagnosis")
    treat_list = []
    type_list = []
    duration_list = []
    treated, type, duration = ("NA", ) * 3
    for treatment in PatientInfo.previous_cancer_treatment:
        treat = gf.get_bool()
        if treat:
            treat_list.append(treatment)
            type_treat = 'data_not_available'
            type_list.append(type_treat)
            duration_treat = 'data_not_available'
            duration_list.append(duration_treat)
            data = treatment, type_treat, duration_treat
            columns = [
                treatment, ("type_" + treatment), ("duration_" + treatment)
            ]
            treated = "; ".join(treat_list)
            type = "; ".join(type_list)
            duration = "; ".join(duration_list)
        elif not treat:
            index_no = "No " + treatment
            type_treat, duration_treat = ("NA", ) * 2
            data = index_no, type_treat, duration_treat
            columns = [
                treatment, ("type_" + treatment), ("duration_" + treatment)
            ]
        treat_all.append(treated)
        type_all.append(type)
        duration_all.append(duration)
    all_data = [
        type_of_cancer_list, year_diagnosis_list, treat_all, type_all,
        duration_all
    ]
    for index in all_data:
        data_joint = "|".join(index)
        data_return.append(data_joint)
    return tuple(data_return)
Пример #3
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)
Пример #4
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
Пример #5
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)