Skip to content

Commit

Permalink
Finish release/v1.4.0
Browse files Browse the repository at this point in the history
Release/v1.4.0
  • Loading branch information
dragos-dobre authored Nov 15, 2022
2 parents f2b8bb5 + 74ee7e8 commit 57d15ac
Show file tree
Hide file tree
Showing 66 changed files with 508 additions and 319 deletions.
4 changes: 2 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
bin\
obj\
bin/
obj/
38 changes: 20 additions & 18 deletions OpenImis.DB.SqlServer/DataHelper/DataHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,21 @@ namespace OpenImis.DB.SqlServer.DataHelper
{
public class DataHelper
{
private readonly string ConnectionString;
private readonly string _connectionString;
private readonly int _commandTimeout = 30;

public int ReturnValue { get; set; }

public DataHelper(IConfiguration configuration)
{
ConnectionString = configuration["ConnectionStrings:IMISDatabase"];
_connectionString = configuration["ConnectionStrings:IMISDatabase"];
if (configuration["ConnectionSettings:CommandTimeout"] != null) _commandTimeout = Int32.Parse(configuration["ConnectionSettings:CommandTimeout"]);
}

public DataSet FillDataSet(string SQL, SqlParameter[] parameters, CommandType commandType)
{
using (var sqlConnection = new SqlConnection(ConnectionString))
using (var command = new SqlCommand(SQL, sqlConnection) { CommandType = commandType })
using (var sqlConnection = new SqlConnection(_connectionString))
using (var command = new SqlCommand(SQL, sqlConnection) { CommandType = commandType, CommandTimeout = _commandTimeout })
using (var adapter = new SqlDataAdapter(command))
{
DataSet ds = new DataSet();
Expand All @@ -48,8 +50,8 @@ public DataSet FillDataSet(string SQL, SqlParameter[] parameters, CommandType co

public DataTable GetDataTable(string SQL, SqlParameter[] parameters, CommandType commandType)
{
using (var sqlConnection = new SqlConnection(ConnectionString))
using (var command = new SqlCommand(SQL, sqlConnection) { CommandType = commandType })
using (var sqlConnection = new SqlConnection(_connectionString))
using (var command = new SqlCommand(SQL, sqlConnection) { CommandType = commandType, CommandTimeout = _commandTimeout })
using (var adapter = new SqlDataAdapter(command))
{
DataTable dt = new DataTable();
Expand All @@ -67,8 +69,8 @@ public DataTable GetDataTable(string SQL, SqlParameter[] parameters, CommandType

public DataSet GetDataSet(string SQL, SqlParameter[] parameters, CommandType commandType)
{
using (var sqlConnection = new SqlConnection(ConnectionString))
using (var command = new SqlCommand(SQL, sqlConnection) { CommandType = commandType })
using (var sqlConnection = new SqlConnection(_connectionString))
using (var command = new SqlCommand(SQL, sqlConnection) { CommandType = commandType, CommandTimeout = _commandTimeout })
using (var adapter = new SqlDataAdapter(command))
{
DataSet ds = new DataSet();
Expand All @@ -86,8 +88,8 @@ public DataSet GetDataSet(string SQL, SqlParameter[] parameters, CommandType com

public void Execute(string SQL, SqlParameter[] parameters, CommandType commandType)
{
using (var sqlConnection = new SqlConnection(ConnectionString))
using (var command = new SqlCommand(SQL, sqlConnection) { CommandType = commandType })
using (var sqlConnection = new SqlConnection(_connectionString))
using (var command = new SqlCommand(SQL, sqlConnection) { CommandType = commandType, CommandTimeout = _commandTimeout })
{
sqlConnection.Open();

Expand All @@ -102,8 +104,8 @@ public void Execute(string SQL, SqlParameter[] parameters, CommandType commandTy

public async Task ExecuteAsync(string SQL, SqlParameter[] parameters, CommandType commandType)
{
using (var sqlConnection = new SqlConnection(ConnectionString))
using (var command = new SqlCommand(SQL, sqlConnection) { CommandType = commandType })
using (var sqlConnection = new SqlConnection(_connectionString))
using (var command = new SqlCommand(SQL, sqlConnection) { CommandType = commandType, CommandTimeout = _commandTimeout })
{
if (command.Connection.State == 0)
{
Expand All @@ -121,8 +123,8 @@ public async Task ExecuteAsync(string SQL, SqlParameter[] parameters, CommandTyp

public ProcedureOutPut Procedure(string StoredProcedure, SqlParameter[] parameters, int tableIndex = 0)
{
using (var sqlConnection = new SqlConnection(ConnectionString))
using (var command = new SqlCommand(StoredProcedure, sqlConnection) { CommandType = CommandType.StoredProcedure })
using (var sqlConnection = new SqlConnection(_connectionString))
using (var command = new SqlCommand(StoredProcedure, sqlConnection) { CommandType = CommandType.StoredProcedure, CommandTimeout = _commandTimeout })
using (var adapter = new SqlDataAdapter(command))
{
DataSet dt = new DataSet();
Expand Down Expand Up @@ -155,8 +157,8 @@ public ProcedureOutPut Procedure(string StoredProcedure, SqlParameter[] paramete

public IList<SqlParameter> ExecProcedure(string StoredProcedure, SqlParameter[] parameters)
{
using (var sqlConnection = new SqlConnection(ConnectionString))
using (var command = new SqlCommand(StoredProcedure, sqlConnection) { CommandType = CommandType.StoredProcedure })
using (var sqlConnection = new SqlConnection(_connectionString))
using (var command = new SqlCommand(StoredProcedure, sqlConnection) { CommandType = CommandType.StoredProcedure, CommandTimeout = _commandTimeout })
{
SqlParameter returnParameter = new SqlParameter("@RV", SqlDbType.Int);
returnParameter.Direction = ParameterDirection.ReturnValue;
Expand All @@ -181,8 +183,8 @@ public IList<SqlParameter> ExecProcedure(string StoredProcedure, SqlParameter[]

public async Task<IList<SqlParameter>> ExecProcedureAsync(string StoredProcedure, SqlParameter[] parameters)
{
using (var sqlConnection = new SqlConnection(ConnectionString))
using (var command = new SqlCommand(StoredProcedure, sqlConnection) { CommandType = CommandType.StoredProcedure })
using (var sqlConnection = new SqlConnection(_connectionString))
using (var command = new SqlCommand(StoredProcedure, sqlConnection) { CommandType = CommandType.StoredProcedure, CommandTimeout = _commandTimeout })
{
SqlParameter returnParameter = new SqlParameter("@RV", SqlDbType.Int);
returnParameter.Direction = ParameterDirection.ReturnValue;
Expand Down
22 changes: 19 additions & 3 deletions OpenImis.DB.SqlServer/ImisDB.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
using System;
using System.Data;
using System.Data.Common;
using System.IO;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.Extensions.Configuration;

namespace OpenImis.DB.SqlServer
{
public partial class ImisDB : IMISContext
{
private int _commandTimeout = 30;

public DbCommand CreateCommand()
{
var connection = Database.GetDbConnection();
var command = connection.CreateCommand();
command.CommandTimeout = _commandTimeout;
return command;
}

public void CheckConnection()
{
var connection = Database.GetDbConnection();
if (connection.State.Equals(ConnectionState.Closed)) connection.Open();
}

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
Expand All @@ -19,8 +35,8 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
//.AddJsonFile("appsettings.json")
.AddJsonFile(Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") != null ? $"{path}appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")}.json" : $"{path}appsettings.Production.json", optional: false, reloadOnChange: true)
.Build();

optionsBuilder.UseSqlServer(configuration.GetConnectionString("IMISDatabase"));
if (configuration["ConnectionSettings:CommandTimeout"] != null) _commandTimeout = Int32.Parse(configuration["ConnectionSettings:CommandTimeout"]);
optionsBuilder.UseSqlServer(configuration.GetConnectionString("IMISDatabase"), options => options.CommandTimeout(_commandTimeout));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ join G in imisContext.TblGender on I.Gender equals G.Code
DOB = I.Dob.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture),
Gender = G.Gender,
InsureeName = I.LastName + " " + I.OtherNames,
PhotoPath = P.PhotoFolder + P.PhotoFileName
PhotoPath = System.IO.Path.Combine(P.PhotoFolder, P.PhotoFileName)
})
.FirstOrDefault();
}
Expand Down
7 changes: 5 additions & 2 deletions OpenImis.ModulesV3/ClaimModule/ClaimModule.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using OpenImis.ModulesV3.ClaimModule.Logic;

namespace OpenImis.ModulesV3.ClaimModule
Expand All @@ -8,20 +9,22 @@ public class ClaimModule
{
private IConfiguration _configuration;
private readonly IHostingEnvironment _hostingEnvironment;
private readonly ILoggerFactory _loggerFactory;

private ClaimLogic _claimLogic;

public ClaimModule(IConfiguration configuration, IHostingEnvironment hostingEnvironment)
public ClaimModule(IConfiguration configuration, IHostingEnvironment hostingEnvironment, ILoggerFactory loggerFactory)
{
_configuration = configuration;
_hostingEnvironment = hostingEnvironment;
_loggerFactory = loggerFactory;
}

public ClaimLogic GetClaimLogic()
{
if (_claimLogic == null)
{
_claimLogic = new ClaimLogic(_configuration, _hostingEnvironment);
_claimLogic = new ClaimLogic(_configuration, _hostingEnvironment, _loggerFactory);
}
return _claimLogic;
}
Expand Down
19 changes: 14 additions & 5 deletions OpenImis.ModulesV3/ClaimModule/Logic/ClaimLogic.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using OpenImis.DB.SqlServer;
using OpenImis.ModulesV3.ClaimModule.Models;
using OpenImis.ModulesV3.ClaimModule.Models.RegisterClaim;
Expand All @@ -12,14 +13,16 @@ public class ClaimLogic
{
private IConfiguration _configuration;
private readonly IHostingEnvironment _hostingEnvironment;
private readonly ILoggerFactory _loggerFactory;
protected ClaimRepository claimRepository;

public ClaimLogic(IConfiguration configuration, IHostingEnvironment hostingEnvironment)
public ClaimLogic(IConfiguration configuration, IHostingEnvironment hostingEnvironment, ILoggerFactory loggerFactory)
{
_configuration = configuration;
_hostingEnvironment = hostingEnvironment;
_loggerFactory = loggerFactory;

claimRepository = new ClaimRepository(_configuration, _hostingEnvironment);
claimRepository = new ClaimRepository(_configuration, _hostingEnvironment, _loggerFactory);
}

public List<SubmitClaimResponse> Create(List<Claim> claims)
Expand All @@ -30,7 +33,7 @@ public List<SubmitClaimResponse> Create(List<Claim> claims)
foreach (var claim in claims)
{
result = claimRepository.Create(claim);

Errors.Claim errorCode;
string message;
switch (result)
Expand Down Expand Up @@ -77,16 +80,22 @@ public List<SubmitClaimResponse> Create(List<Claim> claims)
break;
default:
errorCode = Errors.Claim.UnexpectedException;
message = "Unhandled exception occured. Please contact the system administrator";
message = $"Unhandled exception occured ({result}). Please contact the system administrator";
break;
}

var rejectedItems = claimRepository.GetRejectedItems(claim.Details.HFCode, claim.Details.ClaimCode);
var rejectedServices = claimRepository.GetRejectedServices(claim.Details.HFCode, claim.Details.ClaimCode);


claimResponse.Add(
new SubmitClaimResponse
{
ClaimCode = claim.Details.ClaimCode,
Response = (int)errorCode,
Message = message
Message = message,
RejectedItems = rejectedItems,
RejectedServices = rejectedServices
});

}
Expand Down
4 changes: 1 addition & 3 deletions OpenImis.ModulesV3/ClaimModule/Models/ClaimOutPut.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using Newtonsoft.Json;
using OpenImis.ModulesV3.Utils;
using OpenImis.ModulesV3.Helpers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace OpenImis.ModulesV3.ClaimModule.Models
{
Expand Down
20 changes: 6 additions & 14 deletions OpenImis.ModulesV3/ClaimModule/Models/ClaimsModel.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
using Newtonsoft.Json;
using OpenImis.ModulesV3.Helpers.Validators;
using OpenImis.ModulesV3.Utils;
using Newtonsoft.Json;
using OpenImis.ModulesV3.Helpers;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;

namespace OpenImis.ModulesV3.ClaimModule.Models
{
Expand All @@ -14,17 +10,13 @@ public class ClaimsModel
[Required]
public string claim_administrator_code { get; set; }
public ClaimStatus status_claim { get; set; }
[ValidDate(ErrorMessage = "4:Wrong or missing enrolment date")]
[JsonConverter(typeof(IsoDateSerializer))]
[JsonConverter(typeof(IsoDateSerializer), "Invalid visit_date_from")]
public DateTime? visit_date_from { get; set; }
[ValidDate(ErrorMessage = "4:Wrong or missing enrolment date")]
[JsonConverter(typeof(IsoDateSerializer))]
[JsonConverter(typeof(IsoDateSerializer), "Invalid visit_date_to")]
public DateTime? visit_date_to { get; set; }
[ValidDate(ErrorMessage = "4:Wrong or missing enrolment date")]
[JsonConverter(typeof(IsoDateSerializer))]
[JsonConverter(typeof(IsoDateSerializer), "Invalid processed_date_from")]
public DateTime? processed_date_from { get; set; }
[ValidDate(ErrorMessage = "4:Wrong or missing enrolment date")]
[JsonConverter(typeof(IsoDateSerializer))]
[JsonConverter(typeof(IsoDateSerializer), "Invalid processed_date_to")]
public DateTime? processed_date_to { get; set; }
}

Expand Down
7 changes: 1 addition & 6 deletions OpenImis.ModulesV3/ClaimModule/Models/DsiInputModel.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@

using Newtonsoft.Json;
using OpenImis.ModulesV3.Helpers.Validators;
using OpenImis.ModulesV3.Utils;
using OpenImis.ModulesV3.Helpers;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;

namespace OpenImis.ModulesV3.ClaimModule.Models
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Newtonsoft.Json;
using OpenImis.ModulesV3.Utils;
using OpenImis.ModulesV3.Helpers;
using System;
using System.Collections.Generic;

Expand Down
19 changes: 19 additions & 0 deletions OpenImis.ModulesV3/ClaimModule/Models/SubmitClaimResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,30 @@

namespace OpenImis.ModulesV3.ClaimModule.Models
{
public class RejectedItem
{
public string Code { get; set; }
public short? Error { get; set; }
public string Reason { get; set; }
}

public class RejectedService
{
public string Code { get; set; }
public short? Error { get; set; }
public string Reason { get; set; }
}

public class SubmitClaimResponse
{
public string ClaimCode { get; set; }
public int Response { get; set; }
public string Message { get; set; }

public List<RejectedItem> RejectedItems { get; set; }

public List<RejectedService> RejectedServices { get; set; }

}

}
Loading

0 comments on commit 57d15ac

Please sign in to comment.