예제 #1
0
def add_human():
    name = request.form.get("doctor_name")
    surname = request.form.get("doctor_surname")
    tc = request.form.get("doctor_tc")
    password = request.form.get("doctor_password")
    email = request.form.get("doctor_email")
    authorize = request.form.get("authorize_select")
    city = request.form.get("city_select_add")
    district = request.form.get("district_select_add")
    address = Place(city=city, district=district).get_objects()[0]

    human = Human(tc=tc).get_object()
    if human is None:
        human = Human(tc=tc, password=password, authorize=authorize, name=name, surname=surname, mail=email,
                      address=address)
        human.save()

    if authorize == 'doctor':
        workdays = str()
        day_list = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
        for i, day in enumerate(day_list):
            if request.form.get(day) == "on":
                workdays += str(i + 1)
        expertise = request.form.get("doctor_expertise")
        hospital_id = request.form.get("hospital_select_add")
        hospital = Hospital(id=hospital_id).get_object()

        doctor = Doctor(human=human).get_object()
        if doctor is None:
            doctor = Doctor(human=human, workdays=workdays, expertise=expertise, hospital=hospital)
            doctor.save()
        #  else doctor is already created

    return redirect(url_for(views.admin_humans_page.__name__))
예제 #2
0
    def _parse_doctors(self, records):
        if not isinstance(records, list):
            doctor_id, surname, name, patronymic, doctor_spec = records
            return Doctor(doctor_id, surname, name, patronymic, doctor_spec)

        for i in range(len(records)):
            doctor_id, surname, name, patronymic, doctor_spec = records[i]
            records[i] = Doctor(doctor_id, surname, name, patronymic,
                                doctor_spec)
        return records
예제 #3
0
def create_doctor():
    if not request.is_json or 'name' not in request.get_json():
        return bad_request('Missing required data.')
    doctor = Doctor(request.get_json()['name'])
    db.session.add(doctor)
    db.session.commit()
    return jsonify({'doctor': doctor.serialize}), 201
예제 #4
0
def signup(request):
    """
    Sign Up Page, uses built in Sign-Up
    """
    if request.method == 'POST':
        form = SignUpForm(request.POST)
        if form.is_valid():
            form.save()
            username = form.cleaned_data.get('username')
            raw_password = form.cleaned_data.get('password1')
            name = form.cleaned_data.get('name')
            category = form.cleaned_data.get('category')
            user = authenticate(username=username, password=raw_password)
            if category == "doctor":
                doctor = Doctor(user=user, name=name)
                doctor.save()
            if category == "pharmacist":
                pharmacist = Pharmacist(user=user, name=name)
                pharmacist.save()
            if category == "patient":
                patient = Patient(user=user, name=name)
                patient.save()
            login(request, user)
            return redirect('/pharm/profile')
    else:
        form = SignUpForm()
    return render(request, 'pharmeasyflow/signup.html', {'form': form})
예제 #5
0
def register(request):
    if request.session.get('patient_mode'):
        return redirect('kiosk')
    # If there's a user logged in, require them to log out
    if request.user.is_authenticated():
        return redirect('manual_logout')
    # If it's post, the user has sent us their info and we need to try to set them up
    if request.method == 'POST':
        success = False
        user_form = UserForm(data=request.POST)
        if user_form.is_valid():
            # Save the user and associate it with a new Doctor
            user = user_form.save()
            user.set_password(user.password)
            user.save()

            doctor = Doctor()
            doctor.user = user
            doctor.save()
            success = True

        # Registration done, let's get out of here.
        # (note: I'm not actually sure whether it'd be more appropriate to
        # have a new view for the result and redirect to it. That sort of thing
        # seems common, but this seems simpler)
        return render(request, 'registration_report.html', {
            'success': success,
            'user_form': user_form
        })

    # Otherwise we diplay the form for them to fill out and post to us
    else:
        return render(request, 'register.html', {'user_form': UserForm()})
예제 #6
0
def doctor_add():
    form = DoctorForm()
    if request.method == 'POST' and form.validate_on_submit():
        doctor = Doctor(name=form.name.data, age=form.age.data, gender=form.gender.data, hospital=current_user.hospital)
        db.session.add(doctor)
        db.session.commit()
        flash('Doctor Data is added', 'success')
    return render_template('doctor_add.html', form=form)
