Commit a6111736 authored by Almouhannad's avatar Almouhannad

(B) Add configurations

parent 8150215a
using Domain.Entities.Medicals.Diseases;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Persistence.Configurations.Medicals.Diseases;
internal class DiseaseConfiguration : IEntityTypeConfiguration<Disease>
{
public void Configure(EntityTypeBuilder<Disease> builder)
{
builder.ToTable(nameof(Disease));
builder.Property(disease => disease.Name).HasMaxLength(50);
}
}
\ No newline at end of file
using Domain.Entities.Medicals.Hospitals;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Persistence.Configurations.Medicals.Hospitals;
internal class HospitalConfiguration : IEntityTypeConfiguration<Hospital>
{
public void Configure(EntityTypeBuilder<Hospital> builder)
{
builder.ToTable(nameof(Hospital));
builder.Property(hospital => hospital.Name).HasMaxLength(50);
}
}
\ No newline at end of file
using Domain.Entities.Medicals.MedicalImages;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Persistence.Configurations.Medicals.MedicalImages;
internal class MedicalImageConfiguration : IEntityTypeConfiguration<MedicalImage>
{
public void Configure(EntityTypeBuilder<MedicalImage> builder)
{
builder.ToTable(nameof(MedicalImage));
builder.Property(medicalImage => medicalImage.Description).HasMaxLength(250);
builder.Property(medicalImage => medicalImage.Name).HasMaxLength(50);
}
}
\ No newline at end of file
using Domain.Entities.Medicals.MedicalTests;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Persistence.Configurations.Medicals.MedicalTests;
internal class MedicalTestConfiguration : IEntityTypeConfiguration<MedicalTest>
{
public void Configure(EntityTypeBuilder<MedicalTest> builder)
{
builder.ToTable(nameof(MedicalTest));
builder.Property(medicalTest => medicalTest.Description).HasMaxLength(250);
builder.Property(medicalTest => medicalTest.Name).HasMaxLength(50);
}
}
\ No newline at end of file
using Domain.Entities.Medicals.Medicines;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Persistence.Configurations.Medicals.Medicines;
internal class MedicineConfiguration : IEntityTypeConfiguration<Medicine>
{
public void Configure(EntityTypeBuilder<Medicine> builder)
{
builder.ToTable(nameof(Medicine));
builder.Property(e => e.Dosage).HasColumnType("numeric(9, 3)");
builder.HasOne(medicine => medicine.MedicineForm)
.WithMany()
.OnDelete(DeleteBehavior.NoAction);
}
}
\ No newline at end of file
using Domain.Entities.Medicals.Medicines.MedicineFormValues;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Persistence.Configurations.Medicals.Medicines;
// TODO: Seed database with initial values from MedicineFormValues
internal class MedicineFormConfiguration : IEntityTypeConfiguration<MedicineForm>
{
public void Configure(EntityTypeBuilder<MedicineForm> builder)
{
builder.ToTable(nameof(MedicineForm));
builder.Property(medicineForm => medicineForm.Id).ValueGeneratedNever();
builder.Property(medicineForm => medicineForm.Name).HasMaxLength(50);
}
}
\ No newline at end of file
using Domain.Entities.People.Doctors;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Persistence.Configurations.People.Doctors;
internal class DoctorConfiguration : IEntityTypeConfiguration<Doctor>
{
public void Configure(EntityTypeBuilder<Doctor> builder)
{
builder.ToTable(nameof(Doctor));
builder.HasOne(doctor => doctor.PersonalInfo)
.WithOne()
.HasForeignKey<Doctor>("PersonalInfoId")
.OnDelete(DeleteBehavior.NoAction);
builder.HasOne(doctor => doctor.Status)
.WithMany()
.OnDelete(DeleteBehavior.NoAction);
builder.HasMany(doctor => doctor.Phones)
.WithOne()
.OnDelete(DeleteBehavior.NoAction);
}
}
\ No newline at end of file
using Domain.Entities.People.Doctors.Shared;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Persistence.Configurations.People.Doctors;
internal class DoctorPhoneConfiguration : IEntityTypeConfiguration<DoctorPhone>
{
public void Configure(EntityTypeBuilder<DoctorPhone> builder)
{
builder.ToTable(nameof(DoctorPhone));
builder.Property(doctorPhone => doctorPhone.Name).HasMaxLength(50);
builder.Property(doctorPhone => doctorPhone.Phone).HasMaxLength(20);
builder.HasIndex(doctorPhone => doctorPhone.Phone).IsUnique();
}
}
\ No newline at end of file
using Domain.Entities.People.Doctors.Shared.Constants.DoctorStatusValues;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Persistence.Configurations.People.Doctors;
// TODO: Seed database with initial values from DoctorStatusValues
internal class DoctorStatusConfiguration : IEntityTypeConfiguration<DoctorStatus>
{
public void Configure(EntityTypeBuilder<DoctorStatus> builder)
{
builder.ToTable(nameof(DoctorStatus));
builder.Property(doctorStatus => doctorStatus.Id).ValueGeneratedNever();
builder.Property(doctorStatus => doctorStatus.Name).HasMaxLength(50);
}
}
\ No newline at end of file
using Domain.Entities.People.Employees.Shared;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Persistence.Configurations.People.Employees;
internal class EmployeeAdditionalInfoConfiguration : IEntityTypeConfiguration<EmployeeAdditionalInfo>
{
public void Configure(EntityTypeBuilder<EmployeeAdditionalInfo> builder)
{
builder.ToTable(nameof(EmployeeAdditionalInfo));
builder.Property(employeeAdditionalInfo => employeeAdditionalInfo.AcademicQualification)
.HasMaxLength(50);
builder.Property(employeeAdditionalInfo => employeeAdditionalInfo.WorkPhone)
.HasMaxLength(20);
builder.Property(employeeAdditionalInfo => employeeAdditionalInfo.Location)
.HasMaxLength(50);
builder.Property(employeeAdditionalInfo => employeeAdditionalInfo.Specialization)
.HasMaxLength(50);
builder.Property(employeeAdditionalInfo => employeeAdditionalInfo.JobStatus)
.HasMaxLength(50);
builder.Property(e => e.ImageUrl)
.HasMaxLength(150);
}
}
\ No newline at end of file
using Domain.Entities.People.Employees;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Persistence.Configurations.People.Employees;
internal class EmployeeConfiguration : IEntityTypeConfiguration<Employee>
{
public void Configure(EntityTypeBuilder<Employee> builder)
{
builder.ToTable(nameof(Employee));
builder.Property(employee => employee.Id).ValueGeneratedOnAdd();
builder.Property(employee => employee.CenterStatus).HasMaxLength(50);
builder.Property(employee => employee.SerialNumber).HasMaxLength(20);
builder.Property(employee => employee.IsMarried).HasDefaultValue(false)
.IsRequired();
builder.HasOne(employee => employee.AdditionalInfo)
.WithOne()
.HasForeignKey<Employee>("AdditionalInfoId")
.OnDelete(DeleteBehavior.NoAction);
builder.HasOne(employee => employee.Patient)
.WithOne()
.HasForeignKey<Employee>(employee => employee.Id)
.OnDelete(DeleteBehavior.NoAction);
builder.HasMany(employee => employee.RelatedEmployees)
.WithMany(employee => employee.RelatedTo);
}
}
\ No newline at end of file
using Domain.Entities.People.Employees.Relations.EmployeeFamilyMembers;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Persistence.Configurations.People.Employees;
internal class EmployeeFamilyMemberConfiguration : IEntityTypeConfiguration<EmployeeFamilyMember>
{
public void Configure(EntityTypeBuilder<EmployeeFamilyMember> builder)
{
builder.ToTable(nameof(EmployeeFamilyMember));
builder.HasOne(employeeFamilyMember => employeeFamilyMember.Role)
.WithMany()
.OnDelete(DeleteBehavior.NoAction);
builder.HasOne(employeeFamilyMember => employeeFamilyMember.FamilyMember)
.WithMany()
.HasForeignKey(employeeFamilyMember => employeeFamilyMember.FamilyMemberId)
.OnDelete(DeleteBehavior.NoAction);
builder.HasOne(employeeFamilyMember => employeeFamilyMember.Employee)
.WithMany(employee => employee.FamilyMembers)
.HasForeignKey(employeeFamilyMember => employeeFamilyMember.EmployeeId)
.OnDelete(DeleteBehavior.NoAction);
}
}
\ No newline at end of file
using Domain.Entities.People.Employees.Relations.EmployeeFamilyMembers.FamilyRoleValues;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Persistence.Configurations.People.Employees;
// TODO: Seed database with initial values from FamilyRoleValues
internal class FamilyRoleConfiguration : IEntityTypeConfiguration<FamilyRole>
{
public void Configure(EntityTypeBuilder<FamilyRole> builder)
{
builder.ToTable(nameof(FamilyRole));
builder.Property(familyRole => familyRole.Id).ValueGeneratedNever();
builder.Property(familyRole => familyRole.Name).HasMaxLength(50);
}
}
\ No newline at end of file
using Domain.Entities.People.FamilyMembers;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Persistence.Configurations.People.FamilyMembers;
internal class FamilyMemberConfiguration : IEntityTypeConfiguration<FamilyMember>
{
public void Configure(EntityTypeBuilder<FamilyMember> builder)
{
builder.ToTable(nameof(FamilyMember));
builder.Property(familyMember => familyMember.Id).ValueGeneratedOnAdd();
builder.HasOne(familyMember => familyMember.Patient)
.WithOne()
.HasForeignKey<FamilyMember>(familyMember => familyMember.Id)
.OnDelete(DeleteBehavior.NoAction);
}
}
\ No newline at end of file
using Domain.Entities.People.Patients;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Persistence.Configurations.People.Patients;
internal class PatientConfiguration : IEntityTypeConfiguration<Patient>
{
public void Configure(EntityTypeBuilder<Patient> builder)
{
builder.ToTable(nameof(Patient));
builder.HasOne(patient => patient.PersonalInfo)
.WithOne()
.HasForeignKey<Patient>("PersonalInfoId")
.OnDelete(DeleteBehavior.NoAction);
builder.HasOne(patient => patient.Gender)
.WithMany()
.OnDelete(DeleteBehavior.NoAction);
builder.HasMany(patient => patient.Visits)
.WithOne(visit => visit.Patient)
.OnDelete(DeleteBehavior.NoAction);
}
}
\ No newline at end of file
using Domain.Entities.People.Patients.Relations.PatientDiseases;
using Domain.Entities.People.Patients.Relations.PatientMedicines;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Persistence.Configurations.People.Patients;
internal class PatientDiseaseConfiguration : IEntityTypeConfiguration<PatientDisease>
{
public void Configure(EntityTypeBuilder<PatientDisease> builder)
{
builder.ToTable(nameof(PatientDisease));
builder.HasOne(patientDisease => patientDisease.Patient)
.WithMany(patient => patient.Diseases)
.HasForeignKey(patientDisease => patientDisease.PatientId)
.OnDelete(DeleteBehavior.NoAction);
builder.HasOne(patientDisease => patientDisease.Disease)
.WithMany(medicine => medicine.Patients)
.HasForeignKey(patientDisease => patientDisease.DiseaseId)
.OnDelete(DeleteBehavior.NoAction);
builder.HasIndex(patientDisease =>
new { patientDisease.PatientId, patientDisease.DiseaseId })
.IsUnique();
}
}
using Domain.Entities.People.Patients.Relations.PatientMedicines;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Persistence.Configurations.People.Patients;
internal class PatientMedicineConfiguration : IEntityTypeConfiguration<PatientMedicine>
{
public void Configure(EntityTypeBuilder<PatientMedicine> builder)
{
builder.ToTable(nameof(PatientMedicine));
builder.HasOne(patientMedicine => patientMedicine.Patient)
.WithMany(patient => patient.Medicines)
.HasForeignKey(patientMedicine => patientMedicine.PatientId)
.OnDelete(DeleteBehavior.NoAction);
builder.HasOne(patientMedicine => patientMedicine.Medicine)
.WithMany(medicine => medicine.Patients)
.HasForeignKey(patientMedicine => patientMedicine.MedicineId)
.OnDelete(DeleteBehavior.NoAction);
builder.HasIndex(patientMedicine =>
new { patientMedicine.PatientId, patientMedicine.MedicineId })
.IsUnique();
}
}
\ No newline at end of file
using Domain.Entities.People.Shared.GenderValues;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Persistence.Configurations.People.Shared;
// TODO: Seed database with initial values from GenderValues
internal class GenderConfiguration : IEntityTypeConfiguration<Gender>
{
public void Configure(EntityTypeBuilder<Gender> builder)
{
builder.ToTable(nameof(Gender));
builder.Property(gender => gender.Id).ValueGeneratedNever();
builder.Property(gender => gender.Name).HasMaxLength(50);
}
}
\ No newline at end of file
using Domain.Entities.People.Shared;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Persistence.Configurations.People.Shared;
internal class PersonalInfoConfiguration : IEntityTypeConfiguration<PersonalInfo>
{
public void Configure(EntityTypeBuilder<PersonalInfo> builder)
{
builder.ToTable(nameof(PersonalInfo));
builder.Property(personalInfo => personalInfo.FirstName).HasMaxLength(50);
builder.Property(personalInfo => personalInfo.LastName).HasMaxLength(50);
builder.Property(personalInfo => personalInfo.MiddleName).HasMaxLength(50);
}
}
using Domain.Entities.Visits;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Persistence.Configurations.Visits;
internal class VisitConfiguration : IEntityTypeConfiguration<Visit>
{
public void Configure(EntityTypeBuilder<Visit> builder)
{
builder.ToTable(nameof(Visit));
builder.Property(visit => visit.Diagnosis).HasMaxLength(250);
builder.HasOne(visit => visit.Doctor)
.WithMany()
.OnDelete(DeleteBehavior.NoAction);
builder.HasOne(visit => visit.Hospital)
.WithMany()
.OnDelete(DeleteBehavior.NoAction);
}
}
\ No newline at end of file
using Domain.Entities.Visits.Relations.VisitMedicalImages;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Persistence.Configurations.Visits;
internal class VisitMedicalImageConfiguration : IEntityTypeConfiguration<VisitMedicalImage>
{
public void Configure(EntityTypeBuilder<VisitMedicalImage> builder)
{
builder.ToTable(nameof(VisitMedicalImage));
builder.Property(visitMedicalImage => visitMedicalImage.Result)
.HasMaxLength(250);
builder.HasOne(visitMedicalImage => visitMedicalImage.Visit)
.WithMany(visit => visit.MedicalImages)
.HasForeignKey(visitMedicalImage => visitMedicalImage.VisitId)
.OnDelete(DeleteBehavior.NoAction);
builder.HasOne(visitMedicalImage => visitMedicalImage.MedicalImage)
.WithMany()
.HasForeignKey(visitMedicalImage => visitMedicalImage.MedicalImageId)
.OnDelete(DeleteBehavior.NoAction);
builder.HasIndex(visitMedicalImage =>
new { visitMedicalImage.VisitId, visitMedicalImage.MedicalImageId })
.IsUnique();
}
}
\ No newline at end of file
using Domain.Entities.Visits.Relations.VisitMedicalTests;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Persistence.Configurations.Visits;
internal class VisitMedicalTestConfiguration : IEntityTypeConfiguration<VisitMedicalTest>
{
public void Configure(EntityTypeBuilder<VisitMedicalTest> builder)
{
builder.ToTable(nameof(VisitMedicalTest));
builder.Property(visitMedicalTest => visitMedicalTest.Result)
.HasMaxLength(250);
builder.HasOne(visitMedicalTest => visitMedicalTest.Visit)
.WithMany(visit => visit.MedicalTests)
.HasForeignKey(visitMedicalTest => visitMedicalTest.VisitId)
.OnDelete(DeleteBehavior.NoAction);
builder.HasOne(visitMedicalTest => visitMedicalTest.MedicalTest)
.WithMany()
.HasForeignKey(visitMedicalTest => visitMedicalTest.MedicalTestId)
.OnDelete(DeleteBehavior.NoAction);
builder.HasIndex(visitMedicalTest =>
new { visitMedicalTest.VisitId, visitMedicalTest.MedicalTestId })
.IsUnique();
}
}
\ No newline at end of file
using Domain.Entities.Visits.Relations.VisitMedicines;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Persistence.Configurations.Visits;
internal class VisitMedicineConfiguration : IEntityTypeConfiguration<VisitMedicine>
{
public void Configure(EntityTypeBuilder<VisitMedicine> builder)
{
builder.ToTable(nameof(VisitMedicine));
builder.HasOne(visitMedicine => visitMedicine.Visit)
.WithMany(visitMedicine => visitMedicine.Medicines)
.HasForeignKey(visitMedicine => visitMedicine.VisitId)
.OnDelete(DeleteBehavior.NoAction);
builder.HasOne(visitMedicine => visitMedicine.Medicine)
.WithMany()
.HasForeignKey(visitMedicine => visitMedicine.MedicineId)
.OnDelete(DeleteBehavior.NoAction);
builder.HasIndex(visitMedicine =>
new { visitMedicine.VisitId, visitMedicine.MedicineId })
.IsUnique();
}
}
\ No newline at end of file
using Domain.Entities.WaitingList;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Persistence.Configurations.WaitingList;
internal class WaitingListRecordConfiguration : IEntityTypeConfiguration<WaitingListRecord>
{
public void Configure(EntityTypeBuilder<WaitingListRecord> builder)
{
builder.ToTable(nameof(WaitingListRecord));
builder.Property(waitingListRecord => waitingListRecord.IsServed)
.HasDefaultValue(false)
.IsRequired();
builder.HasOne(waitingListRecord => waitingListRecord.Patient)
.WithMany()
.HasForeignKey(waitingListRecord => waitingListRecord.PatientId)
.OnDelete(DeleteBehavior.NoAction);
builder.HasOne(waitingListRecord => waitingListRecord.Doctor)
.WithMany()
.HasForeignKey(waitingListRecord => waitingListRecord.DoctorId)
.OnDelete(DeleteBehavior.NoAction);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment