feature: Barcode/QR Cover Sheet System

This commit is contained in:
voltsrage
2026-06-27 21:50:32 +08:00
parent 5db60f46eb
commit 756cff332c
43 changed files with 8203 additions and 21 deletions
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,100 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace VigilCareRecordsAPI.Data.Migrations
{
/// <inheritdoc />
public partial class AddCoverSheets : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "cover_sheets",
columns: table => new
{
id = table.Column<Guid>(type: "uuid", nullable: false, defaultValueSql: "gen_random_uuid()"),
code = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
patient_id = table.Column<Guid>(type: "uuid", nullable: true),
batch_type = table.Column<string>(type: "character varying(30)", maxLength: 30, nullable: false),
track = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
assign_to_user_id = table.Column<Guid>(type: "uuid", nullable: true),
generated_by_user_id = table.Column<Guid>(type: "uuid", nullable: false),
is_used = table.Column<bool>(type: "boolean", nullable: false, defaultValue: false),
batch_id = table.Column<Guid>(type: "uuid", nullable: true),
created_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "NOW()"),
used_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_cover_sheets", x => x.id);
table.ForeignKey(
name: "FK_cover_sheets_digitization_batches_batch_id",
column: x => x.batch_id,
principalTable: "digitization_batches",
principalColumn: "id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "FK_cover_sheets_patients_patient_id",
column: x => x.patient_id,
principalSchema: "clinical",
principalTable: "patients",
principalColumn: "id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "FK_cover_sheets_users_assign_to_user_id",
column: x => x.assign_to_user_id,
principalTable: "users",
principalColumn: "id",
onDelete: ReferentialAction.SetNull);
table.ForeignKey(
name: "FK_cover_sheets_users_generated_by_user_id",
column: x => x.generated_by_user_id,
principalTable: "users",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex(
name: "IX_cover_sheets_assign_to_user_id",
table: "cover_sheets",
column: "assign_to_user_id");
migrationBuilder.CreateIndex(
name: "IX_cover_sheets_batch_id",
table: "cover_sheets",
column: "batch_id");
migrationBuilder.CreateIndex(
name: "ix_cover_sheets_code",
table: "cover_sheets",
column: "code",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_cover_sheets_generated_by_user_id",
table: "cover_sheets",
column: "generated_by_user_id");
migrationBuilder.CreateIndex(
name: "IX_cover_sheets_patient_id",
table: "cover_sheets",
column: "patient_id");
migrationBuilder.CreateIndex(
name: "ix_cover_sheets_unused",
table: "cover_sheets",
columns: new[] { "is_used", "created_at" },
filter: "is_used = false");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "cover_sheets");
}
}
}
@@ -230,6 +230,85 @@ namespace VigilCareRecordsAPI.Data.Migrations
});
});
modelBuilder.Entity("CoverSheet", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid")
.HasColumnName("id")
.HasDefaultValueSql("gen_random_uuid()");
b.Property<Guid?>("AssignToUserId")
.HasColumnType("uuid")
.HasColumnName("assign_to_user_id");
b.Property<Guid?>("BatchId")
.HasColumnType("uuid")
.HasColumnName("batch_id");
b.Property<string>("BatchType")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("character varying(30)")
.HasColumnName("batch_type");
b.Property<string>("Code")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)")
.HasColumnName("code");
b.Property<DateTimeOffset>("CreatedAt")
.ValueGeneratedOnAdd()
.HasColumnType("timestamp with time zone")
.HasColumnName("created_at")
.HasDefaultValueSql("NOW()");
b.Property<Guid>("GeneratedByUserId")
.HasColumnType("uuid")
.HasColumnName("generated_by_user_id");
b.Property<bool>("IsUsed")
.ValueGeneratedOnAdd()
.HasColumnType("boolean")
.HasDefaultValue(false)
.HasColumnName("is_used");
b.Property<Guid?>("PatientId")
.HasColumnType("uuid")
.HasColumnName("patient_id");
b.Property<string>("Track")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)")
.HasColumnName("track");
b.Property<DateTimeOffset?>("UsedAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("used_at");
b.HasKey("Id");
b.HasIndex("AssignToUserId");
b.HasIndex("BatchId");
b.HasIndex("Code")
.IsUnique()
.HasDatabaseName("ix_cover_sheets_code");
b.HasIndex("GeneratedByUserId");
b.HasIndex("PatientId");
b.HasIndex("IsUsed", "CreatedAt")
.HasDatabaseName("ix_cover_sheets_unused")
.HasFilter("is_used = false");
b.ToTable("cover_sheets", (string)null);
});
modelBuilder.Entity("DigitizationBatch", b =>
{
b.Property<Guid>("Id")
@@ -1269,6 +1348,38 @@ namespace VigilCareRecordsAPI.Data.Migrations
b.Navigation("User");
});
modelBuilder.Entity("CoverSheet", b =>
{
b.HasOne("User", "AssignToUser")
.WithMany()
.HasForeignKey("AssignToUserId")
.OnDelete(DeleteBehavior.SetNull);
b.HasOne("DigitizationBatch", "Batch")
.WithMany()
.HasForeignKey("BatchId")
.OnDelete(DeleteBehavior.SetNull);
b.HasOne("User", "GeneratedByUser")
.WithMany()
.HasForeignKey("GeneratedByUserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("Patient", "Patient")
.WithMany()
.HasForeignKey("PatientId")
.OnDelete(DeleteBehavior.SetNull);
b.Navigation("AssignToUser");
b.Navigation("Batch");
b.Navigation("GeneratedByUser");
b.Navigation("Patient");
});
modelBuilder.Entity("DigitizationBatch", b =>
{
b.HasOne("User", "ApprovedByUser")