예제 #7
0
 def test_doctor_model(self):
     """Does basic model work?"""
     d = Doctor(first_name="John",
                last_name="Fulcan",
                office_phone="555-5555")
     db.session.add(d)
     db.session.commit()
     """Doctor should have no patients & no medications"""
     self.assertEqual(len(d.medications), 0)
     self.assertEqual(len(d.medications_given), 0)
예제 #8
0
def get_doctor_info_ajax():
    human = Human(tc=request.form.get('doctor_tc')).get_object()
    doctor = Doctor(human=human).get_object()
    day_list = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
    workdays_ = doctor.workdays
    workdays = list()
    for i, workday_ in enumerate(workdays_):
        if int(workday_) == i + 1:
            workdays.append(day_list[i + 1])
    return render_template('sub_templates/doctor_info.html', doctor=doctor, workdays=workdays)
예제 #9
0
    def setUp(self):
        """Create test client, add sample data."""
        db.drop_all()
        db.create_all()

        d1 = Doctor(first_name="John", last_name="Fulcan")
        d2 = Doctor(first_name="Mike", last_name="NightRider")

        db.session.add(d1)
        db.session.add(d2)

        p1 = Patient(first_name="Blub",
                     last_name="Booper",
                     date_of_birth=datetime.date(1999, 1, 19))
        p2 = Patient(first_name="Jak",
                     last_name="Alomaty",
                     date_of_birth=datetime.date(2001, 3, 21))

        db.session.add(p1)
        db.session.add(p2)

        n1 = Nurse(first_name='Marko', last_name="jamie")
        n2 = Nurse(first_name='Jimbo', last_name="Kilayin")

        db.session.add(n1)
        db.session.add(n2)

        db.session.commit()

        d1 = Doctor.query.get(1)
        d2 = Doctor.query.get(2)
        p1 = Patient.query.get(1)
        p2 = Patient.query.get(2)

        self.d1 = d1
        self.d2 = d2
        self.p1 = p1
        self.p2 = p2
        self.n1 = n1
        self.n2 = n2

        self.client = app.test_client()
예제 #10
0
def register_doc(request, doc_id):
    filter = {'id': doc_id}
    data = data_from_url(request, 'https://drchrono.com/api/doctors',
                         filter)[0]
    doc = Doctor()
    doc.first_name = data['first_name']
    doc.last_name = data['last_name']
    doc.doctor_id = doc_id
    doc.total_wait_time = 0
    doc.total_patients = 0
    doc.save()
예제 #11
0
파일: views.py 프로젝트: Kayt/heartmed
def addUser():
    form = AddUserForm()
    if form.validate_on_submit():
        new = Doctor(username=form.username.data,
                     email=form.email.data,
                     password_hash=form.password.data)
        db.session.add(new)
        db.session.commit()
        flash('New {} added!!'.format(new.username))
        return redirect(url_for('dashboard'))
    return render_template('addUser.html', form=form)
예제 #12
0
def create_doctor(user_data):
    user = Doctor(
            government_id = user_data["government_id"],
            first_name = user_data["first_name"],
            last_name = user_data["last_name"],
            email = user_data["email"],
            phone_number = user_data["phone_number"],
            password_hash = create_password_hash( user_data["password"] ),
            verified = False
        )
    add_doctor_degrees( user, user_data.getlist("degree") )

    return user
예제 #13
0
def add_history():
    patient = Human(tc=session['user_tc']).get_object()
    doctor_tc = request.form.get('doctor_select')
    doctor = Doctor(human=Human(tc=doctor_tc).get_object()).get_object()
    hospital_id = request.form.get('hospital_select')
    hospital = Hospital(id=hospital_id).get_object()
    sickness = request.form.get('sickness')
    date = request.form.get('date')
    time = request.form.get('time')
    date_time = date + " " + time

    History(date=date_time, patient=patient, doctor=doctor, hospital=hospital, sickness=sickness).save()
    return redirect(url_for(views.home_page.__name__))
