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 Gestión Clínica API uses the Microsoft Enterprise Library Data Application Block v6 (Microsoft.Practices.EnterpriseLibrary.Data) for all SQL Server interactions. The Data block reads connection strings exclusively from the <connectionStrings> section of Web.config, identified by name. No connection string is hard-coded in C# — all repository classes call ConectionStringRepository.ConnectionStringNameSQL to get the name "ConnectionStringSQL" and pass it to DatabaseFactory.CreateDatabase().

Primary SQL Server Connection

The connection string named ConnectionStringSQL points to the production Azure SQL database:
<connectionStrings>
  <add
    name="ConnectionStringSQL"
    connectionString="Server=tcp:romsoftservidor.database.windows.net,1433;
      Initial Catalog=ROMSOFT-CLINICA;
      Persist Security Info=False;
      User ID=romsoftuser;
      Password=romsoft$123;
      MultipleActiveResultSets=False;
      Encrypt=True;
      TrustServerCertificate=False;
      Connection Timeout=30"
    providerName="System.Data.SqlClient" />
</connectionStrings>
ParameterValueNotes
Servertcp:romsoftservidor.database.windows.net,1433Azure SQL logical server
Initial CatalogROMSOFT-CLINICATarget database name
EncryptTrueRequired by Azure SQL
TrustServerCertificateFalseValidates the server certificate
Connection Timeout30Seconds before a connection attempt fails
MultipleActiveResultSetsFalseMARS is disabled
The credentials shown above (romsoftuser / romsoft$123) are the development defaults committed to the repository. Never deploy these credentials to a shared or production environment. Replace them using a Web.Release.config transform (see below) or an environment variable before publishing.

Switching to a Local SQL Express Instance

A commented-out alternative connection string is included in Web.config for local development against a SQL Server Express instance:
<!--
<add
  name="ConnectionStringSQL"
  connectionString="Data Source=XTS-TTAPULLIMA\SQLEXPRESS;
    Initial Catalog=ROMSOFT-CLINICA;
    User ID=sa;
    Password=xternal01;
    Connect Timeout=300;"
  providerName="System.Data.SqlClient" />
-->
To switch to a local instance, uncomment this line and comment out the Azure entry. The database name (ROMSOFT-CLINICA) must match the name of the restored database on the local instance.

Secondary Connection — SUSALUD OLEDB Access

A second connection string, ConnectionStringACCESS, targets the SUSALUD IPRESSLOG.mdb Access database used for Peruvian health-regulator (SUSALUD) reporting:
<add
  name="ConnectionStringACCESS"
  connectionString="Provider=Microsoft.Jet.OLEDB.4.0;
    Data Source=C:\\SUSALUD\\RED\\IPRESSLOG.mdb" />
This connection uses the 32-bit Jet OLEDB 4.0 provider. The IIS application pool hosting the API must therefore be configured to enable 32-bit applications. The file path C:\SUSALUD\RED\IPRESSLOG.mdb must exist on the server running the API and be accessible by the application pool identity. In ConectionStringRepository, this string is exposed as ConnectionStringACCESS and ConnectionStringNameACCESS.

Enterprise Library Data Configuration Section

The <configSections> block at the top of Web.config declares the Enterprise Library configuration handler. It must be present for the Data block to initialize correctly:
<configSections>
  <section
    name="dataConfiguration"
    type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings,
          Microsoft.Practices.EnterpriseLibrary.Data" />
  <section
    name="log4net"
    type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>

How the Repository Layer Reads the Connection

The static class ConectionStringRepository in Romsoft.GESTIONCLINICA.DataAccess.Core is the single source of truth for connection strings within the data layer:
public static class ConectionStringRepository
{
    // Full connection string value — used when creating DbConnection directly
    public static string ConnectionStringSQL
        => ConfigurationManager.ConnectionStrings["ConnectionStringSQL"].ConnectionString;

    public static string ConnectionStringACCESS
        => ConfigurationManager.ConnectionStrings["ConnectionStringACCESS"].ConnectionString;

    // Named key — passed to DatabaseFactory.CreateDatabase(name)
    public static string ConnectionStringNameSQL => "ConnectionStringSQL";
    public static string ConnectionStringNameACCESS => "ConnectionStringACCESS";

    // Schema prefix used when building stored procedure names
    public static string EsquemaName => "Romsoft.";
}
Repositories call DatabaseFactory.CreateDatabase(ConectionStringRepository.ConnectionStringNameSQL) to obtain a Database object, then use it to execute stored procedures such as Romsoft.USP_ADM_PACIENTE_INSERT.

SQL Server Version Requirements

The application targets SQL Server 2012 or later (Azure SQL is fully supported). Features used include:
  • Stored procedures with OUTPUT parameters for returning inserted IDs
  • OFFSET/FETCH NEXT pagination syntax (SQL Server 2012+)
  • Azure SQL compatibility level 100+

Managing Secrets with Config Transforms

1

Do not commit real production credentials

Keep Web.config credentials pointing at the development/staging database or use placeholder values. Mark the file in .gitignore if credentials must be stored locally.
2

Add a Web.Release.config transform

Visual Studio automatically applies Web.Release.config when publishing in Release mode. Override the connection string using an xdt:Transform:
<!-- Web.Release.config -->
<connectionStrings>
  <add
    name="ConnectionStringSQL"
    connectionString="Server=tcp:PROD_SERVER.database.windows.net,1433;
      Initial Catalog=ROMSOFT-CLINICA;
      User ID=$(DB_USER);
      Password=$(DB_PASSWORD);
      Encrypt=True;
      TrustServerCertificate=False;
      Connection Timeout=30"
    providerName="System.Data.SqlClient"
    xdt:Transform="SetAttributes"
    xdt:Locator="Match(name)" />
</connectionStrings>
3

Inject secrets at deploy time

Use CI/CD pipeline variable substitution (Azure DevOps, GitHub Actions) to replace $(DB_USER) and $(DB_PASSWORD) with secrets stored in the pipeline’s secret store — never in source control.

Build docs developers (and LLMs) love