emr-types
Version:
Comprehensive TypeScript Types Library for Electronic Medical Record (EMR) Applications - Domain-Driven Design with Zod Validation
508 lines • 13.9 kB
TypeScript
/**
* User Domain Entities
*
* User management types for authentication, authorization, and user profiles
*/
import { BaseTenantEntity, BaseAuditEntity, BaseStatusEntity, Priority } from '../../shared/entities/BaseEntity';
import { Id } from '../../shared/value-objects/Id';
import { Timestamp } from '../../shared/value-objects/Timestamp';
import { Email } from '../../shared/value-objects/Email';
import { PhoneNumber } from '../../shared/value-objects/PhoneNumber';
import { Address } from '../../shared/value-objects/Address';
import { DomainEvent } from '../../shared/events/DomainEvent';
/**
* User Entity
*
* Core user entity for authentication and user management
*/
export interface User extends BaseTenantEntity, BaseAuditEntity, BaseStatusEntity {
/** User's email address */
email: Email;
/** Username for login */
username: string;
/** Hashed password */
passwordHash: string;
/** User's first name */
firstName: string;
/** User's last name */
lastName: string;
/** User's display name */
displayName?: string;
/** User's avatar URL */
avatarUrl?: string;
/** User's phone number */
phoneNumber?: PhoneNumber;
/** User's date of birth */
dateOfBirth?: Date;
/** User's gender */
gender?: 'male' | 'female' | 'other' | 'prefer_not_to_say';
/** User's address */
address?: Address;
/** User's preferred language */
preferredLanguage?: string;
/** User's timezone */
timezone?: string;
/** Whether user account is verified */
isVerified: boolean;
/** Whether user account is locked */
isLocked: boolean;
/** Number of failed login attempts */
failedLoginAttempts: number;
/** Last login timestamp */
lastLoginAt?: Timestamp;
/** User's roles */
roles: UserRole[];
/** User's permissions */
permissions: UserPermission[];
/** User's preferences */
preferences: UserPreferences;
}
/**
* User Profile Entity
*
* Extended user profile information
*/
export interface UserProfile extends BaseTenantEntity, BaseAuditEntity {
/** Associated user ID */
userId: Id;
/** User's professional title */
title?: string;
/** User's department */
department?: string;
/** User's employee ID */
employeeId?: string;
/** User's bio/description */
bio?: string;
/** User's skills/expertise */
skills?: string[];
/** User's certifications */
certifications?: UserCertification[];
/** User's work experience */
workExperience?: UserWorkExperience[];
/** User's education */
education?: UserEducation[];
/** User's social media links */
socialMedia?: UserSocialMedia;
/** User's emergency contact */
emergencyContact?: UserEmergencyContact;
}
/**
* User Role Entity
*
* User role for authorization
*/
export interface UserRole extends BaseTenantEntity, BaseAuditEntity {
/** Role name */
name: string;
/** Role description */
description?: string;
/** Role permissions */
permissions: UserPermission[];
/** Whether role is active */
isActive: boolean;
/** Role priority level */
priority: Priority;
/** Role category */
category: 'system' | 'custom' | 'department' | 'project';
/** Role metadata */
metadata?: Record<string, any>;
}
/**
* User Permission Entity
*
* User permission for fine-grained access control
*/
export interface UserPermission extends BaseTenantEntity, BaseAuditEntity {
/** Permission name */
name: string;
/** Permission description */
description?: string;
/** Permission resource */
resource: string;
/** Permission action */
action: 'create' | 'read' | 'update' | 'delete' | 'execute';
/** Permission scope */
scope: 'global' | 'tenant' | 'department' | 'project' | 'personal';
/** Whether permission is active */
isActive: boolean;
/** Permission conditions */
conditions?: PermissionCondition[];
/** Permission metadata */
metadata?: Record<string, any>;
}
/**
* User Session Entity
*
* User session for authentication tracking
*/
export interface UserSession extends BaseTenantEntity, BaseAuditEntity {
/** Associated user ID */
userId: Id;
/** Session token */
sessionToken: string;
/** Session refresh token */
refreshToken?: string;
/** Session IP address */
ipAddress?: string;
/** Session user agent */
userAgent?: string;
/** Session device information */
deviceInfo?: UserDeviceInfo;
/** Session location */
location?: UserLocation;
/** Session start time */
startedAt: Timestamp;
/** Session expiry time */
expiresAt: Timestamp;
/** Session last activity */
lastActivityAt: Timestamp;
/** Whether session is active */
isActive: boolean;
/** Session logout reason */
logoutReason?: 'user_logout' | 'session_expired' | 'security_violation' | 'admin_logout';
}
/**
* User Preferences Entity
*
* User preferences and settings
*/
export interface UserPreferences extends BaseTenantEntity, BaseAuditEntity {
/** Associated user ID */
userId: Id;
/** UI theme preference */
theme: 'light' | 'dark' | 'auto';
/** Language preference */
language: string;
/** Timezone preference */
timezone: string;
/** Date format preference */
dateFormat: string;
/** Time format preference */
timeFormat: '12h' | '24h';
/** Notification preferences */
notifications: NotificationPreferences;
/** Privacy preferences */
privacy: PrivacyPreferences;
/** Accessibility preferences */
accessibility: AccessibilityPreferences;
/** Dashboard preferences */
dashboard: DashboardPreferences;
}
/**
* User Certification Entity
*
* User professional certifications
*/
export interface UserCertification extends BaseTenantEntity, BaseAuditEntity {
/** Certification name */
name: string;
/** Certification issuing organization */
issuingOrganization: string;
/** Certification issue date */
issueDate: Date;
/** Certification expiry date */
expiryDate?: Date;
/** Certification credential ID */
credentialId?: string;
/** Certification URL */
credentialUrl?: string;
/** Whether certification is verified */
isVerified: boolean;
}
/**
* User Work Experience Entity
*
* User work experience history
*/
export interface UserWorkExperience extends BaseTenantEntity, BaseAuditEntity {
/** Company name */
company: string;
/** Job title */
title: string;
/** Start date */
startDate: Date;
/** End date */
endDate?: Date;
/** Whether currently working here */
isCurrent: boolean;
/** Job description */
description?: string;
/** Achievements */
achievements?: string[];
}
/**
* User Education Entity
*
* User education history
*/
export interface UserEducation extends BaseTenantEntity, BaseAuditEntity {
/** Institution name */
institution: string;
/** Degree/qualification */
degree: string;
/** Field of study */
fieldOfStudy: string;
/** Start date */
startDate: Date;
/** End date */
endDate?: Date;
/** Whether currently studying */
isCurrent: boolean;
/** Grade/GPA */
grade?: string;
}
/**
* User Social Media Entity
*
* User social media links
*/
export interface UserSocialMedia extends BaseTenantEntity, BaseAuditEntity {
/** LinkedIn profile URL */
linkedin?: string;
/** Twitter/X profile URL */
twitter?: string;
/** GitHub profile URL */
github?: string;
/** Personal website URL */
website?: string;
/** Other social media links */
other?: Record<string, string>;
}
/**
* User Emergency Contact Entity
*
* User emergency contact information
*/
export interface UserEmergencyContact extends BaseTenantEntity, BaseAuditEntity {
/** Contact name */
name: string;
/** Contact relationship */
relationship: string;
/** Contact phone number */
phoneNumber: PhoneNumber;
/** Contact email */
email?: Email;
/** Contact address */
address?: Address;
/** Whether this is primary emergency contact */
isPrimary: boolean;
}
/**
* User Device Information
*
* Information about user's device
*/
export interface UserDeviceInfo {
/** Device type */
deviceType: 'desktop' | 'mobile' | 'tablet' | 'other';
/** Operating system */
operatingSystem: string;
/** Browser name */
browser: string;
/** Browser version */
browserVersion: string;
/** Device manufacturer */
manufacturer?: string;
/** Device model */
model?: string;
/** Screen resolution */
screenResolution?: string;
}
/**
* User Location Information
*
* Information about user's location
*/
export interface UserLocation {
/** Country */
country?: string;
/** Region/State */
region?: string;
/** City */
city?: string;
/** Latitude */
latitude?: number;
/** Longitude */
longitude?: number;
/** Timezone */
timezone?: string;
}
/**
* Notification Preferences
*
* User notification settings
*/
export interface NotificationPreferences {
/** Email notifications */
email: {
enabled: boolean;
frequency: 'immediate' | 'daily' | 'weekly' | 'never';
types: string[];
};
/** SMS notifications */
sms: {
enabled: boolean;
frequency: 'immediate' | 'daily' | 'weekly' | 'never';
types: string[];
};
/** Push notifications */
push: {
enabled: boolean;
frequency: 'immediate' | 'daily' | 'weekly' | 'never';
types: string[];
};
/** In-app notifications */
inApp: {
enabled: boolean;
frequency: 'immediate' | 'daily' | 'weekly' | 'never';
types: string[];
};
}
/**
* Privacy Preferences
*
* User privacy settings
*/
export interface PrivacyPreferences {
/** Profile visibility */
profileVisibility: 'public' | 'private' | 'friends' | 'custom';
/** Contact information visibility */
contactVisibility: 'public' | 'private' | 'friends' | 'custom';
/** Activity visibility */
activityVisibility: 'public' | 'private' | 'friends' | 'custom';
/** Search engine indexing */
allowSearchIndexing: boolean;
/** Data sharing preferences */
dataSharing: {
analytics: boolean;
marketing: boolean;
thirdParty: boolean;
};
}
/**
* Accessibility Preferences
*
* User accessibility settings
*/
export interface AccessibilityPreferences {
/** High contrast mode */
highContrast: boolean;
/** Large text mode */
largeText: boolean;
/** Screen reader support */
screenReader: boolean;
/** Keyboard navigation */
keyboardNavigation: boolean;
/** Reduced motion */
reducedMotion: boolean;
/** Color blind support */
colorBlindSupport: boolean;
}
/**
* Dashboard Preferences
*
* User dashboard customization
*/
export interface DashboardPreferences {
/** Default dashboard layout */
defaultLayout: 'grid' | 'list' | 'compact' | 'detailed';
/** Visible widgets */
visibleWidgets: string[];
/** Widget positions */
widgetPositions: Record<string, {
x: number;
y: number;
width: number;
height: number;
}>;
/** Auto-refresh interval */
autoRefreshInterval: number;
/** Show welcome message */
showWelcomeMessage: boolean;
}
/**
* Permission Condition
*
* Condition for permission evaluation
*/
export interface PermissionCondition {
/** Condition type */
type: 'time_based' | 'location_based' | 'device_based' | 'custom';
/** Condition operator */
operator: 'equals' | 'not_equals' | 'contains' | 'not_contains' | 'greater_than' | 'less_than';
/** Condition field */
field: string;
/** Condition value */
value: any;
/** Condition metadata */
metadata?: Record<string, any>;
}
/**
* User Domain Events
*/
export declare namespace UserEvents {
interface UserRegisteredEvent extends DomainEvent {
eventType: 'user.registered';
data: {
userId: Id;
email: Email;
tenantId: Id;
};
}
interface UserLoggedInEvent extends DomainEvent {
eventType: 'user.logged_in';
data: {
userId: Id;
sessionId: Id;
ipAddress?: string;
userAgent?: string;
};
}
interface UserLoggedOutEvent extends DomainEvent {
eventType: 'user.logged_out';
data: {
userId: Id;
sessionId: Id;
reason: 'user_logout' | 'session_expired' | 'security_violation' | 'admin_logout';
};
}
interface UserProfileUpdatedEvent extends DomainEvent {
eventType: 'user.profile_updated';
data: {
userId: Id;
updatedFields: string[];
};
}
interface UserRoleAssignedEvent extends DomainEvent {
eventType: 'user.role_assigned';
data: {
userId: Id;
roleId: Id;
assignedBy: Id;
};
}
interface UserRoleRemovedEvent extends DomainEvent {
eventType: 'user.role_removed';
data: {
userId: Id;
roleId: Id;
removedBy: Id;
};
}
interface UserAccountLockedEvent extends DomainEvent {
eventType: 'user.account_locked';
data: {
userId: Id;
reason: string;
lockedBy?: Id;
};
}
interface UserAccountUnlockedEvent extends DomainEvent {
eventType: 'user.account_unlocked';
data: {
userId: Id;
unlockedBy: Id;
};
}
}
//# sourceMappingURL=User.d.ts.map