예제 #14
0
def add_user_doctors():

    request_body = json.loads(request.data)

    if request_body["name"] == None and request_body[
            "last_name"] == None and request_body["Especialidad"] == None:
        return "Datos incompletos"
    else:

        user = Doctor(name=request_body["name"],
                      last_name=request_body["last_name"],
                      Especialidad=request_body["Especialidad"])
        db.session.add(user)
        db.session.commit()
        return "Posteo exitoso"
예제 #15
0
def create_doctor():
    doctor_data = json.loads(request.data)
    doctor = Doctor(name=doctor_data["name"],
                    address=doctor_data["address"],
                    salary=doctor_data["salary"],
                    email=doctor_data["email"])
    try:
        doctor.insert()
    except IntegrityError:
        return jsonify({
            "success": False,
            "description": "there is doctor with the same email"
        })
    except Exception as err:
        return jsonify({"success": False, "error": str(err)}), 500

    return jsonify({"success": True, "doctor": doctor.format()}), 200
예제 #16
0
def seeder():

    print('#### Check Database seed ####')
    all_hospitals = db.session.execute(db.select(Hospital)).all()
    all_hospitals = [id for id, in all_hospitals]

    if (len(all_hospitals) <= 0):
        print('#### Tables are empty ####')
        print('#### Adding some entries... ####')
        with open('flaskr/seeders/seeders.json') as f:
            print('#### Adding some entries... ---####')
            data = json.load(f)

        for hospital in data['hospitals']:
            new_hospital = Hospital(hospital['id'], hospital['name'], hospital['city'])
            db.session.add(new_hospital)

        patients = {}
        for patient in data['patients']:
            new_patient = Patient(patient['id'], patient['name'], patient['surname'], patient['dni'], patient['hospital_id'])
            patients[patient['id']] = new_patient
            db.session.add(new_patient)

        for doctor in data['doctors']:
            new_doctor = Doctor(doctor['id'], doctor['name'], doctor['surname'], doctor['speciality'])
            if (new_doctor.id == '014bd297-0a3d-4a17-b207-cff187690045'):
                new_doctor.patients.append(patients['3a268172-6c5c-4d9b-8964-8b9a1e531af5'])
            if (new_doctor.id == 'a0f54d52-5ccb-4e50-adca-5ea0064262fd'):
                new_doctor.patients.append(patients['088d58e2-7691-47b6-a322-eeffcadc9054'])
            if (new_doctor.id == '1497d1be-577a-41ad-b129-45271e113cc0'):
                new_doctor.patients.append(patients['8ec8c43b-f7e1-43e4-b70f-6d5a9799a86a'])
            if (new_doctor.id == '9bb2e300-fa15-4063-a291-13f7199ddb52'):
                new_doctor.patients.append(patients['923ec756-87b7-4743-808b-795a04b6dd21'])
                new_doctor.patients.append(patients['3a268172-6c5c-4d9b-8964-8b9a1e531af5'])
            db.session.add(new_doctor)

        print(patients)
    
        db.session.commit()
        print('#### Finished! ####')
    else:
        print('#### Database already seed ####')
예제 #17
0
def add_doctors():
    name = input("Insira o nome do médico: ")
    cpf = input("Insira o CPF do médico: ")
    crm = input("Insira a CRM do médico: ")

    while True:
        try:
            genre = input(
                "Insira o sexo do médico (F - Feminino ou M - Masculino): ")

            if genre.upper() != Genre.FEMALE and genre.upper() != Genre.MALE:
                raise Exception(
                    "Insira um sexo válido (F - Feminino ou M - Masculino) ")
        except Exception as e:
            print(e)
        else:
            break

    while True:
        try:
            status = int(
                input(
                    "Insira o Status do cliente (1 - Ativo ou 2 - Inativo): "))

            if status != Status.ACTIVE and status != Status.INACTIVE:
                raise Exception(
                    "Insira um status válido(1 - Ativo ou 2 - Inativo)")
        except Exception as e:
            print(e)
        else:
            break

    doctor_class = Doctor(name, cpf, crm, genre.upper(), status)

    try:
        create_doctor(doctor_class)
    except Exception as e:
        print(e)
