-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from SALUD-AR/Iteracion-3
Iteracion 3
- Loading branch information
Showing
48 changed files
with
1,943 additions
and
417 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
136 changes: 136 additions & 0 deletions
136
Msn.InteropDemo.AppServices.Implementation/Internal/SnomedToCie10Mapper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Dfa.Dfas.ComparizonDfa> dfaComparizon; | ||
Lazy<Dfa.Dfas.IntegerNumberDfa> dfaNumber; | ||
Lazy<Dfa.Notifications.MatchCollector> matchCollector; | ||
|
||
public SnomedToCie10Mapper() | ||
{ | ||
dfaComparizon = new Lazy<Dfa.Dfas.ComparizonDfa>(); | ||
dfaNumber = new Lazy<Dfa.Dfas.IntegerNumberDfa>(); | ||
matchCollector = new Lazy<Dfa.Notifications.MatchCollector>(); | ||
} | ||
|
||
public void SetMapeoPreferido(IEnumerable<Cie10MapResultViewModel> 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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Entities.Codificacion.Cie10> | ||
{ | ||
System.Collections.Generic.IEnumerable<ViewModel.Snomed.Cie10MapResultViewModel> GetCie10MappedItems(string conceptId); | ||
IEnumerable<Cie10MapResultViewModel> GetCie10MappedItems(string conceptId); | ||
IEnumerable<Cie10MapResultViewModel> GetCie10MappedItems(string conceptId, | ||
string sexo, | ||
int edad); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
...eropDemo.Data/EntitiesConfiguration/Evoluciones/EvolucionDiagnosticoCie10Configuration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
|
||
namespace Msn.InteropDemo.Data.EntitiesConfiguration.Pacientes | ||
{ | ||
public class EvolucionDiagnosticoCie10Configuration : IEntityTypeConfiguration<Entities.Evoluciones.EvolucionDiagnosticoCie10> | ||
{ | ||
public void Configure(EntityTypeBuilder<Entities.Evoluciones.EvolucionDiagnosticoCie10> 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(); | ||
} | ||
} | ||
} |
Oops, something went wrong.