예제 #1
0
def api_get_hospitals(*, page='1'):
    page_index = get_page_index(page)
    num = yield from Hospital.findNumber('count(id)')
    p = Page(num, page_index)
    if num == 0:
        return dict(page=p, hospitals=())
    hospitals = yield from Hospital.findAll(limit=(p.offset, p.limit))
    return dict(page=p, hospitals=hospitals)
예제 #2
0
def api_get_hospitals(*, page='1'):
    page_index = get_page_index(page)
    num = yield from Hospital.findNumber('count(id)')
    p = Page(num, page_index)
    if num == 0:
        return dict(page=p, hospitals=())
    hospitals = yield from Hospital.findAll(limit=(p.offset, p.limit))
    return dict(page=p, hospitals=hospitals)
예제 #3
0
def add_hospital():
    if request.method == "POST":
        hosp_name = request.form['hosp_name']
        hosp_type = request.form['hosp_type']
        hosp_addr = request.form['hosp_addr']
        hosp_email = request.form['hosp_email']
        hosp_num = request.form['hosp_num']
        hosp_spec_empnl = request.form['hosp_spec_empnl']
        hosp_spec_up = request.form['hosp_spec_up']
        hosp = Hospital(hosp_name=hosp_name, hosp_type=hosp_type, hosp_addr=hosp_addr, hosp_contact_mail=hosp_email,
                        hosp_contact_no=hosp_num, hosp_spec_empanl=hosp_spec_empnl, hosp_spec_upgraded=hosp_spec_up)
        hosp.save_to_db()
        return redirect(url_for("login"))  # login for hosp
    return render_template("register.html")  # return to hosp registration
예제 #4
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__))
예제 #5
0
    def process_item(self, item, spider):
        record = Hospital(item['name'], item['province'], item['city'], item['district'],\
                    item['address'], item['phone'], item['category'], item['label'], item['groundpos'],\
                    item['marspos'], item['baidupos'], item['poiid'])

        self.session.add(record)
        self.session.commit()
예제 #6
0
def add_hospital():
    hospital_name = request.form.get('hospital_name')
    city = request.form.get('city_select')
    district = request.form.get('district_select')
    park = helpers.checkbox_to_bool(request.form.get('park'))
    handicapped = helpers.checkbox_to_bool(request.form.get('handicapped'))

    p = Place(city, district).get_objects()[0]
    Hospital(hospital_name, p.id, park=park, handicapped=handicapped).save()
    return redirect(url_for(views.admin_hospitals_page.__name__))
예제 #7
0
파일: utils.py 프로젝트: cdvr1993/MHSystem
def CreateHospitalInfo(dict = None):
    create = False
    if Hospital.objects.all() > 0:
        create = True
    if dict is None:
        raise Exception('Hospital dictionary is not defined')
    # También crearemos la información del Hospital
    if create:
        h = Hospital()
    else:
        h = Hospital.objects.get(pk=1)
    h.razon = dict['razon']
    h.rfc = dict['rfc']
    h.numero = dict['numero']
    h.calle = dict['calle']
    h.colonia = dict['colonia']
    h.municipio = dict['municipio']
    h.estado = dict['estado']
    h.save()
예제 #8
0
def add_hospitals():
    from models import Hospital

    hospitals = pd.DataFrame()
    hospitals = hospitals.append(pd.read_csv('../kb/kerala_hospitals.csv'))
    hospitals = hospitals.append(pd.read_csv('../kb/tamilnadu_hospitals.csv'))
    hospitals.index = hospitals.Sno
    hospitals = hospitals.drop('Sno', axis=1)
    hospitals = hospitals.drop('Unnamed: 0', axis=1)

    for i, row in hospitals.iterrows():
        new_hosp = Hospital(
            hosp_name=cleanVal(row['Hospital Name']),
            hosp_type=cleanVal(row['Hospital Type']),
            hosp_addr=cleanVal(row['Hospital Address']),
            hosp_contact_mail=cleanVal(row['Hospital E-Mail']),
            hosp_contact_no=cleanVal(row['Hospital Contact']),
            hosp_spec_empanl=cleanVal(row['Specialities Empanelled']),
            hosp_spec_upgraded=cleanVal(row['Specialities Upgraded']))
        new_hosp.save_to_db()
예제 #9
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__))
예제 #10
0
def update_hospital(hospital_id):
    hospital_name = request.form.get('modal_hospital_name')
    city = request.form.get('modal_city_select')
    district = request.form.get('modal_district_select')
    a = request.form.get('modal_park')
    park = helpers.checkbox_to_bool(request.form.get('modal_park'))
    handicapped = helpers.checkbox_to_bool(request.form.get('modal_handicapped'))

    if city and district:
        address = Place(city, district).get_objects()[0]
    else:
        address = None

    Hospital(id=hospital_id).get_object().update(hospital_name, address, handicapped=handicapped, park=park)
    return redirect(url_for(views.admin_hospitals_page.__name__))