예제 #18
0
def save_user(doctor, access_token):
    """

    :param doctor:
    :param access_token:
    :return: saved user and doctor objects which can be used for performing operations
    """
    user = User.objects.create_user(
        id=doctor['id'],
        username=doctor['username'],
    )
    doctor = Doctor(
        first_name=doctor['first_name'],
        last_name=doctor['last_name'],
        user=user,
        token=access_token,
    )
    if Doctor.objects.filter(pk=user).exists():
        doctor.save(update_fields=['first_name', 'last_name'])
    else:
        doctor.save()

    return doctor, user
예제 #19
0
def get_doctors_ajax():
    hospital = Hospital(id=request.form.get('hospital_id')).get_object()
    doctors = Doctor(hospital=hospital).get_objects()
    response = " ".join(
        ['<option value="{}">{}</option>'.format(doctor.human.tc, doctor.human.name + " " + doctor.human.surname) for doctor in doctors])
    return response
예제 #20
0
def register_doctor():
    f_name = input('enter first name: ')
    l_name = input('enter last name: ')
    print('the doctor is added!!!')
    d = Doctor(f_name, l_name)
    doctors.append(d)
예제 #21
0
def delete_doctor():
    tc = request.form.get("doctor_tc")
    human_for_check = Human(tc=tc).get_object()
    if human_for_check is not None:
        Doctor(human=human_for_check).delete()
    return redirect(url_for('admin_humans_page'))
예제 #22
0
"""SEED FOR CAPSTONE"""
from models import db, connect_db, Medication, Doctor, Patient, Nurse, Medication_Given
from app import app
import datetime

# Create Tables
db.drop_all()
db.create_all()

d1 = Doctor(first_name="mikey", last_name="jamie", office_phone="555-5555")
d2 = Doctor(first_name="Jun", last_name="Folkan", office_phone="555-5555")
d3 = Doctor(first_name="Moke", last_name="NightRyder", office_phone="555-5555")
d4 = Doctor(first_name="Miguel", last_name="Sabado", office_phone="555-5555")

db.session.add(d1)
db.session.add(d2)
db.session.add(d3)
db.session.add(d4)
#  datetime.date(yr, month, day)
p1 = Patient(first_name="koopa",
             last_name="posha",
             date_of_birth=datetime.date(1999, 1, 19))
p2 = Patient(first_name="musha",
             last_name="shqarm",
             date_of_birth=datetime.date(2001, 4, 21))
p3 = Patient(first_name="Gibber",
             last_name="Nimmerman",
             date_of_birth=datetime.date(1973, 1, 9))
p4 = Patient(first_name="Andy",
             last_name="Rudoph",
             date_of_birth=datetime.date(1973, 1, 9))
