Esempio n. 1
0
    def event_data():
        print("Please enter the following informations!")
        date_of_event = Switch.general_data_inputer(["Date of the event", "Date of the event (YYYY.MM.DD)"])
        start_time = Switch.general_data_inputer(["Start time", "Start time (hh:mm)"])
        end_time = Switch.general_data_inputer(["End time", "End time (hh:mm)", start_time])
        zip_code = Switch.general_data_inputer(["Zip code", "Zip code"])
        city = Switch.general_data_inputer(["City", "City"])
        address = Switch.general_data_inputer(["Address", "Address"])
        available_beds = Switch.general_data_inputer(["Available beds", "Available beds"])
        planned_donor_number = Switch.general_data_inputer(["Planned donor number", "Planned donor number"])
        event_duration_time = EventCalculations.duration_in_time(start_time, end_time)
        colon_in_duration_time = str(event_duration_time).find(":")
        final_donor_number = EventCalculations.maximum_donor_number(available_beds, start_time, end_time)
        success_rate = EventCalculations.success_rate(planned_donor_number, final_donor_number)
        success_text = EventCalculations.success_text(success_rate)

        os.system('cls')

        print("\n" + "-" * 32 + "\n")
        print("Details of the planned event:\n")
        print("Date of the event:", date_of_event)
        print("Start time:", start_time)
        print("End time:", end_time)
        print("Event duration time: %s hour(s) %s minute(s)" % (str(event_duration_time)[:colon_in_duration_time],
                str(event_duration_time)[colon_in_duration_time+1:colon_in_duration_time+3]))
        print("Zip code:", zip_code)
        print("City:", city)
        print("Address:", address)
        print("Available beds:", available_beds)
        print("Planned donor number:", planned_donor_number)
        print("Maximum donor number:", final_donor_number)
        print("Percent of success:", success_rate, "%")
        print("Efficiency:", success_text)
        print("\n" + "-" * 32)

        if os.path.isfile("C:/Users/" + user_name + "/AppData/Local/Programs/Python/Python35-32/Lib/site-packages/colorama-0.3.3-py3.5.egg"):
            save = SaveMenu.save_menu(2, 21)
        else:
            save = SaveMenuOldFashioned.save_menu(2, "Do you want to save?")
            print()
        if save:
            every_file_data = [str(date_of_event).replace("-", "."), str(start_time)[:len(str(start_time))-3],\
                               str(end_time)[:len(str(end_time))-3], zip_code, city, address, available_beds, \
                               planned_donor_number, final_donor_number]
            header = "id,date_of_event,start_time,end_time,zip_code,city,address,number_of_available_beds," + \
                     "planned_donor_number,final_donor_number\n"
            FileOperator.save_new_data(every_file_data, header, 'Data/donations.csv')
            print("Save was successful!")
            time.sleep(2)
Esempio n. 2
0
    def donor_register_app():
        print("Please enter the following informations!")

        name = Switch.general_data_inputer(
            ["Donor's name", "Enter your full name"])
        birth_date = Switch.general_data_inputer(
            ["Birth date", "Birth date (YYYY.MM.DD)"])
        weight = Switch.general_data_inputer(["Weight", "Weight"])
        gender = Switch.general_data_inputer(["Gender", "Gender"])
        uniqeid = Switch.general_data_inputer(
            ["Unique ID", "Unique identifier number"])
        expuniqeid = Switch.general_data_inputer(
            ["Expiration of ID", "Expiration date of your ID"])
        blood_type = Switch.general_data_inputer(
            ["Blood type", "Blood type (A, B, AB, 0 with +/-)"])
        last_donation = Switch.general_data_inputer([
            "Last donation date",
            "Last donation date (type 'never' if never before)"
        ])
        sick = Switch.general_data_inputer(
            ["Sickness", "Were you sick in the last month?"])
        phone_number = Switch.general_data_inputer(
            ["Mobile number", "Mobile number"])
        email = Switch.general_data_inputer(["Email", "E-mail address"])
        age_of_donor = Validations.count_age_of_donor(birth_date[0])
        hemoglobin = Validations.validate_hmg()
        suitable = Validations.donor_suitable(
            [birth_date, weight, last_donation, sick, hemoglobin])

        os.system('cls')

        print("\n" + "-" * 32 + "\n")
        print("Donor's data:\n")
        print("Name:", name)
        print("Birth date: %s - %d years old" % (birth_date[0], age_of_donor))
        print("Weight:", weight[0], "kg")
        print("Gender:", gender)
        print("Type of donor's ID: %s\nNumber of donor's ID: %s" %
              (uniqeid[0], uniqeid[1]))
        print("Expiration of donor's ID: %s" % expuniqeid[0])
        print("Last donation date: %s" % last_donation[0])
        print("Were donor sick last month:", sick[0])
        print("Phone number:", phone_number)
        print("Email:", email)
        print("Hemoglobin level:", hemoglobin[0], "\n")
        print(suitable[1])
        print("\n" + "-" * 32)

        if os.path.isfile(
                "C:/Users/" + user_name +
                "/AppData/Local/Programs/Python/Python35-32/Lib/site-packages/colorama-0.3.3-py3.5.egg"
        ):
            save = SaveMenu.save_menu(2, 24)
        else:
            save = SaveMenuOldFashioned.save_menu(2, "Do you want to save?")
            print()
        if save:
            every_file_data = [
                str(name),
                str(weight[0]),
                str(gender),
                str(birth_date[0]),
                str(last_donation[0]),
                str(sick[0]),
                str(uniqeid[1]),
                str(expuniqeid[0]),
                str(blood_type),
                str(hemoglobin[0]),
                str(email),
                str(phone_number),
                str(suitable[0])
            ]
            header = "name,weight,gender,date_of_birth,last_donation,last_month_sickness,unique_identifier," + \
                     "expiration_of_id,blood_type,hemoglobin,email,mobil,is_suitable"
            FileOperator.save_new_data(every_file_data, header,
                                       'Data/donors.csv')
            print("Save was successful!")
            time.sleep(2)