UNPKG

emr-types

Version:

Comprehensive TypeScript Types Library for Electronic Medical Record (EMR) Applications - Domain-Driven Design with Zod Validation

548 lines 14.1 kB
/** * Tenant Domain Entities * * Multi-tenant support types for EMR system */ import { BaseEntity, BaseAuditEntity, BaseStatusEntity } from '../../shared/entities/BaseEntity'; import { Id } from '../../shared/value-objects/Id'; import { Email } from '../../shared/value-objects/Email'; import { PhoneNumber } from '../../shared/value-objects/PhoneNumber'; import { Address } from '../../shared/value-objects/Address'; import { Money } from '../../shared/value-objects/Money'; import { DomainEvent } from '../../shared/events/DomainEvent'; /** * Tenant Entity * * Core tenant entity for multi-tenant support */ export interface Tenant extends BaseEntity, BaseAuditEntity, BaseStatusEntity { /** Tenant name */ name: string; /** Tenant display name */ displayName: string; /** Tenant domain/subdomain */ domain: string; /** Tenant description */ description?: string; /** Tenant logo URL */ logoUrl?: string; /** Tenant contact information */ contact: TenantContact; /** Tenant address */ address: Address; /** Tenant configuration */ config: TenantConfig; /** Tenant subscription */ subscription: TenantSubscription; /** Tenant features */ features: TenantFeatures; /** Tenant limits */ limits: TenantLimits; /** Tenant settings */ settings: TenantSettings; /** Tenant metadata */ metadata?: Record<string, any>; } /** * Tenant Contact Entity * * Tenant contact information */ export interface TenantContact extends BaseEntity, BaseAuditEntity { /** Primary contact email */ primaryEmail: Email; /** Secondary contact email */ secondaryEmail?: Email; /** Primary contact phone */ primaryPhone: PhoneNumber; /** Secondary contact phone */ secondaryPhone?: PhoneNumber; /** Contact person name */ contactPerson: string; /** Contact person title */ contactTitle?: string; /** Emergency contact */ emergencyContact?: TenantEmergencyContact; } /** * Tenant Emergency Contact Entity * * Tenant emergency contact information */ export interface TenantEmergencyContact extends BaseEntity, BaseAuditEntity { /** Contact name */ name: string; /** Contact phone */ phone: PhoneNumber; /** Contact email */ email?: Email; /** Contact relationship */ relationship: string; /** Whether this is primary emergency contact */ isPrimary: boolean; } /** * Tenant Configuration Entity * * Tenant-specific configuration */ export interface TenantConfig extends BaseEntity, BaseAuditEntity { /** Associated tenant ID */ tenantId: Id; /** System configuration */ system: TenantSystemConfig; /** Security configuration */ security: TenantSecurityConfig; /** Integration configuration */ integrations: TenantIntegrationConfig; /** Customization configuration */ customization: TenantCustomizationConfig; /** Compliance configuration */ compliance: TenantComplianceConfig; } /** * Tenant System Configuration * * System-level tenant configuration */ export interface TenantSystemConfig { /** Default language */ defaultLanguage: string; /** Supported languages */ supportedLanguages: string[]; /** Default timezone */ defaultTimezone: string; /** Date format */ dateFormat: string; /** Time format */ timeFormat: '12h' | '24h'; /** Currency */ currency: string; /** Number format */ numberFormat: string; /** Auto-logout timeout (minutes) */ autoLogoutTimeout: number; /** Session timeout (minutes) */ sessionTimeout: number; /** Maximum file upload size (MB) */ maxFileUploadSize: number; /** Allowed file types */ allowedFileTypes: string[]; } /** * Tenant Security Configuration * * Security-related tenant configuration */ export interface TenantSecurityConfig { /** Password policy */ passwordPolicy: { minLength: number; requireUppercase: boolean; requireLowercase: boolean; requireNumbers: boolean; requireSpecialChars: boolean; maxAge: number; }; /** Multi-factor authentication */ mfa: { enabled: boolean; required: boolean; methods: ('sms' | 'email' | 'totp' | 'authenticator')[]; }; /** IP whitelist */ ipWhitelist: string[]; /** Session management */ sessionManagement: { maxConcurrentSessions: number; allowMultipleDevices: boolean; requireReauthentication: boolean; }; /** Data encryption */ encryption: { enabled: boolean; algorithm: string; keyRotationDays: number; }; } /** * Tenant Integration Configuration * * External service integration configuration */ export interface TenantIntegrationConfig { /** Email service */ emailService: { provider: 'smtp' | 'sendgrid' | 'mailgun' | 'aws_ses'; config: Record<string, any>; enabled: boolean; }; /** SMS service */ smsService: { provider: 'twilio' | 'aws_sns' | 'nexmo'; config: Record<string, any>; enabled: boolean; }; /** Payment gateway */ paymentGateway: { provider: 'stripe' | 'paypal' | 'square'; config: Record<string, any>; enabled: boolean; }; /** File storage */ fileStorage: { provider: 'aws_s3' | 'google_cloud' | 'azure_blob'; config: Record<string, any>; enabled: boolean; }; /** Analytics */ analytics: { provider: 'google_analytics' | 'mixpanel' | 'amplitude'; config: Record<string, any>; enabled: boolean; }; } /** * Tenant Customization Configuration * * UI/UX customization configuration */ export interface TenantCustomizationConfig { /** Branding */ branding: { primaryColor: string; secondaryColor: string; accentColor: string; logoUrl: string; faviconUrl: string; }; /** Theme */ theme: { mode: 'light' | 'dark' | 'auto'; customCSS?: string; customJS?: string; }; /** Layout */ layout: { sidebarPosition: 'left' | 'right'; headerStyle: 'default' | 'minimal' | 'custom'; footerEnabled: boolean; }; /** Localization */ localization: { dateFormat: string; timeFormat: string; numberFormat: string; currencySymbol: string; currencyPosition: 'before' | 'after'; }; } /** * Tenant Compliance Configuration * * Compliance and regulatory configuration */ export interface TenantComplianceConfig { /** HIPAA compliance */ hipaa: { enabled: boolean; auditLogging: boolean; dataRetention: number; encryptionRequired: boolean; }; /** GDPR compliance */ gdpr: { enabled: boolean; dataProcessingConsent: boolean; rightToBeForgotten: boolean; dataPortability: boolean; }; /** SOX compliance */ sox: { enabled: boolean; auditTrail: boolean; accessControls: boolean; }; /** ISO 27001 */ iso27001: { enabled: boolean; securityControls: boolean; riskAssessment: boolean; }; } /** * Tenant Subscription Entity * * Tenant subscription and billing information */ export interface TenantSubscription extends BaseEntity, BaseAuditEntity { /** Associated tenant ID */ tenantId: Id; /** Subscription plan */ plan: TenantPlan; /** Subscription status */ status: 'active' | 'inactive' | 'suspended' | 'cancelled' | 'expired'; /** Subscription start date */ startDate: Date; /** Subscription end date */ endDate?: Date; /** Billing cycle */ billingCycle: 'monthly' | 'quarterly' | 'yearly'; /** Billing amount */ billingAmount: Money; /** Payment method */ paymentMethod: TenantPaymentMethod; /** Auto-renewal */ autoRenewal: boolean; /** Trial information */ trial?: TenantTrial; /** Discount information */ discount?: TenantDiscount; } /** * Tenant Plan Entity * * Available subscription plans */ export interface TenantPlan extends BaseEntity, BaseAuditEntity { /** Plan name */ name: string; /** Plan description */ description: string; /** Plan features */ features: string[]; /** Plan limits */ limits: { users: number; patients: number; storage: number; apiCalls: number; customizations: number; }; /** Plan pricing */ pricing: { monthly: Money; quarterly: Money; yearly: Money; }; /** Plan category */ category: 'basic' | 'professional' | 'enterprise' | 'custom'; /** Whether plan is active */ isActive: boolean; /** Plan metadata */ metadata?: Record<string, any>; } /** * Tenant Payment Method Entity * * Tenant payment method information */ export interface TenantPaymentMethod extends BaseEntity, BaseAuditEntity { /** Associated tenant ID */ tenantId: Id; /** Payment method type */ type: 'credit_card' | 'bank_transfer' | 'paypal' | 'stripe'; /** Payment method details */ details: Record<string, any>; /** Whether this is default payment method */ isDefault: boolean; /** Payment method status */ status: 'active' | 'inactive' | 'expired'; /** Expiry date */ expiryDate?: Date; } /** * Tenant Trial Entity * * Trial period information */ export interface TenantTrial extends BaseEntity, BaseAuditEntity { /** Associated tenant ID */ tenantId: Id; /** Trial start date */ startDate: Date; /** Trial end date */ endDate: Date; /** Trial duration (days) */ duration: number; /** Whether trial is active */ isActive: boolean; /** Trial features */ features: string[]; /** Trial limits */ limits: Record<string, number>; } /** * Tenant Discount Entity * * Discount information */ export interface TenantDiscount extends BaseEntity, BaseAuditEntity { /** Associated tenant ID */ tenantId: Id; /** Discount type */ type: 'percentage' | 'fixed_amount' | 'free_months'; /** Discount value */ value: number; /** Discount description */ description: string; /** Discount start date */ startDate: Date; /** Discount end date */ endDate?: Date; /** Whether discount is active */ isActive: boolean; } /** * Tenant Features Entity * * Tenant feature flags and capabilities */ export interface TenantFeatures extends BaseEntity, BaseAuditEntity { /** Associated tenant ID */ tenantId: Id; /** Core features */ core: { patientManagement: boolean; appointmentScheduling: boolean; medicalRecords: boolean; billing: boolean; reporting: boolean; }; /** Advanced features */ advanced: { telemedicine: boolean; labIntegration: boolean; pharmacyIntegration: boolean; insuranceIntegration: boolean; analytics: boolean; apiAccess: boolean; }; /** Custom features */ custom: Record<string, boolean>; /** Feature limits */ limits: Record<string, number>; } /** * Tenant Limits Entity * * Tenant usage limits and quotas */ export interface TenantLimits extends BaseEntity, BaseAuditEntity { /** Associated tenant ID */ tenantId: Id; /** User limits */ users: { total: number; active: number; inactive: number; limit: number; }; /** Patient limits */ patients: { total: number; active: number; inactive: number; limit: number; }; /** Storage limits */ storage: { used: number; limit: number; files: number; fileLimit: number; }; /** API limits */ api: { calls: number; limit: number; resetDate: Date; }; /** Custom limits */ custom: Record<string, { used: number; limit: number; }>; } /** * Tenant Settings Entity * * Tenant-specific settings */ export interface TenantSettings extends BaseEntity, BaseAuditEntity { /** Associated tenant ID */ tenantId: Id; /** General settings */ general: { timezone: string; dateFormat: string; timeFormat: string; language: string; currency: string; }; /** Notification settings */ notifications: { email: boolean; sms: boolean; push: boolean; inApp: boolean; }; /** Privacy settings */ privacy: { dataSharing: boolean; analytics: boolean; marketing: boolean; }; /** Security settings */ security: { mfaRequired: boolean; sessionTimeout: number; passwordPolicy: Record<string, any>; }; /** Custom settings */ custom: Record<string, any>; } /** * Tenant Domain Events */ export declare namespace TenantEvents { interface TenantCreatedEvent extends DomainEvent { eventType: 'tenant.created'; data: { tenantId: Id; name: string; domain: string; }; } interface TenantUpdatedEvent extends DomainEvent { eventType: 'tenant.updated'; data: { tenantId: Id; updatedFields: string[]; }; } interface TenantSubscriptionChangedEvent extends DomainEvent { eventType: 'tenant.subscription_changed'; data: { tenantId: Id; oldPlan: string; newPlan: string; }; } interface TenantSuspendedEvent extends DomainEvent { eventType: 'tenant.suspended'; data: { tenantId: Id; reason: string; suspendedBy: Id; }; } interface TenantActivatedEvent extends DomainEvent { eventType: 'tenant.activated'; data: { tenantId: Id; activatedBy: Id; }; } } //# sourceMappingURL=Tenant.d.ts.map