Skip to content

Commit

Permalink
Merge pull request #2 from SALUD-AR/Renaper-FirmaDigital
Browse files Browse the repository at this point in the history
Renaper firma digital
  • Loading branch information
mamorese-net authored Sep 2, 2019
2 parents 3afca7f + 5f153e7 commit aa03532
Show file tree
Hide file tree
Showing 49 changed files with 2,793 additions and 117 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using Microsoft.Extensions.Logging;
using Msn.InteropDemo.AppServices.Core;
using Msn.InteropDemo.Snowstorm;
using Msn.InteropDemo.ViewModel.Snomed;
using System.Collections.Generic;
using System.Linq;

namespace Msn.InteropDemo.AppServices.Implementation.AppServices
{
public class Cie10AppService : Core.GenericServiceReadOnly<Entities.Codificacion.Cie10>, ICie10AppService
{
private readonly ISnowstormManager _snowstormManager;

public Cie10AppService(ICurrentContext currentContext,
ILogger<Cie10AppService> logger,
Snowstorm.ISnowstormManager snowstormManager) :
base(currentContext, logger)
{
_snowstormManager = snowstormManager;
}

public IEnumerable<Cie10MapResultViewModel> GetCie10MappedItems(string conceptId)
{
var lst = new List<Cie10MapResultViewModel>();

var cie10lst = _snowstormManager.RunQueryCie10MapRefset(conceptId);

//se seleccionan solo aquellos que tienen un MapTarget, es decir, un Mapeo Esistente.
cie10lst.Items = cie10lst.Items.Where(x => !string.IsNullOrWhiteSpace(x.additionalFields.mapTarget)).ToList();

//Customization para el formato de la codificacion de la DEIS
foreach (var item in cie10lst.Items)
{
if(item.additionalFields.mapTarget.Length == 3)
{
item.additionalFields.mapTarget += "X";
}
}

//Mapeo a nuestros ViewModels
var cie10Maplst = Mapper.Map<List<Cie10MapResultViewModel>>(cie10lst.Items);

//Se seleccionadn los distintos MApTargue para is a buscar en la DB
var cie102search = cie10Maplst.Select(x => x.MapTarget).Distinct();

//obtenidos de la DB
var cie10FromDbItems = CurrentContext.DataContext.Cie10.Where(x => cie102search.Contains(x.SubcategoriaId));

//por cada uno encontrado se le setea el texto de la SubcategoriaNombre y CategoriaNombre de la CIE10 esn Español
foreach (var item in cie10Maplst)
{
var dbitem = cie10FromDbItems.FirstOrDefault(x => x.SubcategoriaId == item.MapTarget);
if(dbitem != null)
{
item.SubcategoriaNombre = dbitem.SubcategoriaNombre;
item.CategoriaNombre = dbitem.CategoriaNombre;
}
}

return cie10Maplst;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,6 @@ public EvolucionProfile()
.ForMember(dest => dest.ProfesionalApellido, orig => orig.MapFrom(x => $"Dr. {x.CreatedUser.Apellido}"))
.ForMember(dest => dest.FechaEvolucion, orig => orig.MapFrom(x => x.CreatedDateTime.ToString("dd/MM/yyyy")));

CreateMap<Snowstorm.Model.Components.Item, ViewModel.Snomed.SnomedItem>()
.ForMember(dest => dest.ConceptId, orig => orig.MapFrom(x => x.ConceptId))
.ForMember(dest => dest.Description, orig => orig.MapFrom(x => x.pt.Term))
.ForMember(dest => dest.FSN, orig => orig.MapFrom(x => x.fsn.Term))
.ForMember(dest => dest.Language, orig => orig.MapFrom(x => x.pt.Lang));

CreateMap<Snowstorm.Model.Components.RefsetItem, ViewModel.Snomed.SnomedItem>()
.ForMember(dest => dest.ConceptId, orig => orig.MapFrom(x => x.referencedComponent.conceptId))
.ForMember(dest => dest.Description, orig => orig.MapFrom(x => x.referencedComponent.pt.Term))
.ForMember(dest => dest.FSN, orig => orig.MapFrom(x => x.referencedComponent.fsn.Term))
.ForMember(dest => dest.Language, orig => orig.MapFrom(x => x.referencedComponent.pt.Lang));

CreateMap<Entities.Evoluciones.EvolucionDiagnostico, ViewModel.Evoluciones.EvolucionDiagnosticoViewModel>();
CreateMap<Entities.Evoluciones.EvolucionMedicamento, ViewModel.Evoluciones.EvolucionMedicamentoViewModel>();
CreateMap<Entities.Evoluciones.EvolucionVacunaAplicacion, ViewModel.Evoluciones.EvolucionVacunaAplicacionViewModel>();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Msn.InteropDemo.ViewModel.Snomed;

namespace Msn.InteropDemo.AppServices.Implementation.Mapping.Profiles
{
public class SnowstormProfile : AutoMapper.Profile
{
public SnowstormProfile()
{
CreateMap<Snowstorm.Model.Components.Item, ViewModel.Snomed.SnomedItem>()
.ForMember(dest => dest.ConceptId, orig => orig.MapFrom(x => x.ConceptId))
.ForMember(dest => dest.Description, orig => orig.MapFrom(x => x.pt.Term))
.ForMember(dest => dest.FSN, orig => orig.MapFrom(x => x.fsn.Term))
.ForMember(dest => dest.Language, orig => orig.MapFrom(x => x.pt.Lang));

CreateMap<Snowstorm.Model.Components.RefsetItem, ViewModel.Snomed.SnomedItem>()
.ForMember(dest => dest.ConceptId, orig => orig.MapFrom(x => x.referencedComponent.conceptId))
.ForMember(dest => dest.Description, orig => orig.MapFrom(x => x.referencedComponent.pt.Term))
.ForMember(dest => dest.FSN, orig => orig.MapFrom(x => x.referencedComponent.fsn.Term))
.ForMember(dest => dest.Language, orig => orig.MapFrom(x => x.referencedComponent.pt.Lang));

CreateMap<Snowstorm.Model.Components.RefsetCie10MapItem, Cie10MapResultViewModel>()
.ForMember(dest => dest.ConceptId, orig => orig.MapFrom(x => x.referencedComponent.conceptId))
.ForMember(dest => dest.Description, orig => orig.MapFrom(x => x.referencedComponent.pt.Term))
.ForMember(dest => dest.FSN, orig => orig.MapFrom(x => x.referencedComponent.fsn.Term))
.ForMember(dest => dest.Language, orig => orig.MapFrom(x => x.referencedComponent.pt.Lang))
.ForMember(dest => dest.MapGroup, orig => orig.MapFrom(x => x.additionalFields.mapGroup))
.ForMember(dest => dest.MapPriority, orig => orig.MapFrom(x => x.additionalFields.mapPriority))
.ForMember(dest => dest.MapRule, orig => orig.MapFrom(x => x.additionalFields.mapRule))
.ForMember(dest => dest.MapAdvice, orig => orig.MapFrom(x => x.additionalFields.mapAdvice))
.ForMember(dest => dest.MapTarget, orig => orig.MapFrom(x => x.additionalFields.mapTarget.Replace(".", "")))
.ForMember(dest => dest.SubcategoriaId, orig => orig.MapFrom(x => x.additionalFields.mapTarget.Replace(".", "")));
}
}
}
7 changes: 7 additions & 0 deletions Msn.InteropDemo.AppServices/ICie10AppService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Msn.InteropDemo.AppServices
{
public interface ICie10AppService : Core.IGenericServiceReadOnly<Entities.Codificacion.Cie10>
{
System.Collections.Generic.IEnumerable<ViewModel.Snomed.Cie10MapResultViewModel> GetCie10MappedItems(string conceptId);
}
}
7 changes: 6 additions & 1 deletion Msn.InteropDemo.Common/Constants/DomainName.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@ namespace Msn.InteropDemo.Common.Constants
{
public sealed class DomainName
{
public static readonly DomainName LocalDomain = new DomainName { Value = "http://www.msal.gov.ar" };
public static readonly DomainName LocalDomain = new DomainName();
public static readonly DomainName FederadorPatientDomain = new DomainName { Value = "https://federador.msal.gob.ar/patient-id" };
public static readonly DomainName RenaperDniDomain = new DomainName { Value = "http://www.renaper.gob.ar/dni" };
public static readonly DomainName MinInteriorPassportDomain = new DomainName { Value = "http://www.mininterior.gob.ar/pas" };

public void SetValue(string domainName)
{
Value = domainName;
}

public string Value { get; private set; }

}
Expand Down
108 changes: 108 additions & 0 deletions Msn.InteropDemo.Common/Utils/Helpers/Cuit.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
using System;
using System.Text.RegularExpressions;

namespace Msn.InteropDemo.Common.Utils.Helpers
{
public static class Cuit
{
public static bool Validate(string cuit)
{
if (string.IsNullOrWhiteSpace(cuit))
{
return false;
}

cuit = cuit.Trim();
if (cuit.Length > 13) //no puede ser mayor que 13 con los guiones incluidos.
{
return false;
}

cuit = cuit.Replace("-", ""); // Le quito el guión
if (cuit.Length != 11)
{
return false;
}

var rg = new Regex("[A-Z_a-z]"); // Expresión regular para caracteres no válidos
if (rg.IsMatch(cuit))
{
// Tiene caracteres no válidos
return false;
}

var calculado = GetCuitVerificationDigit(cuit);
var digito = int.Parse(cuit.Substring(10));
return calculado == digito;
}

public static int GetCuitVerificationDigit(string cuit)
{
var mult = new[] { 5, 4, 3, 2, 7, 6, 5, 4, 3, 2 };
var nums = cuit.ToCharArray();
var total = 0;
for (var i = 0; i < mult.Length; i++)
{
total += int.Parse(nums[i].ToString()) * mult[i];
}
var resto = total % 11;
return resto == 0 ? 0 : resto == 1 ? 9 : 11 - resto;
}

public static string ToCleanFormat(string cuit)
{
if (cuit != null)
{
cuit = cuit.Trim(); //quito espacios
cuit = cuit.Replace("-", ""); // Le quito el guión
}
return cuit;
}

public static string ToUIFormat(long? cuit, bool mustValidate = false)
{
if(!cuit.HasValue)
{
return string.Empty;
}
if(cuit.Value == 0)
{
return string.Empty;
}

return ToUIFormat(cuit.ToString(), mustValidate);
}

public static string ToUIFormat(string cuit, bool mustValidate = false)
{
if (mustValidate && !Validate(cuit))
{
throw new ArgumentException("Número de CUIT incorrecto");
}

cuit = cuit.Trim(); //quito espacios
cuit = cuit.Replace("-", ""); // Le quito el guión si lo hubiera, posiblemente tenga solo uno.

//cuit = 20172874127

if (cuit.Length != 11)
{
return cuit;
}

var preCuit = cuit.Substring(0, 2) + "-";
//preCuit = 20-

preCuit += cuit.Substring(2, cuit.Length - 3) + "-";
//preCuit = 20-17287412-

preCuit += cuit.Substring(cuit.Length - 1);
//preCuit = 20-17287412-7

cuit = preCuit;

return cuit;
}

}
}
10 changes: 1 addition & 9 deletions Msn.InteropDemo.Data/Context/DataContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,6 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)

public DbSet<Entities.Evoluciones.EvolucionVacunaAplicacion> EvolucionVacunaAplicaciones { get; set; }










public DbSet<Entities.Codificacion.Cie10> Cie10 { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Msn.InteropDemo.Entities.Codificacion;

namespace Msn.InteropDemo.Data.EntitiesConfiguration.Codificacion
{
public class Cie10Configuration : IEntityTypeConfiguration<Entities.Codificacion.Cie10>
{
public void Configure(EntityTypeBuilder<Cie10> builder)
{
builder.HasKey(x => x.SubcategoriaId);

builder.Property(x => x.SubcategoriaId)
.ValueGeneratedNever()
.HasMaxLength(4)
.HasColumnType("char(4)")
.IsRequired(true)
.IsUnicode(false);

builder.Property(x => x.SubcategoriaNombre)
.HasMaxLength(300)
.IsRequired()
.IsUnicode();

builder.Property(x => x.CategoriaNombre)
.HasMaxLength(300)
.IsRequired()
.IsUnicode();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,20 @@ public void Configure(EntityTypeBuilder<Entities.Evoluciones.EvolucionDiagnostic
.IsUnicode()
.IsRequired();

builder.Property(x => x.Cie10SubcategoriaId)
.HasMaxLength(4)
.HasColumnType("char(4)")
.IsRequired(false)
.IsUnicode(false);

builder.Property(x => x.Cie10SubcategoriaNombre)
.HasMaxLength(300)
.IsRequired(false)
.IsUnicode();

builder.HasIndex(x => x.SctConceptId);

builder.HasIndex(x => x.Cie10SubcategoriaId);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ public void Configure(EntityTypeBuilder<SystemUser> builder)
.HasMaxLength(100)
.IsUnicode()
.IsRequired();

builder.Property(p => p.CUIT)
.IsRequired(false);
}
}
}
Loading

1 comment on commit aa03532

@mamorese-net
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Se realiza el Merge para la incorporación de cambios específicos.

Please sign in to comment.