diff --git a/Migrations/20241213124817_Patients got messages.Designer.cs b/Migrations/20241213124817_Patients got messages.Designer.cs new file mode 100644 index 0000000..ed1c3f0 --- /dev/null +++ b/Migrations/20241213124817_Patients got messages.Designer.cs @@ -0,0 +1,170 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using SimpleLIS; + +#nullable disable + +namespace SimpleLIS.Migrations +{ + [DbContext(typeof(HL7DbContext))] + [Migration("20241213124817_Patients got messages")] + partial class Patientsgotmessages + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "8.0.11"); + + modelBuilder.Entity("SimpleLIS.Models.Message", b => + { + b.Property("MessageId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ControlId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("MessageType") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("PatientId") + .HasColumnType("INTEGER"); + + b.Property("ReceivingApp") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ReceivingFacility") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("SendingApp") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("SendingFacility") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Timestamp") + .HasColumnType("TEXT"); + + b.Property("Version") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("MessageId"); + + b.HasIndex("PatientId"); + + b.ToTable("Messages"); + }); + + modelBuilder.Entity("SimpleLIS.Models.Observation", b => + { + b.Property("ObservationId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AbnormalFlag") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("MessageId") + .HasColumnType("INTEGER"); + + b.Property("ObservationCode") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ObservationValue") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ResultStatus") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Units") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("ObservationId"); + + b.HasIndex("MessageId"); + + b.ToTable("Observations"); + }); + + modelBuilder.Entity("SimpleLIS.Models.Patient", b => + { + b.Property("PatientId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("DateOfBirth") + .HasColumnType("TEXT"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Gender") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("HL7PatientId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("PatientId"); + + b.ToTable("Patients"); + }); + + modelBuilder.Entity("SimpleLIS.Models.Message", b => + { + b.HasOne("SimpleLIS.Models.Patient", "Patient") + .WithMany("Messages") + .HasForeignKey("PatientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Patient"); + }); + + modelBuilder.Entity("SimpleLIS.Models.Observation", b => + { + b.HasOne("SimpleLIS.Models.Message", "Message") + .WithMany("Observations") + .HasForeignKey("MessageId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Message"); + }); + + modelBuilder.Entity("SimpleLIS.Models.Message", b => + { + b.Navigation("Observations"); + }); + + modelBuilder.Entity("SimpleLIS.Models.Patient", b => + { + b.Navigation("Messages"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Migrations/20241213124817_Patients got messages.cs b/Migrations/20241213124817_Patients got messages.cs new file mode 100644 index 0000000..8423967 --- /dev/null +++ b/Migrations/20241213124817_Patients got messages.cs @@ -0,0 +1,50 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace SimpleLIS.Migrations +{ + /// + public partial class Patientsgotmessages : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "PatientId", + table: "Messages", + type: "INTEGER", + nullable: false, + defaultValue: 0); + + migrationBuilder.CreateIndex( + name: "IX_Messages_PatientId", + table: "Messages", + column: "PatientId"); + + migrationBuilder.AddForeignKey( + name: "FK_Messages_Patients_PatientId", + table: "Messages", + column: "PatientId", + principalTable: "Patients", + principalColumn: "PatientId", + onDelete: ReferentialAction.Cascade); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Messages_Patients_PatientId", + table: "Messages"); + + migrationBuilder.DropIndex( + name: "IX_Messages_PatientId", + table: "Messages"); + + migrationBuilder.DropColumn( + name: "PatientId", + table: "Messages"); + } + } +} diff --git a/Migrations/HL7DbContextModelSnapshot.cs b/Migrations/HL7DbContextModelSnapshot.cs index 6f5269e..97dbc8b 100644 --- a/Migrations/HL7DbContextModelSnapshot.cs +++ b/Migrations/HL7DbContextModelSnapshot.cs @@ -31,6 +31,9 @@ namespace SimpleLIS.Migrations .IsRequired() .HasColumnType("TEXT"); + b.Property("PatientId") + .HasColumnType("INTEGER"); + b.Property("ReceivingApp") .IsRequired() .HasColumnType("TEXT"); @@ -56,6 +59,8 @@ namespace SimpleLIS.Migrations b.HasKey("MessageId"); + b.HasIndex("PatientId"); + b.ToTable("Messages"); }); @@ -125,6 +130,17 @@ namespace SimpleLIS.Migrations b.ToTable("Patients"); }); + modelBuilder.Entity("SimpleLIS.Models.Message", b => + { + b.HasOne("SimpleLIS.Models.Patient", "Patient") + .WithMany("Messages") + .HasForeignKey("PatientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Patient"); + }); + modelBuilder.Entity("SimpleLIS.Models.Observation", b => { b.HasOne("SimpleLIS.Models.Message", "Message") @@ -140,6 +156,11 @@ namespace SimpleLIS.Migrations { b.Navigation("Observations"); }); + + modelBuilder.Entity("SimpleLIS.Models.Patient", b => + { + b.Navigation("Messages"); + }); #pragma warning restore 612, 618 } }