simple-lis/Migrations/20241214065908_Initial Migrations.cs

107 lines
4.6 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace SimpleLIS.Migrations
{
/// <inheritdoc />
public partial class InitialMigrations : Migration
{
/// <inheritdoc />
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(
name: "Messages",
columns: table => new
{
MessageId = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
ControlId = table.Column<string>(type: "TEXT", nullable: false),
MessageType = table.Column<string>(type: "TEXT", nullable: false),
SendingApp = table.Column<string>(type: "TEXT", nullable: true),
SendingFacility = table.Column<string>(type: "TEXT", nullable: true),
ReceivingApp = table.Column<string>(type: "TEXT", nullable: true),
ReceivingFacility = table.Column<string>(type: "TEXT", nullable: true),
Timestamp = table.Column<DateTime>(type: "TEXT", nullable: false),
Version = table.Column<string>(type: "TEXT", nullable: true),
PatientId = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Messages", x => x.MessageId);
table.ForeignKey(
name: "FK_Messages_Patients_PatientId",
column: x => x.PatientId,
principalTable: "Patients",
principalColumn: "PatientId",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Observations",
columns: table => new
{
ObservationId = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
MessageId = table.Column<int>(type: "INTEGER", nullable: false),
ObservationCode = table.Column<string>(type: "TEXT", nullable: false),
ObservationValue = table.Column<string>(type: "TEXT", nullable: false),
Units = table.Column<string>(type: "TEXT", nullable: true),
AbnormalFlag = table.Column<string>(type: "TEXT", nullable: true),
ResultStatus = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Observations", x => x.ObservationId);
table.ForeignKey(
name: "FK_Observations_Messages_MessageId",
column: x => x.MessageId,
principalTable: "Messages",
principalColumn: "MessageId",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Messages_PatientId",
table: "Messages",
column: "PatientId");
migrationBuilder.CreateIndex(
name: "IX_Observations_MessageId",
table: "Observations",
column: "MessageId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Observations");
migrationBuilder.DropTable(
name: "Messages");
migrationBuilder.DropTable(
name: "Patients");
}
}
}