feat: initial commit
This commit is contained in:
+44
@@ -0,0 +1,44 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Options;
|
||||
using NUnit.Framework;
|
||||
using Strata.SnowflakeLib;
|
||||
using Strata.Stratasphere.Biz.Configuration;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Strata.Stratasphere.Biz.IntegrationTests.Standards.IntegrationTests
|
||||
{
|
||||
[SetUpFixture]
|
||||
|
||||
public abstract class IntegrationTestBase
|
||||
{
|
||||
protected readonly Guid _DatabaseGuid = new Guid("00732a12-e90f-49bd-9d9d-3ff43ec7c750"); //gm working small
|
||||
protected StrataSnowflakeConnection _dbSnowflakeConnection;
|
||||
protected IServiceProvider _serviceProvider; //used to grab any necessary DI objects
|
||||
public IntegrationTestBase()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//When running locally sets the profile to the data wrangler profile so you have access to resources
|
||||
[OneTimeSetUp]
|
||||
public void SetAwsProfile()
|
||||
{
|
||||
#if DEBUG
|
||||
Environment.SetEnvironmentVariable("AWS_Profile", "sdt-data-wrangler-Service-Role");
|
||||
#endif
|
||||
var services = ServiceCollectionFactory.Create();
|
||||
_serviceProvider = services.BuildServiceProvider();
|
||||
var sfOptions = _serviceProvider.GetService<IOptions<SnowflakeEnvironmentOptions>>();
|
||||
var sfConnBuilderFactory = _serviceProvider.GetRequiredService<ISnowflakeConnectionStringBuilderFactory>();
|
||||
var builder = sfConnBuilderFactory.CreateAsync($"stratareplication/snowflake/{_DatabaseGuid:N}/connectionstring", _DatabaseGuid).GetAwaiter().GetResult();
|
||||
builder.Warehouse = sfOptions.Value.StandardsWarehouse;
|
||||
_dbSnowflakeConnection = builder.CreateConnection();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+228
@@ -0,0 +1,228 @@
|
||||
using CsvHelper;
|
||||
using Dapper;
|
||||
using NUnit.Framework;
|
||||
using Strata.Stratasphere.Biz.Standards;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading;
|
||||
using Strata.SnowflakeLib;
|
||||
|
||||
namespace Strata.Stratasphere.Biz.IntegrationTests.Standards.IntegrationTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class ReadmissionTests : IntegrationTestBase
|
||||
{
|
||||
|
||||
public List<TestInput> TestInputs { get; set; }
|
||||
private List<TestOutput> TestOutputs { get; set; }
|
||||
private readonly string TransactionalTableName;
|
||||
public ReadmissionTests() : base()
|
||||
{
|
||||
#if (DEBUG)
|
||||
TransactionalTableName = "SPH.MEL_TEST123";
|
||||
#else
|
||||
TransactionalTableName = $"SPH.MEL_TEST123_{Guid.NewGuid():N}";
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
[OneTimeSetUp]
|
||||
public void SetupFixture()
|
||||
{
|
||||
DeleteData(_dbSnowflakeConnection);
|
||||
LoadInitialData(_dbSnowflakeConnection);
|
||||
RunFullReadmit(_dbSnowflakeConnection);
|
||||
CreateEncounterTable(_dbSnowflakeConnection);
|
||||
}
|
||||
|
||||
[OneTimeTearDown]
|
||||
public void TearDownFixture()
|
||||
{
|
||||
DeleteData(_dbSnowflakeConnection);
|
||||
}
|
||||
|
||||
private void CreateEncounterTable(StrataSnowflakeConnection conn)
|
||||
{
|
||||
var ctable = $@"CREATE OR REPLACE TABLE {TransactionalTableName} (ENCOUNTERID BIGINT, ROWID BIGINT IDENTITY(1,1));";
|
||||
conn.Execute(ctable);
|
||||
}
|
||||
|
||||
private void LoadInitialData(StrataSnowflakeConnection conn)
|
||||
{
|
||||
using StreamReader reader = File.OpenText("./Standards/IntegrationTests/TestData/Readmit Test Data.csv");
|
||||
using var csvReader = new CsvReader(reader, CultureInfo.InvariantCulture);
|
||||
TestInputs = csvReader.GetRecords<TestInput>().ToList();
|
||||
LoadData(conn, TestInputs);
|
||||
}
|
||||
|
||||
private void LoadData(StrataSnowflakeConnection conn, List<TestInput> testInputs)
|
||||
{
|
||||
|
||||
var encLoops = string.Join("\nUNION ALL ", testInputs.Select(a => $"SELECT {a.EncounterID} ENCOUNTERID, {a.PatientID} PATIENTID, '{a.AdmitDateTime:u}' ADMITDATETIME, '{a.DischargeDateTime:u}' DISCHARGEDATETIME,'{a.Diag1}' DIAG1"));
|
||||
var ptLoops = string.Join("\nUNION ALL ", testInputs.Select(a => $"SELECT {a.EncounterID} ENCOUNTERID, '{a.IsInpatient}' ISINPATIENT, '{a.IsOutpatient}' ISOUTPATIENT"));
|
||||
var diagLoops = string.Join("\nUNION ALL ", testInputs.Select(a => $"SELECT {a.EncounterID} ENCOUNTERID, '{a.Diag1}' DIAGCODE, 1 SEQUENCENUMBER\nUNION ALL SELECT {a.EncounterID} ENCOUNTERID, '{a.Diag2}' DIAGCODE, 2 SEQUENCENUMBER"));
|
||||
var procLoops = string.Join("\nUNION ALL ", testInputs.Select(a => $"SELECT {a.EncounterID} ENCOUNTERID, '{a.Proc1}' PROCCODE, 1 SEQUENCENUMBER\nUNION ALL SELECT {a.EncounterID} ENCOUNTERID, '{a.Proc2}' PROCCODE, 2 SEQUENCENUMBER"));
|
||||
|
||||
var encInput = $@"
|
||||
INSERT INTO CLIENTDSS.FACTPATIENTENCOUNTERSUMMARY (ENCOUNTERID, ENCOUNTERRECORDNUMBER, PATIENTID, ADMITDATETIME, DISCHARGEDATETIME, ICD10DXPRIMARYDIAGID, DISCHARGEDATEID, ADMITDATEID)
|
||||
SELECT a.EncounterID, a.EncounterID, a.PatientID, a.AdmitDateTime, a.DischargeDateTime, DX.ICD10DXID, DISDATE.DATEID, ADDATE.DATEID FROM
|
||||
(
|
||||
{encLoops}
|
||||
) a
|
||||
INNER JOIN DSS.DIMICD10DX DX ON DX.ICD10DXCODENODECIMAL = a.Diag1
|
||||
INNER JOIN FW.DIMDATE DISDATE ON DISDATE.CALENDARDATETIME = a.DISCHARGEDATETIME
|
||||
INNER JOIN FW.DIMDATE ADDATE ON ADDATE.CALENDARDATETIME = a.ADMITDATETIME;";
|
||||
var ptInput = $@"
|
||||
INSERT INTO SPH.ENCOUNTERPATIENTTYPE (ENCOUNTERID, ISINPATIENT, ISOUTPATIENT)
|
||||
SELECT ENCOUNTERID, ISINPATIENT, ISOUTPATIENT FROM
|
||||
(
|
||||
{ptLoops}
|
||||
);
|
||||
";
|
||||
var diagInput = $@"
|
||||
INSERT INTO DSS.FACTPATIENTICD10DIAGNOSTICDETAIL (ENCOUNTERID, ENCOUNTERRECORDNUMBER, ICD10DXID, SEQUENCENUMBERID)
|
||||
SELECT ENCOUNTERID, ENCOUNTERID, DX.ICD10DXID, SEQUENCENUMBER
|
||||
FROM (
|
||||
{diagLoops}
|
||||
) a
|
||||
INNER JOIN DSS.DIMICD10DX DX ON DX.ICD10DXCODENODECIMAL = a.DIAGCODE;
|
||||
";
|
||||
|
||||
var procInput = $@"
|
||||
INSERT INTO DSS.FACTPATIENTICD10PROCEDURALDETAIL (ENCOUNTERID, ENCOUNTERRECORDNUMBER, ICD10PXID, SEQUENCENUMBERID)
|
||||
SELECT ENCOUNTERID, ENCOUNTERID, PX.ICD10PXID, SEQUENCENUMBER
|
||||
FROM (
|
||||
{procLoops}
|
||||
) a
|
||||
INNER JOIN DSS.DIMICD10PX PX ON PX.ICD10PXCODENODECIMAL = a.PROCCODE;
|
||||
";
|
||||
|
||||
conn.Execute(encInput);
|
||||
conn.Execute(ptInput);
|
||||
conn.Execute(diagInput);
|
||||
conn.Execute(procInput);
|
||||
}
|
||||
|
||||
private void RunFullReadmit(StrataSnowflakeConnection conn)
|
||||
{
|
||||
var readmitJob = _serviceProvider.GetRequiredService<ReadmissionJob>();
|
||||
readmitJob.ProcessReadmissionsForAllEncounters(_DatabaseGuid, "GM Working Small", null, CancellationToken.None).GetAwaiter().GetResult();
|
||||
|
||||
TestOutputs = conn.Query<TestOutput>($"SELECT * FROM {StandardsConstants.READMISSION_TABLENAME} WHERE ENCOUNTERID < 0").ToList();
|
||||
}
|
||||
|
||||
private void DeleteData(StrataSnowflakeConnection conn)
|
||||
{
|
||||
conn.Execute("DELETE FROM CLIENTDSS.FACTPATIENTENCOUNTERSUMMARY where EncounterID < 0;");
|
||||
conn.Execute("DELETE FROM dss.FACTPATIENTICD10DIAGNOSTICDETAIL where encounterid < 0; ");
|
||||
conn.Execute("DELETE FROM DSS.FACTPATIENTICD10PROCEDURALDETAIL where encounterid < 0; ");
|
||||
conn.Execute("DELETE FROM SPH.ENCOUNTERPATIENTTYPE where encounterid < 0; ");
|
||||
conn.Execute($"DROP TABLE IF EXISTS {TransactionalTableName};");
|
||||
}
|
||||
|
||||
private static IEnumerable<TestCaseData> GetTestCases()
|
||||
{
|
||||
using StreamReader reader = File.OpenText("./Standards/IntegrationTests/TestData/Readmit Test Data.csv");
|
||||
using var csvReader = new CsvReader(reader, CultureInfo.InvariantCulture);
|
||||
return csvReader.GetRecords<TestResult>().Select(a => new TestCaseData(a).SetName($"Encounter: {a.EncounterID} - 30Day-90Day: {a.Is30DayReadmit}/{a.Is30DayIndex} - {a.Is90DayReadmit}/{a.Is90DayIndex}").SetDescription(a.Description)).ToList();
|
||||
}
|
||||
|
||||
[Test, TestCaseSource("GetTestCases")]
|
||||
public void Test(TestResult test)
|
||||
{
|
||||
var output = TestOutputs.FirstOrDefault(a => a.EncounterID == test.EncounterID);
|
||||
AssertReadmit(output, test);
|
||||
}
|
||||
|
||||
private void AssertReadmit(TestOutput output, TestResult expected)
|
||||
{
|
||||
if (output != null)
|
||||
{
|
||||
Assert.AreEqual(expected.EncounterID, output.EncounterID);
|
||||
Assert.AreEqual(expected.IsEligibleIndex, output.IsEligibleIndex);
|
||||
Assert.AreEqual(expected.IsEligibleReadmit, output.IsEligibleReadmit);
|
||||
Assert.AreEqual(expected.Is30DayReadmit, output.Is30DayReadmit);
|
||||
Assert.AreEqual(expected.Is30DayIndex, output.Is30DayReadmitIndex);
|
||||
Assert.AreEqual(expected.Is90DayReadmit, output.Is90DayReadmit);
|
||||
Assert.AreEqual(expected.Is90DayIndex, output.Is90DayReadmitIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.AreEqual(!expected.IsEligibleIndex && !expected.IsEligibleReadmit, output == null);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCase(-101, Description = "Test Transactional Readmission Based on Index Encounter")]
|
||||
[TestCase(-102, Description = "Test Transactional Readmission Based on Readmit Encounter")]
|
||||
public void TestReadmit_Transactional(int changedEncounter)
|
||||
{
|
||||
var input = new List<TestInput>()
|
||||
{
|
||||
new TestInput() { PatientID = -150, EncounterID = -101, IsInpatient = true,IsOutpatient = false, AdmitDateTime = new DateTime(2030, 1, 10), DischargeDateTime = new DateTime(2030, 1, 11), Diag1 = "E03", Diag2 = "E030", Proc1 = "0SW5X8Z", Proc2 = "04734FZ" },
|
||||
new TestInput() {PatientID = -150, EncounterID = -102, IsInpatient = true,IsOutpatient = false, AdmitDateTime = new DateTime(2030, 1, 20), DischargeDateTime = new DateTime(2030, 1, 21), Diag1 = "E03", Diag2 = "E030", Proc1 = "0SW5X8Z", Proc2 = "04734FZ" }
|
||||
};
|
||||
var expectedIndex = new TestResult() { EncounterID = -101, Is30DayReadmit = false, Is30DayIndex = true, Is90DayReadmit = false, Is90DayIndex = true, IsEligibleIndex = true, IsEligibleReadmit = true };
|
||||
var expectedReadmit = new TestResult() { EncounterID = -102, Is30DayReadmit = true, Is30DayIndex = false, Is90DayReadmit = true, Is90DayIndex = false, IsEligibleIndex = true, IsEligibleReadmit = true };
|
||||
|
||||
|
||||
_dbSnowflakeConnection.Execute($"DELETE FROM {TransactionalTableName};");
|
||||
_dbSnowflakeConnection.Execute($"INSERT INTO {TransactionalTableName} (ENCOUNTERID) VALUES ({changedEncounter});");
|
||||
LoadData(_dbSnowflakeConnection, input);
|
||||
var readmitJob = _serviceProvider.GetRequiredService<ReadmissionJob>();
|
||||
readmitJob.ProcessReadmissions(_DatabaseGuid, TransactionalTableName, null, CancellationToken.None).GetAwaiter().GetResult();
|
||||
|
||||
var outputs = _dbSnowflakeConnection.Query<TestOutput>($"SELECT * FROM {StandardsConstants.READMISSION_TABLENAME} WHERE ENCOUNTERID < 0").ToList();
|
||||
|
||||
var index = outputs.FirstOrDefault(a => a.EncounterID == -101);
|
||||
var readmit = outputs.FirstOrDefault(a => a.EncounterID == -102);
|
||||
AssertReadmit(index, expectedIndex);
|
||||
AssertReadmit(readmit, expectedReadmit);
|
||||
}
|
||||
|
||||
|
||||
public class TestResult
|
||||
{
|
||||
public long EncounterID { get; set; }
|
||||
public bool IsEligibleIndex { get; set; }
|
||||
public bool IsEligibleReadmit { get; set; }
|
||||
public bool Is30DayReadmit { get; set; }
|
||||
public bool Is30DayIndex { get; set; }
|
||||
public bool Is90DayReadmit { get; set; }
|
||||
public bool Is90DayIndex { get; set; }
|
||||
public string Description { get; set; }
|
||||
}
|
||||
|
||||
public class TestInput
|
||||
{
|
||||
public long EncounterID { get; set; }
|
||||
public long PatientID { get; set; }
|
||||
public bool IsInpatient { get; set; }
|
||||
public bool IsOutpatient { get; set; }
|
||||
public DateTime AdmitDateTime { get; set; }
|
||||
public DateTime DischargeDateTime { get; set; }
|
||||
public string Diag1 { get; set; }
|
||||
public string Diag2 { get; set; }
|
||||
public string Proc1 { get; set; }
|
||||
public string Proc2 { get; set; }
|
||||
}
|
||||
|
||||
public class TestOutput
|
||||
{
|
||||
public long EncounterID { get; set; }
|
||||
public bool IsEligibleIndex { get; set; }
|
||||
public bool IsEligibleReadmit { get; set; }
|
||||
public bool Is30DayReadmit { get; set; }
|
||||
public bool Is30DayReadmitIndex { get; set; }
|
||||
public bool Is90DayReadmit { get; set; }
|
||||
public bool Is90DayReadmitIndex { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Strata.Configuration.Client.DependencyInjection.ConsoleApps;
|
||||
using Strata.ApiLib.Core.StrataAuthentication.Bootstrappers;
|
||||
using Strata.Stratasphere.Biz.Configuration;
|
||||
using Hangfire;
|
||||
using Hangfire.MemoryStorage;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Strata.Stratasphere.Biz.Standards;
|
||||
|
||||
namespace Strata.Stratasphere.Biz.IntegrationTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Factory class for getting the dependencies in place for testing purposes
|
||||
/// </summary>
|
||||
public static class ServiceCollectionFactory
|
||||
{
|
||||
public static IServiceCollection Create()
|
||||
{
|
||||
var services = new ServiceCollection();
|
||||
var configuration = StrataConfigurationFactory.GetConfiguration();
|
||||
services.AddSingleton(configuration);
|
||||
services.AddStrataAuthentication(configuration);
|
||||
services.AddStratasphere(configuration);
|
||||
services.AddLogging();
|
||||
|
||||
services.AddHangfire(c => c.UseMemoryStorage());
|
||||
|
||||
//ADD any test specific stuff
|
||||
services.AddTransient<HACsJob>();
|
||||
services.AddTransient<ReadmissionJob>();
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
}
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
PatientID,EncounterID,IsInpatient,IsOutpatient,AdmitDateTime,DischargeDateTime,Diag1,Diag2,Proc1,Proc2,Description,Is30DayReadmit,Is30DayIndex,Is90DayReadmit,Is90DayIndex,IsEligibleIndex,IsEligibleReadmit
|
||||
-50,-1,1,0,1/10/2030,1/11/2030,E03,E030,0SW5X8Z,04734FZ,Readmit,FALSE,TRUE,FALSE,TRUE,TRUE,TRUE
|
||||
-50,-2,1,0,1/20/2030,1/21/2030,E03,E030,0SW5X8Z,04734FZ,Readmit,TRUE,FALSE,TRUE,FALSE,TRUE,TRUE
|
||||
-51,-3,1,0,1/10/2030,1/11/2030,E03,E030,0SW5X8Z,04734FZ,Not readmit because of planned procedure,FALSE,FALSE,FALSE,FALSE,TRUE,TRUE
|
||||
-51,-4,1,0,1/20/2030,1/21/2030,E03,E030,30230G0,04734FZ,Not readmit because of planned procedure,FALSE,FALSE,FALSE,FALSE,TRUE,FALSE
|
||||
-52,-5,1,0,1/10/2030,1/11/2030,E03,E030,00803ZZ,04734FZ,Not readmit because of excluded procedure,FALSE,FALSE,FALSE,FALSE,FALSE,TRUE
|
||||
-52,-6,1,0,1/20/2030,1/21/2030,E03,E030,0SW5X8Z,04734FZ,Not readmit because of excluded procedure,FALSE,FALSE,FALSE,FALSE,TRUE,TRUE
|
||||
-53,-7,1,0,1/10/2030,1/11/2030,E03,E030,0SW5X8Z,04734FZ,Not readmit because of planned diag,FALSE,FALSE,FALSE,FALSE,TRUE,TRUE
|
||||
-53,-8,1,0,1/20/2030,1/21/2030,Z510,E030,0SW5X8Z,04734FZ,Not readmit because of planned diag,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE
|
||||
-54,-9,1,0,1/10/2030,1/11/2030,C002,E030,0SW5X8Z,04734FZ,Not readmit because of excluded diag,FALSE,FALSE,FALSE,FALSE,FALSE,TRUE
|
||||
-54,-10,1,0,1/20/2030,1/21/2030,E03,E030,0SW5X8Z,04734FZ,Not readmit because of excluded diag,FALSE,FALSE,FALSE,FALSE,TRUE,TRUE
|
||||
-55,-11,1,0,1/10/2030,1/11/2030,E03,E030,0SW5X8Z,04734FZ,Not readmit because of > 30 days,FALSE,FALSE,FALSE,TRUE,TRUE,TRUE
|
||||
-55,-12,1,0,3/20/2030,3/21/2030,E03,E030,0SW5X8Z,04734FZ,Not readmit because of > 30 days,FALSE,FALSE,TRUE,FALSE,TRUE,TRUE
|
||||
-56,-13,1,0,1/10/2030,1/11/2030,E03,E030,0SW5X8Z,04734FZ,Not readmit because planned between,FALSE,FALSE,FALSE,FALSE,TRUE,TRUE
|
||||
-56,-14,1,0,1/20/2030,1/21/2030,Z510,E030,30230Y0,04734FZ,Not readmit because planned between,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE
|
||||
-56,-15,1,0,1/30/2030,2/1/2030,E03,E030,0SW5X8Z,04734FZ,Not readmit because planned between,FALSE,FALSE,FALSE,FALSE,TRUE,TRUE
|
||||
-57,-16,1,0,1/10/2030,1/11/2030,E03,E030,0SW5X8Z,04734FZ,Readmit but initial encounter not considered,FALSE,FALSE,FALSE,FALSE,TRUE,TRUE
|
||||
-57,-17,1,0,1/20/2030,1/21/2030,Z510,E030,0SW5X8Z,04734FZ,Readmit but initial encounter not considered,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE
|
||||
-57,-18,1,0,1/22/2030,1/23/2030,E03,E030,0SW5X8Z,04734FZ,Readmit but initial encounter not considered,FALSE,TRUE,FALSE,TRUE,TRUE,TRUE
|
||||
-57,-19,1,0,1/30/2030,2/1/2030,E03,E030,0SW5X8Z,04734FZ,Readmit but initial encounter not considered,TRUE,FALSE,TRUE,FALSE,TRUE,TRUE
|
||||
-58,-20,0,1,1/10/2030,1/11/2030,E03,E030,0SW5X8Z,04734FZ,Not readmit because outpatient,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE
|
||||
-58,-21,0,1,1/20/2030,1/21/2030,E03,E030,0SW5X8Z,04734FZ,Not readmit because outpatient,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE
|
||||
-59,-22,1,0,1/10/2030,1/11/2030,E03,E030,0SW5X8Z,04734FZ,Readmit,FALSE,TRUE,FALSE,TRUE,TRUE,TRUE
|
||||
-59,-23,1,0,1/20/2030,1/21/2030,E03,E030,0SW5X8Z,04734FZ,Readmit,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE
|
||||
-59,-24,1,0,1/25/2030,1/26/2030,E03,E030,0SW5X8Z,04734FZ,Readmit,TRUE,FALSE,TRUE,FALSE,TRUE,TRUE
|
||||
-60,-25,1,0,1/20/2030,1/21/2030,E03,E030,0SW5X8Z,04734FZ,"Readmit, but readmit encounter not eligible",FALSE,TRUE,FALSE,TRUE,TRUE,TRUE
|
||||
-60,-26,1,0,1/25/2030,1/26/2030,E03,E030,0SW5X8Z,09R90JZ,"Readmit, but readmit encounter not eligible, is part of population should be false because the diag is excluded",TRUE,FALSE,TRUE,FALSE,FALSE,TRUE
|
||||
-61,-27,1,0,1/20/2030,1/21/2030,E03,E030,0SW5X8Z,04734FZ,Readmit 31 day boundary Test,FALSE,FALSE,FALSE,TRUE,TRUE,TRUE
|
||||
-61,-28,1,0,2/21/2030,2/21/2030,E03,E030,0SW5X8Z,04734FZ,Readmit 31 day boundary Test,FALSE,FALSE,TRUE,FALSE,TRUE,TRUE
|
||||
-62,-29,1,0,1/20/2030,1/21/2030,E03,E030,0SW5X8Z,04734FZ,Readmit 90 day boundary Test,FALSE,FALSE,FALSE,TRUE,TRUE,TRUE
|
||||
-62,-30,1,0,4/21/2030,4/21/2030,E03,E030,0SW5X8Z,04734FZ,Readmit 90 day boundary Test,FALSE,FALSE,TRUE,FALSE,TRUE,TRUE
|
||||
-63,-31,1,0,1/20/2030,1/21/2030,E03,E030,0SW5X8Z,04734FZ,Readmit 91 day boundary Test,FALSE,FALSE,FALSE,FALSE,TRUE,TRUE
|
||||
-63,-32,1,0,4/22/2030,4/22/2030,E03,E030,0SW5X8Z,04734FZ,Readmit 91 day boundary Test,FALSE,FALSE,FALSE,FALSE,TRUE,TRUE
|
||||
-64,-33,1,0,1/20/2030,1/21/2030,E03,E030,0SW5X8Z,04734FZ,Readmit 30 day boundary Test,FALSE,TRUE,FALSE,TRUE,TRUE,TRUE
|
||||
-64,-34,1,0,2/20/2030,1/26/2030,C002,E030,0SW5X8Z,04734FZ,Readmit 30 day boundary Test,TRUE,FALSE,TRUE,FALSE,FALSE,TRUE
|
||||
-65,-35,1,0,1/10/2030,1/11/2030,E03,E030,0SW5X8Z,04734FZ,No Readmit due to same primary diagnosis,FALSE,FALSE,FALSE,FALSE,FALSE,TRUE
|
||||
-65,-36,1,0,1/11/2030,1/21/2030,E03,E030,0SW5X8Z,04734FZ,No Readmit due to same primary diagnosis,FALSE,FALSE,FALSE,FALSE,TRUE,FALSE
|
||||
-66,-37,1,0,1/10/2030,1/11/2030,E03,E030,0SW5X8Z,04734FZ,Same day readmit,FALSE,TRUE,FALSE,TRUE,TRUE,TRUE
|
||||
-66,-38,1,0,1/11/2030,1/21/2030,E030,E03,0SW5X8Z,04734FZ,Same day readmit,TRUE,FALSE,TRUE,FALSE,TRUE,TRUE
|
||||
-67,-39,1,0,1/10/2030,1/11/2030,E03,E030,0SW5X8Z,04734FZ,Same day readmit,FALSE,TRUE,FALSE,TRUE,TRUE,TRUE
|
||||
-67,-40,1,0,1/11/2030,1/11/2030,E030,E03,0SW5X8Z,04734FZ,Same day readmit,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE
|
||||
-67,-41,1,0,1/11/2030,1/21/2030,E301,E03,0SW5X8Z,04734FZ,Same day readmit,TRUE,FALSE,TRUE,FALSE,TRUE,TRUE
|
||||
-68,-42,1,0,1/11/2030,1/11/2030,E030,E03,0SW5X8Z,04734FZ,Same day readmit and discharge,FALSE,TRUE,FALSE,TRUE,TRUE,TRUE
|
||||
-68,-43,1,0,1/11/2030,1/21/2030,E301,E03,0SW5X8Z,04734FZ,Same Day readmit and discharge,TRUE,FALSE,TRUE,FALSE,TRUE,TRUE
|
||||
-69,-3458925,1,0,1/5/2019,1/6/2019,E1010,N179,,,Client Example 1,FALSE,FALSE,FALSE,TRUE,TRUE,TRUE
|
||||
-69,-3525720,1,0,3/17/2019,3/19/2019,E1110,E871,,,Client Example 2,FALSE,TRUE,TRUE,TRUE,TRUE,TRUE
|
||||
-69,-3552421,1,0,4/15/2019,4/18/2019,E1010,K5900,BW211ZZ,,Client Example 3,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE
|
||||
-69,-3576528,1,0,5/12/2019,5/14/2019,E1010,E871,,,Client Example 4,TRUE,FALSE,TRUE,TRUE,TRUE,TRUE
|
||||
-69,-3652662,1,0,8/7/2019,8/9/2019,E1010,E870,05HY33Z,,Client Example 5,FALSE,FALSE,TRUE,TRUE,TRUE,TRUE
|
||||
-69,-3709446,1,0,10/4/2019,10/7/2019,E1010,E872,,,Client Example 6,FALSE,TRUE,TRUE,TRUE,TRUE,TRUE
|
||||
-69,-3740054,1,0,11/6/2019,11/9/2019,E1010,J069,,,Client Example 7,TRUE,FALSE,TRUE,TRUE,TRUE,TRUE
|
||||
-69,-3805926,1,0,1/22/2020,1/23/2020,E1010,N179,,,Client Example 8,FALSE,TRUE,TRUE,TRUE,TRUE,TRUE
|
||||
-69,-3834689,1,0,2/19/2020,2/21/2020,E1010,E860,,,Client Example 9,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE
|
||||
-69,-3857183,1,0,3/14/2020,3/15/2020,E1010,E8339,,,Client Example 10,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE
|
||||
-69,-3861884,1,0,3/21/2020,3/23/2020,E1010,N179,,,Client Example 11,TRUE,FALSE,TRUE,TRUE,TRUE,TRUE
|
||||
-69,-3880338,1,0,4/27/2020,4/29/2020,E1010,G9340,BR20ZZZ,BW28ZZZ,Client Example 12,FALSE,FALSE,TRUE,TRUE,TRUE,TRUE
|
||||
-69,-3906214,1,0,6/1/2020,6/3/2020,E1010,E860,,,Client Example 13,FALSE,TRUE,TRUE,TRUE,TRUE,TRUE
|
||||
-69,-3915939,1,0,6/13/2020,6/16/2020,E1010,N390,BW211ZZ,,Client Example 14,TRUE,FALSE,TRUE,FALSE,TRUE,TRUE
|
||||
-69,-4117703,1,0,1/19/2021,1/22/2021,E1010,E876,,,Client Example 15,FALSE,TRUE,FALSE,TRUE,TRUE,TRUE
|
||||
-69,-4131168,1,0,1/31/2021,2/2/2021,E1010,N179,,,Client Example 16,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE
|
||||
-69,-4136598,1,0,2/4/2021,2/6/2021,E1010,K047,,,Client Example 17,TRUE,FALSE,TRUE,TRUE,TRUE,TRUE
|
||||
-69,-4178296,1,0,3/13/2021,3/15/2021,E1110,G9341,02HV33Z,B548ZZA,Client Example 18,FALSE,TRUE,TRUE,TRUE,TRUE,TRUE
|
||||
-69,-4192591,1,0,3/27/2021,3/28/2021,E1010,N179,,,Client Example 19,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE
|
||||
-69,-4200663,1,0,4/4/2021,4/6/2021,E1010,M1990,,,Client Example 20,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE
|
||||
-69,-4228571,1,0,5/2/2021,5/4/2021,E1010,E876,06HN33Z,,Client Example 21,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE
|
||||
-69,-4240674,1,0,5/14/2021,5/17/2021,E1010,J95811,05H533Z,0W9930Z,Client Example 22,TRUE,FALSE,TRUE,TRUE,TRUE,TRUE
|
||||
-69,-4286465,1,0,7/1/2021,7/4/2021,E1010,Z9114,,,Client Example 23,FALSE,FALSE,TRUE,FALSE,TRUE,TRUE
|
||||
-69,-4392493,1,0,10/14/2021,10/17/2021,E1010,N179,,,Client Example 24,FALSE,FALSE,FALSE,TRUE,TRUE,TRUE
|
||||
-69,-4440146,1,0,12/5/2021,12/7/2021,E1010,N179,,,Client Example 25,FALSE,TRUE,TRUE,TRUE,TRUE,TRUE
|
||||
-69,-4467167,1,0,1/3/2022,1/5/2022,E1010,N179,,,Client Example 26,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE
|
||||
-69,-4475791,1,0,1/12/2022,1/13/2022,E1010,K219,05H533Z,,Client Example 27,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE
|
||||
-69,-4493555,1,0,1/30/2022,1/31/2022,E1010,K219,BW251ZZ,,Client Example 28,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE
|
||||
-69,-4498191,1,0,2/3/2022,2/7/2022,E1010,E872,,,Client Example 29,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE
|
||||
-69,-4525932,1,0,3/6/2022,3/8/2022,E1010,N179,,,Client Example 30,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE
|
||||
-69,-4543519,1,0,3/27/2022,3/28/2022,E1010,N179,,,Client Example 31,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE
|
||||
-69,-4556181,1,0,4/8/2022,4/11/2022,E1010,Z9641,,,Client Example 32,TRUE,FALSE,TRUE,TRUE,TRUE,TRUE
|
||||
-69,-4601338,1,0,5/28/2022,5/29/2022,E1010,E876,,,Client Example 33,FALSE,TRUE,TRUE,TRUE,TRUE,TRUE
|
||||
-69,-4627620,1,0,6/24/2022,6/25/2022,E1010,Z794,,,Client Example 34,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE
|
||||
-69,-4632125,1,0,6/29/2022,7/1/2022,E1010,E1042,,,Client Example 35,TRUE,FALSE,TRUE,FALSE,TRUE,TRUE
|
||||
-70,-45,1,0,1/11/2030,1/11/2030,E1010,E876,,,"Encounter -45 and -46 should be treated as the same encounter (-45 is the index, -46 is not)",FALSE,FALSE,FALSE,FALSE,FALSE,TRUE
|
||||
-70,-46,1,0,1/11/2030,1/21/2030,E1010,Z794,,,Encounter -45 and -46 should be treated as the same encounter,FALSE,TRUE,FALSE,TRUE,TRUE,FALSE
|
||||
-70,-47,1,0,1/22/2030,1/24/2030,E1010,E1042,,,Encounter -45 and -46 should be treated as the same encounter,TRUE,FALSE,TRUE,FALSE,TRUE,TRUE
|
||||
-71,-48,1,0,1/11/2030,1/11/2030,E1010,E876,,,Encounter -49 and -50 should be treated as the same encounter,FALSE,TRUE,FALSE,TRUE,TRUE,TRUE
|
||||
-71,-49,1,0,1/12/2030,1/22/2030,E1010,Z794,,,Encounter -49 and -50 should be treated as the same encounter (-49 should be the readmit),TRUE,FALSE,TRUE,FALSE,FALSE,TRUE
|
||||
-71,-50,1,0,1/22/2030,1/24/2030,E1010,E1042,,,Encounter -49 and -50 should be treated as the same encounter,FALSE,FALSE,FALSE,FALSE,TRUE,FALSE
|
||||
-72,-51,1,0,1/11/2030,1/11/2030,E1010,E876,,,31 days after the first encounter discharge,FALSE,FALSE,FALSE,FALSE,FALSE,TRUE
|
||||
-72,-52,1,0,1/11/2030,1/21/2030,E1010,Z794,,,31 days after the first encounter discharge,FALSE,FALSE,FALSE,TRUE,TRUE,FALSE
|
||||
-72,-53,1,0,2/21/2030,1/24/2030,E1010,E1042,,,31 days after the first encounter discharge,FALSE,FALSE,TRUE,FALSE,TRUE,TRUE
|
||||
-73,-54,1,0,1/11/2030,1/11/2030,E1010,E876,,,Same Day Readmit 55 days after the first encounter discharge,FALSE,FALSE,FALSE,TRUE,TRUE,TRUE
|
||||
-73,-55,1,0,3/7/2030,3/12/2030,E1010,Z794,,,Same Day Readmit 55 days after the first encounter discharge,FALSE,FALSE,TRUE,FALSE,FALSE,TRUE
|
||||
-73,-56,1,0,3/12/2030,3/16/2030,E1010,E1042,,,Same Day Readmit 55 days after the first encounter discharge,FALSE,FALSE,FALSE,FALSE,TRUE,FALSE
|
||||
-74,-57,1,0,1/11/2030,1/11/2030,E1010,E876,,,Same Day Index 31 days after the second encounter discharge,FALSE,FALSE,FALSE,FALSE,FALSE,TRUE
|
||||
-74,-58,1,0,1/11/2030,1/21/2030,E1010,Z794,,,Same Day Index 31 days after the second encounter discharge,FALSE,FALSE,FALSE,TRUE,TRUE,FALSE
|
||||
-74,-59,1,0,2/21/2030,2/22/2030,E1010,E1042,,,Same Day Index 31 days after the second encounter discharge,FALSE,FALSE,TRUE,FALSE,TRUE,TRUE
|
||||
-75,-60,1,0,1/11/2030,1/11/2030,E1010,E876,,,Same Day Readmit 30 days before the first encounter readmit,FALSE,TRUE,FALSE,TRUE,TRUE,TRUE
|
||||
-75,-61,1,0,2/10/2030,2/12/2030,E1010,Z794,,,Same Day Readmit 30 days before the first encounter readmit,TRUE,FALSE,TRUE,FALSE,FALSE,TRUE
|
||||
-75,-62,1,0,2/12/2030,2/25/2030,E1010,E1042,,,Same Day Readmit 30 days before the first encounter readmit,FALSE,FALSE,FALSE,FALSE,TRUE,FALSE
|
||||
-76,-63,1,0,1/11/2030,1/11/2030,E1010,E876,,,Same Day Readmit 31 days before the second encounter readmit,FALSE,FALSE,FALSE,TRUE,TRUE,TRUE
|
||||
-76,-64,1,0,2/11/2030,2/20/2030,E1010,Z794,,,Same Day Readmit 31 days before the second encounter readmit,FALSE,FALSE,TRUE,FALSE,FALSE,TRUE
|
||||
-76,-65,1,0,2/20/2030,2/25/2030,E1010,E1042,,,Same Day Readmit 31 days before the second encounter readmit,FALSE,FALSE,FALSE,FALSE,TRUE,FALSE
|
||||
-77,-66,1,0,1/10/2030,1/11/2030,E03,E030,0SW5X8Z,04734FZ,Readmit because of potential planned procedure but acute diagnosis,FALSE,TRUE,FALSE,TRUE,TRUE,TRUE
|
||||
-77,-67,1,0,1/20/2030,1/21/2030,A150,E030,00800ZZ,04734FZ,Readmit because of potential planned procedure but acute diagnosis,TRUE,FALSE,TRUE,FALSE,FALSE,TRUE
|
||||
|
+51
@@ -0,0 +1,51 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="AutoMapperTests.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AWSSDK.SecurityToken" Version="3.7.100.21" />
|
||||
<PackageReference Include="FluentAssertions" Version="6.8.0" />
|
||||
<PackageReference Include="Hangfire.MemoryStorage" Version="1.7.0" />
|
||||
<PackageReference Include="Hangfire.NetCore" Version="1.7.31" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.10">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Moq" Version="4.18.2" />
|
||||
<PackageReference Include="NUnit" Version="3.13.3" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="4.3.0" />
|
||||
<PackageReference Include="coverlet.msbuild" Version="3.2.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
|
||||
<PackageReference Include="Strata.ApiLib.Core" Version="5.2.0" />
|
||||
<PackageReference Include="Strata.Configuration.Client" Version="8.17.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Strata.Stratasphere.Biz\Strata.Stratasphere.Biz.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="appsettings.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Standards\IntegrationTests\TestData\Readmit Test Data.csv">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Debug",
|
||||
"System": "Information",
|
||||
"Microsoft": "Information"
|
||||
}
|
||||
},
|
||||
|
||||
"Snowflake": {
|
||||
"Url": "https://stratadev.us-east-1.privatelink.snowflakecomputing.com",
|
||||
"Account": "stratadev",
|
||||
"RoleName": "DATAADMIN",
|
||||
"Warehouse": "DATA_ANALYSIS_WH",
|
||||
"StandardsWarehouseSize": "XSMALL",
|
||||
"StandardsWarehouseMaxClusterSize": "1",
|
||||
"StandardsWarehouse": "STANDARDS_WH",
|
||||
"AdminRoleName": "DEVADMIN",
|
||||
"SphCoreRoleName": "SPHCORE"
|
||||
},
|
||||
|
||||
|
||||
"aws": {
|
||||
"masterEncounterListSQSQueueName": "sdt-masterencounterlist-queue",
|
||||
"snowflakeAdminSecretName": "stratareplication/snowflake/automation/connectionstring"
|
||||
},
|
||||
|
||||
"s3": {
|
||||
"bucketName": "sdt-dev-data-wrangler"
|
||||
},
|
||||
|
||||
"configuration": {
|
||||
"basicAuthUsername": "BkQsRDdmdjkFNhKVuTI.TpujQJXuKhGDcV.F_hjADMRTaEUWMJnviaesoOrhhfnz",
|
||||
"basicAuthPassword": "GWPIIWECDqh.hjDNdpxVEfeFe-bYFwPSx-oBGFD_od_SUQVk-QqTIkZY_NXMeqeo"
|
||||
},
|
||||
|
||||
"StrataConfigServerBaseUrl": "https://configuration.dev.stratanetwork.net"
|
||||
}
|
||||
@@ -0,0 +1,862 @@
|
||||
using Newtonsoft.Json;
|
||||
using NUnit.Framework;
|
||||
using Strata.Stratasphere.Biz.DataManagement.Models;
|
||||
using Strata.Stratasphere.Biz.Parser;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Strata.Stratasphere.Biz.UnitTests.Parser
|
||||
{
|
||||
|
||||
[TestFixture]
|
||||
public class DirectedAcyclicGraphTests
|
||||
{
|
||||
[Test]
|
||||
public void AddEdgesWithCycles()
|
||||
{
|
||||
var graph = new DirectedAcyclicGraph<int>(new[] { 1, 2, 3, 4 });
|
||||
|
||||
Assert.DoesNotThrow(() => graph.AddEdge(1, 2));
|
||||
Assert.DoesNotThrow(() => graph.AddEdge(2, 3));
|
||||
Assert.DoesNotThrow(() => graph.AddEdge(3, 4));
|
||||
Assert.DoesNotThrow(() => graph.AddEdge(3, 2));
|
||||
|
||||
Assert.That(() => graph.IsCyclicTest(),
|
||||
Throws.TypeOf<InvalidOperationException>()
|
||||
.With.Message.EqualTo("Cannot add this edge 3->2 because it would create a cycle"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AddEdgesWithoutCycles()
|
||||
{
|
||||
var graph = new DirectedAcyclicGraph<int>(new[] { 1, 2, 3, 4 });
|
||||
|
||||
Assert.DoesNotThrow(() => graph.AddEdge(1, 2));
|
||||
Assert.DoesNotThrow(() => graph.AddEdge(2, 3));
|
||||
Assert.DoesNotThrow(() => graph.AddEdge(3, 4));
|
||||
Assert.DoesNotThrow(() => graph.IsCyclicTest());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AddFullDAGWithoutCycles()
|
||||
{
|
||||
var graph = new DirectedAcyclicGraph<int>(new[] { 1, 2, 3, 4, 5, 6, 7, 8 });
|
||||
|
||||
Assert.DoesNotThrow(() => graph.AddEdge(1, 2));
|
||||
Assert.DoesNotThrow(() => graph.AddEdge(3, 4));
|
||||
Assert.DoesNotThrow(() => graph.AddEdge(2, 5));
|
||||
Assert.DoesNotThrow(() => graph.AddEdge(5, 6));
|
||||
Assert.DoesNotThrow(() => graph.AddEdge(5, 7));
|
||||
Assert.DoesNotThrow(() => graph.AddEdge(6, 7));
|
||||
Assert.DoesNotThrow(() => graph.AddEdge(7, 8));
|
||||
Assert.DoesNotThrow(() => graph.AddEdge(4, 1));
|
||||
Assert.DoesNotThrow(() => graph.IsCyclicTest());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AddEdgeWithUnknownTargetNode()
|
||||
{
|
||||
var graph = new DirectedAcyclicGraph<int>(new[] { 1, 2 });
|
||||
Assert.That(() => graph.AddEdge(1, 3),
|
||||
Throws.TypeOf<InvalidOperationException>()
|
||||
.With.Message.EqualTo("Node 3 not found"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AddEdgeWithUnknownSourceNode()
|
||||
{
|
||||
var graph = new DirectedAcyclicGraph<int>(new[] { 1, 2 });
|
||||
|
||||
Assert.That(() => graph.AddEdge(3, 2),
|
||||
Throws.TypeOf<InvalidOperationException>()
|
||||
.With.Message.EqualTo("Node 3 not found"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetTopologicallyOrderedNodes()
|
||||
{
|
||||
var graph = new DirectedAcyclicGraph<int>(new[] { 1, 2, 3, 4, 5, 6, 7, 8 });
|
||||
|
||||
graph.AddEdge(1, 3);
|
||||
graph.AddEdge(2, 3);
|
||||
graph.AddEdge(3, 4);
|
||||
graph.AddEdge(4, 8);
|
||||
graph.AddEdge(4, 5);
|
||||
graph.AddEdge(2, 6);
|
||||
graph.AddEdge(5, 6);
|
||||
graph.AddEdge(6, 7);
|
||||
Assert.DoesNotThrow(() => graph.IsCyclicTest());
|
||||
|
||||
var topOrdered = graph.TopologicalSort();
|
||||
|
||||
CollectionAssert.AreEqual(new[] { 1, 2, 3, 4, 8, 5, 6, 7 }, topOrdered);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GenerationCalc_EmptyGraph()
|
||||
{
|
||||
var graph = new DirectedAcyclicGraph<int>(new int[0]);
|
||||
|
||||
var generationLookup = graph.GetNodeGenerationLookup();
|
||||
|
||||
CollectionAssert.AreEqual(new Dictionary<int, int>(), generationLookup);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GenerationCalc_SingleNode()
|
||||
{
|
||||
var graph = new DirectedAcyclicGraph<string>(new[] { "Node_1_0" });
|
||||
|
||||
var expected = new Dictionary<string, int>
|
||||
{
|
||||
{ "Node_1_0", 0 }
|
||||
};
|
||||
|
||||
CollectionAssert.AreEqual(expected, graph.GetNodeGenerationLookup());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GenerationCalc_SingleEdge()
|
||||
{
|
||||
var graph = new DirectedAcyclicGraph<string>(new[] { "Node_1_0", "Node_2_1" });
|
||||
|
||||
graph.AddEdge("Node_1_0", "Node_2_1");
|
||||
|
||||
var expected = new Dictionary<string, int>
|
||||
{
|
||||
{ "Node_1_0", 0 },
|
||||
{ "Node_2_1", 1 }
|
||||
};
|
||||
|
||||
var actual = graph.GetNodeGenerationLookup();
|
||||
|
||||
CollectionAssert.AreEqual(expected, actual);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GenerationCalc_TwoNodesInGen1()
|
||||
{
|
||||
var graph = new DirectedAcyclicGraph<string>(new[] { "Node_1_0", "Node_2_1", "Node_3_1" });
|
||||
|
||||
graph.AddEdge("Node_1_0", "Node_2_1");
|
||||
graph.AddEdge("Node_1_0", "Node_3_1");
|
||||
|
||||
var expected = new Dictionary<string, int>
|
||||
{
|
||||
{ "Node_1_0", 0 },
|
||||
{ "Node_2_1", 1 },
|
||||
{ "Node_3_1", 1 }
|
||||
};
|
||||
|
||||
var actual = graph.GetNodeGenerationLookup();
|
||||
|
||||
CollectionAssert.AreEqual(expected, actual);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GenerationCalc_MultipleGenerations()
|
||||
{
|
||||
var graph = new DirectedAcyclicGraph<string>(new[] { "Node_1_0", "Node_2_1", "Node_3_1", "Node_4_2", "Node_5_2", "Node_6_2" });
|
||||
|
||||
graph.AddEdge("Node_1_0", "Node_2_1");
|
||||
graph.AddEdge("Node_2_1", "Node_4_2");
|
||||
graph.AddEdge("Node_2_1", "Node_5_2");
|
||||
graph.AddEdge("Node_1_0", "Node_3_1");
|
||||
graph.AddEdge("Node_3_1", "Node_6_2");
|
||||
|
||||
var expected = new Dictionary<string, int>
|
||||
{
|
||||
{ "Node_1_0", 0 },
|
||||
{ "Node_2_1", 1 },
|
||||
{ "Node_3_1", 1 },
|
||||
{ "Node_4_2", 2 },
|
||||
{ "Node_5_2", 2 },
|
||||
{ "Node_6_2", 2 }
|
||||
};
|
||||
|
||||
var actual = graph.GetNodeGenerationLookup();
|
||||
|
||||
CollectionAssert.AreEqual(expected, actual);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GenerationCalc_ChildNodesReferenceEachOther()
|
||||
{
|
||||
var graph = new DirectedAcyclicGraph<string>(new[] { "Node_1_0", "Node_2_1", "Node_3_1", "Node_4_3", "Node_5_2", "Node_6_2" });
|
||||
|
||||
graph.AddEdge("Node_1_0", "Node_2_1");
|
||||
graph.AddEdge("Node_2_1", "Node_4_3");
|
||||
graph.AddEdge("Node_2_1", "Node_5_2");
|
||||
graph.AddEdge("Node_5_2", "Node_4_3");
|
||||
graph.AddEdge("Node_1_0", "Node_3_1");
|
||||
graph.AddEdge("Node_3_1", "Node_6_2");
|
||||
|
||||
var expected = new Dictionary<string, int>
|
||||
{
|
||||
{ "Node_1_0", 0 },
|
||||
{ "Node_2_1", 1 },
|
||||
{ "Node_3_1", 1 },
|
||||
{ "Node_4_3", 3 },
|
||||
{ "Node_5_2", 2 },
|
||||
{ "Node_6_2", 2 }
|
||||
};
|
||||
|
||||
var actual = graph.GetNodeGenerationLookup();
|
||||
|
||||
CollectionAssert.AreEqual(expected, actual);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GenerationCalc_MultipleOriginsAndChildNodesReferenceEachOther()
|
||||
{
|
||||
var nodes = new[]
|
||||
{
|
||||
"Node_1_0",
|
||||
"Node_2_1",
|
||||
"Node_3_1",
|
||||
"Node_4_3",
|
||||
"Node_5_2",
|
||||
"Node_6_2",
|
||||
"Node_7_0",
|
||||
"Node_8_1",
|
||||
"Node_9_1",
|
||||
"Node_10_3",
|
||||
"Node_11_2",
|
||||
"Node_12_2",
|
||||
};
|
||||
|
||||
var graph = new DirectedAcyclicGraph<string>(nodes);
|
||||
|
||||
graph.AddEdge("Node_1_0", "Node_2_1");
|
||||
graph.AddEdge("Node_2_1", "Node_4_3");
|
||||
graph.AddEdge("Node_2_1", "Node_5_2");
|
||||
graph.AddEdge("Node_5_2", "Node_4_3");
|
||||
graph.AddEdge("Node_1_0", "Node_3_1");
|
||||
graph.AddEdge("Node_3_1", "Node_6_2");
|
||||
|
||||
graph.AddEdge("Node_7_0", "Node_8_1");
|
||||
graph.AddEdge("Node_8_1", "Node_10_3");
|
||||
graph.AddEdge("Node_8_1", "Node_11_2");
|
||||
graph.AddEdge("Node_11_2", "Node_10_3");
|
||||
graph.AddEdge("Node_7_0", "Node_9_1");
|
||||
graph.AddEdge("Node_9_1", "Node_12_2");
|
||||
|
||||
var expected = new Dictionary<string, int>
|
||||
{
|
||||
{ "Node_1_0", 0 },
|
||||
{ "Node_2_1", 1 },
|
||||
{ "Node_3_1", 1 },
|
||||
{ "Node_4_3", 3 },
|
||||
{ "Node_5_2", 2 },
|
||||
{ "Node_6_2", 2 },
|
||||
{ "Node_7_0", 0 },
|
||||
{ "Node_8_1", 1 },
|
||||
{ "Node_9_1", 1 },
|
||||
{ "Node_10_3", 3 },
|
||||
{ "Node_11_2", 2 },
|
||||
{ "Node_12_2", 2 }
|
||||
};
|
||||
|
||||
var actual = graph.GetNodeGenerationLookup();
|
||||
|
||||
CollectionAssert.AreEqual(expected, actual);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestFunctionalDAG()
|
||||
{
|
||||
|
||||
var json = @"[
|
||||
{
|
||||
""queryId"": 2058,
|
||||
""queryText"": ""SELECT sum(Value) as GLDollars, FiscalYearCode,FiscalMonthCode,CalendarYear,CalendarMonth,
|
||||
AccountID,DepartmentID,DepartmentCode,DepartmentType
|
||||
,ClientEntityID, SPHEntityID, SPHisVariableAcctDept
|
||||
,SPHDepartmentRollup,SPHCategory,SPHLineItem,SPHSection,SPHStatement,ORGPIN
|
||||
FROM {{ref('GL_Initial_Stage')}}
|
||||
WHERE FiscalMonthCode != 'Not Specified'
|
||||
GROUP BY FiscalYearCode,FiscalMonthCode,CalendarYear,CalendarMonth,AccountID
|
||||
,DepartmentID,DepartmentCode,DepartmentType,
|
||||
ClientEntityID,SPHEntityID,SPHisVariableAcctDept
|
||||
,SPHDepartmentRollup,SPHCategory,SPHLineItem,SPHSection,SPHStatement,ORGPIN"",
|
||||
""targetTable"": ""DepartmentGL"",
|
||||
""description"": ""sum GL dollars, final Dept GL table"",
|
||||
""materializationType"": 1,
|
||||
""processId"": 161,
|
||||
""displayOrder"": 2,
|
||||
""clientQueries"": [],
|
||||
""queryTags"": [
|
||||
{
|
||||
""queryTagId"": 11084,
|
||||
""tagId"": 21,
|
||||
""queryId"": 2058
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
""queryId"": 2059,
|
||||
""queryText"": ""select distinct
|
||||
entMap.SPHEntityID,
|
||||
entMap.ClientEntityID,
|
||||
entmap.SourceTable,
|
||||
entmap.StrataID as em_StrataID,
|
||||
entmap.ORGPIN
|
||||
from datalake_sandbox.config.Entity_MAPPING as entmap
|
||||
WHERE entmap.strataid = $StrataID
|
||||
and entmap.EntityType = 'GL'
|
||||
"",
|
||||
""targetTable"": ""Org_EntityMapping"",
|
||||
""description"": ""get entity mappings"",
|
||||
""materializationType"": 1,
|
||||
""processId"": 161,
|
||||
""displayOrder"": 0,
|
||||
""clientQueries"": [],
|
||||
""queryTags"": [
|
||||
{
|
||||
""queryTagId"": 11060,
|
||||
""tagId"": 21,
|
||||
""queryId"": 2059
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
""queryId"": 2454,
|
||||
""queryText"": ""SELECT DISTINCT
|
||||
/* Custom GL Dollars */
|
||||
CASE WHEN dgl.OrgPin in (2962) and dgl.AccountID in (1838, 1545, 1122, 1128) THEN GLDollars * -1
|
||||
WHEN dgl.OrgPin in (3120, 2980) and dgl.SPHCategory in ('Revenue Deduction') THEN GLDollars * -1
|
||||
WHEN dgl.OrgPin in (1170) and dgl.AccountID in (4809) THEN GLDollars * -1
|
||||
WHEN dgl.OrgPin in (1975) and dgl.AccountID in (7742) THEN GLDollars * -1
|
||||
WHEN dgl.OrgPin in (2724) and dgl.AccountID in (1346, 1394, 1395, 1443) THEN GLDollars * -1
|
||||
ELSE GLDollars END as GLDollars,
|
||||
FiscalYearCode,
|
||||
FiscalMonthCode,
|
||||
CalendarYear,
|
||||
CalendarMonth,
|
||||
dgl.AccountID,
|
||||
da.AccountCode,
|
||||
da.Description as GLDescription,
|
||||
dgl.DepartmentID,
|
||||
dgl.DepartmentCode,
|
||||
dgl.ClientEntityID,
|
||||
dgl.SPHisVariableAcctDept,
|
||||
dgl.SPHDepartmentRollup,
|
||||
dgl.SPHCategory,
|
||||
dgl.SPHLineItem,
|
||||
dgl.SPHSection,
|
||||
dgl.SPHStatement,
|
||||
dgl.DepartmentType,
|
||||
dgl.SPHEntityID,
|
||||
dgl.orgpin as orgpin_sys,
|
||||
CASE WHEN dd.SPHDEPARTMENTROLLUPCONFIDENCESCORE=1 THEN 1 ELSE 0 END AS IsValidatedSPHDepartmentRollup,
|
||||
CASE WHEN da.SPHACCOUNTROLLUPCONFIDENCESCORE=1 THEN 1 ELSE 0 END AS IsValidatedSPHLineItem
|
||||
FROM {{ref('DepartmentGL')}} dgl
|
||||
LEFT JOIN FW.DIMACCOUNT da ON dgl.AccountID=da.AccountID
|
||||
LEFT JOIN FW.DIMDEPARTMENT dd ON dgl.DepartmentID=dd.DepartmentID"",
|
||||
""targetTable"": ""Gl_DEPARTMENTGL_stage"",
|
||||
""description"": ""custom GL Dollar, DepartmentType"",
|
||||
""materializationType"": 1,
|
||||
""processId"": 161,
|
||||
""displayOrder"": 3,
|
||||
""clientQueries"": [],
|
||||
""queryTags"": [
|
||||
{
|
||||
""queryTagId"": 11080,
|
||||
""tagId"": 21,
|
||||
""queryId"": 2454
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
""queryId"": 2455,
|
||||
""queryText"": ""SELECT gl.*
|
||||
FROM {{ref('Gl_DEPARTMENTGL_stage')}} as gl inner join DATALAKE_SANDBOX.CONFIG.SYSTEM_CRITERIA as s on s.orgpin = gl.orgpin_sys
|
||||
WHERE
|
||||
/* DATA TO BE FILTERED OUT */
|
||||
(s.orgpin = 1178 AND gl.AccountID IN (13238,13239,13461,14102,13240,13241,13242,
|
||||
13236,13237,13243,14722,15227))
|
||||
OR (s.orgpin = 3120 AND gl.AccountID IN (97))
|
||||
OR (s.orgpin = 3196 AND gl.AccountID IN (1031))
|
||||
OR ( s.orgpin = 2973 AND gl.AccountID IN (485, 486, 488, 490, 493, 494, 1901, 1909))
|
||||
OR ( s.orgpin = 3167 AND gl.AccountID IN (257,7369))
|
||||
OR ( s.orgpin = 2951 AND gl.AccountID IN (247))
|
||||
OR ( s.orgpin = 2717 AND gl.AccountID IN (7))
|
||||
OR ( s.orgpin = 3109 AND gl.AccountID IN (1352))
|
||||
OR ( s.orgpin = 3113 AND gl.AccountID IN (70272))
|
||||
OR ( s.orgpin = 3157 AND gl.AccountID IN (20415))
|
||||
OR ( s.orgpin = 3202 AND gl.AccountID IN (4085, 2984))
|
||||
OR ( s.orgpin = 1975 and (
|
||||
(AccountID IN (734) and gl.ClientEntityID=17 /*SYSTEM SERVICES Entity*/) or
|
||||
(AccountCode like '%0090%' or GLDescription like 'SS-%') or
|
||||
(AccountID IN (2310, 2313, 2318,2319, 2320, 2321, 2322, 2324, 2328, 2294,
|
||||
2295, 2296, 2298, 2299, 2302, 5832, 2306, 3284, 3286, 3287, 3288, 3290, 12434, 3295,
|
||||
3297, 5838, 2291, 5841, 16174, 16873, 16874, 16875, 16876, 16877, 16879, 13349,
|
||||
22261, 22256, 22309, 22288, 22270, 22280, 22513, 23954, 22291, 22301, 22294, 22264,
|
||||
22353,22283, 22308, 22297, 23082, 22282, 22278, 22292, 22281, 22277, 22510, 23083,
|
||||
12327, 23950, 12957, 20308, 25753, 16306, 12963, 11391, 16992, 14101, 14304, 16993,
|
||||
17213, 14333, 13749, 973, 974, 975, 976, 977, 978, 983, 1041, 2672, 3576, 12448,
|
||||
12793, 12798, 19985, 21969))
|
||||
))
|
||||
OR ( s.orgpin = 1137 AND CalendarYear= 2021 and CalendarMonth = 4 AND gl.AccountID IN (613))
|
||||
OR ( s.orgpin = 3179 AND gl.AccountID IN (9828))
|
||||
OR ( s.orgpin = 3228 AND gl.AccountID IN (778))
|
||||
OR ( s.orgpin = 3266 AND gl.AccountID IN (518))
|
||||
OR ( s.orgpin = 1475 AND gl.DepartmentCode IN ('1.10201199'))
|
||||
OR ( s.orgpin = 3196 AND gl.AccountID IN (517) and DepartmentCode IN ('01.9000'))
|
||||
OR ( s.orgpin = 2052 and CalendarYear = 2021 and CalendarMonth = 6 AND gl.AccountID IN (710, 711, 712))"",
|
||||
""targetTable"": ""Gl_DEPARTMENTGL_stage_filter"",
|
||||
""description"": ""data to be filtered out via customizations"",
|
||||
""materializationType"": 1,
|
||||
""processId"": 161,
|
||||
""displayOrder"": 4,
|
||||
""clientQueries"": [],
|
||||
""queryTags"": [
|
||||
{
|
||||
""queryTagId"": 11066,
|
||||
""tagId"": 21,
|
||||
""queryId"": 2455
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
""queryId"": 2456,
|
||||
""queryText"": ""select
|
||||
s.*
|
||||
from {{ref('Gl_DEPARTMENTGL_stage')}} as s
|
||||
except (
|
||||
select *
|
||||
from {{ref('Gl_DEPARTMENTGL_stage_filter')}}
|
||||
)"",
|
||||
""targetTable"": ""GL_Summary_Stage"",
|
||||
""description"": ""Handle custom exclusions - last step before data is ready"",
|
||||
""materializationType"": 1,
|
||||
""processId"": 161,
|
||||
""displayOrder"": 5,
|
||||
""clientQueries"": [],
|
||||
""queryTags"": [
|
||||
{
|
||||
""queryTagId"": 11076,
|
||||
""tagId"": 21,
|
||||
""queryId"": 2456
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
""queryId"": 2457,
|
||||
""queryText"": ""SELECT
|
||||
AccountID,
|
||||
CalendarMonth,
|
||||
CalendarYear,
|
||||
ClientEntityID,
|
||||
DepartmentCode,
|
||||
DepartmentID,
|
||||
DepartmentType,
|
||||
FiscalMonthCode,
|
||||
FiscalYearCode,
|
||||
GLDollars,
|
||||
IsValidatedSPHDepartmentRollup,
|
||||
IsValidatedSPHLineItem,
|
||||
SPHCategory,
|
||||
SPHDepartmentRollup,
|
||||
SPHEntityID,
|
||||
SPHisVariableAcctDept,
|
||||
SPHLineItem,
|
||||
SPHSection,
|
||||
SPHStatement
|
||||
FROM {{ref('GL_Summary_Stage')}}"",
|
||||
""targetTable"": ""GL_Summary"",
|
||||
""description"": ""Final output of GL Datamart"",
|
||||
""materializationType"": 0,
|
||||
""processId"": 161,
|
||||
""displayOrder"": 6,
|
||||
""clientQueries"": [],
|
||||
""queryTags"": [
|
||||
{
|
||||
""queryTagId"": 11081,
|
||||
""tagId"": 21,
|
||||
""queryId"": 2457
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
""queryId"": 2458,
|
||||
""queryText"": ""SELECT
|
||||
(CASE
|
||||
WHEN acct.isinverted = 1 THEN data.Value * -1
|
||||
ELSE data.Value
|
||||
END) AS Value,
|
||||
data.AccountID,
|
||||
data.FiscalYearCode,
|
||||
data.FiscalMonthCode,
|
||||
dt.CalendarYear,
|
||||
dt.CalendarMonth,
|
||||
dt.CalendarQuarter,
|
||||
data.TimeClassCode,
|
||||
acct.SPAccountRollupCategory,
|
||||
acct.SPAccountRollupName,
|
||||
acct.OBDollarsFinancialReporting,
|
||||
acct.OBDollarsFinancialReportingCategory,
|
||||
acct.OBDollarsFinancialReportingLineName,
|
||||
acct.DSSAccountRollup1Name,
|
||||
acct.Variability,
|
||||
dd.DepartmentID,
|
||||
dd.DepartmentCode,
|
||||
dd.DepartmentType,
|
||||
dd.IsMRPlan,
|
||||
dd.IsVariable,
|
||||
COALESCE(
|
||||
emap.CLIENTENTITYID,
|
||||
dr1map.CLIENTENTITYID,
|
||||
NULL
|
||||
) as ClientEntityID,
|
||||
COALESCE(
|
||||
emap.SPHEntityID,
|
||||
dr1map.SPHEntityID
|
||||
) as SPHEntityID,
|
||||
(CASE WHEN (acct.Variability=1 and dd.IsVariable=1) THEN '1' ELSE '0' END) AS SPHisVariableAcctDept,
|
||||
sphdr.Name as SPHDepartmentRollup,
|
||||
sphar.Category as SPHCategory,
|
||||
sphar.LineItem as SPHLineItem,
|
||||
sphar.Section as SPHSection,
|
||||
sphar.Statement as SPHStatement,
|
||||
$OrgPin as ORGPIN
|
||||
FROM int.FactGL data
|
||||
INNER JOIN fw.DimAccount acct ON acct.AccountID=data.AccountID
|
||||
INNER JOIN (SELECT distinct CalendarYear,CalendarMonth,CalendarQuarter,FiscalYear,FiscalMonth
|
||||
FROM fw.DimDate
|
||||
WHERE FiscalMonth != 0 or FiscalMonth != '0') dt on dt.FiscalYear=data.FiscalYearCode and dt.FiscalMonth=data.FiscalMonthCode
|
||||
INNER JOIN fw.DimDepartment dd ON dd.DepartmentID=data.DepartmentID
|
||||
INNER JOIN fw.DimFiscalMonth fm ON fm.FiscalMonthID=data.FiscalMonthID
|
||||
LEFT JOIN fw.DimEntity e on dd.EntityID=e.EntityID
|
||||
INNER JOIN fw.DimSPHDepartmentRollup as sphdr on sphdr.SPHDepartmentRollupID = dd.SPHDepartmentRollupID
|
||||
INNER JOIN fw.DimSPHAccountRollup as sphar on sphar.SPHAccountRollupID = acct.SPHAccountRollupID
|
||||
LEFT JOIN {{ref('Org_EntityMapping')}} emap on
|
||||
emap.SourceTable in ('fw_dimEntity')
|
||||
and e.EntityID = emap.CLIENTENTITYID
|
||||
and emap.em_StrataID=$StrataID
|
||||
LEFT JOIN {{ref('Org_EntityMapping')}} dr1map on
|
||||
dr1map.SourceTable in ('fw_dimDepartment_DepartmentRollup1')
|
||||
and dd.DepartmentRollup1ID = dr1map.CLIENTENTITYID
|
||||
and dr1map.em_StrataID=$StrataID
|
||||
WHERE dt.CalendarYear >= $StartDate_CalendarYear
|
||||
and fm.FiscalMonthCode <> '0'
|
||||
and data.TimeClassCode = 'A'"",
|
||||
""targetTable"": ""GL_Initial_Stage"",
|
||||
""description"": ""Preaggregated FactGL stage"",
|
||||
""materializationType"": 1,
|
||||
""processId"": 161,
|
||||
""displayOrder"": 1,
|
||||
""clientQueries"": [],
|
||||
""queryTags"": [
|
||||
{
|
||||
""queryTagId"": 11100,
|
||||
""tagId"": 21,
|
||||
""queryId"": 2458
|
||||
}
|
||||
]
|
||||
}
|
||||
]";
|
||||
var query = JsonConvert.DeserializeObject<List<Query>>(json);
|
||||
Assert.DoesNotThrow(() => query.ToDirectedAcyclicGraph());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestFunctionalDAGReorder()
|
||||
{
|
||||
|
||||
var json = @"[
|
||||
{
|
||||
""queryId"": 2458,
|
||||
""queryText"": ""SELECT
|
||||
(CASE
|
||||
WHEN acct.isinverted = 1 THEN data.Value * -1
|
||||
ELSE data.Value
|
||||
END) AS Value,
|
||||
data.AccountID,
|
||||
data.FiscalYearCode,
|
||||
data.FiscalMonthCode,
|
||||
dt.CalendarYear,
|
||||
dt.CalendarMonth,
|
||||
dt.CalendarQuarter,
|
||||
data.TimeClassCode,
|
||||
acct.SPAccountRollupCategory,
|
||||
acct.SPAccountRollupName,
|
||||
acct.OBDollarsFinancialReporting,
|
||||
acct.OBDollarsFinancialReportingCategory,
|
||||
acct.OBDollarsFinancialReportingLineName,
|
||||
acct.DSSAccountRollup1Name,
|
||||
acct.Variability,
|
||||
dd.DepartmentID,
|
||||
dd.DepartmentCode,
|
||||
dd.DepartmentType,
|
||||
dd.IsMRPlan,
|
||||
dd.IsVariable,
|
||||
COALESCE(
|
||||
emap.CLIENTENTITYID,
|
||||
dr1map.CLIENTENTITYID,
|
||||
NULL
|
||||
) as ClientEntityID,
|
||||
COALESCE(
|
||||
emap.SPHEntityID,
|
||||
dr1map.SPHEntityID
|
||||
) as SPHEntityID,
|
||||
(CASE WHEN (acct.Variability=1 and dd.IsVariable=1) THEN '1' ELSE '0' END) AS SPHisVariableAcctDept,
|
||||
sphdr.Name as SPHDepartmentRollup,
|
||||
sphar.Category as SPHCategory,
|
||||
sphar.LineItem as SPHLineItem,
|
||||
sphar.Section as SPHSection,
|
||||
sphar.Statement as SPHStatement,
|
||||
$OrgPin as ORGPIN
|
||||
FROM int.FactGL data
|
||||
INNER JOIN fw.DimAccount acct ON acct.AccountID=data.AccountID
|
||||
INNER JOIN (SELECT distinct CalendarYear,CalendarMonth,CalendarQuarter,FiscalYear,FiscalMonth
|
||||
FROM fw.DimDate
|
||||
WHERE FiscalMonth != 0 or FiscalMonth != '0') dt on dt.FiscalYear=data.FiscalYearCode and dt.FiscalMonth=data.FiscalMonthCode
|
||||
INNER JOIN fw.DimDepartment dd ON dd.DepartmentID=data.DepartmentID
|
||||
INNER JOIN fw.DimFiscalMonth fm ON fm.FiscalMonthID=data.FiscalMonthID
|
||||
LEFT JOIN fw.DimEntity e on dd.EntityID=e.EntityID
|
||||
INNER JOIN fw.DimSPHDepartmentRollup as sphdr on sphdr.SPHDepartmentRollupID = dd.SPHDepartmentRollupID
|
||||
INNER JOIN fw.DimSPHAccountRollup as sphar on sphar.SPHAccountRollupID = acct.SPHAccountRollupID
|
||||
LEFT JOIN {{ref('Org_EntityMapping')}} emap on
|
||||
emap.SourceTable in ('fw_dimEntity')
|
||||
and e.EntityID = emap.CLIENTENTITYID
|
||||
and emap.em_StrataID=$StrataID
|
||||
LEFT JOIN {{ref('Org_EntityMapping')}} dr1map on
|
||||
dr1map.SourceTable in ('fw_dimDepartment_DepartmentRollup1')
|
||||
and dd.DepartmentRollup1ID = dr1map.CLIENTENTITYID
|
||||
and dr1map.em_StrataID=$StrataID
|
||||
WHERE dt.CalendarYear >= $StartDate_CalendarYear
|
||||
and fm.FiscalMonthCode <> '0'
|
||||
and data.TimeClassCode = 'A'"",
|
||||
""targetTable"": ""GL_Initial_Stage"",
|
||||
""description"": ""Preaggregated FactGL stage"",
|
||||
""materializationType"": 1,
|
||||
""processId"": 161,
|
||||
""displayOrder"": 1,
|
||||
""clientQueries"": [],
|
||||
""queryTags"": [
|
||||
{
|
||||
""queryTagId"": 11100,
|
||||
""tagId"": 21,
|
||||
""queryId"": 2458
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
""queryId"": 2058,
|
||||
""queryText"": ""SELECT sum(Value) as GLDollars, FiscalYearCode,FiscalMonthCode,CalendarYear,CalendarMonth,
|
||||
AccountID,DepartmentID,DepartmentCode,DepartmentType
|
||||
,ClientEntityID, SPHEntityID, SPHisVariableAcctDept
|
||||
,SPHDepartmentRollup,SPHCategory,SPHLineItem,SPHSection,SPHStatement,ORGPIN
|
||||
FROM {{ref('GL_Initial_Stage')}}
|
||||
WHERE FiscalMonthCode != 'Not Specified'
|
||||
GROUP BY FiscalYearCode,FiscalMonthCode,CalendarYear,CalendarMonth,AccountID
|
||||
,DepartmentID,DepartmentCode,DepartmentType,
|
||||
ClientEntityID,SPHEntityID,SPHisVariableAcctDept
|
||||
,SPHDepartmentRollup,SPHCategory,SPHLineItem,SPHSection,SPHStatement,ORGPIN"",
|
||||
""targetTable"": ""DepartmentGL"",
|
||||
""description"": ""sum GL dollars, final Dept GL table"",
|
||||
""materializationType"": 1,
|
||||
""processId"": 161,
|
||||
""displayOrder"": 2,
|
||||
""clientQueries"": [],
|
||||
""queryTags"": [
|
||||
{
|
||||
""queryTagId"": 11084,
|
||||
""tagId"": 21,
|
||||
""queryId"": 2058
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
""queryId"": 2059,
|
||||
""queryText"": ""select distinct
|
||||
entMap.SPHEntityID,
|
||||
entMap.ClientEntityID,
|
||||
entmap.SourceTable,
|
||||
entmap.StrataID as em_StrataID,
|
||||
entmap.ORGPIN
|
||||
from datalake_sandbox.config.Entity_MAPPING as entmap
|
||||
WHERE entmap.strataid = $StrataID
|
||||
and entmap.EntityType = 'GL'
|
||||
"",
|
||||
""targetTable"": ""Org_EntityMapping"",
|
||||
""description"": ""get entity mappings"",
|
||||
""materializationType"": 1,
|
||||
""processId"": 161,
|
||||
""displayOrder"": 0,
|
||||
""clientQueries"": [],
|
||||
""queryTags"": [
|
||||
{
|
||||
""queryTagId"": 11060,
|
||||
""tagId"": 21,
|
||||
""queryId"": 2059
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
""queryId"": 2454,
|
||||
""queryText"": ""SELECT DISTINCT
|
||||
/* Custom GL Dollars */
|
||||
CASE WHEN dgl.OrgPin in (2962) and dgl.AccountID in (1838, 1545, 1122, 1128) THEN GLDollars * -1
|
||||
WHEN dgl.OrgPin in (3120, 2980) and dgl.SPHCategory in ('Revenue Deduction') THEN GLDollars * -1
|
||||
WHEN dgl.OrgPin in (1170) and dgl.AccountID in (4809) THEN GLDollars * -1
|
||||
WHEN dgl.OrgPin in (1975) and dgl.AccountID in (7742) THEN GLDollars * -1
|
||||
WHEN dgl.OrgPin in (2724) and dgl.AccountID in (1346, 1394, 1395, 1443) THEN GLDollars * -1
|
||||
ELSE GLDollars END as GLDollars,
|
||||
FiscalYearCode,
|
||||
FiscalMonthCode,
|
||||
CalendarYear,
|
||||
CalendarMonth,
|
||||
dgl.AccountID,
|
||||
da.AccountCode,
|
||||
da.Description as GLDescription,
|
||||
dgl.DepartmentID,
|
||||
dgl.DepartmentCode,
|
||||
dgl.ClientEntityID,
|
||||
dgl.SPHisVariableAcctDept,
|
||||
dgl.SPHDepartmentRollup,
|
||||
dgl.SPHCategory,
|
||||
dgl.SPHLineItem,
|
||||
dgl.SPHSection,
|
||||
dgl.SPHStatement,
|
||||
dgl.DepartmentType,
|
||||
dgl.SPHEntityID,
|
||||
dgl.orgpin as orgpin_sys,
|
||||
CASE WHEN dd.SPHDEPARTMENTROLLUPCONFIDENCESCORE=1 THEN 1 ELSE 0 END AS IsValidatedSPHDepartmentRollup,
|
||||
CASE WHEN da.SPHACCOUNTROLLUPCONFIDENCESCORE=1 THEN 1 ELSE 0 END AS IsValidatedSPHLineItem
|
||||
FROM {{ref('DepartmentGL')}} dgl
|
||||
LEFT JOIN FW.DIMACCOUNT da ON dgl.AccountID=da.AccountID
|
||||
LEFT JOIN FW.DIMDEPARTMENT dd ON dgl.DepartmentID=dd.DepartmentID"",
|
||||
""targetTable"": ""Gl_DEPARTMENTGL_stage"",
|
||||
""description"": ""custom GL Dollar, DepartmentType"",
|
||||
""materializationType"": 1,
|
||||
""processId"": 161,
|
||||
""displayOrder"": 3,
|
||||
""clientQueries"": [],
|
||||
""queryTags"": [
|
||||
{
|
||||
""queryTagId"": 11080,
|
||||
""tagId"": 21,
|
||||
""queryId"": 2454
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
""queryId"": 2455,
|
||||
""queryText"": ""SELECT gl.*
|
||||
FROM {{ref('Gl_DEPARTMENTGL_stage')}} as gl inner join DATALAKE_SANDBOX.CONFIG.SYSTEM_CRITERIA as s on s.orgpin = gl.orgpin_sys
|
||||
WHERE
|
||||
/* DATA TO BE FILTERED OUT */
|
||||
(s.orgpin = 1178 AND gl.AccountID IN (13238,13239,13461,14102,13240,13241,13242,
|
||||
13236,13237,13243,14722,15227))
|
||||
OR (s.orgpin = 3120 AND gl.AccountID IN (97))
|
||||
OR (s.orgpin = 3196 AND gl.AccountID IN (1031))
|
||||
OR ( s.orgpin = 2973 AND gl.AccountID IN (485, 486, 488, 490, 493, 494, 1901, 1909))
|
||||
OR ( s.orgpin = 3167 AND gl.AccountID IN (257,7369))
|
||||
OR ( s.orgpin = 2951 AND gl.AccountID IN (247))
|
||||
OR ( s.orgpin = 2717 AND gl.AccountID IN (7))
|
||||
OR ( s.orgpin = 3109 AND gl.AccountID IN (1352))
|
||||
OR ( s.orgpin = 3113 AND gl.AccountID IN (70272))
|
||||
OR ( s.orgpin = 3157 AND gl.AccountID IN (20415))
|
||||
OR ( s.orgpin = 3202 AND gl.AccountID IN (4085, 2984))
|
||||
OR ( s.orgpin = 1975 and (
|
||||
(AccountID IN (734) and gl.ClientEntityID=17 /*SYSTEM SERVICES Entity*/) or
|
||||
(AccountCode like '%0090%' or GLDescription like 'SS-%') or
|
||||
(AccountID IN (2310, 2313, 2318,2319, 2320, 2321, 2322, 2324, 2328, 2294,
|
||||
2295, 2296, 2298, 2299, 2302, 5832, 2306, 3284, 3286, 3287, 3288, 3290, 12434, 3295,
|
||||
3297, 5838, 2291, 5841, 16174, 16873, 16874, 16875, 16876, 16877, 16879, 13349,
|
||||
22261, 22256, 22309, 22288, 22270, 22280, 22513, 23954, 22291, 22301, 22294, 22264,
|
||||
22353,22283, 22308, 22297, 23082, 22282, 22278, 22292, 22281, 22277, 22510, 23083,
|
||||
12327, 23950, 12957, 20308, 25753, 16306, 12963, 11391, 16992, 14101, 14304, 16993,
|
||||
17213, 14333, 13749, 973, 974, 975, 976, 977, 978, 983, 1041, 2672, 3576, 12448,
|
||||
12793, 12798, 19985, 21969))
|
||||
))
|
||||
OR ( s.orgpin = 1137 AND CalendarYear= 2021 and CalendarMonth = 4 AND gl.AccountID IN (613))
|
||||
OR ( s.orgpin = 3179 AND gl.AccountID IN (9828))
|
||||
OR ( s.orgpin = 3228 AND gl.AccountID IN (778))
|
||||
OR ( s.orgpin = 3266 AND gl.AccountID IN (518))
|
||||
OR ( s.orgpin = 1475 AND gl.DepartmentCode IN ('1.10201199'))
|
||||
OR ( s.orgpin = 3196 AND gl.AccountID IN (517) and DepartmentCode IN ('01.9000'))
|
||||
OR ( s.orgpin = 2052 and CalendarYear = 2021 and CalendarMonth = 6 AND gl.AccountID IN (710, 711, 712))"",
|
||||
""targetTable"": ""Gl_DEPARTMENTGL_stage_filter"",
|
||||
""description"": ""data to be filtered out via customizations"",
|
||||
""materializationType"": 1,
|
||||
""processId"": 161,
|
||||
""displayOrder"": 4,
|
||||
""clientQueries"": [],
|
||||
""queryTags"": [
|
||||
{
|
||||
""queryTagId"": 11066,
|
||||
""tagId"": 21,
|
||||
""queryId"": 2455
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
""queryId"": 2456,
|
||||
""queryText"": ""select
|
||||
s.*
|
||||
from {{ref('Gl_DEPARTMENTGL_stage')}} as s
|
||||
except (
|
||||
select *
|
||||
from {{ref('Gl_DEPARTMENTGL_stage_filter')}}
|
||||
)"",
|
||||
""targetTable"": ""GL_Summary_Stage"",
|
||||
""description"": ""Handle custom exclusions - last step before data is ready"",
|
||||
""materializationType"": 1,
|
||||
""processId"": 161,
|
||||
""displayOrder"": 5,
|
||||
""clientQueries"": [],
|
||||
""queryTags"": [
|
||||
{
|
||||
""queryTagId"": 11076,
|
||||
""tagId"": 21,
|
||||
""queryId"": 2456
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
""queryId"": 2457,
|
||||
""queryText"": ""SELECT
|
||||
AccountID,
|
||||
CalendarMonth,
|
||||
CalendarYear,
|
||||
ClientEntityID,
|
||||
DepartmentCode,
|
||||
DepartmentID,
|
||||
DepartmentType,
|
||||
FiscalMonthCode,
|
||||
FiscalYearCode,
|
||||
GLDollars,
|
||||
IsValidatedSPHDepartmentRollup,
|
||||
IsValidatedSPHLineItem,
|
||||
SPHCategory,
|
||||
SPHDepartmentRollup,
|
||||
SPHEntityID,
|
||||
SPHisVariableAcctDept,
|
||||
SPHLineItem,
|
||||
SPHSection,
|
||||
SPHStatement
|
||||
FROM {{ref('GL_Summary_Stage')}}"",
|
||||
""targetTable"": ""GL_Summary"",
|
||||
""description"": ""Final output of GL Datamart"",
|
||||
""materializationType"": 0,
|
||||
""processId"": 161,
|
||||
""displayOrder"": 6,
|
||||
""clientQueries"": [],
|
||||
""queryTags"": [
|
||||
{
|
||||
""queryTagId"": 11081,
|
||||
""tagId"": 21,
|
||||
""queryId"": 2457
|
||||
}
|
||||
]
|
||||
}
|
||||
]";
|
||||
var query = JsonConvert.DeserializeObject<List<Query>>(json);
|
||||
Assert.DoesNotThrow(() => query.ToDirectedAcyclicGraph());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
using NUnit.Framework;
|
||||
using Strata.Stratasphere.Biz.Standards;
|
||||
using Strata.Stratasphere.Biz.Standards.Commands;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using FluentAssertions;
|
||||
using System.Collections;
|
||||
using Microsoft.EntityFrameworkCore.Query.SqlExpressions;
|
||||
|
||||
namespace Strata.Stratasphere.Biz.UnitTests.Standards
|
||||
{
|
||||
[TestFixture]
|
||||
public class HACQueryDefinitionUnitTests
|
||||
{
|
||||
private static IEnumerable<TestCaseData> GetHacTestCases(string testName)
|
||||
{
|
||||
yield return new TestCaseData("HAC01", true, false).SetName($"{testName}.HAC01, IsDX = true, IsPx = false");
|
||||
yield return new TestCaseData("HAC02", true, false).SetName($"{testName}.HAC02, IsDX = true, IsPx = false");
|
||||
yield return new TestCaseData("HAC03", true, false).SetName($"{testName}.HAC03, IsDX = true, IsPx = false");
|
||||
yield return new TestCaseData("HAC04", true, false).SetName($"{testName}.HAC04, IsDX = true, IsPx = false");
|
||||
yield return new TestCaseData("HAC05", true, false).SetName($"{testName}.HAC05, IsDX = true, IsPx = false)");
|
||||
yield return new TestCaseData("HAC06", true, false).SetName($"{testName}.HAC06, IsDX = true, IsPx = false");
|
||||
yield return new TestCaseData("HAC07", true, false).SetName($"{testName}.HAC07, IsDX = true, IsPx = false");
|
||||
yield return new TestCaseData("HAC08", true, true).SetName($"{testName}.HAC08, IsDX = true, IsPx = true");
|
||||
yield return new TestCaseData("HAC09", true, false).SetName($"{testName}.HAC09, IsDX = true, IsPx = false");
|
||||
yield return new TestCaseData("HAC10", true, true).SetName($"{testName}.HAC10, IsDX = true, IsPx = true");
|
||||
yield return new TestCaseData("HAC11", true, true).SetName($"{testName}.HAC11, IsDX = true, IsPx = true");
|
||||
yield return new TestCaseData("HAC12", true, true).SetName($"{testName}.HAC12, IsDX = true, IsPx = true");
|
||||
yield return new TestCaseData("HAC13", true, true).SetName($"{testName}.HAC13, IsDX = true, IsPx = true");
|
||||
yield return new TestCaseData("HAC14", true, true).SetName($"{testName}.HAC14, IsDX = true, IsPx = true");
|
||||
}
|
||||
|
||||
[Test, TestCaseSource("GetHacTestCases", new object[] { "Full Refresh" })]
|
||||
public void Test(string hacCmd, bool isDx, bool isPx)
|
||||
{
|
||||
//Creates an instance of the type from the name of the hac command
|
||||
var cmd = Activator.CreateInstance("Strata.Stratasphere.Biz", $"Strata.Stratasphere.Biz.Standards.Commands.{hacCmd}Command").Unwrap() as HACsBaseCommand;
|
||||
cmd.Query.Should().Contain("DSSPES")
|
||||
.And.Contain($@"INSERT INTO SPH.ENCOUNTERHACS (ENCOUNTERID, HAC)
|
||||
SELECT DISTINCT DSSPES.ENCOUNTERID, '{hacCmd}'
|
||||
FROM CLIENTDSS.FACTPATIENTENCOUNTERSUMMARY DSSPES
|
||||
INNER JOIN SPH.ENCOUNTERPATIENTTYPE PT ON PT.ENCOUNTERID = DSSPES.ENCOUNTERID");
|
||||
if (isDx)
|
||||
{
|
||||
|
||||
cmd.Query.Should().Contain(@"INNER JOIN DSS.FACTPATIENTICD10DIAGNOSTICDETAIL PATICD10DX ON PATICD10DX.ENCOUNTERID = DSSPES.ENCOUNTERID
|
||||
INNER JOIN DSS.DIMICD10DX ICD10DX ON PATICD10DX.ICD10DXID = ICD10DX.ICD10DXID
|
||||
INNER JOIN CLIENTDSS.DIMPRESENTONADMISSION PRESENTONADMISSION ON PATICD10DX.PRESENTONADMISSIONID = PRESENTONADMISSION.PRESENTONADMISSIONID
|
||||
INNER JOIN DSS.DIMSPHPRESENTONADMISSIONROLLUP SPHPOA ON SPHPOA.SPHPRESENTONADMISSIONROLLUPID = PRESENTONADMISSION.SPHPRESENTONADMISSIONROLLUPID").
|
||||
And.Contain(@"PATICD10DX.SEQUENCENUMBERID <> 1
|
||||
AND
|
||||
SPHPOA.SPHPRESENTONADMISSIONROLLUPCODE IN ('1', 'N', 'U', 'W')
|
||||
AND ICD10DX.ICD10DXCODENODECIMAL IN ");
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd.Query.Should().NotContain(@"INNER JOIN DSS.FACTPATIENTICD10DIAGNOSTICDETAIL PATICD10DX ON PATICD10DX.ENCOUNTERID = DSSPES.ENCOUNTERID
|
||||
INNER JOIN DSS.DIMICD10DX ICD10DX ON PATICD10DX.ICD10DXID = ICD10DX.ICD10DXID
|
||||
INNER JOIN CLIENTDSS.DIMPRESENTONADMISSION PRESENTONADMISSION ON PATICD10DX.PRESENTONADMISSIONID = PRESENTONADMISSION.PRESENTONADMISSIONID
|
||||
INNER JOIN DSS.DIMSPHPRESENTONADMISSIONROLLUP SPHPOA ON SPHPOA.SPHPRESENTONADMISSIONROLLUPID = PRESENTONADMISSION.SPHPRESENTONADMISSIONROLLUPID").
|
||||
And.NotContain(@" PATICD10DX.SEQUENCENUMBERID <> 1
|
||||
AND
|
||||
SPHPOA.SPHPRESENTONADMISSIONROLLUPCODE IN ('1', 'N', 'U', 'W')
|
||||
AND ICD10DX.ICD10DXCODENODECIMAL IN ");
|
||||
}
|
||||
if (isPx)
|
||||
{
|
||||
cmd.Query.Should().Contain(@"INNER JOIN DSS.FACTPATIENTICD10PROCEDURALDETAIL PATICD10PX ON PATICD10PX.ENCOUNTERID = DSSPES.ENCOUNTERID
|
||||
INNER JOIN DSS.DIMICD10PX ICD10PX ON PATICD10PX.ICD10PXID = ICD10PX.ICD10PXID").
|
||||
And.Contain(@" AND ICD10PX.ICD10PXCODENODECIMAL IN ");
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd.Query.Should().NotContain(@"INNER JOIN DSS.FACTPATIENTICD10PROCEDURALDETAIL PATICD10PX ON PATICD10PX.ENCOUNTERID = DSSPES.ENCOUNTERID
|
||||
INNER JOIN DSS.DIMICD10PX ICD10PX ON PATICD10PX.ICD10PXID = ICD10PX.ICD10PXID").
|
||||
And.NotContain(@" AND ICD10PX.ICD10PXCODENODECIMAL IN ");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Test, TestCaseSource("GetHacTestCases", new object[] { "Encounter List" })]
|
||||
public void TestMasterEncounterList(string hacCmd, bool isDx, bool isPx)
|
||||
{
|
||||
var sessionId = Guid.NewGuid().ToString("N");
|
||||
var mel = new MasterEncounterListDto()
|
||||
{
|
||||
ClientDbGuid = Guid.NewGuid(),
|
||||
MasterEncounterListTableName = $"DSS.MASTERENCOUNTERLIST_{sessionId}",
|
||||
SessionId = sessionId
|
||||
};
|
||||
var cmd = Activator.CreateInstance("Strata.Stratasphere.Biz", $"Strata.Stratasphere.Biz.Standards.Commands.{hacCmd}Command", false, System.Reflection.BindingFlags.Default, null, new object[]{ mel.MasterEncounterListTableName }, null, null).Unwrap() as HACsBaseCommand;
|
||||
|
||||
cmd.Query.Should().Contain("DSSPES").
|
||||
And.Contain($@"INSERT INTO SPH.ENCOUNTERHACS (ENCOUNTERID, HAC)")
|
||||
.And.Contain($"SELECT DISTINCT DSSPES.ENCOUNTERID, '{hacCmd}'")
|
||||
.And.Contain($"FROM CLIENTDSS.FACTPATIENTENCOUNTERSUMMARY DSSPES")
|
||||
.And.Contain($"INNER JOIN SPH.ENCOUNTERPATIENTTYPE PT ON PT.ENCOUNTERID = DSSPES.ENCOUNTERID")
|
||||
.And.Contain($"INNER JOIN {mel.MasterEncounterListTableName} MEL ON MEL.ENCOUNTERID = DSSPES.ENCOUNTERID");
|
||||
if (isDx)
|
||||
{
|
||||
cmd.Query.Should().Contain(@"INNER JOIN DSS.FACTPATIENTICD10DIAGNOSTICDETAIL PATICD10DX ON PATICD10DX.ENCOUNTERID = DSSPES.ENCOUNTERID
|
||||
INNER JOIN DSS.DIMICD10DX ICD10DX ON PATICD10DX.ICD10DXID = ICD10DX.ICD10DXID
|
||||
INNER JOIN CLIENTDSS.DIMPRESENTONADMISSION PRESENTONADMISSION ON PATICD10DX.PRESENTONADMISSIONID = PRESENTONADMISSION.PRESENTONADMISSIONID
|
||||
INNER JOIN DSS.DIMSPHPRESENTONADMISSIONROLLUP SPHPOA ON SPHPOA.SPHPRESENTONADMISSIONROLLUPID = PRESENTONADMISSION.SPHPRESENTONADMISSIONROLLUPID").
|
||||
And.Contain(@"PATICD10DX.SEQUENCENUMBERID <> 1
|
||||
AND
|
||||
SPHPOA.SPHPRESENTONADMISSIONROLLUPCODE IN ('1', 'N', 'U', 'W')
|
||||
AND ICD10DX.ICD10DXCODENODECIMAL IN ");
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd.Query.Should().NotContain(@"INNER JOIN DSS.FACTPATIENTICD10DIAGNOSTICDETAIL PATICD10DX ON PATICD10DX.ENCOUNTERID = DSSPES.ENCOUNTERID
|
||||
INNER JOIN DSS.DIMICD10DX ICD10DX ON PATICD10DX.ICD10DXID = ICD10DX.ICD10DXID
|
||||
INNER JOIN CLIENTDSS.DIMPRESENTONADMISSION PRESENTONADMISSION ON PATICD10DX.PRESENTONADMISSIONID = PRESENTONADMISSION.PRESENTONADMISSIONID
|
||||
INNER JOIN DSS.DIMSPHPRESENTONADMISSIONROLLUP SPHPOA ON SPHPOA.SPHPRESENTONADMISSIONROLLUPID = PRESENTONADMISSION.SPHPRESENTONADMISSIONROLLUPID").
|
||||
And.NotContain(@" PATICD10DX.SEQUENCENUMBERID <> 1
|
||||
AND
|
||||
AND ICD10DX.ICD10DXCODENODECIMAL IN ");
|
||||
}
|
||||
if (isPx)
|
||||
{
|
||||
cmd.Query.Should().Contain(@"INNER JOIN DSS.FACTPATIENTICD10DIAGNOSTICDETAIL PATICD10DX ON PATICD10DX.ENCOUNTERID = DSSPES.ENCOUNTERID
|
||||
INNER JOIN DSS.DIMICD10DX ICD10DX ON PATICD10DX.ICD10DXID = ICD10DX.ICD10DXID").
|
||||
And.Contain(@" AND ICD10PX.ICD10PXCODENODECIMAL IN ");
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd.Query.Should().NotContain(@"INNER JOIN DSS.FACTPATIENTICD10PROCEDURALDETAIL PATICD10PX ON PATICD10PX.ENCOUNTERID = DSSPES.ENCOUNTERID
|
||||
INNER JOIN DSS.DIMICD10PX ICD10PX ON PATICD10PX.ICD10PXID = ICD10PX.ICD10PXID").
|
||||
And.NotContain(@" AND ICD10PX.ICD10PXCODENODECIMAL IN ");
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSpecialCaseForHAC11()
|
||||
{
|
||||
var hac11 = new HAC11Command();
|
||||
hac11.Query.Should().Contain("INNER JOIN DSS.DIMICD10DX PRIMARYDX ON PRIMARYDX.ICD10DXID = DSSPES.ICD10DXPRIMARYDIAGID");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="AutoMapperTests.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AWSSDK.SecurityToken" Version="3.7.100.21" />
|
||||
<PackageReference Include="FluentAssertions" Version="6.8.0" />
|
||||
<PackageReference Include="Hangfire.MemoryStorage" Version="1.7.0" />
|
||||
<PackageReference Include="Hangfire.NetCore" Version="1.7.31" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.10">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Moq" Version="4.18.2" />
|
||||
<PackageReference Include="NUnit" Version="3.13.3" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="4.3.0" />
|
||||
<PackageReference Include="coverlet.msbuild" Version="3.2.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
|
||||
<PackageReference Include="Strata.ApiLib.Core" Version="5.2.0" />
|
||||
<PackageReference Include="Strata.Configuration.Client" Version="8.17.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Strata.Stratasphere.Biz\Strata.Stratasphere.Biz.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="appsettings.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Debug",
|
||||
"System": "Information",
|
||||
"Microsoft": "Information"
|
||||
}
|
||||
},
|
||||
|
||||
"Snowflake": {
|
||||
"Url": "https://stratadev.us-east-1.privatelink.snowflakecomputing.com",
|
||||
"Account": "stratadev",
|
||||
"RoleName": "DATAADMIN",
|
||||
"Warehouse": "DATA_ANALYSIS_WH",
|
||||
"StandardsWarehouseSize": "XSMALL",
|
||||
"StandardsWarehouseMaxClusterSize": "1",
|
||||
"StandardsWarehouse": "STANDARDS_WH",
|
||||
"AdminRoleName": "DEVADMIN",
|
||||
"SphCoreRoleName": "SPHCORE"
|
||||
},
|
||||
|
||||
|
||||
"aws": {
|
||||
"masterEncounterListSQSQueueName": "sdt-masterencounterlist-queue",
|
||||
"snowflakeAdminSecretName": "stratareplication/snowflake/automation/connectionstring"
|
||||
},
|
||||
|
||||
"s3": {
|
||||
"bucketName": "sdt-dev-data-wrangler"
|
||||
},
|
||||
|
||||
"configuration": {
|
||||
"basicAuthUsername": "BkQsRDdmdjkFNhKVuTI.TpujQJXuKhGDcV.F_hjADMRTaEUWMJnviaesoOrhhfnz",
|
||||
"basicAuthPassword": "GWPIIWECDqh.hjDNdpxVEfeFe-bYFwPSx-oBGFD_od_SUQVk-QqTIkZY_NXMeqeo"
|
||||
},
|
||||
|
||||
"StrataConfigServerBaseUrl": "https://configuration.dev.stratanetwork.net"
|
||||
}
|
||||
Reference in New Issue
Block a user