예제 #23
0
def screen():

    print("from screen")
    print(request.method)

    if request.method == 'POST':

        name_of_test = request.form['name_of_test']
        if name_of_test not in [
                'fsmc', 'hads', 'memory_test', 'sf-36', '25_foot', '9_hpt',
                'pasat_3', 'neurostatus_scoring'
        ]:
            print('error')

        print("Here")

        birth_day = int(request.form['birth_day'])
        birth_month = int(request.form['birth_month'])
        birth_year = int(request.form['birth_year'])

        birth_date = datetime(birth_year, birth_month, birth_day)
        print(birth_date)

        patient = Patient.query.filter_by(fname=request.form['fname'].lower(),
                                          sname=request.form['sname'].lower(),
                                          lname=request.form['lname'].lower(),
                                          birth_date=birth_date).first()

        if not patient:

            patient = Patient(
                fname=request.form['fname'].lower(),
                sname=request.form['sname'].lower(),
                lname=request.form['lname'].lower(),
                birth_date=birth_date,
                sex=True if request.form['sex'] == "male" else False,
            )

            db.session.add(patient)
            db.session.commit()
            print("Patient Created")
        else:
            print("Patient Existed")

        doctor = Doctor.query.filter_by(
            fname=request.form['spec_fname'].lower(),
            sname=request.form['spec_sname'].lower(),
            lname=request.form['spec_lname'].lower(),
            clinic=request.form['clinic'].lower()).first()

        if not doctor:

            doctor = Doctor(fname=request.form['spec_fname'].lower(),
                            sname=request.form['spec_sname'].lower(),
                            lname=request.form['spec_lname'].lower(),
                            clinic=request.form['clinic'].lower())

            db.session.add(doctor)
            db.session.commit()
            print("Doctor Created")
        else:
            print("Doctor Existed")

        visit_day = int(request.form['visit_day'])
        visit_month = int(request.form['visit_month'])
        visit_year = int(request.form['visit_year'])

        visit_date = datetime(visit_year, visit_month, visit_day)
        print(visit_date)

        visit = Visit.query.filter_by(patient_id=patient.id,
                                      doctor_id=doctor.id,
                                      visit_date=visit_date).first()

        if not visit:

            visit = Visit(patient_id=patient.id,
                          doctor_id=doctor.id,
                          visit_date=visit_date)

            db.session.add(visit)
            db.session.commit()
            print("Visit Created")
        else:
            print("Visit Existed")

        screen_name = '_'.join([str(visit.id), name_of_test]) + '.png'
        screen_name = os.path.join(UPLOAD_FOLDER, screen_name)

        screenshot = request.form['screen'].split(',')[1]
        screenshot = base64.b64decode(screenshot)

        with open(screen_name, 'wb') as file:
            file.write(screenshot)

        print(name_of_test)

        test_summary = None
        if name_of_test == 'neurostatus_scoring':

            test_summary = EDSS(
                visit_id=visit.id,
                screenshot_path=screen_name,
                visual=float(request.form['visual']),
                brainstem=float(request.form['brainstem']),
                pyramidal=float(request.form['pyramidal']),
                cerebellar=float(request.form['cerebellar']),
                sensory=float(request.form['sensory']),
                bowel_bladder=float(request.form['bowel_bladder']),
                cerebral=float(request.form['cerebral']),
                ambulation_score=float(request.form['ambulation_score']),
                edss_step=float(request.form['edss_step']),
            )

        if name_of_test == 'fsmc':

            test_summary = FSMC(visit_id=visit.id,
                                screenshot_path=screen_name,
                                kog=int(request.form['kog']),
                                mot=int(request.form['mot']),
                                total=int(request.form['total']))

        if name_of_test == '25_foot':

            test_summary = Foot25(
                visit_id=visit.id,
                screenshot_path=screen_name,
                foot25_try1=float(request.form['foot25_try1']),
                foot25_try2=float(request.form['foot25_try2']),
                foot25_tools=request.form['foot25_tools'],
                foot25_addition=request.form['foot25_addition'])

        if name_of_test == 'hads':

            test_summary = HADS(visit_id=visit.id,
                                screenshot_path=screen_name,
                                anxiety=int(request.form['hads_anx']),
                                depression=int(request.form['hads_dep']))

        if name_of_test == 'memory_test':

            test_summary = MemoryTest(
                visit_id=visit.id,
                screenshot_path=screen_name,
                memtest_all=int(request.form['memtest_all']),
                memtest_correct=int(request.form['memtest_correct']),
                memtest_wrong=int(request.form['memtest_wrong']))

        if name_of_test == 'sf-36':

            test_summary = SF36(visit_id=visit.id,
                                screenshot_path=screen_name,
                                PHC=float(request.form['PHC']),
                                MHC=float(request.form['MHC']))

        if name_of_test == 'pasat_3':

            test_summary = PASAT3(visit_id=visit.id,
                                  screenshot_path=screen_name,
                                  form_type=request.form['pasat_form_type'],
                                  correct=int(request.form['pasat_correct']),
                                  procent=float(request.form['pasat_procent']))

        if name_of_test == '9_hpt':

            test_summary = HPT9(
                visit_id=visit.id,
                screenshot_path=screen_name,
                main_hand=request.form['hpt9_hand'],
                attempt_main_hand_1=float(request.form['hpt9_main_hand_1']),
                attempt_main_hand_2=float(request.form['hpt9_main_hand_2']),
                note_main=request.form['hpt9_note_main'],
                attempt_sec_hand_1=float(request.form['hpt9_sec_hand_1']),
                attempt_sec_hand_2=float(request.form['hpt9_sec_hand_1']),
                note_sec=request.form['hpt9_note_sec'])

        try:
            assert test_summary
            db.session.add(test_summary)
            db.session.commit()
        except AssertionError:
            print('No information about test results')

        print(test_summary)

    return redirect(url_for('index'))