463c2997-8a6a-4688-9575-6549e5215f7b true D0011-SQL-01.sdt.local jazz tst Riverside Health System 20190930.1 true <ProgramFilesX64>\Microsoft SDKs\Azure\.NET SDK\v2.9\bin\plugins\Diagnostics\Newtonsoft.Json.dll Amazon.Lambda.S3Events AWSSDK.Core AWSSDK.S3 RestSharp Amazon Amazon.Auth.AccessControlPolicy Amazon.Auth.AccessControlPolicy.ActionIdentifiers Amazon.Internal Amazon.Lambda.S3Events Amazon.MissingTypes Amazon.Runtime Amazon.Runtime.CredentialManagement Amazon.Runtime.CredentialManagement.Internal Amazon.Runtime.EventStreams Amazon.Runtime.EventStreams.Internal Amazon.Runtime.Internal Amazon.Runtime.Internal.Auth Amazon.Runtime.Internal.Settings Amazon.Runtime.Internal.Transform Amazon.Runtime.Internal.Util Amazon.Runtime.SharedInterfaces Amazon.Runtime.SharedInterfaces.Internal Amazon.S3 Amazon.S3.Encryption Amazon.S3.Encryption.Internal Amazon.S3.Internal Amazon.S3.IO Amazon.S3.Model Amazon.S3.Model.Internal.MarshallTransformations Amazon.S3.Transfer Amazon.S3.Util Amazon.Util Amazon.Util.Internal Amazon.Util.Internal.PlatformServices Newtonsoft.Json Newtonsoft.Json.Converters Newtonsoft.Json.Linq Newtonsoft.Json.Schema Newtonsoft.Json.Serialization System System.Diagnostics System.Diagnostics.Tracing System.IO.Compression ThirdParty.BouncyCastle.Asn1 ThirdParty.BouncyCastle.Asn1.Utilities ThirdParty.BouncyCastle.Math ThirdParty.BouncyCastle.OpenSsl ThirdParty.BouncyCastle.Utilities.IO.Pem ThirdParty.Ionic.Zlib ThirdParty.Json.LitJson ThirdParty.MD5 RestSharp private string BaseUrl = "https://api-dev.sdt.local/StrataSphere.Web.API.Service/api/v1/"; private IList _mappedDefinitions; void Main() { RestClient client = new RestClient(); var definitions = GetList(client, "Definitions"); var standardDefinitionMappings = from def in StandardDefinitionMappings select new { def.MappingId, def.StandardDefinitionGUID, def.StandardDefinitionType, MappingMemberValue = JsonConvert.DeserializeObject(def.MappingMemberValue) }; var guidDefinitionDictionary = standardDefinitionMappings.ToDictionary(u => u.StandardDefinitionGUID); var foundDefinitions = definitions.Where(p => guidDefinitionDictionary.ContainsKey(p.Id)); _mappedDefinitions = (from d in foundDefinitions join m in StandardDefinitionMappings on d.Id equals m.StandardDefinitionGUID select new StrataSphereMappedDefinition(d, m.MappingMemberValue)).ToList(); var pathAlias = "HIERALIAS"; var sqlTableAlias = "viewDimMetri"; var attributeID = new[] { "Cardiomyopathy" }.ToList(); StrataSphereMappedValue find; attributeID.ForEach(id => { find = MapToStrataSphere("[Case Type Family MSDRG]", "[Case Type Family MSDRG].[Case Type Family]", new List { $"{id}" }); find.Dump($"StrataSphereMappedValue: {id}"); }); } // Define other methods and classes here public StrataSphereMappedValue MapToStrataSphere(string dimensionId, string attributeId, IList valuesToMap) { var mdx = new Regex(@"^(\[.+\]\.)+\[.+\]$"); var clientValues = valuesToMap.Select(valueToMap => mdx.IsMatch(valueToMap) ? AnalysisServicesUtils.GetMeasureIDFromMDXName(valueToMap) : valueToMap).ToList(); return FindMappedValue(dimensionId, attributeId, clientValues); } public static class AnalysisServicesUtils { public static string GetMeasureIDFromMDXName(string aMemberMDXName) { return aMemberMDXName; } } protected StrataSphereMappedValue FindMappedValue(string dimensionId, string attributeId, List valuesToMap) { var definitions = _mappedDefinitions .Where(d => d.DimensionId.Equals(dimensionId, StringComparison.CurrentCultureIgnoreCase) && d.AttributeId.Equals(attributeId, StringComparison.CurrentCultureIgnoreCase)).ToList(); var mappings = definitions.Where(p => p.MappedValues != null && p.MappedValues.mappings.Any()).SelectMany(p => p.MappedValues.mappings); mappings.Dump(); var mappedDefinition = definitions .SingleOrDefault(p => p.MappedValues != null && (!p.MappedValues.mappings.Any() || p.MappedValues.mappings.SelectMany(m => m.attributeValues .Select(a => a.ToString())) .OrderBy(v => v).SequenceEqual(valuesToMap.OrderBy(v => v), StringComparer.CurrentCultureIgnoreCase))) ?? definitions .SingleOrDefault(p => p.MappedValues != null && (!p.MappedValues.mappings.Any() || p.MappedValues.mappings .Select(m => m.name) .OrderBy(v => v).SequenceEqual(valuesToMap.OrderBy(v => v), StringComparer.CurrentCultureIgnoreCase))) ?? definitions .SingleOrDefault(p => p.MappedValues != null && (!p.MappedValues.mappings.Any() || p.MappedValues.mappings .Select(m => m.text) .OrderBy(v => v).SequenceEqual(valuesToMap.OrderBy(v => v), StringComparer.CurrentCultureIgnoreCase))) ?? definitions .SingleOrDefault(p => p.MappedValues != null && (!p.MappedValues.mappings.Any() || p.MappedValues.mappings .Select(m => m.id) .OrderBy(v => v).SequenceEqual(valuesToMap.OrderBy(v => v), StringComparer.CurrentCultureIgnoreCase))) ?? definitions .SingleOrDefault(p => p.MappedValues != null && (!p.MappedValues.mappings.Any() || p.MappedValues.mappings .SelectMany(m => m.hierarchyPaths) .OrderBy(v => v).SequenceEqual(valuesToMap.OrderBy(v => v), StringComparer.CurrentCultureIgnoreCase))) ?? definitions.FirstOrDefault(); return mappedDefinition != null ? new StrataSphereMappedValue(valuesToMap, mappedDefinition.StrataSphereDefinitionGuid) : new StrataSphereMappedValue(valuesToMap); } public struct StrataSphereMappedValue { public IList ClientValues { get; set; } public Guid? StrataSphereDefinitionGuid { get; set; } public StrataSphereMappedValue(IList clientValues) { ClientValues = clientValues; StrataSphereDefinitionGuid = null; } public StrataSphereMappedValue(IList clientValues, Guid definitionGuid) { ClientValues = clientValues; StrataSphereDefinitionGuid = definitionGuid; } public bool IsMapped => StrataSphereDefinitionGuid.HasValue; } public class StrataSphereMappedDefinition { public StrataSphereMappedDefinition(DefinitionDto definitionDto, string mappedValues) { StrataSphereDefinitionGuid = definitionDto.Id; HierarchyGuid = definitionDto.HierarchyGuid; DimensionGuid = definitionDto.DimensionGuid; AttributeGuid = definitionDto.AttributeGuid; HierarchyId = definitionDto.HierarchyId; DimensionId = definitionDto.DimensionId; AttributeId = definitionDto.AttributeId; MappedValues = JsonConvert.DeserializeObject(mappedValues); } public Guid StrataSphereDefinitionGuid { get; } public Guid HierarchyGuid { get; } public Guid DimensionGuid { get; } public Guid AttributeGuid { get; } public string HierarchyId { get; } public string DimensionId { get; } public string AttributeId { get; } public StrataSphereMappingValues MappedValues { get; } } public class StrataSphereMappingValues { public string HierarchyGUID { get; set; } public string DimensionGUID { get; set; } public List values { get; set; } public List mappings { get; set; } public List hierarchyPaths { get; set; } public StrataSphereMappingValues() { mappings = new List(); } } public class MappingValue { public string id { get; set; } public string displayHierarchyName { get; set; } public string text { get; set; } public string name { get; set; } public List attributeValues { get; set; } public List hierarchyPaths { get; set; } public MappingValue() { attributeValues = new List(); hierarchyPaths = new List(); } } public class ApiBaseDto { /// /// API Item Id Guid in StrataSphere /// /// 00000000-0000-0000-0000-000000000000 public Guid Id { get; set; } /// /// When the API item was uploaded to StrataSphere /// public DateTime DateCreated { get; set; } /// /// When the API item was last updated in StrataSphere /// public DateTime DateLastModified { get; set; } } public class DefinitionDto : ApiBaseDto { /// /// The name of the definition /// /// TOP 10 DRGs BY SERVICE LINE public string Name { get; set; } /// /// A short description of the definition's content /// /// Top 10 DRGs by Service Line filtered per service line rollup public string Description { get; set; } = ""; /// /// The Guid of the Definition's hierarchy in a GM database /// /// 00000000-0000-0000-0000-000000000000 public Guid HierarchyGuid { get; set; } /// /// The Guid of the Definition's dimension in a GM database /// /// 00000000-0000-0000-0000-000000000000 public Guid DimensionGuid { get; set; } /// /// The Guid of the Definition's attribute in a GM database /// /// 00000000-0000-0000-0000-000000000000 public Guid AttributeGuid { get; set; } /// /// The string of the Definition's hierarchy friendly name /// /// PatientTypeRollupID public string HierarchyId { get; set; } /// /// The string of the Definition's dimension Id /// /// [Patient Encounter] public string DimensionId { get; set; } /// /// The string of the Definition's attribute Id /// /// [Patient Encounter].[Service Line Strata Decision] public string AttributeId { get; set; } } IEnumerable GetList(RestClient client, string something) { return Get>(client, something); } T Get(RestClient client, string something) { client.BaseUrl = new Uri(BaseUrl + something); RestRequest request = new RestRequest(); request.Method = Method.GET; return JsonConvert.DeserializeObject(client.Execute(request).Content); }