π IPMMigration Class Documentation
File:
IrbyImaging.DomainClasses/IPMMigration.cs
Assembly:IrbyImaging.DomainClasses
Author: kvamshi
Created / Last Modified: 01β12β2022
π Table of Contents
- Overview & Purpose
- Dependencies & Technologies
- Data Model & EF Core Mapping
- Property Reference
- Use Cases & Scenarios
- Sample Code & Usage Examples
- UML Class Diagram
- 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.IPMMigrationtable.
- Maps this class to the
- [Key] attribute
- Declares
IPMMigrationIdas the Primary Key (GUID).
- Declares
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
- Bulk Document Import
- Read a multi-page PDF or TIFF, split into pages, convert to images, and persist each page as an
IPMMigrationrecord.
- Read a multi-page PDF or TIFF, split into pages, convert to images, and persist each page as an
- OCR Processing Workflow
- After raw import, queue pages for OCR. Store OCR outputs in
ImageOCRContentsand extracted text inImageOCRText.
- After raw import, queue pages for OCR. Store OCR outputs in
- Indexing for Search
- Mark
IsIndexed = trueonce the text has been indexed in fullβtext search engine (ElasticSearch, Azure Cognitive Search, etc.).
- Mark
- Audit & Traceability
- Retain
DocumentUploadedByandDocumentUploadedDatefor compliance and audit trails.
- Retain
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! β¨