πŸ“„ IPMMigration Class Documentation

File: IrbyImaging.DomainClasses/IPMMigration.cs
Assembly: IrbyImaging.DomainClasses
Author: kvamshi
Created / Last Modified: 01‑12‑2022


πŸ“š Table of Contents

  1. Overview & Purpose
  2. Dependencies & Technologies
  3. Data Model & EF Core Mapping
  4. Property Reference
  5. Use Cases & Scenarios
  6. Sample Code & Usage Examples
  7. UML Class Diagram
  8. Conclusion

1. Overview & Purpose

The IPMMigration class is a Domain Model representing one page of an β€œIPM” document during bulk migration or ingestion into the Irby Imaging system. It captures:

  • Raw image bytes
  • Embedded OCR data (both binary and text)
  • Metadata such as filename, page number, content type, batch/reference IDs, indexing status, and upload audit fields

This entity is meant to be stored in a relational database (SQL Server, PostgreSQL, etc.) via Entity Framework Core.


2. Dependencies & Technologies

  • .NET (β‰₯5.0) / .NET Core
  • Entity Framework Core (Code-First)
  • System.ComponentModel.DataAnnotations
  • System.ComponentModel.DataAnnotations.Schema

No third‑party libraries beyond EF Core are directly referenced.


3. Data Model & EF Core Mapping

using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace IrbyImaging.DomainClasses
{
    [Table("IPMMigration", Schema = "irby")]
    public class IPMMigration
    {
        [Key]
        public Guid IPMMigrationId { get; set; }
        // ... other properties ...
    }
}
  • [Table] attribute
    • Maps this class to the irby.IPMMigration table.
  • [Key] attribute
    • Declares IPMMigrationId as the Primary Key (GUID).

4. Property Reference

Property Name Type Attributes Description
IPMMigrationId Guid [Key] Unique identifier for this page record.
FileName string β€” Original filename of the document.
ContentType string β€” MIME type (e.g., image/tiff, application/pdf).
TotalPages int β€” Total number of pages in this document.
Page int β€” Current page number (1‑based).
ImageContents byte[] β€” Raw image bytes for this page.
ImageOCRContents byte[] β€” Raw OCR engine output (if binary) for this page.
ImageOCRText string β€” Extracted text from OCR for quick searching/indexing.
ReferenceId Guid β€” External reference (e.g., Patient or Case ID).
BatchId Guid β€” Identifier for the import batch.
IsIndexed bool β€” Indicates whether OCR/text has been indexed in search engine.
DocumentUploadedBy string β€” User or system that performed the upload.
DocumentUploadedDate DateTime β€” UTC timestamp of when the page was uploaded.

5. Use Cases & Scenarios

  1. Bulk Document Import
    • Read a multi-page PDF or TIFF, split into pages, convert to images, and persist each page as an IPMMigration record.
  2. OCR Processing Workflow
    • After raw import, queue pages for OCR. Store OCR outputs in ImageOCRContents and extracted text in ImageOCRText.
  3. Indexing for Search
    • Mark IsIndexed = true once the text has been indexed in full‑text search engine (ElasticSearch, Azure Cognitive Search, etc.).
  4. Audit & Traceability
    • Retain DocumentUploadedBy and DocumentUploadedDate for compliance and audit trails.

6. Sample Code & Usage Examples

6.1. Creating & Saving a Page Record

using (var context = new ImagingDbContext())
{
    var pageRecord = new IPMMigration
    {
        IPMMigrationId        = Guid.NewGuid(),
        FileName              = "scan_20221201.tiff",
        ContentType           = "image/tiff",
        TotalPages            = 10,
        Page                  = 1,
        ImageContents         = File.ReadAllBytes("scan_20221201_page1.tiff"),
        ImageOCRContents      = RunOcrAndGetBinary(...),
        ImageOCRText          = RunOcrAndGetText(...),
        ReferenceId           = somePatientId,
        BatchId               = importBatchId,
        IsIndexed             = false,
        DocumentUploadedBy    = currentUserName,
        DocumentUploadedDate  = DateTime.UtcNow
    };

    context.IPMMigrations.Add(pageRecord);
    await context.SaveChangesAsync();
}

6.2. Querying Unindexed Pages

var pendingPages = await context.IPMMigrations
    .Where(x => !x.IsIndexed)
    .OrderBy(x => x.BatchId)
    .ThenBy(x => x.Page)
    .ToListAsync();

7. UML Class Diagram

classDiagram
    class IPMMigration {
        <<Entity>>
        +Guid IPMMigrationId
        +string FileName
        +string ContentType
        +int TotalPages
        +int Page
        +byte[] ImageContents
        +byte[] ImageOCRContents
        +string ImageOCRText
        +Guid ReferenceId
        +Guid BatchId
        +bool IsIndexed
        +string DocumentUploadedBy
        +DateTime DocumentUploadedDate
    }

8. Conclusion

The IPMMigration class is the cornerstone of the Imaging import pipeline, enabling:

  • Granular storage of each document page
  • Binary + text persistence for future processing
  • Auditability and indexing flags for workflows

By leveraging Entity Framework Core’s Code-First approach, developers can easily evolve the schema, query efficiently, and integrate into larger imaging and OCR pipelines.


✨ Happy Coding & Imaging! ✨