1198 lines
27 KiB
JavaScript
1198 lines
27 KiB
JavaScript
const db = require('../models');
|
|
const Users = db.users;
|
|
|
|
const Appointments = db.appointments;
|
|
|
|
const AuditLogs = db.audit_logs;
|
|
|
|
const FinancialEntries = db.financial_entries;
|
|
|
|
const MessageLogs = db.message_logs;
|
|
|
|
const MessageTemplates = db.message_templates;
|
|
|
|
const PatientProfiles = db.patient_profiles;
|
|
|
|
const PublicRequests = db.public_requests;
|
|
|
|
const Settings = db.settings;
|
|
|
|
const TherapistProfiles = db.therapist_profiles;
|
|
|
|
const AppointmentsData = [
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
start_at: new Date('2023-11-01T09:00:00Z'),
|
|
|
|
end_at: new Date('2023-11-01T10:00:00Z'),
|
|
|
|
status: 'completed',
|
|
|
|
type: 'Initial Consultation',
|
|
|
|
notes: 'Patient has a history of back pain.',
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
start_at: new Date('2023-11-02T11:00:00Z'),
|
|
|
|
end_at: new Date('2023-11-02T12:00:00Z'),
|
|
|
|
status: 'no_show',
|
|
|
|
type: 'Follow-up',
|
|
|
|
notes: 'Review progress on shoulder rehabilitation.',
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
start_at: new Date('2023-11-03T14:00:00Z'),
|
|
|
|
end_at: new Date('2023-11-03T15:00:00Z'),
|
|
|
|
status: 'confirmed',
|
|
|
|
type: 'Therapy Session',
|
|
|
|
notes: 'Focus on improving mobility.',
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
start_at: new Date('2023-11-04T10:00:00Z'),
|
|
|
|
end_at: new Date('2023-11-04T11:00:00Z'),
|
|
|
|
status: 'scheduled',
|
|
|
|
type: 'Consultation',
|
|
|
|
notes: 'Patient cancelled due to illness.',
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
start_at: new Date('2023-11-05T13:00:00Z'),
|
|
|
|
end_at: new Date('2023-11-05T14:00:00Z'),
|
|
|
|
status: 'confirmed',
|
|
|
|
type: 'Routine Check-up',
|
|
|
|
notes: 'Patient did not attend the session.',
|
|
},
|
|
];
|
|
|
|
const AuditLogsData = [
|
|
{
|
|
entity: 'appointments',
|
|
|
|
action: 'create',
|
|
|
|
details: 'Created a new appointment for Sarah Davis.',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
timestamp: new Date('2023-10-30T08:00:00Z'),
|
|
},
|
|
|
|
{
|
|
entity: 'financial_entries',
|
|
|
|
action: 'update',
|
|
|
|
details: "Updated status to paid for Emily Johnson's session.",
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
timestamp: new Date('2023-11-02T12:30:00Z'),
|
|
},
|
|
|
|
{
|
|
entity: 'public_requests',
|
|
|
|
action: 'delete',
|
|
|
|
details: 'Deleted a request from Charlie Black.',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
timestamp: new Date('2023-11-03T15:00:00Z'),
|
|
},
|
|
|
|
{
|
|
entity: 'message_templates',
|
|
|
|
action: 'create',
|
|
|
|
details: 'Added a new template for birthday greetings.',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
timestamp: new Date('2023-11-04T09:00:00Z'),
|
|
},
|
|
|
|
{
|
|
entity: 'users',
|
|
|
|
action: 'update',
|
|
|
|
details: 'Updated contact information for John Doe.',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
timestamp: new Date('2023-11-05T14:00:00Z'),
|
|
},
|
|
];
|
|
|
|
const FinancialEntriesData = [
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
description: 'Consultation Fee',
|
|
|
|
type: 'expense',
|
|
|
|
amount: 100,
|
|
|
|
due_date: new Date('2023-11-01T00:00:00Z'),
|
|
|
|
status: 'pending',
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
description: 'Therapy Session Fee',
|
|
|
|
type: 'expense',
|
|
|
|
amount: 150,
|
|
|
|
due_date: new Date('2023-11-02T00:00:00Z'),
|
|
|
|
status: 'pending',
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
description: 'Rehabilitation Fee',
|
|
|
|
type: 'income',
|
|
|
|
amount: 200,
|
|
|
|
due_date: new Date('2023-11-03T00:00:00Z'),
|
|
|
|
status: 'paid',
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
description: 'Consultation Fee',
|
|
|
|
type: 'income',
|
|
|
|
amount: 100,
|
|
|
|
due_date: new Date('2023-11-04T00:00:00Z'),
|
|
|
|
status: 'deleted',
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
description: 'Check-up Fee',
|
|
|
|
type: 'expense',
|
|
|
|
amount: 80,
|
|
|
|
due_date: new Date('2023-11-05T00:00:00Z'),
|
|
|
|
status: 'cancelled',
|
|
},
|
|
];
|
|
|
|
const MessageLogsData = [
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
channel: 'email',
|
|
|
|
content: 'This is a reminder for your upcoming appointment.',
|
|
|
|
sent_at: new Date('2023-10-31T09:00:00Z'),
|
|
|
|
status: 'sent',
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
channel: 'email',
|
|
|
|
content: 'Thank you for your payment. Here is your receipt.',
|
|
|
|
sent_at: new Date('2023-11-02T12:00:00Z'),
|
|
|
|
status: 'failed',
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
channel: 'whatsapp',
|
|
|
|
content: 'Happy Birthday! We wish you a wonderful year ahead.',
|
|
|
|
sent_at: new Date('2023-11-03T14:00:00Z'),
|
|
|
|
status: 'pending',
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
channel: 'whatsapp',
|
|
|
|
content: 'Your payment is due. Please make the necessary arrangements.',
|
|
|
|
sent_at: new Date('2023-11-04T10:00:00Z'),
|
|
|
|
status: 'sent',
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
channel: 'whatsapp',
|
|
|
|
content: 'A new request has been submitted. Please review it.',
|
|
|
|
sent_at: new Date('2023-11-05T13:00:00Z'),
|
|
|
|
status: 'failed',
|
|
},
|
|
];
|
|
|
|
const MessageTemplatesData = [
|
|
{
|
|
name: 'Appointment Reminder',
|
|
|
|
channel: 'whatsapp',
|
|
|
|
purpose: 'request_notification',
|
|
|
|
content: 'This is a reminder for your upcoming appointment.',
|
|
},
|
|
|
|
{
|
|
name: 'Payment Receipt',
|
|
|
|
channel: 'whatsapp',
|
|
|
|
purpose: 'charge',
|
|
|
|
content: 'Thank you for your payment. Here is your receipt.',
|
|
},
|
|
|
|
{
|
|
name: 'Birthday Greetings',
|
|
|
|
channel: 'whatsapp',
|
|
|
|
purpose: 'reminder',
|
|
|
|
content: 'Happy Birthday! We wish you a wonderful year ahead.',
|
|
},
|
|
|
|
{
|
|
name: 'Payment Due',
|
|
|
|
channel: 'whatsapp',
|
|
|
|
purpose: 'receipt',
|
|
|
|
content: 'Your payment is due. Please make the necessary arrangements.',
|
|
},
|
|
|
|
{
|
|
name: 'New Request Notification',
|
|
|
|
channel: 'email',
|
|
|
|
purpose: 'reminder',
|
|
|
|
content: 'A new request has been submitted. Please review it.',
|
|
},
|
|
];
|
|
|
|
const PatientProfilesData = [
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
birth_date: new Date('1985-06-15T00:00:00Z'),
|
|
|
|
address: '123 Main St, Springfield',
|
|
|
|
emergency_contact: 'John Davis',
|
|
|
|
consent_whatsapp: true,
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
birth_date: new Date('1990-09-25T00:00:00Z'),
|
|
|
|
address: '456 Elm St, Springfield',
|
|
|
|
emergency_contact: 'Michael Johnson',
|
|
|
|
consent_whatsapp: true,
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
birth_date: new Date('1975-03-10T00:00:00Z'),
|
|
|
|
address: '789 Oak St, Springfield',
|
|
|
|
emergency_contact: 'Laura Brown',
|
|
|
|
consent_whatsapp: true,
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
birth_date: new Date('1988-12-05T00:00:00Z'),
|
|
|
|
address: '321 Pine St, Springfield',
|
|
|
|
emergency_contact: 'Robert Smith',
|
|
|
|
consent_whatsapp: true,
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
birth_date: new Date('1982-01-20T00:00:00Z'),
|
|
|
|
address: '654 Maple St, Springfield',
|
|
|
|
emergency_contact: 'Anna Doe',
|
|
|
|
consent_whatsapp: true,
|
|
},
|
|
];
|
|
|
|
const PublicRequestsData = [
|
|
{
|
|
name: 'Alice Green',
|
|
|
|
contact: 'alice.green@example.com',
|
|
|
|
preferred_times: 'Morning',
|
|
|
|
message: 'Interested in a consultation for knee pain.',
|
|
|
|
status: 'confirmed',
|
|
},
|
|
|
|
{
|
|
name: 'Bob White',
|
|
|
|
contact: 'bob.white@example.com',
|
|
|
|
preferred_times: 'Afternoon',
|
|
|
|
message: 'Looking for therapy sessions for back pain.',
|
|
|
|
status: 'rejected',
|
|
},
|
|
|
|
{
|
|
name: 'Charlie Black',
|
|
|
|
contact: 'charlie.black@example.com',
|
|
|
|
preferred_times: 'Evening',
|
|
|
|
message: 'Need advice on post-surgery rehabilitation.',
|
|
|
|
status: 'confirmed',
|
|
},
|
|
|
|
{
|
|
name: 'Diana Blue',
|
|
|
|
contact: 'diana.blue@example.com',
|
|
|
|
preferred_times: 'Morning',
|
|
|
|
message: 'Seeking treatment for chronic neck pain.',
|
|
|
|
status: 'pending',
|
|
},
|
|
|
|
{
|
|
name: 'Ethan Red',
|
|
|
|
contact: 'ethan.red@example.com',
|
|
|
|
preferred_times: 'Afternoon',
|
|
|
|
message: 'Interested in sports therapy for ankle injury.',
|
|
|
|
status: 'confirmed',
|
|
},
|
|
];
|
|
|
|
const SettingsData = [
|
|
{
|
|
reminder_24h: true,
|
|
|
|
reminder_2h: true,
|
|
|
|
birthday_message: true,
|
|
|
|
google_calendar_sync: false,
|
|
|
|
whatsapp_enabled: true,
|
|
|
|
email_provider: 'SendGrid',
|
|
},
|
|
|
|
{
|
|
reminder_24h: false,
|
|
|
|
reminder_2h: false,
|
|
|
|
birthday_message: true,
|
|
|
|
google_calendar_sync: false,
|
|
|
|
whatsapp_enabled: true,
|
|
|
|
email_provider: 'Ernst Mayr',
|
|
},
|
|
|
|
{
|
|
reminder_24h: true,
|
|
|
|
reminder_2h: true,
|
|
|
|
birthday_message: true,
|
|
|
|
google_calendar_sync: false,
|
|
|
|
whatsapp_enabled: true,
|
|
|
|
email_provider: 'Archimedes',
|
|
},
|
|
|
|
{
|
|
reminder_24h: true,
|
|
|
|
reminder_2h: true,
|
|
|
|
birthday_message: false,
|
|
|
|
google_calendar_sync: false,
|
|
|
|
whatsapp_enabled: true,
|
|
|
|
email_provider: 'Stephen Hawking',
|
|
},
|
|
|
|
{
|
|
reminder_24h: true,
|
|
|
|
reminder_2h: true,
|
|
|
|
birthday_message: true,
|
|
|
|
google_calendar_sync: true,
|
|
|
|
whatsapp_enabled: false,
|
|
|
|
email_provider: 'James Watson',
|
|
},
|
|
];
|
|
|
|
const TherapistProfilesData = [
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
license_number: 'PT123456',
|
|
|
|
specialties: 'Orthopedics, Sports Therapy',
|
|
|
|
bio: 'Experienced in treating sports injuries and orthopedic conditions.',
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
license_number: 'PT654321',
|
|
|
|
specialties: 'Pediatrics, Neurology',
|
|
|
|
bio: 'Specializes in pediatric and neurological physiotherapy.',
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
license_number: 'PT789012',
|
|
|
|
specialties: 'Geriatrics, Cardiopulmonary',
|
|
|
|
bio: 'Focuses on geriatric and cardiopulmonary rehabilitation.',
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
license_number: 'PT345678',
|
|
|
|
specialties: "Women's Health, Manual Therapy",
|
|
|
|
bio: "Expert in women's health and manual therapy techniques.",
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
license_number: 'PT901234',
|
|
|
|
specialties: 'Chronic Pain, Vestibular Rehab',
|
|
|
|
bio: 'Dedicated to managing chronic pain and vestibular disorders.',
|
|
},
|
|
];
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
async function associateAppointmentWithPatient() {
|
|
const relatedPatient0 = await PatientProfiles.findOne({
|
|
offset: Math.floor(Math.random() * (await PatientProfiles.count())),
|
|
});
|
|
const Appointment0 = await Appointments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Appointment0?.setPatient) {
|
|
await Appointment0.setPatient(relatedPatient0);
|
|
}
|
|
|
|
const relatedPatient1 = await PatientProfiles.findOne({
|
|
offset: Math.floor(Math.random() * (await PatientProfiles.count())),
|
|
});
|
|
const Appointment1 = await Appointments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Appointment1?.setPatient) {
|
|
await Appointment1.setPatient(relatedPatient1);
|
|
}
|
|
|
|
const relatedPatient2 = await PatientProfiles.findOne({
|
|
offset: Math.floor(Math.random() * (await PatientProfiles.count())),
|
|
});
|
|
const Appointment2 = await Appointments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Appointment2?.setPatient) {
|
|
await Appointment2.setPatient(relatedPatient2);
|
|
}
|
|
|
|
const relatedPatient3 = await PatientProfiles.findOne({
|
|
offset: Math.floor(Math.random() * (await PatientProfiles.count())),
|
|
});
|
|
const Appointment3 = await Appointments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Appointment3?.setPatient) {
|
|
await Appointment3.setPatient(relatedPatient3);
|
|
}
|
|
|
|
const relatedPatient4 = await PatientProfiles.findOne({
|
|
offset: Math.floor(Math.random() * (await PatientProfiles.count())),
|
|
});
|
|
const Appointment4 = await Appointments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Appointment4?.setPatient) {
|
|
await Appointment4.setPatient(relatedPatient4);
|
|
}
|
|
}
|
|
|
|
async function associateAppointmentWithTherapist() {
|
|
const relatedTherapist0 = await TherapistProfiles.findOne({
|
|
offset: Math.floor(Math.random() * (await TherapistProfiles.count())),
|
|
});
|
|
const Appointment0 = await Appointments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Appointment0?.setTherapist) {
|
|
await Appointment0.setTherapist(relatedTherapist0);
|
|
}
|
|
|
|
const relatedTherapist1 = await TherapistProfiles.findOne({
|
|
offset: Math.floor(Math.random() * (await TherapistProfiles.count())),
|
|
});
|
|
const Appointment1 = await Appointments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Appointment1?.setTherapist) {
|
|
await Appointment1.setTherapist(relatedTherapist1);
|
|
}
|
|
|
|
const relatedTherapist2 = await TherapistProfiles.findOne({
|
|
offset: Math.floor(Math.random() * (await TherapistProfiles.count())),
|
|
});
|
|
const Appointment2 = await Appointments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Appointment2?.setTherapist) {
|
|
await Appointment2.setTherapist(relatedTherapist2);
|
|
}
|
|
|
|
const relatedTherapist3 = await TherapistProfiles.findOne({
|
|
offset: Math.floor(Math.random() * (await TherapistProfiles.count())),
|
|
});
|
|
const Appointment3 = await Appointments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Appointment3?.setTherapist) {
|
|
await Appointment3.setTherapist(relatedTherapist3);
|
|
}
|
|
|
|
const relatedTherapist4 = await TherapistProfiles.findOne({
|
|
offset: Math.floor(Math.random() * (await TherapistProfiles.count())),
|
|
});
|
|
const Appointment4 = await Appointments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Appointment4?.setTherapist) {
|
|
await Appointment4.setTherapist(relatedTherapist4);
|
|
}
|
|
}
|
|
|
|
async function associateAuditLogWithChanged_by() {
|
|
const relatedChanged_by0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const AuditLog0 = await AuditLogs.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (AuditLog0?.setChanged_by) {
|
|
await AuditLog0.setChanged_by(relatedChanged_by0);
|
|
}
|
|
|
|
const relatedChanged_by1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const AuditLog1 = await AuditLogs.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (AuditLog1?.setChanged_by) {
|
|
await AuditLog1.setChanged_by(relatedChanged_by1);
|
|
}
|
|
|
|
const relatedChanged_by2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const AuditLog2 = await AuditLogs.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (AuditLog2?.setChanged_by) {
|
|
await AuditLog2.setChanged_by(relatedChanged_by2);
|
|
}
|
|
|
|
const relatedChanged_by3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const AuditLog3 = await AuditLogs.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (AuditLog3?.setChanged_by) {
|
|
await AuditLog3.setChanged_by(relatedChanged_by3);
|
|
}
|
|
|
|
const relatedChanged_by4 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const AuditLog4 = await AuditLogs.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (AuditLog4?.setChanged_by) {
|
|
await AuditLog4.setChanged_by(relatedChanged_by4);
|
|
}
|
|
}
|
|
|
|
async function associateFinancialEntryWithAppointment() {
|
|
const relatedAppointment0 = await Appointments.findOne({
|
|
offset: Math.floor(Math.random() * (await Appointments.count())),
|
|
});
|
|
const FinancialEntry0 = await FinancialEntries.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (FinancialEntry0?.setAppointment) {
|
|
await FinancialEntry0.setAppointment(relatedAppointment0);
|
|
}
|
|
|
|
const relatedAppointment1 = await Appointments.findOne({
|
|
offset: Math.floor(Math.random() * (await Appointments.count())),
|
|
});
|
|
const FinancialEntry1 = await FinancialEntries.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (FinancialEntry1?.setAppointment) {
|
|
await FinancialEntry1.setAppointment(relatedAppointment1);
|
|
}
|
|
|
|
const relatedAppointment2 = await Appointments.findOne({
|
|
offset: Math.floor(Math.random() * (await Appointments.count())),
|
|
});
|
|
const FinancialEntry2 = await FinancialEntries.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (FinancialEntry2?.setAppointment) {
|
|
await FinancialEntry2.setAppointment(relatedAppointment2);
|
|
}
|
|
|
|
const relatedAppointment3 = await Appointments.findOne({
|
|
offset: Math.floor(Math.random() * (await Appointments.count())),
|
|
});
|
|
const FinancialEntry3 = await FinancialEntries.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (FinancialEntry3?.setAppointment) {
|
|
await FinancialEntry3.setAppointment(relatedAppointment3);
|
|
}
|
|
|
|
const relatedAppointment4 = await Appointments.findOne({
|
|
offset: Math.floor(Math.random() * (await Appointments.count())),
|
|
});
|
|
const FinancialEntry4 = await FinancialEntries.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (FinancialEntry4?.setAppointment) {
|
|
await FinancialEntry4.setAppointment(relatedAppointment4);
|
|
}
|
|
}
|
|
|
|
async function associateMessageLogWithPatient() {
|
|
const relatedPatient0 = await PatientProfiles.findOne({
|
|
offset: Math.floor(Math.random() * (await PatientProfiles.count())),
|
|
});
|
|
const MessageLog0 = await MessageLogs.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (MessageLog0?.setPatient) {
|
|
await MessageLog0.setPatient(relatedPatient0);
|
|
}
|
|
|
|
const relatedPatient1 = await PatientProfiles.findOne({
|
|
offset: Math.floor(Math.random() * (await PatientProfiles.count())),
|
|
});
|
|
const MessageLog1 = await MessageLogs.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (MessageLog1?.setPatient) {
|
|
await MessageLog1.setPatient(relatedPatient1);
|
|
}
|
|
|
|
const relatedPatient2 = await PatientProfiles.findOne({
|
|
offset: Math.floor(Math.random() * (await PatientProfiles.count())),
|
|
});
|
|
const MessageLog2 = await MessageLogs.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (MessageLog2?.setPatient) {
|
|
await MessageLog2.setPatient(relatedPatient2);
|
|
}
|
|
|
|
const relatedPatient3 = await PatientProfiles.findOne({
|
|
offset: Math.floor(Math.random() * (await PatientProfiles.count())),
|
|
});
|
|
const MessageLog3 = await MessageLogs.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (MessageLog3?.setPatient) {
|
|
await MessageLog3.setPatient(relatedPatient3);
|
|
}
|
|
|
|
const relatedPatient4 = await PatientProfiles.findOne({
|
|
offset: Math.floor(Math.random() * (await PatientProfiles.count())),
|
|
});
|
|
const MessageLog4 = await MessageLogs.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (MessageLog4?.setPatient) {
|
|
await MessageLog4.setPatient(relatedPatient4);
|
|
}
|
|
}
|
|
|
|
async function associateMessageLogWithAppointment() {
|
|
const relatedAppointment0 = await Appointments.findOne({
|
|
offset: Math.floor(Math.random() * (await Appointments.count())),
|
|
});
|
|
const MessageLog0 = await MessageLogs.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (MessageLog0?.setAppointment) {
|
|
await MessageLog0.setAppointment(relatedAppointment0);
|
|
}
|
|
|
|
const relatedAppointment1 = await Appointments.findOne({
|
|
offset: Math.floor(Math.random() * (await Appointments.count())),
|
|
});
|
|
const MessageLog1 = await MessageLogs.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (MessageLog1?.setAppointment) {
|
|
await MessageLog1.setAppointment(relatedAppointment1);
|
|
}
|
|
|
|
const relatedAppointment2 = await Appointments.findOne({
|
|
offset: Math.floor(Math.random() * (await Appointments.count())),
|
|
});
|
|
const MessageLog2 = await MessageLogs.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (MessageLog2?.setAppointment) {
|
|
await MessageLog2.setAppointment(relatedAppointment2);
|
|
}
|
|
|
|
const relatedAppointment3 = await Appointments.findOne({
|
|
offset: Math.floor(Math.random() * (await Appointments.count())),
|
|
});
|
|
const MessageLog3 = await MessageLogs.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (MessageLog3?.setAppointment) {
|
|
await MessageLog3.setAppointment(relatedAppointment3);
|
|
}
|
|
|
|
const relatedAppointment4 = await Appointments.findOne({
|
|
offset: Math.floor(Math.random() * (await Appointments.count())),
|
|
});
|
|
const MessageLog4 = await MessageLogs.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (MessageLog4?.setAppointment) {
|
|
await MessageLog4.setAppointment(relatedAppointment4);
|
|
}
|
|
}
|
|
|
|
async function associateMessageLogWithTemplate() {
|
|
const relatedTemplate0 = await MessageTemplates.findOne({
|
|
offset: Math.floor(Math.random() * (await MessageTemplates.count())),
|
|
});
|
|
const MessageLog0 = await MessageLogs.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (MessageLog0?.setTemplate) {
|
|
await MessageLog0.setTemplate(relatedTemplate0);
|
|
}
|
|
|
|
const relatedTemplate1 = await MessageTemplates.findOne({
|
|
offset: Math.floor(Math.random() * (await MessageTemplates.count())),
|
|
});
|
|
const MessageLog1 = await MessageLogs.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (MessageLog1?.setTemplate) {
|
|
await MessageLog1.setTemplate(relatedTemplate1);
|
|
}
|
|
|
|
const relatedTemplate2 = await MessageTemplates.findOne({
|
|
offset: Math.floor(Math.random() * (await MessageTemplates.count())),
|
|
});
|
|
const MessageLog2 = await MessageLogs.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (MessageLog2?.setTemplate) {
|
|
await MessageLog2.setTemplate(relatedTemplate2);
|
|
}
|
|
|
|
const relatedTemplate3 = await MessageTemplates.findOne({
|
|
offset: Math.floor(Math.random() * (await MessageTemplates.count())),
|
|
});
|
|
const MessageLog3 = await MessageLogs.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (MessageLog3?.setTemplate) {
|
|
await MessageLog3.setTemplate(relatedTemplate3);
|
|
}
|
|
|
|
const relatedTemplate4 = await MessageTemplates.findOne({
|
|
offset: Math.floor(Math.random() * (await MessageTemplates.count())),
|
|
});
|
|
const MessageLog4 = await MessageLogs.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (MessageLog4?.setTemplate) {
|
|
await MessageLog4.setTemplate(relatedTemplate4);
|
|
}
|
|
}
|
|
|
|
async function associatePatientProfileWithUser() {
|
|
const relatedUser0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const PatientProfile0 = await PatientProfiles.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (PatientProfile0?.setUser) {
|
|
await PatientProfile0.setUser(relatedUser0);
|
|
}
|
|
|
|
const relatedUser1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const PatientProfile1 = await PatientProfiles.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (PatientProfile1?.setUser) {
|
|
await PatientProfile1.setUser(relatedUser1);
|
|
}
|
|
|
|
const relatedUser2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const PatientProfile2 = await PatientProfiles.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (PatientProfile2?.setUser) {
|
|
await PatientProfile2.setUser(relatedUser2);
|
|
}
|
|
|
|
const relatedUser3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const PatientProfile3 = await PatientProfiles.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (PatientProfile3?.setUser) {
|
|
await PatientProfile3.setUser(relatedUser3);
|
|
}
|
|
|
|
const relatedUser4 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const PatientProfile4 = await PatientProfiles.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (PatientProfile4?.setUser) {
|
|
await PatientProfile4.setUser(relatedUser4);
|
|
}
|
|
}
|
|
|
|
async function associateTherapistProfileWithUser() {
|
|
const relatedUser0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const TherapistProfile0 = await TherapistProfiles.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (TherapistProfile0?.setUser) {
|
|
await TherapistProfile0.setUser(relatedUser0);
|
|
}
|
|
|
|
const relatedUser1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const TherapistProfile1 = await TherapistProfiles.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (TherapistProfile1?.setUser) {
|
|
await TherapistProfile1.setUser(relatedUser1);
|
|
}
|
|
|
|
const relatedUser2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const TherapistProfile2 = await TherapistProfiles.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (TherapistProfile2?.setUser) {
|
|
await TherapistProfile2.setUser(relatedUser2);
|
|
}
|
|
|
|
const relatedUser3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const TherapistProfile3 = await TherapistProfiles.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (TherapistProfile3?.setUser) {
|
|
await TherapistProfile3.setUser(relatedUser3);
|
|
}
|
|
|
|
const relatedUser4 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const TherapistProfile4 = await TherapistProfiles.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (TherapistProfile4?.setUser) {
|
|
await TherapistProfile4.setUser(relatedUser4);
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
up: async (queryInterface, Sequelize) => {
|
|
await Appointments.bulkCreate(AppointmentsData);
|
|
|
|
await AuditLogs.bulkCreate(AuditLogsData);
|
|
|
|
await FinancialEntries.bulkCreate(FinancialEntriesData);
|
|
|
|
await MessageLogs.bulkCreate(MessageLogsData);
|
|
|
|
await MessageTemplates.bulkCreate(MessageTemplatesData);
|
|
|
|
await PatientProfiles.bulkCreate(PatientProfilesData);
|
|
|
|
await PublicRequests.bulkCreate(PublicRequestsData);
|
|
|
|
await Settings.bulkCreate(SettingsData);
|
|
|
|
await TherapistProfiles.bulkCreate(TherapistProfilesData);
|
|
|
|
await Promise.all([
|
|
// Similar logic for "relation_many"
|
|
|
|
await associateAppointmentWithPatient(),
|
|
|
|
await associateAppointmentWithTherapist(),
|
|
|
|
await associateAuditLogWithChanged_by(),
|
|
|
|
await associateFinancialEntryWithAppointment(),
|
|
|
|
await associateMessageLogWithPatient(),
|
|
|
|
await associateMessageLogWithAppointment(),
|
|
|
|
await associateMessageLogWithTemplate(),
|
|
|
|
await associatePatientProfileWithUser(),
|
|
|
|
await associateTherapistProfileWithUser(),
|
|
]);
|
|
},
|
|
|
|
down: async (queryInterface, Sequelize) => {
|
|
await queryInterface.bulkDelete('appointments', null, {});
|
|
|
|
await queryInterface.bulkDelete('audit_logs', null, {});
|
|
|
|
await queryInterface.bulkDelete('financial_entries', null, {});
|
|
|
|
await queryInterface.bulkDelete('message_logs', null, {});
|
|
|
|
await queryInterface.bulkDelete('message_templates', null, {});
|
|
|
|
await queryInterface.bulkDelete('patient_profiles', null, {});
|
|
|
|
await queryInterface.bulkDelete('public_requests', null, {});
|
|
|
|
await queryInterface.bulkDelete('settings', null, {});
|
|
|
|
await queryInterface.bulkDelete('therapist_profiles', null, {});
|
|
},
|
|
};
|