diff --git a/MnsInteropDemo.sln b/MnsInteropDemo.sln index 36a1f23..8f9f125 100644 --- a/MnsInteropDemo.sln +++ b/MnsInteropDemo.sln @@ -52,7 +52,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Msn.InteropDemo.Snowstorm", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Msn.InteropDemo.Snowstorm.Expressions", "Msn.InteropDemo.Snowstorm.Expressions\Msn.InteropDemo.Snowstorm.Expressions.csproj", "{9B53B72E-74A0-4347-B3C0-F9FE9A9F5461}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Msn.InteropDemo.Communication", "Msn.InteropDemo.Communication\Msn.InteropDemo.Communication.csproj", "{319F5146-DE42-4007-B945-56F3A5E1B800}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Msn.InteropDemo.Communication", "Msn.InteropDemo.Communication\Msn.InteropDemo.Communication.csproj", "{319F5146-DE42-4007-B945-56F3A5E1B800}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Msn.InteropDemo.Dfa", "Msn.InteropDemo.Dfa\Msn.InteropDemo.Dfa.csproj", "{9140330A-D988-4A66-8E0B-C363BBA7596A}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -120,6 +122,10 @@ Global {319F5146-DE42-4007-B945-56F3A5E1B800}.Debug|Any CPU.Build.0 = Debug|Any CPU {319F5146-DE42-4007-B945-56F3A5E1B800}.Release|Any CPU.ActiveCfg = Release|Any CPU {319F5146-DE42-4007-B945-56F3A5E1B800}.Release|Any CPU.Build.0 = Release|Any CPU + {9140330A-D988-4A66-8E0B-C363BBA7596A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9140330A-D988-4A66-8E0B-C363BBA7596A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9140330A-D988-4A66-8E0B-C363BBA7596A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9140330A-D988-4A66-8E0B-C363BBA7596A}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -140,6 +146,7 @@ Global {ABF37951-4736-45F4-96D4-F21FE86BD7B3} = {0710DC47-8B52-459E-A34A-3D0AA50606B2} {9B53B72E-74A0-4347-B3C0-F9FE9A9F5461} = {0710DC47-8B52-459E-A34A-3D0AA50606B2} {319F5146-DE42-4007-B945-56F3A5E1B800} = {E0EFA8A1-D0D1-4097-A308-48CA1882AE4B} + {9140330A-D988-4A66-8E0B-C363BBA7596A} = {75047E25-9AA1-4691-A119-CD2A9505DBF9} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {D3168AB5-DFEF-4290-816E-538D42CB6424} diff --git a/Msn.InteropDemo.AppServices.Implementation/AppServices/Cie10AppService.cs b/Msn.InteropDemo.AppServices.Implementation/AppServices/Cie10AppService.cs index 9e2874e..186c40c 100644 --- a/Msn.InteropDemo.AppServices.Implementation/AppServices/Cie10AppService.cs +++ b/Msn.InteropDemo.AppServices.Implementation/AppServices/Cie10AppService.cs @@ -2,6 +2,7 @@ using Msn.InteropDemo.AppServices.Core; using Msn.InteropDemo.Snowstorm; using Msn.InteropDemo.ViewModel.Snomed; +using System; using System.Collections.Generic; using System.Linq; @@ -18,6 +19,18 @@ public Cie10AppService(ICurrentContext currentContext, { _snowstormManager = snowstormManager; } + + public IEnumerable GetCie10MappedItems(string conceptId, + string sexo, + int edad) + { + var lst = GetCie10MappedItems(conceptId); + var cie10Mapper = new Internal.SnomedToCie10Mapper(); + cie10Mapper.SetMapeoPreferido(lst, sexo, edad); + + return lst; + } + public IEnumerable GetCie10MappedItems(string conceptId) { @@ -25,7 +38,7 @@ public IEnumerable GetCie10MappedItems(string conceptId var cie10lst = _snowstormManager.RunQueryCie10MapRefset(conceptId); - //se seleccionan solo aquellos que tienen un MapTarget, es decir, un Mapeo Esistente. + //se seleccionan solo aquellos que tienen un MapTarget, es decir, un Mapeo Existente. cie10lst.Items = cie10lst.Items.Where(x => !string.IsNullOrWhiteSpace(x.additionalFields.mapTarget)).ToList(); //Customization para el formato de la codificacion de la DEIS @@ -37,10 +50,10 @@ public IEnumerable GetCie10MappedItems(string conceptId } } - //Mapeo a nuestros ViewModels + //Mapeo a nuestros ViewModels var cie10Maplst = Mapper.Map>(cie10lst.Items); - //Se seleccionadn los distintos MApTargue para is a buscar en la DB + //Se seleccionadn los distintos MapTarguet para is a buscar en la DB var cie102search = cie10Maplst.Select(x => x.MapTarget).Distinct(); //obtenidos de la DB @@ -55,7 +68,9 @@ public IEnumerable GetCie10MappedItems(string conceptId item.SubcategoriaNombre = dbitem.SubcategoriaNombre; item.CategoriaNombre = dbitem.CategoriaNombre; } - } + } + + cie10Maplst = cie10Maplst.OrderBy(x => x.MapGroup).ThenBy(x => x.MapPriority).ToList(); return cie10Maplst; } diff --git a/Msn.InteropDemo.AppServices.Implementation/AppServices/EvolucionAppService.cs b/Msn.InteropDemo.AppServices.Implementation/AppServices/EvolucionAppService.cs index 095a2a5..1cd3532 100644 --- a/Msn.InteropDemo.AppServices.Implementation/AppServices/EvolucionAppService.cs +++ b/Msn.InteropDemo.AppServices.Implementation/AppServices/EvolucionAppService.cs @@ -1,6 +1,7 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; using Msn.InteropDemo.AppServices.Core; +using Msn.InteropDemo.Entities.Evoluciones; using Msn.InteropDemo.Snowstorm; using Msn.InteropDemo.ViewModel.Evoluciones; using System; @@ -22,9 +23,39 @@ public EvolucionAppService(Snowstorm.ISnowstormManager snowstormManager, public EvolucionViewModel GetById(int evolucionId) { - var entity = GetById(criteria: x => x.Id == evolucionId, - includeProperties: "Diagnosticos,Medicamentos,Vacunas,CreatedUser"); - return entity; + var entity_old = GetById(criteria: x => x.Id == evolucionId, + includeProperties: "Diagnosticos.Cie10Mapeos,Medicamentos,Vacunas,CreatedUser"); + + var entity = Get(filter: x => x.Id == evolucionId, includeProperties: "Diagnosticos.Cie10Mapeos,Medicamentos,Vacunas,CreatedUser").First(); + + //conversion al nuevo formato de mapeo multiple + if (entity.Diagnosticos.Any(x => x.Cie10SubcategoriaId != null)) + { + foreach (var item in entity.Diagnosticos) + { + //si existe un mapeo de la vieja forma, lo paso a la forma nueva + if (!string.IsNullOrWhiteSpace(item.Cie10SubcategoriaId)) + { + item.Cie10Mapeos = new List + { + new EvolucionDiagnosticoCie10 + { + Cie10SubcategoriaId = item.Cie10SubcategoriaId, + Cie10SubcategoriaNombre = item.Cie10SubcategoriaNombre + } + }; + + item.Cie10SubcategoriaId = null; + item.Cie10SubcategoriaNombre = null; + }; + } + + CurrentContext.DataContext.SaveChanges(); + } + + var model = Mapper.Map(entity); + + return model; } public IEnumerable GetDiagnosticos(int evolucionId) diff --git a/Msn.InteropDemo.AppServices.Implementation/AppServices/PacienteAppService.cs b/Msn.InteropDemo.AppServices.Implementation/AppServices/PacienteAppService.cs index 9426a71..267f72f 100644 --- a/Msn.InteropDemo.AppServices.Implementation/AppServices/PacienteAppService.cs +++ b/Msn.InteropDemo.AppServices.Implementation/AppServices/PacienteAppService.cs @@ -53,7 +53,7 @@ public Common.OperationResults.OperationResult FederarPaciente(int pacienteId) } else { - op.AddError("El registro en el BUS noha devuelto resultados."); + op.AddError("El Federador no ha devuelto resultados."); } } diff --git a/Msn.InteropDemo.AppServices.Implementation/Internal/SnomedToCie10Mapper.cs b/Msn.InteropDemo.AppServices.Implementation/Internal/SnomedToCie10Mapper.cs new file mode 100644 index 0000000..93d07b8 --- /dev/null +++ b/Msn.InteropDemo.AppServices.Implementation/Internal/SnomedToCie10Mapper.cs @@ -0,0 +1,136 @@ +using Msn.InteropDemo.ViewModel.Snomed; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Msn.InteropDemo.AppServices.Implementation.Internal +{ + internal class SnomedToCie10Mapper + { + Lazy dfaComparizon; + Lazy dfaNumber; + Lazy matchCollector; + + public SnomedToCie10Mapper() + { + dfaComparizon = new Lazy(); + dfaNumber = new Lazy(); + matchCollector = new Lazy(); + } + + public void SetMapeoPreferido(IEnumerable items, + string sexo, + int edad) + { + var groups = from i in items + group i by i.MapGroup into newGroup + orderby newGroup.Key + select newGroup; + + foreach (var g in groups) + { + foreach (var item in g) + { + //Rancking por Sexo + SetRankingSexo(item, sexo); + + //Rancking por Edad + SetRankingEdad(item, edad); + } + + var maxRank = g.Max(x => x.RankingPreferido); + if((maxRank == 0) && (g.Count() > 1)) //ninguno item tiene Ranking en el Grupo + { + var ot = g.Where(x => x.MapRule.Contains("OTHERWISE TRUE")); + foreach (var item in ot) + { + item.RankingPreferido++; + } + + maxRank = 1; + } + + var preferidos = g.Where(x => x.RankingPreferido == maxRank); + + foreach (var item in preferidos) + { + item.EsMapeoPreferido = true; + } + } + } + + private void SetRankingSexo(Cie10MapResultViewModel item, string sexo) + { + if (((item.MapRule.Contains("248153007") && sexo == "M") || (item.MapRule.Contains("248152002") && sexo == "F"))) + { + item.RankingPreferido++; + } + } + + private void SetRankingEdad(Cie10MapResultViewModel item, int edad) + { + string ruleSimbol; + string ruleAge; + + if (item.MapRule.Contains("424144002")) + { + var textToParse = item.MapRule.Split('|')[2].ToCharArray(); + + matchCollector.Value.CollectorResult = string.Empty; + dfaComparizon.Value.CollectTokens(textToParse, matchCollector.Value); + ruleSimbol = matchCollector.Value.CollectorResult; + + matchCollector.Value.CollectorResult = string.Empty; + dfaNumber.Value.CollectTokens(textToParse, matchCollector.Value); + ruleAge = matchCollector.Value.CollectorResult; + + if(CompareEdad(ruleSimbol, ruleAge, edad)) + { + item.RankingPreferido++; + } + } + } + + private bool CompareEdad(string ruleSimbol, string ruleAge, int edad) + { + if (ruleSimbol is null) + { + throw new ArgumentNullException(nameof(ruleSimbol)); + } + + if (ruleAge is null) + { + throw new ArgumentNullException(nameof(ruleAge)); + } + + if (!int.TryParse(ruleAge, out var ruleEdad)) + { + throw new Exception($"No se pudo parsear la Edad del la Rule:{ruleAge}"); + } + if(ruleEdad >= 100) + { + ruleEdad = ruleEdad / 10; + } + + switch (ruleSimbol) + { + case "<": + return edad < ruleEdad; + case "<=": + return edad <= ruleEdad; + case "=": + return edad == ruleEdad; + case ">=": + return edad >= ruleEdad; + case ">": + return edad > ruleEdad; + case "!": + return edad != ruleEdad; + case "<>": + return edad != ruleEdad; + } + + return false; + } + } +} diff --git a/Msn.InteropDemo.AppServices.Implementation/Mapping/Profiles/EvolucionProfile.cs b/Msn.InteropDemo.AppServices.Implementation/Mapping/Profiles/EvolucionProfile.cs index cef25ba..8c3321a 100644 --- a/Msn.InteropDemo.AppServices.Implementation/Mapping/Profiles/EvolucionProfile.cs +++ b/Msn.InteropDemo.AppServices.Implementation/Mapping/Profiles/EvolucionProfile.cs @@ -27,6 +27,7 @@ public EvolucionProfile() .ForMember(dest => dest.FechaEvolucion, orig => orig.MapFrom(x => x.CreatedDateTime.ToString("dd/MM/yyyy"))); CreateMap(); + CreateMap(); CreateMap(); CreateMap(); /////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -35,6 +36,7 @@ public EvolucionProfile() /////////////////////////////////////////////////////////////////////////////////////////////////////// CreateMap(); CreateMap(); + CreateMap(); CreateMap(); CreateMap(); /////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/Msn.InteropDemo.AppServices.Implementation/Msn.InteropDemo.AppServices.Implementation.csproj b/Msn.InteropDemo.AppServices.Implementation/Msn.InteropDemo.AppServices.Implementation.csproj index 6dc5de8..c6bc592 100644 --- a/Msn.InteropDemo.AppServices.Implementation/Msn.InteropDemo.AppServices.Implementation.csproj +++ b/Msn.InteropDemo.AppServices.Implementation/Msn.InteropDemo.AppServices.Implementation.csproj @@ -15,6 +15,7 @@ + diff --git a/Msn.InteropDemo.AppServices/ICie10AppService.cs b/Msn.InteropDemo.AppServices/ICie10AppService.cs index 89715c0..b9fba60 100644 --- a/Msn.InteropDemo.AppServices/ICie10AppService.cs +++ b/Msn.InteropDemo.AppServices/ICie10AppService.cs @@ -1,7 +1,13 @@ -namespace Msn.InteropDemo.AppServices +using Msn.InteropDemo.ViewModel.Snomed; +using System.Collections.Generic; + +namespace Msn.InteropDemo.AppServices { public interface ICie10AppService : Core.IGenericServiceReadOnly { - System.Collections.Generic.IEnumerable GetCie10MappedItems(string conceptId); + IEnumerable GetCie10MappedItems(string conceptId); + IEnumerable GetCie10MappedItems(string conceptId, + string sexo, + int edad); } } diff --git a/Msn.InteropDemo.Data/DataInitialization/Initializer.cs b/Msn.InteropDemo.Data/DataInitialization/Initializer.cs index 569f8d2..b591ffd 100644 --- a/Msn.InteropDemo.Data/DataInitialization/Initializer.cs +++ b/Msn.InteropDemo.Data/DataInitialization/Initializer.cs @@ -39,6 +39,7 @@ public async Task SeedAsync() await SeedRoles(); await SeedDefaultAdminUser(); await SeedActivityTypeDescriptorsAsync(); + await SeedPacientesPrueba(); } catch (Exception ex) { @@ -46,6 +47,38 @@ public async Task SeedAsync() } } + private async Task SeedPacientesPrueba() + { + await InsertPacientePrueba("Matilde", 1111111, "F", 75); + await InsertPacientePrueba("Juan", 1111112, "M", 50); + await InsertPacientePrueba("Mateo", 1111113, "M", 17); + await InsertPacientePrueba("Valentina", 1111114, "F", 3); + } + + private async Task InsertPacientePrueba(string nombre, int nroDocumento, string sexo, int edad) + { + var apellido = "Prueba"; + + if (!_dataContext.Pacientes.Any(x => x.PrimerApellido == apellido + && x.PrimerNombre == nombre + && x.NroDocumento == nroDocumento)) + { + var p = new Paciente + { + PrimerApellido = apellido, + PrimerNombre = nombre, + TipoDocumentoId = 1, //DNI + NroDocumento = nroDocumento, + FechaNacimiento = DateTime.Today.AddYears(edad * (-1)), + Sexo = sexo, + CreatedUserId = "1" + }; + + _dataContext.Pacientes.Add(p); + await _dataContext.SaveChangesAsync(); + } + } + private async Task SeedRoles() { if (!_dataContext.Roles.Any()) diff --git a/Msn.InteropDemo.Data/EntitiesConfiguration/Evoluciones/EvolucionDiagnosticoCie10Configuration.cs b/Msn.InteropDemo.Data/EntitiesConfiguration/Evoluciones/EvolucionDiagnosticoCie10Configuration.cs new file mode 100644 index 0000000..4d32387 --- /dev/null +++ b/Msn.InteropDemo.Data/EntitiesConfiguration/Evoluciones/EvolucionDiagnosticoCie10Configuration.cs @@ -0,0 +1,22 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace Msn.InteropDemo.Data.EntitiesConfiguration.Pacientes +{ + public class EvolucionDiagnosticoCie10Configuration : IEntityTypeConfiguration + { + public void Configure(EntityTypeBuilder builder) + { + builder.Property(x => x.Cie10SubcategoriaId) + .HasMaxLength(4) + .HasColumnType("char(4)") + .IsRequired(false) + .IsUnicode(false); + + builder.Property(x => x.Cie10SubcategoriaNombre) + .HasMaxLength(300) + .IsRequired(false) + .IsUnicode(); + } + } +} diff --git a/Msn.InteropDemo.Data/Migrations/20190919234940_add_DiagnosticoCie10.Designer.cs b/Msn.InteropDemo.Data/Migrations/20190919234940_add_DiagnosticoCie10.Designer.cs new file mode 100644 index 0000000..613b4fc --- /dev/null +++ b/Msn.InteropDemo.Data/Migrations/20190919234940_add_DiagnosticoCie10.Designer.cs @@ -0,0 +1,673 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Msn.InteropDemo.Data.Context; + +namespace Msn.InteropDemo.Data.Migrations +{ + [DbContext(typeof(DataContext))] + [Migration("20190919234940_add_DiagnosticoCie10")] + partial class add_DiagnosticoCie10 + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "2.2.6-servicing-10079"); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken(); + + b.Property("Name") + .HasMaxLength(256); + + b.Property("NormalizedName") + .HasMaxLength(256); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasName("RoleNameIndex"); + + b.ToTable("AspNetRoles"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ClaimType"); + + b.Property("ClaimValue"); + + b.Property("RoleId") + .IsRequired(); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ClaimType"); + + b.Property("ClaimValue"); + + b.Property("UserId") + .IsRequired(); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider"); + + b.Property("ProviderKey"); + + b.Property("ProviderDisplayName"); + + b.Property("UserId") + .IsRequired(); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId"); + + b.Property("RoleId"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId"); + + b.Property("LoginProvider"); + + b.Property("Name"); + + b.Property("Value"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens"); + }); + + modelBuilder.Entity("Msn.InteropDemo.Entities.Activity.ActivityLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ActivityRequest") + .HasMaxLength(1000) + .IsUnicode(false); + + b.Property("ActivityRequestBody"); + + b.Property("ActivityRequestUI"); + + b.Property("ActivityResponse") + .HasMaxLength(1000) + .IsUnicode(false); + + b.Property("ActivityResponseBody"); + + b.Property("ActivityTypeDescriptorId"); + + b.Property("CreatedDateTime") + .HasColumnType("SmallDateTime"); + + b.Property("CreatedUserId") + .IsRequired(); + + b.Property("Enabled"); + + b.Property("RequestIsJson"); + + b.Property("RequestIsURL"); + + b.Property("ResponseIsJson"); + + b.Property("ResponseIsURL"); + + b.Property("RowVersion") + .IsConcurrencyToken() + .ValueGeneratedOnAddOrUpdate(); + + b.Property("SessionUserId") + .IsRequired() + .HasMaxLength(200) + .IsUnicode(false); + + b.Property("UpdatedDateTime") + .HasColumnType("SmallDateTime"); + + b.Property("UpdatedUserId"); + + b.HasKey("Id"); + + b.HasIndex("ActivityTypeDescriptorId"); + + b.HasIndex("CreatedDateTime"); + + b.HasIndex("CreatedUserId"); + + b.HasIndex("SessionUserId"); + + b.HasIndex("UpdatedUserId"); + + b.ToTable("ActivityLog"); + }); + + modelBuilder.Entity("Msn.InteropDemo.Entities.Activity.ActivityTypeDescriptor", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Enabled"); + + b.Property("Nombre") + .IsRequired() + .HasColumnType("varchar(50)") + .HasMaxLength(200) + .IsUnicode(false); + + b.Property("Orden"); + + b.HasKey("Id"); + + b.ToTable("ActivityTypeDescriptor"); + }); + + modelBuilder.Entity("Msn.InteropDemo.Entities.Codificacion.Cie10", b => + { + b.Property("SubcategoriaId") + .HasColumnType("char(4)") + .HasMaxLength(4) + .IsUnicode(false); + + b.Property("CategoriaNombre") + .IsRequired() + .HasMaxLength(300) + .IsUnicode(true); + + b.Property("SubcategoriaNombre") + .IsRequired() + .HasMaxLength(300) + .IsUnicode(true); + + b.HasKey("SubcategoriaId"); + + b.ToTable("Cie10"); + }); + + modelBuilder.Entity("Msn.InteropDemo.Entities.Evoluciones.Evolucion", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("CreatedDateTime") + .HasColumnType("SmallDateTime"); + + b.Property("CreatedUserId") + .IsRequired(); + + b.Property("Enabled"); + + b.Property("Observacion") + .HasMaxLength(500) + .IsUnicode(true); + + b.Property("PacienteId"); + + b.Property("RowVersion") + .IsConcurrencyToken() + .ValueGeneratedOnAddOrUpdate(); + + b.Property("UpdatedDateTime") + .HasColumnType("SmallDateTime"); + + b.Property("UpdatedUserId"); + + b.HasKey("Id"); + + b.HasIndex("CreatedDateTime"); + + b.HasIndex("CreatedUserId"); + + b.HasIndex("PacienteId"); + + b.HasIndex("UpdatedUserId"); + + b.ToTable("Evolucion"); + }); + + modelBuilder.Entity("Msn.InteropDemo.Entities.Evoluciones.EvolucionDiagnostico", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Cie10SubcategoriaId") + .HasColumnType("char(4)") + .HasMaxLength(4) + .IsUnicode(false); + + b.Property("Cie10SubcategoriaNombre") + .HasMaxLength(300) + .IsUnicode(true); + + b.Property("EvolucionId"); + + b.Property("SctConceptId") + .IsRequired() + .HasColumnType("numeric(18,0)"); + + b.Property("SctDescriptionTerm") + .IsRequired() + .HasMaxLength(500) + .IsUnicode(true); + + b.HasKey("Id"); + + b.HasIndex("Cie10SubcategoriaId"); + + b.HasIndex("EvolucionId"); + + b.HasIndex("SctConceptId"); + + b.ToTable("EvolucionDiagnostico"); + }); + + modelBuilder.Entity("Msn.InteropDemo.Entities.Evoluciones.EvolucionDiagnosticoCie10", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Cie10SubcategoriaId") + .HasColumnType("char(4)") + .HasMaxLength(4) + .IsUnicode(false); + + b.Property("Cie10SubcategoriaNombre") + .HasMaxLength(300) + .IsUnicode(true); + + b.Property("EvolucionDiagnosticoId"); + + b.HasKey("Id"); + + b.HasIndex("EvolucionDiagnosticoId"); + + b.ToTable("EvolucionDiagnosticoCie10"); + }); + + modelBuilder.Entity("Msn.InteropDemo.Entities.Evoluciones.EvolucionMedicamento", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("EvolucionId"); + + b.Property("SctConceptId") + .IsRequired() + .HasColumnType("numeric(18,0)"); + + b.Property("SctDescriptionTerm") + .IsRequired() + .HasMaxLength(500) + .IsUnicode(true); + + b.HasKey("Id"); + + b.HasIndex("EvolucionId"); + + b.HasIndex("SctConceptId"); + + b.ToTable("EvolucionMedicamento"); + }); + + modelBuilder.Entity("Msn.InteropDemo.Entities.Evoluciones.EvolucionVacunaAplicacion", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("EvolucionId"); + + b.Property("SctConceptId") + .IsRequired() + .HasColumnType("numeric(18,0)"); + + b.Property("SctDescriptionTerm") + .IsRequired() + .HasMaxLength(500) + .IsUnicode(true); + + b.HasKey("Id"); + + b.HasIndex("EvolucionId"); + + b.HasIndex("SctConceptId"); + + b.ToTable("EvolucionVacunaAplicacion"); + }); + + modelBuilder.Entity("Msn.InteropDemo.Entities.Identity.SystemUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AccessFailedCount"); + + b.Property("Apellido") + .IsRequired() + .HasMaxLength(100) + .IsUnicode(true); + + b.Property("CUIT"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken(); + + b.Property("Email") + .HasMaxLength(256); + + b.Property("EmailConfirmed"); + + b.Property("LockoutEnabled"); + + b.Property("LockoutEnd"); + + b.Property("Nombre") + .IsRequired() + .HasMaxLength(100) + .IsUnicode(true); + + b.Property("NormalizedEmail") + .HasMaxLength(256); + + b.Property("NormalizedUserName") + .HasMaxLength(256); + + b.Property("PasswordHash"); + + b.Property("PhoneNumber"); + + b.Property("PhoneNumberConfirmed"); + + b.Property("SecurityStamp"); + + b.Property("TwoFactorEnabled"); + + b.Property("UserName") + .HasMaxLength(256); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasName("UserNameIndex"); + + b.ToTable("AspNetUsers"); + }); + + modelBuilder.Entity("Msn.InteropDemo.Entities.Pacientes.Paciente", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("CreatedDateTime") + .HasColumnType("SmallDateTime"); + + b.Property("CreatedUserId") + .IsRequired(); + + b.Property("DomicilioCalle"); + + b.Property("DomicilioCalleAltura"); + + b.Property("DomicilioCodPostal"); + + b.Property("DomicilioDepto"); + + b.Property("DomicilioPiso"); + + b.Property("Email") + .HasMaxLength(100) + .IsUnicode(false); + + b.Property("Enabled"); + + b.Property("FechaNacimiento") + .HasColumnType("Date"); + + b.Property("FederadoDateTime") + .HasColumnType("SmallDateTime"); + + b.Property("FederadorId"); + + b.Property("NroDocumento"); + + b.Property("OtrosApellidos") + .HasMaxLength(50); + + b.Property("OtrosNombres") + .HasMaxLength(50); + + b.Property("PrimerApellido") + .IsRequired() + .HasMaxLength(50); + + b.Property("PrimerNombre") + .IsRequired() + .HasMaxLength(50); + + b.Property("RowVersion") + .IsConcurrencyToken() + .ValueGeneratedOnAddOrUpdate(); + + b.Property("Sexo") + .IsRequired() + .HasColumnType("char(1)"); + + b.Property("TipoDocumentoId"); + + b.Property("UpdatedDateTime") + .HasColumnType("SmallDateTime"); + + b.Property("UpdatedUserId"); + + b.HasKey("Id"); + + b.HasIndex("CreatedUserId"); + + b.HasIndex("TipoDocumentoId"); + + b.HasIndex("UpdatedUserId"); + + b.ToTable("Paciente"); + }); + + modelBuilder.Entity("Msn.InteropDemo.Entities.Pacientes.TipoDocumento", b => + { + b.Property("Id"); + + b.Property("Enabled"); + + b.Property("Nombre") + .IsRequired() + .HasColumnType("varchar(50)") + .HasMaxLength(50); + + b.Property("Orden"); + + b.HasKey("Id"); + + b.ToTable("TipoDocumento"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("Msn.InteropDemo.Entities.Identity.SystemUser") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("Msn.InteropDemo.Entities.Identity.SystemUser") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("Msn.InteropDemo.Entities.Identity.SystemUser") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("Msn.InteropDemo.Entities.Identity.SystemUser") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Msn.InteropDemo.Entities.Activity.ActivityLog", b => + { + b.HasOne("Msn.InteropDemo.Entities.Activity.ActivityTypeDescriptor", "ActivityTypeDescriptor") + .WithMany() + .HasForeignKey("ActivityTypeDescriptorId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Msn.InteropDemo.Entities.Identity.SystemUser", "CreatedUser") + .WithMany() + .HasForeignKey("CreatedUserId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Msn.InteropDemo.Entities.Identity.SystemUser", "UpdatedUser") + .WithMany() + .HasForeignKey("UpdatedUserId"); + }); + + modelBuilder.Entity("Msn.InteropDemo.Entities.Evoluciones.Evolucion", b => + { + b.HasOne("Msn.InteropDemo.Entities.Identity.SystemUser", "CreatedUser") + .WithMany() + .HasForeignKey("CreatedUserId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Msn.InteropDemo.Entities.Pacientes.Paciente", "Paciente") + .WithMany() + .HasForeignKey("PacienteId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Msn.InteropDemo.Entities.Identity.SystemUser", "UpdatedUser") + .WithMany() + .HasForeignKey("UpdatedUserId"); + }); + + modelBuilder.Entity("Msn.InteropDemo.Entities.Evoluciones.EvolucionDiagnostico", b => + { + b.HasOne("Msn.InteropDemo.Entities.Evoluciones.Evolucion", "Evolucion") + .WithMany("Diagnosticos") + .HasForeignKey("EvolucionId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("Msn.InteropDemo.Entities.Evoluciones.EvolucionDiagnosticoCie10", b => + { + b.HasOne("Msn.InteropDemo.Entities.Evoluciones.EvolucionDiagnostico", "EvolucionDiagnostico") + .WithMany("Cie10Mapeos") + .HasForeignKey("EvolucionDiagnosticoId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("Msn.InteropDemo.Entities.Evoluciones.EvolucionMedicamento", b => + { + b.HasOne("Msn.InteropDemo.Entities.Evoluciones.Evolucion", "Evolucion") + .WithMany("Medicamentos") + .HasForeignKey("EvolucionId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("Msn.InteropDemo.Entities.Evoluciones.EvolucionVacunaAplicacion", b => + { + b.HasOne("Msn.InteropDemo.Entities.Evoluciones.Evolucion", "Evolucion") + .WithMany("Vacunas") + .HasForeignKey("EvolucionId") + .OnDelete(DeleteBehavior.Restrict); + }); + + modelBuilder.Entity("Msn.InteropDemo.Entities.Pacientes.Paciente", b => + { + b.HasOne("Msn.InteropDemo.Entities.Identity.SystemUser", "CreatedUser") + .WithMany() + .HasForeignKey("CreatedUserId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Msn.InteropDemo.Entities.Pacientes.TipoDocumento", "TipoDocumento") + .WithMany() + .HasForeignKey("TipoDocumentoId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Msn.InteropDemo.Entities.Identity.SystemUser", "UpdatedUser") + .WithMany() + .HasForeignKey("UpdatedUserId"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Msn.InteropDemo.Data/Migrations/20190919234940_add_DiagnosticoCie10.cs b/Msn.InteropDemo.Data/Migrations/20190919234940_add_DiagnosticoCie10.cs new file mode 100644 index 0000000..d9b9b5c --- /dev/null +++ b/Msn.InteropDemo.Data/Migrations/20190919234940_add_DiagnosticoCie10.cs @@ -0,0 +1,42 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +namespace Msn.InteropDemo.Data.Migrations +{ + public partial class add_DiagnosticoCie10 : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "EvolucionDiagnosticoCie10", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("Sqlite:Autoincrement", true), + EvolucionDiagnosticoId = table.Column(nullable: false), + Cie10SubcategoriaId = table.Column(type: "char(4)", unicode: false, maxLength: 4, nullable: true), + Cie10SubcategoriaNombre = table.Column(maxLength: 300, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_EvolucionDiagnosticoCie10", x => x.Id); + table.ForeignKey( + name: "FK_EvolucionDiagnosticoCie10_EvolucionDiagnostico_EvolucionDiagnosticoId", + column: x => x.EvolucionDiagnosticoId, + principalTable: "EvolucionDiagnostico", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateIndex( + name: "IX_EvolucionDiagnosticoCie10_EvolucionDiagnosticoId", + table: "EvolucionDiagnosticoCie10", + column: "EvolucionDiagnosticoId"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "EvolucionDiagnosticoCie10"); + } + } +} diff --git a/Msn.InteropDemo.Data/Migrations/DataContextModelSnapshot.cs b/Msn.InteropDemo.Data/Migrations/DataContextModelSnapshot.cs index 1c1b127..cf891be 100644 --- a/Msn.InteropDemo.Data/Migrations/DataContextModelSnapshot.cs +++ b/Msn.InteropDemo.Data/Migrations/DataContextModelSnapshot.cs @@ -308,6 +308,29 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("EvolucionDiagnostico"); }); + modelBuilder.Entity("Msn.InteropDemo.Entities.Evoluciones.EvolucionDiagnosticoCie10", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Cie10SubcategoriaId") + .HasColumnType("char(4)") + .HasMaxLength(4) + .IsUnicode(false); + + b.Property("Cie10SubcategoriaNombre") + .HasMaxLength(300) + .IsUnicode(true); + + b.Property("EvolucionDiagnosticoId"); + + b.HasKey("Id"); + + b.HasIndex("EvolucionDiagnosticoId"); + + b.ToTable("EvolucionDiagnosticoCie10"); + }); + modelBuilder.Entity("Msn.InteropDemo.Entities.Evoluciones.EvolucionMedicamento", b => { b.Property("Id") @@ -602,6 +625,14 @@ protected override void BuildModel(ModelBuilder modelBuilder) .OnDelete(DeleteBehavior.Restrict); }); + modelBuilder.Entity("Msn.InteropDemo.Entities.Evoluciones.EvolucionDiagnosticoCie10", b => + { + b.HasOne("Msn.InteropDemo.Entities.Evoluciones.EvolucionDiagnostico", "EvolucionDiagnostico") + .WithMany("Cie10Mapeos") + .HasForeignKey("EvolucionDiagnosticoId") + .OnDelete(DeleteBehavior.Restrict); + }); + modelBuilder.Entity("Msn.InteropDemo.Entities.Evoluciones.EvolucionMedicamento", b => { b.HasOne("Msn.InteropDemo.Entities.Evoluciones.Evolucion", "Evolucion") diff --git a/Msn.InteropDemo.Dfa/Base/DFA.cs b/Msn.InteropDemo.Dfa/Base/DFA.cs new file mode 100644 index 0000000..e50fa9c --- /dev/null +++ b/Msn.InteropDemo.Dfa/Base/DFA.cs @@ -0,0 +1,83 @@ +using Msn.InteropDemo.Dfa.Notifications; +using System.Collections.Generic; + +namespace Msn.InteropDemo.Dfa.Base +{ + /// + /// DFA = Deterministic Finite Automata + /// + public abstract class Dfa + { + public Dfa() { + States = new List(); + } + + public Dfa(List states) + { + States = states; + } + + public List States { get; protected set; } + + /// + /// Recolecta los Tokens validos + /// + /// caracteres a evaluar por el automata + /// Objeto al cual se llamara en cada coincidencia de la Sintaxis + /// True si cumplio con la sintaxis, caso contrario False + public virtual bool CollectTokens(char[] caracters, IMatchNotificator matchNotificator) + { + var currentState = States[0]; + StateBase nextState = null; + foreach (var c in caracters) + { + nextState = CollectToken(currentState, c, matchNotificator); + if (nextState != null) + { + currentState = nextState; + } + + //nextState = currentState.GetNextState(c); + //if (nextState != null) + //{ + // matchNotificator.Notificate(c); + // currentState = nextState; + //} + } + + return currentState != null && currentState.IsFinalState; + //return nextState != null && nextState.IsFinalState; + } + + public virtual StateBase CollectToken(StateBase currentState, char c, IMatchNotificator matchNotificator) + { + var nextState = currentState.GetNextState(c); + if (nextState != null) + { + matchNotificator.Notificate(c); + } + + return nextState; + } + + /// + /// Valida si se cumple con la Sintaxis + /// + /// caracteres a evaluar por el automata + /// True si cumplio con la sintaxis, caso contrario False + public virtual bool Validate(char[] caracters) + { + var nextState = States[0]; + foreach (var c in caracters) + { + nextState = nextState.GetNextState(c); + if (nextState == null) + { + return false; + } + } + + return nextState != null && nextState.IsFinalState; + } + } +} diff --git a/Msn.InteropDemo.Dfa/Base/StateBase.cs b/Msn.InteropDemo.Dfa/Base/StateBase.cs new file mode 100644 index 0000000..a9a7ab1 --- /dev/null +++ b/Msn.InteropDemo.Dfa/Base/StateBase.cs @@ -0,0 +1,44 @@ +using Msn.InteropDemo.Dfa.Components; +using System.Collections.Generic; +using System.Linq; + +namespace Msn.InteropDemo.Dfa.Base +{ + public abstract class StateBase + { + private List transitions = new List(); + + public StateBase(string stateName, int stateIndex, bool isFinalState = false) + { + StateName = stateName; + StateIndex = stateIndex; + IsFinalState = isFinalState; + } + + public string StateName { get; set; } + public int StateIndex { get; set; } + + public bool IsFinalState { get; set; } + + public bool IsErrorState { get; protected set; } + + public virtual void AddTransition(Transition transition) + { + transition.FromState = this; + transitions.Add(transition); + } + + public virtual StateBase GetNextState(char token) + { + var trans = transitions.FirstOrDefault(x => x.Token == token); + if (trans != null) + { + return trans.ToState; + } + + return null; + } + + + } +} diff --git a/Msn.InteropDemo.Dfa/Components/ErrorState.cs b/Msn.InteropDemo.Dfa/Components/ErrorState.cs new file mode 100644 index 0000000..863f55a --- /dev/null +++ b/Msn.InteropDemo.Dfa/Components/ErrorState.cs @@ -0,0 +1,14 @@ +using Msn.InteropDemo.Dfa.Base; + +namespace Msn.InteropDemo.Dfa.Components +{ + public class ErrorState : StateBase + { + public ErrorState(string stateName, int stateIndex) : base(stateName, stateIndex, false) + { + IsErrorState = true; + } + + public override StateBase GetNextState(char token) => this; + } +} diff --git a/Msn.InteropDemo.Dfa/Components/State.cs b/Msn.InteropDemo.Dfa/Components/State.cs new file mode 100644 index 0000000..2f92776 --- /dev/null +++ b/Msn.InteropDemo.Dfa/Components/State.cs @@ -0,0 +1,31 @@ +using Msn.InteropDemo.Dfa.Base; + +namespace Msn.InteropDemo.Dfa.Components +{ + public class State : StateBase + { + + + public State(string stateName, int stateIndex, bool isFinalState = false) : + base(stateName, stateIndex, isFinalState) + { + } + + //override public StateBase GetNextState(char token) + //{ + // var trans = transitions.FirstOrDefault(x => x.Token == token); + // if (trans != null) + // { + // return trans.ToState; + // } + + // return this; + + //} + + + + + + } +} diff --git a/Msn.InteropDemo.Dfa/Components/Transition.cs b/Msn.InteropDemo.Dfa/Components/Transition.cs new file mode 100644 index 0000000..5c491ad --- /dev/null +++ b/Msn.InteropDemo.Dfa/Components/Transition.cs @@ -0,0 +1,17 @@ +using Msn.InteropDemo.Dfa.Base; + +namespace Msn.InteropDemo.Dfa.Components +{ + public class Transition + { + public Transition(char token, StateBase toState) + { + Token = token; + ToState = toState; + } + + public StateBase FromState { get; set; } + public char Token { get; } + public StateBase ToState { get; set; } + } +} diff --git a/Msn.InteropDemo.Dfa/Dfas/ComparizonDfa.cs b/Msn.InteropDemo.Dfa/Dfas/ComparizonDfa.cs new file mode 100644 index 0000000..0c1323d --- /dev/null +++ b/Msn.InteropDemo.Dfa/Dfas/ComparizonDfa.cs @@ -0,0 +1,31 @@ +using Msn.InteropDemo.Dfa.Base; +using Msn.InteropDemo.Dfa.Components; +using System.Collections.Generic; + +namespace Msn.InteropDemo.Dfa.Dfas +{ + /// + /// Autómata finito para los simbolos de comparación + /// + public class ComparizonDfa : Base.Dfa + { + private List states; + + public ComparizonDfa() + { + var s0 = new State("State 0 Inicio", 0, true); + + states = new List + { + s0 + }; + + s0.AddTransition(new Transition('<', s0)); + s0.AddTransition(new Transition('=', s0)); + s0.AddTransition(new Transition('>', s0)); + s0.AddTransition(new Transition('!', s0)); + + States = states; + } + } +} diff --git a/Msn.InteropDemo.Dfa/Dfas/IntegerNumberDfa.cs b/Msn.InteropDemo.Dfa/Dfas/IntegerNumberDfa.cs new file mode 100644 index 0000000..28c63ac --- /dev/null +++ b/Msn.InteropDemo.Dfa/Dfas/IntegerNumberDfa.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Msn.InteropDemo.Dfa.Dfas +{ + public class IntegerNumberDfa : Base.Dfa + { + public IntegerNumberDfa() + { + var s0 = new Components.State("Numeros Inicial - Final", 0, true); + //var s1 = new Components.ErrorState("Punto", 1); + //var s2 = new Components.ErrorState("Comma", 2); + //var s3 = new Components.ErrorState("Espacio", 2); + + s0.AddTransition(new Components.Transition('0', s0)); + s0.AddTransition(new Components.Transition('1', s0)); + s0.AddTransition(new Components.Transition('2', s0)); + s0.AddTransition(new Components.Transition('3', s0)); + s0.AddTransition(new Components.Transition('4', s0)); + s0.AddTransition(new Components.Transition('5', s0)); + s0.AddTransition(new Components.Transition('6', s0)); + s0.AddTransition(new Components.Transition('7', s0)); + s0.AddTransition(new Components.Transition('8', s0)); + s0.AddTransition(new Components.Transition('9', s0)); + + //s0.AddTransition(new Components.Transition('.', s1)); + //s0.AddTransition(new Components.Transition(',', s2)); + //s0.AddTransition(new Components.Transition(' ', s3)); + + States.Add(s0); + //States.Add(s1); + //States.Add(s2); + //States.Add(s3); + } + } +} diff --git a/Msn.InteropDemo.Dfa/Dfas/NumberDfa.cs b/Msn.InteropDemo.Dfa/Dfas/NumberDfa.cs new file mode 100644 index 0000000..ca85c68 --- /dev/null +++ b/Msn.InteropDemo.Dfa/Dfas/NumberDfa.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Msn.InteropDemo.Dfa.Dfas +{ + public class NumberDfa : Base.Dfa + { + public NumberDfa() + { + var s0 = new Components.State("Numeros Inicial - Final", 0, true); + var s1 = new Components.State("Punto Separador decimales", 1, false); + var s2 = new Components.State("Numeros - Final", 1, false); + + s0.AddTransition(new Components.Transition('0', s0)); + s0.AddTransition(new Components.Transition('1', s0)); + s0.AddTransition(new Components.Transition('2', s0)); + s0.AddTransition(new Components.Transition('3', s0)); + s0.AddTransition(new Components.Transition('4', s0)); + s0.AddTransition(new Components.Transition('5', s0)); + s0.AddTransition(new Components.Transition('6', s0)); + s0.AddTransition(new Components.Transition('7', s0)); + s0.AddTransition(new Components.Transition('8', s0)); + s0.AddTransition(new Components.Transition('9', s0)); + s0.AddTransition(new Components.Transition('.', s1)); + + s1.AddTransition(new Components.Transition('0', s2)); + s1.AddTransition(new Components.Transition('1', s2)); + s1.AddTransition(new Components.Transition('2', s2)); + s1.AddTransition(new Components.Transition('3', s2)); + s1.AddTransition(new Components.Transition('4', s2)); + s1.AddTransition(new Components.Transition('5', s2)); + s1.AddTransition(new Components.Transition('6', s2)); + s1.AddTransition(new Components.Transition('7', s2)); + s1.AddTransition(new Components.Transition('8', s2)); + s1.AddTransition(new Components.Transition('9', s2)); + + s2.AddTransition(new Components.Transition('0', s2)); + s2.AddTransition(new Components.Transition('1', s2)); + s2.AddTransition(new Components.Transition('2', s2)); + s2.AddTransition(new Components.Transition('3', s2)); + s2.AddTransition(new Components.Transition('4', s2)); + s2.AddTransition(new Components.Transition('5', s2)); + s2.AddTransition(new Components.Transition('6', s2)); + s2.AddTransition(new Components.Transition('7', s2)); + s2.AddTransition(new Components.Transition('8', s2)); + s2.AddTransition(new Components.Transition('9', s2)); + + States.Add(s0); + States.Add(s1); + States.Add(s2); + } + } +} diff --git a/Msn.InteropDemo.Dfa/Msn.InteropDemo.Dfa.csproj b/Msn.InteropDemo.Dfa/Msn.InteropDemo.Dfa.csproj new file mode 100644 index 0000000..2bd48b2 --- /dev/null +++ b/Msn.InteropDemo.Dfa/Msn.InteropDemo.Dfa.csproj @@ -0,0 +1,7 @@ + + + + netcoreapp2.2 + + + diff --git a/Msn.InteropDemo.Dfa/Notifications/IMatchNotificator.cs b/Msn.InteropDemo.Dfa/Notifications/IMatchNotificator.cs new file mode 100644 index 0000000..cf46c98 --- /dev/null +++ b/Msn.InteropDemo.Dfa/Notifications/IMatchNotificator.cs @@ -0,0 +1,7 @@ +namespace Msn.InteropDemo.Dfa.Notifications +{ + public interface IMatchNotificator + { + void Notificate(char c); + } +} diff --git a/Msn.InteropDemo.Dfa/Notifications/MatchCollector.cs b/Msn.InteropDemo.Dfa/Notifications/MatchCollector.cs new file mode 100644 index 0000000..1c9297c --- /dev/null +++ b/Msn.InteropDemo.Dfa/Notifications/MatchCollector.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Msn.InteropDemo.Dfa.Notifications +{ + public class MatchCollector : IMatchNotificator + { + public void Notificate(char c) + { + CollectorResult += c; + } + + public string CollectorResult { get; set; } + + + } +} diff --git a/Msn.InteropDemo.Entities/Evoluciones/EvolucionDiagnostico.cs b/Msn.InteropDemo.Entities/Evoluciones/EvolucionDiagnostico.cs index 0096036..fd1d119 100644 --- a/Msn.InteropDemo.Entities/Evoluciones/EvolucionDiagnostico.cs +++ b/Msn.InteropDemo.Entities/Evoluciones/EvolucionDiagnostico.cs @@ -1,4 +1,6 @@ -namespace Msn.InteropDemo.Entities.Evoluciones +using System.Collections.Generic; + +namespace Msn.InteropDemo.Entities.Evoluciones { public class EvolucionDiagnostico { @@ -15,5 +17,7 @@ public class EvolucionDiagnostico public string Cie10SubcategoriaId { get; set; } public string Cie10SubcategoriaNombre { get; set; } + + public ICollection Cie10Mapeos { get; set; } } } diff --git a/Msn.InteropDemo.Entities/Evoluciones/EvolucionDiagnosticoCie10.cs b/Msn.InteropDemo.Entities/Evoluciones/EvolucionDiagnosticoCie10.cs new file mode 100644 index 0000000..740d857 --- /dev/null +++ b/Msn.InteropDemo.Entities/Evoluciones/EvolucionDiagnosticoCie10.cs @@ -0,0 +1,15 @@ +namespace Msn.InteropDemo.Entities.Evoluciones +{ + public class EvolucionDiagnosticoCie10 + { + public int Id { get; set; } + + public int EvolucionDiagnosticoId { get; set; } + + public EvolucionDiagnostico EvolucionDiagnostico { get; set; } + + public string Cie10SubcategoriaId { get; set; } + + public string Cie10SubcategoriaNombre { get; set; } + } +} diff --git a/Msn.InteropDemo.Fhir.ConsoleTest/Msn.InteropDemo.Fhir.ConsoleTest.csproj b/Msn.InteropDemo.Fhir.ConsoleTest/Msn.InteropDemo.Fhir.ConsoleTest.csproj index 6c3e622..7598e1c 100644 --- a/Msn.InteropDemo.Fhir.ConsoleTest/Msn.InteropDemo.Fhir.ConsoleTest.csproj +++ b/Msn.InteropDemo.Fhir.ConsoleTest/Msn.InteropDemo.Fhir.ConsoleTest.csproj @@ -23,7 +23,9 @@ + + diff --git a/Msn.InteropDemo.Fhir.ConsoleTest/Program.cs b/Msn.InteropDemo.Fhir.ConsoleTest/Program.cs index a0dd98d..743c3d9 100644 --- a/Msn.InteropDemo.Fhir.ConsoleTest/Program.cs +++ b/Msn.InteropDemo.Fhir.ConsoleTest/Program.cs @@ -1,5 +1,4 @@ -using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using Msn.InteropDemo.Fhir.ConsoleTest.Mock; @@ -48,7 +47,9 @@ static void Main(string[] args) //ShowPatient("1982708"); //TestExpressionAppService(); - TestCie10Mapping(); + //TestCie10Mapping(); + + TestAutomataFinito(); } catch (Exception ex) @@ -61,6 +62,18 @@ static void Main(string[] args) } + public static void TestAutomataFinito() + { + string simbolo = " IFA <= 15 years"; + //string simbolo = "<="; + var af = new Dfa.Dfas.NumberDfa(); + var collector = new Msn.InteropDemo.Dfa.Notifications.MatchCollector(); + + var results = af.CollectTokens(simbolo.ToCharArray(), collector); + + //var results = af.Validate(simbolo.ToCharArray()); + } + private static void TestCie10Mapping() { var service = _serviceProvider.GetService(); diff --git a/Msn.InteropDemo.ViewModel/Evoluciones/EvolucionDiagnosticoCie10ViewModel.cs b/Msn.InteropDemo.ViewModel/Evoluciones/EvolucionDiagnosticoCie10ViewModel.cs new file mode 100644 index 0000000..174efd1 --- /dev/null +++ b/Msn.InteropDemo.ViewModel/Evoluciones/EvolucionDiagnosticoCie10ViewModel.cs @@ -0,0 +1,14 @@ + +namespace Msn.InteropDemo.ViewModel.Evoluciones +{ + public class EvolucionDiagnosticoCie10ViewModel + { + public int Id { get; set; } + + public int EvolucionDiagnosticoId { get; set; } + + public string Cie10SubcategoriaId { get; set; } + + public string Cie10SubcategoriaNombre { get; set; } + } +} diff --git a/Msn.InteropDemo.ViewModel/Evoluciones/EvolucionDiagnosticoViewModel.cs b/Msn.InteropDemo.ViewModel/Evoluciones/EvolucionDiagnosticoViewModel.cs index 9eaf8ea..62ad2e5 100644 --- a/Msn.InteropDemo.ViewModel/Evoluciones/EvolucionDiagnosticoViewModel.cs +++ b/Msn.InteropDemo.ViewModel/Evoluciones/EvolucionDiagnosticoViewModel.cs @@ -1,4 +1,6 @@  +using System.Collections.Generic; + namespace Msn.InteropDemo.ViewModel.Evoluciones { public class EvolucionDiagnosticoViewModel @@ -16,5 +18,7 @@ public class EvolucionDiagnosticoViewModel public string Cie10SubcategoriaId { get; set; } public string Cie10SubcategoriaNombre { get; set; } + + public List Cie10Mapeos { get; set; } } } diff --git a/Msn.InteropDemo.ViewModel/Snomed/Cie10MapResultViewModel.cs b/Msn.InteropDemo.ViewModel/Snomed/Cie10MapResultViewModel.cs index 8a28636..47dc6e1 100644 --- a/Msn.InteropDemo.ViewModel/Snomed/Cie10MapResultViewModel.cs +++ b/Msn.InteropDemo.ViewModel/Snomed/Cie10MapResultViewModel.cs @@ -18,5 +18,7 @@ public class Cie10MapResultViewModel public int MapPriority { get; set; } public string MapRule { get; set; } public string MapTarget { get; set; } + public bool EsMapeoPreferido { get; set; } + public int RankingPreferido { get; set; } } } diff --git a/Msn.InteropDemo.Web/Areas/Identity/Pages/Account/Register.cshtml b/Msn.InteropDemo.Web/Areas/Identity/Pages/Account/Register.cshtml index c569af5..488bb99 100644 --- a/Msn.InteropDemo.Web/Areas/Identity/Pages/Account/Register.cshtml +++ b/Msn.InteropDemo.Web/Areas/Identity/Pages/Account/Register.cshtml @@ -20,27 +20,35 @@
- +
- +
+ + +
+ +
+ +
- +
- - +
@@ -51,27 +59,27 @@
-
- +
+
-
- +
+
-
- +
+
-
- +
+
diff --git a/Msn.InteropDemo.Web/Areas/Identity/Pages/Account/Register.cshtml.cs b/Msn.InteropDemo.Web/Areas/Identity/Pages/Account/Register.cshtml.cs index 9fefba6..06b6e49 100644 --- a/Msn.InteropDemo.Web/Areas/Identity/Pages/Account/Register.cshtml.cs +++ b/Msn.InteropDemo.Web/Areas/Identity/Pages/Account/Register.cshtml.cs @@ -42,7 +42,7 @@ public class InputModel { [Required(ErrorMessage = "La {0} es requerida.")] [EmailAddress(ErrorMessage = "Debe ingresar una {0} válida." )] - [Display(Name = "Casila de Correo")] + [Display(Name = "Casilla de Correo")] public string Email { get; set; } [Required(ErrorMessage = "El {0} es requerido")] diff --git a/Msn.InteropDemo.Web/Areas/Seguimiento/Controllers/EvolucionarController.cs b/Msn.InteropDemo.Web/Areas/Seguimiento/Controllers/EvolucionarController.cs index b0e89bb..294ac89 100644 --- a/Msn.InteropDemo.Web/Areas/Seguimiento/Controllers/EvolucionarController.cs +++ b/Msn.InteropDemo.Web/Areas/Seguimiento/Controllers/EvolucionarController.cs @@ -13,23 +13,19 @@ namespace Msn.InteropDemo.Web.Areas.Seguimiento.Controllers [Authorize] public class EvolucionarController : Web.Controllers.Base.ControllerBase { - private readonly IPacienteAppService _pacienteAppService; private readonly IEvolucionAppService _evolucionAppService; private readonly ICie10AppService _cie10AppService; - private readonly ISelectListHelper _selectListHelper; private readonly ILogger _logger; - public EvolucionarController(IPacienteAppService pacienteAppService, + public EvolucionarController(IPacienteAppService pacienteAppService, IEvolucionAppService evolucionAppService, ICie10AppService cie10AppService, ISelectListHelper selectListHelper, ILogger logger ) { - _pacienteAppService = pacienteAppService; _evolucionAppService = evolucionAppService; _cie10AppService = cie10AppService; - _selectListHelper = selectListHelper; _logger = logger; } // GET: Evolucionar @@ -44,9 +40,9 @@ public ActionResult Index() public ActionResult EvolucionarPaciente(int id) { var model = _evolucionAppService.GetEvolucionesHisto(id); - if(model.Items.Any()) + if (model.Items.Any()) { - model.Items = model.Items.OrderByDescending(x => x.FechaEvolucion).ToList(); + model.Items = model.Items.OrderByDescending(x => x.CreatedDateTime).ToList(); model.PredefEvolucionId = model.Items[0].Id; } @@ -58,7 +54,7 @@ public JsonResult GetEvolucionListMenu(int pacienteId) try { var model = _evolucionAppService.GetEvolucionHistoDates(pacienteId); - if(model.Any()) + if (model.Any()) { model[0].Active = "active"; } @@ -94,7 +90,7 @@ public JsonResult SearchByExpressionTerm(string expression, string term) var items = _evolucionAppService.SearchSnowstormByExpressionTerm(expression, term) .ToList(); - if(items.Any()) + if (items.Any()) { table = this.RenderViewToStringAsync("Partials/_GridSnowstormSearchResult", items).Result; } @@ -129,20 +125,25 @@ public JsonResult SearchHallazgos(string term) } } - public JsonResult GetMapeoCie10(string conceptId) + [HttpPost] + [AutoValidateAntiforgeryToken] + public JsonResult GetMapeoCie10(string conceptId, string sexo, int edad) { try { - var lstitems = _cie10AppService.GetCie10MappedItems(conceptId); + var lstitems = _cie10AppService.GetCie10MappedItems(conceptId, sexo, edad); - //TODO: Modificar con la implementacion del modal para seleccion multiple - if(lstitems.Any()) + if(lstitems.Count() == 1) + { + return new JsonResult(new { success = true, item = lstitems.First(), count = lstitems.Count()}) { StatusCode = 200 }; + } + else if (lstitems.Count() > 1) { - var item = lstitems.ToList()[0]; - return new JsonResult(new { success = true, item }) { StatusCode = 200 }; + var table = this.RenderViewToStringAsync("Partials/_GridMapeoCie10", lstitems).Result; + return new JsonResult(new { success = true, table, count = lstitems.Count() }) { StatusCode = 200 }; } - return new JsonResult(new { success = false }) { StatusCode = 200 }; + return new JsonResult(new { success = false, count = 0 }) { StatusCode = 200 }; } catch (Exception ex) { diff --git a/Msn.InteropDemo.Web/Areas/Seguimiento/Controllers/PacientesController.cs b/Msn.InteropDemo.Web/Areas/Seguimiento/Controllers/PacientesController.cs index 296ba19..7973483 100644 --- a/Msn.InteropDemo.Web/Areas/Seguimiento/Controllers/PacientesController.cs +++ b/Msn.InteropDemo.Web/Areas/Seguimiento/Controllers/PacientesController.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using Msn.InteropDemo.AppServices; @@ -97,6 +93,7 @@ public ActionResult Create(PacienteViewModel model) [Helpers.Attributes.Breadcrumb("Pacientes")] public ActionResult BuscarPaciente() { + ViewBag.PacientesPrueba = _selectListHelper.GetPacientesPrueba(); var model = new BuscarPacienteRequestModel(); SetupModel(model); return View(model); @@ -174,7 +171,7 @@ public JsonResult FederarPaciente(int id) catch (Exception ex) { _logger.LogError(ex, "Error Federando Paciente"); - return new JsonResult(new { message = ex.Message }) { StatusCode = 500 }; + return new JsonResult(new { success = false, message = ex.Message }) { StatusCode = 500 }; } } diff --git a/Msn.InteropDemo.Web/Areas/Seguimiento/Views/Evolucionar/EvolucionarPaciente.cshtml b/Msn.InteropDemo.Web/Areas/Seguimiento/Views/Evolucionar/EvolucionarPaciente.cshtml index e50e965..9b2632c 100644 --- a/Msn.InteropDemo.Web/Areas/Seguimiento/Views/Evolucionar/EvolucionarPaciente.cshtml +++ b/Msn.InteropDemo.Web/Areas/Seguimiento/Views/Evolucionar/EvolucionarPaciente.cshtml @@ -5,14 +5,20 @@ var pacienteSexoClass = Model.Sexo == "M" ? "fa-male" : "fa-female"; } +@section AddToHead { + +} +
- - + + + + @Html.AntiForgeryToken() @@ -37,7 +43,7 @@
- + Consultas
@@ -122,7 +128,6 @@
-
@@ -137,8 +142,11 @@ + + @section Scripts { @{await Html.RenderPartialAsync("_ValidationScriptsPartial");} + diff --git a/Msn.InteropDemo.Web/Areas/Seguimiento/Views/Evolucionar/Partials/_GridMapeoCie10.cshtml b/Msn.InteropDemo.Web/Areas/Seguimiento/Views/Evolucionar/Partials/_GridMapeoCie10.cshtml new file mode 100644 index 0000000..dbac476 --- /dev/null +++ b/Msn.InteropDemo.Web/Areas/Seguimiento/Views/Evolucionar/Partials/_GridMapeoCie10.cshtml @@ -0,0 +1,47 @@ +@model IEnumerable + + + + + + + + + + + + @foreach (var item in Model) + { + var esPref = item.EsMapeoPreferido ? "bg-success text-white" : ""; + var chk = item.EsMapeoPreferido ? "checked" : ""; + var subcatTextId = "tableMapCie10SubcategoriaNombre-" + item.SubcategoriaId; + + + + + + + + + } + +
GrupoRecomendación para el mapeoCódigo CIE10 
+
@Html.DisplayFor(modelItem => item.MapGroup)
+
+
@Html.DisplayFor(modelItem => item.MapAdvice)
+
+
@Html.DisplayFor(modelItem => item.SubcategoriaNombre)
+
+
@Html.DisplayFor(modelItem => item.SubcategoriaId)
+
+ +
diff --git a/Msn.InteropDemo.Web/Areas/Seguimiento/Views/Evolucionar/Partials/_MapeoCIE10MultipleModal.cshtml b/Msn.InteropDemo.Web/Areas/Seguimiento/Views/Evolucionar/Partials/_MapeoCIE10MultipleModal.cshtml new file mode 100644 index 0000000..5b6c0f6 --- /dev/null +++ b/Msn.InteropDemo.Web/Areas/Seguimiento/Views/Evolucionar/Partials/_MapeoCIE10MultipleModal.cshtml @@ -0,0 +1,39 @@ +@* + For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860 +*@ + + diff --git a/Msn.InteropDemo.Web/Areas/Seguimiento/Views/Pacientes/BuscarPaciente.cshtml b/Msn.InteropDemo.Web/Areas/Seguimiento/Views/Pacientes/BuscarPaciente.cshtml index b9c726b..c2399dd 100644 --- a/Msn.InteropDemo.Web/Areas/Seguimiento/Views/Pacientes/BuscarPaciente.cshtml +++ b/Msn.InteropDemo.Web/Areas/Seguimiento/Views/Pacientes/BuscarPaciente.cshtml @@ -4,7 +4,32 @@ ViewData["Title"] = "Buscar Paciente"; } - +
+
+ +
+
+ +
+ +
+ +
+
+
+
+ + + +
diff --git a/Msn.InteropDemo.Web/Areas/Seguimiento/Views/Pacientes/Partials/_GridBusquedaPaciente.cshtml b/Msn.InteropDemo.Web/Areas/Seguimiento/Views/Pacientes/Partials/_GridBusquedaPaciente.cshtml index 2edc21f..965b8b6 100644 --- a/Msn.InteropDemo.Web/Areas/Seguimiento/Views/Pacientes/Partials/_GridBusquedaPaciente.cshtml +++ b/Msn.InteropDemo.Web/Areas/Seguimiento/Views/Pacientes/Partials/_GridBusquedaPaciente.cshtml @@ -65,11 +65,7 @@ diff --git a/Msn.InteropDemo.Web/Areas/Seguimiento/Views/Pacientes/Partials/_ModalPaciente.cshtml b/Msn.InteropDemo.Web/Areas/Seguimiento/Views/Pacientes/Partials/_ModalPaciente.cshtml index ed377e3..e1853e3 100644 --- a/Msn.InteropDemo.Web/Areas/Seguimiento/Views/Pacientes/Partials/_ModalPaciente.cshtml +++ b/Msn.InteropDemo.Web/Areas/Seguimiento/Views/Pacientes/Partials/_ModalPaciente.cshtml @@ -14,81 +14,77 @@