mirror of
https://github.com/Sudo-JHare/FhirPad.git
synced 2025-06-15 20:49:59 +00:00
75 lines
2.7 KiB
Python
75 lines
2.7 KiB
Python
from app import db, create_app
|
|
from app.models import ApplicationType, Category, OSSupport, FHIRSupport, Speciality, PricingLicense, DesignedFor, EHRSupport, User
|
|
|
|
app = create_app()
|
|
|
|
def seed_table(model, names):
|
|
for name in names:
|
|
if not model.query.filter_by(name=name).first():
|
|
db.session.add(model(name=name))
|
|
db.session.commit()
|
|
|
|
def seed_admin_user():
|
|
if not User.query.filter_by(username='admin').first():
|
|
admin = User(
|
|
username='admin',
|
|
email='admin@fhirpad.com',
|
|
is_admin=True,
|
|
force_password_change=True
|
|
)
|
|
admin.set_password('admin123')
|
|
db.session.add(admin)
|
|
db.session.commit()
|
|
print("Default admin user created: username=admin, password=admin123")
|
|
|
|
with app.app_context():
|
|
db.create_all()
|
|
|
|
try:
|
|
# Seed admin user
|
|
seed_admin_user()
|
|
|
|
# Seed application types
|
|
app_types = ['FHIR App', 'Bulk Data', 'Health Cards']
|
|
seed_table(ApplicationType, app_types)
|
|
|
|
# Seed categories
|
|
categories = [
|
|
'Care Coordination', 'Clinical Research', 'Data Visualization', 'Disease Management',
|
|
'Genomics', 'Medication Management', 'Patient Engagement', 'Population Health',
|
|
'Risk Calculation', 'FHIR Tools', 'Telehealth'
|
|
]
|
|
seed_table(Category, categories)
|
|
|
|
# Seed OS support
|
|
os_supports = ['iOS', 'Android', 'Web', 'Mac', 'Windows', 'Linux']
|
|
seed_table(OSSupport, os_supports)
|
|
|
|
# Seed FHIR support
|
|
fhir_supports = ['DSTU 2', 'STU 3', 'R4', 'R5']
|
|
seed_table(FHIRSupport, fhir_supports)
|
|
|
|
# Seed specialties
|
|
specialties = [
|
|
'Anesthesiology', 'Cardiology', 'Gastroenterology', 'Infectious Disease', 'Neurology',
|
|
'Obstetrics', 'Oncology', 'Pediatrics', 'Pulmonology', 'Nephrology', 'Rheumatology',
|
|
'Trauma', 'Primary Care'
|
|
]
|
|
seed_table(Speciality, specialties)
|
|
|
|
# Seed pricing/licenses
|
|
pricings = ['Open Source', 'Free', 'Per User', 'Site-Based', 'Subscription']
|
|
seed_table(PricingLicense, pricings)
|
|
|
|
# Seed designed for
|
|
designed_fors = ['Clinicians', 'Patients', 'Patients & Clinicians', 'IT Professionals']
|
|
seed_table(DesignedFor, designed_fors)
|
|
|
|
# Seed EHR support
|
|
ehr_supports = ['Allscripts', 'Athenahealth', 'Epic', 'Cerner', 'Meditech']
|
|
seed_table(EHRSupport, ehr_supports)
|
|
|
|
print("Database seeded successfully!")
|
|
except Exception as e:
|
|
print(f"Seeding failed: {str(e)}")
|
|
db.session.rollback() |