1. Architecture Overview

Architecture Type: Three-tier (Controller → Service → Repository)
Multi-Tenant Isolation: providerServiceMapID scoping ensures data separation between providers and states
Session Management: Redis with JWT authentication
Soft Deletion Pattern: deleted flags used across entities for safe deletion
Current System ER Diagram: 





2. Core Entity Relationships

2.1 User Management Structure

Primary User Entity: M_User1

AttributeDescription
Basic profilefirstName, lastName, username, etc.
DesignationSingle designation per user
Demographics & LanguagesLinked via one-to-one relationships
Supervisor/Admin flagsSupports role-specific behavior

User-Service-Role Mapping: M_UserServiceRoleMapping2

FeatureDescription
Multi-role supportAssign multiple roles to a single user
Facility assignmentUses workingLocationID
Multi-village coverageStored as comma-separated villageidDb
Multi-tenant scopeScoped by providerServiceMapID

2.2 Multi-Tenant Provider Structure

Provider Service Mapping: M_ProviderServiceMapping

Geographic Hierarchy

State → District → Block → Village


3. User Creation and Management Flow

Creation Hierarchy:

  1. Provider Creation – Setup healthcare organization

  2. Provider-Service-State Mapping – Define operational scope

  3. User Creation – Basic profile in M_User1

  4. Role Assignment – Map users to services and facilities

Step-by-Step Process:

StepDescription
Step 1: Basic ProfilePersonal details, credentials, designation. Endpoint: /m/AddEmployee
Step 2: Demographics & AddressFamily info, present/permanent addresses, geographic mapping
Step 3: Language CapabilitiesMultiple languages with read/write/speak proficiency
Step 4: Role & Service AssignmentsMulti-role assignments, facility via workingLocationID, village coverage

4. Facility Management

4.1 Facility Structure

Entity: M_Facility

FeatureDescription
HierarchyTwo levels: Main Store / Sub Store
TypeInventory-focused via M_facilitytype
LocationBasic address info

4.2 Main/Sub Store Logic

Facility TypePurposeParent FacilityMapping
Main StoreCentral inventory hub, MMU parkingNone (mainFacilityID = null)Parking place assignment
Sub StoreDistribution point, MMU unitPoints to Main StoreVan assignment

UI Implications:

4.3 Healthcare Facility Hierarchy Integration

Current LogicHealthcare Logic
Main Store / Sub StoreDH → CHC → PHC → SC
Inventory focusHealthcare service focus
MMU operationsClinical service delivery

5. Geographic & Village Management


6. Role and Permission System


7. Services and UI Components NOT Affected

7.1 MMU/Van Services:

7.2 Inventory Management:

7.3 User Management:

7.4 Facility Types:

7.5 File Upload Systems:

Note: Healthcare fields are additive and nullable; zero disruption to current system.


8. User & Entity Mapping Architecture

Central Junction Table: M_UserServiceRoleMapping2

ColumnPurpose
userIDLinks to M_User1 profile
providerServiceMapIDProvider-Service-State mapping
workingLocationIDFacility assignment
roleIDUser role
blockIDGeographic block
villageidDbComma-separated villages

Connection Examples:

Data Flow Summary:


9. Multi-Role Assignment Architecture

Role TypeContext
Clinical (Doctor/Nurse)Facilities via workingLocationID, multiple roles, screen access via RoleScreenMapping
Field (ASHA/ANM)Subcenters, multi-village coverage (villageidDb)
Administrative (Supervisor)Multiple service lines, optional CTI integration

Key Features:

Note: Junction table pattern enables complex multi-role assignments; audit trails and soft deletion supported


10. Summary

The PSMRI/Admin-API provides: