2131 lines
90 KiB
C#
2131 lines
90 KiB
C#
using ClinicalInsightsPro.API.Models;
|
|
using Microsoft.AspNetCore.Identity;
|
|
|
|
namespace ClinicalInsightsPro.API.Data;
|
|
|
|
/// <summary>
|
|
/// Seeds the database with 5 demo records per resource, using Indian patient /
|
|
/// practitioner / hospital data.
|
|
///
|
|
/// IMPORTANT — insert order follows the foreign-key dependency chain, because
|
|
/// every child row references the PARENT's BaseEntity.Id (not its business id):
|
|
///
|
|
/// Location -> Organization -> Practitioner -> Patient
|
|
/// -> PractitionerRole
|
|
/// -> Condition / Encounter / Observation / Allergy / Medication
|
|
/// -> ServiceRequest / RiskAssessment / CarePlan / CdsAlert
|
|
///
|
|
/// Each block is saved before the next one starts, so the FK values are
|
|
/// guaranteed to exist in the parent table.
|
|
/// </summary>
|
|
public static class SeedData
|
|
{
|
|
private const string SeedUser = "system-seed";
|
|
|
|
public static void Initialize(ApplicationDbContext context)
|
|
{
|
|
SeedClinicalData(context);
|
|
SeedCdsRules(context);
|
|
SeedUsers(context);
|
|
}
|
|
|
|
// ------------------------------------------------------------------
|
|
// MAIN CLINICAL DATA
|
|
// ------------------------------------------------------------------
|
|
private static void SeedClinicalData(ApplicationDbContext context)
|
|
{
|
|
// Idempotent guard: only seed into an empty database.
|
|
if (context.Patients.Any())
|
|
return;
|
|
|
|
// ==============================================================
|
|
// 1. LOCATIONS (no FK — must be inserted first)
|
|
// ==============================================================
|
|
var locations = new List<Location>
|
|
{
|
|
new Location
|
|
{
|
|
Id = "loc-001",
|
|
LocationId = "loc-001",
|
|
ResourceType = "Location",
|
|
IdentifierSystem = "http://clinicalinsightspro.in/location",
|
|
IdentifierValue = "LOC-NAG-001",
|
|
Status = "active",
|
|
OperationalStatusSystem = "http://terminology.hl7.org/CodeSystem/v2-0116",
|
|
OperationalStatusCode = "U",
|
|
OperationalStatusDisplay = "Unoccupied",
|
|
Name = "Sanjeevani Cardiology Wing",
|
|
Description = "Cardiology OPD and cath lab, Block A, Nagpur",
|
|
City = "Nagpur",
|
|
State = "Maharashtra",
|
|
PostalCode = "440010",
|
|
AddressUse = "work",
|
|
AddressType = "both",
|
|
Mode = "instance",
|
|
TypeSystem = "http://terminology.hl7.org/CodeSystem/v3-RoleCode",
|
|
TypeCode = "HOSP",
|
|
TypeDisplay = "Hospital Unit",
|
|
TelecomSystem = "phone",
|
|
TelecomUse = "work",
|
|
TelecomValue = "+91-712-2451001",
|
|
Latitude = 21.1458,
|
|
Longitude = 79.0882,
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new Location
|
|
{
|
|
Id = "loc-002",
|
|
LocationId = "loc-002",
|
|
ResourceType = "Location",
|
|
IdentifierSystem = "http://clinicalinsightspro.in/location",
|
|
IdentifierValue = "LOC-PUN-002",
|
|
Status = "active",
|
|
Name = "Aarogya OPD Block",
|
|
Description = "Outpatient consulting block, Kothrud, Pune",
|
|
City = "Pune",
|
|
State = "Maharashtra",
|
|
PostalCode = "411038",
|
|
AddressUse = "work",
|
|
AddressType = "both",
|
|
Mode = "instance",
|
|
TypeSystem = "http://terminology.hl7.org/CodeSystem/v3-RoleCode",
|
|
TypeCode = "OF",
|
|
TypeDisplay = "Outpatient Facility",
|
|
TelecomSystem = "phone",
|
|
TelecomUse = "work",
|
|
TelecomValue = "+91-20-25441002",
|
|
Latitude = 18.5204,
|
|
Longitude = 73.8567,
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new Location
|
|
{
|
|
Id = "loc-003",
|
|
LocationId = "loc-003",
|
|
ResourceType = "Location",
|
|
IdentifierSystem = "http://clinicalinsightspro.in/location",
|
|
IdentifierValue = "LOC-CHE-003",
|
|
Status = "active",
|
|
Name = "Sri Balaji Diagnostics Centre",
|
|
Description = "Pathology and radiology centre, T. Nagar, Chennai",
|
|
City = "Chennai",
|
|
State = "Tamil Nadu",
|
|
PostalCode = "600017",
|
|
AddressUse = "work",
|
|
AddressType = "both",
|
|
Mode = "instance",
|
|
TypeSystem = "http://terminology.hl7.org/CodeSystem/v3-RoleCode",
|
|
TypeCode = "RADDX",
|
|
TypeDisplay = "Radiology Diagnostics",
|
|
TelecomSystem = "phone",
|
|
TelecomUse = "work",
|
|
TelecomValue = "+91-44-28151003",
|
|
Latitude = 13.0827,
|
|
Longitude = 80.2707,
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new Location
|
|
{
|
|
Id = "loc-004",
|
|
LocationId = "loc-004",
|
|
ResourceType = "Location",
|
|
IdentifierSystem = "http://clinicalinsightspro.in/location",
|
|
IdentifierValue = "LOC-DEL-004",
|
|
Status = "active",
|
|
Name = "Ganga Emergency Department",
|
|
Description = "24x7 casualty and trauma unit, Karol Bagh, New Delhi",
|
|
City = "New Delhi",
|
|
State = "Delhi",
|
|
PostalCode = "110005",
|
|
AddressUse = "work",
|
|
AddressType = "both",
|
|
Mode = "instance",
|
|
TypeSystem = "http://terminology.hl7.org/CodeSystem/v3-RoleCode",
|
|
TypeCode = "ER",
|
|
TypeDisplay = "Emergency Room",
|
|
TelecomSystem = "phone",
|
|
TelecomUse = "work",
|
|
TelecomValue = "+91-11-23611004",
|
|
Latitude = 28.6139,
|
|
Longitude = 77.2090,
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new Location
|
|
{
|
|
Id = "loc-005",
|
|
LocationId = "loc-005",
|
|
ResourceType = "Location",
|
|
IdentifierSystem = "http://clinicalinsightspro.in/location",
|
|
IdentifierValue = "LOC-KOC-005",
|
|
Status = "active",
|
|
Name = "Malabar Dialysis Unit",
|
|
Description = "Nephrology and dialysis unit, Kaloor, Kochi",
|
|
City = "Kochi",
|
|
State = "Kerala",
|
|
PostalCode = "682017",
|
|
AddressUse = "work",
|
|
AddressType = "both",
|
|
Mode = "instance",
|
|
TypeSystem = "http://terminology.hl7.org/CodeSystem/v3-RoleCode",
|
|
TypeCode = "HOSP",
|
|
TypeDisplay = "Hospital Unit",
|
|
TelecomSystem = "phone",
|
|
TelecomUse = "work",
|
|
TelecomValue = "+91-484-2401005",
|
|
Latitude = 9.9312,
|
|
Longitude = 76.2673,
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
}
|
|
};
|
|
|
|
context.Locations.AddRange(locations);
|
|
context.SaveChanges();
|
|
|
|
// ==============================================================
|
|
// 2. ORGANIZATIONS (FK -> Location.Id)
|
|
// ==============================================================
|
|
var organizations = new List<Organization>
|
|
{
|
|
new Organization
|
|
{
|
|
Id = "org-001",
|
|
OrganizationId = "org-001",
|
|
Name = "Sanjeevani Multispeciality Hospital",
|
|
Alias = "Sanjeevani Hospital",
|
|
Identifier = "NABH-MH-NAG-1001",
|
|
Line = "12, Ram Nagar, Wardha Road",
|
|
City = "Nagpur",
|
|
State = "Maharashtra",
|
|
PostalCode = "440010",
|
|
System = "phone",
|
|
Use = "work",
|
|
Value = "+91-712-2451000",
|
|
LocationId = "loc-001",
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new Organization
|
|
{
|
|
Id = "org-002",
|
|
OrganizationId = "org-002",
|
|
Name = "Aarogya Care Hospital",
|
|
Alias = "Aarogya Care",
|
|
Identifier = "NABH-MH-PUN-1002",
|
|
Line = "45, Karve Road, Kothrud",
|
|
City = "Pune",
|
|
State = "Maharashtra",
|
|
PostalCode = "411038",
|
|
System = "phone",
|
|
Use = "work",
|
|
Value = "+91-20-25441000",
|
|
LocationId = "loc-002",
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new Organization
|
|
{
|
|
Id = "org-003",
|
|
OrganizationId = "org-003",
|
|
Name = "Sri Balaji Medical Centre",
|
|
Alias = "Balaji Medical",
|
|
Identifier = "NABH-TN-CHE-1003",
|
|
Line = "78, Usman Road, T. Nagar",
|
|
City = "Chennai",
|
|
State = "Tamil Nadu",
|
|
PostalCode = "600017",
|
|
System = "phone",
|
|
Use = "work",
|
|
Value = "+91-44-28151000",
|
|
LocationId = "loc-003",
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new Organization
|
|
{
|
|
Id = "org-004",
|
|
OrganizationId = "org-004",
|
|
Name = "Ganga Health Institute",
|
|
Alias = "Ganga Institute",
|
|
Identifier = "NABH-DL-NDL-1004",
|
|
Line = "9, Pusa Road, Karol Bagh",
|
|
City = "New Delhi",
|
|
State = "Delhi",
|
|
PostalCode = "110005",
|
|
System = "phone",
|
|
Use = "work",
|
|
Value = "+91-11-23611000",
|
|
LocationId = "loc-004",
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new Organization
|
|
{
|
|
Id = "org-005",
|
|
OrganizationId = "org-005",
|
|
Name = "Malabar Health Services",
|
|
Alias = "Malabar Health",
|
|
Identifier = "NABH-KL-KOC-1005",
|
|
Line = "23, Banerji Road, Kaloor",
|
|
City = "Kochi",
|
|
State = "Kerala",
|
|
PostalCode = "682017",
|
|
System = "phone",
|
|
Use = "work",
|
|
Value = "+91-484-2401000",
|
|
LocationId = "loc-005",
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
}
|
|
};
|
|
|
|
context.Organizations.AddRange(organizations);
|
|
context.SaveChanges();
|
|
|
|
// ==============================================================
|
|
// 3. PRACTITIONERS (no FK)
|
|
// ==============================================================
|
|
var practitioners = new List<Practitioner>
|
|
{
|
|
new Practitioner
|
|
{
|
|
Id = "prac-001",
|
|
PractitionerId = "prac-001",
|
|
ResourceType = "Practitioner",
|
|
IdentifierSystem = "http://nmc.org.in/registration",
|
|
IdentifierValue = "MMC-2001-45871",
|
|
NameUse = "official",
|
|
Prefix = "Dr.",
|
|
GivenName = "Rajesh",
|
|
FamilyName = "Kulkarni",
|
|
Suffix = "MD, DM",
|
|
TelecomSystem = "phone",
|
|
TelecomUse = "work",
|
|
TelecomValue = "+91-9822011001",
|
|
AddressUse = "work",
|
|
AddressType = "both",
|
|
AddressLine1 = "12, Ram Nagar, Wardha Road",
|
|
AddressLine2 = "Sanjeevani Cardiology Wing",
|
|
City = "Nagpur",
|
|
State = "Maharashtra",
|
|
PostalCode = "440010",
|
|
Gender = "male",
|
|
BirthDate = new DateTime(1975, 2, 18),
|
|
QualificationSystem = "http://terminology.hl7.org/CodeSystem/v2-0360",
|
|
QualificationCode = "MD",
|
|
QualificationDisplay = "Doctor of Medicine - Cardiology",
|
|
QualificationStart = new DateTime(2001, 7, 1),
|
|
QualificationEnd = new DateTime(2035, 6, 30),
|
|
CommunicationCode = "mr-IN",
|
|
CommunicationDisplay = "Marathi (India)",
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new Practitioner
|
|
{
|
|
Id = "prac-002",
|
|
PractitionerId = "prac-002",
|
|
ResourceType = "Practitioner",
|
|
IdentifierSystem = "http://nmc.org.in/registration",
|
|
IdentifierValue = "MMC-2006-51234",
|
|
NameUse = "official",
|
|
Prefix = "Dr.",
|
|
GivenName = "Meera",
|
|
FamilyName = "Joshi",
|
|
Suffix = "MD, DM",
|
|
TelecomSystem = "phone",
|
|
TelecomUse = "work",
|
|
TelecomValue = "+91-9822011002",
|
|
AddressUse = "work",
|
|
AddressType = "both",
|
|
AddressLine1 = "45, Karve Road, Kothrud",
|
|
AddressLine2 = "Aarogya OPD Block",
|
|
City = "Pune",
|
|
State = "Maharashtra",
|
|
PostalCode = "411038",
|
|
Gender = "female",
|
|
BirthDate = new DateTime(1980, 8, 9),
|
|
QualificationSystem = "http://terminology.hl7.org/CodeSystem/v2-0360",
|
|
QualificationCode = "MD",
|
|
QualificationDisplay = "Doctor of Medicine - Endocrinology",
|
|
QualificationStart = new DateTime(2006, 7, 1),
|
|
QualificationEnd = new DateTime(2036, 6, 30),
|
|
CommunicationCode = "hi-IN",
|
|
CommunicationDisplay = "Hindi (India)",
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new Practitioner
|
|
{
|
|
Id = "prac-003",
|
|
PractitionerId = "prac-003",
|
|
ResourceType = "Practitioner",
|
|
IdentifierSystem = "http://nmc.org.in/registration",
|
|
IdentifierValue = "TNMC-1996-33210",
|
|
NameUse = "official",
|
|
Prefix = "Dr.",
|
|
GivenName = "Suresh",
|
|
FamilyName = "Reddy",
|
|
Suffix = "MBBS, MD",
|
|
TelecomSystem = "phone",
|
|
TelecomUse = "work",
|
|
TelecomValue = "+91-9840011003",
|
|
AddressUse = "work",
|
|
AddressType = "both",
|
|
AddressLine1 = "78, Usman Road, T. Nagar",
|
|
AddressLine2 = "Sri Balaji Medical Centre",
|
|
City = "Chennai",
|
|
State = "Tamil Nadu",
|
|
PostalCode = "600017",
|
|
Gender = "male",
|
|
BirthDate = new DateTime(1970, 12, 1),
|
|
QualificationSystem = "http://terminology.hl7.org/CodeSystem/v2-0360",
|
|
QualificationCode = "MD",
|
|
QualificationDisplay = "Doctor of Medicine - General Medicine",
|
|
QualificationStart = new DateTime(1996, 7, 1),
|
|
QualificationEnd = new DateTime(2032, 6, 30),
|
|
CommunicationCode = "ta-IN",
|
|
CommunicationDisplay = "Tamil (India)",
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new Practitioner
|
|
{
|
|
Id = "prac-004",
|
|
PractitionerId = "prac-004",
|
|
ResourceType = "Practitioner",
|
|
IdentifierSystem = "http://nmc.org.in/registration",
|
|
IdentifierValue = "TCMC-2009-77812",
|
|
NameUse = "official",
|
|
Prefix = "Dr.",
|
|
GivenName = "Kavita",
|
|
FamilyName = "Menon",
|
|
Suffix = "MD, DNB",
|
|
TelecomSystem = "phone",
|
|
TelecomUse = "work",
|
|
TelecomValue = "+91-9847011004",
|
|
AddressUse = "work",
|
|
AddressType = "both",
|
|
AddressLine1 = "23, Banerji Road, Kaloor",
|
|
AddressLine2 = "Malabar Health Services",
|
|
City = "Kochi",
|
|
State = "Kerala",
|
|
PostalCode = "682017",
|
|
Gender = "female",
|
|
BirthDate = new DateTime(1983, 5, 27),
|
|
QualificationSystem = "http://terminology.hl7.org/CodeSystem/v2-0360",
|
|
QualificationCode = "MD",
|
|
QualificationDisplay = "Doctor of Medicine - Pulmonology",
|
|
QualificationStart = new DateTime(2009, 7, 1),
|
|
QualificationEnd = new DateTime(2039, 6, 30),
|
|
CommunicationCode = "ml-IN",
|
|
CommunicationDisplay = "Malayalam (India)",
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new Practitioner
|
|
{
|
|
Id = "prac-005",
|
|
PractitionerId = "prac-005",
|
|
ResourceType = "Practitioner",
|
|
IdentifierSystem = "http://nmc.org.in/registration",
|
|
IdentifierValue = "DMC-2003-66540",
|
|
NameUse = "official",
|
|
Prefix = "Dr.",
|
|
GivenName = "Arjun",
|
|
FamilyName = "Bhatt",
|
|
Suffix = "MD, DM",
|
|
TelecomSystem = "phone",
|
|
TelecomUse = "work",
|
|
TelecomValue = "+91-9811011005",
|
|
AddressUse = "work",
|
|
AddressType = "both",
|
|
AddressLine1 = "9, Pusa Road, Karol Bagh",
|
|
AddressLine2 = "Ganga Health Institute",
|
|
City = "New Delhi",
|
|
State = "Delhi",
|
|
PostalCode = "110005",
|
|
Gender = "male",
|
|
BirthDate = new DateTime(1977, 10, 14),
|
|
QualificationSystem = "http://terminology.hl7.org/CodeSystem/v2-0360",
|
|
QualificationCode = "MD",
|
|
QualificationDisplay = "Doctor of Medicine - Nephrology",
|
|
QualificationStart = new DateTime(2003, 7, 1),
|
|
QualificationEnd = new DateTime(2037, 6, 30),
|
|
CommunicationCode = "hi-IN",
|
|
CommunicationDisplay = "Hindi (India)",
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
}
|
|
};
|
|
|
|
context.Practitioners.AddRange(practitioners);
|
|
context.SaveChanges();
|
|
|
|
// ==============================================================
|
|
// 4. PATIENTS (FK -> Organization.Id, Practitioner.Id)
|
|
// ==============================================================
|
|
var patients = new List<Patient>
|
|
{
|
|
new Patient
|
|
{
|
|
Id = "pat-001",
|
|
PatientId = "pat-001",
|
|
ResourceType = "Patient",
|
|
MedicalRecordNumber = "MRN-IN-100001",
|
|
IdentifierSystem = "http://clinicalinsightspro.in/mrn",
|
|
IdentifierValue = "MRN-IN-100001",
|
|
NameUse = "official",
|
|
Prefix = "Mr.",
|
|
GivenName = "Aarav",
|
|
FamilyName = "Sharma",
|
|
TelecomSystem = "phone",
|
|
TelecomUse = "mobile",
|
|
TelecomValue = "+91-9823456701",
|
|
Gender = "male",
|
|
BirthDate = new DateTime(1985, 4, 12),
|
|
AddressUse = "home",
|
|
AddressType = "both",
|
|
AddressLine = "104, Shivaji Nagar, Dharampeth",
|
|
City = "Nagpur",
|
|
State = "Maharashtra",
|
|
PostalCode = "440010",
|
|
MaritalStatusSystem = "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus",
|
|
MaritalStatusCode = "M",
|
|
MaritalStatusDisplay = "Married",
|
|
ContactNameUse = "official",
|
|
ContactPrefix = "Mrs.",
|
|
ContactTelecomSystem = "phone",
|
|
ContactTelecomUse = "mobile",
|
|
ContactTelecomValue = "+91-9823456702",
|
|
ContactAddressUse = "home",
|
|
ContactAddressType = "both",
|
|
ContactAddressLine = "104, Shivaji Nagar, Dharampeth",
|
|
ContactCity = "Nagpur",
|
|
ContactState = "Maharashtra",
|
|
ContactPostalCode = "440010",
|
|
ContactGender = "female",
|
|
ContactOrganizationId = "org-001",
|
|
ContactPeriodStart = new DateTime(2020, 1, 1),
|
|
ContactPeriodEnd = new DateTime(2030, 12, 31),
|
|
ManagingOrganizationId = "org-001",
|
|
GeneralPractitionerId = "prac-001",
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new Patient
|
|
{
|
|
Id = "pat-002",
|
|
PatientId = "pat-002",
|
|
ResourceType = "Patient",
|
|
MedicalRecordNumber = "MRN-IN-100002",
|
|
IdentifierSystem = "http://clinicalinsightspro.in/mrn",
|
|
IdentifierValue = "MRN-IN-100002",
|
|
NameUse = "official",
|
|
Prefix = "Ms.",
|
|
GivenName = "Priya",
|
|
FamilyName = "Deshmukh",
|
|
TelecomSystem = "phone",
|
|
TelecomUse = "mobile",
|
|
TelecomValue = "+91-9890123402",
|
|
Gender = "female",
|
|
BirthDate = new DateTime(1992, 9, 5),
|
|
AddressUse = "home",
|
|
AddressType = "both",
|
|
AddressLine = "22, Sahakar Nagar, Kothrud",
|
|
City = "Pune",
|
|
State = "Maharashtra",
|
|
PostalCode = "411038",
|
|
MaritalStatusSystem = "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus",
|
|
MaritalStatusCode = "S",
|
|
MaritalStatusDisplay = "Never Married",
|
|
ContactNameUse = "official",
|
|
ContactPrefix = "Mr.",
|
|
ContactTelecomSystem = "phone",
|
|
ContactTelecomUse = "mobile",
|
|
ContactTelecomValue = "+91-9890123403",
|
|
ContactAddressUse = "home",
|
|
ContactAddressType = "both",
|
|
ContactAddressLine = "22, Sahakar Nagar, Kothrud",
|
|
ContactCity = "Pune",
|
|
ContactState = "Maharashtra",
|
|
ContactPostalCode = "411038",
|
|
ContactGender = "male",
|
|
ContactOrganizationId = "org-002",
|
|
ContactPeriodStart = new DateTime(2021, 3, 15),
|
|
ContactPeriodEnd = new DateTime(2031, 3, 14),
|
|
ManagingOrganizationId = "org-002",
|
|
GeneralPractitionerId = "prac-002",
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new Patient
|
|
{
|
|
Id = "pat-003",
|
|
PatientId = "pat-003",
|
|
ResourceType = "Patient",
|
|
MedicalRecordNumber = "MRN-IN-100003",
|
|
IdentifierSystem = "http://clinicalinsightspro.in/mrn",
|
|
IdentifierValue = "MRN-IN-100003",
|
|
NameUse = "official",
|
|
Prefix = "Mr.",
|
|
GivenName = "Rohan",
|
|
FamilyName = "Iyer",
|
|
TelecomSystem = "phone",
|
|
TelecomUse = "mobile",
|
|
TelecomValue = "+91-9841234504",
|
|
Gender = "male",
|
|
BirthDate = new DateTime(1978, 1, 23),
|
|
AddressUse = "home",
|
|
AddressType = "both",
|
|
AddressLine = "9, Anna Salai, Mylapore",
|
|
City = "Chennai",
|
|
State = "Tamil Nadu",
|
|
PostalCode = "600004",
|
|
MaritalStatusSystem = "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus",
|
|
MaritalStatusCode = "M",
|
|
MaritalStatusDisplay = "Married",
|
|
ContactNameUse = "official",
|
|
ContactPrefix = "Mrs.",
|
|
ContactTelecomSystem = "phone",
|
|
ContactTelecomUse = "mobile",
|
|
ContactTelecomValue = "+91-9841234505",
|
|
ContactAddressUse = "home",
|
|
ContactAddressType = "both",
|
|
ContactAddressLine = "9, Anna Salai, Mylapore",
|
|
ContactCity = "Chennai",
|
|
ContactState = "Tamil Nadu",
|
|
ContactPostalCode = "600004",
|
|
ContactGender = "female",
|
|
ContactOrganizationId = "org-003",
|
|
ContactPeriodStart = new DateTime(2019, 6, 1),
|
|
ContactPeriodEnd = new DateTime(2029, 5, 31),
|
|
ManagingOrganizationId = "org-003",
|
|
GeneralPractitionerId = "prac-003",
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new Patient
|
|
{
|
|
Id = "pat-004",
|
|
PatientId = "pat-004",
|
|
ResourceType = "Patient",
|
|
MedicalRecordNumber = "MRN-IN-100004",
|
|
IdentifierSystem = "http://clinicalinsightspro.in/mrn",
|
|
IdentifierValue = "MRN-IN-100004",
|
|
NameUse = "official",
|
|
Prefix = "Ms.",
|
|
GivenName = "Ananya",
|
|
FamilyName = "Verma",
|
|
TelecomSystem = "phone",
|
|
TelecomUse = "mobile",
|
|
TelecomValue = "+91-9811223306",
|
|
Gender = "female",
|
|
BirthDate = new DateTime(1996, 11, 17),
|
|
AddressUse = "home",
|
|
AddressType = "both",
|
|
AddressLine = "58, Rajouri Garden",
|
|
City = "New Delhi",
|
|
State = "Delhi",
|
|
PostalCode = "110027",
|
|
MaritalStatusSystem = "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus",
|
|
MaritalStatusCode = "S",
|
|
MaritalStatusDisplay = "Never Married",
|
|
ContactNameUse = "official",
|
|
ContactPrefix = "Mr.",
|
|
ContactTelecomSystem = "phone",
|
|
ContactTelecomUse = "mobile",
|
|
ContactTelecomValue = "+91-9811223307",
|
|
ContactAddressUse = "home",
|
|
ContactAddressType = "both",
|
|
ContactAddressLine = "58, Rajouri Garden",
|
|
ContactCity = "New Delhi",
|
|
ContactState = "Delhi",
|
|
ContactPostalCode = "110027",
|
|
ContactGender = "male",
|
|
ContactOrganizationId = "org-004",
|
|
ContactPeriodStart = new DateTime(2022, 2, 1),
|
|
ContactPeriodEnd = new DateTime(2032, 1, 31),
|
|
ManagingOrganizationId = "org-004",
|
|
GeneralPractitionerId = "prac-005",
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new Patient
|
|
{
|
|
Id = "pat-005",
|
|
PatientId = "pat-005",
|
|
ResourceType = "Patient",
|
|
MedicalRecordNumber = "MRN-IN-100005",
|
|
IdentifierSystem = "http://clinicalinsightspro.in/mrn",
|
|
IdentifierValue = "MRN-IN-100005",
|
|
NameUse = "official",
|
|
Prefix = "Mr.",
|
|
GivenName = "Vikram",
|
|
FamilyName = "Nair",
|
|
TelecomSystem = "phone",
|
|
TelecomUse = "mobile",
|
|
TelecomValue = "+91-9847556608",
|
|
Gender = "male",
|
|
BirthDate = new DateTime(1965, 6, 30),
|
|
AddressUse = "home",
|
|
AddressType = "both",
|
|
AddressLine = "31, Panampilly Nagar",
|
|
City = "Kochi",
|
|
State = "Kerala",
|
|
PostalCode = "682036",
|
|
MaritalStatusSystem = "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus",
|
|
MaritalStatusCode = "M",
|
|
MaritalStatusDisplay = "Married",
|
|
ContactNameUse = "official",
|
|
ContactPrefix = "Mrs.",
|
|
ContactTelecomSystem = "phone",
|
|
ContactTelecomUse = "mobile",
|
|
ContactTelecomValue = "+91-9847556609",
|
|
ContactAddressUse = "home",
|
|
ContactAddressType = "both",
|
|
ContactAddressLine = "31, Panampilly Nagar",
|
|
ContactCity = "Kochi",
|
|
ContactState = "Kerala",
|
|
ContactPostalCode = "682036",
|
|
ContactGender = "female",
|
|
ContactOrganizationId = "org-005",
|
|
ContactPeriodStart = new DateTime(2018, 9, 1),
|
|
ContactPeriodEnd = new DateTime(2028, 8, 31),
|
|
ManagingOrganizationId = "org-005",
|
|
GeneralPractitionerId = "prac-004",
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
}
|
|
};
|
|
|
|
context.Patients.AddRange(patients);
|
|
context.SaveChanges();
|
|
|
|
// ==============================================================
|
|
// 5. PRACTITIONER ROLES (FK -> Practitioner.Id, Organization.Id, Location.Id)
|
|
// ==============================================================
|
|
var practitionerRoles = new List<PractitionerRole>
|
|
{
|
|
new PractitionerRole
|
|
{
|
|
Id = "prole-001",
|
|
PractitionerRoleId = "prole-001",
|
|
ResourceType = "PractitionerRole",
|
|
IdentifierSystem = "http://clinicalinsightspro.in/practitioner-role",
|
|
IdentifierValue = "ROLE-NAG-001",
|
|
PeriodStart = new DateTime(2015, 4, 1),
|
|
PeriodEnd = new DateTime(2030, 3, 31),
|
|
PractitionerId = "prac-001",
|
|
OrganizationId = "org-001",
|
|
LocationId = "loc-001",
|
|
RoleSystem = "http://terminology.hl7.org/CodeSystem/practitioner-role",
|
|
RoleCode = "doctor",
|
|
RoleDisplay = "Consultant Cardiologist",
|
|
SpecialtyCode = "394579002",
|
|
SpecialtyDisplay = "Cardiology",
|
|
TelecomSystem = "phone",
|
|
TelecomUse = "work",
|
|
TelecomValue = "+91-712-2451011",
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new PractitionerRole
|
|
{
|
|
Id = "prole-002",
|
|
PractitionerRoleId = "prole-002",
|
|
ResourceType = "PractitionerRole",
|
|
IdentifierSystem = "http://clinicalinsightspro.in/practitioner-role",
|
|
IdentifierValue = "ROLE-PUN-002",
|
|
PeriodStart = new DateTime(2016, 8, 1),
|
|
PeriodEnd = new DateTime(2031, 7, 31),
|
|
PractitionerId = "prac-002",
|
|
OrganizationId = "org-002",
|
|
LocationId = "loc-002",
|
|
RoleSystem = "http://terminology.hl7.org/CodeSystem/practitioner-role",
|
|
RoleCode = "doctor",
|
|
RoleDisplay = "Consultant Endocrinologist",
|
|
SpecialtyCode = "394583002",
|
|
SpecialtyDisplay = "Endocrinology",
|
|
TelecomSystem = "phone",
|
|
TelecomUse = "work",
|
|
TelecomValue = "+91-20-25441012",
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new PractitionerRole
|
|
{
|
|
Id = "prole-003",
|
|
PractitionerRoleId = "prole-003",
|
|
ResourceType = "PractitionerRole",
|
|
IdentifierSystem = "http://clinicalinsightspro.in/practitioner-role",
|
|
IdentifierValue = "ROLE-CHE-003",
|
|
PeriodStart = new DateTime(2010, 1, 1),
|
|
PeriodEnd = new DateTime(2028, 12, 31),
|
|
PractitionerId = "prac-003",
|
|
OrganizationId = "org-003",
|
|
LocationId = "loc-003",
|
|
RoleSystem = "http://terminology.hl7.org/CodeSystem/practitioner-role",
|
|
RoleCode = "doctor",
|
|
RoleDisplay = "Senior Consultant - General Medicine",
|
|
SpecialtyCode = "419192003",
|
|
SpecialtyDisplay = "Internal Medicine",
|
|
TelecomSystem = "phone",
|
|
TelecomUse = "work",
|
|
TelecomValue = "+91-44-28151013",
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new PractitionerRole
|
|
{
|
|
Id = "prole-004",
|
|
PractitionerRoleId = "prole-004",
|
|
ResourceType = "PractitionerRole",
|
|
IdentifierSystem = "http://clinicalinsightspro.in/practitioner-role",
|
|
IdentifierValue = "ROLE-KOC-004",
|
|
PeriodStart = new DateTime(2018, 5, 1),
|
|
PeriodEnd = new DateTime(2033, 4, 30),
|
|
PractitionerId = "prac-004",
|
|
OrganizationId = "org-005",
|
|
LocationId = "loc-005",
|
|
RoleSystem = "http://terminology.hl7.org/CodeSystem/practitioner-role",
|
|
RoleCode = "doctor",
|
|
RoleDisplay = "Consultant Pulmonologist",
|
|
SpecialtyCode = "418112009",
|
|
SpecialtyDisplay = "Pulmonary Medicine",
|
|
TelecomSystem = "phone",
|
|
TelecomUse = "work",
|
|
TelecomValue = "+91-484-2401014",
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new PractitionerRole
|
|
{
|
|
Id = "prole-005",
|
|
PractitionerRoleId = "prole-005",
|
|
ResourceType = "PractitionerRole",
|
|
IdentifierSystem = "http://clinicalinsightspro.in/practitioner-role",
|
|
IdentifierValue = "ROLE-DEL-005",
|
|
PeriodStart = new DateTime(2012, 11, 1),
|
|
PeriodEnd = new DateTime(2032, 10, 31),
|
|
PractitionerId = "prac-005",
|
|
OrganizationId = "org-004",
|
|
LocationId = "loc-004",
|
|
RoleSystem = "http://terminology.hl7.org/CodeSystem/practitioner-role",
|
|
RoleCode = "doctor",
|
|
RoleDisplay = "Consultant Nephrologist",
|
|
SpecialtyCode = "394589003",
|
|
SpecialtyDisplay = "Nephrology",
|
|
TelecomSystem = "phone",
|
|
TelecomUse = "work",
|
|
TelecomValue = "+91-11-23611015",
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
}
|
|
};
|
|
|
|
context.PractitionerRoles.AddRange(practitionerRoles);
|
|
context.SaveChanges();
|
|
|
|
// ==============================================================
|
|
// 6. CONDITIONS (FK -> Patient.Id, Practitioner.Id x2)
|
|
// ==============================================================
|
|
var conditions = new List<Condition>
|
|
{
|
|
new Condition
|
|
{
|
|
Id = "cond-001",
|
|
ConditionId = "cond-001",
|
|
ResourceType = "Condition",
|
|
IdentifierSystem = "http://clinicalinsightspro.in/condition",
|
|
IdentifierValue = "COND-100001",
|
|
ClinicalStatusCode = "active",
|
|
ClinicalStatusDisplay = "Active",
|
|
VerificationStatusCode = "confirmed",
|
|
VerificationStatusDisplay = "Confirmed",
|
|
CategorySystem = "http://terminology.hl7.org/CodeSystem/condition-category",
|
|
CategoryCode = "problem-list-item",
|
|
CategoryDisplay = "Problem List Item",
|
|
SeverityCode = "6736007",
|
|
SeverityDisplay = "Moderate",
|
|
ConditionCode = "E11.9",
|
|
ConditionDisplay = "Type 2 diabetes mellitus without complications",
|
|
PatientId = "pat-001",
|
|
OnsetDateTime = new DateTime(2021, 3, 18),
|
|
AbatementDateTime = null,
|
|
RecordedDate = new DateTime(2021, 3, 20),
|
|
RecorderId = "prac-001",
|
|
AsserterId = "prac-002",
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new Condition
|
|
{
|
|
Id = "cond-002",
|
|
ConditionId = "cond-002",
|
|
ResourceType = "Condition",
|
|
IdentifierSystem = "http://clinicalinsightspro.in/condition",
|
|
IdentifierValue = "COND-100002",
|
|
ClinicalStatusCode = "active",
|
|
ClinicalStatusDisplay = "Active",
|
|
VerificationStatusCode = "confirmed",
|
|
VerificationStatusDisplay = "Confirmed",
|
|
CategorySystem = "http://terminology.hl7.org/CodeSystem/condition-category",
|
|
CategoryCode = "problem-list-item",
|
|
CategoryDisplay = "Problem List Item",
|
|
SeverityCode = "255604002",
|
|
SeverityDisplay = "Mild",
|
|
ConditionCode = "I10",
|
|
ConditionDisplay = "Essential (primary) hypertension",
|
|
PatientId = "pat-002",
|
|
OnsetDateTime = new DateTime(2022, 7, 4),
|
|
AbatementDateTime = null,
|
|
RecordedDate = new DateTime(2022, 7, 6),
|
|
RecorderId = "prac-002",
|
|
AsserterId = "prac-002",
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new Condition
|
|
{
|
|
Id = "cond-003",
|
|
ConditionId = "cond-003",
|
|
ResourceType = "Condition",
|
|
IdentifierSystem = "http://clinicalinsightspro.in/condition",
|
|
IdentifierValue = "COND-100003",
|
|
ClinicalStatusCode = "active",
|
|
ClinicalStatusDisplay = "Active",
|
|
VerificationStatusCode = "confirmed",
|
|
VerificationStatusDisplay = "Confirmed",
|
|
CategorySystem = "http://terminology.hl7.org/CodeSystem/condition-category",
|
|
CategoryCode = "encounter-diagnosis",
|
|
CategoryDisplay = "Encounter Diagnosis",
|
|
SeverityCode = "255604002",
|
|
SeverityDisplay = "Mild",
|
|
ConditionCode = "J45.909",
|
|
ConditionDisplay = "Unspecified asthma, uncomplicated",
|
|
PatientId = "pat-003",
|
|
OnsetDateTime = new DateTime(2019, 12, 11),
|
|
AbatementDateTime = null,
|
|
RecordedDate = new DateTime(2019, 12, 12),
|
|
RecorderId = "prac-003",
|
|
AsserterId = "prac-004",
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new Condition
|
|
{
|
|
Id = "cond-004",
|
|
ConditionId = "cond-004",
|
|
ResourceType = "Condition",
|
|
IdentifierSystem = "http://clinicalinsightspro.in/condition",
|
|
IdentifierValue = "COND-100004",
|
|
ClinicalStatusCode = "resolved",
|
|
ClinicalStatusDisplay = "Resolved",
|
|
VerificationStatusCode = "confirmed",
|
|
VerificationStatusDisplay = "Confirmed",
|
|
CategorySystem = "http://terminology.hl7.org/CodeSystem/condition-category",
|
|
CategoryCode = "problem-list-item",
|
|
CategoryDisplay = "Problem List Item",
|
|
SeverityCode = "255604002",
|
|
SeverityDisplay = "Mild",
|
|
ConditionCode = "D50.9",
|
|
ConditionDisplay = "Iron deficiency anaemia, unspecified",
|
|
PatientId = "pat-004",
|
|
OnsetDateTime = new DateTime(2023, 2, 9),
|
|
AbatementDateTime = new DateTime(2023, 9, 14),
|
|
RecordedDate = new DateTime(2023, 2, 10),
|
|
RecorderId = "prac-005",
|
|
AsserterId = "prac-005",
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new Condition
|
|
{
|
|
Id = "cond-005",
|
|
ConditionId = "cond-005",
|
|
ResourceType = "Condition",
|
|
IdentifierSystem = "http://clinicalinsightspro.in/condition",
|
|
IdentifierValue = "COND-100005",
|
|
ClinicalStatusCode = "active",
|
|
ClinicalStatusDisplay = "Active",
|
|
VerificationStatusCode = "confirmed",
|
|
VerificationStatusDisplay = "Confirmed",
|
|
CategorySystem = "http://terminology.hl7.org/CodeSystem/condition-category",
|
|
CategoryCode = "problem-list-item",
|
|
CategoryDisplay = "Problem List Item",
|
|
SeverityCode = "24484000",
|
|
SeverityDisplay = "Severe",
|
|
ConditionCode = "N18.3",
|
|
ConditionDisplay = "Chronic kidney disease, stage 3 (moderate)",
|
|
PatientId = "pat-005",
|
|
OnsetDateTime = new DateTime(2020, 5, 22),
|
|
AbatementDateTime = null,
|
|
RecordedDate = new DateTime(2020, 5, 25),
|
|
RecorderId = "prac-004",
|
|
AsserterId = "prac-005",
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
}
|
|
};
|
|
|
|
context.Conditions.AddRange(conditions);
|
|
context.SaveChanges();
|
|
|
|
// ==============================================================
|
|
// 7. ENCOUNTERS (FK -> Patient.Id)
|
|
// ==============================================================
|
|
var encounters = new List<Encounter>
|
|
{
|
|
new Encounter
|
|
{
|
|
Id = "enc-001",
|
|
EncounterId = "enc-001",
|
|
ResourceType = "Encounter",
|
|
IdentifierSystem = "http://clinicalinsightspro.in/encounter",
|
|
IdentifierValue = "ENC-100001",
|
|
Status = "finished",
|
|
ClassSystem = "http://terminology.hl7.org/CodeSystem/v3-ActCode",
|
|
ClassCode = "AMB",
|
|
ClassDisplay = "Ambulatory",
|
|
StatusHistory = "planned",
|
|
StatusHistoryStart = new DateTime(2025, 6, 10, 9, 0, 0),
|
|
StatusHistoryEnd = new DateTime(2025, 6, 10, 9, 30, 0),
|
|
ClassHistorySystem = "http://terminology.hl7.org/CodeSystem/v3-ActCode",
|
|
ClassHistoryCode = "AMB",
|
|
ClassHistoryDisplay = "Ambulatory",
|
|
ClassHistoryStart = new DateTime(2025, 6, 10, 9, 0, 0),
|
|
ClassHistoryEnd = new DateTime(2025, 6, 10, 10, 0, 0),
|
|
TypeSystem = "http://snomed.info/sct",
|
|
TypeCode = "185349003",
|
|
TypeDisplay = "Encounter for check-up",
|
|
ServiceTypeSystem = "http://terminology.hl7.org/CodeSystem/service-type",
|
|
ServiceTypeCode = "124",
|
|
ServiceTypeDisplay = "General Practice",
|
|
PrioritySystem = "http://terminology.hl7.org/CodeSystem/v3-ActPriority",
|
|
PriorityCode = "R",
|
|
PriorityDisplay = "Routine",
|
|
PatientId = "pat-001",
|
|
PeriodStart = new DateTime(2025, 6, 10, 9, 0, 0),
|
|
PeriodEnd = new DateTime(2025, 6, 10, 10, 0, 0),
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new Encounter
|
|
{
|
|
Id = "enc-002",
|
|
EncounterId = "enc-002",
|
|
ResourceType = "Encounter",
|
|
IdentifierSystem = "http://clinicalinsightspro.in/encounter",
|
|
IdentifierValue = "ENC-100002",
|
|
Status = "finished",
|
|
ClassSystem = "http://terminology.hl7.org/CodeSystem/v3-ActCode",
|
|
ClassCode = "AMB",
|
|
ClassDisplay = "Ambulatory",
|
|
TypeSystem = "http://snomed.info/sct",
|
|
TypeCode = "390906007",
|
|
TypeDisplay = "Follow-up encounter",
|
|
ServiceTypeSystem = "http://terminology.hl7.org/CodeSystem/service-type",
|
|
ServiceTypeCode = "124",
|
|
ServiceTypeDisplay = "General Practice",
|
|
PrioritySystem = "http://terminology.hl7.org/CodeSystem/v3-ActPriority",
|
|
PriorityCode = "R",
|
|
PriorityDisplay = "Routine",
|
|
PatientId = "pat-002",
|
|
PeriodStart = new DateTime(2025, 7, 2, 11, 0, 0),
|
|
PeriodEnd = new DateTime(2025, 7, 2, 11, 45, 0),
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new Encounter
|
|
{
|
|
Id = "enc-003",
|
|
EncounterId = "enc-003",
|
|
ResourceType = "Encounter",
|
|
IdentifierSystem = "http://clinicalinsightspro.in/encounter",
|
|
IdentifierValue = "ENC-100003",
|
|
Status = "finished",
|
|
ClassSystem = "http://terminology.hl7.org/CodeSystem/v3-ActCode",
|
|
ClassCode = "EMER",
|
|
ClassDisplay = "Emergency",
|
|
TypeSystem = "http://snomed.info/sct",
|
|
TypeCode = "50849002",
|
|
TypeDisplay = "Emergency room admission",
|
|
ServiceTypeSystem = "http://terminology.hl7.org/CodeSystem/service-type",
|
|
ServiceTypeCode = "117",
|
|
ServiceTypeDisplay = "Emergency Department",
|
|
PrioritySystem = "http://terminology.hl7.org/CodeSystem/v3-ActPriority",
|
|
PriorityCode = "EM",
|
|
PriorityDisplay = "Emergency",
|
|
PatientId = "pat-003",
|
|
PeriodStart = new DateTime(2025, 4, 18, 21, 15, 0),
|
|
PeriodEnd = new DateTime(2025, 4, 19, 1, 30, 0),
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new Encounter
|
|
{
|
|
Id = "enc-004",
|
|
EncounterId = "enc-004",
|
|
ResourceType = "Encounter",
|
|
IdentifierSystem = "http://clinicalinsightspro.in/encounter",
|
|
IdentifierValue = "ENC-100004",
|
|
Status = "finished",
|
|
ClassSystem = "http://terminology.hl7.org/CodeSystem/v3-ActCode",
|
|
ClassCode = "IMP",
|
|
ClassDisplay = "Inpatient Encounter",
|
|
TypeSystem = "http://snomed.info/sct",
|
|
TypeCode = "32485007",
|
|
TypeDisplay = "Hospital admission",
|
|
ServiceTypeSystem = "http://terminology.hl7.org/CodeSystem/service-type",
|
|
ServiceTypeCode = "168",
|
|
ServiceTypeDisplay = "Haematology",
|
|
PrioritySystem = "http://terminology.hl7.org/CodeSystem/v3-ActPriority",
|
|
PriorityCode = "UR",
|
|
PriorityDisplay = "Urgent",
|
|
PatientId = "pat-004",
|
|
PeriodStart = new DateTime(2025, 3, 5, 8, 0, 0),
|
|
PeriodEnd = new DateTime(2025, 3, 8, 16, 0, 0),
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new Encounter
|
|
{
|
|
Id = "enc-005",
|
|
EncounterId = "enc-005",
|
|
ResourceType = "Encounter",
|
|
IdentifierSystem = "http://clinicalinsightspro.in/encounter",
|
|
IdentifierValue = "ENC-100005",
|
|
Status = "in-progress",
|
|
ClassSystem = "http://terminology.hl7.org/CodeSystem/v3-ActCode",
|
|
ClassCode = "AMB",
|
|
ClassDisplay = "Ambulatory",
|
|
TypeSystem = "http://snomed.info/sct",
|
|
TypeCode = "265764009",
|
|
TypeDisplay = "Renal dialysis",
|
|
ServiceTypeSystem = "http://terminology.hl7.org/CodeSystem/service-type",
|
|
ServiceTypeCode = "180",
|
|
ServiceTypeDisplay = "Nephrology",
|
|
PrioritySystem = "http://terminology.hl7.org/CodeSystem/v3-ActPriority",
|
|
PriorityCode = "R",
|
|
PriorityDisplay = "Routine",
|
|
PatientId = "pat-005",
|
|
PeriodStart = new DateTime(2025, 8, 1, 7, 30, 0),
|
|
PeriodEnd = new DateTime(2025, 8, 1, 11, 30, 0),
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
}
|
|
};
|
|
|
|
context.Encounters.AddRange(encounters);
|
|
context.SaveChanges();
|
|
|
|
// ==============================================================
|
|
// 8. OBSERVATIONS (FK -> Patient.Id, Practitioner.Id x2)
|
|
// ==============================================================
|
|
var observations = new List<Observation>
|
|
{
|
|
new Observation
|
|
{
|
|
Id = "obs-001",
|
|
Status = "final",
|
|
CategoryCode = "laboratory",
|
|
CategoryDisplay = "Laboratory",
|
|
ObservationCode = "4548-4",
|
|
ObservationDisplay = "Haemoglobin A1c / Haemoglobin total in Blood",
|
|
PatientId = "pat-001",
|
|
PerformerPractitionerId = "prac-002",
|
|
EffectiveDateTime = new DateTimeOffset(2025, 6, 10, 9, 15, 0, TimeSpan.Zero),
|
|
Issued = new DateTimeOffset(2025, 6, 10, 14, 0, 0, TimeSpan.Zero),
|
|
NoteText = "HbA1c 8.4% — above target. Reinforce diet and adherence counselling.",
|
|
NoteAuthorPractitionerId = "prac-002",
|
|
NoteTime = new DateTimeOffset(2025, 6, 10, 14, 10, 0, TimeSpan.Zero),
|
|
InterpretationCode = "H",
|
|
InterpretationDisplay = "High",
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new Observation
|
|
{
|
|
Id = "obs-002",
|
|
Status = "final",
|
|
CategoryCode = "vital-signs",
|
|
CategoryDisplay = "Vital Signs",
|
|
ObservationCode = "8480-6",
|
|
ObservationDisplay = "Systolic blood pressure",
|
|
PatientId = "pat-002",
|
|
PerformerPractitionerId = "prac-002",
|
|
EffectiveDateTime = new DateTimeOffset(2025, 7, 2, 11, 5, 0, TimeSpan.Zero),
|
|
Issued = new DateTimeOffset(2025, 7, 2, 11, 20, 0, TimeSpan.Zero),
|
|
NoteText = "Systolic BP 148 mmHg on repeat measurement. Review antihypertensive dose.",
|
|
NoteAuthorPractitionerId = "prac-002",
|
|
NoteTime = new DateTimeOffset(2025, 7, 2, 11, 25, 0, TimeSpan.Zero),
|
|
InterpretationCode = "H",
|
|
InterpretationDisplay = "High",
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new Observation
|
|
{
|
|
Id = "obs-003",
|
|
Status = "final",
|
|
CategoryCode = "vital-signs",
|
|
CategoryDisplay = "Vital Signs",
|
|
ObservationCode = "2708-6",
|
|
ObservationDisplay = "Oxygen saturation in Arterial blood",
|
|
PatientId = "pat-003",
|
|
PerformerPractitionerId = "prac-003",
|
|
EffectiveDateTime = new DateTimeOffset(2025, 4, 18, 21, 30, 0, TimeSpan.Zero),
|
|
Issued = new DateTimeOffset(2025, 4, 18, 21, 40, 0, TimeSpan.Zero),
|
|
NoteText = "SpO2 96% on room air after nebulisation. Symptoms settled.",
|
|
NoteAuthorPractitionerId = "prac-003",
|
|
NoteTime = new DateTimeOffset(2025, 4, 18, 22, 0, 0, TimeSpan.Zero),
|
|
InterpretationCode = "N",
|
|
InterpretationDisplay = "Normal",
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new Observation
|
|
{
|
|
Id = "obs-004",
|
|
Status = "final",
|
|
CategoryCode = "laboratory",
|
|
CategoryDisplay = "Laboratory",
|
|
ObservationCode = "718-7",
|
|
ObservationDisplay = "Haemoglobin [Mass/volume] in Blood",
|
|
PatientId = "pat-004",
|
|
PerformerPractitionerId = "prac-005",
|
|
EffectiveDateTime = new DateTimeOffset(2025, 3, 5, 8, 30, 0, TimeSpan.Zero),
|
|
Issued = new DateTimeOffset(2025, 3, 5, 12, 0, 0, TimeSpan.Zero),
|
|
NoteText = "Haemoglobin 9.1 g/dL — microcytic picture, iron studies advised.",
|
|
NoteAuthorPractitionerId = "prac-005",
|
|
NoteTime = new DateTimeOffset(2025, 3, 5, 12, 15, 0, TimeSpan.Zero),
|
|
InterpretationCode = "L",
|
|
InterpretationDisplay = "Low",
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new Observation
|
|
{
|
|
Id = "obs-005",
|
|
Status = "final",
|
|
CategoryCode = "laboratory",
|
|
CategoryDisplay = "Laboratory",
|
|
ObservationCode = "2160-0",
|
|
ObservationDisplay = "Creatinine [Mass/volume] in Serum or Plasma",
|
|
PatientId = "pat-005",
|
|
PerformerPractitionerId = "prac-004",
|
|
EffectiveDateTime = new DateTimeOffset(2025, 8, 1, 7, 45, 0, TimeSpan.Zero),
|
|
Issued = new DateTimeOffset(2025, 8, 1, 10, 0, 0, TimeSpan.Zero),
|
|
NoteText = "Serum creatinine 2.3 mg/dL, eGFR 34 — consistent with CKD stage 3b.",
|
|
NoteAuthorPractitionerId = "prac-005",
|
|
NoteTime = new DateTimeOffset(2025, 8, 1, 10, 20, 0, TimeSpan.Zero),
|
|
InterpretationCode = "H",
|
|
InterpretationDisplay = "High",
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
}
|
|
};
|
|
|
|
context.Observations.AddRange(observations);
|
|
context.SaveChanges();
|
|
|
|
// ==============================================================
|
|
// 9. ALLERGIES (FK -> Patient.Id, Patient.Id (asserter), Practitioner.Id)
|
|
// ==============================================================
|
|
var allergies = new List<AllergyIntolerance>
|
|
{
|
|
new AllergyIntolerance
|
|
{
|
|
Id = "alg-001",
|
|
ClinicalStatus = "active",
|
|
VerificationStatus = "confirmed",
|
|
Type = "allergy",
|
|
Criticality = "high",
|
|
PatientId = "pat-001",
|
|
AsserterPatientId = "pat-001",
|
|
RecorderPractitionerId = "prac-001",
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new AllergyIntolerance
|
|
{
|
|
Id = "alg-002",
|
|
ClinicalStatus = "active",
|
|
VerificationStatus = "confirmed",
|
|
Type = "intolerance",
|
|
Criticality = "low",
|
|
PatientId = "pat-002",
|
|
AsserterPatientId = "pat-002",
|
|
RecorderPractitionerId = "prac-002",
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new AllergyIntolerance
|
|
{
|
|
Id = "alg-003",
|
|
ClinicalStatus = "active",
|
|
VerificationStatus = "unconfirmed",
|
|
Type = "allergy",
|
|
Criticality = "unable-to-assess",
|
|
PatientId = "pat-003",
|
|
AsserterPatientId = null,
|
|
RecorderPractitionerId = "prac-003",
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new AllergyIntolerance
|
|
{
|
|
Id = "alg-004",
|
|
ClinicalStatus = "resolved",
|
|
VerificationStatus = "confirmed",
|
|
Type = "intolerance",
|
|
Criticality = "low",
|
|
PatientId = "pat-004",
|
|
AsserterPatientId = "pat-004",
|
|
RecorderPractitionerId = "prac-005",
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new AllergyIntolerance
|
|
{
|
|
Id = "alg-005",
|
|
ClinicalStatus = "active",
|
|
VerificationStatus = "confirmed",
|
|
Type = "allergy",
|
|
Criticality = "high",
|
|
PatientId = "pat-005",
|
|
AsserterPatientId = null,
|
|
RecorderPractitionerId = "prac-004",
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
}
|
|
};
|
|
|
|
context.Allergies.AddRange(allergies);
|
|
context.SaveChanges();
|
|
|
|
// ==============================================================
|
|
// 10. MEDICATION REQUESTS (FK -> Patient.Id)
|
|
// NOTE: pat-001 has active diabetes (E11.9) and NO statin on
|
|
// file, so CdsRulesEngineService raises DM-STATIN-GUIDELINE.
|
|
// ==============================================================
|
|
var medications = new List<MedicationRequest>
|
|
{
|
|
new MedicationRequest
|
|
{
|
|
Id = "med-001",
|
|
Status = "active",
|
|
Intent = "order",
|
|
Priority = "routine",
|
|
PatientId = "pat-001",
|
|
MedicationCode = "860975",
|
|
MedicationDisplay = "Metformin 500 mg oral tablet",
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new MedicationRequest
|
|
{
|
|
Id = "med-002",
|
|
Status = "active",
|
|
Intent = "order",
|
|
Priority = "routine",
|
|
PatientId = "pat-002",
|
|
MedicationCode = "197361",
|
|
MedicationDisplay = "Amlodipine 5 mg oral tablet",
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new MedicationRequest
|
|
{
|
|
Id = "med-003",
|
|
Status = "active",
|
|
Intent = "order",
|
|
Priority = "urgent",
|
|
PatientId = "pat-003",
|
|
MedicationCode = "746763",
|
|
MedicationDisplay = "Salbutamol 100 mcg metered dose inhaler",
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new MedicationRequest
|
|
{
|
|
Id = "med-004",
|
|
Status = "completed",
|
|
Intent = "order",
|
|
Priority = "routine",
|
|
PatientId = "pat-004",
|
|
MedicationCode = "310182",
|
|
MedicationDisplay = "Ferrous sulphate 325 mg oral tablet",
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new MedicationRequest
|
|
{
|
|
Id = "med-005",
|
|
Status = "active",
|
|
Intent = "order",
|
|
Priority = "routine",
|
|
PatientId = "pat-005",
|
|
MedicationCode = "617312",
|
|
MedicationDisplay = "Atorvastatin 10 mg oral tablet",
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
}
|
|
};
|
|
|
|
context.Medications.AddRange(medications);
|
|
context.SaveChanges();
|
|
|
|
// ==============================================================
|
|
// 11. SERVICE REQUESTS (FK -> Patient.Id, Practitioner.Id x2)
|
|
// ==============================================================
|
|
var serviceRequests = new List<ServiceRequest>
|
|
{
|
|
new ServiceRequest
|
|
{
|
|
Id = "sreq-001",
|
|
IdentifierSystem = "http://clinicalinsightspro.in/service-request",
|
|
IdentifierValue = "SR-100001",
|
|
Status = "active",
|
|
Intent = "order",
|
|
QuantityComparator = ">=",
|
|
QuantityValue = 1m,
|
|
QuantityUnit = "test",
|
|
PatientId = "pat-001",
|
|
OccurrenceDateTime = new DateTimeOffset(2025, 9, 10, 9, 0, 0, TimeSpan.Zero),
|
|
RequesterPractitionerId = "prac-002",
|
|
PatientInstruction = "Fasting sample not required. Report to the lab any weekday morning.",
|
|
NoteText = "Repeat HbA1c after three months of therapy intensification.",
|
|
NoteAuthorPractitionerId = "prac-002",
|
|
NoteTime = new DateTimeOffset(2025, 6, 10, 14, 30, 0, TimeSpan.Zero),
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new ServiceRequest
|
|
{
|
|
Id = "sreq-002",
|
|
IdentifierSystem = "http://clinicalinsightspro.in/service-request",
|
|
IdentifierValue = "SR-100002",
|
|
Status = "active",
|
|
Intent = "order",
|
|
QuantityComparator = null,
|
|
QuantityValue = 1m,
|
|
QuantityUnit = "study",
|
|
PatientId = "pat-002",
|
|
OccurrenceDateTime = new DateTimeOffset(2025, 7, 15, 10, 0, 0, TimeSpan.Zero),
|
|
RequesterPractitionerId = "prac-002",
|
|
PatientInstruction = "Carry previous BP records and current medication list.",
|
|
NoteText = "24-hour ambulatory blood pressure monitoring requested.",
|
|
NoteAuthorPractitionerId = "prac-001",
|
|
NoteTime = new DateTimeOffset(2025, 7, 2, 12, 0, 0, TimeSpan.Zero),
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new ServiceRequest
|
|
{
|
|
Id = "sreq-003",
|
|
IdentifierSystem = "http://clinicalinsightspro.in/service-request",
|
|
IdentifierValue = "SR-100003",
|
|
Status = "completed",
|
|
Intent = "original-order",
|
|
QuantityComparator = null,
|
|
QuantityValue = 1m,
|
|
QuantityUnit = "study",
|
|
PatientId = "pat-003",
|
|
OccurrenceDateTime = new DateTimeOffset(2025, 4, 19, 0, 30, 0, TimeSpan.Zero),
|
|
RequesterPractitionerId = "prac-003",
|
|
PatientInstruction = "Remove metal objects before the chest X-ray.",
|
|
NoteText = "Chest X-ray to rule out infective exacerbation.",
|
|
NoteAuthorPractitionerId = "prac-004",
|
|
NoteTime = new DateTimeOffset(2025, 4, 19, 1, 0, 0, TimeSpan.Zero),
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new ServiceRequest
|
|
{
|
|
Id = "sreq-004",
|
|
IdentifierSystem = "http://clinicalinsightspro.in/service-request",
|
|
IdentifierValue = "SR-100004",
|
|
Status = "completed",
|
|
Intent = "order",
|
|
QuantityComparator = null,
|
|
QuantityValue = 3m,
|
|
QuantityUnit = "test",
|
|
PatientId = "pat-004",
|
|
OccurrenceDateTime = new DateTimeOffset(2025, 3, 6, 8, 0, 0, TimeSpan.Zero),
|
|
RequesterPractitionerId = "prac-005",
|
|
PatientInstruction = "Overnight fasting required for the iron studies panel.",
|
|
NoteText = "Serum iron, ferritin and TIBC ordered for anaemia work-up.",
|
|
NoteAuthorPractitionerId = "prac-005",
|
|
NoteTime = new DateTimeOffset(2025, 3, 5, 13, 0, 0, TimeSpan.Zero),
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new ServiceRequest
|
|
{
|
|
Id = "sreq-005",
|
|
IdentifierSystem = "http://clinicalinsightspro.in/service-request",
|
|
IdentifierValue = "SR-100005",
|
|
Status = "active",
|
|
Intent = "plan",
|
|
QuantityComparator = ">=",
|
|
QuantityValue = 12m,
|
|
QuantityUnit = "session",
|
|
PatientId = "pat-005",
|
|
OccurrenceDateTime = new DateTimeOffset(2025, 8, 8, 7, 30, 0, TimeSpan.Zero),
|
|
RequesterPractitionerId = "prac-005",
|
|
PatientInstruction = "Attend the dialysis unit twice weekly. Maintain fluid restriction.",
|
|
NoteText = "Maintenance haemodialysis schedule for CKD stage 3b.",
|
|
NoteAuthorPractitionerId = "prac-004",
|
|
NoteTime = new DateTimeOffset(2025, 8, 1, 12, 0, 0, TimeSpan.Zero),
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
}
|
|
};
|
|
|
|
context.ServiceRequests.AddRange(serviceRequests);
|
|
context.SaveChanges();
|
|
|
|
// ==============================================================
|
|
// 12. RISK ASSESSMENTS (FK -> Patient.Id, Practitioner.Id x2)
|
|
// ==============================================================
|
|
var riskAssessments = new List<RiskAssessment>
|
|
{
|
|
new RiskAssessment
|
|
{
|
|
Id = "risk-001",
|
|
Status = "final",
|
|
PatientId = "pat-001",
|
|
OccurrenceDateTime = new DateTimeOffset(2025, 6, 10, 15, 0, 0, TimeSpan.Zero),
|
|
PerformerPractitionerId = "prac-001",
|
|
NoteText = "High 10-year cardiovascular risk driven by uncontrolled HbA1c and central obesity.",
|
|
NoteAuthorPractitionerId = "prac-001",
|
|
NoteTime = new DateTimeOffset(2025, 6, 10, 15, 10, 0, TimeSpan.Zero),
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new RiskAssessment
|
|
{
|
|
Id = "risk-002",
|
|
Status = "final",
|
|
PatientId = "pat-002",
|
|
OccurrenceDateTime = new DateTimeOffset(2025, 7, 2, 12, 30, 0, TimeSpan.Zero),
|
|
PerformerPractitionerId = "prac-002",
|
|
NoteText = "Moderate risk. Stage 1 hypertension with no end-organ damage documented.",
|
|
NoteAuthorPractitionerId = "prac-002",
|
|
NoteTime = new DateTimeOffset(2025, 7, 2, 12, 40, 0, TimeSpan.Zero),
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new RiskAssessment
|
|
{
|
|
Id = "risk-003",
|
|
Status = "preliminary",
|
|
PatientId = "pat-003",
|
|
OccurrenceDateTime = new DateTimeOffset(2025, 4, 19, 2, 0, 0, TimeSpan.Zero),
|
|
PerformerPractitionerId = "prac-003",
|
|
NoteText = "Low risk of readmission. Inhaler technique reviewed before discharge.",
|
|
NoteAuthorPractitionerId = "prac-004",
|
|
NoteTime = new DateTimeOffset(2025, 4, 19, 2, 15, 0, TimeSpan.Zero),
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new RiskAssessment
|
|
{
|
|
Id = "risk-004",
|
|
Status = "amended",
|
|
PatientId = "pat-004",
|
|
OccurrenceDateTime = new DateTimeOffset(2025, 3, 8, 15, 0, 0, TimeSpan.Zero),
|
|
PerformerPractitionerId = "prac-005",
|
|
NoteText = "Risk downgraded after haemoglobin recovery on oral iron therapy.",
|
|
NoteAuthorPractitionerId = "prac-005",
|
|
NoteTime = new DateTimeOffset(2025, 3, 8, 15, 20, 0, TimeSpan.Zero),
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new RiskAssessment
|
|
{
|
|
Id = "risk-005",
|
|
Status = "final",
|
|
PatientId = "pat-005",
|
|
OccurrenceDateTime = new DateTimeOffset(2025, 8, 1, 12, 0, 0, TimeSpan.Zero),
|
|
PerformerPractitionerId = "prac-005",
|
|
NoteText = "High risk of CKD progression. Nephrology review scheduled every eight weeks.",
|
|
NoteAuthorPractitionerId = "prac-004",
|
|
NoteTime = new DateTimeOffset(2025, 8, 1, 12, 30, 0, TimeSpan.Zero),
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
}
|
|
};
|
|
|
|
context.RiskAssessments.AddRange(riskAssessments);
|
|
context.SaveChanges();
|
|
|
|
// ==============================================================
|
|
// 13. CARE PLANS (FK -> Patient.Id x2, Practitioner.Id)
|
|
// ==============================================================
|
|
var carePlans = new List<CarePlan>
|
|
{
|
|
new CarePlan
|
|
{
|
|
Id = "cp-001",
|
|
Status = "active",
|
|
Intent = "plan",
|
|
SubjectPatientId = "pat-001",
|
|
AuthorPatientId = "pat-001",
|
|
PeriodStart = new DateTimeOffset(2025, 6, 10, 0, 0, 0, TimeSpan.Zero),
|
|
PeriodEnd = new DateTimeOffset(2026, 6, 9, 0, 0, 0, TimeSpan.Zero),
|
|
ActivityStatus = "in-progress",
|
|
ActivityScheduledStart = new DateTimeOffset(2025, 6, 15, 0, 0, 0, TimeSpan.Zero),
|
|
ActivityScheduledEnd = new DateTimeOffset(2025, 12, 15, 0, 0, 0, TimeSpan.Zero),
|
|
ActivityPerformerPractitionerId = "prac-002",
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new CarePlan
|
|
{
|
|
Id = "cp-002",
|
|
Status = "active",
|
|
Intent = "plan",
|
|
SubjectPatientId = "pat-002",
|
|
AuthorPatientId = "pat-002",
|
|
PeriodStart = new DateTimeOffset(2025, 7, 2, 0, 0, 0, TimeSpan.Zero),
|
|
PeriodEnd = new DateTimeOffset(2026, 7, 1, 0, 0, 0, TimeSpan.Zero),
|
|
ActivityStatus = "scheduled",
|
|
ActivityScheduledStart = new DateTimeOffset(2025, 7, 15, 0, 0, 0, TimeSpan.Zero),
|
|
ActivityScheduledEnd = new DateTimeOffset(2025, 10, 15, 0, 0, 0, TimeSpan.Zero),
|
|
ActivityPerformerPractitionerId = "prac-002",
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new CarePlan
|
|
{
|
|
Id = "cp-003",
|
|
Status = "completed",
|
|
Intent = "order",
|
|
SubjectPatientId = "pat-003",
|
|
AuthorPatientId = null,
|
|
PeriodStart = new DateTimeOffset(2025, 4, 19, 0, 0, 0, TimeSpan.Zero),
|
|
PeriodEnd = new DateTimeOffset(2025, 6, 19, 0, 0, 0, TimeSpan.Zero),
|
|
ActivityStatus = "completed",
|
|
ActivityScheduledStart = new DateTimeOffset(2025, 4, 20, 0, 0, 0, TimeSpan.Zero),
|
|
ActivityScheduledEnd = new DateTimeOffset(2025, 6, 18, 0, 0, 0, TimeSpan.Zero),
|
|
ActivityPerformerPractitionerId = "prac-004",
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new CarePlan
|
|
{
|
|
Id = "cp-004",
|
|
Status = "on-hold",
|
|
Intent = "proposal",
|
|
SubjectPatientId = "pat-004",
|
|
AuthorPatientId = "pat-004",
|
|
PeriodStart = new DateTimeOffset(2025, 3, 8, 0, 0, 0, TimeSpan.Zero),
|
|
PeriodEnd = new DateTimeOffset(2025, 9, 8, 0, 0, 0, TimeSpan.Zero),
|
|
ActivityStatus = "on-hold",
|
|
ActivityScheduledStart = new DateTimeOffset(2025, 3, 10, 0, 0, 0, TimeSpan.Zero),
|
|
ActivityScheduledEnd = new DateTimeOffset(2025, 9, 7, 0, 0, 0, TimeSpan.Zero),
|
|
ActivityPerformerPractitionerId = "prac-005",
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
},
|
|
new CarePlan
|
|
{
|
|
Id = "cp-005",
|
|
Status = "active",
|
|
Intent = "order",
|
|
SubjectPatientId = "pat-005",
|
|
AuthorPatientId = null,
|
|
PeriodStart = new DateTimeOffset(2025, 8, 1, 0, 0, 0, TimeSpan.Zero),
|
|
PeriodEnd = new DateTimeOffset(2026, 7, 31, 0, 0, 0, TimeSpan.Zero),
|
|
ActivityStatus = "in-progress",
|
|
ActivityScheduledStart = new DateTimeOffset(2025, 8, 8, 0, 0, 0, TimeSpan.Zero),
|
|
ActivityScheduledEnd = new DateTimeOffset(2026, 2, 8, 0, 0, 0, TimeSpan.Zero),
|
|
ActivityPerformerPractitionerId = "prac-005",
|
|
CreatedBy = SeedUser,
|
|
CreatedDate = DateTime.UtcNow,
|
|
IsActive = true,
|
|
IsDelete = false,
|
|
VersionId = "1",
|
|
LastUpdated = DateTime.UtcNow
|
|
}
|
|
};
|
|
|
|
context.CarePlans.AddRange(carePlans);
|
|
context.SaveChanges();
|
|
|
|
// ==============================================================
|
|
// 14. CDS ALERTS (FK -> Patient.Id)
|
|
// Id is an int identity column, so it is NOT set here.
|
|
// ==============================================================
|
|
var cdsAlerts = new List<CdsAlert>
|
|
{
|
|
new CdsAlert
|
|
{
|
|
PatientId = "pat-001",
|
|
RuleId = "DM-STATIN-GUIDELINE",
|
|
Severity = "warning",
|
|
Summary = "Active Type 2 diabetes with no statin therapy on file.",
|
|
Recommendation = "Consider initiating statin therapy per ADA cardiovascular risk-reduction guidelines.",
|
|
GeneratedDate = DateTime.UtcNow,
|
|
Actioned = false
|
|
},
|
|
new CdsAlert
|
|
{
|
|
PatientId = "pat-002",
|
|
RuleId = "BP-ABOVE-TARGET",
|
|
Severity = "warning",
|
|
Summary = "Systolic blood pressure above 140 mmHg on the latest reading.",
|
|
Recommendation = "Review antihypertensive dosing and reinforce home BP monitoring.",
|
|
GeneratedDate = DateTime.UtcNow,
|
|
Actioned = false
|
|
},
|
|
new CdsAlert
|
|
{
|
|
PatientId = "pat-003",
|
|
RuleId = "ASTHMA-REVIEW-DUE",
|
|
Severity = "info",
|
|
Summary = "Emergency visit for asthma with no follow-up review recorded.",
|
|
Recommendation = "Schedule an asthma control review and check inhaler technique.",
|
|
GeneratedDate = DateTime.UtcNow,
|
|
Actioned = true
|
|
},
|
|
new CdsAlert
|
|
{
|
|
PatientId = "pat-004",
|
|
RuleId = "ANAEMIA-FOLLOWUP",
|
|
Severity = "info",
|
|
Summary = "Haemoglobin below reference range at the last inpatient encounter.",
|
|
Recommendation = "Repeat a full blood count after completing the oral iron course.",
|
|
GeneratedDate = DateTime.UtcNow,
|
|
Actioned = false
|
|
},
|
|
new CdsAlert
|
|
{
|
|
PatientId = "pat-005",
|
|
RuleId = "CKD-NEPHRO-REFERRAL",
|
|
Severity = "critical",
|
|
Summary = "eGFR below 45 with rising serum creatinine trend.",
|
|
Recommendation = "Escalate to nephrology and review all nephrotoxic medication.",
|
|
GeneratedDate = DateTime.UtcNow,
|
|
Actioned = false
|
|
}
|
|
};
|
|
|
|
context.CdsAlerts.AddRange(cdsAlerts);
|
|
context.SaveChanges();
|
|
}
|
|
|
|
// ------------------------------------------------------------------
|
|
// CDS RULES (no FK — seeded independently)
|
|
// ------------------------------------------------------------------
|
|
private static void SeedCdsRules(ApplicationDbContext context)
|
|
{
|
|
if (context.CdsRules.Any())
|
|
return;
|
|
|
|
var rules = new List<CdsRule>
|
|
{
|
|
new CdsRule
|
|
{
|
|
RuleId = "DM-STATIN-GUIDELINE",
|
|
RuleType = "ConditionMedicationGap",
|
|
Description = "Active Type 2 diabetes (E11.9) with no statin medication on file.",
|
|
ParametersJson = "{\"conditionCode\":\"E11.9\",\"medicationKeyword\":\"statin\"}",
|
|
Severity = "warning",
|
|
Recommendation = "Consider initiating statin therapy per ADA cardiovascular risk-reduction guidelines.",
|
|
Enabled = true,
|
|
CreatedDate = DateTime.UtcNow
|
|
},
|
|
new CdsRule
|
|
{
|
|
RuleId = "BP-ABOVE-TARGET",
|
|
RuleType = "ObservationThreshold",
|
|
Description = "Systolic blood pressure at or above 140 mmHg.",
|
|
ParametersJson = "{\"observationCode\":\"8480-6\",\"operator\":\">=\",\"threshold\":140}",
|
|
Severity = "warning",
|
|
Recommendation = "Review antihypertensive therapy and confirm with home blood pressure readings.",
|
|
Enabled = true,
|
|
CreatedDate = DateTime.UtcNow
|
|
},
|
|
new CdsRule
|
|
{
|
|
RuleId = "HBA1C-ABOVE-TARGET",
|
|
RuleType = "ObservationThreshold",
|
|
Description = "HbA1c at or above 7.0 percent in a diabetic patient.",
|
|
ParametersJson = "{\"observationCode\":\"4548-4\",\"operator\":\">=\",\"threshold\":7.0}",
|
|
Severity = "warning",
|
|
Recommendation = "Intensify glycaemic control and arrange diabetes education counselling.",
|
|
Enabled = true,
|
|
CreatedDate = DateTime.UtcNow
|
|
},
|
|
new CdsRule
|
|
{
|
|
RuleId = "CKD-NEPHRO-REFERRAL",
|
|
RuleType = "ObservationThreshold",
|
|
Description = "Serum creatinine above 2.0 mg/dL suggesting declining renal function.",
|
|
ParametersJson = "{\"observationCode\":\"2160-0\",\"operator\":\">\",\"threshold\":2.0}",
|
|
Severity = "critical",
|
|
Recommendation = "Refer to nephrology and review all nephrotoxic medication.",
|
|
Enabled = true,
|
|
CreatedDate = DateTime.UtcNow
|
|
},
|
|
new CdsRule
|
|
{
|
|
RuleId = "LATEX-ALLERGY-CONFLICT",
|
|
RuleType = "AllergyDrugConflict",
|
|
Description = "Documented latex allergy with a procedure or product containing latex.",
|
|
ParametersJson = "{\"substance\":\"Latex\",\"keywords\":[\"latex\"]}",
|
|
Severity = "critical",
|
|
Recommendation = "Use a latex-free pathway and flag the allergy on the theatre checklist.",
|
|
Enabled = false,
|
|
CreatedDate = DateTime.UtcNow
|
|
}
|
|
};
|
|
|
|
context.CdsRules.AddRange(rules);
|
|
context.SaveChanges();
|
|
}
|
|
|
|
// ------------------------------------------------------------------
|
|
// USERS (login accounts — passwords are hashed, never stored raw)
|
|
// Demo password for every seeded account: Test@1234
|
|
// ------------------------------------------------------------------
|
|
private static void SeedUsers(ApplicationDbContext context)
|
|
{
|
|
if (context.Users.Any())
|
|
return;
|
|
|
|
var hasher = new PasswordHasher<User>();
|
|
|
|
var users = new List<User>
|
|
{
|
|
new User
|
|
{
|
|
FirstName = "Rajesh",
|
|
LastName = "Kulkarni",
|
|
Username = "rajesh.kulkarni",
|
|
MobileNumber = "+919822011001",
|
|
Email = "rajesh.kulkarni@sanjeevani.in",
|
|
Gender = "male",
|
|
IsActive = true,
|
|
CreatedDate = DateTime.UtcNow
|
|
},
|
|
new User
|
|
{
|
|
FirstName = "Meera",
|
|
LastName = "Joshi",
|
|
Username = "meera.joshi",
|
|
MobileNumber = "+919822011002",
|
|
Email = "meera.joshi@aarogyacare.in",
|
|
Gender = "female",
|
|
IsActive = true,
|
|
CreatedDate = DateTime.UtcNow
|
|
},
|
|
new User
|
|
{
|
|
FirstName = "Suresh",
|
|
LastName = "Reddy",
|
|
Username = "suresh.reddy",
|
|
MobileNumber = "+919840011003",
|
|
Email = "suresh.reddy@sribalaji.in",
|
|
Gender = "male",
|
|
IsActive = true,
|
|
CreatedDate = DateTime.UtcNow
|
|
},
|
|
new User
|
|
{
|
|
FirstName = "Kavita",
|
|
LastName = "Menon",
|
|
Username = "kavita.menon",
|
|
MobileNumber = "+919847011004",
|
|
Email = "kavita.menon@malabarhealth.in",
|
|
Gender = "female",
|
|
IsActive = true,
|
|
CreatedDate = DateTime.UtcNow
|
|
},
|
|
new User
|
|
{
|
|
FirstName = "Arjun",
|
|
LastName = "Bhatt",
|
|
Username = "arjun.bhatt",
|
|
MobileNumber = "+919811011005",
|
|
Email = "arjun.bhatt@gangahealth.in",
|
|
Gender = "male",
|
|
IsActive = true,
|
|
CreatedDate = DateTime.UtcNow
|
|
}
|
|
};
|
|
|
|
foreach (var user in users)
|
|
{
|
|
user.PasswordHash = hasher.HashPassword(user, "Test@1234");
|
|
}
|
|
|
|
context.Users.AddRange(users);
|
|
context.SaveChanges();
|
|
}
|
|
}
|