예제 #11
0
def add_user_hospital():

    request_body = json.loads(request.data)

    # if request_body["birth"] :
    #     return "Datos incompletos"
    # else:

    user = Hospital(
        birth=request_body["birth"],
        DNI_paciente_hospital=request_body["DNI_paciente_hospital"],
        DNI_doctor_hospital=request_body["DNI_doctor_hospital"])
    db.session.add(user)
    db.session.commit()
    return "Posteo exitoso"
예제 #12
0
def find_match():
    for i in file.iterrows():
        name = str(i[1]['hosp_name']).split(',')[0]
        out = Hospital.find_by_name(_name=name)
        out = out.order_by(Hospital.hosp_name).all()
        found = False
        if out:
            for one_id in out:
                if str(str(i[1]['hosp_name']).split(',')
                       [-1]).upper() in one_id.hosp_addr:
                    print('sor')
                    print('\t', one_id.hosp_id, one_id.hosp_name,
                          one_id.hosp_addr)
                    found = True
                    print('eor')
예제 #13
0
def addhospital():
    form = addhospitalform()   
    if request.method=='POST' and form.validate_on_submit():
        hospital = Hospital(name=form.hospitalname.data,area=form.area.data,\
                            district=form.district.data, phone=form.phone.data, total_beds=form.total_beds.data,\
                            state=form.state.data,total_ward_beds=form.total_ward_beds.data,\
                            total_ward_beds_with_oxygen=form.total_ward_beds_with_oxygen.data,total_icu_beds=form.total_icu_beds.data,\
                            total_icu_beds_with_oxygen=form.total_icu_beds_with_oxygen.data,available_beds=form.total_beds.data,\
                            available_ward_beds=form.total_ward_beds.data,available_ward_beds_with_oxygen=form.total_ward_beds_with_oxygen.data,\
                            available_icu_beds=form.total_icu_beds.data,available_icu_beds_with_oxygen=form.total_icu_beds_with_oxygen.data)
        db.session.add(hospital)
        user = User(name=form.user.data, role='hospital', hospital=hospital)
        user.set_password(form.password.data)
        db.session.add(user)
        db.session.commit()
        return redirect(url_for('hospital'))
    return render_template('hospitaladd.html', form=form, title="Add Hospital")
예제 #14
0
def populateTable(type):
    # fields: name, address, zipcode, lat/long, opening_hours, business_status, rating, website, google_maps_url
    # phone_number, city_id, drugstores_nearby
    for city in cities_list:
        city_info = get_city_opendata(city)
        result = getJSON(type, city, city_info['state'])
        name = result['name']
        address = result['address']
        zipcode = result['zipcode']
        latitude = result['latitude']
        longitude = result['longitude']
        opening_hours = result['opening_hours']
        business_status = result['business_status']
        # rating = result['rating']
        # website = result['website']
        google_maps_url = result['url']
        # phone_number = result['phone_number']
        id = result['place_id']
        city_id = db.execute("SELECT * FROM city WHERE name = :city", {
            ":city": city
        }).first()
        if (type == 'hospital'):
            entry = Hospital(id=id,
                             name=name,
                             address=address,
                             zipcode=zipcode,
                             latitude=latitude,
                             longitude=longitude,
                             opening_hours=opening_hours,
                             business_status=business_status,
                             google_maps_url=google_maps_url,
                             city_id=city_id)
        else:
            entry = Drugstore(id=id,
                              name=name,
                              address=address,
                              zipcode=zipcode,
                              latitude=latitude,
                              longitude=longitude,
                              opening_hours=opening_hours,
                              business_status=business_status,
                              google_maps_url=google_maps_url,
                              city_id=city_id)

        db.session.add(entry)
    db.session.commit()
예제 #15
0
def filter_hospital_ajax():
    city = request.form.get('city')
    district = request.form.get('district')
    name = request.form.get('name')
    if name == '':
        name = None
    capacity = request.form.get('capacity')
    rate = request.form.get('rate')
    park = helpers.checkbox_to_bool(request.form.get('park'))
    handicapped = helpers.checkbox_to_bool(request.form.get('handicapped'))
    if city and district:
        address = Place(city, district).get_objects()[0]
    else:
        address = None

    hospitals = Hospital(address=address, name=name, capacity=capacity, rate=rate, park=park,
                         handicapped=handicapped).get_objects()

    return render_template('sub_templates/filtered_hospital_table.html', hospitals=hospitals)
