Files
linqpad/CaseType Analytics/CaseTypeDestination.linq
T

140 lines
6.0 KiB
C#

<Query Kind="Program">
<Connection>
<ID>870a756b-af44-4db4-b004-58ff41318b3a</ID>
<Persist>true</Persist>
<Server>P9900-SQL-11.sdt.local</Server>
<Database>jazz tst GM DSS Share Training Master</Database>
<ShowServer>true</ShowServer>
</Connection>
<Reference>&lt;ProgramFilesX64&gt;\Microsoft SDKs\Azure\.NET SDK\v2.9\bin\plugins\Diagnostics\Newtonsoft.Json.dll</Reference>
<NuGetReference>Amazon.Lambda.S3Events</NuGetReference>
<NuGetReference>AWSSDK.Core</NuGetReference>
<NuGetReference>AWSSDK.S3</NuGetReference>
<Namespace>Amazon</Namespace>
<Namespace>Amazon.Auth.AccessControlPolicy</Namespace>
<Namespace>Amazon.Auth.AccessControlPolicy.ActionIdentifiers</Namespace>
<Namespace>Amazon.Internal</Namespace>
<Namespace>Amazon.Lambda.S3Events</Namespace>
<Namespace>Amazon.MissingTypes</Namespace>
<Namespace>Amazon.Runtime</Namespace>
<Namespace>Amazon.Runtime.CredentialManagement</Namespace>
<Namespace>Amazon.Runtime.CredentialManagement.Internal</Namespace>
<Namespace>Amazon.Runtime.EventStreams</Namespace>
<Namespace>Amazon.Runtime.EventStreams.Internal</Namespace>
<Namespace>Amazon.Runtime.Internal</Namespace>
<Namespace>Amazon.Runtime.Internal.Auth</Namespace>
<Namespace>Amazon.Runtime.Internal.Settings</Namespace>
<Namespace>Amazon.Runtime.Internal.Transform</Namespace>
<Namespace>Amazon.Runtime.Internal.Util</Namespace>
<Namespace>Amazon.Runtime.SharedInterfaces</Namespace>
<Namespace>Amazon.Runtime.SharedInterfaces.Internal</Namespace>
<Namespace>Amazon.S3</Namespace>
<Namespace>Amazon.S3.Encryption</Namespace>
<Namespace>Amazon.S3.Encryption.Internal</Namespace>
<Namespace>Amazon.S3.Internal</Namespace>
<Namespace>Amazon.S3.IO</Namespace>
<Namespace>Amazon.S3.Model</Namespace>
<Namespace>Amazon.S3.Model.Internal.MarshallTransformations</Namespace>
<Namespace>Amazon.S3.Transfer</Namespace>
<Namespace>Amazon.S3.Util</Namespace>
<Namespace>Amazon.Util</Namespace>
<Namespace>Amazon.Util.Internal</Namespace>
<Namespace>Amazon.Util.Internal.PlatformServices</Namespace>
<Namespace>Newtonsoft.Json</Namespace>
<Namespace>Newtonsoft.Json.Converters</Namespace>
<Namespace>Newtonsoft.Json.Linq</Namespace>
<Namespace>Newtonsoft.Json.Schema</Namespace>
<Namespace>Newtonsoft.Json.Serialization</Namespace>
<Namespace>System</Namespace>
<Namespace>System.Diagnostics</Namespace>
<Namespace>System.Diagnostics.Tracing</Namespace>
<Namespace>System.IO.Compression</Namespace>
<Namespace>ThirdParty.BouncyCastle.Asn1</Namespace>
<Namespace>ThirdParty.BouncyCastle.Asn1.Utilities</Namespace>
<Namespace>ThirdParty.BouncyCastle.Math</Namespace>
<Namespace>ThirdParty.BouncyCastle.OpenSsl</Namespace>
<Namespace>ThirdParty.BouncyCastle.Utilities.IO.Pem</Namespace>
<Namespace>ThirdParty.Ionic.Zlib</Namespace>
<Namespace>ThirdParty.Json.LitJson</Namespace>
<Namespace>ThirdParty.MD5</Namespace>
</Query>
private IEnumerable<VersionInfo> existing_versions;
private IEnumerable<string> existing_migrations;
private IEnumerable<FamilyInfo> existing_families;
private IEnumerable<MappingInfo> existing_mappings;
void Main()
{
Step1();
existing_migrations.Dump();
existing_versions.Dump();
existing_families.Count().Dump();
existing_mappings.Count().Dump();
var documentFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
File.WriteAllText(Path.Combine(documentFolder, $"{nameof(existing_migrations)}.json"), JsonConvert.SerializeObject(existing_migrations, Newtonsoft.Json.Formatting.Indented));
File.WriteAllText(Path.Combine(documentFolder, $"{nameof(existing_versions)}.json"), JsonConvert.SerializeObject(existing_versions, Newtonsoft.Json.Formatting.Indented));
File.WriteAllText(Path.Combine(documentFolder, $"{nameof(existing_families)}.json"), JsonConvert.SerializeObject(existing_families, Newtonsoft.Json.Formatting.Indented));
File.WriteAllText(Path.Combine(documentFolder, $"{nameof(existing_mappings)}.json"), JsonConvert.SerializeObject(existing_mappings, Newtonsoft.Json.Formatting.Indented));
}
// Define other methods and classes here
private void Step1()
{
existing_migrations = from ml in MigrationLogs where ml.DateTimeStamp > new DateTime(2018, 11, 16) && ml.Name.Replace(" ", "").Contains("CaseType") orderby ml.DateTimeStamp descending select ml.Name;
existing_versions = from ctfv in CaseTypeFamilyVersions select new VersionInfo(ctfv.CaseTypeFamilyVersionID, ctfv.Name, ctfv.StartDate, ctfv.EndDate);
existing_families = from ctf in CaseTypeFamilies select new FamilyInfo(ctf.CaseTypeFamilyGlobalID, ctf.Name, ctf.CaseTypeFamilyID);
existing_mappings = (from ctfm in CaseTypeFamilyMappingICD10s
join family in CaseTypeFamilies on ctfm.CaseTypeFamilyID equals family.CaseTypeFamilyID
where ctfm.CaseTypeFamilyVersionID == 1
select new MappingInfo(family.CaseTypeFamilyGlobalID, ctfm.SkipICD, ctfm.ICD10Code, ctfm.MSDRGCode)).Distinct();
}
public class VersionInfo
{
public int CaseTypeFamilyVersionId { get; set; }
public string Name { get; set; }
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
public VersionInfo(int id, string name, DateTime start, DateTime end)
{
CaseTypeFamilyVersionId = id;
Name = name;
StartDate = start;
EndDate = end;
}
}
public class FamilyInfo
{
public int CaseTypeFamilyID { get; set; }
public string CaseTypeFamilyGlobalID { get; set; }
public string Name { get; set; }
public FamilyInfo(string caseTypeFamilyGlobalID, string name, int caseTypeFamilyID)
{
CaseTypeFamilyID = caseTypeFamilyID;
CaseTypeFamilyGlobalID = caseTypeFamilyGlobalID;
Name = name;
}
}
public class MappingInfo
{
public string CaseTypeFamilyGlobalID { get; set; }
public bool SkipICD { get; set; }
public string ICD10Code { get; set; }
public string MSDRGCode { get; set; }
public MappingInfo(string caseTypeFamilyGlobalID, bool skipICD, string icd10Code, string msdrgCode)
{
CaseTypeFamilyGlobalID = caseTypeFamilyGlobalID;
SkipICD = skipICD;
ICD10Code = icd10Code;
MSDRGCode = msdrgCode;
}
}