Reworked on relationships
This commit is contained in:
parent
fa45623f6e
commit
9f4197505e
@ -3,31 +3,14 @@ namespace SimpleLIS.DTO;
|
|||||||
public class MessageDTO
|
public class MessageDTO
|
||||||
{
|
{
|
||||||
public int MessageId { get; set; }
|
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 required string ControlId { get; set; }
|
||||||
public string ControlId { get; set; } // Unique identifier for the HL7 message
|
public required string MessageType { 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 string? SendingApp { 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? SendingFacility { get; set; }
|
||||||
public string MessageType { get; set; } // Type of HL7 message (e.g., ORU^R01)
|
public string? ReceivingApp { 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 string? ReceivingFacility { 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 DateTime Timestamp { get; set; }
|
||||||
public string SendingApp { get; set; } // Sending application
|
public string? Version { 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 int PatientId { 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 required List<ObservationDTO> Observations { get; set; }
|
||||||
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<ObservationDTO> 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.
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,20 +2,11 @@ namespace SimpleLIS.DTO;
|
|||||||
|
|
||||||
public class ObservationDTO
|
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 required string ObservationCode { get; set; }
|
||||||
public string ObservationCode { get; set; } // Code identifying the observation (e.g., WBC, HGB)
|
public required string ObservationValue { 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 string? Units { 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? AbnormalFlag { get; set; }
|
||||||
public string ObservationValue { get; set; } // The observed value
|
public string? ResultStatus { 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.
|
|
||||||
#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 int ObservationId { get; internal 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; }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,14 +1,8 @@
|
|||||||
public class PatientDTO
|
public class PatientDTO
|
||||||
{
|
{
|
||||||
public int PatientId { get; set; }
|
public int PatientId { get; set; }
|
||||||
#pragma warning disable CS8618
|
public string? LastName { get; set; }
|
||||||
public string LastName { get; set; }
|
public string? FirstName { get; set; }
|
||||||
#pragma warning restore CS8618
|
|
||||||
#pragma warning disable CS8618
|
|
||||||
public string FirstName { get; set; }
|
|
||||||
#pragma warning restore CS8618
|
|
||||||
public DateTime DateOfBirth { get; set; }
|
public DateTime DateOfBirth { get; set; }
|
||||||
#pragma warning disable CS8618
|
public string? Gender { get; set; }
|
||||||
public string Gender { get; set; }
|
|
||||||
#pragma warning restore CS8618
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,11 +8,15 @@ public class MappingProfile : Profile
|
|||||||
{
|
{
|
||||||
public MappingProfile()
|
public MappingProfile()
|
||||||
{
|
{
|
||||||
CreateMap<MessageDTO, Message>();
|
CreateMap<Message, MessageDTO>()
|
||||||
CreateMap<Message, MessageDTO>();
|
.ForMember(dest => dest.Observations, opt => opt.MapFrom(src => src.Observations));
|
||||||
CreateMap<ObservationDTO, Observation>();
|
CreateMap<MessageDTO, Message>()
|
||||||
|
.ForMember(dest => dest.Patient, opt => opt.Ignore());
|
||||||
CreateMap<Observation, ObservationDTO>();
|
CreateMap<Observation, ObservationDTO>();
|
||||||
CreateMap<PatientDTO, Patient>();
|
CreateMap<ObservationDTO, Observation>()
|
||||||
|
.ForMember(dest => dest.Message, opt => opt.Ignore());
|
||||||
CreateMap<Patient, PatientDTO>();
|
CreateMap<Patient, PatientDTO>();
|
||||||
|
CreateMap<PatientDTO, Patient>()
|
||||||
|
.ForMember(dest => dest.Messages, opt => opt.Ignore());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
149
Migrations/20241212113523_Initial migrations.Designer.cs
generated
149
Migrations/20241212113523_Initial migrations.Designer.cs
generated
@ -1,149 +0,0 @@
|
|||||||
// <auto-generated />
|
|
||||||
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
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
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<int>("MessageId")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<string>("ControlId")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("MessageType")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("ReceivingApp")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("ReceivingFacility")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("SendingApp")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("SendingFacility")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<DateTime>("Timestamp")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("Version")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.HasKey("MessageId");
|
|
||||||
|
|
||||||
b.ToTable("Messages");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("SimpleLIS.Models.Observation", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("ObservationId")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<string>("AbnormalFlag")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<int>("MessageId")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<string>("ObservationCode")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("ObservationValue")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("ResultStatus")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("Units")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.HasKey("ObservationId");
|
|
||||||
|
|
||||||
b.HasIndex("MessageId");
|
|
||||||
|
|
||||||
b.ToTable("Observations");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("SimpleLIS.Models.Patient", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("PatientId")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<DateTime>("DateOfBirth")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("FirstName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("Gender")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("HL7PatientId")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,50 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace SimpleLIS.Migrations
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public partial class Patientsgotmessages : Migration
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AddColumn<int>(
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -11,8 +11,8 @@ using SimpleLIS;
|
|||||||
namespace SimpleLIS.Migrations
|
namespace SimpleLIS.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(HL7DbContext))]
|
[DbContext(typeof(HL7DbContext))]
|
||||||
[Migration("20241213124817_Patients got messages")]
|
[Migration("20241214065908_Initial Migrations")]
|
||||||
partial class Patientsgotmessages
|
partial class InitialMigrations
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
@ -38,26 +38,21 @@ namespace SimpleLIS.Migrations
|
|||||||
.HasColumnType("INTEGER");
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
b.Property<string>("ReceivingApp")
|
b.Property<string>("ReceivingApp")
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<string>("ReceivingFacility")
|
b.Property<string>("ReceivingFacility")
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<string>("SendingApp")
|
b.Property<string>("SendingApp")
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<string>("SendingFacility")
|
b.Property<string>("SendingFacility")
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<DateTime>("Timestamp")
|
b.Property<DateTime>("Timestamp")
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<string>("Version")
|
b.Property<string>("Version")
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.HasKey("MessageId");
|
b.HasKey("MessageId");
|
||||||
@ -74,7 +69,6 @@ namespace SimpleLIS.Migrations
|
|||||||
.HasColumnType("INTEGER");
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
b.Property<string>("AbnormalFlag")
|
b.Property<string>("AbnormalFlag")
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<int>("MessageId")
|
b.Property<int>("MessageId")
|
||||||
@ -93,7 +87,6 @@ namespace SimpleLIS.Migrations
|
|||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<string>("Units")
|
b.Property<string>("Units")
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.HasKey("ObservationId");
|
b.HasKey("ObservationId");
|
||||||
@ -113,19 +106,15 @@ namespace SimpleLIS.Migrations
|
|||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<string>("FirstName")
|
b.Property<string>("FirstName")
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<string>("Gender")
|
b.Property<string>("Gender")
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<string>("HL7PatientId")
|
b.Property<string>("HL7PatientId")
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<string>("LastName")
|
b.Property<string>("LastName")
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.HasKey("PatientId");
|
b.HasKey("PatientId");
|
||||||
@ -6,11 +6,28 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
|||||||
namespace SimpleLIS.Migrations
|
namespace SimpleLIS.Migrations
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public partial class Initialmigrations : Migration
|
public partial class InitialMigrations : Migration
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Patients",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
PatientId = table.Column<int>(type: "INTEGER", nullable: false)
|
||||||
|
.Annotation("Sqlite:Autoincrement", true),
|
||||||
|
HL7PatientId = table.Column<string>(type: "TEXT", nullable: true),
|
||||||
|
LastName = table.Column<string>(type: "TEXT", nullable: true),
|
||||||
|
FirstName = table.Column<string>(type: "TEXT", nullable: true),
|
||||||
|
DateOfBirth = table.Column<DateTime>(type: "TEXT", nullable: false),
|
||||||
|
Gender = table.Column<string>(type: "TEXT", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Patients", x => x.PatientId);
|
||||||
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "Messages",
|
name: "Messages",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
@ -19,33 +36,23 @@ namespace SimpleLIS.Migrations
|
|||||||
.Annotation("Sqlite:Autoincrement", true),
|
.Annotation("Sqlite:Autoincrement", true),
|
||||||
ControlId = table.Column<string>(type: "TEXT", nullable: false),
|
ControlId = table.Column<string>(type: "TEXT", nullable: false),
|
||||||
MessageType = table.Column<string>(type: "TEXT", nullable: false),
|
MessageType = table.Column<string>(type: "TEXT", nullable: false),
|
||||||
SendingApp = table.Column<string>(type: "TEXT", nullable: false),
|
SendingApp = table.Column<string>(type: "TEXT", nullable: true),
|
||||||
SendingFacility = table.Column<string>(type: "TEXT", nullable: false),
|
SendingFacility = table.Column<string>(type: "TEXT", nullable: true),
|
||||||
ReceivingApp = table.Column<string>(type: "TEXT", nullable: false),
|
ReceivingApp = table.Column<string>(type: "TEXT", nullable: true),
|
||||||
ReceivingFacility = table.Column<string>(type: "TEXT", nullable: false),
|
ReceivingFacility = table.Column<string>(type: "TEXT", nullable: true),
|
||||||
Timestamp = table.Column<DateTime>(type: "TEXT", nullable: false),
|
Timestamp = table.Column<DateTime>(type: "TEXT", nullable: false),
|
||||||
Version = table.Column<string>(type: "TEXT", nullable: false)
|
Version = table.Column<string>(type: "TEXT", nullable: true),
|
||||||
|
PatientId = table.Column<int>(type: "INTEGER", nullable: false)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
table.PrimaryKey("PK_Messages", x => x.MessageId);
|
table.PrimaryKey("PK_Messages", x => x.MessageId);
|
||||||
});
|
table.ForeignKey(
|
||||||
|
name: "FK_Messages_Patients_PatientId",
|
||||||
migrationBuilder.CreateTable(
|
column: x => x.PatientId,
|
||||||
name: "Patients",
|
principalTable: "Patients",
|
||||||
columns: table => new
|
principalColumn: "PatientId",
|
||||||
{
|
onDelete: ReferentialAction.Cascade);
|
||||||
PatientId = table.Column<int>(type: "INTEGER", nullable: false)
|
|
||||||
.Annotation("Sqlite:Autoincrement", true),
|
|
||||||
HL7PatientId = table.Column<string>(type: "TEXT", nullable: false),
|
|
||||||
LastName = table.Column<string>(type: "TEXT", nullable: false),
|
|
||||||
FirstName = table.Column<string>(type: "TEXT", nullable: false),
|
|
||||||
DateOfBirth = table.Column<DateTime>(type: "TEXT", nullable: false),
|
|
||||||
Gender = table.Column<string>(type: "TEXT", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Patients", x => x.PatientId);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
@ -57,8 +64,8 @@ namespace SimpleLIS.Migrations
|
|||||||
MessageId = table.Column<int>(type: "INTEGER", nullable: false),
|
MessageId = table.Column<int>(type: "INTEGER", nullable: false),
|
||||||
ObservationCode = table.Column<string>(type: "TEXT", nullable: false),
|
ObservationCode = table.Column<string>(type: "TEXT", nullable: false),
|
||||||
ObservationValue = table.Column<string>(type: "TEXT", nullable: false),
|
ObservationValue = table.Column<string>(type: "TEXT", nullable: false),
|
||||||
Units = table.Column<string>(type: "TEXT", nullable: false),
|
Units = table.Column<string>(type: "TEXT", nullable: true),
|
||||||
AbnormalFlag = table.Column<string>(type: "TEXT", nullable: false),
|
AbnormalFlag = table.Column<string>(type: "TEXT", nullable: true),
|
||||||
ResultStatus = table.Column<string>(type: "TEXT", nullable: false)
|
ResultStatus = table.Column<string>(type: "TEXT", nullable: false)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
@ -72,6 +79,11 @@ namespace SimpleLIS.Migrations
|
|||||||
onDelete: ReferentialAction.Cascade);
|
onDelete: ReferentialAction.Cascade);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Messages_PatientId",
|
||||||
|
table: "Messages",
|
||||||
|
column: "PatientId");
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
name: "IX_Observations_MessageId",
|
name: "IX_Observations_MessageId",
|
||||||
table: "Observations",
|
table: "Observations",
|
||||||
@ -85,10 +97,10 @@ namespace SimpleLIS.Migrations
|
|||||||
name: "Observations");
|
name: "Observations");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "Patients");
|
name: "Messages");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "Messages");
|
name: "Patients");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -35,26 +35,21 @@ namespace SimpleLIS.Migrations
|
|||||||
.HasColumnType("INTEGER");
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
b.Property<string>("ReceivingApp")
|
b.Property<string>("ReceivingApp")
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<string>("ReceivingFacility")
|
b.Property<string>("ReceivingFacility")
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<string>("SendingApp")
|
b.Property<string>("SendingApp")
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<string>("SendingFacility")
|
b.Property<string>("SendingFacility")
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<DateTime>("Timestamp")
|
b.Property<DateTime>("Timestamp")
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<string>("Version")
|
b.Property<string>("Version")
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.HasKey("MessageId");
|
b.HasKey("MessageId");
|
||||||
@ -71,7 +66,6 @@ namespace SimpleLIS.Migrations
|
|||||||
.HasColumnType("INTEGER");
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
b.Property<string>("AbnormalFlag")
|
b.Property<string>("AbnormalFlag")
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<int>("MessageId")
|
b.Property<int>("MessageId")
|
||||||
@ -90,7 +84,6 @@ namespace SimpleLIS.Migrations
|
|||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<string>("Units")
|
b.Property<string>("Units")
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.HasKey("ObservationId");
|
b.HasKey("ObservationId");
|
||||||
@ -110,19 +103,15 @@ namespace SimpleLIS.Migrations
|
|||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<string>("FirstName")
|
b.Property<string>("FirstName")
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<string>("Gender")
|
b.Property<string>("Gender")
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<string>("HL7PatientId")
|
b.Property<string>("HL7PatientId")
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<string>("LastName")
|
b.Property<string>("LastName")
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.HasKey("PatientId");
|
b.HasKey("PatientId");
|
||||||
|
|||||||
@ -3,36 +3,15 @@ namespace SimpleLIS.Models;
|
|||||||
public class Message
|
public class Message
|
||||||
{
|
{
|
||||||
public int MessageId { get; set; }
|
public int MessageId { get; set; }
|
||||||
#pragma warning disable CS8618
|
public required string ControlId { get; set; }
|
||||||
public string ControlId { get; set; }
|
public required string MessageType { get; set; }
|
||||||
#pragma warning restore CS8618
|
public string? SendingApp { get; set; }
|
||||||
#pragma warning disable CS8618
|
public string? SendingFacility { get; set; }
|
||||||
public string MessageType { get; set; }
|
public string? ReceivingApp { get; set; }
|
||||||
#pragma warning restore CS8618
|
public string? ReceivingFacility { get; set; }
|
||||||
#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 DateTime Timestamp { get; set; }
|
public DateTime Timestamp { get; set; }
|
||||||
#pragma warning disable CS8618
|
public string? Version { get; set; }
|
||||||
public string Version { get; set; }
|
public required ICollection<Observation> Observations { get; set; }
|
||||||
#pragma warning restore CS8618
|
|
||||||
|
|
||||||
// Navigation Property for Observations
|
|
||||||
#pragma warning disable CS8618
|
|
||||||
public ICollection<Observation> Observations { get; set; }
|
|
||||||
#pragma warning restore CS8618
|
|
||||||
|
|
||||||
public int PatientId { get; set; }
|
public int PatientId { get; set; }
|
||||||
#pragma warning disable CS8618
|
public required Patient Patient { get; set; }
|
||||||
public Patient Patient { get; set; }
|
|
||||||
#pragma warning restore CS8618
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,25 +3,11 @@ namespace SimpleLIS.Models;
|
|||||||
public class Observation
|
public class Observation
|
||||||
{
|
{
|
||||||
public int ObservationId { get; set; }
|
public int ObservationId { get; set; }
|
||||||
public int MessageId { get; set; } // Foreign Key
|
public int MessageId { get; set; }
|
||||||
#pragma warning disable CS8618
|
public required string ObservationCode { get; set; }
|
||||||
public string ObservationCode { get; set; }
|
public required string ObservationValue { get; set; }
|
||||||
#pragma warning restore CS8618
|
public string? Units { get; set; }
|
||||||
#pragma warning disable CS8618
|
public string? AbnormalFlag { get; set; }
|
||||||
public string ObservationValue { get; set; }
|
public required string ResultStatus { get; set; }
|
||||||
#pragma warning restore CS8618
|
public required Message Message { get; set; }
|
||||||
#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
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,21 +3,10 @@ namespace SimpleLIS.Models;
|
|||||||
public class Patient
|
public class Patient
|
||||||
{
|
{
|
||||||
public int PatientId { get; set; }
|
public int PatientId { get; set; }
|
||||||
#pragma warning disable CS8618
|
public string? HL7PatientId { get; set; }
|
||||||
public string HL7PatientId { get; set; }
|
public string? LastName { get; set; }
|
||||||
#pragma warning restore CS8618
|
public string? FirstName { 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 DateTime DateOfBirth { get; set; }
|
public DateTime DateOfBirth { get; set; }
|
||||||
#pragma warning disable CS8618
|
public string? Gender { get; set; }
|
||||||
public string Gender { get; set; }
|
public required ICollection<Message> Messages { get; set; }
|
||||||
#pragma warning restore CS8618
|
|
||||||
|
|
||||||
#pragma warning disable CS8618
|
|
||||||
public ICollection<Message> Messages { get; set; }
|
|
||||||
#pragma warning restore CS8618
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,11 +19,11 @@ public class MessageService
|
|||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Message> GetMessageByIdAsync(int id)
|
public async Task<Message?> GetMessageByIdAsync(int id)
|
||||||
{
|
{
|
||||||
#pragma warning disable CS8603
|
return await _context.Messages
|
||||||
return await _context.Messages.Include(m => m.Observations).FirstOrDefaultAsync(m => m.MessageId == id);
|
.Include(m => m.Observations)
|
||||||
#pragma warning restore CS8603
|
.FirstOrDefaultAsync(m => m.MessageId == id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<Message>> ListMessagesAsync()
|
public async Task<IEnumerable<Message>> ListMessagesAsync()
|
||||||
|
|||||||
@ -19,16 +19,16 @@ public class ObservationService
|
|||||||
return observation;
|
return observation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Observation> GetObservationByIdAsync(int id)
|
public async Task<Observation?> GetObservationByIdAsync(int id)
|
||||||
{
|
{
|
||||||
#pragma warning disable CS8603
|
return await _context.Observations
|
||||||
return await _context.Observations.FirstOrDefaultAsync(o => o.ObservationId == id);
|
.Include(o => o.Message)
|
||||||
#pragma warning restore CS8603
|
.FirstOrDefaultAsync(o => o.ObservationId == id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<Observation>> ListObservationsAsync()
|
public async Task<IEnumerable<Observation>> ListObservationsAsync()
|
||||||
{
|
{
|
||||||
return await _context.Observations.ToListAsync();
|
return await _context.Observations.Include(o => o.Message).ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Observation> UpdateObservationAsync(Observation observation)
|
public async Task<Observation> UpdateObservationAsync(Observation observation)
|
||||||
|
|||||||
@ -12,7 +12,6 @@ public class PatientService
|
|||||||
_context = context;
|
_context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public async Task<Patient> CreatePatientAsync(Patient patient)
|
public async Task<Patient> CreatePatientAsync(Patient patient)
|
||||||
{
|
{
|
||||||
_context.Patients.Add(patient);
|
_context.Patients.Add(patient);
|
||||||
@ -20,11 +19,11 @@ public class PatientService
|
|||||||
return patient;
|
return patient;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Patient> GetPatientByIdAsync(int id)
|
public async Task<Patient?> GetPatientByIdAsync(int id)
|
||||||
{
|
{
|
||||||
#pragma warning disable CS8603
|
return await _context.Patients
|
||||||
return await _context.Patients.FirstOrDefaultAsync(p => p.PatientId == id);
|
.Include(p => p.Messages)
|
||||||
#pragma warning restore CS8603
|
.FirstOrDefaultAsync(p => p.PatientId == id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<Patient>> ListPatientsAsync()
|
public async Task<IEnumerable<Patient>> ListPatientsAsync()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user