diff --git a/DTO/MessageDTO.cs b/DTO/MessageDTO.cs index f6e256b..f33b6f2 100644 --- a/DTO/MessageDTO.cs +++ b/DTO/MessageDTO.cs @@ -3,31 +3,14 @@ namespace SimpleLIS.DTO; public class MessageDTO { public int MessageId { get; set; } -#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable. - public string ControlId { get; set; } // Unique identifier for the HL7 message -#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable. -#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable. - public string MessageType { get; set; } // Type of HL7 message (e.g., ORU^R01) -#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable. -#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable. - public string SendingApp { get; set; } // Sending application -#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable. -#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable. - public string SendingFacility { get; set; } // Sending facility -#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable. -#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable. - public string ReceivingApp { get; set; } // Receiving application -#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable. -#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable. - public string ReceivingFacility { get; set; } // Receiving facility -#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable. - public DateTime Timestamp { get; set; } // Message creation time -#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable. - public string Version { get; set; } // HL7 version -#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable. - - // Associated Observations -#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable. - public List Observations { get; set; } -#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable. + public required string ControlId { get; set; } + public required string MessageType { get; set; } + public string? SendingApp { get; set; } + public string? SendingFacility { get; set; } + public string? ReceivingApp { get; set; } + public string? ReceivingFacility { get; set; } + public DateTime Timestamp { get; set; } + public string? Version { get; set; } + public int PatientId { get; set; } + public required List Observations { get; set; } } diff --git a/DTO/ObservationDTO.cs b/DTO/ObservationDTO.cs index 616bc4c..c374d7d 100644 --- a/DTO/ObservationDTO.cs +++ b/DTO/ObservationDTO.cs @@ -2,20 +2,11 @@ namespace SimpleLIS.DTO; public class ObservationDTO { -#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable. - public string ObservationCode { get; set; } // Code identifying the observation (e.g., WBC, HGB) -#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable. -#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable. - public string ObservationValue { get; set; } // The observed value -#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable. -#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable. - public string Units { get; set; } // Units of measurement (e.g., g/dL, %) -#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable. -#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable. - public string AbnormalFlag { get; set; } // Indicates if the result is abnormal -#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable. -#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable. - public string ResultStatus { get; set; } // Status of the result (e.g., F for final) + public required string ObservationCode { get; set; } + public required string ObservationValue { get; set; } + public string? Units { get; set; } + public string? AbnormalFlag { get; set; } + public string? ResultStatus { get; set; } public int ObservationId { get; internal set; } -#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable. + public int MessageId { get; set; } } diff --git a/DTO/PatientDTO.cs b/DTO/PatientDTO.cs index 9057b31..c2f953b 100644 --- a/DTO/PatientDTO.cs +++ b/DTO/PatientDTO.cs @@ -1,14 +1,8 @@ public class PatientDTO { public int PatientId { get; set; } -#pragma warning disable CS8618 - public string LastName { get; set; } -#pragma warning restore CS8618 -#pragma warning disable CS8618 - public string FirstName { get; set; } -#pragma warning restore CS8618 + public string? LastName { get; set; } + public string? FirstName { get; set; } public DateTime DateOfBirth { get; set; } -#pragma warning disable CS8618 - public string Gender { get; set; } -#pragma warning restore CS8618 + public string? Gender { get; set; } } diff --git a/MessageProfile.cs b/MessageProfile.cs index f391d48..83d351f 100644 --- a/MessageProfile.cs +++ b/MessageProfile.cs @@ -8,11 +8,15 @@ public class MappingProfile : Profile { public MappingProfile() { - CreateMap(); - CreateMap(); - CreateMap(); + CreateMap() + .ForMember(dest => dest.Observations, opt => opt.MapFrom(src => src.Observations)); + CreateMap() + .ForMember(dest => dest.Patient, opt => opt.Ignore()); CreateMap(); - CreateMap(); + CreateMap() + .ForMember(dest => dest.Message, opt => opt.Ignore()); CreateMap(); + CreateMap() + .ForMember(dest => dest.Messages, opt => opt.Ignore()); } } diff --git a/Migrations/20241212113523_Initial migrations.Designer.cs b/Migrations/20241212113523_Initial migrations.Designer.cs deleted file mode 100644 index adb5613..0000000 --- a/Migrations/20241212113523_Initial migrations.Designer.cs +++ /dev/null @@ -1,149 +0,0 @@ -// -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("20241212113523_Initial migrations")] - partial class Initialmigrations - { - /// - 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("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.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.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"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Migrations/20241213124817_Patients got messages.cs b/Migrations/20241213124817_Patients got messages.cs deleted file mode 100644 index 8423967..0000000 --- a/Migrations/20241213124817_Patients got messages.cs +++ /dev/null @@ -1,50 +0,0 @@ -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/20241213124817_Patients got messages.Designer.cs b/Migrations/20241214065908_Initial Migrations.Designer.cs similarity index 90% rename from Migrations/20241213124817_Patients got messages.Designer.cs rename to Migrations/20241214065908_Initial Migrations.Designer.cs index ed1c3f0..9f3cee8 100644 --- a/Migrations/20241213124817_Patients got messages.Designer.cs +++ b/Migrations/20241214065908_Initial Migrations.Designer.cs @@ -11,8 +11,8 @@ using SimpleLIS; namespace SimpleLIS.Migrations { [DbContext(typeof(HL7DbContext))] - [Migration("20241213124817_Patients got messages")] - partial class Patientsgotmessages + [Migration("20241214065908_Initial Migrations")] + partial class InitialMigrations { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -38,26 +38,21 @@ namespace SimpleLIS.Migrations .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"); @@ -74,7 +69,6 @@ namespace SimpleLIS.Migrations .HasColumnType("INTEGER"); b.Property("AbnormalFlag") - .IsRequired() .HasColumnType("TEXT"); b.Property("MessageId") @@ -93,7 +87,6 @@ namespace SimpleLIS.Migrations .HasColumnType("TEXT"); b.Property("Units") - .IsRequired() .HasColumnType("TEXT"); b.HasKey("ObservationId"); @@ -113,19 +106,15 @@ namespace SimpleLIS.Migrations .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"); diff --git a/Migrations/20241212113523_Initial migrations.cs b/Migrations/20241214065908_Initial Migrations.cs similarity index 81% rename from Migrations/20241212113523_Initial migrations.cs rename to Migrations/20241214065908_Initial Migrations.cs index 8134b8d..d44a9ac 100644 --- a/Migrations/20241212113523_Initial migrations.cs +++ b/Migrations/20241214065908_Initial Migrations.cs @@ -6,11 +6,28 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace SimpleLIS.Migrations { /// - public partial class Initialmigrations : Migration + public partial class InitialMigrations : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { + migrationBuilder.CreateTable( + name: "Patients", + columns: table => new + { + PatientId = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + HL7PatientId = table.Column(type: "TEXT", nullable: true), + LastName = table.Column(type: "TEXT", nullable: true), + FirstName = table.Column(type: "TEXT", nullable: true), + DateOfBirth = table.Column(type: "TEXT", nullable: false), + Gender = table.Column(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Patients", x => x.PatientId); + }); + migrationBuilder.CreateTable( name: "Messages", columns: table => new @@ -19,33 +36,23 @@ namespace SimpleLIS.Migrations .Annotation("Sqlite:Autoincrement", true), ControlId = table.Column(type: "TEXT", nullable: false), MessageType = table.Column(type: "TEXT", nullable: false), - SendingApp = table.Column(type: "TEXT", nullable: false), - SendingFacility = table.Column(type: "TEXT", nullable: false), - ReceivingApp = table.Column(type: "TEXT", nullable: false), - ReceivingFacility = table.Column(type: "TEXT", nullable: false), + SendingApp = table.Column(type: "TEXT", nullable: true), + SendingFacility = table.Column(type: "TEXT", nullable: true), + ReceivingApp = table.Column(type: "TEXT", nullable: true), + ReceivingFacility = table.Column(type: "TEXT", nullable: true), Timestamp = table.Column(type: "TEXT", nullable: false), - Version = table.Column(type: "TEXT", nullable: false) + Version = table.Column(type: "TEXT", nullable: true), + PatientId = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Messages", x => x.MessageId); - }); - - migrationBuilder.CreateTable( - name: "Patients", - columns: table => new - { - PatientId = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - HL7PatientId = table.Column(type: "TEXT", nullable: false), - LastName = table.Column(type: "TEXT", nullable: false), - FirstName = table.Column(type: "TEXT", nullable: false), - DateOfBirth = table.Column(type: "TEXT", nullable: false), - Gender = table.Column(type: "TEXT", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Patients", x => x.PatientId); + table.ForeignKey( + name: "FK_Messages_Patients_PatientId", + column: x => x.PatientId, + principalTable: "Patients", + principalColumn: "PatientId", + onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( @@ -57,8 +64,8 @@ namespace SimpleLIS.Migrations MessageId = table.Column(type: "INTEGER", nullable: false), ObservationCode = table.Column(type: "TEXT", nullable: false), ObservationValue = table.Column(type: "TEXT", nullable: false), - Units = table.Column(type: "TEXT", nullable: false), - AbnormalFlag = table.Column(type: "TEXT", nullable: false), + Units = table.Column(type: "TEXT", nullable: true), + AbnormalFlag = table.Column(type: "TEXT", nullable: true), ResultStatus = table.Column(type: "TEXT", nullable: false) }, constraints: table => @@ -72,6 +79,11 @@ namespace SimpleLIS.Migrations onDelete: ReferentialAction.Cascade); }); + migrationBuilder.CreateIndex( + name: "IX_Messages_PatientId", + table: "Messages", + column: "PatientId"); + migrationBuilder.CreateIndex( name: "IX_Observations_MessageId", table: "Observations", @@ -85,10 +97,10 @@ namespace SimpleLIS.Migrations name: "Observations"); migrationBuilder.DropTable( - name: "Patients"); + name: "Messages"); migrationBuilder.DropTable( - name: "Messages"); + name: "Patients"); } } } diff --git a/Migrations/HL7DbContextModelSnapshot.cs b/Migrations/HL7DbContextModelSnapshot.cs index 97dbc8b..ea7e817 100644 --- a/Migrations/HL7DbContextModelSnapshot.cs +++ b/Migrations/HL7DbContextModelSnapshot.cs @@ -35,26 +35,21 @@ namespace SimpleLIS.Migrations .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"); @@ -71,7 +66,6 @@ namespace SimpleLIS.Migrations .HasColumnType("INTEGER"); b.Property("AbnormalFlag") - .IsRequired() .HasColumnType("TEXT"); b.Property("MessageId") @@ -90,7 +84,6 @@ namespace SimpleLIS.Migrations .HasColumnType("TEXT"); b.Property("Units") - .IsRequired() .HasColumnType("TEXT"); b.HasKey("ObservationId"); @@ -110,19 +103,15 @@ namespace SimpleLIS.Migrations .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"); diff --git a/Models/Message.cs b/Models/Message.cs index 06d8867..d2d8397 100644 --- a/Models/Message.cs +++ b/Models/Message.cs @@ -3,36 +3,15 @@ namespace SimpleLIS.Models; public class Message { public int MessageId { get; set; } -#pragma warning disable CS8618 - public string ControlId { get; set; } -#pragma warning restore CS8618 -#pragma warning disable CS8618 - public string MessageType { get; set; } -#pragma warning restore CS8618 -#pragma warning disable CS8618 - public string SendingApp { get; set; } -#pragma warning restore CS8618 -#pragma warning disable CS8618 - public string SendingFacility { get; set; } -#pragma warning restore CS8618 -#pragma warning disable CS8618 - public string ReceivingApp { get; set; } -#pragma warning restore CS8618 -#pragma warning disable CS8618 - public string ReceivingFacility { get; set; } -#pragma warning restore CS8618 + public required string ControlId { get; set; } + public required string MessageType { get; set; } + public string? SendingApp { get; set; } + public string? SendingFacility { get; set; } + public string? ReceivingApp { get; set; } + public string? ReceivingFacility { get; set; } public DateTime Timestamp { get; set; } -#pragma warning disable CS8618 - public string Version { get; set; } -#pragma warning restore CS8618 - - // Navigation Property for Observations -#pragma warning disable CS8618 - public ICollection Observations { get; set; } -#pragma warning restore CS8618 - + public string? Version { get; set; } + public required ICollection Observations { get; set; } public int PatientId { get; set; } -#pragma warning disable CS8618 - public Patient Patient { get; set; } -#pragma warning restore CS8618 + public required Patient Patient { get; set; } } diff --git a/Models/Observation.cs b/Models/Observation.cs index cc9415f..311e2d2 100644 --- a/Models/Observation.cs +++ b/Models/Observation.cs @@ -3,25 +3,11 @@ namespace SimpleLIS.Models; public class Observation { public int ObservationId { get; set; } - public int MessageId { get; set; } // Foreign Key -#pragma warning disable CS8618 - public string ObservationCode { get; set; } -#pragma warning restore CS8618 -#pragma warning disable CS8618 - public string ObservationValue { get; set; } -#pragma warning restore CS8618 -#pragma warning disable CS8618 - public string Units { get; set; } -#pragma warning restore CS8618 -#pragma warning disable CS8618 - public string AbnormalFlag { get; set; } -#pragma warning restore CS8618 -#pragma warning disable CS8618 - public string ResultStatus { get; set; } -#pragma warning restore CS8618 - - // Navigation Property -#pragma warning disable CS8618 - public Message Message { get; set; } -#pragma warning restore CS8618 + public int MessageId { get; set; } + public required string ObservationCode { get; set; } + public required string ObservationValue { get; set; } + public string? Units { get; set; } + public string? AbnormalFlag { get; set; } + public required string ResultStatus { get; set; } + public required Message Message { get; set; } } diff --git a/Models/Patient.cs b/Models/Patient.cs index 9fb9f25..57c3df7 100644 --- a/Models/Patient.cs +++ b/Models/Patient.cs @@ -3,21 +3,10 @@ namespace SimpleLIS.Models; public class Patient { public int PatientId { get; set; } -#pragma warning disable CS8618 - public string HL7PatientId { get; set; } -#pragma warning restore CS8618 -#pragma warning disable CS8618 - public string LastName { get; set; } -#pragma warning restore CS8618 -#pragma warning disable CS8618 - public string FirstName { get; set; } -#pragma warning restore CS8618 + public string? HL7PatientId { get; set; } + public string? LastName { get; set; } + public string? FirstName { get; set; } public DateTime DateOfBirth { get; set; } -#pragma warning disable CS8618 - public string Gender { get; set; } -#pragma warning restore CS8618 - -#pragma warning disable CS8618 - public ICollection Messages { get; set; } -#pragma warning restore CS8618 + public string? Gender { get; set; } + public required ICollection Messages { get; set; } } diff --git a/Services/MessageService.cs b/Services/MessageService.cs index c257801..3a2dc9a 100644 --- a/Services/MessageService.cs +++ b/Services/MessageService.cs @@ -19,11 +19,11 @@ public class MessageService return message; } - public async Task GetMessageByIdAsync(int id) + public async Task GetMessageByIdAsync(int id) { -#pragma warning disable CS8603 - return await _context.Messages.Include(m => m.Observations).FirstOrDefaultAsync(m => m.MessageId == id); -#pragma warning restore CS8603 + return await _context.Messages + .Include(m => m.Observations) + .FirstOrDefaultAsync(m => m.MessageId == id); } public async Task> ListMessagesAsync() diff --git a/Services/ObservationService.cs b/Services/ObservationService.cs index 8dbc7d9..1fd2678 100644 --- a/Services/ObservationService.cs +++ b/Services/ObservationService.cs @@ -19,16 +19,16 @@ public class ObservationService return observation; } - public async Task GetObservationByIdAsync(int id) + public async Task GetObservationByIdAsync(int id) { -#pragma warning disable CS8603 - return await _context.Observations.FirstOrDefaultAsync(o => o.ObservationId == id); -#pragma warning restore CS8603 + return await _context.Observations + .Include(o => o.Message) + .FirstOrDefaultAsync(o => o.ObservationId == id); } public async Task> ListObservationsAsync() { - return await _context.Observations.ToListAsync(); + return await _context.Observations.Include(o => o.Message).ToListAsync(); } public async Task UpdateObservationAsync(Observation observation) diff --git a/Services/PatientService.cs b/Services/PatientService.cs index 34e6ff1..3b0e23a 100644 --- a/Services/PatientService.cs +++ b/Services/PatientService.cs @@ -12,7 +12,6 @@ public class PatientService _context = context; } - public async Task CreatePatientAsync(Patient patient) { _context.Patients.Add(patient); @@ -20,11 +19,11 @@ public class PatientService return patient; } - public async Task GetPatientByIdAsync(int id) + public async Task GetPatientByIdAsync(int id) { -#pragma warning disable CS8603 - return await _context.Patients.FirstOrDefaultAsync(p => p.PatientId == id); -#pragma warning restore CS8603 + return await _context.Patients + .Include(p => p.Messages) + .FirstOrDefaultAsync(p => p.PatientId == id); } public async Task> ListPatientsAsync()