// using System; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace VigilCareRecordsAPI.Data.Migrations { [DbContext(typeof(AppDbContext))] [Migration("20260626074837_AddLiveEncountersAndObservations")] partial class AddLiveEncountersAndObservations { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder .HasAnnotation("ProductVersion", "8.0.4") .HasAnnotation("Relational:MaxIdentifierLength", 63); NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); modelBuilder.Entity("AuthAuditEvent", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("uuid") .HasColumnName("id") .HasDefaultValueSql("gen_random_uuid()"); b.Property("EventType") .IsRequired() .HasMaxLength(30) .HasColumnType("character varying(30)") .HasColumnName("event_type"); b.Property("MetadataJson") .HasColumnType("jsonb") .HasColumnName("metadata_json"); b.Property("OccurredAt") .ValueGeneratedOnAdd() .HasColumnType("timestamp with time zone") .HasColumnName("occurred_at") .HasDefaultValueSql("NOW()"); b.Property("UserId") .HasColumnType("uuid") .HasColumnName("user_id"); b.HasKey("Id"); b.HasIndex("UserId", "OccurredAt"); b.ToTable("auth_audit_events", null, t => { t.HasCheckConstraint("chk_auth_audit_events_event_type", "event_type IN ('USER_LOGOUT', 'TOKEN_REFRESHED')"); }); }); modelBuilder.Entity("DigitizationBatch", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("uuid") .HasColumnName("id") .HasDefaultValueSql("gen_random_uuid()"); b.Property("ApprovedByUserId") .HasColumnType("uuid") .HasColumnName("approved_by_user_id"); b.Property("BatchType") .IsRequired() .HasMaxLength(30) .HasColumnType("character varying(30)") .HasColumnName("batch_type"); b.Property("ClinicianAttestation") .ValueGeneratedOnAdd() .HasColumnType("boolean") .HasDefaultValue(false) .HasColumnName("clinician_attestation"); b.Property("CreatedAt") .ValueGeneratedOnAdd() .HasColumnType("timestamp with time zone") .HasColumnName("created_at") .HasDefaultValueSql("NOW()"); b.Property("DocumentRef") .IsRequired() .HasMaxLength(500) .HasColumnType("character varying(500)") .HasColumnName("document_ref"); b.Property("DocumentSha256") .IsRequired() .HasMaxLength(64) .HasColumnType("character varying(64)") .HasColumnName("document_sha256"); b.Property("EnableRetroactiveAlerts") .ValueGeneratedOnAdd() .HasColumnType("boolean") .HasDefaultValue(false) .HasColumnName("enable_retroactive_alerts"); b.Property("EncounterDraftId") .HasColumnType("uuid") .HasColumnName("encounter_draft_id"); b.Property("EnteredByUserId") .HasColumnType("uuid") .HasColumnName("entered_by_user_id"); b.Property("PatientId") .HasColumnType("uuid") .HasColumnName("patient_id"); b.Property("PromotedAt") .HasColumnType("timestamp with time zone") .HasColumnName("promoted_at"); b.Property("PromotionEncounterId") .HasColumnType("uuid") .HasColumnName("promotion_encounter_id"); b.Property("RejectionReason") .HasColumnType("text") .HasColumnName("rejection_reason"); b.Property("Status") .IsRequired() .ValueGeneratedOnAdd() .HasMaxLength(30) .HasColumnType("character varying(30)") .HasColumnName("status") .HasDefaultValueSql("'UPLOADED'"); b.Property("SupersedesBatchId") .HasColumnType("uuid") .HasColumnName("supersedes_batch_id"); b.Property("Track") .IsRequired() .ValueGeneratedOnAdd() .HasMaxLength(20) .HasColumnType("character varying(20)") .HasColumnName("track") .HasDefaultValueSql("'BACKFILL'"); b.Property("UpdatedAt") .ValueGeneratedOnAdd() .HasColumnType("timestamp with time zone") .HasColumnName("updated_at") .HasDefaultValueSql("NOW()"); b.Property("VerifiedByUserId") .HasColumnType("uuid") .HasColumnName("verified_by_user_id"); b.HasKey("Id"); b.HasIndex("ApprovedByUserId"); b.HasIndex("EnteredByUserId"); b.HasIndex("Status"); b.HasIndex("SupersedesBatchId") .HasFilter("supersedes_batch_id IS NOT NULL"); b.HasIndex("VerifiedByUserId"); b.HasIndex("DocumentSha256", "PatientId", "CreatedAt"); b.ToTable("digitization_batches", null, t => { t.HasCheckConstraint("chk_batches_batch_type", "batch_type IN ('PATIENT_REGISTRATION', 'ENCOUNTER_SUMMARY', 'VITALS_SHEET', 'LAB_RESULTS', 'MEDICATION_LIST', 'ALLERGY_UPDATE', 'MIXED')"); t.HasCheckConstraint("chk_batches_status", "status IN ('UPLOADED', 'IN_ENTRY', 'PENDING_VERIFICATION', 'REJECTED', 'VERIFIED', 'AWAITING_CLINICAL_APPROVAL', 'APPROVED', 'PROMOTED')"); t.HasCheckConstraint("chk_batches_track", "track IN ('BACKFILL', 'LIVE_CAPTURE')"); }); }); modelBuilder.Entity("DigitizationEvent", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("uuid") .HasColumnName("id") .HasDefaultValueSql("gen_random_uuid()"); b.Property("ActorUserId") .HasColumnType("uuid") .HasColumnName("actor_user_id"); b.Property("BatchId") .HasColumnType("uuid") .HasColumnName("batch_id"); b.Property("EventType") .IsRequired() .HasMaxLength(50) .HasColumnType("character varying(50)") .HasColumnName("event_type"); b.Property("MetadataJson") .HasColumnType("jsonb") .HasColumnName("metadata_json"); b.Property("OccurredAt") .ValueGeneratedOnAdd() .HasColumnType("timestamp with time zone") .HasColumnName("occurred_at") .HasDefaultValueSql("NOW()"); b.HasKey("Id"); b.HasIndex("ActorUserId"); b.HasIndex("BatchId", "OccurredAt"); b.ToTable("digitization_events", null, t => { t.HasCheckConstraint("chk_digitization_events_event_type", "event_type IN ('uploaded', 'entry_started', 'submitted_for_verification', 'rejected', 'verified', 'verified_pending_clinical', 'awaiting_clinical_approval', 'approved', 'promoted', 'live_capture_attested', 'correction_requested', 'verification_failed', 'superseded', 'correction_promoted', 'correction_uploaded', 'promotion_retry_succeeded', 'promotion_retry_failed', 'promotion_retry_exhausted', 'promotion_failed')"); }); }); modelBuilder.Entity("DraftEncounter", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("uuid") .HasColumnName("id") .HasDefaultValueSql("gen_random_uuid()"); b.Property("AdmissionDate") .HasColumnType("timestamp with time zone") .HasColumnName("admission_date"); b.Property("AdmissionReason") .HasMaxLength(500) .HasColumnType("character varying(500)") .HasColumnName("admission_reason"); b.Property("BatchId") .HasColumnType("uuid") .HasColumnName("batch_id"); b.Property("CreatedAt") .ValueGeneratedOnAdd() .HasColumnType("timestamp with time zone") .HasColumnName("created_at") .HasDefaultValueSql("NOW()"); b.Property("Department") .HasMaxLength(100) .HasColumnType("character varying(100)") .HasColumnName("department"); b.Property("DischargeDiagnosis") .HasMaxLength(500) .HasColumnType("character varying(500)") .HasColumnName("discharge_diagnosis"); b.Property("RoomBed") .HasMaxLength(50) .HasColumnType("character varying(50)") .HasColumnName("room_bed"); b.Property("Status") .HasMaxLength(20) .HasColumnType("character varying(20)") .HasColumnName("status"); b.Property("UpdatedAt") .ValueGeneratedOnAdd() .HasColumnType("timestamp with time zone") .HasColumnName("updated_at") .HasDefaultValueSql("NOW()"); b.HasKey("Id"); b.HasIndex("BatchId") .IsUnique(); b.ToTable("draft_encounters", null, t => { t.HasCheckConstraint("chk_draft_encounters_department", "department IS NULL OR department IN ('Emergency Department', 'Internal Medicine', 'General Medicine', 'Surgery', 'ICU', 'NICU', 'Medical-Surgical', 'Outpatient Clinic', 'Pediatrics', 'Obstetrics & Gynecology', 'Labor & Delivery', 'Cardiology', 'Orthopedics', 'Neurology', 'Oncology', 'Radiology', 'Laboratory', 'Psychiatry', 'Physical Therapy', 'Anesthesiology')"); }); }); modelBuilder.Entity("DraftObservation", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("uuid") .HasColumnName("id") .HasDefaultValueSql("gen_random_uuid()"); b.Property("BatchId") .HasColumnType("uuid") .HasColumnName("batch_id"); b.Property("CreatedAt") .ValueGeneratedOnAdd() .HasColumnType("timestamp with time zone") .HasColumnName("created_at") .HasDefaultValueSql("NOW()"); b.Property("Note") .HasMaxLength(500) .HasColumnType("character varying(500)") .HasColumnName("note"); b.Property("ObservationCode") .IsRequired() .HasMaxLength(50) .HasColumnType("character varying(50)") .HasColumnName("observation_code"); b.Property("RecordedAt") .HasColumnType("timestamp with time zone") .HasColumnName("recorded_at"); b.Property("Unit") .IsRequired() .HasMaxLength(20) .HasColumnType("character varying(20)") .HasColumnName("unit"); b.Property("Value") .HasColumnType("decimal(10,3)") .HasColumnName("value"); b.HasKey("Id"); b.HasIndex("BatchId", "ObservationCode"); b.ToTable("draft_observations", (string)null); }); modelBuilder.Entity("DraftPatient", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("uuid") .HasColumnName("id") .HasDefaultValueSql("gen_random_uuid()"); b.Property("AllergiesJson") .HasColumnType("jsonb") .HasColumnName("allergies_json"); b.Property("BatchId") .HasColumnType("uuid") .HasColumnName("batch_id"); b.Property("BloodType") .HasMaxLength(10) .HasColumnType("character varying(10)") .HasColumnName("blood_type"); b.Property("CreatedAt") .ValueGeneratedOnAdd() .HasColumnType("timestamp with time zone") .HasColumnName("created_at") .HasDefaultValueSql("NOW()"); b.Property("DateOfBirth") .HasColumnType("date") .HasColumnName("date_of_birth"); b.Property("EmergencyContact") .HasMaxLength(500) .HasColumnType("character varying(500)") .HasColumnName("emergency_contact"); b.Property("FullName") .HasMaxLength(200) .HasColumnType("character varying(200)") .HasColumnName("full_name"); b.Property("MedicationsJson") .HasColumnType("jsonb") .HasColumnName("medications_json"); b.Property("NoActiveMedications") .ValueGeneratedOnAdd() .HasColumnType("boolean") .HasDefaultValue(false) .HasColumnName("no_active_medications"); b.Property("NoKnownAllergies") .ValueGeneratedOnAdd() .HasColumnType("boolean") .HasDefaultValue(false) .HasColumnName("no_known_allergies"); b.Property("Sex") .HasMaxLength(10) .HasColumnType("character varying(10)") .HasColumnName("sex"); b.Property("UpdatedAt") .ValueGeneratedOnAdd() .HasColumnType("timestamp with time zone") .HasColumnName("updated_at") .HasDefaultValueSql("NOW()"); b.HasKey("Id"); b.HasIndex("BatchId") .IsUnique(); b.ToTable("draft_patients", null, t => { t.HasCheckConstraint("chk_draft_patients_blood_type", "blood_type IS NULL OR blood_type IN ('A+', 'A-', 'B+', 'B-', 'AB+', 'AB-', 'O+', 'O-')"); }); }); modelBuilder.Entity("Encounter", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("uuid") .HasColumnName("id") .HasDefaultValueSql("gen_random_uuid()"); b.Property("AdmissionDate") .HasColumnType("timestamp with time zone") .HasColumnName("admission_date"); b.Property("AdmissionReason") .HasMaxLength(500) .HasColumnType("character varying(500)") .HasColumnName("admission_reason"); b.Property("CreatedAt") .ValueGeneratedOnAdd() .HasColumnType("timestamp with time zone") .HasColumnName("created_at") .HasDefaultValueSql("NOW()"); b.Property("Department") .HasMaxLength(100) .HasColumnType("character varying(100)") .HasColumnName("department"); b.Property("DischargeDiagnosis") .HasMaxLength(500) .HasColumnType("character varying(500)") .HasColumnName("discharge_diagnosis"); b.Property("PatientId") .HasColumnType("uuid") .HasColumnName("patient_id"); b.Property("RoomBed") .HasMaxLength(50) .HasColumnType("character varying(50)") .HasColumnName("room_bed"); b.Property("SourceBatchId") .HasColumnType("uuid") .HasColumnName("source_batch_id"); b.Property("Status") .IsRequired() .HasMaxLength(20) .HasColumnType("character varying(20)") .HasColumnName("status"); b.Property("UpdatedAt") .ValueGeneratedOnAdd() .HasColumnType("timestamp with time zone") .HasColumnName("updated_at") .HasDefaultValueSql("NOW()"); b.HasKey("Id"); b.HasIndex("PatientId", "Status") .HasDatabaseName("ix_encounters_patient_status"); b.ToTable("encounters", "clinical", t => { t.HasCheckConstraint("chk_encounters_department", "department IS NULL OR department IN ('Emergency Department', 'Internal Medicine', 'General Medicine', 'Surgery', 'ICU', 'NICU', 'Medical-Surgical', 'Outpatient Clinic', 'Pediatrics', 'Obstetrics & Gynecology', 'Labor & Delivery', 'Cardiology', 'Orthopedics', 'Neurology', 'Oncology', 'Radiology', 'Laboratory', 'Psychiatry', 'Physical Therapy', 'Anesthesiology')"); }); }); modelBuilder.Entity("IdempotencyRecord", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("uuid") .HasColumnName("id") .HasDefaultValueSql("gen_random_uuid()"); b.Property("CreatedAt") .ValueGeneratedOnAdd() .HasColumnType("timestamp with time zone") .HasColumnName("created_at") .HasDefaultValueSql("NOW()"); b.Property("ExpiresAt") .HasColumnType("timestamp with time zone") .HasColumnName("expires_at"); b.Property("HttpStatusCode") .HasColumnType("integer") .HasColumnName("http_status_code"); b.Property("IdempotencyKey") .IsRequired() .HasMaxLength(100) .HasColumnType("character varying(100)") .HasColumnName("idempotency_key"); b.Property("OperationName") .IsRequired() .HasMaxLength(100) .HasColumnType("character varying(100)") .HasColumnName("operation_name"); b.Property("ResourceId") .HasColumnType("uuid") .HasColumnName("resource_id"); b.Property("ResponseBodyJson") .IsRequired() .HasColumnType("jsonb") .HasColumnName("response_body_json"); b.HasKey("Id"); b.HasIndex("ExpiresAt") .HasDatabaseName("ix_idempotency_records_expires_at"); b.HasIndex("IdempotencyKey", "OperationName") .IsUnique() .HasDatabaseName("ix_idempotency_records_key_operation"); b.ToTable("idempotency_records", (string)null); }); modelBuilder.Entity("LiveEncounter", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("uuid") .HasColumnName("id") .HasDefaultValueSql("gen_random_uuid()"); b.Property("AdmissionDate") .HasColumnType("timestamp with time zone") .HasColumnName("admission_date"); b.Property("AdmissionReason") .HasMaxLength(500) .HasColumnType("character varying(500)") .HasColumnName("admission_reason"); b.Property("CreatedAt") .ValueGeneratedOnAdd() .HasColumnType("timestamp with time zone") .HasColumnName("created_at") .HasDefaultValueSql("NOW()"); b.Property("Department") .HasMaxLength(100) .HasColumnType("character varying(100)") .HasColumnName("department"); b.Property("DischargeDiagnosis") .HasMaxLength(500) .HasColumnType("character varying(500)") .HasColumnName("discharge_diagnosis"); b.Property("PatientId") .HasColumnType("uuid") .HasColumnName("patient_id"); b.Property("RoomBed") .HasMaxLength(50) .HasColumnType("character varying(50)") .HasColumnName("room_bed"); b.Property("Status") .IsRequired() .HasMaxLength(20) .HasColumnType("character varying(20)") .HasColumnName("status"); b.HasKey("Id"); b.HasIndex("PatientId", "Status"); b.ToTable("live_encounters", null, t => { t.HasCheckConstraint("chk_live_encounters_department", "department IS NULL OR department IN ('Emergency Department', 'Internal Medicine', 'General Medicine', 'Surgery', 'ICU', 'NICU', 'Medical-Surgical', 'Outpatient Clinic', 'Pediatrics', 'Obstetrics & Gynecology', 'Labor & Delivery', 'Cardiology', 'Orthopedics', 'Neurology', 'Oncology', 'Radiology', 'Laboratory', 'Psychiatry', 'Physical Therapy', 'Anesthesiology')"); }); }); modelBuilder.Entity("LiveObservation", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("uuid") .HasColumnName("id") .HasDefaultValueSql("gen_random_uuid()"); b.Property("CreatedAt") .ValueGeneratedOnAdd() .HasColumnType("timestamp with time zone") .HasColumnName("created_at") .HasDefaultValueSql("NOW()"); b.Property("EncounterId") .HasColumnType("uuid") .HasColumnName("encounter_id"); b.Property("IsSuperseded") .ValueGeneratedOnAdd() .HasColumnType("boolean") .HasDefaultValue(false) .HasColumnName("is_superseded"); b.Property("Note") .HasMaxLength(500) .HasColumnType("character varying(500)") .HasColumnName("note"); b.Property("ObservationCode") .IsRequired() .HasMaxLength(50) .HasColumnType("character varying(50)") .HasColumnName("observation_code"); b.Property("PatientId") .HasColumnType("uuid") .HasColumnName("patient_id"); b.Property("RecordedAt") .HasColumnType("timestamp with time zone") .HasColumnName("recorded_at"); b.Property("SourceBatchId") .HasColumnType("uuid") .HasColumnName("source_batch_id"); b.Property("SupersededAt") .HasColumnType("timestamp with time zone") .HasColumnName("superseded_at"); b.Property("SupersededByBatchId") .HasColumnType("uuid") .HasColumnName("superseded_by_batch_id"); b.Property("Unit") .IsRequired() .HasMaxLength(20) .HasColumnType("character varying(20)") .HasColumnName("unit"); b.Property("Value") .HasColumnType("decimal(10,3)") .HasColumnName("value"); b.HasKey("Id"); b.HasIndex("IsSuperseded") .HasFilter("is_superseded = true"); b.HasIndex("SourceBatchId"); b.HasIndex("EncounterId", "ObservationCode"); b.ToTable("live_observations", (string)null); }); modelBuilder.Entity("Observation", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("uuid") .HasColumnName("id") .HasDefaultValueSql("gen_random_uuid()"); b.Property("CreatedAt") .ValueGeneratedOnAdd() .HasColumnType("timestamp with time zone") .HasColumnName("created_at") .HasDefaultValueSql("NOW()"); b.Property("EncounterId") .HasColumnType("uuid") .HasColumnName("encounter_id"); b.Property("Note") .HasMaxLength(500) .HasColumnType("character varying(500)") .HasColumnName("note"); b.Property("ObservationCode") .IsRequired() .HasMaxLength(50) .HasColumnType("character varying(50)") .HasColumnName("observation_code"); b.Property("PatientId") .HasColumnType("uuid") .HasColumnName("patient_id"); b.Property("RecordedAt") .HasColumnType("timestamp with time zone") .HasColumnName("recorded_at"); b.Property("Source") .IsRequired() .HasMaxLength(30) .HasColumnType("character varying(30)") .HasColumnName("source"); b.Property("SourceBatchId") .HasColumnType("uuid") .HasColumnName("source_batch_id"); b.Property("SourceDraftObservationId") .HasColumnType("uuid") .HasColumnName("source_draft_observation_id"); b.Property("Unit") .IsRequired() .HasMaxLength(20) .HasColumnType("character varying(20)") .HasColumnName("unit"); b.Property("Value") .HasColumnType("decimal(10,3)") .HasColumnName("value"); b.HasKey("Id"); b.HasIndex("PatientId"); b.HasIndex("SourceBatchId") .HasDatabaseName("ix_observations_source_batch") .HasFilter("source_batch_id IS NOT NULL"); b.HasIndex("EncounterId", "ObservationCode") .HasDatabaseName("ix_observations_encounter_code"); b.ToTable("observations", "clinical"); }); modelBuilder.Entity("OutboxEvent", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("uuid") .HasColumnName("id") .HasDefaultValueSql("gen_random_uuid()"); b.Property("AggregateId") .HasColumnType("uuid") .HasColumnName("aggregate_id"); b.Property("AggregateType") .IsRequired() .HasMaxLength(50) .HasColumnType("character varying(50)") .HasColumnName("aggregate_type"); b.Property("CreatedAt") .ValueGeneratedOnAdd() .HasColumnType("timestamp with time zone") .HasColumnName("created_at") .HasDefaultValueSql("NOW()"); b.Property("EventType") .IsRequired() .HasMaxLength(100) .HasColumnType("character varying(100)") .HasColumnName("event_type"); b.Property("PayloadJson") .IsRequired() .HasColumnType("jsonb") .HasColumnName("payload_json"); b.Property("ProcessedAt") .HasColumnType("timestamp with time zone") .HasColumnName("processed_at"); b.Property("RetryCount") .ValueGeneratedOnAdd() .HasColumnType("integer") .HasDefaultValue(0) .HasColumnName("retry_count"); b.HasKey("Id"); b.HasIndex("ProcessedAt") .HasDatabaseName("ix_outbox_events_unprocessed") .HasFilter("processed_at IS NULL"); b.ToTable("outbox_events", "clinical"); }); modelBuilder.Entity("Patient", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("uuid") .HasColumnName("id") .HasDefaultValueSql("gen_random_uuid()"); b.Property("AllergiesJson") .HasColumnType("jsonb") .HasColumnName("allergies_json"); b.Property("BloodType") .HasMaxLength(10) .HasColumnType("character varying(10)") .HasColumnName("blood_type"); b.Property("CreatedAt") .ValueGeneratedOnAdd() .HasColumnType("timestamp with time zone") .HasColumnName("created_at") .HasDefaultValueSql("NOW()"); b.Property("DateOfBirth") .HasColumnType("date") .HasColumnName("date_of_birth"); b.Property("EmergencyContact") .HasMaxLength(500) .HasColumnType("character varying(500)") .HasColumnName("emergency_contact"); b.Property("FullName") .IsRequired() .HasMaxLength(200) .HasColumnType("character varying(200)") .HasColumnName("full_name"); b.Property("Mrn") .IsRequired() .HasMaxLength(20) .HasColumnType("character varying(20)") .HasColumnName("mrn"); b.Property("NoKnownAllergies") .ValueGeneratedOnAdd() .HasColumnType("boolean") .HasDefaultValue(false) .HasColumnName("no_known_allergies"); b.Property("Sex") .HasMaxLength(10) .HasColumnType("character varying(10)") .HasColumnName("sex"); b.Property("UpdatedAt") .ValueGeneratedOnAdd() .HasColumnType("timestamp with time zone") .HasColumnName("updated_at") .HasDefaultValueSql("NOW()"); b.HasKey("Id"); b.HasIndex("Mrn") .IsUnique() .HasDatabaseName("ix_patients_mrn"); b.ToTable("patients", "clinical", t => { t.HasCheckConstraint("chk_patients_blood_type", "blood_type IS NULL OR blood_type IN ('A+', 'A-', 'B+', 'B-', 'AB+', 'AB-', 'O+', 'O-')"); }); }); modelBuilder.Entity("RefreshToken", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("uuid") .HasColumnName("id") .HasDefaultValueSql("gen_random_uuid()"); b.Property("CreatedAt") .ValueGeneratedOnAdd() .HasColumnType("timestamp with time zone") .HasColumnName("created_at") .HasDefaultValueSql("NOW()"); b.Property("ExpiresAt") .HasColumnType("timestamp with time zone") .HasColumnName("expires_at"); b.Property("ReplacedByTokenId") .HasColumnType("uuid") .HasColumnName("replaced_by_token_id"); b.Property("RevokedAt") .HasColumnType("timestamp with time zone") .HasColumnName("revoked_at"); b.Property("TokenHash") .IsRequired() .HasMaxLength(64) .HasColumnType("character varying(64)") .HasColumnName("token_hash"); b.Property("UserId") .HasColumnType("uuid") .HasColumnName("user_id"); b.HasKey("Id"); b.HasIndex("ReplacedByTokenId"); b.HasIndex("TokenHash") .IsUnique(); b.HasIndex("UserId", "RevokedAt"); b.ToTable("refresh_tokens", (string)null); }); modelBuilder.Entity("ScannedDocument", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("uuid") .HasColumnName("id") .HasDefaultValueSql("gen_random_uuid()"); b.Property("BatchId") .HasColumnType("uuid") .HasColumnName("batch_id"); b.Property("ContentType") .IsRequired() .HasMaxLength(100) .HasColumnType("character varying(100)") .HasColumnName("content_type"); b.Property("FileSizeBytes") .HasColumnType("bigint") .HasColumnName("file_size_bytes"); b.Property("ObjectKey") .IsRequired() .HasMaxLength(500) .HasColumnType("character varying(500)") .HasColumnName("object_key"); b.Property("Sha256") .IsRequired() .HasMaxLength(64) .HasColumnType("character varying(64)") .HasColumnName("sha256"); b.Property("UploadedAt") .ValueGeneratedOnAdd() .HasColumnType("timestamp with time zone") .HasColumnName("uploaded_at") .HasDefaultValueSql("NOW()"); b.HasKey("Id"); b.HasIndex("BatchId") .IsUnique(); b.HasIndex("Sha256"); b.ToTable("scanned_documents", (string)null); }); modelBuilder.Entity("User", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("uuid") .HasColumnName("id") .HasDefaultValueSql("gen_random_uuid()"); b.Property("CreatedAt") .ValueGeneratedOnAdd() .HasColumnType("timestamp with time zone") .HasColumnName("created_at") .HasDefaultValueSql("NOW()"); b.Property("FullName") .IsRequired() .HasMaxLength(200) .HasColumnType("character varying(200)") .HasColumnName("full_name"); b.Property("IsActive") .ValueGeneratedOnAdd() .HasColumnType("boolean") .HasDefaultValue(true) .HasColumnName("is_active"); b.Property("PasswordHash") .IsRequired() .HasMaxLength(200) .HasColumnType("character varying(200)") .HasColumnName("password_hash"); b.Property("Role") .IsRequired() .HasMaxLength(30) .HasColumnType("character varying(30)") .HasColumnName("role"); b.Property("Username") .IsRequired() .HasMaxLength(100) .HasColumnType("character varying(100)") .HasColumnName("username"); b.HasKey("Id"); b.HasIndex("Username") .IsUnique(); b.ToTable("users", null, t => { t.HasCheckConstraint("chk_users_role", "role IN ('INTAKE_CLERK', 'DATA_ENTRY_CLERK', 'VERIFIER', 'CLINICAL_APPROVER', 'CLINICIAN', 'ADMINISTRATOR')"); }); }); modelBuilder.Entity("AuthAuditEvent", b => { b.HasOne("User", "User") .WithMany() .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Restrict) .IsRequired(); b.Navigation("User"); }); modelBuilder.Entity("DigitizationBatch", b => { b.HasOne("User", "ApprovedByUser") .WithMany() .HasForeignKey("ApprovedByUserId") .OnDelete(DeleteBehavior.Restrict); b.HasOne("User", "EnteredByUser") .WithMany() .HasForeignKey("EnteredByUserId") .OnDelete(DeleteBehavior.Restrict); b.HasOne("User", "VerifiedByUser") .WithMany() .HasForeignKey("VerifiedByUserId") .OnDelete(DeleteBehavior.Restrict); b.Navigation("ApprovedByUser"); b.Navigation("EnteredByUser"); b.Navigation("VerifiedByUser"); }); modelBuilder.Entity("DigitizationEvent", b => { b.HasOne("User", "Actor") .WithMany() .HasForeignKey("ActorUserId") .OnDelete(DeleteBehavior.Restrict) .IsRequired(); b.HasOne("DigitizationBatch", "Batch") .WithMany("Events") .HasForeignKey("BatchId") .OnDelete(DeleteBehavior.Restrict) .IsRequired(); b.Navigation("Actor"); b.Navigation("Batch"); }); modelBuilder.Entity("DraftEncounter", b => { b.HasOne("DigitizationBatch", "Batch") .WithOne("DraftEncounter") .HasForeignKey("DraftEncounter", "BatchId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.Navigation("Batch"); }); modelBuilder.Entity("DraftObservation", b => { b.HasOne("DigitizationBatch", "Batch") .WithMany("DraftObservations") .HasForeignKey("BatchId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.Navigation("Batch"); }); modelBuilder.Entity("DraftPatient", b => { b.HasOne("DigitizationBatch", "Batch") .WithOne("DraftPatient") .HasForeignKey("DraftPatient", "BatchId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.Navigation("Batch"); }); modelBuilder.Entity("Encounter", b => { b.HasOne("Patient", "Patient") .WithMany() .HasForeignKey("PatientId") .OnDelete(DeleteBehavior.Restrict) .IsRequired(); b.Navigation("Patient"); }); modelBuilder.Entity("LiveEncounter", b => { b.HasOne("Patient", null) .WithMany() .HasForeignKey("PatientId") .OnDelete(DeleteBehavior.Restrict) .IsRequired(); }); modelBuilder.Entity("LiveObservation", b => { b.HasOne("LiveEncounter", "Encounter") .WithMany("Observations") .HasForeignKey("EncounterId") .OnDelete(DeleteBehavior.Restrict) .IsRequired(); b.Navigation("Encounter"); }); modelBuilder.Entity("Observation", b => { b.HasOne("Encounter", "Encounter") .WithMany() .HasForeignKey("EncounterId") .OnDelete(DeleteBehavior.Restrict) .IsRequired(); b.HasOne("Patient", "Patient") .WithMany() .HasForeignKey("PatientId") .OnDelete(DeleteBehavior.Restrict) .IsRequired(); b.Navigation("Encounter"); b.Navigation("Patient"); }); modelBuilder.Entity("RefreshToken", b => { b.HasOne("RefreshToken", "ReplacedByToken") .WithMany() .HasForeignKey("ReplacedByTokenId") .OnDelete(DeleteBehavior.SetNull); b.HasOne("User", "User") .WithMany() .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.Navigation("ReplacedByToken"); b.Navigation("User"); }); modelBuilder.Entity("ScannedDocument", b => { b.HasOne("DigitizationBatch", "Batch") .WithOne("Document") .HasForeignKey("ScannedDocument", "BatchId") .OnDelete(DeleteBehavior.Restrict) .IsRequired(); b.Navigation("Batch"); }); modelBuilder.Entity("DigitizationBatch", b => { b.Navigation("Document"); b.Navigation("DraftEncounter"); b.Navigation("DraftObservations"); b.Navigation("DraftPatient"); b.Navigation("Events"); }); modelBuilder.Entity("LiveEncounter", b => { b.Navigation("Observations"); }); #pragma warning restore 612, 618 } } }