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__))
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()
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__))
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__))
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
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"
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__))
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()
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")
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)
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 ####')
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()
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()
def del_hospital(hospital_id): Hospital(id=hospital_id).delete() return redirect(url_for(views.admin_hospitals_page.__name__))
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()
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
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