Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/ttpullima/RomsoftBackEnd2021_v2/llms.txt

Use this file to discover all available pages before exploring further.

The Romsoft Gestión Clínica API is an ASP.NET Web API application targeting .NET Framework 4.5, designed to serve as the backend for a Peruvian healthcare clinic management system. Every concern in the system — HTTP request handling, clinical business rules, data persistence, and domain modelling — is isolated in its own dedicated assembly, making the codebase navigable, testable in isolation, and replaceable layer by layer without disrupting the rest of the system.

The Four Layers

┌─────────────────────────────────────────────────────────┐
│               Romsoft.GESTIONCLINICA.WebApi              │
│  Controllers (BaseController → ApiController)           │
│  TokenValidationHandler · Swashbuckle /swagger          │
│  AutoMapper DTOs ↔ Entities · log4net LogError()        │
└──────────────────────────┬──────────────────────────────┘
                           │ calls
┌──────────────────────────▼──────────────────────────────┐
│          Romsoft.GESTIONCLINICA.Business.Logic           │
│  Singleton<T> BL classes  (e.g. ADM_PACIENTEBL)        │
│  ILogic<T> interface · LogBL · domain validation        │
└──────────────────────────┬──────────────────────────────┘
                           │ calls
┌──────────────────────────▼──────────────────────────────┐
│           Romsoft.GESTIONCLINICA.DataAccess              │
│  Repository classes (e.g. ADM_PACIENTERepository)      │
│  ConectionStringRepository · Enterprise Library Data    │
│  SQL Server stored procedures via DatabaseFactory       │
└──────────────────────────┬──────────────────────────────┘
                           │ maps to / from
┌──────────────────────────▼──────────────────────────────┐
│   Romsoft.GESTIONCLINICA.Entidades + .DTO + .Common     │
│  Plain C# entity classes · DTO classes                  │
│  JsonResponse · PaginationParameter · CryptoHelper      │
└─────────────────────────────────────────────────────────┘

Layer 1 — WebApi (HTTP Entry Point)

Romsoft.GESTIONCLINICA.WebApi is the only IIS-hosted project in the solution. Global.asax.cs bootstraps the system at startup: it calls WebApiConfig.Register to configure routing and attach the TokenValidationHandler message handler, then wires up log4net (XmlConfigurator.Configure) and AutoMapper (AutoMapperConfiguration.Configure). All controller classes extend BaseController, which itself extends ApiController and adds a shared ILog Logger instance and convenience LogError overloads.

Layer 2 — Business Logic (BL Singletons)

Romsoft.GESTIONCLINICA.Business.Logic houses one class per domain entity. Each BL class extends the thread-safe Singleton<T> base (mutex-guarded instance), so callers use ADM_PACIENTEBL.Instancia.Add(entity) rather than instantiating a new object. BL classes implement ILogic<T>, which mandates Add, Update, Delete, GetAll, GetAllPaging, GetAllFilters, and GetAllActives. The LogBL singleton provides audit-trail persistence.

Layer 3 — DataAccess (Repositories)

Romsoft.GESTIONCLINICA.DataAccess contains repository classes that issue SQL through the Microsoft Enterprise Library Data Application Block (Microsoft.Practices.EnterpriseLibrary.Data). The static ConectionStringRepository class reads connection string names from Web.config and exposes them to DatabaseFactory.CreateDatabase(). All stored procedures in the Romsoft. schema are invoked here. A secondary ConnectionStringACCESS entry supports OLEDB access to the SUSALUD IPRESSLOG.mdb file for regulatory reporting.

Layer 4 — Entidades, DTO, and Common (Domain Models)

Romsoft.GESTIONCLINICA.Entidades contains plain C# classes that mirror database tables (e.g., ADM_PACIENTE, SEG_USUARIO, Log). Romsoft.GESTIONCLINICA.DTO holds the matching Data Transfer Objects plus the AutoMapper profiles (DomainToDtoMappingProfile, DtoToDomainMappingProfile). Romsoft.GESTIONCLINICA.Common provides shared infrastructure: JsonResponse (the universal response envelope), PaginationParameter, and CryptoHelper.

Routing

All API endpoints are registered under a single route template:
api/{controller}/{action}/{id}
Every action uses [HttpPost], meaning the route POST /api/ADM_PACIENTE/Add calls ADM_PACIENTEController.Add(). Attribute routing (MapHttpAttributeRoutes) is also enabled for any controllers that opt in. There are no GET-based query endpoints — callers always POST a DTO or filter object.

Cross-Cutting Concerns

Token Validation

TokenValidationHandler is registered as a DelegatingHandler in WebApiConfig.Register and intercepts every incoming request before it reaches a controller. It extracts the Bearer token from the Authorization header, validates lifetime, issuer, audience, and signing key against the four JWT_* appSettings, and sets Thread.CurrentPrincipal and HttpContext.Current.User if validation succeeds. Requests without a token are passed through to the controller (which may itself demand authentication), while requests carrying an invalid token receive an immediate 401 Unauthorized.

Swagger UI

Swashbuckle 5.6.0 is configured in App_Start/SwaggerConfig.cs and exposes the interactive API explorer at /swagger. The configuration reads XML doc comments from bin/Romsoft.GESTIONCLINICA.WebApi.xml and enables the Authorization header API-key input so testers can paste a JWT directly in the Swagger UI.

AutoMapper

AutoMapperConfiguration.Configure() is called once at application start. It registers DomainToDtoMappingProfile and DtoToDomainMappingProfile so that controllers can use MapperHelper.Map<TSource, TDest>(source) to convert between entity and DTO without manual property assignment.

log4net

A RollingFileAppender writes to Log/Log.txt alongside a DebugAppender. The shared Logger in BaseController is bound to the root log4net logger. Any unhandled exception caught in a controller action is passed to LogError(ex), which serializes the message and stack trace.

Project Structure

Visual Studio solution layout, assembly responsibilities, and controller naming conventions.

Response Format

The JsonResponse envelope that wraps every API response, including Success, Warning, and Data fields.

Build docs developers (and LLMs) love