示例#1
0
文件: holter_move.py 项目: p-p-m/tcp
def _init_new_day():
    for doctor in all_doctors():
        prefolder = os.path.split(doctor.folder)[0]
        if os.path.split(doctor.folder)[1] != _today_date():
            pprint('init new day', _today_date())
            doctor.folder = os.path.join(prefolder, _today_date())
            doctor.save_doctor()
示例#2
0
文件: views.py 项目: p-p-m/tcp
def small_statistics():
    doctor = doc_operations.doctor_by_request(request)
    doctors = all_doctors() if not doctor else [doctor]
    data = []
    today = datetime.datetime.strptime(_today_date(), ("%d.%m.%Y"))
    monthrange = calendar.monthrange(today.year, today.month)[1]
    #holters count for every day
    for doc in doctors:
        holters_count = get_doctor_holters_count(doc, DOCTORS, int(_today_date().split('.')[1]))
        for i in range(monthrange):
            if not i + 1 in holters_count:
                holters_count[i + 1] = -1
        # sum for all month (raw-sum):
        holters_sum = 0
        for hc in holters_count:
            if holters_count[hc] != -1:
                holters_sum += holters_count[hc]
        holters_count['sum'] = holters_sum
        data.append([doc.name, holters_count])
    #every day sum(column sum)
    if len(doctors) > 1:
        ed_sum = {}
        for day in holters_count:
            day_counts = [d[1][day] for d in data if d[1][day] != -1]
            ed_sum[day] = sum(day_counts)
        data.append(['Сумма за день', ed_sum])
    return render_template('small_statistics.html', data=data, monthrange=monthrange)
示例#3
0
文件: holter_move.py 项目: p-p-m/tcp
def _get_next_doctor(holter):
    doctors = [doctor for doctor in all_doctors() if doctor.is_holter_available(holter)]
    # print [doctor.engname for doctor in doctors]
    selected_doctor = doctors[0]
    for doctor in doctors:
        if doctor.holters_count() < selected_doctor.holters_count():
            selected_doctor = doctor
    min_doctors = [doctor for doctor in doctors if selected_doctor.holters_count == doctor.holters_count]
    return min_doctors[random.randint(0, len(min_doctors) - 1)]
示例#4
0
文件: views.py 项目: p-p-m/tcp
def first():
    global program_process
    global first_program_start
    global watch_process
    if not watch_process:
        watch_process = subprocess.Popen((sys.executable, 'logger.py'))
    if (request.args.get('start', '') and not program_process) or first_program_start:
        first_program_start = False
        print 'starting program_process'
        hm_parameters = (sys.executable, 'holter_move.py')
        program_process = subprocess.Popen(hm_parameters)
    if request.args.get('stop', '') and program_process:
        if program_process:
            print 'killing program_process'
            program_process.kill()
        program_process = None
    return render_template('first.html', doctors=all_doctors(), program_working=True if program_process else False)
示例#5
0
文件: views.py 项目: p-p-m/tcp
def _holters_data(doctor_and_day):
    '''
    This filter uses in small statistics to get holters data (patient name and holter name)
    '''
    #getting date
    day = doctor_and_day.split('$')[1]
    today_date = datetime.datetime.now()
    date = datetime.date(day=int(day), month=today_date.month, year=today_date.year)
    #getting doctor folder
    docfolder = doctor_and_day.split('$')[0].decode('utf-8')
    if docfolder == u'Сумма за день':  # in this case we need to show all doctros
        holters_data = ''
        for doctor in all_doctors():
            holters_data += _holter_data_by_doctor(doctor.name, date, doctor_name=doctor.name)
        header = '<tr><th>Доктор</th><th>Холтер</th><th>ФИО пациента</th></tr>'
    else:  # getting holters for one choosen doctor
        holters_data = _holter_data_by_doctor(docfolder, date)
        header = '<tr><th>Холтер</th><th>ФИО пациента</th><th>'
    return header + holters_data
示例#6
0
文件: tclogin.py 项目: p-p-m/tcp
def all_users():
    doctors = [User(d.engname, d.password, 'doctor') for d in all_doctors()]
    admin = User('admin', ADMIN_PASSWORD, 'admin')
    accountant = User('tatiana', ACC_PASSWORD, 'accountant')
    return doctors + [admin, accountant]
示例#7
0
def doctor_by_login(login):
    doctors = [doctor for doctor in all_doctors() if doctor.engname == login]
    return doctors[0] if doctors else None
示例#8
0
文件: views.py 项目: p-p-m/tcp
def doctor_control():
    return render_template('doctor_control.html', doctors=all_doctors())