{
    "meta": {
        "project": "Blazma",
        "domain": "Laboratory Information Management System (LIMS)",
        "framework": "Laravel 12 / PHP 8.2",
        "database": "MySQL",
        "generated_at": "2026-03-11",
        "version": "1.0",
        "tables_count": 320,
        "models_count": 431,
        "controllers_count": 40,
        "services_count": 107,
        "jobs_count": 49,
        "routes_count": 1911
    },
    "modules": {
        "authentication": {
            "description": "Patient and staff authentication, OTP verification, token management",
            "controllers": [
                "WebController (auth methods)",
                "UserController"
            ],
            "services": [
                "EndUserService"
            ],
            "models": [
                "ENDUSER",
                "SYSTEMUSER",
                "BMADMINS"
            ],
            "tables": [
                "END_USER",
                "SYSTEM_USER",
                "BM_ADMINS",
                "MOBILE_NO_VERIFICATION",
                "END_USER_EMAIL_VERIFICATION",
                "DEVICE_TOKENS",
                "SYSTEM_USER_DEVICE_TOKEN"
            ]
        },
        "test_catalog": {
            "description": "Lab test and package catalog, pricing, reference ranges",
            "controllers": [
                "MetadataController"
            ],
            "services": [
                "LabService",
                "SymbolsService"
            ],
            "models": [
                "LABCATEGORYPACKAGE",
                "LABCATEGORY",
                "PROFILELABCATEGORYPACKAGE"
            ],
            "tables": [
                "LAB_CATEGORY_PACKAGE",
                "LAB_CATEGORY",
                "LAB_CATEGORY_PACKAGE_RESULT",
                "PROFILE_LAB_CATEGORY_PACKAGE",
                "PROFILE_PRICE_LIST",
                "PROFILE_REFERENCE_RANGE",
                "SPECIMEN_TYPE",
                "LAB_PACKAGE_ITEM"
            ]
        },
        "order_management": {
            "description": "Patient ordering: cart, confirmation, booking",
            "controllers": [
                "WebController"
            ],
            "services": [
                "EndUserService",
                "LabService"
            ],
            "models": [
                "ENDUSERLABCART",
                "ENDUSERLABORDER",
                "ENDUSERLABORDERPACKAGE"
            ],
            "tables": [
                "END_USER_LAB_CART",
                "END_USER_LAB_ORDER",
                "END_USER_LAB_ORDER_PACKAGE",
                "END_USER_LAB_ORDER_HISTORY"
            ]
        },
        "sample_lab_operations": {
            "description": "Sample collection, processing, analysis, result entry",
            "controllers": [
                "LabController",
                "LdmController"
            ],
            "services": [
                "LabService"
            ],
            "models": [
                "ENDUSERLABORDERPACKAGE",
                "BATCH",
                "PICKUP",
                "SAMPLEGENERATION"
            ],
            "tables": [
                "END_USER_LAB_ORDER_PACKAGE",
                "BATCH",
                "PICKUP",
                "SAMPLE_GENERATION",
                "SAMPLE_GENERATION_ANALYZER",
                "SAMPLE_GENERATION_TEST"
            ]
        },
        "results_reporting": {
            "description": "PDF report generation and result delivery",
            "controllers": [
                "LabController"
            ],
            "services": [
                "NormalReportService",
                "NormalReportServiceV2",
                "SmartReportService",
                "TemplateReportService",
                "TemplateReportV2Service",
                "IntegratedReportService",
                "AiRecommendationReportService"
            ],
            "models": [
                "ENDUSERLABORDERPACKAGERESULT",
                "ENDUSERLABORDERPACKAGETEMPLATE"
            ],
            "tables": [
                "END_USER_LAB_ORDER_PACKAGE_RESULT",
                "END_USER_LAB_ORDER_PACKAGE_TEMPLATE",
                "TEMPLATE",
                "TEMPLATE_COMPONENTS",
                "PROFILE_PROGRAMMABLE_COMMENT"
            ],
            "jobs": [
                "SmartReportReady",
                "TemplateReportReady"
            ]
        },
        "payment_processing": {
            "description": "Multi-gateway payment handling: COD, Wallet, Tamara, PayFort, TAP, NearPay",
            "controllers": [
                "PaymentController",
                "PayfortController",
                "TamaraController",
                "TapController",
                "TerminalController"
            ],
            "services": [
                "PaymentService",
                "TamaraService",
                "PayfortService",
                "TapService",
                "NearPayService"
            ],
            "models": [
                "PAYMENTS",
                "ENDUSERWAL"
            ],
            "tables": [
                "PAYMENTS",
                "ONLINE_PAYMENT_METHOD",
                "PROFILE_ONLINE_PAYMENT_METHOD",
                "END_USER_WALLET",
                "WALLET_TRANSACTION_TYPE",
                "ORDER_TRANSACTION_REFUND"
            ]
        },
        "insurance_claims": {
            "description": "Insurance eligibility, pre-authorization, NPHIES claim submission",
            "controllers": [
                "InsuranceController"
            ],
            "services": [
                "NphiesService"
            ],
            "models": [
                "INSURANCECLAIMS",
                "INSURANCEINVOICES",
                "INSURANCECOMPANY"
            ],
            "tables": [
                "INSURANCE_CLAIMS",
                "INSURANCE_INVOICES",
                "INSURANCE_APPROVALS",
                "INSURANCE_COMPANY",
                "INSURANCE_HOSPITAL",
                "INSURANCE_GROUPS",
                "INSURANCE_TEST_PRICES"
            ],
            "jobs": [
                "NphiesResultStatusUpdate"
            ]
        },
        "invoicing_zatca": {
            "description": "Invoice generation, credit/debit notes, ZATCA e-invoicing compliance",
            "controllers": [
                "InvoiceController",
                "ZatcaController"
            ],
            "services": [
                "TaxService",
                "Services/Zatca/*"
            ],
            "models": [
                "ENDUSERINVOICE",
                "ZATCAINVOICE",
                "ENDUSERCREDITNOTE"
            ],
            "tables": [
                "END_USER_INVOICE",
                "ZATCA_INVOICE",
                "ZATCA_B2B_INVOICE",
                "ZATCA_HOSPITAL",
                "ZATCA_INTEGRATION",
                "END_USER_CREDIT_NOTE",
                "END_USER_DEBIT_NOTE",
                "INVOICES",
                "INVOICES_SEQUENCES"
            ],
            "jobs": [
                "ZatcaInvoice",
                "ZatcaRefund",
                "ZatcaB2BInvoice",
                "ZatcaB2BCredit",
                "ZatcaB2BDebit",
                "GenerateInvoiceNumber"
            ]
        },
        "notifications_alerts": {
            "description": "Multi-channel notifications (SMS, Push, WhatsApp, Email) and alert system",
            "controllers": [
                "NotificationController",
                "AlertController"
            ],
            "services": [
                "FCMService",
                "SMSService",
                "EmailService",
                "WhatsAppService",
                "Services/Notification/*",
                "Services/Alert/*"
            ],
            "models": [
                "ENDUSERNOTIFICATION",
                "SYSTEMUSERNOTIFICATION",
                "ALERT"
            ],
            "tables": [
                "NOTIFICATION",
                "NOTIFICATION_EVENTS",
                "NOTIFICATION_GROUPS",
                "END_USER_NOTIFICATION",
                "SYSTEM_USER_NOTIFICATION",
                "ALERT",
                "ALERT_PROCESSING",
                "ALERT_TYPE",
                "ALERT_USER_GROUP",
                "DEVICE_TOKENS"
            ],
            "jobs": [
                "NotificationFired",
                "NotificationClosed",
                "NotificationPush",
                "NotificationRejection",
                "AlertDelivery",
                "AlertEscalationEvent",
                "AlertTypeEvent",
                "SendSMSJob",
                "SendEmailJob",
                "SendWhatsAppJob"
            ]
        },
        "ai_recommendations": {
            "description": "OpenAI-powered lab test recommendations based on patient symptoms",
            "controllers": [
                "AiRecommendationController"
            ],
            "services": [
                "MyHealthAiService"
            ],
            "models": [
                "ENDUSERAIRECOMMENDATION",
                "ENDUSERAIRECOMMENDATIONPACKAGE"
            ],
            "tables": [
                "END_USER_AI_RECOMMENDATION",
                "END_USER_AI_RECOMMENDATION_PACKAGES"
            ],
            "jobs": [
                "GenerateAiRecommendationJob"
            ]
        },
        "quality_control": {
            "description": "Westgard rules QC, QC lots, control charts, corrective actions",
            "controllers": [
                "LabController"
            ],
            "services": [
                "LabService"
            ],
            "models": [
                "QC",
                "QCRESULT",
                "QCLOT",
                "QCSTATISTIC",
                "CORRECTIVEACTION"
            ],
            "tables": [
                "QC",
                "QC_RESULT",
                "QC_LOT",
                "QC_LOT_TEST",
                "QC_STATISTIC",
                "QC_WESTGARD_RULE",
                "PROFILE_QC_WESTGARD_RULES",
                "QC_APPROVAL_RESULT",
                "CORRECTIVE_ACTIONS"
            ]
        },
        "inventory_warehouse": {
            "description": "Reagent/kit inventory, purchase orders, vendor management",
            "controllers": [
                "WarehouseController"
            ],
            "services": [
                "WarehouseService"
            ],
            "models": [
                "PROFILEINVITEM",
                "PROFILEPURCHASEORDER",
                "PROFILEPURCHASERECEIVED"
            ],
            "tables": [
                "PROFILE_INV_ITEM",
                "PROFILE_INV_ITEM_TYPE",
                "PROFILE_INV_VENDOR",
                "PROFILE_PURCHASE_ORDER",
                "PROFILE_PURCHASE_ORDER_ITEM",
                "PROFILE_PURCHASE_RECEIVED",
                "PROFILE_INV_MAIN_TRANSACTION",
                "PROFILE_INV_MAIN_TRANSACTION_DETAILS"
            ],
            "jobs": [
                "PurchaseOrderJob"
            ]
        },
        "hesn_plus": {
            "description": "Saudi MOH national health platform data synchronization",
            "controllers": [],
            "services": [
                "HESNPlusService",
                "HESNService"
            ],
            "models": [
                "HESNPLUSTOKEN"
            ],
            "tables": [
                "HESN_PLUS_TOKEN",
                "HESN_PLUS_DIRECTORATE",
                "PROFILE_HESN"
            ],
            "jobs": [
                "HESNPlusSendData",
                "HESNReceive",
                "HESNRequisition",
                "HESNUpdateResult"
            ]
        },
        "erp_integration": {
            "description": "ERP (Dynamic/SAP) invoice, payment, and inventory synchronization",
            "controllers": [
                "ErpController"
            ],
            "services": [
                "Services/ERP/*"
            ],
            "models": [
                "ERPINTEGRATION"
            ],
            "tables": [
                "ERP_INTEGRATION",
                "ERP_COMPANIES",
                "PROFILE_ERP_CREDENTIAL"
            ],
            "jobs": [
                "ERPInvoice",
                "ERPInvoiceClient",
                "ERPInvoiceClientCash",
                "ERPRefund",
                "ERPRefundClient",
                "ERPRefundClientCash",
                "ERPMovement"
            ]
        },
        "sales_analytics": {
            "description": "Sales reports, branch performance, TAT analysis, forecasting",
            "controllers": [
                "SalesController",
                "NewSalesController",
                "BranchIncomeController",
                "SalesForecastController",
                "CommandCenterController"
            ],
            "services": [
                "SalesService",
                "NewSalesService",
                "BranchIncomeService",
                "CommandCenterService"
            ],
            "models": [
                "SALESFORECAST",
                "FORECASTBRANCHTAR"
            ],
            "tables": [
                "SALES_FORECAST",
                "FORECAST_BRANCH_TARGETS",
                "FORECAST_MONTHLY_TARGETS",
                "FORECAST_YEARLY_DATA",
                "branch_totals_cache"
            ],
            "jobs": [
                "SalesDetailsReport",
                "TatAnalysisReport",
                "RevenueReportTest",
                "ProcessBranchTotalsReportJob"
            ]
        },
        "white_label": {
            "description": "Per-tenant branding, landing pages, configurable UI",
            "controllers": [
                "WhitelabelController"
            ],
            "services": [],
            "models": [],
            "tables": [
                "WHITE_LABEL_BRANCHES",
                "WHITE_LABEL_CAROUSEL_SLIDES",
                "WHITE_LABEL_MEDIA_ITEMS",
                "WHITE_LABEL_PAGE_SECTIONS",
                "WHITE_LABEL_SERVICES",
                "WHITE_LABEL_SERVICE_FEATURES",
                "WHITE_LABEL_STATISTICS"
            ]
        },
        "loyalty": {
            "description": "Point-based patient rewards system",
            "controllers": [
                "LoyaltyController"
            ],
            "services": [],
            "models": [
                "ENDUSERPOINT"
            ],
            "tables": [
                "END_USER_POINT",
                "PROFILE_LOYALTY_TEST"
            ]
        },
        "diabetic_dashboard": {
            "description": "Specialized tracking for diabetic patient clinical visits",
            "controllers": [
                "DiabeticDashboardController"
            ],
            "services": [],
            "models": [
                "DiabeticPatientVisit"
            ],
            "tables": [
                "diabetic_patient_visits",
                "diabetic_genders",
                "diabetic_types_of_diabetes",
                "diabetic_hba1c_levels",
                "diabetic_smokers",
                "diabetic_type_of_footwears",
                "diabetic_affected_areas",
                "diabetic_types_of_amputation",
                "diabetic_wound_duration",
                "diabetic_type_of_visits",
                "CLUSTER"
            ]
        },
        "genetics_histopathology": {
            "description": "Specialized lab workflows for genetics and pathology tests",
            "controllers": [
                "GeneticsExtractionController"
            ],
            "services": [],
            "models": [],
            "tables": [
                "GENETICS_BATCHES",
                "HISTOPATHOLOGY_BATCH"
            ]
        },
        "hl7_messaging": {
            "description": "HL7 healthcare interoperability messaging",
            "controllers": [
                "HlController"
            ],
            "services": [
                "HL7Service"
            ],
            "models": [],
            "tables": [
                "HL7_ERROR_LOGS"
            ],
            "jobs": [
                "SendHL7InProcessMessageJob"
            ]
        }
    },
    "controllers": {
        "WebController": "app/Http/Controllers/WebController.php",
        "LabController": "app/Http/Controllers/LabController.php",
        "InvoiceController": "app/Http/Controllers/InvoiceController.php",
        "InsuranceController": "app/Http/Controllers/InsuranceController.php",
        "PaymentController": "app/Http/Controllers/PaymentController.php",
        "PayfortController": "app/Http/Controllers/PayfortController.php",
        "TamaraController": "app/Http/Controllers/TamaraController.php",
        "TapController": "app/Http/Controllers/TapController.php",
        "SalesController": "app/Http/Controllers/SalesController.php",
        "NewSalesController": "app/Http/Controllers/NewSalesController.php",
        "BranchIncomeController": "app/Http/Controllers/BranchIncomeController.php",
        "WarehouseController": "app/Http/Controllers/WarehouseController.php",
        "NotificationController": "app/Http/Controllers/NotificationController.php",
        "AlertController": "app/Http/Controllers/AlertController.php",
        "AiRecommendationController": "app/Http/Controllers/AiRecommendationController.php",
        "UserController": "app/Http/Controllers/UserController.php",
        "MetadataController": "app/Http/Controllers/MetadataController.php",
        "CommandCenterController": "app/Http/Controllers/CommandCenterController.php",
        "ZatcaController": "app/Http/Controllers/ZatcaController.php",
        "AyenatiController": "app/Http/Controllers/AyenatiController.php",
        "HlController": "app/Http/Controllers/HlController.php",
        "LdmController": "app/Http/Controllers/LdmController.php",
        "LiveHealthController": "app/Http/Controllers/LiveHealthController.php",
        "ErpController": "app/Http/Controllers/ErpController.php",
        "WhitelabelController": "app/Http/Controllers/WhitelabelController.php",
        "SalesForecastController": "app/Http/Controllers/SalesForecastController.php",
        "LoyaltyController": "app/Http/Controllers/LoyaltyController.php",
        "GeneticsExtractionController": "app/Http/Controllers/GeneticsExtractionController.php",
        "DiabeticDashboardController": "app/Http/Controllers/DiabeticDashboardController.php",
        "TerminalController": "app/Http/Controllers/TerminalController.php",
        "OperationsController": "app/Http/Controllers/OperationsController.php",
        "ApiController": "app/Http/Controllers/ApiController.php",
        "WebhookController": "app/Http/Controllers/WebhookController.php",
        "MyHealthController": "app/Http/Controllers/MyHealthController.php",
        "QuestionnaireController": "app/Http/Controllers/QuestionnaireController.php"
    },
    "services": {
        "LabService": "app/Services/LabService.php",
        "EndUserService": "app/Services/EndUserService.php",
        "PaymentService": "app/Services/PaymentService.php",
        "TamaraService": "app/Services/TamaraService.php",
        "PayfortService": "app/Services/PayfortService.php",
        "TapService": "app/Services/TapService.php",
        "NearPayService": "app/Services/NearPayService.php",
        "NphiesService": "app/Services/NphiesService.php",
        "HESNPlusService": "app/Services/HESNPlusService.php",
        "HESNService": "app/Services/HESNService.php",
        "AyenatiService": "app/Services/Ayenati/AyenatiService.php",
        "HL7Service": "app/Services/HL7Service.php",
        "LdmService": "app/Services/LdmService.php",
        "LivehealthService": "app/Services/LivehealthService.php",
        "EmailService": "app/Services/EmailService.php",
        "SMSService": "app/Services/SMSService.php",
        "WhatsAppService": "app/Services/WhatsAppService.php",
        "FCMService": "app/Services/FCMService.php",
        "FileService": "app/Services/FileService.php",
        "TaxService": "app/Services/TaxService.php",
        "NormalReportService": "app/Services/NormalReportService.php",
        "SmartReportService": "app/Services/SmartReportService.php",
        "TemplateReportService": "app/Services/TemplateReportService.php",
        "SalesService": "app/Services/SalesService.php",
        "BranchIncomeService": "app/Services/BranchIncomeService.php",
        "WarehouseService": "app/Services/WarehouseService.php",
        "CommandCenterService": "app/Services/CommandCenterService.php",
        "MyHealthAiService": "app/Services/MyHealthAiService.php",
        "LeanAPIService": "app/Services/LeanAPIService.php",
        "LogService": "app/Services/LogService.php",
        "FlagService": "app/Services/FlagService.php",
        "QRService": "app/Services/QRService.php"
    },
    "jobs": [
        "AlertDelivery",
        "AlertEscalationEvent",
        "AlertTypeEvent",
        "ERPInvoice",
        "ERPInvoiceClient",
        "ERPInvoiceClientCash",
        "ERPMovement",
        "ERPRefund",
        "ERPRefundClient",
        "ERPRefundClientCash",
        "ExportInvoicesJob",
        "GenerateAiRecommendationJob",
        "GenerateInvoiceNumber",
        "HESNPlusSendData",
        "HESNReceive",
        "HESNRequisition",
        "HESNUpdateResult",
        "HisLog",
        "HisResultReady",
        "ImportPriceListToUsersJob",
        "LogData",
        "Mtc",
        "NotificationClosed",
        "NotificationFired",
        "NotificationPromotionReservationFired",
        "NotificationPromotionResult",
        "NotificationPush",
        "NotificationRejection",
        "NphiesResultStatusUpdate",
        "ProcessBranchTotalsReportJob",
        "PurchaseOrderJob",
        "RevenueReportTest",
        "SalesDetailsReport",
        "SampleDetailsReport",
        "SendEmailJob",
        "SendEmailNotificationJob",
        "SendHL7InProcessMessageJob",
        "SendSMSJob",
        "SendWhatsAppJob",
        "SmartReportReady",
        "TatAnalysisReport",
        "TemplateReportReady",
        "ZatcaB2BCredit",
        "ZatcaB2BDebit",
        "ZatcaB2BInvoice",
        "ZatcaInvoice",
        "ZatcaRefund"
    ],
    "models": {
        "critical": [
            "PROFILE",
            "HOSPITAL",
            "END_USER",
            "SYSTEM_USER",
            "LAB_CATEGORY_PACKAGE",
            "LAB_CATEGORY",
            "END_USER_LAB_ORDER",
            "END_USER_LAB_ORDER_PACKAGE",
            "END_USER_LAB_ORDER_PACKAGE_RESULT",
            "PAYMENTS",
            "END_USER_INVOICE",
            "INSURANCE_CLAIMS",
            "INSURANCE_INVOICES",
            "ZATCA_INVOICE",
            "ZATCA_B2B_INVOICE",
            "QC",
            "QC_RESULT",
            "QC_LOT"
        ],
        "path": "app/Models/"
    },
    "database_tables": {
        "identity_auth": [
            "END_USER",
            "SYSTEM_USER",
            "BM_ADMINS",
            "BM_ROLES",
            "BM_PERMISSIONS",
            "ROLE",
            "PERMISSION",
            "MOBILE_NO_VERIFICATION",
            "DEVICE_TOKENS",
            "personal_access_tokens",
            "sessions"
        ],
        "tenancy_config": [
            "PROFILE",
            "HOSPITAL",
            "HOSPITAL_LOCATION",
            "HOSPITAL_BANK",
            "LAB_SETTING",
            "VAT_PROFILE"
        ],
        "test_catalog": [
            "LAB_CATEGORY_PACKAGE",
            "LAB_CATEGORY",
            "LAB_CATEGORY_PACKAGE_RESULT",
            "SPECIMEN_TYPE",
            "PROFILE_REFERENCE_RANGE",
            "PROFILE_PRICE_LIST",
            "LAB_PACKAGE_ITEM"
        ],
        "orders_samples": [
            "END_USER_LAB_CART",
            "END_USER_LAB_ORDER",
            "END_USER_LAB_ORDER_PACKAGE",
            "END_USER_LAB_ORDER_PACKAGE_RESULT",
            "END_USER_LAB_ORDER_HISTORY",
            "BATCH",
            "PICKUP"
        ],
        "payments_finance": [
            "PAYMENTS",
            "END_USER_INVOICE",
            "END_USER_WALLET",
            "ORDER_TRANSACTION_REFUND",
            "COUPON",
            "END_USER_CREDIT_NOTE"
        ],
        "insurance_claims": [
            "INSURANCE_CLAIMS",
            "INSURANCE_INVOICES",
            "INSURANCE_APPROVALS",
            "INSURANCE_COMPANY",
            "NPHIES related"
        ],
        "zatca_einvoice": [
            "ZATCA_INVOICE",
            "ZATCA_B2B_INVOICE",
            "ZATCA_HOSPITAL",
            "ZATCA_INTEGRATION"
        ],
        "quality_control": [
            "QC",
            "QC_RESULT",
            "QC_LOT",
            "QC_STATISTIC",
            "QC_WESTGARD_RULE",
            "CORRECTIVE_ACTIONS"
        ],
        "inventory": [
            "PROFILE_INV_ITEM",
            "PROFILE_PURCHASE_ORDER",
            "PROFILE_PURCHASE_RECEIVED",
            "PROFILE_INV_VENDOR",
            "PROFILE_INV_MAIN_TRANSACTION"
        ],
        "notifications_alerts": [
            "NOTIFICATION",
            "NOTIFICATION_EVENTS",
            "END_USER_NOTIFICATION",
            "SYSTEM_USER_NOTIFICATION",
            "ALERT",
            "ALERT_PROCESSING"
        ],
        "analytics_bi": [
            "SALES_FORECAST",
            "FORECAST_BRANCH_TARGETS",
            "branch_totals_cache",
            "MY_HEALTH_USER_SCORES"
        ],
        "integrations": [
            "HESN_PLUS_TOKEN",
            "PROFILE_HESN",
            "ERP_INTEGRATION",
            "PROFILE_HIS",
            "HL7_ERROR_LOGS",
            "ZATCA_INTEGRATION"
        ],
        "content_cms": [
            "BANNER",
            "BLOG_ARTICLE",
            "WHITE_LABEL_BRANCHES",
            "LAB_SLIDER"
        ],
        "lookup_reference": [
            "COUNTRY",
            "CITY",
            "GENDER",
            "NATIONALITY",
            "LANGUAGE",
            "SPECIMEN_TYPE",
            "ORDER_STATUS",
            "LAB_ORDER_STATUS"
        ],
        "laravel_system": [
            "migrations",
            "jobs",
            "failed_jobs",
            "cache",
            "sessions",
            "telescope_entries"
        ]
    },
    "integrations": {
        "payment_gateways": {
            "tamara": {
                "service": "TamaraService",
                "type": "BNPL",
                "config": "PROFILE.TAMARA_TOKEN"
            },
            "payfort": {
                "service": "PayfortService",
                "type": "card",
                "config": ".env PAYFORT_*"
            },
            "tap": {
                "service": "TapService",
                "type": "card",
                "config": "PROFILE.TAP_PUBLIC/SECRET"
            },
            "nearpay": {
                "service": "NearPayService",
                "type": "POS",
                "config": "PROFILE.NEARPAY_*"
            }
        },
        "government": {
            "zatca": {
                "service": "Services/Zatca/*",
                "purpose": "e-invoicing",
                "tables": [
                    "ZATCA_INVOICE",
                    "ZATCA_INTEGRATION"
                ]
            },
            "nphies": {
                "service": "NphiesService",
                "purpose": "insurance claims",
                "tables": [
                    "INSURANCE_CLAIMS"
                ]
            },
            "hesn_plus": {
                "service": "HESNPlusService",
                "purpose": "MOH health data",
                "tables": [
                    "HESN_PLUS_TOKEN"
                ]
            },
            "lean_api": {
                "service": "LeanAPIService",
                "purpose": "health ID + practitioner",
                "config": "PROFILE.LEAN_*"
            }
        },
        "emr_his": {
            "ayenati": {
                "service": "AyenatiService",
                "middleware": "AyenatiTokenAuth"
            },
            "hl7": {
                "service": "HL7Service",
                "library": "aranyasen/hl7"
            },
            "ldm": {
                "service": "LdmService",
                "middleware": "LdmAuth"
            },
            "livehealth": {
                "service": "LivehealthService",
                "config": "PROFILE.LIVEHEALTH_*"
            },
            "his": {
                "service": "via Jobs",
                "tables": [
                    "PROFILE_HIS",
                    "PROFILE_HIS_ENDPOINT"
                ]
            },
            "erp": {
                "service": "Services/ERP/*",
                "jobs": [
                    "ERPInvoice",
                    "ERPRefund",
                    "ERPMovement"
                ]
            }
        },
        "cloud": {
            "aws_s3": {
                "purpose": "file storage",
                "bucket": "blazma.com",
                "region": "eu-west-1"
            },
            "aws_ses": {
                "purpose": "email (production)"
            },
            "firebase_fcm": {
                "service": "FCMService",
                "config": "PROFILE.FCM_SERVER_KEY"
            }
        },
        "communication": {
            "unifonic_sms": {
                "service": "SMSService",
                "config": "PROFILE.UNIFONIC_*"
            },
            "connectsaudi_sms": {
                "service": "SMSService",
                "config": "PROFILE.CONNECTSAUDI_SENDER_ID"
            },
            "whatsapp": {
                "service": "WhatsAppService",
                "config": "PROFILE.WHATSAPP_*"
            },
            "email_smtp": {
                "service": "EmailService",
                "config": "PROFILE SMTP columns"
            }
        },
        "ai_utilities": {
            "openai": {
                "service": "MyHealthAiService",
                "purpose": "test recommendations",
                "config": "OPENAI_API_KEY"
            },
            "scandit": {
                "purpose": "barcode scanning",
                "config": "SCANDIT_TOKEN"
            },
            "redis": {
                "purpose": "queue + cache",
                "driver": "phpredis"
            }
        }
    },
    "middleware": {
        "WebAuth": "Patient session authentication",
        "AccessTokenValidation": "API bearer token validation",
        "AccessTokenOptional": "Optional API authentication",
        "OperationsAuth": "Operations panel + permission check",
        "TerminalAuth": "POS terminal token",
        "AyenatiTokenAuth": "Ayenati integration token",
        "LdmAuth": "LDM system authentication",
        "MetaDataAuth": "Metadata API authentication",
        "NupcoAuth": "NUPCO authentication",
        "CorsMiddleware": "CORS headers",
        "NormalizeSlashes": "URL normalization",
        "RedirectToPayment": "Payment flow redirect",
        "Authenticate": "Laravel default auth"
    },
    "key_relationships": {
        "PROFILE -> HOSPITAL": "one-to-many (profile has many branches)",
        "PROFILE -> END_USER": "one-to-many (profile has many patients)",
        "PROFILE -> LAB_CATEGORY_PACKAGE": "one-to-many (profile has test catalog)",
        "PROFILE -> SYSTEM_USER": "one-to-many (profile has staff)",
        "HOSPITAL -> END_USER_LAB_ORDER": "one-to-many (hospital has orders)",
        "END_USER -> END_USER_LAB_ORDER": "one-to-many (patient has orders)",
        "END_USER_LAB_ORDER -> END_USER_LAB_ORDER_PACKAGE": "one-to-many (order has test items)",
        "LAB_CATEGORY_PACKAGE -> END_USER_LAB_ORDER_PACKAGE": "one-to-many (test has order items)",
        "END_USER_LAB_ORDER_PACKAGE -> END_USER_LAB_ORDER_PACKAGE_RESULT": "one-to-many (sample has results)",
        "END_USER_LAB_ORDER_PACKAGE -> PAYMENTS": "one-to-one (sample has payment)",
        "END_USER_LAB_ORDER_PACKAGE -> INSURANCE_CLAIMS": "one-to-one (sample may have claim)",
        "END_USER_LAB_ORDER -> END_USER_INVOICE": "one-to-one (order has invoice)",
        "END_USER_INVOICE -> ZATCA_INVOICE": "one-to-one (invoice has ZATCA record)",
        "INSURANCE_CLAIMS -> INSURANCE_INVOICES": "many-to-one (claims grouped in invoice)"
    },
    "coding_conventions": {
        "table_naming": "UPPERCASE for app tables",
        "column_naming": "UPPERCASE for app columns",
        "primary_key": "ID (uppercase) for app tables",
        "tenant_key": "PROFILE_ID required on all business tables",
        "bilingual_fields": "NAME_EN/NAME_AR, TITLE_EN/TITLE_AR pattern",
        "feature_flags": "ENABLE_* tinyint columns in PROFILE table",
        "model_classes": "UPPERCASE class names matching tables",
        "service_suffix": "Service (e.g., LabService, PaymentService)",
        "job_dispatch": "Always async for heavy/external operations"
    },
    "ai_rules_summary": [
        "Read /docs/ai/ before any modification",
        "Always scope queries by PROFILE_ID",
        "Never bypass the Service layer",
        "Dispatch Jobs for heavy/external operations",
        "Maintain database relationships and PROFILE_ID FK",
        "Check feature flags before feature-specific code",
        "Maintain bilingual data (EN + AR)",
        "Never hardcode credentials",
        "Do not modify ZATCA/NPHIES compliance structures",
        "Update /docs/ai/ after architecture changes",
        "Run php artisan ai:update-docs after each sprint"
    ]
}