initial commit
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
public class DraftEncounterConfiguration : IEntityTypeConfiguration<DraftEncounter>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<DraftEncounter> builder)
|
||||
{
|
||||
builder.ToTable("draft_encounters", t =>
|
||||
{
|
||||
t.HasCheckConstraint("chk_draft_encounters_department",
|
||||
"department IS NULL OR department IN ('Emergency Department', 'Internal Medicine', 'General Medicine', 'Surgery', 'ICU', 'NICU', 'Medical-Surgical', 'Outpatient Clinic', 'Pediatrics', 'Obstetrics & Gynecology', 'Labor & Delivery', 'Cardiology', 'Orthopedics', 'Neurology', 'Oncology', 'Radiology', 'Laboratory', 'Psychiatry', 'Physical Therapy', 'Anesthesiology')");
|
||||
});
|
||||
builder.HasKey(e => e.Id);
|
||||
builder.Property(e => e.Id).HasColumnName("id").HasDefaultValueSql("gen_random_uuid()");
|
||||
builder.Property(e => e.BatchId).HasColumnName("batch_id").IsRequired();
|
||||
builder.Property(e => e.AdmissionDate).HasColumnName("admission_date");
|
||||
builder.Property(e => e.Department)
|
||||
.HasColumnName("department")
|
||||
.HasMaxLength(100)
|
||||
.HasConversion(
|
||||
v => v.HasValue ? v.Value.ToDbString() : null,
|
||||
v => v == null ? null : DepartmentExtensions.FromDbString(v));
|
||||
builder.Property(e => e.RoomBed).HasColumnName("room_bed").HasMaxLength(50);
|
||||
builder.Property(e => e.AdmissionReason).HasColumnName("admission_reason").HasMaxLength(500);
|
||||
builder.Property(e => e.DischargeDiagnosis).HasColumnName("discharge_diagnosis").HasMaxLength(500);
|
||||
builder.Property(e => e.Status).HasColumnName("status").HasMaxLength(20);
|
||||
builder.Property(e => e.CreatedAt).HasColumnName("created_at").HasDefaultValueSql("NOW()");
|
||||
builder.Property(e => e.UpdatedAt).HasColumnName("updated_at").HasDefaultValueSql("NOW()");
|
||||
|
||||
builder.HasOne(e => e.Batch).WithOne(b => b.DraftEncounter).HasForeignKey<DraftEncounter>(e => e.BatchId).OnDelete(DeleteBehavior.Cascade);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user