예제 #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 hospital_details():
    selected_id = str(request.args.get('hosp_id'))
    hosp = Hospital.find_by_id(selected_id)
    specs_up = hosp.hosp_spec_upgraded
    specs_emp = hosp.hosp_spec_empanl
    dec_specs_up = decodeSpecialties(specs_up)
    dec_specs_emp = decodeSpecialties(specs_emp)
    # from views import AddScheme
    # form = AddScheme()
    # if form.is_submitted():
    #     sch_id = form.sch.data
    #     print(sch_id)
    #     scheme = Scheme.find_by_scheme_id(sch_id)
    #     print(scheme.name)
    #     hosp.Schemes.append(scheme)
    #     hosp.save_to_db()
    #     return render_template('hospitalDetails.html', title='Hospital Details', data=hosp, specs_up=dec_specs_up,
    #                        specs_emp=dec_specs_emp, auth=is_auth())
    return render_template('hospitalDetails.html', title='Hospital Details', data=hosp, specs_up=dec_specs_up,
                           specs_emp=dec_specs_emp, auth=is_auth())
예제 #18
0
def main():
    last_update = last_scrape()
    print("Last update: {}".format(last_update))
    print("Fetching page...")
    data = scrape("https://www.indexsante.ca/urgences/", last_update)
    cur_update = data.pop("last_update", last_update)
    if last_update == cur_update:
        print("Data already processed.")
        return
    all_records = []
    scrape_id = Scrape.create(scrape_date=cur_update).id
    defaults = {"scrape": scrape_id}
    for (region_str, records) in data.items():
        (region, _) = Region.get_or_create(nom=region_str, defaults=defaults)
        for record in records:
            hospital_name = record.pop("nom")
            (hospital, _) = Hospital.get_or_create(nom=hospital_name,
                                                   region=region.id,
                                                   defaults=defaults)
            record["hospital"] = hospital.id
            record["scrape"] = scrape_id
            all_records.append(record)
    HospitalRecord.insert_many(all_records).execute()
예제 #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 add_scheme_by_hosp_id(hosp_id, scheme_id):
    from models import Hospital, Scheme
    hosp = Hospital.find_by_id(int(hosp_id))
    scheme = Scheme.find_by_scheme_id(scheme_id)
    hosp.Schemes.append(scheme)
    hosp.save_to_db()
예제 #21
0
def addOneCityInfo(city_name):
    city_info = get_city_opendata(city_name)
    lat = city_info['latitude']
    longitude = city_info['longitude']
    state = city_info['state']
    pop = city_info['population']

    entryCity = City(name=city_name,
                     state=state,
                     latitude=lat,
                     longitude=longitude,
                     population=pop)
    db.session.add(entryCity)

    db.session.commit()

    sql_query = text("SELECT city.id FROM city WHERE city.name = \'" +
                     city_name + "\';")
    result = db.engine.execute(sql_query).first()
    cityID = result[0]

    hospital_results = getJSON('hospital', city_name, state)

    for hospital in hospital_results:
        name = hospital['name']
        address = hospital['address']
        zipcode = hospital['zipcode']
        latitude = hospital['latitude']
        longitude = hospital['longitude']
        opening_hours = hospital['opening_hours']
        business_status = hospital['business_status']

        google_maps_url = hospital['url']
        id = hospital['place_id']

        entry = Hospital(id=id,
                         name=name,
                         address=address,
                         zipcode=zipcode,
                         latitude=latitude,
                         longitude=longitude,
                         opening_hours=opening_hours,
                         business_status=business_status,
                         google_maps_url=google_maps_url,
                         city_id=cityID)
        db.session.add(entry)

    db.session.commit()

    drugstore_results = getJSON('drugstore', city_name, state)

    for drugstore in drugstore_results:
        name = drugstore['name']
        address = drugstore['address']
        zipcode = drugstore['zipcode']
        latitude = drugstore['latitude']
        longitude = drugstore['longitude']
        opening_hours = drugstore['opening_hours']
        business_status = drugstore['business_status']

        google_maps_url = drugstore['url']
        id = drugstore['place_id']

        entry = Drugstore(id=id,
                          name=name,
                          address=address,
                          zipcode=zipcode,
                          latitude=latitude,
                          longitude=longitude,
                          opening_hours=opening_hours,
                          business_status=business_status,
                          google_maps_url=google_maps_url,
                          city_id=cityID)
        db.session.add(entry)
        db.session.commit()

        sql_query = text(
            "SELECT hospital.id FROM hospital WHERE hospital.zipcode = \'" +
            zipcode + "\';")
        result = db.engine.execute(sql_query)

        if result.returns_rows:
            hospital_ids = [item[0] for item in result.fetchall()]
            for hospital_id in hospital_ids:
                hospitalObj = db.session.query(Hospital).get(hospital_id)
                entry.hospitals_nearby.append(hospitalObj)
                db.session.commit()
예제 #22
0
def get_hospitals_ajax():
    place = Place(request.form.get('city_name'), request.form.get('district_name')).get_objects()[0]
    hospitals = Hospital(address=place).get_objects()
    response = " ".join(
        ['<option value="{}">{}</option>'.format(hospital.id, hospital.name) for hospital in hospitals])
    return response
예제 #23
0
def serach_for_hosp(search_term):
    results1 = Hospital.find_by_name(_name=search_term).all()
    results2 = Hospital.find_by_addr(_addr=search_term).all()
    results = results1 + results2
    return list(set(results))
예제 #24
0
from models import Admin
from models import Hospital, Ward, Theater
from models import PractitionerDetails, PatientDetails
from models import PreOperativeRecord, OperativeRecord, PostOperativeRecord
from models import OperationRecord
from models import db_session as db

# creating models for use
admin = Admin(username="******", email="*****@*****.**", password="******")
parirenyatwa = Hospital(name="parirenyatwa")
bc1 = Ward(name="BC1", hospital_id=parirenyatwa.id)
theatre_a = Theater(name="TA", ward_id=bc1.id)

if __name__ == '__main__':
    db.add_all([admin, parirenyatwa, bc1, theatre_a])
    db.commit()
예제 #25
0
def search_hospital():
    form = SearchHospitalForm()
    if form.state != "None":
        form.city.choices = [(city.uuid, city.name) for city in City.find_by_state(form.city.data)]
    if form.is_submitted():
        if form.city != "None" or form.state != "None":
            city = City.get_by_id(form.city.data)
            state_name = city.name
            spec = form.spec.data
            scheme_id = form.scheme.data
            if spec != "None" and state_name != "" and not state_name.isspace():
                hosps = Hospital.find_by_spec_and_state(_spec=spec, _state=state_name)
                print("scheme id is ", scheme_id)
                if scheme_id != '0':
                    filtered = []
                    scheme = Scheme.find_by_scheme_id(scheme_id)
                    print(scheme.name)
                    print(scheme.partner_hospitals)
                    for a_hosp in hosps:
                        if a_hosp in scheme.partner_hospitals.all():
                            filtered.append(a_hosp)
                    print(filtered)
                    if len(filtered) <= 0:
                        flash("No Hospitals found, why don't you try without the Scheme filter!!")
                        return render_template("search_hospital.html", current_user=current_user, form=form)
                    return render_template('searchResult.html', data=filtered, current_user=current_user,
                                           auth=is_auth(),
                                           searchterm=state_name)
                print("results form spec for ", decodeSpecialties(spec)[0])
                if len(hosps.all()) > 0:
                    return render_template('searchResult.html', data=hosps, current_user=current_user, auth=is_auth(),
                                           searchterm=state_name)
                else:
                    print('no hospitals with ', spec)
                    flash("No Hospitals found, why don't you try without the Speciality filter!!")
                    return render_template("search_hospital.html", current_user=current_user, form=form, auth=is_auth())
            elif state_name != '' and not state_name.isspace():
                hosp = Hospital.find_by_state(state_name)
                if len(hosp.all()) > 0:
                    print("scheme id is ", scheme_id)
                    if scheme_id != '0':
                        scheme = Scheme.find_by_scheme_id(scheme_id)
                        print(scheme.name)
                        filtered = []
                        for a_hosp in hosp:
                            if a_hosp in scheme.partner_hospitals.all():
                                filtered.append(a_hosp)
                        if len(filtered) <= 0:
                            flash("No Hospitals found, why don't you try without the Scheme filter!!")
                            return render_template("search_hospital.html", current_user=current_user, form=form,
                                                   auth=is_auth())
                        return render_template('searchResult.html', data=filtered, current_user=current_user,
                                               auth=is_auth(),
                                               searchterm=state_name)
                    return render_template('searchResult.html', data=hosp, current_user=current_user,
                                           searchterm=state_name, auth=is_auth())
                else:
                    flash('No Hospitals found!!')
                    return render_template("search_hospital.html", current_user=current_user, form=form, auth=is_auth())
            else:
                flash("Enter a valid query")
                return render_template("search_hospital.html", current_user=current_user, form=form, auth=is_auth())
        flash("State and City are Mandatory Fields")
        return render_template("search_hospital.html", current_user=current_user, form=form, auth=is_auth())
    return render_template("search_hospital.html", current_user=current_user, form=form, auth=is_auth())
예제 #26
0
def del_hospital(hospital_id):
    Hospital(id=hospital_id).delete()
    return redirect(url_for(views.admin_hospitals_page.__name__))