Saltar al contenido principal

ADR-031 — Hybrid Visibility System

Status: Approved | Date: 2026-06-20 | Scope: All plugins with role-based UI

Context

Healthcare SaaS needs granular control over what each user role sees. FacturaScripts provides a linear level attribute on XML columns. This is not enough for clinical scenarios where:

  • The same field must be visible to non-adjacent roles (physician + admin, but not nurse)
  • Whole sections (tabs) must be toggled per clinic, not per field
  • Clinic administrators need to adjust visibility without touching code

Decision

Implement two independent layers:

Layer A — FacturaScripts level (field-level, static)

  • Use the native level="N" attribute on XML view columns
  • Linear hierarchy: role with level N sees all fields with level N or lower
  • Thresholds are configurable per company via obelio_core_settings (AdminObelioFieldLevels)
  • No extra queries — FS handles it at render time

Layer B — ObelioSectionVisibility (section-level, dynamic)

  • ObelioCore table obelio_core_section_visibility
  • Stores per-company, per-section, per-role visibility rules
  • Admin UI: AdminObelioSectionVisibility — drag-and-drop, no code changes
  • Audits define default matrices (role x section); clinics can modify after install

See the Visibility System architecture page for implementation details.

Decision criteria (when to use which layer)

ScenarioUse
Hide a field from junior rolesLayer A
Show/hide a whole section based on roleLayer B
Performance-critical list viewLayer A only
Clinic-specific customisation neededLayer B

Consequences

  • Audit specs must include an explicit section-x-role default matrix for Layer B
  • ObelioCore must be installed before any other plugin (Layer B depends on it)
  • One extra DB query per page for Layer B (cached per session)
  • Clinic admins can customise visibility without a developer